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 /*XXX: nvfx state, DO NOT USE EVER OUTSIDE "STOLEN" NVFX code */
125 bool hw_pointsprite_control
;
130 struct pipe_query
*render_cond_query
;
131 unsigned render_cond_mode
;
132 boolean render_cond_cond
;
135 static INLINE
struct nv30_context
*
136 nv30_context(struct pipe_context
*pipe
)
138 return (struct nv30_context
*)pipe
;
141 struct pipe_context
*
142 nv30_context_create(struct pipe_screen
*pscreen
, void *priv
);
145 nv30_vbo_init(struct pipe_context
*pipe
);
148 nv30_vbo_validate(struct nv30_context
*nv30
);
151 nv30_query_init(struct pipe_context
*pipe
);
154 nv30_state_init(struct pipe_context
*pipe
);
157 nv30_clear_init(struct pipe_context
*pipe
);
160 nv30_vertprog_init(struct pipe_context
*pipe
);
163 nv30_vertprog_validate(struct nv30_context
*nv30
);
166 nv30_fragprog_init(struct pipe_context
*pipe
);
169 nv30_fragprog_validate(struct nv30_context
*nv30
);
172 nv30_texture_init(struct pipe_context
*pipe
);
175 nv30_texture_validate(struct nv30_context
*nv30
);
178 nv30_fragtex_init(struct pipe_context
*pipe
);
181 nv30_fragtex_validate(struct nv30_context
*nv30
);
184 nv40_verttex_init(struct pipe_context
*pipe
);
187 nv40_verttex_validate(struct nv30_context
*nv30
);
190 nv30_push_vbo(struct nv30_context
*nv30
, const struct pipe_draw_info
*info
);
193 nv30_draw_init(struct pipe_context
*pipe
);
196 nv30_render_vbo(struct pipe_context
*pipe
, const struct pipe_draw_info
*info
);
199 nv30_state_validate(struct nv30_context
*nv30
, boolean hwtnl
);
202 nv30_state_release(struct nv30_context
*nv30
);
204 //XXX: needed to make it build, clean this up!
206 _nvfx_fragprog_translate(struct nv30_context
*nvfx
, struct nv30_fragprog
*fp
,
207 boolean emulate_sprite_flipping
);
210 _nvfx_vertprog_translate(struct nv30_context
*nv30
, struct nv30_vertprog
*vp
);
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
;