1 #ifndef __NV30_CONTEXT_H__
2 #define __NV30_CONTEXT_H__
4 #include "pipe/p_format.h"
5 #include "util/u_blitter.h"
7 #include "nv30/nv30_screen.h"
8 #include "nv30/nv30_state.h"
10 #include "nouveau_context.h"
13 #define BUFCTX_VTXTMP 1
14 #define BUFCTX_VTXBUF 2
15 #define BUFCTX_IDXBUF 3
16 #define BUFCTX_VERTTEX(n) (4 + (n))
17 #define BUFCTX_FRAGPROG 8
18 #define BUFCTX_FRAGTEX(n) (9 + (n))
20 #define NV30_NEW_BLEND (1 << 0)
21 #define NV30_NEW_RASTERIZER (1 << 1)
22 #define NV30_NEW_ZSA (1 << 2)
23 #define NV30_NEW_VERTPROG (1 << 3)
24 #define NV30_NEW_VERTCONST (1 << 4)
25 #define NV30_NEW_FRAGPROG (1 << 5)
26 #define NV30_NEW_FRAGCONST (1 << 6)
27 #define NV30_NEW_BLEND_COLOUR (1 << 7)
28 #define NV30_NEW_STENCIL_REF (1 << 8)
29 #define NV30_NEW_CLIP (1 << 9)
30 #define NV30_NEW_SAMPLE_MASK (1 << 10)
31 #define NV30_NEW_FRAMEBUFFER (1 << 11)
32 #define NV30_NEW_STIPPLE (1 << 12)
33 #define NV30_NEW_SCISSOR (1 << 13)
34 #define NV30_NEW_VIEWPORT (1 << 14)
35 #define NV30_NEW_ARRAYS (1 << 15)
36 #define NV30_NEW_VERTEX (1 << 16)
37 #define NV30_NEW_CONSTBUF (1 << 17)
38 #define NV30_NEW_FRAGTEX (1 << 18)
39 #define NV30_NEW_VERTTEX (1 << 19)
40 #define NV30_NEW_SWTNL (1 << 31)
41 #define NV30_NEW_ALL 0x000fffff
44 struct nouveau_context base
;
45 struct nv30_screen
*screen
;
46 struct blitter_context
*blitter
;
48 struct nouveau_bufctx
*bufctx
;
55 struct nv30_fragprog
*fragprog
;
60 struct draw_context
*draw
;
64 struct nv30_blend_stateobj
*blend
;
65 struct nv30_rasterizer_stateobj
*rast
;
66 struct nv30_zsa_stateobj
*zsa
;
67 struct nv30_vertex_stateobj
*vertex
;
75 struct nv30_vertprog
*program
;
77 struct pipe_resource
*constbuf
;
80 struct pipe_sampler_view
*textures
[PIPE_MAX_SAMPLERS
];
81 unsigned num_textures
;
82 struct nv30_sampler_state
*samplers
[PIPE_MAX_SAMPLERS
];
83 unsigned num_samplers
;
84 unsigned dirty_samplers
;
88 struct nv30_fragprog
*program
;
90 struct pipe_resource
*constbuf
;
93 struct pipe_sampler_view
*textures
[PIPE_MAX_SAMPLERS
];
94 unsigned num_textures
;
95 struct nv30_sampler_state
*samplers
[PIPE_MAX_SAMPLERS
];
96 unsigned num_samplers
;
97 unsigned dirty_samplers
;
100 struct pipe_framebuffer_state framebuffer
;
101 struct pipe_blend_color blend_colour
;
102 struct pipe_stencil_ref stencil_ref
;
103 struct pipe_poly_stipple stipple
;
104 struct pipe_scissor_state scissor
;
105 struct pipe_viewport_state viewport
;
106 struct pipe_clip_state clip
;
108 unsigned sample_mask
;
110 struct pipe_vertex_buffer vtxbuf
[PIPE_MAX_ATTRIBS
];
111 unsigned num_vtxbufs
;
112 struct pipe_index_buffer idxbuf
;
115 unsigned vbo_min_index
;
116 unsigned vbo_max_index
;
117 boolean vbo_push_hint
;
119 struct nouveau_heap
*blit_vp
;
120 struct pipe_resource
*blit_fp
;
122 struct pipe_query
*render_cond_query
;
123 unsigned render_cond_mode
;
124 boolean render_cond_cond
;
127 static INLINE
struct nv30_context
*
128 nv30_context(struct pipe_context
*pipe
)
130 return (struct nv30_context
*)pipe
;
133 struct pipe_context
*
134 nv30_context_create(struct pipe_screen
*pscreen
, void *priv
);
137 nv30_vbo_init(struct pipe_context
*pipe
);
140 nv30_vbo_validate(struct nv30_context
*nv30
);
143 nv30_query_init(struct pipe_context
*pipe
);
146 nv30_state_init(struct pipe_context
*pipe
);
149 nv30_clear_init(struct pipe_context
*pipe
);
152 nv30_vertprog_init(struct pipe_context
*pipe
);
155 nv30_vertprog_validate(struct nv30_context
*nv30
);
158 nv30_fragprog_init(struct pipe_context
*pipe
);
161 nv30_fragprog_validate(struct nv30_context
*nv30
);
164 nv30_texture_init(struct pipe_context
*pipe
);
167 nv30_texture_validate(struct nv30_context
*nv30
);
170 nv30_fragtex_init(struct pipe_context
*pipe
);
173 nv30_fragtex_validate(struct nv30_context
*nv30
);
176 nv40_verttex_init(struct pipe_context
*pipe
);
179 nv40_verttex_validate(struct nv30_context
*nv30
);
182 nv30_fragtex_sampler_states_bind(struct pipe_context
*pipe
,
183 unsigned nr
, void **hwcso
);
186 nv40_verttex_sampler_states_bind(struct pipe_context
*pipe
,
187 unsigned nr
, void **hwcso
);
190 nv40_verttex_set_sampler_views(struct pipe_context
*pipe
, unsigned nr
,
191 struct pipe_sampler_view
**views
);
194 nv30_fragtex_set_sampler_views(struct pipe_context
*pipe
,
195 unsigned nr
, struct pipe_sampler_view
**views
);
198 nv30_push_vbo(struct nv30_context
*nv30
, const struct pipe_draw_info
*info
);
201 nv30_draw_init(struct pipe_context
*pipe
);
204 nv30_render_vbo(struct pipe_context
*pipe
, const struct pipe_draw_info
*info
);
207 nv30_state_validate(struct nv30_context
*nv30
, uint32_t mask
, boolean hwtnl
);
210 nv30_state_release(struct nv30_context
*nv30
);
212 #ifdef NV30_3D_VERTEX_BEGIN_END
213 #define NV30_PRIM_GL_CASE(n) \
214 case PIPE_PRIM_##n: return NV30_3D_VERTEX_BEGIN_END_##n
216 static INLINE
unsigned
217 nv30_prim_gl(unsigned prim
)
220 NV30_PRIM_GL_CASE(POINTS
);
221 NV30_PRIM_GL_CASE(LINES
);
222 NV30_PRIM_GL_CASE(LINE_LOOP
);
223 NV30_PRIM_GL_CASE(LINE_STRIP
);
224 NV30_PRIM_GL_CASE(TRIANGLES
);
225 NV30_PRIM_GL_CASE(TRIANGLE_STRIP
);
226 NV30_PRIM_GL_CASE(TRIANGLE_FAN
);
227 NV30_PRIM_GL_CASE(QUADS
);
228 NV30_PRIM_GL_CASE(QUAD_STRIP
);
229 NV30_PRIM_GL_CASE(POLYGON
);
231 return NV30_3D_VERTEX_BEGIN_END_POINTS
;