st/nine: Minor refactor of a few NINE_STATE_* flags
[mesa.git] / src / gallium / state_trackers / nine / nine_state.h
1 /*
2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #ifndef _NINE_STATE_H_
24 #define _NINE_STATE_H_
25
26 #include "d3d9.h"
27 #include "nine_defines.h"
28 #include "pipe/p_state.h"
29 #include "util/list.h"
30
31 #define NINED3DSAMP_MINLOD (D3DSAMP_DMAPOFFSET + 1)
32 #define NINED3DSAMP_SHADOW (D3DSAMP_DMAPOFFSET + 2)
33 #define NINED3DSAMP_CUBETEX (D3DSAMP_DMAPOFFSET + 3)
34
35 #define NINED3DRS_VSPOINTSIZE (D3DRS_BLENDOPALPHA + 1)
36 #define NINED3DRS_RTMASK (D3DRS_BLENDOPALPHA + 2)
37 /* ALPHACOVERAGE:
38 * bit 0: enable alpha coverage
39 * bit 1: ATOC is on
40 */
41 #define NINED3DRS_ALPHACOVERAGE (D3DRS_BLENDOPALPHA + 3)
42 #define NINED3DRS_MULTISAMPLE (D3DRS_BLENDOPALPHA + 4)
43
44 #define D3DRS_LAST D3DRS_BLENDOPALPHA
45 #define D3DSAMP_LAST D3DSAMP_DMAPOFFSET
46 #define NINED3DRS_LAST NINED3DRS_MULTISAMPLE /* 214 */
47 #define NINED3DSAMP_LAST NINED3DSAMP_CUBETEX /* 16 */
48 #define NINED3DTSS_LAST D3DTSS_CONSTANT
49 #define NINED3DTS_LAST D3DTS_WORLDMATRIX(255)
50
51 #define D3DRS_COUNT (D3DRS_LAST + 1)
52 #define D3DSAMP_COUNT (D3DSAMP_LAST + 1)
53 #define NINED3DRS_COUNT (NINED3DRS_LAST + 1)
54 #define NINED3DSAMP_COUNT (NINED3DSAMP_LAST + 1)
55 #define NINED3DTSS_COUNT (NINED3DTSS_LAST + 1)
56 #define NINED3DTS_COUNT (NINED3DTS_LAST + 1)
57
58 #define NINE_STATE_FB (1 << 0)
59 #define NINE_STATE_VIEWPORT (1 << 1)
60 #define NINE_STATE_SCISSOR (1 << 2)
61 #define NINE_STATE_RASTERIZER (1 << 3)
62 #define NINE_STATE_BLEND (1 << 4)
63 #define NINE_STATE_DSA (1 << 5)
64 #define NINE_STATE_VS (1 << 6)
65 #define NINE_STATE_VS_CONST (1 << 7)
66 #define NINE_STATE_PS (1 << 8)
67 #define NINE_STATE_PS_CONST (1 << 9)
68 #define NINE_STATE_TEXTURE (1 << 10)
69 #define NINE_STATE_SAMPLER (1 << 11)
70 #define NINE_STATE_VDECL (1 << 12)
71 #define NINE_STATE_IDXBUF (1 << 13)
72 #define NINE_STATE_STREAMFREQ (1 << 14)
73 #define NINE_STATE_PRIM (1 << 15)
74 #define NINE_STATE_MATERIAL (1 << 16)
75 #define NINE_STATE_BLEND_COLOR (1 << 17)
76 #define NINE_STATE_STENCIL_REF (1 << 18)
77 #define NINE_STATE_SAMPLE_MASK (1 << 19)
78 #define NINE_STATE_FF (0x1f << 20)
79 #define NINE_STATE_FF_VS (0x17 << 20)
80 #define NINE_STATE_FF_PS (0x18 << 20)
81 #define NINE_STATE_FF_LIGHTING (1 << 20)
82 #define NINE_STATE_FF_MATERIAL (1 << 21)
83 #define NINE_STATE_FF_VSTRANSF (1 << 22)
84 #define NINE_STATE_FF_PSSTAGES (1 << 23)
85 #define NINE_STATE_FF_OTHER (1 << 24)
86 #define NINE_STATE_VS_PARAMS_MISC (1 << 25)
87 #define NINE_STATE_PS_PARAMS_MISC (1 << 26)
88 #define NINE_STATE_MULTISAMPLE (1 << 27)
89 #define NINE_STATE_SWVP (1 << 28)
90 #define NINE_STATE_ALL 0x1fffffff
91 #define NINE_STATE_UNHANDLED (1 << 29)
92
93 #define NINE_STATE_COMMIT_DSA (1 << 0)
94 #define NINE_STATE_COMMIT_RASTERIZER (1 << 1)
95 #define NINE_STATE_COMMIT_BLEND (1 << 2)
96 #define NINE_STATE_COMMIT_CONST_VS (1 << 3)
97 #define NINE_STATE_COMMIT_CONST_PS (1 << 4)
98 #define NINE_STATE_COMMIT_VS (1 << 5)
99 #define NINE_STATE_COMMIT_PS (1 << 6)
100
101
102 #define NINE_MAX_SIMULTANEOUS_RENDERTARGETS 4
103 #define NINE_MAX_CONST_F_PS3 224
104 #define NINE_MAX_CONST_F 256
105 #define NINE_MAX_CONST_I 16
106 #define NINE_MAX_CONST_B 16
107 #define NINE_MAX_CONST_F_SWVP 8192
108 #define NINE_MAX_CONST_I_SWVP 2048
109 #define NINE_MAX_CONST_B_SWVP 2048
110 #define NINE_MAX_CONST_ALL 276 /* B consts count only 1/4 th */
111
112 #define NINE_CONST_I_BASE(nconstf) \
113 ((nconstf) * 4 * sizeof(float))
114 #define NINE_CONST_B_BASE(nconstf) \
115 ((nconstf) * 4 * sizeof(float) + \
116 NINE_MAX_CONST_I * 4 * sizeof(int))
117
118 #define VS_CONST_F_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_F_SWVP * sizeof(float[4])) : (NINE_MAX_CONST_F * sizeof(float[4])))
119 #define VS_CONST_I_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_I_SWVP * sizeof(int[4])) : (NINE_MAX_CONST_I * sizeof(int[4])))
120 #define VS_CONST_B_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_B_SWVP * sizeof(BOOL)) : (NINE_MAX_CONST_B * sizeof(BOOL)))
121
122
123 #define NINE_MAX_TEXTURE_STAGES 8
124
125 #define NINE_MAX_LIGHTS 65536
126 #define NINE_MAX_LIGHTS_ACTIVE 8
127
128 #define NINED3DLIGHT_INVALID (D3DLIGHT_DIRECTIONAL + 1)
129
130 #define NINE_MAX_SAMPLERS_PS 16
131 #define NINE_MAX_SAMPLERS_VS 4
132 #define NINE_MAX_SAMPLERS 21 /* PS + DMAP + VS */
133 #define NINE_SAMPLER_PS(s) ( 0 + (s))
134 #define NINE_SAMPLER_DMAP 16
135 #define NINE_SAMPLER_VS(s) (17 + (s))
136 #define NINE_PS_SAMPLERS_MASK 0x00ffff
137 #define NINE_VS_SAMPLERS_MASK 0x1e0000
138
139 struct nine_ff_state {
140 struct {
141 uint32_t tex_stage[NINE_MAX_TEXTURE_STAGES][(NINED3DTSS_COUNT + 31) / 32]; /* stateblocks only */
142 uint32_t transform[(NINED3DTS_COUNT + 31) / 32];
143 } changed;
144
145 D3DMATRIX *transform; /* access only via nine_state_access_transform */
146 unsigned num_transforms;
147
148 /* XXX: Do state blocks just change the set of active lights or do we
149 * have to store which lights have been disabled, too ?
150 */
151 D3DLIGHT9 *light;
152 uint16_t active_light[NINE_MAX_LIGHTS_ACTIVE]; /* 8 */
153 unsigned num_lights;
154 unsigned num_lights_active;
155
156 D3DMATERIAL9 material;
157
158 DWORD tex_stage[NINE_MAX_TEXTURE_STAGES][NINED3DTSS_COUNT];
159 };
160
161 struct nine_state
162 {
163 struct {
164 uint32_t group;
165 uint32_t rs[(NINED3DRS_COUNT + 31) / 32];
166 uint32_t vtxbuf;
167 uint32_t stream_freq;
168 uint32_t texture;
169 uint16_t sampler[NINE_MAX_SAMPLERS];
170 struct nine_range *vs_const_f;
171 struct nine_range *ps_const_f;
172 struct nine_range *vs_const_i;
173 uint16_t ps_const_i; /* NINE_MAX_CONST_I == 16 */
174 struct nine_range *vs_const_b;
175 uint16_t ps_const_b; /* NINE_MAX_CONST_B == 16 */
176 uint8_t ucp;
177 } changed; /* stateblocks only */
178
179 struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS];
180 struct NineSurface9 *ds;
181
182 D3DVIEWPORT9 viewport;
183
184 struct pipe_scissor_state scissor;
185
186 /* NOTE: vs, ps will be NULL for FF and are set in device->ff.vs,ps instead
187 * (XXX: or is it better to reference FF shaders here, too ?)
188 * NOTE: const_f contains extra space for const_i,b to use as user constbuf
189 */
190 struct NineVertexShader9 *vs;
191 float *vs_const_f;
192 int *vs_const_i;
193 BOOL *vs_const_b;
194 float *vs_lconstf_temp; /* ProcessVertices */
195
196 struct NinePixelShader9 *ps;
197 float *ps_const_f;
198 int ps_const_i[NINE_MAX_CONST_I][4];
199 BOOL ps_const_b[NINE_MAX_CONST_B];
200
201 struct NineVertexDeclaration9 *vdecl;
202
203 struct NineIndexBuffer9 *idxbuf;
204 struct NineVertexBuffer9 *stream[PIPE_MAX_ATTRIBS];
205 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; /* vtxbuf.buffer unused */
206 UINT stream_freq[PIPE_MAX_ATTRIBS];
207
208 struct pipe_clip_state clip;
209
210 DWORD rs_advertised[NINED3DRS_COUNT]; /* the ones apps get with GetRenderState */
211
212 struct NineBaseTexture9 *texture[NINE_MAX_SAMPLERS]; /* PS, DMAP, VS */
213
214 DWORD samp_advertised[NINE_MAX_SAMPLERS][D3DSAMP_COUNT];
215
216 struct nine_ff_state ff;
217 };
218
219 struct nine_context {
220 struct {
221 uint32_t group;
222 uint16_t sampler[NINE_MAX_SAMPLERS];
223 uint32_t vtxbuf;
224 BOOL vs_const_f;
225 BOOL vs_const_i;
226 BOOL vs_const_b;
227 BOOL ps_const_f;
228 BOOL ps_const_i;
229 BOOL ps_const_b;
230 BOOL ucp;
231 } changed;
232
233 uint32_t bumpmap_vars[6 * NINE_MAX_TEXTURE_STAGES];
234
235 struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS];
236 struct NineSurface9 *ds;
237
238 struct {
239 void *vs;
240 void *ps;
241 } cso_shader;
242
243 struct pipe_context *pipe;
244 struct cso_context *cso;
245
246 uint8_t rt_mask;
247
248 D3DVIEWPORT9 viewport;
249
250 struct pipe_scissor_state scissor;
251
252 struct NineVertexShader9 *vs;
253 BOOL programmable_vs;
254 float *vs_const_f;
255 float *vs_const_f_swvp;
256 int *vs_const_i;
257 BOOL *vs_const_b;
258 float *vs_lconstf_temp;
259
260 struct NinePixelShader9 *ps;
261 float *ps_const_f;
262 int ps_const_i[NINE_MAX_CONST_I][4];
263 BOOL ps_const_b[NINE_MAX_CONST_B];
264 float *ps_lconstf_temp;
265
266 struct NineVertexDeclaration9 *vdecl;
267
268 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
269 UINT stream_freq[PIPE_MAX_ATTRIBS];
270 uint32_t stream_instancedata_mask; /* derived from stream_freq */
271 uint32_t stream_usage_mask; /* derived from VS and vdecl */
272
273 struct pipe_resource *idxbuf;
274 unsigned index_offset;
275 unsigned index_size;
276
277 struct pipe_clip_state clip;
278
279 DWORD rs[NINED3DRS_COUNT];
280
281 struct {
282 BOOL enabled;
283 BOOL shadow;
284 DWORD lod;
285 D3DRESOURCETYPE type;
286 struct pipe_resource *resource;
287 struct pipe_sampler_view *view[2];
288 uint8_t pstype;
289 } texture[NINE_MAX_SAMPLERS];
290
291 DWORD samp[NINE_MAX_SAMPLERS][NINED3DSAMP_COUNT];
292
293 uint32_t samplers_shadow;
294
295 uint8_t bound_samplers_mask_vs;
296 uint16_t bound_samplers_mask_ps;
297
298 int dummy_vbo_bound_at; /* -1 = not bound , >= 0 = bound index */
299 boolean vbo_bound_done;
300
301 struct nine_ff_state ff;
302
303 /* software vertex processing */
304 boolean swvp;
305
306 uint32_t commit;
307 struct {
308 struct pipe_framebuffer_state fb;
309 struct pipe_depth_stencil_alpha_state dsa;
310 struct pipe_rasterizer_state rast;
311 struct pipe_blend_state blend;
312 struct pipe_constant_buffer cb_vs;
313 struct pipe_constant_buffer cb0_swvp;
314 struct pipe_constant_buffer cb1_swvp;
315 struct pipe_constant_buffer cb2_swvp;
316 struct pipe_constant_buffer cb3_swvp;
317 struct pipe_constant_buffer cb_ps;
318 struct pipe_constant_buffer cb_vs_ff;
319 struct pipe_constant_buffer cb_ps_ff;
320 } pipe_data;
321 };
322
323 struct nine_state_sw_internal {
324 struct pipe_transfer *transfers_so[4];
325 };
326
327 struct nine_clipplane {
328 float plane[4];
329 };
330 /* map D3DRS -> NINE_STATE_x
331 */
332 extern const uint32_t nine_render_state_group[NINED3DRS_COUNT];
333
334 /* for D3DSBT_PIXEL/VERTEX:
335 */
336 extern const uint32_t nine_render_states_pixel[(NINED3DRS_COUNT + 31) / 32];
337 extern const uint32_t nine_render_states_vertex[(NINED3DRS_COUNT + 31) / 32];
338
339 struct NineDevice9;
340
341 /* Internal multithreading: When enabled, the nine_context functions
342 * will append work to a worker thread when possible. Only the worker
343 * thread can access struct nine_context. */
344
345 void
346 nine_context_set_render_state(struct NineDevice9 *device,
347 D3DRENDERSTATETYPE State,
348 DWORD Value);
349
350 void
351 nine_context_set_texture(struct NineDevice9 *device,
352 DWORD Stage,
353 struct NineBaseTexture9 *tex);
354
355 void
356 nine_context_set_sampler_state(struct NineDevice9 *device,
357 DWORD Sampler,
358 D3DSAMPLERSTATETYPE Type,
359 DWORD Value);
360
361 void
362 nine_context_set_stream_source(struct NineDevice9 *device,
363 UINT StreamNumber,
364 struct NineVertexBuffer9 *pVBuf9,
365 UINT OffsetInBytes,
366 UINT Stride);
367
368 void
369 nine_context_set_stream_source_freq(struct NineDevice9 *device,
370 UINT StreamNumber,
371 UINT Setting);
372
373 void
374 nine_context_set_indices(struct NineDevice9 *device,
375 struct NineIndexBuffer9 *idxbuf);
376
377 void
378 nine_context_set_vertex_declaration(struct NineDevice9 *device,
379 struct NineVertexDeclaration9 *vdecl);
380
381 void
382 nine_context_set_vertex_shader(struct NineDevice9 *device,
383 struct NineVertexShader9 *pShader);
384
385 void
386 nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device,
387 UINT StartRegister,
388 const float *pConstantData,
389 const unsigned pConstantData_size,
390 UINT Vector4fCount);
391
392 void
393 nine_context_set_vertex_shader_constant_i(struct NineDevice9 *device,
394 UINT StartRegister,
395 const int *pConstantData,
396 const unsigned pConstantData_size,
397 UINT Vector4iCount);
398
399 void
400 nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device,
401 UINT StartRegister,
402 const BOOL *pConstantData,
403 const unsigned pConstantData_size,
404 UINT BoolCount);
405
406 void
407 nine_context_set_pixel_shader(struct NineDevice9 *device,
408 struct NinePixelShader9* ps);
409
410 void
411 nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device,
412 UINT StartRegister,
413 const float *pConstantData,
414 const unsigned pConstantData_size,
415 UINT Vector4fCount);
416
417 void
418 nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device,
419 UINT StartRegister,
420 const int *pConstantData,
421 const unsigned pConstantData_size,
422 UINT Vector4iCount);
423
424 void
425 nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
426 UINT StartRegister,
427 const BOOL *pConstantData,
428 const unsigned pConstantData_size,
429 UINT BoolCount);
430
431 void
432 nine_context_set_viewport(struct NineDevice9 *device,
433 const D3DVIEWPORT9 *viewport);
434
435 void
436 nine_context_set_scissor(struct NineDevice9 *device,
437 const struct pipe_scissor_state *scissor);
438
439 void
440 nine_context_set_transform(struct NineDevice9 *device,
441 D3DTRANSFORMSTATETYPE State,
442 const D3DMATRIX *pMatrix);
443
444 void
445 nine_context_set_material(struct NineDevice9 *device,
446 const D3DMATERIAL9 *pMaterial);
447
448 void
449 nine_context_set_light(struct NineDevice9 *device,
450 DWORD Index,
451 const D3DLIGHT9 *pLight);
452
453 void
454 nine_context_light_enable(struct NineDevice9 *device,
455 DWORD Index,
456 BOOL Enable);
457
458 void
459 nine_context_set_texture_stage_state(struct NineDevice9 *device,
460 DWORD Stage,
461 D3DTEXTURESTAGESTATETYPE Type,
462 DWORD Value);
463
464 void
465 nine_context_set_render_target(struct NineDevice9 *device,
466 DWORD RenderTargetIndex,
467 struct NineSurface9 *rt);
468
469 void
470 nine_context_set_depth_stencil(struct NineDevice9 *device,
471 struct NineSurface9 *ds);
472
473 void
474 nine_context_set_clip_plane(struct NineDevice9 *device,
475 DWORD Index,
476 const struct nine_clipplane *pPlane);
477
478 void
479 nine_context_set_swvp(struct NineDevice9 *device,
480 boolean swvp);
481
482 void
483 nine_context_apply_stateblock(struct NineDevice9 *device,
484 const struct nine_state *src);
485
486 void
487 nine_context_clear_fb(struct NineDevice9 *device, DWORD Count,
488 const D3DRECT *pRects, DWORD Flags,
489 D3DCOLOR Color, float Z, DWORD Stencil);
490
491 void
492 nine_context_draw_primitive(struct NineDevice9 *device,
493 D3DPRIMITIVETYPE PrimitiveType,
494 UINT StartVertex,
495 UINT PrimitiveCount);
496
497 void
498 nine_context_draw_indexed_primitive(struct NineDevice9 *device,
499 D3DPRIMITIVETYPE PrimitiveType,
500 INT BaseVertexIndex,
501 UINT MinVertexIndex,
502 UINT NumVertices,
503 UINT StartIndex,
504 UINT PrimitiveCount);
505
506 void
507 nine_context_draw_primitive_from_vtxbuf(struct NineDevice9 *device,
508 D3DPRIMITIVETYPE PrimitiveType,
509 UINT PrimitiveCount,
510 struct pipe_vertex_buffer *vtxbuf);
511
512 void
513 nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *device,
514 D3DPRIMITIVETYPE PrimitiveType,
515 UINT MinVertexIndex,
516 UINT NumVertices,
517 UINT PrimitiveCount,
518 struct pipe_vertex_buffer *vbuf,
519 struct pipe_resource *ibuf,
520 void *user_ibuf,
521 unsigned index_offset,
522 unsigned index_size);
523
524 void
525 nine_context_resource_copy_region(struct NineDevice9 *device,
526 struct NineUnknown *dst,
527 struct NineUnknown *src,
528 struct pipe_resource* dst_res,
529 unsigned dst_level,
530 const struct pipe_box *dst_box,
531 struct pipe_resource* src_res,
532 unsigned src_level,
533 const struct pipe_box *src_box);
534
535 void
536 nine_context_blit(struct NineDevice9 *device,
537 struct NineUnknown *dst,
538 struct NineUnknown *src,
539 struct pipe_blit_info *blit);
540
541 void
542 nine_context_clear_render_target(struct NineDevice9 *device,
543 struct NineSurface9 *surface,
544 D3DCOLOR color,
545 UINT x,
546 UINT y,
547 UINT width,
548 UINT height);
549
550 void
551 nine_context_gen_mipmap(struct NineDevice9 *device,
552 struct NineUnknown *dst,
553 struct pipe_resource *res,
554 UINT base_level, UINT last_level,
555 UINT first_layer, UINT last_layer,
556 UINT filter);
557
558 void
559 nine_context_range_upload(struct NineDevice9 *device,
560 unsigned *counter,
561 struct pipe_resource *res,
562 unsigned offset,
563 unsigned size,
564 const void *data);
565
566 void
567 nine_context_box_upload(struct NineDevice9 *device,
568 unsigned *counter,
569 struct NineUnknown *dst,
570 struct pipe_resource *res,
571 unsigned level,
572 const struct pipe_box *dst_box,
573 enum pipe_format src_format,
574 const void *src, unsigned src_stride,
575 unsigned src_layer_stride,
576 const struct pipe_box *src_box);
577
578 struct pipe_query *
579 nine_context_create_query(struct NineDevice9 *device, unsigned query_type);
580
581 void
582 nine_context_destroy_query(struct NineDevice9 *device, struct pipe_query *query);
583
584 void
585 nine_context_begin_query(struct NineDevice9 *device, unsigned *counter, struct pipe_query *query);
586
587 void
588 nine_context_end_query(struct NineDevice9 *device, unsigned *counter, struct pipe_query *query);
589
590 boolean
591 nine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *query,
592 unsigned *counter, boolean flush, boolean wait,
593 union pipe_query_result *result);
594
595 void nine_state_restore_non_cso(struct NineDevice9 *device);
596 void nine_state_set_defaults(struct NineDevice9 *, const D3DCAPS9 *,
597 boolean is_reset);
598 void nine_state_clear(struct nine_state *, const boolean device);
599 void nine_context_clear(struct NineDevice9 *);
600
601 void nine_state_init_sw(struct NineDevice9 *device);
602 void nine_state_prepare_draw_sw(struct NineDevice9 *device,
603 struct NineVertexDeclaration9 *vdecl_out,
604 int start_vertice,
605 int num_vertices,
606 struct pipe_stream_output_info *so);
607 void nine_state_after_draw_sw(struct NineDevice9 *device);
608 void nine_state_destroy_sw(struct NineDevice9 *device);
609
610 /* If @alloc is FALSE, the return value may be a const identity matrix.
611 * Therefore, do not modify if you set alloc to FALSE !
612 */
613 D3DMATRIX *
614 nine_state_access_transform(struct nine_ff_state *, D3DTRANSFORMSTATETYPE,
615 boolean alloc);
616
617 HRESULT
618 nine_state_set_light(struct nine_ff_state *, DWORD, const D3DLIGHT9 *);
619
620 HRESULT
621 nine_state_light_enable(struct nine_ff_state *, uint32_t *,
622 DWORD, BOOL);
623
624 const char *nine_d3drs_to_string(DWORD State);
625
626 /* CSMT functions */
627 struct csmt_context;
628
629 struct csmt_context *
630 nine_csmt_create( struct NineDevice9 *This );
631
632 void
633 nine_csmt_destroy( struct NineDevice9 *This, struct csmt_context *ctx );
634
635 void
636 nine_csmt_process( struct NineDevice9 *This );
637
638
639 /* Get the pipe_context (should not be called from the worker thread).
640 * All the work in the worker thread is finished before returning. */
641 struct pipe_context *
642 nine_context_get_pipe( struct NineDevice9 *device );
643
644 /* Can be called from all threads */
645 struct pipe_context *
646 nine_context_get_pipe_multithread( struct NineDevice9 *device );
647
648
649 /* Get the pipe_context (should not be called from the worker thread).
650 * All the work in the worker thread is paused before returning.
651 * It is neccessary to release in order to restart the thread.
652 * This is intended for use of the nine_context pipe_context that don't
653 * need the worker thread to finish all queued job. */
654 struct pipe_context *
655 nine_context_get_pipe_acquire( struct NineDevice9 *device );
656
657 void
658 nine_context_get_pipe_release( struct NineDevice9 *device );
659
660 #endif /* _NINE_STATE_H_ */