1 #ifndef __NV30_CONTEXT_H__
2 #define __NV30_CONTEXT_H__
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
8 #include "draw/draw_vertex.h"
10 #include "nouveau/nouveau_winsys.h"
11 #include "nouveau/nouveau_gldefs.h"
13 #define NOUVEAU_PUSH_CONTEXT(ctx) \
14 struct nv30_screen *ctx = nv30->screen
15 #include "nouveau/nouveau_push.h"
16 #include "nouveau/nouveau_stateobj.h"
18 #include "nv30_state.h"
20 #define NOUVEAU_ERR(fmt, args...) \
21 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
22 #define NOUVEAU_MSG(fmt, args...) \
23 fprintf(stderr, "nouveau: "fmt, ##args);
25 enum nv30_state_index
{
27 NV30_STATE_VIEWPORT
= 1,
33 NV30_STATE_SCISSOR
= 7,
34 NV30_STATE_STIPPLE
= 8,
35 NV30_STATE_FRAGPROG
= 9,
36 NV30_STATE_VERTPROG
= 10,
37 NV30_STATE_FRAGTEX0
= 11,
38 NV30_STATE_FRAGTEX1
= 12,
39 NV30_STATE_FRAGTEX2
= 13,
40 NV30_STATE_FRAGTEX3
= 14,
41 NV30_STATE_FRAGTEX4
= 15,
42 NV30_STATE_FRAGTEX5
= 16,
43 NV30_STATE_FRAGTEX6
= 17,
44 NV30_STATE_FRAGTEX7
= 18,
45 NV30_STATE_FRAGTEX8
= 19,
46 NV30_STATE_FRAGTEX9
= 20,
47 NV30_STATE_FRAGTEX10
= 21,
48 NV30_STATE_FRAGTEX11
= 22,
49 NV30_STATE_FRAGTEX12
= 23,
50 NV30_STATE_FRAGTEX13
= 24,
51 NV30_STATE_FRAGTEX14
= 25,
52 NV30_STATE_FRAGTEX15
= 26,
53 NV30_STATE_VERTTEX0
= 27,
54 NV30_STATE_VERTTEX1
= 28,
55 NV30_STATE_VERTTEX2
= 29,
56 NV30_STATE_VERTTEX3
= 30,
57 NV30_STATE_VTXBUF
= 31,
58 NV30_STATE_VTXFMT
= 32,
59 NV30_STATE_VTXATTR
= 33,
63 #include "nv30_screen.h"
65 #define NV30_NEW_BLEND (1 << 0)
66 #define NV30_NEW_RAST (1 << 1)
67 #define NV30_NEW_ZSA (1 << 2)
68 #define NV30_NEW_SAMPLER (1 << 3)
69 #define NV30_NEW_FB (1 << 4)
70 #define NV30_NEW_STIPPLE (1 << 5)
71 #define NV30_NEW_SCISSOR (1 << 6)
72 #define NV30_NEW_VIEWPORT (1 << 7)
73 #define NV30_NEW_BCOL (1 << 8)
74 #define NV30_NEW_VERTPROG (1 << 9)
75 #define NV30_NEW_FRAGPROG (1 << 10)
76 #define NV30_NEW_ARRAYS (1 << 11)
77 #define NV30_NEW_UCP (1 << 12)
79 /* TODO: rename when removing the old state emitter */
80 struct nv30_rasterizer_state_new
{
81 struct pipe_rasterizer_state pipe
;
82 struct nouveau_stateobj
*so
;
85 struct nv30_zsa_state
{
86 struct pipe_depth_stencil_alpha_state pipe
;
87 struct nouveau_stateobj
*so
;
90 /* TODO: rename when removing the old state emitter */
91 struct nv30_blend_state_new
{
92 struct pipe_blend_state pipe
;
93 struct nouveau_stateobj
*so
;
98 unsigned scissor_enabled
;
99 unsigned stipple_enabled
;
100 unsigned viewport_bypass
;
103 struct nouveau_stateobj
*hw
[NV30_STATE_MAX
];
106 struct nv30_context
{
107 struct pipe_context pipe
;
109 struct nouveau_winsys
*nvws
;
110 struct nv30_screen
*screen
;
113 struct draw_context
*draw
;
115 /* HW state derived from pipe states */
116 struct nv30_state state
;
117 struct pipe_scissor_state scissor
;
121 struct nv30_sampler_state
*tex_sampler
[PIPE_MAX_SAMPLERS
];
122 struct nv30_miptree
*tex_miptree
[PIPE_MAX_SAMPLERS
];
123 unsigned dirty_samplers
;
124 unsigned fp_samplers
;
125 unsigned vp_samplers
;
128 struct nv30_blend_state_new
*blend
;
129 struct pipe_blend_color blend_colour
;
130 struct pipe_viewport_state viewport
;
131 struct pipe_framebuffer_state framebuffer
;
132 struct nv30_rasterizer_state_new
*rasterizer
;
133 struct nv30_zsa_state
*zsa
;
134 unsigned stipple
[32];
137 struct pipe_buffer
*rt
[2];
138 struct pipe_buffer
*zeta
;
141 struct pipe_buffer *buffer;
147 struct pipe_buffer
*buffer
;
152 struct nv30_vertex_program
*active
;
154 struct nv30_vertex_program
*current
;
155 struct pipe_buffer
*constant_buf
;
159 struct nv30_fragment_program
*active
;
161 struct nv30_fragment_program
*current
;
162 struct pipe_buffer
*constant_buf
;
165 struct pipe_vertex_buffer vtxbuf
[PIPE_MAX_ATTRIBS
];
166 struct pipe_vertex_element vtxelt
[PIPE_MAX_ATTRIBS
];
169 static INLINE
struct nv30_context
*
170 nv30_context(struct pipe_context
*pipe
)
172 return (struct nv30_context
*)pipe
;
175 struct nv30_state_entry
{
176 boolean (*validate
)(struct nv30_context
*nv30
);
183 extern void nv30_init_state_functions(struct nv30_context
*nv30
);
184 extern void nv30_init_surface_functions(struct nv30_context
*nv30
);
185 extern void nv30_init_query_functions(struct nv30_context
*nv30
);
187 extern void nv30_screen_init_miptree_functions(struct pipe_screen
*pscreen
);
190 extern struct draw_stage
*nv30_draw_render_stage(struct nv30_context
*nv30
);
192 /* nv30_vertprog.c */
193 extern void nv30_vertprog_translate(struct nv30_context
*,
194 struct nv30_vertex_program
*);
195 extern void nv30_vertprog_bind(struct nv30_context
*,
196 struct nv30_vertex_program
*);
197 extern void nv30_vertprog_destroy(struct nv30_context
*,
198 struct nv30_vertex_program
*);
200 /* nv30_fragprog.c */
201 extern void nv30_fragprog_translate(struct nv30_context
*,
202 struct nv30_fragment_program
*);
203 extern void nv30_fragprog_bind(struct nv30_context
*,
204 struct nv30_fragment_program
*);
205 extern void nv30_fragprog_destroy(struct nv30_context
*,
206 struct nv30_fragment_program
*);
209 extern void nv30_fragtex_bind(struct nv30_context
*);
211 /* nv30_state.c and friends */
212 extern boolean
nv30_state_validate(struct nv30_context
*nv30
);
213 extern void nv30_emit_hw_state(struct nv30_context
*nv30
);
214 extern void nv30_state_tex_update(struct nv30_context
*nv30
);
215 extern struct nv30_state_entry nv30_state_framebuffer
;
218 extern boolean
nv30_draw_arrays(struct pipe_context
*, unsigned mode
,
219 unsigned start
, unsigned count
);
220 extern boolean
nv30_draw_elements(struct pipe_context
*pipe
,
221 struct pipe_buffer
*indexBuffer
,
223 unsigned mode
, unsigned start
,
227 extern void nv30_clear(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
228 unsigned clearValue
);