1 #ifndef __NV50_CONTEXT_H__
2 #define __NV50_CONTEXT_H__
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
7 #include "pipe/p_compiler.h"
9 #include "util/u_memory.h"
10 #include "util/u_math.h"
12 #include "draw/draw_vertex.h"
14 #include "nouveau/nouveau_winsys.h"
15 #include "nouveau/nouveau_gldefs.h"
16 #include "nouveau/nouveau_stateobj.h"
18 #define NOUVEAU_PUSH_CONTEXT(ctx) \
19 struct nv50_screen *ctx = nv50->screen
20 #include "nouveau/nouveau_push.h"
22 #include "nv50_screen.h"
23 #include "nv50_program.h"
25 #define NOUVEAU_ERR(fmt, args...) \
26 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
27 #define NOUVEAU_MSG(fmt, args...) \
28 fprintf(stderr, "nouveau: "fmt, ##args);
30 /* Constant buffer assignment */
31 #define NV50_CB_PMISC 0
37 #define NV50_CB_PUPLOAD 6
39 #define NV50_NEW_BLEND (1 << 0)
40 #define NV50_NEW_ZSA (1 << 1)
41 #define NV50_NEW_BLEND_COLOUR (1 << 2)
42 #define NV50_NEW_STIPPLE (1 << 3)
43 #define NV50_NEW_SCISSOR (1 << 4)
44 #define NV50_NEW_VIEWPORT (1 << 5)
45 #define NV50_NEW_RASTERIZER (1 << 6)
46 #define NV50_NEW_FRAMEBUFFER (1 << 7)
47 #define NV50_NEW_VERTPROG (1 << 8)
48 #define NV50_NEW_VERTPROG_CB (1 << 9)
49 #define NV50_NEW_FRAGPROG (1 << 10)
50 #define NV50_NEW_FRAGPROG_CB (1 << 11)
51 #define NV50_NEW_ARRAYS (1 << 12)
52 #define NV50_NEW_SAMPLER (1 << 13)
53 #define NV50_NEW_TEXTURE (1 << 14)
55 struct nv50_blend_stateobj
{
56 struct pipe_blend_state pipe
;
57 struct nouveau_stateobj
*so
;
60 struct nv50_zsa_stateobj
{
61 struct pipe_depth_stencil_alpha_state pipe
;
62 struct nouveau_stateobj
*so
;
65 struct nv50_rasterizer_stateobj
{
66 struct pipe_rasterizer_state pipe
;
67 struct nouveau_stateobj
*so
;
70 struct nv50_miptree_level
{
71 struct pipe_buffer
**image
;
73 unsigned image_dirty_cpu
;
74 unsigned image_dirty_gpu
;
78 struct pipe_texture base
;
79 struct pipe_buffer
*buffer
;
81 struct nv50_miptree_level level
[PIPE_MAX_TEXTURE_LEVELS
];
86 static INLINE
struct nv50_miptree
*
87 nv50_miptree(struct pipe_texture
*pt
)
89 return (struct nv50_miptree
*)pt
;
93 struct pipe_surface base
;
94 struct pipe_buffer
*untiled
;
97 static INLINE
struct nv50_surface
*
98 nv50_surface(struct pipe_surface
*pt
)
100 return (struct nv50_surface
*)pt
;
106 struct nouveau_stateobj
*fb
;
107 struct nouveau_stateobj
*blend
;
108 struct nouveau_stateobj
*blend_colour
;
109 struct nouveau_stateobj
*zsa
;
110 struct nouveau_stateobj
*rast
;
111 struct nouveau_stateobj
*stipple
;
112 struct nouveau_stateobj
*scissor
;
113 unsigned scissor_enabled
;
114 struct nouveau_stateobj
*viewport
;
115 unsigned viewport_bypass
;
116 struct nouveau_stateobj
*tsc_upload
;
117 struct nouveau_stateobj
*tic_upload
;
118 struct nouveau_stateobj
*vertprog
;
119 struct nouveau_stateobj
*fragprog
;
120 struct nouveau_stateobj
*vtxfmt
;
121 struct nouveau_stateobj
*vtxbuf
;
124 struct nv50_context
{
125 struct pipe_context pipe
;
127 struct nv50_screen
*screen
;
130 struct draw_context
*draw
;
132 struct nv50_state state
;
135 struct nv50_blend_stateobj
*blend
;
136 struct nv50_zsa_stateobj
*zsa
;
137 struct nv50_rasterizer_stateobj
*rasterizer
;
138 struct pipe_blend_color blend_colour
;
139 struct pipe_poly_stipple stipple
;
140 struct pipe_scissor_state scissor
;
141 struct pipe_viewport_state viewport
;
142 struct pipe_framebuffer_state framebuffer
;
143 struct nv50_program
*vertprog
;
144 struct nv50_program
*fragprog
;
145 struct pipe_buffer
*constbuf
[PIPE_SHADER_TYPES
];
146 struct pipe_vertex_buffer vtxbuf
[PIPE_MAX_ATTRIBS
];
148 struct pipe_vertex_element vtxelt
[PIPE_MAX_ATTRIBS
];
150 unsigned *sampler
[PIPE_MAX_SAMPLERS
];
152 struct nv50_miptree
*miptree
[PIPE_MAX_SAMPLERS
];
156 static INLINE
struct nv50_context
*
157 nv50_context(struct pipe_context
*pipe
)
159 return (struct nv50_context
*)pipe
;
162 extern void nv50_init_surface_functions(struct nv50_context
*nv50
);
163 extern void nv50_init_state_functions(struct nv50_context
*nv50
);
164 extern void nv50_init_query_functions(struct nv50_context
*nv50
);
166 extern void nv50_screen_init_miptree_functions(struct pipe_screen
*pscreen
);
169 extern struct draw_stage
*nv50_draw_render_stage(struct nv50_context
*nv50
);
172 extern boolean
nv50_draw_arrays(struct pipe_context
*, unsigned mode
,
173 unsigned start
, unsigned count
);
174 extern boolean
nv50_draw_elements(struct pipe_context
*pipe
,
175 struct pipe_buffer
*indexBuffer
,
177 unsigned mode
, unsigned start
,
179 extern void nv50_vbo_validate(struct nv50_context
*nv50
);
182 extern void nv50_clear(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
183 unsigned clearValue
);
186 extern void nv50_vertprog_validate(struct nv50_context
*nv50
);
187 extern void nv50_fragprog_validate(struct nv50_context
*nv50
);
188 extern void nv50_program_destroy(struct nv50_context
*nv50
, struct nv50_program
*p
);
190 /* nv50_state_validate.c */
191 extern boolean
nv50_state_validate(struct nv50_context
*nv50
);
194 extern void nv50_tex_validate(struct nv50_context
*);