nv50_context.h revision c0ed6a871cd3513e17a1fab960f5626485ffed13
1a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#ifndef __NV50_CONTEXT_H__
2a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define __NV50_CONTEXT_H__
3a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
4a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "pipe/p_context.h"
5a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "pipe/p_defines.h"
6a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "pipe/p_state.h"
7a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
8a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "draw/draw_vertex.h"
9a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
10a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "nouveau/nouveau_winsys.h"
11a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "nouveau/nouveau_gldefs.h"
12a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "nouveau/nouveau_stateobj.h"
13a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
14a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
15a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nv50_screen *ctx = nv50->screen
16a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "nouveau/nouveau_push.h"
17a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
18a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "nv50_screen.h"
19a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "nv50_program.h"
20a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
21a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NOUVEAU_ERR(fmt, args...) \
22a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	fprintf(stderr, "%s:%d -  "fmt, __func__, __LINE__, ##args);
23a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NOUVEAU_MSG(fmt, args...) \
24a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	fprintf(stderr, "nouveau: "fmt, ##args);
25a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
26a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch/* Constant buffer assignment */
27a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_CB_PMISC		0
28a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_CB_PVP		1
29a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_CB_PFP		2
30a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_CB_PGP		3
31a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_CB_TIC		4
32a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_CB_TSC		5
33a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
34a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_BLEND		(1 << 0)
35a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_ZSA		(1 << 1)
36a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_BLEND_COLOUR	(1 << 2)
37a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_STIPPLE	(1 << 3)
38a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_SCISSOR	(1 << 4)
39a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_VIEWPORT	(1 << 5)
40a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_RASTERIZER	(1 << 6)
41a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_FRAMEBUFFER	(1 << 7)
42a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_VERTPROG	(1 << 8)
43a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_VERTPROG_CB	(1 << 9)
44a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_FRAGPROG	(1 << 10)
45a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_FRAGPROG_CB	(1 << 11)
46a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_ARRAYS		(1 << 12)
47a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_SAMPLER	(1 << 13)
48a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#define NV50_NEW_TEXTURE	(1 << 14)
49a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
50a3f7b4e666c476898878fa745f637129375cd889Ben Murdochstruct nv50_blend_stateobj {
51a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_blend_state pipe;
52a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nouveau_stateobj *so;
53a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch};
54a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
55a3f7b4e666c476898878fa745f637129375cd889Ben Murdochstruct nv50_zsa_stateobj {
560f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)	struct pipe_depth_stencil_alpha_state pipe;
57a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nouveau_stateobj *so;
58a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch};
59a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
60a3f7b4e666c476898878fa745f637129375cd889Ben Murdochstruct nv50_rasterizer_stateobj {
61a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_rasterizer_state pipe;
62a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nouveau_stateobj *so;
63a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch};
64a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
65a3f7b4e666c476898878fa745f637129375cd889Ben Murdochstruct nv50_miptree {
66a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_texture base;
67a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_buffer *buffer;
68a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch};
69a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
70a3f7b4e666c476898878fa745f637129375cd889Ben Murdochstatic INLINE struct nv50_miptree *
71a3f7b4e666c476898878fa745f637129375cd889Ben Murdochnv50_miptree(struct pipe_texture *pt)
72a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch{
73a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	return (struct nv50_miptree *)pt;
74a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch}
75a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)struct nv50_context {
771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	struct pipe_context pipe;
78a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
79a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nv50_screen *screen;
8058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)	unsigned pctx_id;
81f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
82a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct draw_context *draw;
83a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
84a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	unsigned dirty;
85a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nv50_blend_stateobj *blend;
86a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nv50_zsa_stateobj *zsa;
87a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nv50_rasterizer_stateobj *rasterizer;
88a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_blend_color blend_colour;
89a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_poly_stipple stipple;
90a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_scissor_state scissor;
91a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_viewport_state viewport;
92a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_framebuffer_state framebuffer;
93a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nv50_program *vertprog;
94a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nv50_program *fragprog;
95a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
96a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
97a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	unsigned vtxbuf_nr;
98a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
99a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	unsigned vtxelt_nr;
100a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	unsigned *sampler[PIPE_MAX_SAMPLERS];
101a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	unsigned sampler_nr;
102a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	struct nv50_miptree *miptree[PIPE_MAX_SAMPLERS];
103a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	unsigned miptree_nr;
104a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch};
105a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
106a3f7b4e666c476898878fa745f637129375cd889Ben Murdochstatic INLINE struct nv50_context *
107a3f7b4e666c476898878fa745f637129375cd889Ben Murdochnv50_context(struct pipe_context *pipe)
108a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch{
109a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch	return (struct nv50_context *)pipe;
110a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch}
111a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
112a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_init_surface_functions(struct nv50_context *nv50);
113a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_init_state_functions(struct nv50_context *nv50);
114a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_init_query_functions(struct nv50_context *nv50);
115a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
116a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_screen_init_miptree_functions(struct pipe_screen *pscreen);
117a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
118a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch/* nv50_draw.c */
119a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50);
120a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
121a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch/* nv50_vbo.c */
122a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern boolean nv50_draw_arrays(struct pipe_context *, unsigned mode,
123a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch				unsigned start, unsigned count);
124a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern boolean nv50_draw_elements(struct pipe_context *pipe,
125a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch				  struct pipe_buffer *indexBuffer,
126a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch				  unsigned indexSize,
127a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch				  unsigned mode, unsigned start,
128a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch				  unsigned count);
129a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_vbo_validate(struct nv50_context *nv50);
130a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
131a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch/* nv50_clear.c */
132a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps,
133a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch		       unsigned clearValue);
134a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
135a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch/* nv50_program.c */
136a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_vertprog_validate(struct nv50_context *nv50);
137a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_fragprog_validate(struct nv50_context *nv50);
138a3f7b4e666c476898878fa745f637129375cd889Ben Murdochextern void nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p);
139a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
140a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch/* nv50_state_validate.c */
1410f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)extern boolean nv50_state_validate(struct nv50_context *nv50);
142a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
143a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#endif
144a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch