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