st/nine: Add dummy ff shader state
[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 /* These states affect the ff shader key,
94 * which we recompute everytime. */
95 #define NINE_STATE_FF_SHADER 0
96
97 #define NINE_STATE_COMMIT_DSA (1 << 0)
98 #define NINE_STATE_COMMIT_RASTERIZER (1 << 1)
99 #define NINE_STATE_COMMIT_BLEND (1 << 2)
100 #define NINE_STATE_COMMIT_CONST_VS (1 << 3)
101 #define NINE_STATE_COMMIT_CONST_PS (1 << 4)
102 #define NINE_STATE_COMMIT_VS (1 << 5)
103 #define NINE_STATE_COMMIT_PS (1 << 6)
104
105
106 #define NINE_MAX_SIMULTANEOUS_RENDERTARGETS 4
107 #define NINE_MAX_CONST_F_PS3 224
108 #define NINE_MAX_CONST_F 256
109 #define NINE_MAX_CONST_I 16
110 #define NINE_MAX_CONST_B 16
111 #define NINE_MAX_CONST_F_SWVP 8192
112 #define NINE_MAX_CONST_I_SWVP 2048
113 #define NINE_MAX_CONST_B_SWVP 2048
114 #define NINE_MAX_CONST_ALL 276 /* B consts count only 1/4 th */
115
116 #define NINE_CONST_I_BASE(nconstf) \
117 ((nconstf) * 4 * sizeof(float))
118 #define NINE_CONST_B_BASE(nconstf) \
119 ((nconstf) * 4 * sizeof(float) + \
120 NINE_MAX_CONST_I * 4 * sizeof(int))
121
122 #define VS_CONST_F_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_F_SWVP * sizeof(float[4])) : (NINE_MAX_CONST_F * sizeof(float[4])))
123 #define VS_CONST_I_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_I_SWVP * sizeof(int[4])) : (NINE_MAX_CONST_I * sizeof(int[4])))
124 #define VS_CONST_B_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_B_SWVP * sizeof(BOOL)) : (NINE_MAX_CONST_B * sizeof(BOOL)))
125
126
127 #define NINE_MAX_TEXTURE_STAGES 8
128
129 #define NINE_MAX_LIGHTS 65536
130 #define NINE_MAX_LIGHTS_ACTIVE 8
131
132 #define NINED3DLIGHT_INVALID (D3DLIGHT_DIRECTIONAL + 1)
133
134 #define NINE_MAX_SAMPLERS_PS 16
135 #define NINE_MAX_SAMPLERS_VS 4
136 #define NINE_MAX_SAMPLERS 21 /* PS + DMAP + VS */
137 #define NINE_SAMPLER_PS(s) ( 0 + (s))
138 #define NINE_SAMPLER_DMAP 16
139 #define NINE_SAMPLER_VS(s) (17 + (s))
140 #define NINE_PS_SAMPLERS_MASK 0x00ffff
141 #define NINE_VS_SAMPLERS_MASK 0x1e0000
142
143 struct nine_ff_state {
144 struct {
145 uint32_t tex_stage[NINE_MAX_TEXTURE_STAGES][(NINED3DTSS_COUNT + 31) / 32]; /* stateblocks only */
146 uint32_t transform[(NINED3DTS_COUNT + 31) / 32];
147 } changed;
148
149 D3DMATRIX *transform; /* access only via nine_state_access_transform */
150 unsigned num_transforms;
151
152 /* XXX: Do state blocks just change the set of active lights or do we
153 * have to store which lights have been disabled, too ?
154 */
155 D3DLIGHT9 *light;
156 uint16_t active_light[NINE_MAX_LIGHTS_ACTIVE]; /* 8 */
157 unsigned num_lights;
158 unsigned num_lights_active;
159
160 D3DMATERIAL9 material;
161
162 DWORD tex_stage[NINE_MAX_TEXTURE_STAGES][NINED3DTSS_COUNT];
163 };
164
165 struct nine_state
166 {
167 struct {
168 uint32_t group;
169 uint32_t rs[(NINED3DRS_COUNT + 31) / 32];
170 uint32_t vtxbuf;
171 uint32_t stream_freq;
172 uint32_t texture;
173 uint16_t sampler[NINE_MAX_SAMPLERS];
174 struct nine_range *vs_const_f;
175 struct nine_range *ps_const_f;
176 struct nine_range *vs_const_i;
177 uint16_t ps_const_i; /* NINE_MAX_CONST_I == 16 */
178 struct nine_range *vs_const_b;
179 uint16_t ps_const_b; /* NINE_MAX_CONST_B == 16 */
180 uint8_t ucp;
181 } changed; /* stateblocks only */
182
183 struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS];
184 struct NineSurface9 *ds;
185
186 D3DVIEWPORT9 viewport;
187
188 struct pipe_scissor_state scissor;
189
190 /* NOTE: vs, ps will be NULL for FF and are set in device->ff.vs,ps instead
191 * (XXX: or is it better to reference FF shaders here, too ?)
192 * NOTE: const_f contains extra space for const_i,b to use as user constbuf
193 */
194 struct NineVertexShader9 *vs;
195 float *vs_const_f;
196 int *vs_const_i;
197 BOOL *vs_const_b;
198 float *vs_lconstf_temp; /* ProcessVertices */
199
200 struct NinePixelShader9 *ps;
201 float *ps_const_f;
202 int ps_const_i[NINE_MAX_CONST_I][4];
203 BOOL ps_const_b[NINE_MAX_CONST_B];
204
205 struct NineVertexDeclaration9 *vdecl;
206
207 struct NineIndexBuffer9 *idxbuf;
208 struct NineVertexBuffer9 *stream[PIPE_MAX_ATTRIBS];
209 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; /* vtxbuf.buffer unused */
210 UINT stream_freq[PIPE_MAX_ATTRIBS];
211
212 struct pipe_clip_state clip;
213
214 DWORD rs_advertised[NINED3DRS_COUNT]; /* the ones apps get with GetRenderState */
215
216 struct NineBaseTexture9 *texture[NINE_MAX_SAMPLERS]; /* PS, DMAP, VS */
217
218 DWORD samp_advertised[NINE_MAX_SAMPLERS][D3DSAMP_COUNT];
219
220 struct nine_ff_state ff;
221 };
222
223 struct nine_context {
224 struct {
225 uint32_t group;
226 uint16_t sampler[NINE_MAX_SAMPLERS];
227 uint32_t vtxbuf;
228 BOOL vs_const_f;
229 BOOL vs_const_i;
230 BOOL vs_const_b;
231 BOOL ps_const_f;
232 BOOL ps_const_i;
233 BOOL ps_const_b;
234 BOOL ucp;
235 } changed;
236
237 uint32_t bumpmap_vars[6 * NINE_MAX_TEXTURE_STAGES];
238
239 struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS];
240 struct NineSurface9 *ds;
241
242 struct {
243 void *vs;
244 void *ps;
245 } cso_shader;
246
247 struct pipe_context *pipe;
248 struct cso_context *cso;
249
250 uint8_t rt_mask;
251
252 D3DVIEWPORT9 viewport;
253
254 struct pipe_scissor_state scissor;
255
256 struct NineVertexShader9 *vs;
257 BOOL programmable_vs;
258 float *vs_const_f;
259 float *vs_const_f_swvp;
260 int *vs_const_i;
261 BOOL *vs_const_b;
262 float *vs_lconstf_temp;
263
264 struct NinePixelShader9 *ps;
265 float *ps_const_f;
266 int ps_const_i[NINE_MAX_CONST_I][4];
267 BOOL ps_const_b[NINE_MAX_CONST_B];
268 float *ps_lconstf_temp;
269
270 struct NineVertexDeclaration9 *vdecl;
271
272 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
273 UINT stream_freq[PIPE_MAX_ATTRIBS];
274 uint32_t stream_instancedata_mask; /* derived from stream_freq */
275 uint32_t stream_usage_mask; /* derived from VS and vdecl */
276
277 struct pipe_resource *idxbuf;
278 unsigned index_offset;
279 unsigned index_size;
280
281 struct pipe_clip_state clip;
282
283 DWORD rs[NINED3DRS_COUNT];
284
285 struct {
286 BOOL enabled;
287 BOOL shadow;
288 DWORD lod;
289 D3DRESOURCETYPE type;
290 struct pipe_resource *resource;
291 struct pipe_sampler_view *view[2];
292 uint8_t pstype;
293 } texture[NINE_MAX_SAMPLERS];
294
295 DWORD samp[NINE_MAX_SAMPLERS][NINED3DSAMP_COUNT];
296
297 uint32_t samplers_shadow;
298
299 uint8_t bound_samplers_mask_vs;
300 uint16_t bound_samplers_mask_ps;
301
302 int dummy_vbo_bound_at; /* -1 = not bound , >= 0 = bound index */
303 boolean vbo_bound_done;
304
305 struct nine_ff_state ff;
306
307 /* software vertex processing */
308 boolean swvp;
309
310 uint32_t commit;
311 struct {
312 struct pipe_framebuffer_state fb;
313 struct pipe_depth_stencil_alpha_state dsa;
314 struct pipe_rasterizer_state rast;
315 struct pipe_blend_state blend;
316 struct pipe_constant_buffer cb_vs;
317 struct pipe_constant_buffer cb0_swvp;
318 struct pipe_constant_buffer cb1_swvp;
319 struct pipe_constant_buffer cb2_swvp;
320 struct pipe_constant_buffer cb3_swvp;
321 struct pipe_constant_buffer cb_ps;
322 struct pipe_constant_buffer cb_vs_ff;
323 struct pipe_constant_buffer cb_ps_ff;
324 } pipe_data;
325 };
326
327 struct nine_state_sw_internal {
328 struct pipe_transfer *transfers_so[4];
329 };
330
331 struct nine_clipplane {
332 float plane[4];
333 };
334 /* map D3DRS -> NINE_STATE_x
335 */
336 extern const uint32_t nine_render_state_group[NINED3DRS_COUNT];
337
338 /* for D3DSBT_PIXEL/VERTEX:
339 */
340 extern const uint32_t nine_render_states_pixel[(NINED3DRS_COUNT + 31) / 32];
341 extern const uint32_t nine_render_states_vertex[(NINED3DRS_COUNT + 31) / 32];
342
343 struct NineDevice9;
344
345 /* Internal multithreading: When enabled, the nine_context functions
346 * will append work to a worker thread when possible. Only the worker
347 * thread can access struct nine_context. */
348
349 void
350 nine_context_set_render_state(struct NineDevice9 *device,
351 D3DRENDERSTATETYPE State,
352 DWORD Value);
353
354 void
355 nine_context_set_texture(struct NineDevice9 *device,
356 DWORD Stage,
357 struct NineBaseTexture9 *tex);
358
359 void
360 nine_context_set_sampler_state(struct NineDevice9 *device,
361 DWORD Sampler,
362 D3DSAMPLERSTATETYPE Type,
363 DWORD Value);
364
365 void
366 nine_context_set_stream_source(struct NineDevice9 *device,
367 UINT StreamNumber,
368 struct NineVertexBuffer9 *pVBuf9,
369 UINT OffsetInBytes,
370 UINT Stride);
371
372 void
373 nine_context_set_stream_source_freq(struct NineDevice9 *device,
374 UINT StreamNumber,
375 UINT Setting);
376
377 void
378 nine_context_set_indices(struct NineDevice9 *device,
379 struct NineIndexBuffer9 *idxbuf);
380
381 void
382 nine_context_set_vertex_declaration(struct NineDevice9 *device,
383 struct NineVertexDeclaration9 *vdecl);
384
385 void
386 nine_context_set_vertex_shader(struct NineDevice9 *device,
387 struct NineVertexShader9 *pShader);
388
389 void
390 nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device,
391 UINT StartRegister,
392 const float *pConstantData,
393 const unsigned pConstantData_size,
394 UINT Vector4fCount);
395
396 void
397 nine_context_set_vertex_shader_constant_i(struct NineDevice9 *device,
398 UINT StartRegister,
399 const int *pConstantData,
400 const unsigned pConstantData_size,
401 UINT Vector4iCount);
402
403 void
404 nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device,
405 UINT StartRegister,
406 const BOOL *pConstantData,
407 const unsigned pConstantData_size,
408 UINT BoolCount);
409
410 void
411 nine_context_set_pixel_shader(struct NineDevice9 *device,
412 struct NinePixelShader9* ps);
413
414 void
415 nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device,
416 UINT StartRegister,
417 const float *pConstantData,
418 const unsigned pConstantData_size,
419 UINT Vector4fCount);
420
421 void
422 nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device,
423 UINT StartRegister,
424 const int *pConstantData,
425 const unsigned pConstantData_size,
426 UINT Vector4iCount);
427
428 void
429 nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
430 UINT StartRegister,
431 const BOOL *pConstantData,
432 const unsigned pConstantData_size,
433 UINT BoolCount);
434
435 void
436 nine_context_set_viewport(struct NineDevice9 *device,
437 const D3DVIEWPORT9 *viewport);
438
439 void
440 nine_context_set_scissor(struct NineDevice9 *device,
441 const struct pipe_scissor_state *scissor);
442
443 void
444 nine_context_set_transform(struct NineDevice9 *device,
445 D3DTRANSFORMSTATETYPE State,
446 const D3DMATRIX *pMatrix);
447
448 void
449 nine_context_set_material(struct NineDevice9 *device,
450 const D3DMATERIAL9 *pMaterial);
451
452 void
453 nine_context_set_light(struct NineDevice9 *device,
454 DWORD Index,
455 const D3DLIGHT9 *pLight);
456
457 void
458 nine_context_light_enable(struct NineDevice9 *device,
459 DWORD Index,
460 BOOL Enable);
461
462 void
463 nine_context_set_texture_stage_state(struct NineDevice9 *device,
464 DWORD Stage,
465 D3DTEXTURESTAGESTATETYPE Type,
466 DWORD Value);
467
468 void
469 nine_context_set_render_target(struct NineDevice9 *device,
470 DWORD RenderTargetIndex,
471 struct NineSurface9 *rt);
472
473 void
474 nine_context_set_depth_stencil(struct NineDevice9 *device,
475 struct NineSurface9 *ds);
476
477 void
478 nine_context_set_clip_plane(struct NineDevice9 *device,
479 DWORD Index,
480 const struct nine_clipplane *pPlane);
481
482 void
483 nine_context_set_swvp(struct NineDevice9 *device,
484 boolean swvp);
485
486 void
487 nine_context_apply_stateblock(struct NineDevice9 *device,
488 const struct nine_state *src);
489
490 void
491 nine_context_clear_fb(struct NineDevice9 *device, DWORD Count,
492 const D3DRECT *pRects, DWORD Flags,
493 D3DCOLOR Color, float Z, DWORD Stencil);
494
495 void
496 nine_context_draw_primitive(struct NineDevice9 *device,
497 D3DPRIMITIVETYPE PrimitiveType,
498 UINT StartVertex,
499 UINT PrimitiveCount);
500
501 void
502 nine_context_draw_indexed_primitive(struct NineDevice9 *device,
503 D3DPRIMITIVETYPE PrimitiveType,
504 INT BaseVertexIndex,
505 UINT MinVertexIndex,
506 UINT NumVertices,
507 UINT StartIndex,
508 UINT PrimitiveCount);
509
510 void
511 nine_context_draw_primitive_from_vtxbuf(struct NineDevice9 *device,
512 D3DPRIMITIVETYPE PrimitiveType,
513 UINT PrimitiveCount,
514 struct pipe_vertex_buffer *vtxbuf);
515
516 void
517 nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *device,
518 D3DPRIMITIVETYPE PrimitiveType,
519 UINT MinVertexIndex,
520 UINT NumVertices,
521 UINT PrimitiveCount,
522 struct pipe_vertex_buffer *vbuf,
523 struct pipe_resource *ibuf,
524 void *user_ibuf,
525 unsigned index_offset,
526 unsigned index_size);
527
528 void
529 nine_context_resource_copy_region(struct NineDevice9 *device,
530 struct NineUnknown *dst,
531 struct NineUnknown *src,
532 struct pipe_resource* dst_res,
533 unsigned dst_level,
534 const struct pipe_box *dst_box,
535 struct pipe_resource* src_res,
536 unsigned src_level,
537 const struct pipe_box *src_box);
538
539 void
540 nine_context_blit(struct NineDevice9 *device,
541 struct NineUnknown *dst,
542 struct NineUnknown *src,
543 struct pipe_blit_info *blit);
544
545 void
546 nine_context_clear_render_target(struct NineDevice9 *device,
547 struct NineSurface9 *surface,
548 D3DCOLOR color,
549 UINT x,
550 UINT y,
551 UINT width,
552 UINT height);
553
554 void
555 nine_context_gen_mipmap(struct NineDevice9 *device,
556 struct NineUnknown *dst,
557 struct pipe_resource *res,
558 UINT base_level, UINT last_level,
559 UINT first_layer, UINT last_layer,
560 UINT filter);
561
562 void
563 nine_context_range_upload(struct NineDevice9 *device,
564 unsigned *counter,
565 struct pipe_resource *res,
566 unsigned offset,
567 unsigned size,
568 const void *data);
569
570 void
571 nine_context_box_upload(struct NineDevice9 *device,
572 unsigned *counter,
573 struct NineUnknown *dst,
574 struct pipe_resource *res,
575 unsigned level,
576 const struct pipe_box *dst_box,
577 enum pipe_format src_format,
578 const void *src, unsigned src_stride,
579 unsigned src_layer_stride,
580 const struct pipe_box *src_box);
581
582 struct pipe_query *
583 nine_context_create_query(struct NineDevice9 *device, unsigned query_type);
584
585 void
586 nine_context_destroy_query(struct NineDevice9 *device, struct pipe_query *query);
587
588 void
589 nine_context_begin_query(struct NineDevice9 *device, unsigned *counter, struct pipe_query *query);
590
591 void
592 nine_context_end_query(struct NineDevice9 *device, unsigned *counter, struct pipe_query *query);
593
594 boolean
595 nine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *query,
596 unsigned *counter, boolean flush, boolean wait,
597 union pipe_query_result *result);
598
599 void nine_state_restore_non_cso(struct NineDevice9 *device);
600 void nine_state_set_defaults(struct NineDevice9 *, const D3DCAPS9 *,
601 boolean is_reset);
602 void nine_state_clear(struct nine_state *, const boolean device);
603 void nine_context_clear(struct NineDevice9 *);
604
605 void nine_state_init_sw(struct NineDevice9 *device);
606 void nine_state_prepare_draw_sw(struct NineDevice9 *device,
607 struct NineVertexDeclaration9 *vdecl_out,
608 int start_vertice,
609 int num_vertices,
610 struct pipe_stream_output_info *so);
611 void nine_state_after_draw_sw(struct NineDevice9 *device);
612 void nine_state_destroy_sw(struct NineDevice9 *device);
613
614 /* If @alloc is FALSE, the return value may be a const identity matrix.
615 * Therefore, do not modify if you set alloc to FALSE !
616 */
617 D3DMATRIX *
618 nine_state_access_transform(struct nine_ff_state *, D3DTRANSFORMSTATETYPE,
619 boolean alloc);
620
621 HRESULT
622 nine_state_set_light(struct nine_ff_state *, DWORD, const D3DLIGHT9 *);
623
624 HRESULT
625 nine_state_light_enable(struct nine_ff_state *, uint32_t *,
626 DWORD, BOOL);
627
628 const char *nine_d3drs_to_string(DWORD State);
629
630 /* CSMT functions */
631 struct csmt_context;
632
633 struct csmt_context *
634 nine_csmt_create( struct NineDevice9 *This );
635
636 void
637 nine_csmt_destroy( struct NineDevice9 *This, struct csmt_context *ctx );
638
639 void
640 nine_csmt_process( struct NineDevice9 *This );
641
642
643 /* Get the pipe_context (should not be called from the worker thread).
644 * All the work in the worker thread is finished before returning. */
645 struct pipe_context *
646 nine_context_get_pipe( struct NineDevice9 *device );
647
648 /* Can be called from all threads */
649 struct pipe_context *
650 nine_context_get_pipe_multithread( struct NineDevice9 *device );
651
652
653 /* Get the pipe_context (should not be called from the worker thread).
654 * All the work in the worker thread is paused before returning.
655 * It is neccessary to release in order to restart the thread.
656 * This is intended for use of the nine_context pipe_context that don't
657 * need the worker thread to finish all queued job. */
658 struct pipe_context *
659 nine_context_get_pipe_acquire( struct NineDevice9 *device );
660
661 void
662 nine_context_get_pipe_release( struct NineDevice9 *device );
663
664 #endif /* _NINE_STATE_H_ */