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"
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"
17 #define NOUVEAU_PUSH_CONTEXT(ctx) \
18 struct nv30_screen *ctx = nv30->screen
19 #include "nouveau/nouveau_push.h"
20 #include "nouveau/nouveau_stateobj.h"
22 #include "nv30_state.h"
24 #define NOUVEAU_ERR(fmt, args...) \
25 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
26 #define NOUVEAU_MSG(fmt, args...) \
27 fprintf(stderr, "nouveau: "fmt, ##args);
29 enum nv30_state_index
{
31 NV30_STATE_VIEWPORT
= 1,
37 NV30_STATE_SCISSOR
= 7,
38 NV30_STATE_STIPPLE
= 8,
39 NV30_STATE_FRAGPROG
= 9,
40 NV30_STATE_VERTPROG
= 10,
41 NV30_STATE_FRAGTEX0
= 11,
42 NV30_STATE_FRAGTEX1
= 12,
43 NV30_STATE_FRAGTEX2
= 13,
44 NV30_STATE_FRAGTEX3
= 14,
45 NV30_STATE_FRAGTEX4
= 15,
46 NV30_STATE_FRAGTEX5
= 16,
47 NV30_STATE_FRAGTEX6
= 17,
48 NV30_STATE_FRAGTEX7
= 18,
49 NV30_STATE_FRAGTEX8
= 19,
50 NV30_STATE_FRAGTEX9
= 20,
51 NV30_STATE_FRAGTEX10
= 21,
52 NV30_STATE_FRAGTEX11
= 22,
53 NV30_STATE_FRAGTEX12
= 23,
54 NV30_STATE_FRAGTEX13
= 24,
55 NV30_STATE_FRAGTEX14
= 25,
56 NV30_STATE_FRAGTEX15
= 26,
57 NV30_STATE_VERTTEX0
= 27,
58 NV30_STATE_VERTTEX1
= 28,
59 NV30_STATE_VERTTEX2
= 29,
60 NV30_STATE_VERTTEX3
= 30,
61 NV30_STATE_VTXBUF
= 31,
62 NV30_STATE_VTXFMT
= 32,
63 NV30_STATE_VTXATTR
= 33,
67 #include "nv30_screen.h"
69 #define NV30_NEW_BLEND (1 << 0)
70 #define NV30_NEW_RAST (1 << 1)
71 #define NV30_NEW_ZSA (1 << 2)
72 #define NV30_NEW_SAMPLER (1 << 3)
73 #define NV30_NEW_FB (1 << 4)
74 #define NV30_NEW_STIPPLE (1 << 5)
75 #define NV30_NEW_SCISSOR (1 << 6)
76 #define NV30_NEW_VIEWPORT (1 << 7)
77 #define NV30_NEW_BCOL (1 << 8)
78 #define NV30_NEW_VERTPROG (1 << 9)
79 #define NV30_NEW_FRAGPROG (1 << 10)
80 #define NV30_NEW_ARRAYS (1 << 11)
81 #define NV30_NEW_UCP (1 << 12)
83 struct nv30_rasterizer_state
{
84 struct pipe_rasterizer_state pipe
;
85 struct nouveau_stateobj
*so
;
88 struct nv30_zsa_state
{
89 struct pipe_depth_stencil_alpha_state pipe
;
90 struct nouveau_stateobj
*so
;
93 struct nv30_blend_state
{
94 struct pipe_blend_state pipe
;
95 struct nouveau_stateobj
*so
;
100 unsigned scissor_enabled
;
101 unsigned stipple_enabled
;
102 unsigned viewport_bypass
;
103 unsigned fp_samplers
;
106 struct nouveau_stateobj
*hw
[NV30_STATE_MAX
];
109 struct nv30_context
{
110 struct pipe_context pipe
;
112 struct nouveau_winsys
*nvws
;
113 struct nv30_screen
*screen
;
116 struct draw_context
*draw
;
118 /* HW state derived from pipe states */
119 struct nv30_state state
;
123 struct pipe_scissor_state scissor
;
124 unsigned stipple
[32];
125 struct nv30_vertex_program
*vertprog
;
126 struct nv30_fragment_program
*fragprog
;
127 struct pipe_buffer
*constbuf
[PIPE_SHADER_TYPES
];
128 unsigned constbuf_nr
[PIPE_SHADER_TYPES
];
129 struct nv30_rasterizer_state
*rasterizer
;
130 struct nv30_zsa_state
*zsa
;
131 struct nv30_blend_state
*blend
;
132 struct pipe_blend_color blend_colour
;
133 struct pipe_viewport_state viewport
;
134 struct pipe_framebuffer_state framebuffer
;
135 struct pipe_buffer
*idxbuf
;
136 unsigned idxbuf_format
;
137 struct nv30_sampler_state
*tex_sampler
[PIPE_MAX_SAMPLERS
];
138 struct nv30_miptree
*tex_miptree
[PIPE_MAX_SAMPLERS
];
139 unsigned nr_samplers
;
140 unsigned nr_textures
;
141 unsigned dirty_samplers
;
142 struct pipe_vertex_buffer vtxbuf
[PIPE_MAX_ATTRIBS
];
144 struct pipe_vertex_element vtxelt
[PIPE_MAX_ATTRIBS
];
146 const unsigned *edgeflags
;
149 static INLINE
struct nv30_context
*
150 nv30_context(struct pipe_context
*pipe
)
152 return (struct nv30_context
*)pipe
;
155 struct nv30_state_entry
{
156 boolean (*validate
)(struct nv30_context
*nv30
);
163 extern void nv30_init_state_functions(struct nv30_context
*nv30
);
164 extern void nv30_init_surface_functions(struct nv30_context
*nv30
);
165 extern void nv30_init_query_functions(struct nv30_context
*nv30
);
167 extern void nv30_screen_init_miptree_functions(struct pipe_screen
*pscreen
);
170 extern struct draw_stage
*nv30_draw_render_stage(struct nv30_context
*nv30
);
172 /* nv30_vertprog.c */
173 extern void nv30_vertprog_destroy(struct nv30_context
*,
174 struct nv30_vertex_program
*);
176 /* nv30_fragprog.c */
177 extern void nv30_fragprog_destroy(struct nv30_context
*,
178 struct nv30_fragment_program
*);
181 extern void nv30_fragtex_bind(struct nv30_context
*);
183 /* nv30_state.c and friends */
184 extern boolean
nv30_state_validate(struct nv30_context
*nv30
);
185 extern void nv30_state_emit(struct nv30_context
*nv30
);
186 extern struct nv30_state_entry nv30_state_rasterizer
;
187 extern struct nv30_state_entry nv30_state_scissor
;
188 extern struct nv30_state_entry nv30_state_stipple
;
189 extern struct nv30_state_entry nv30_state_fragprog
;
190 extern struct nv30_state_entry nv30_state_vertprog
;
191 extern struct nv30_state_entry nv30_state_blend
;
192 extern struct nv30_state_entry nv30_state_blend_colour
;
193 extern struct nv30_state_entry nv30_state_zsa
;
194 extern struct nv30_state_entry nv30_state_viewport
;
195 extern struct nv30_state_entry nv30_state_framebuffer
;
196 extern struct nv30_state_entry nv30_state_fragtex
;
197 extern struct nv30_state_entry nv30_state_vbo
;
200 extern boolean
nv30_draw_arrays(struct pipe_context
*, unsigned mode
,
201 unsigned start
, unsigned count
);
202 extern boolean
nv30_draw_elements(struct pipe_context
*pipe
,
203 struct pipe_buffer
*indexBuffer
,
205 unsigned mode
, unsigned start
,
209 extern void nv30_clear(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
210 unsigned clearValue
);