ReactOS  0.4.13-dev-1148-g9b75b67
stateblock.c
Go to the documentation of this file.
1 /*
2  * state block implementation
3  *
4  * Copyright 2002 Raphael Junqueira
5  * Copyright 2004 Jason Edmeades
6  * Copyright 2005 Oliver Stieber
7  * Copyright 2007 Stefan Dösinger for CodeWeavers
8  * Copyright 2009 Henri Verbeet for CodeWeavers
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include "config.h"
26 #include "wine/port.h"
27 #include "wined3d_private.h"
28 
30 
31 static const DWORD pixel_states_render[] =
32 {
97 };
98 
99 static const DWORD pixel_states_texture[] =
100 {
118 };
119 
120 static const DWORD pixel_states_sampler[] =
121 {
134 };
135 
136 static const DWORD vertex_states_render[] =
137 {
183 };
184 
185 static const DWORD vertex_states_texture[] =
186 {
189 };
190 
191 static const DWORD vertex_states_sampler[] =
192 {
194 };
195 
196 static inline void stateblock_set_bits(DWORD *map, UINT map_size)
197 {
198  DWORD mask = (1u << (map_size & 0x1f)) - 1;
199  memset(map, 0xff, (map_size >> 5) * sizeof(*map));
200  if (mask) map[map_size >> 5] = mask;
201 }
202 
203 /* Set all members of a stateblock savedstate to the given value */
204 static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, DWORD vs_consts, DWORD ps_consts)
205 {
206  unsigned int i;
207 
208  /* Single values */
209  states->indices = 1;
210  states->material = 1;
211  states->viewport = 1;
212  states->vertexDecl = 1;
213  states->pixelShader = 1;
214  states->vertexShader = 1;
215  states->scissorRect = 1;
216 
217  /* Fixed size arrays */
218  states->streamSource = 0xffff;
219  states->streamFreq = 0xffff;
220  states->textures = 0xfffff;
223  for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = 0x3ffff;
224  for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3ffe;
225  states->clipplane = (1u << MAX_CLIP_DISTANCES) - 1;
226  states->pixelShaderConstantsB = 0xffff;
227  states->pixelShaderConstantsI = 0xffff;
228  states->vertexShaderConstantsB = 0xffff;
229  states->vertexShaderConstantsI = 0xffff;
230 
231  /* Dynamically sized arrays */
232  memset(states->ps_consts_f, TRUE, sizeof(BOOL) * ps_consts);
233  memset(states->vs_consts_f, TRUE, sizeof(BOOL) * vs_consts);
234 }
235 
236 static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants)
237 {
238  DWORD texture_mask = 0;
239  WORD sampler_mask = 0;
240  unsigned int i;
241 
242  states->pixelShader = 1;
243 
244  for (i = 0; i < ARRAY_SIZE(pixel_states_render); ++i)
245  {
247  states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
248  }
249 
250  for (i = 0; i < ARRAY_SIZE(pixel_states_texture); ++i)
251  texture_mask |= 1u << pixel_states_texture[i];
252  for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = texture_mask;
253  for (i = 0; i < ARRAY_SIZE(pixel_states_sampler); ++i)
254  sampler_mask |= 1u << pixel_states_sampler[i];
255  for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
256  states->pixelShaderConstantsB = 0xffff;
257  states->pixelShaderConstantsI = 0xffff;
258 
259  memset(states->ps_consts_f, TRUE, sizeof(BOOL) * num_constants);
260 }
261 
262 static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *states, const DWORD num_constants)
263 {
264  DWORD texture_mask = 0;
265  WORD sampler_mask = 0;
266  unsigned int i;
267 
268  states->vertexDecl = 1;
269  states->vertexShader = 1;
270 
271  for (i = 0; i < ARRAY_SIZE(vertex_states_render); ++i)
272  {
274  states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
275  }
276 
277  for (i = 0; i < ARRAY_SIZE(vertex_states_texture); ++i)
278  texture_mask |= 1u << vertex_states_texture[i];
279  for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = texture_mask;
280  for (i = 0; i < ARRAY_SIZE(vertex_states_sampler); ++i)
281  sampler_mask |= 1u << vertex_states_sampler[i];
282  for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
283  states->vertexShaderConstantsB = 0xffff;
284  states->vertexShaderConstantsI = 0xffff;
285 
286  memset(states->vs_consts_f, TRUE, sizeof(BOOL) * num_constants);
287 }
288 
290 {
291  const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
292  unsigned int i, j;
293 
294  for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
295  {
296  DWORD map = stateblock->changed.renderState[i];
297  for (j = 0; map; map >>= 1, ++j)
298  {
299  if (!(map & 1)) continue;
300 
301  stateblock->contained_render_states[stateblock->num_contained_render_states] = (i << 5) | j;
302  ++stateblock->num_contained_render_states;
303  }
304  }
305 
306  for (i = 0; i <= HIGHEST_TRANSFORMSTATE >> 5; ++i)
307  {
308  DWORD map = stateblock->changed.transform[i];
309  for (j = 0; map; map >>= 1, ++j)
310  {
311  if (!(map & 1)) continue;
312 
313  stateblock->contained_transform_states[stateblock->num_contained_transform_states] = (i << 5) | j;
314  ++stateblock->num_contained_transform_states;
315  }
316  }
317 
318  for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
319  {
320  if (stateblock->changed.vs_consts_f[i])
321  {
322  stateblock->contained_vs_consts_f[stateblock->num_contained_vs_consts_f] = i;
323  ++stateblock->num_contained_vs_consts_f;
324  }
325  }
326 
327  for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
328  {
329  if (stateblock->changed.vertexShaderConstantsI & (1u << i))
330  {
331  stateblock->contained_vs_consts_i[stateblock->num_contained_vs_consts_i] = i;
332  ++stateblock->num_contained_vs_consts_i;
333  }
334  }
335 
336  for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
337  {
338  if (stateblock->changed.vertexShaderConstantsB & (1u << i))
339  {
340  stateblock->contained_vs_consts_b[stateblock->num_contained_vs_consts_b] = i;
341  ++stateblock->num_contained_vs_consts_b;
342  }
343  }
344 
345  for (i = 0; i < d3d_info->limits.ps_uniform_count; ++i)
346  {
347  if (stateblock->changed.ps_consts_f[i])
348  {
349  stateblock->contained_ps_consts_f[stateblock->num_contained_ps_consts_f] = i;
350  ++stateblock->num_contained_ps_consts_f;
351  }
352  }
353 
354  for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
355  {
356  if (stateblock->changed.pixelShaderConstantsI & (1u << i))
357  {
358  stateblock->contained_ps_consts_i[stateblock->num_contained_ps_consts_i] = i;
359  ++stateblock->num_contained_ps_consts_i;
360  }
361  }
362 
363  for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
364  {
365  if (stateblock->changed.pixelShaderConstantsB & (1u << i))
366  {
367  stateblock->contained_ps_consts_b[stateblock->num_contained_ps_consts_b] = i;
368  ++stateblock->num_contained_ps_consts_b;
369  }
370  }
371 
372  for (i = 0; i < MAX_TEXTURES; ++i)
373  {
374  DWORD map = stateblock->changed.textureState[i];
375 
376  for(j = 0; map; map >>= 1, ++j)
377  {
378  if (!(map & 1)) continue;
379 
380  stateblock->contained_tss_states[stateblock->num_contained_tss_states].stage = i;
381  stateblock->contained_tss_states[stateblock->num_contained_tss_states].state = j;
382  ++stateblock->num_contained_tss_states;
383  }
384  }
385 
386  for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
387  {
388  DWORD map = stateblock->changed.samplerState[i];
389 
390  for (j = 0; map; map >>= 1, ++j)
391  {
392  if (!(map & 1)) continue;
393 
394  stateblock->contained_sampler_states[stateblock->num_contained_sampler_states].stage = i;
395  stateblock->contained_sampler_states[stateblock->num_contained_sampler_states].state = j;
396  ++stateblock->num_contained_sampler_states;
397  }
398  }
399 }
400 
401 static void stateblock_init_lights(struct wined3d_stateblock *stateblock, struct list *light_map)
402 {
403  unsigned int i;
404 
405  for (i = 0; i < LIGHTMAP_SIZE; ++i)
406  {
407  const struct wined3d_light_info *src_light;
408 
409  LIST_FOR_EACH_ENTRY(src_light, &light_map[i], struct wined3d_light_info, entry)
410  {
411  struct wined3d_light_info *dst_light = heap_alloc(sizeof(*dst_light));
412 
413  *dst_light = *src_light;
414  list_add_tail(&stateblock->state.light_map[i], &dst_light->entry);
415  }
416  }
417 }
418 
420 {
421  ULONG refcount = InterlockedIncrement(&stateblock->ref);
422 
423  TRACE("%p increasing refcount to %u.\n", stateblock, refcount);
424 
425  return refcount;
426 }
427 
429 {
430  struct wined3d_unordered_access_view *uav;
431  struct wined3d_shader_resource_view *srv;
432  struct wined3d_vertex_declaration *decl;
433  struct wined3d_sampler *sampler;
434  struct wined3d_texture *texture;
435  struct wined3d_buffer *buffer;
436  struct wined3d_shader *shader;
437  unsigned int i, j;
438 
439  if ((decl = state->vertex_declaration))
440  {
441  state->vertex_declaration = NULL;
443  }
444 
445  for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
446  {
447  if ((texture = state->textures[i]))
448  {
449  state->textures[i] = NULL;
451  }
452  }
453 
454  for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i)
455  {
456  if ((buffer = state->stream_output[i].buffer))
457  {
458  state->stream_output[i].buffer = NULL;
460  }
461  }
462 
463  for (i = 0; i < MAX_STREAMS; ++i)
464  {
465  if ((buffer = state->streams[i].buffer))
466  {
467  state->streams[i].buffer = NULL;
469  }
470  }
471 
472  if ((buffer = state->index_buffer))
473  {
474  state->index_buffer = NULL;
476  }
477 
478  for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
479  {
480  if ((shader = state->shader[i]))
481  {
482  state->shader[i] = NULL;
484  }
485 
486  for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j)
487  {
488  if ((buffer = state->cb[i][j]))
489  {
490  state->cb[i][j] = NULL;
492  }
493  }
494 
495  for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j)
496  {
497  if ((sampler = state->sampler[i][j]))
498  {
499  state->sampler[i][j] = NULL;
501  }
502  }
503 
504  for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j)
505  {
506  if ((srv = state->shader_resource_view[i][j]))
507  {
508  state->shader_resource_view[i][j] = NULL;
510  }
511  }
512  }
513 
514  for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i)
515  {
516  for (j = 0; j < MAX_UNORDERED_ACCESS_VIEWS; ++j)
517  {
518  if ((uav = state->unordered_access_view[i][j]))
519  {
520  state->unordered_access_view[i][j] = NULL;
522  }
523  }
524  }
525 }
526 
528 {
529  unsigned int counter;
530 
531  if (!(state->flags & WINED3D_STATE_NO_REF))
533 
534  for (counter = 0; counter < MAX_ACTIVE_LIGHTS; ++counter)
535  {
536  state->lights[counter] = NULL;
537  }
538 
539  for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
540  {
541  struct list *e1, *e2;
542  LIST_FOR_EACH_SAFE(e1, e2, &state->light_map[counter])
543  {
545  list_remove(&light->entry);
546  heap_free(light);
547  }
548  }
549 }
550 
552 {
553  ULONG refcount = InterlockedDecrement(&stateblock->ref);
554 
555  TRACE("%p decreasing refcount to %u\n", stateblock, refcount);
556 
557  if (!refcount)
558  {
559  state_cleanup(&stateblock->state);
560  heap_free(stateblock);
561  }
562 
563  return refcount;
564 }
565 
567 {
568  struct wined3d_light_info *light_info;
569  unsigned int hash_idx;
570 
571  hash_idx = LIGHTMAP_HASHFUNC(idx);
572  LIST_FOR_EACH_ENTRY(light_info, &state->light_map[hash_idx], struct wined3d_light_info, entry)
573  {
574  if (light_info->OriginalIndex == idx)
575  return light_info;
576  }
577 
578  return NULL;
579 }
580 
581 void wined3d_state_enable_light(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info,
582  struct wined3d_light_info *light_info, BOOL enable)
583 {
584  unsigned int light_count, i;
585 
586  if (!(light_info->enabled = enable))
587  {
588  if (light_info->glIndex == -1)
589  {
590  TRACE("Light already disabled, nothing to do.\n");
591  return;
592  }
593 
594  state->lights[light_info->glIndex] = NULL;
595  light_info->glIndex = -1;
596  return;
597  }
598 
599  if (light_info->glIndex != -1)
600  {
601  TRACE("Light already enabled, nothing to do.\n");
602  return;
603  }
604 
605  /* Find a free light. */
606  light_count = d3d_info->limits.active_light_count;
607  for (i = 0; i < light_count; ++i)
608  {
609  if (state->lights[i])
610  continue;
611 
612  state->lights[i] = light_info;
613  light_info->glIndex = i;
614  return;
615  }
616 
617  /* Our tests show that Windows returns D3D_OK in this situation, even with
618  * D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE devices.
619  * This is consistent among ddraw, d3d8 and d3d9. GetLightEnable returns
620  * TRUE * as well for those lights.
621  *
622  * TODO: Test how this affects rendering. */
623  WARN("Too many concurrently active lights.\n");
624 }
625 
626 static void wined3d_state_record_lights(struct wined3d_state *dst_state, const struct wined3d_state *src_state)
627 {
628  UINT i;
629 
630  /* Lights... For a recorded state block, we just had a chain of actions
631  * to perform, so we need to walk that chain and update any actions which
632  * differ. */
633  for (i = 0; i < LIGHTMAP_SIZE; ++i)
634  {
635  struct list *e, *f;
636  LIST_FOR_EACH(e, &dst_state->light_map[i])
637  {
638  BOOL updated = FALSE;
639  struct wined3d_light_info *src = LIST_ENTRY(e, struct wined3d_light_info, entry), *realLight;
640 
641  /* Look up the light in the destination */
642  LIST_FOR_EACH(f, &src_state->light_map[i])
643  {
644  realLight = LIST_ENTRY(f, struct wined3d_light_info, entry);
645  if (realLight->OriginalIndex == src->OriginalIndex)
646  {
647  src->OriginalParms = realLight->OriginalParms;
648 
649  if (realLight->glIndex == -1 && src->glIndex != -1)
650  {
651  /* Light disabled */
652  dst_state->lights[src->glIndex] = NULL;
653  }
654  else if (realLight->glIndex != -1 && src->glIndex == -1)
655  {
656  /* Light enabled */
657  dst_state->lights[realLight->glIndex] = src;
658  }
659  src->glIndex = realLight->glIndex;
660  updated = TRUE;
661  break;
662  }
663  }
664 
665  if (!updated)
666  {
667  /* This can happen if the light was originally created as a
668  * default light for SetLightEnable() while recording. */
669  WARN("Light %u in dst_state %p does not exist in src_state %p.\n",
670  src->OriginalIndex, dst_state, src_state);
671 
672  src->OriginalParms = WINED3D_default_light;
673  if (src->glIndex != -1)
674  {
675  dst_state->lights[src->glIndex] = NULL;
676  src->glIndex = -1;
677  }
678  }
679  }
680  }
681 }
682 
684 {
685  const struct wined3d_state *src_state = &stateblock->device->state;
686  unsigned int i;
687  DWORD map;
688 
689  TRACE("stateblock %p.\n", stateblock);
690 
691  TRACE("Capturing state %p.\n", src_state);
692 
693  if (stateblock->changed.vertexShader && stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX]
694  != src_state->shader[WINED3D_SHADER_TYPE_VERTEX])
695  {
696  TRACE("Updating vertex shader from %p to %p\n",
697  stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX],
698  src_state->shader[WINED3D_SHADER_TYPE_VERTEX]);
699 
700  if (src_state->shader[WINED3D_SHADER_TYPE_VERTEX])
702  if (stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX])
704  stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX] = src_state->shader[WINED3D_SHADER_TYPE_VERTEX];
705  }
706 
707  /* Vertex shader float constants. */
708  for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
709  {
710  unsigned int idx = stateblock->contained_vs_consts_f[i];
711 
712  TRACE("Setting vs_consts_f[%u] to %s.\n", idx, debug_vec4(&src_state->vs_consts_f[idx]));
713 
714  stateblock->state.vs_consts_f[idx] = src_state->vs_consts_f[idx];
715  }
716 
717  /* Vertex shader integer constants. */
718  for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
719  {
720  unsigned int idx = stateblock->contained_vs_consts_i[i];
721 
722  TRACE("Setting vs_consts[%u] to %s.\n", idx, debug_ivec4(&src_state->vs_consts_i[idx]));
723 
724  stateblock->state.vs_consts_i[idx] = src_state->vs_consts_i[idx];
725  }
726 
727  /* Vertex shader boolean constants. */
728  for (i = 0; i < stateblock->num_contained_vs_consts_b; ++i)
729  {
730  unsigned int idx = stateblock->contained_vs_consts_b[i];
731 
732  TRACE("Setting vs_consts_b[%u] to %s.\n",
733  idx, src_state->vs_consts_b[idx] ? "TRUE" : "FALSE");
734 
735  stateblock->state.vs_consts_b[idx] = src_state->vs_consts_b[idx];
736  }
737 
738  /* Pixel shader float constants. */
739  for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
740  {
741  unsigned int idx = stateblock->contained_ps_consts_f[i];
742 
743  TRACE("Setting ps_consts_f[%u] to %s.\n", idx, debug_vec4(&src_state->ps_consts_f[idx]));
744 
745  stateblock->state.ps_consts_f[idx] = src_state->ps_consts_f[idx];
746  }
747 
748  /* Pixel shader integer constants. */
749  for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i)
750  {
751  unsigned int idx = stateblock->contained_ps_consts_i[i];
752 
753  TRACE("Setting ps_consts_i[%u] to %s.\n", idx, debug_ivec4(&src_state->ps_consts_i[idx]));
754 
755  stateblock->state.ps_consts_i[idx] = src_state->ps_consts_i[idx];
756  }
757 
758  /* Pixel shader boolean constants. */
759  for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i)
760  {
761  unsigned int idx = stateblock->contained_ps_consts_b[i];
762  TRACE("Setting ps_consts_b[%u] to %s.\n",
763  idx, src_state->ps_consts_b[idx] ? "TRUE" : "FALSE");
764 
765  stateblock->state.ps_consts_b[idx] = src_state->ps_consts_b[idx];
766  }
767 
768  /* Others + Render & Texture */
769  for (i = 0; i < stateblock->num_contained_transform_states; ++i)
770  {
772 
773  TRACE("Updating transform %#x.\n", transform);
774 
775  stateblock->state.transforms[transform] = src_state->transforms[transform];
776  }
777 
778  if (stateblock->changed.indices
779  && ((stateblock->state.index_buffer != src_state->index_buffer)
780  || (stateblock->state.base_vertex_index != src_state->base_vertex_index)
781  || (stateblock->state.index_format != src_state->index_format)
782  || (stateblock->state.index_offset != src_state->index_offset)))
783  {
784  TRACE("Updating index buffer to %p, base vertex index to %d.\n",
785  src_state->index_buffer, src_state->base_vertex_index);
786 
787  if (src_state->index_buffer)
789  if (stateblock->state.index_buffer)
790  wined3d_buffer_decref(stateblock->state.index_buffer);
791  stateblock->state.index_buffer = src_state->index_buffer;
792  stateblock->state.base_vertex_index = src_state->base_vertex_index;
793  stateblock->state.index_format = src_state->index_format;
794  stateblock->state.index_offset = src_state->index_offset;
795  }
796 
797  if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration != src_state->vertex_declaration)
798  {
799  TRACE("Updating vertex declaration from %p to %p.\n",
800  stateblock->state.vertex_declaration, src_state->vertex_declaration);
801 
802  if (src_state->vertex_declaration)
804  if (stateblock->state.vertex_declaration)
805  wined3d_vertex_declaration_decref(stateblock->state.vertex_declaration);
806  stateblock->state.vertex_declaration = src_state->vertex_declaration;
807  }
808 
809  if (stateblock->changed.material
810  && memcmp(&src_state->material, &stateblock->state.material, sizeof(stateblock->state.material)))
811  {
812  TRACE("Updating material.\n");
813 
814  stateblock->state.material = src_state->material;
815  }
816 
817  assert(src_state->viewport_count <= 1);
818 
819  if (stateblock->changed.viewport
820  && (src_state->viewport_count != stateblock->state.viewport_count
821  || memcmp(src_state->viewports, stateblock->state.viewports,
822  src_state->viewport_count * sizeof(*stateblock->state.viewports))))
823  {
824  TRACE("Updating viewports.\n");
825 
826  if ((stateblock->state.viewport_count = src_state->viewport_count))
827  memcpy(stateblock->state.viewports, src_state->viewports, sizeof(src_state->viewports));
828  else
829  memset(stateblock->state.viewports, 0, sizeof(*stateblock->state.viewports));
830  }
831 
832  if (stateblock->changed.scissorRect
833  && (src_state->scissor_rect_count != stateblock->state.scissor_rect_count
834  || memcmp(src_state->scissor_rects, stateblock->state.scissor_rects,
835  src_state->scissor_rect_count * sizeof(*stateblock->state.scissor_rects))))
836  {
837  TRACE("Updating scissor rects.\n");
838 
839  if ((stateblock->state.scissor_rect_count = src_state->scissor_rect_count))
840  memcpy(stateblock->state.scissor_rects, src_state->scissor_rects,
841  src_state->scissor_rect_count * sizeof(*src_state->scissor_rects));
842  else
843  SetRectEmpty(stateblock->state.scissor_rects);
844  }
845 
846  map = stateblock->changed.streamSource;
847  for (i = 0; map; map >>= 1, ++i)
848  {
849  if (!(map & 1)) continue;
850 
851  if (stateblock->state.streams[i].stride != src_state->streams[i].stride
852  || stateblock->state.streams[i].buffer != src_state->streams[i].buffer)
853  {
854  TRACE("Updating stream source %u to %p, stride to %u.\n",
855  i, src_state->streams[i].buffer,
856  src_state->streams[i].stride);
857 
858  stateblock->state.streams[i].stride = src_state->streams[i].stride;
859  if (src_state->streams[i].buffer)
860  wined3d_buffer_incref(src_state->streams[i].buffer);
861  if (stateblock->state.streams[i].buffer)
862  wined3d_buffer_decref(stateblock->state.streams[i].buffer);
863  stateblock->state.streams[i].buffer = src_state->streams[i].buffer;
864  }
865  }
866 
867  map = stateblock->changed.streamFreq;
868  for (i = 0; map; map >>= 1, ++i)
869  {
870  if (!(map & 1)) continue;
871 
872  if (stateblock->state.streams[i].frequency != src_state->streams[i].frequency
873  || stateblock->state.streams[i].flags != src_state->streams[i].flags)
874  {
875  TRACE("Updating stream frequency %u to %u flags to %#x.\n",
876  i, src_state->streams[i].frequency, src_state->streams[i].flags);
877 
878  stateblock->state.streams[i].frequency = src_state->streams[i].frequency;
879  stateblock->state.streams[i].flags = src_state->streams[i].flags;
880  }
881  }
882 
883  map = stateblock->changed.clipplane;
884  for (i = 0; map; map >>= 1, ++i)
885  {
886  if (!(map & 1)) continue;
887 
888  if (memcmp(&stateblock->state.clip_planes[i], &src_state->clip_planes[i], sizeof(src_state->clip_planes[i])))
889  {
890  TRACE("Updating clipplane %u.\n", i);
891  stateblock->state.clip_planes[i] = src_state->clip_planes[i];
892  }
893  }
894 
895  /* Render */
896  for (i = 0; i < stateblock->num_contained_render_states; ++i)
897  {
898  enum wined3d_render_state rs = stateblock->contained_render_states[i];
899 
900  TRACE("Updating render state %#x to %u.\n", rs, src_state->render_states[rs]);
901 
902  stateblock->state.render_states[rs] = src_state->render_states[rs];
903  }
904 
905  /* Texture states */
906  for (i = 0; i < stateblock->num_contained_tss_states; ++i)
907  {
908  DWORD stage = stateblock->contained_tss_states[i].stage;
909  DWORD state = stateblock->contained_tss_states[i].state;
910 
911  TRACE("Updating texturestage state %u, %u to %#x (was %#x).\n", stage, state,
912  src_state->texture_states[stage][state], stateblock->state.texture_states[stage][state]);
913 
914  stateblock->state.texture_states[stage][state] = src_state->texture_states[stage][state];
915  }
916 
917  /* Samplers */
918  map = stateblock->changed.textures;
919  for (i = 0; map; map >>= 1, ++i)
920  {
921  if (!(map & 1)) continue;
922 
923  TRACE("Updating texture %u to %p (was %p).\n",
924  i, src_state->textures[i], stateblock->state.textures[i]);
925 
926  if (src_state->textures[i])
927  wined3d_texture_incref(src_state->textures[i]);
928  if (stateblock->state.textures[i])
929  wined3d_texture_decref(stateblock->state.textures[i]);
930  stateblock->state.textures[i] = src_state->textures[i];
931  }
932 
933  for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
934  {
935  DWORD stage = stateblock->contained_sampler_states[i].stage;
936  DWORD state = stateblock->contained_sampler_states[i].state;
937 
938  TRACE("Updating sampler state %u, %u to %#x (was %#x).\n", stage, state,
939  src_state->sampler_states[stage][state], stateblock->state.sampler_states[stage][state]);
940 
941  stateblock->state.sampler_states[stage][state] = src_state->sampler_states[stage][state];
942  }
943 
944  if (stateblock->changed.pixelShader && stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL]
945  != src_state->shader[WINED3D_SHADER_TYPE_PIXEL])
946  {
947  if (src_state->shader[WINED3D_SHADER_TYPE_PIXEL])
949  if (stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL])
951  stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL] = src_state->shader[WINED3D_SHADER_TYPE_PIXEL];
952  }
953 
954  wined3d_state_record_lights(&stateblock->state, src_state);
955 
956  TRACE("Capture done.\n");
957 }
958 
959 static void apply_lights(struct wined3d_device *device, const struct wined3d_state *state)
960 {
961  UINT i;
962 
963  for (i = 0; i < LIGHTMAP_SIZE; ++i)
964  {
965  struct list *e;
966 
967  LIST_FOR_EACH(e, &state->light_map[i])
968  {
969  const struct wined3d_light_info *light = LIST_ENTRY(e, struct wined3d_light_info, entry);
970 
971  wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
972  wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1);
973  }
974  }
975 }
976 
977 void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
978 {
979  struct wined3d_device *device = stateblock->device;
980  unsigned int i;
981  DWORD map;
982 
983  TRACE("Applying stateblock %p to device %p.\n", stateblock, device);
984 
985  if (stateblock->changed.vertexShader)
987 
988  /* Vertex Shader Constants. */
989  for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
990  {
992  1, &stateblock->state.vs_consts_f[stateblock->contained_vs_consts_f[i]]);
993  }
994  for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
995  {
997  1, &stateblock->state.vs_consts_i[stateblock->contained_vs_consts_i[i]]);
998  }
999  for (i = 0; i < stateblock->num_contained_vs_consts_b; ++i)
1000  {
1002  1, &stateblock->state.vs_consts_b[stateblock->contained_vs_consts_b[i]]);
1003  }
1004 
1005  apply_lights(device, &stateblock->state);
1006 
1007  if (stateblock->changed.pixelShader)
1009 
1010  /* Pixel Shader Constants. */
1011  for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
1012  {
1014  1, &stateblock->state.ps_consts_f[stateblock->contained_ps_consts_f[i]]);
1015  }
1016  for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i)
1017  {
1019  1, &stateblock->state.ps_consts_i[stateblock->contained_ps_consts_i[i]]);
1020  }
1021  for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i)
1022  {
1024  1, &stateblock->state.ps_consts_b[stateblock->contained_ps_consts_b[i]]);
1025  }
1026 
1027  /* Render states. */
1028  for (i = 0; i < stateblock->num_contained_render_states; ++i)
1029  {
1031  stateblock->state.render_states[stateblock->contained_render_states[i]]);
1032  }
1033 
1034  /* Texture states. */
1035  for (i = 0; i < stateblock->num_contained_tss_states; ++i)
1036  {
1037  DWORD stage = stateblock->contained_tss_states[i].stage;
1038  DWORD state = stateblock->contained_tss_states[i].state;
1039 
1040  wined3d_device_set_texture_stage_state(device, stage, state, stateblock->state.texture_states[stage][state]);
1041  }
1042 
1043  /* Sampler states. */
1044  for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
1045  {
1046  DWORD stage = stateblock->contained_sampler_states[i].stage;
1047  DWORD state = stateblock->contained_sampler_states[i].state;
1048  DWORD value = stateblock->state.sampler_states[stage][state];
1049 
1052  }
1053 
1054  /* Transform states. */
1055  for (i = 0; i < stateblock->num_contained_transform_states; ++i)
1056  {
1058  &stateblock->state.transforms[stateblock->contained_transform_states[i]]);
1059  }
1060 
1061  if (stateblock->changed.indices)
1062  {
1063  wined3d_device_set_index_buffer(device, stateblock->state.index_buffer,
1064  stateblock->state.index_format, stateblock->state.index_offset);
1065  wined3d_device_set_base_vertex_index(device, stateblock->state.base_vertex_index);
1066  }
1067 
1068  if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration)
1069  wined3d_device_set_vertex_declaration(device, stateblock->state.vertex_declaration);
1070 
1071  if (stateblock->changed.material)
1072  wined3d_device_set_material(device, &stateblock->state.material);
1073 
1074  if (stateblock->changed.viewport)
1075  wined3d_device_set_viewports(device, stateblock->state.viewport_count, stateblock->state.viewports);
1076 
1077  if (stateblock->changed.scissorRect)
1078  wined3d_device_set_scissor_rects(device, stateblock->state.scissor_rect_count,
1079  stateblock->state.scissor_rects);
1080 
1081  map = stateblock->changed.streamSource;
1082  for (i = 0; map; map >>= 1, ++i)
1083  {
1084  if (map & 1)
1086  stateblock->state.streams[i].buffer,
1087  0, stateblock->state.streams[i].stride);
1088  }
1089 
1090  map = stateblock->changed.streamFreq;
1091  for (i = 0; map; map >>= 1, ++i)
1092  {
1093  if (map & 1)
1095  stateblock->state.streams[i].frequency | stateblock->state.streams[i].flags);
1096  }
1097 
1098  map = stateblock->changed.textures;
1099  for (i = 0; map; map >>= 1, ++i)
1100  {
1101  DWORD stage;
1102 
1103  if (!(map & 1)) continue;
1104 
1106  wined3d_device_set_texture(device, stage, stateblock->state.textures[i]);
1107  }
1108 
1109  map = stateblock->changed.clipplane;
1110  for (i = 0; map; map >>= 1, ++i)
1111  {
1112  if (!(map & 1)) continue;
1113 
1114  wined3d_device_set_clip_plane(device, i, &stateblock->state.clip_planes[i]);
1115  }
1116 
1117  TRACE("Applied stateblock %p.\n", stateblock);
1118 }
1119 
1120 static void state_init_default(struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
1121 {
1122  union
1123  {
1124  struct wined3d_line_pattern lp;
1125  DWORD d;
1126  } lp;
1127  union {
1128  float f;
1129  DWORD d;
1130  } tmpfloat;
1131  unsigned int i;
1132  struct wined3d_matrix identity;
1133 
1134  TRACE("state %p, gl_info %p.\n", state, gl_info);
1135 
1137  state->gl_primitive_type = ~0u;
1138  state->gl_patch_vertices = 0;
1139 
1140  /* Set some of the defaults for lights, transforms etc */
1141  state->transforms[WINED3D_TS_PROJECTION] = identity;
1142  state->transforms[WINED3D_TS_VIEW] = identity;
1143  for (i = 0; i < 256; ++i)
1144  {
1145  state->transforms[WINED3D_TS_WORLD_MATRIX(i)] = identity;
1146  }
1147 
1148  TRACE("Render states\n");
1149  /* Render states: */
1150  state->render_states[WINED3D_RS_ZENABLE] = WINED3D_ZB_TRUE;
1151  state->render_states[WINED3D_RS_FILLMODE] = WINED3D_FILL_SOLID;
1153  lp.lp.repeat_factor = 0;
1154  lp.lp.line_pattern = 0;
1155  state->render_states[WINED3D_RS_LINEPATTERN] = lp.d;
1156  state->render_states[WINED3D_RS_ZWRITEENABLE] = TRUE;
1157  state->render_states[WINED3D_RS_ALPHATESTENABLE] = FALSE;
1158  state->render_states[WINED3D_RS_LASTPIXEL] = TRUE;
1159  state->render_states[WINED3D_RS_SRCBLEND] = WINED3D_BLEND_ONE;
1160  state->render_states[WINED3D_RS_DESTBLEND] = WINED3D_BLEND_ZERO;
1161  state->render_states[WINED3D_RS_CULLMODE] = WINED3D_CULL_BACK;
1162  state->render_states[WINED3D_RS_ZFUNC] = WINED3D_CMP_LESSEQUAL;
1163  state->render_states[WINED3D_RS_ALPHAFUNC] = WINED3D_CMP_ALWAYS;
1164  state->render_states[WINED3D_RS_ALPHAREF] = 0;
1165  state->render_states[WINED3D_RS_DITHERENABLE] = FALSE;
1166  state->render_states[WINED3D_RS_ALPHABLENDENABLE] = FALSE;
1167  state->render_states[WINED3D_RS_FOGENABLE] = FALSE;
1168  state->render_states[WINED3D_RS_SPECULARENABLE] = FALSE;
1169  state->render_states[WINED3D_RS_ZVISIBLE] = 0;
1170  state->render_states[WINED3D_RS_FOGCOLOR] = 0;
1172  tmpfloat.f = 0.0f;
1173  state->render_states[WINED3D_RS_FOGSTART] = tmpfloat.d;
1174  tmpfloat.f = 1.0f;
1175  state->render_states[WINED3D_RS_FOGEND] = tmpfloat.d;
1176  tmpfloat.f = 1.0f;
1177  state->render_states[WINED3D_RS_FOGDENSITY] = tmpfloat.d;
1178  state->render_states[WINED3D_RS_EDGEANTIALIAS] = FALSE;
1179  state->render_states[WINED3D_RS_RANGEFOGENABLE] = FALSE;
1180  state->render_states[WINED3D_RS_STENCILENABLE] = FALSE;
1184  state->render_states[WINED3D_RS_STENCILREF] = 0;
1185  state->render_states[WINED3D_RS_STENCILMASK] = 0xffffffff;
1187  state->render_states[WINED3D_RS_STENCILWRITEMASK] = 0xffffffff;
1188  state->render_states[WINED3D_RS_TEXTUREFACTOR] = 0xffffffff;
1189  state->render_states[WINED3D_RS_WRAP0] = 0;
1190  state->render_states[WINED3D_RS_WRAP1] = 0;
1191  state->render_states[WINED3D_RS_WRAP2] = 0;
1192  state->render_states[WINED3D_RS_WRAP3] = 0;
1193  state->render_states[WINED3D_RS_WRAP4] = 0;
1194  state->render_states[WINED3D_RS_WRAP5] = 0;
1195  state->render_states[WINED3D_RS_WRAP6] = 0;
1196  state->render_states[WINED3D_RS_WRAP7] = 0;
1197  state->render_states[WINED3D_RS_CLIPPING] = TRUE;
1198  state->render_states[WINED3D_RS_LIGHTING] = TRUE;
1199  state->render_states[WINED3D_RS_AMBIENT] = 0;
1201  state->render_states[WINED3D_RS_COLORVERTEX] = TRUE;
1202  state->render_states[WINED3D_RS_LOCALVIEWER] = TRUE;
1203  state->render_states[WINED3D_RS_NORMALIZENORMALS] = FALSE;
1209  state->render_states[WINED3D_RS_CLIPPLANEENABLE] = 0;
1211  tmpfloat.f = 1.0f;
1212  state->render_states[WINED3D_RS_POINTSIZE] = tmpfloat.d;
1213  tmpfloat.f = 1.0f;
1214  state->render_states[WINED3D_RS_POINTSIZE_MIN] = tmpfloat.d;
1215  state->render_states[WINED3D_RS_POINTSPRITEENABLE] = FALSE;
1216  state->render_states[WINED3D_RS_POINTSCALEENABLE] = FALSE;
1217  tmpfloat.f = 1.0f;
1218  state->render_states[WINED3D_RS_POINTSCALE_A] = tmpfloat.d;
1219  tmpfloat.f = 0.0f;
1220  state->render_states[WINED3D_RS_POINTSCALE_B] = tmpfloat.d;
1221  tmpfloat.f = 0.0f;
1222  state->render_states[WINED3D_RS_POINTSCALE_C] = tmpfloat.d;
1223  state->render_states[WINED3D_RS_MULTISAMPLEANTIALIAS] = TRUE;
1224  state->render_states[WINED3D_RS_MULTISAMPLEMASK] = 0xffffffff;
1226  tmpfloat.f = 1.0f;
1227  state->render_states[WINED3D_RS_PATCHSEGMENTS] = tmpfloat.d;
1228  state->render_states[WINED3D_RS_DEBUGMONITORTOKEN] = 0xbaadcafe;
1229  tmpfloat.f = gl_info->limits.pointsize_max;
1230  state->render_states[WINED3D_RS_POINTSIZE_MAX] = tmpfloat.d;
1232  tmpfloat.f = 0.0f;
1233  state->render_states[WINED3D_RS_TWEENFACTOR] = tmpfloat.d;
1234  state->render_states[WINED3D_RS_BLENDOP] = WINED3D_BLEND_OP_ADD;
1237  /* states new in d3d9 */
1238  state->render_states[WINED3D_RS_SCISSORTESTENABLE] = FALSE;
1239  state->render_states[WINED3D_RS_SLOPESCALEDEPTHBIAS] = 0;
1240  tmpfloat.f = 1.0f;
1241  state->render_states[WINED3D_RS_MINTESSELLATIONLEVEL] = tmpfloat.d;
1242  state->render_states[WINED3D_RS_MAXTESSELLATIONLEVEL] = tmpfloat.d;
1243  state->render_states[WINED3D_RS_ANTIALIASEDLINEENABLE] = FALSE;
1244  tmpfloat.f = 0.0f;
1245  state->render_states[WINED3D_RS_ADAPTIVETESS_X] = tmpfloat.d;
1246  state->render_states[WINED3D_RS_ADAPTIVETESS_Y] = tmpfloat.d;
1247  tmpfloat.f = 1.0f;
1248  state->render_states[WINED3D_RS_ADAPTIVETESS_Z] = tmpfloat.d;
1249  tmpfloat.f = 0.0f;
1250  state->render_states[WINED3D_RS_ADAPTIVETESS_W] = tmpfloat.d;
1252  state->render_states[WINED3D_RS_TWOSIDEDSTENCILMODE] = FALSE;
1257  state->render_states[WINED3D_RS_BLENDFACTOR] = 0xffffffff;
1258  state->render_states[WINED3D_RS_SRGBWRITEENABLE] = 0;
1259  state->render_states[WINED3D_RS_DEPTHBIAS] = 0;
1260  tmpfloat.f = 0.0f;
1261  state->render_states[WINED3D_RS_DEPTHBIASCLAMP] = tmpfloat.d;
1262  state->render_states[WINED3D_RS_WRAP8] = 0;
1263  state->render_states[WINED3D_RS_WRAP9] = 0;
1264  state->render_states[WINED3D_RS_WRAP10] = 0;
1265  state->render_states[WINED3D_RS_WRAP11] = 0;
1266  state->render_states[WINED3D_RS_WRAP12] = 0;
1267  state->render_states[WINED3D_RS_WRAP13] = 0;
1268  state->render_states[WINED3D_RS_WRAP14] = 0;
1269  state->render_states[WINED3D_RS_WRAP15] = 0;
1274  for (i = 0; i < MAX_RENDER_TARGETS; ++i)
1275  state->render_states[WINED3D_RS_COLORWRITE(i)] = 0x0000000f;
1276 
1277  /* Texture Stage States - Put directly into state block, we will call function below */
1278  for (i = 0; i < MAX_TEXTURES; ++i)
1279  {
1280  TRACE("Setting up default texture states for texture Stage %u.\n", i);
1281  state->transforms[WINED3D_TS_TEXTURE0 + i] = identity;
1283  state->texture_states[i][WINED3D_TSS_COLOR_ARG1] = WINED3DTA_TEXTURE;
1284  state->texture_states[i][WINED3D_TSS_COLOR_ARG2] = WINED3DTA_CURRENT;
1286  state->texture_states[i][WINED3D_TSS_ALPHA_ARG1] = WINED3DTA_TEXTURE;
1287  state->texture_states[i][WINED3D_TSS_ALPHA_ARG2] = WINED3DTA_CURRENT;
1288  state->texture_states[i][WINED3D_TSS_BUMPENV_MAT00] = 0;
1289  state->texture_states[i][WINED3D_TSS_BUMPENV_MAT01] = 0;
1290  state->texture_states[i][WINED3D_TSS_BUMPENV_MAT10] = 0;
1291  state->texture_states[i][WINED3D_TSS_BUMPENV_MAT11] = 0;
1292  state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX] = i;
1293  state->texture_states[i][WINED3D_TSS_BUMPENV_LSCALE] = 0;
1294  state->texture_states[i][WINED3D_TSS_BUMPENV_LOFFSET] = 0;
1296  state->texture_states[i][WINED3D_TSS_COLOR_ARG0] = WINED3DTA_CURRENT;
1297  state->texture_states[i][WINED3D_TSS_ALPHA_ARG0] = WINED3DTA_CURRENT;
1298  state->texture_states[i][WINED3D_TSS_RESULT_ARG] = WINED3DTA_CURRENT;
1299  }
1300 
1301  for (i = 0 ; i < MAX_COMBINED_SAMPLERS; ++i)
1302  {
1303  TRACE("Setting up default samplers states for sampler %u.\n", i);
1307  state->sampler_states[i][WINED3D_SAMP_BORDER_COLOR] = 0;
1308  state->sampler_states[i][WINED3D_SAMP_MAG_FILTER] = WINED3D_TEXF_POINT;
1309  state->sampler_states[i][WINED3D_SAMP_MIN_FILTER] = WINED3D_TEXF_POINT;
1310  state->sampler_states[i][WINED3D_SAMP_MIP_FILTER] = WINED3D_TEXF_NONE;
1311  state->sampler_states[i][WINED3D_SAMP_MIPMAP_LOD_BIAS] = 0;
1312  state->sampler_states[i][WINED3D_SAMP_MAX_MIP_LEVEL] = 0;
1313  state->sampler_states[i][WINED3D_SAMP_MAX_ANISOTROPY] = 1;
1314  state->sampler_states[i][WINED3D_SAMP_SRGB_TEXTURE] = 0;
1315  /* TODO: Indicates which element of a multielement texture to use. */
1316  state->sampler_states[i][WINED3D_SAMP_ELEMENT_INDEX] = 0;
1317  /* TODO: Vertex offset in the presampled displacement map. */
1318  state->sampler_states[i][WINED3D_SAMP_DMAP_OFFSET] = 0;
1319  }
1320 }
1321 
1323  const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info,
1324  DWORD flags)
1325 {
1326  unsigned int i;
1327 
1328  state->flags = flags;
1329  state->fb = fb;
1330 
1331  for (i = 0; i < LIGHTMAP_SIZE; i++)
1332  {
1333  list_init(&state->light_map[i]);
1334  }
1335 
1337  state_init_default(state, gl_info);
1338 }
1339 
1340 static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
1342 {
1343  const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
1344 
1345  stateblock->ref = 1;
1346  stateblock->device = device;
1347  state_init(&stateblock->state, NULL, &device->adapter->gl_info, d3d_info, 0);
1348 
1349  if (type == WINED3D_SBT_RECORDED)
1350  return WINED3D_OK;
1351 
1352  TRACE("Updating changed flags appropriate for type %#x.\n", type);
1353 
1354  switch (type)
1355  {
1356  case WINED3D_SBT_ALL:
1357  stateblock_init_lights(stateblock, device->state.light_map);
1359  d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
1360  break;
1361 
1364  d3d_info->limits.ps_uniform_count);
1365  break;
1366 
1368  stateblock_init_lights(stateblock, device->state.light_map);
1370  d3d_info->limits.vs_uniform_count);
1371  break;
1372 
1373  default:
1374  FIXME("Unrecognized state block type %#x.\n", type);
1375  break;
1376  }
1377 
1379  wined3d_stateblock_capture(stateblock);
1380 
1381  return WINED3D_OK;
1382 }
1383 
1385  enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock)
1386 {
1387  struct wined3d_stateblock *object;
1388  HRESULT hr;
1389 
1390  TRACE("device %p, type %#x, stateblock %p.\n",
1391  device, type, stateblock);
1392 
1393  if (!(object = heap_alloc_zero(sizeof(*object))))
1394  return E_OUTOFMEMORY;
1395 
1396  hr = stateblock_init(object, device, type);
1397  if (FAILED(hr))
1398  {
1399  WARN("Failed to initialize stateblock, hr %#x.\n", hr);
1400  heap_free(object);
1401  return hr;
1402  }
1403 
1404  TRACE("Created stateblock %p.\n", object);
1405  *stateblock = object;
1406 
1407  return WINED3D_OK;
1408 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define MAX_RENDER_TARGETS
void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader)
Definition: device.c:2226
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:673
unsigned int num_contained_ps_consts_f
#define MAX_TEXTURES
BOOL ps_consts_f[WINED3D_MAX_PS_CONSTS_F]
unsigned int num_contained_tss_states
void CDECL wined3d_device_set_render_state(struct wined3d_device *device, enum wined3d_render_state state, DWORD value)
Definition: device.c:2048
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
const struct wined3d_light WINED3D_default_light
Definition: device.c:41
DWORD contained_render_states[WINEHIGHEST_RENDER_STATE+1]
#define TRUE
Definition: types.h:120
DWORD contained_transform_states[HIGHEST_TRANSFORMSTATE+1]
HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
Definition: device.c:2503
const char * debug_ivec4(const struct wined3d_ivec4 *v)
Definition: utils.c:3898
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define MAX_SHADER_RESOURCE_VIEWS
struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F]
HRESULT hr
Definition: shlfolder.c:183
DWORD transform[(HIGHEST_TRANSFORMSTATE >> 5)+1]
struct wined3d_state state
struct wined3d_saved_states changed
void get_identity_matrix(struct wined3d_matrix *mat)
Definition: utils.c:4827
struct wined3d_vertex_declaration * vertex_declaration
WORD samplerState[MAX_COMBINED_SAMPLERS]
static const DWORD vertex_states_sampler[]
Definition: stateblock.c:191
#define WINED3D_MAX_CONSTS_I
WINE_DEFAULT_DEBUG_CHANNEL(d3d9)
struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]
#define MAX_CONSTANT_BUFFERS
#define WARN(fmt,...)
Definition: debug.h:111
void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration)
Definition: device.c:2197
BOOL vs_consts_f[WINED3D_MAX_VS_CONSTS_F]
#define WINED3D_MAX_STREAM_OUTPUT_BUFFERS
Definition: wined3d.h:1569
RECT scissor_rects[WINED3D_MAX_VIEWPORTS]
DWORD contained_vs_consts_b[WINED3D_MAX_CONSTS_B]
struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]
struct wined3d_texture * textures[MAX_COMBINED_SAMPLERS]
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
#define MAX_ACTIVE_LIGHTS
GLuint buffer
Definition: glext.h:5915
HRESULT CDECL wined3d_device_set_vs_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
Definition: device.c:2455
static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants)
Definition: stateblock.c:236
HRESULT CDECL wined3d_stateblock_create(struct wined3d_device *device, enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock)
Definition: stateblock.c:1384
void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device, UINT stage, enum wined3d_texture_stage_state state, DWORD value)
Definition: device.c:3462
struct StageState contained_sampler_states[MAX_COMBINED_SAMPLERS *WINED3D_HIGHEST_SAMPLER_STATE]
static enum wined3d_render_state WINED3D_RS_COLORWRITE(int index)
Definition: wined3d.h:399
DWORD contained_ps_consts_i[WINED3D_MAX_CONSTS_I]
#define WINED3DTA_CURRENT
Definition: wined3d.h:877
void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset)
Definition: device.c:1877
static void wined3d_state_record_lights(struct wined3d_state *dst_state, const struct wined3d_state *src_state)
Definition: stateblock.c:626
struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE+1]
unsigned int num_contained_ps_consts_i
static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *states, const DWORD num_constants)
Definition: stateblock.c:262
unsigned int num_contained_vs_consts_f
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const char * debug_vec4(const struct wined3d_vec4 *v)
Definition: utils.c:3914
struct wined3d_buffer * index_buffer
wined3d_render_state
Definition: wined3d.h:263
struct wined3d_light_info * wined3d_state_get_light(const struct wined3d_state *state, unsigned int idx)
Definition: stateblock.c:566
ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
Definition: buffer.c:525
DWORD contained_vs_consts_i[WINED3D_MAX_CONSTS_I]
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum light
Definition: glfuncs.h:170
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MAX_COMBINED_SAMPLERS
unsigned int viewport_count
unsigned int num_contained_vs_consts_i
GLenum GLint GLuint mask
Definition: glext.h:6028
struct wined3d_shader * shader[WINED3D_SHADER_TYPE_COUNT]
#define MAX_SAMPLER_OBJECTS
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT CDECL wined3d_device_set_ps_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
Definition: device.c:2670
static D3DRMMATRIX4D identity
Definition: frame.c:29
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LIGHTMAP_HASHFUNC(x)
Definition: devices.h:37
#define e
Definition: ke_i.h:82
HRESULT CDECL wined3d_device_set_vs_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants)
Definition: device.c:2406
#define FIXME(fmt,...)
Definition: debug.h:110
HRESULT stateblock_init(struct d3d9_stateblock *stateblock, struct d3d9_device *device, D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock)
Definition: stateblock.c:134
unsigned int idx
Definition: utils.c:41
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
smooth NULL
Definition: ftsmooth.c:416
#define WINED3DTA_TEXTURE
Definition: wined3d.h:878
struct list light_map[LIGHTMAP_SIZE]
DWORD textureState[MAX_TEXTURES]
struct wined3d_stream_state streams[MAX_STREAMS+1]
void CDECL wined3d_device_set_transform(struct wined3d_device *device, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
Definition: device.c:1508
GLuint counter
Definition: glext.h:11116
struct wined3d_material material
void state_cleanup(struct wined3d_state *state)
Definition: stateblock.c:527
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:3421
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:289
unsigned int num_contained_render_states
static void stateblock_set_bits(DWORD *map, UINT map_size)
Definition: stateblock.c:196
HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride)
Definition: device.c:1381
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static const DWORD vertex_states_texture[]
Definition: stateblock.c:185
static void apply_lights(struct wined3d_device *device, const struct wined3d_state *state)
Definition: stateblock.c:959
#define MAX_UNORDERED_ACCESS_VIEWS
ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)
wined3d_stateblock_type
Definition: wined3d.h:774
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
GLuint shader
Definition: glext.h:6030
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
DWORD contained_ps_consts_f[WINED3D_MAX_PS_CONSTS_F]
HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
Definition: device.c:2719
#define d
Definition: ke_i.h:81
struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES]
GLenum GLuint texture
Definition: glext.h:6295
ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:551
LONG HRESULT
Definition: typedefs.h:77
ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
Definition: buffer.c:788
ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
Definition: sampler.c:53
const struct wined3d_light_info * lights[MAX_ACTIVE_LIGHTS]
DWORD contained_vs_consts_f[WINED3D_MAX_VS_CONSTS_F]
#define MAX_FRAGMENT_SAMPLERS
#define WINED3D_OK
Definition: wined3d.h:37
unsigned short WORD
Definition: ntddk_ex.h:93
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MAX_CLIP_DISTANCES
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE+1]
Definition: _map.h:44
void state_unbind_resources(struct wined3d_state *state)
Definition: stateblock.c:428
GLbitfield flags
Definition: glext.h:7161
DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5)+1]
void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb, const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info, DWORD flags)
Definition: stateblock.c:1322
BOOL ps_consts_b[WINED3D_MAX_CONSTS_B]
unsigned int scissor_rect_count
HRESULT CDECL wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const struct wined3d_vec4 *plane)
Definition: device.c:1786
HRESULT CDECL wined3d_device_set_ps_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants)
Definition: device.c:2621
HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const struct wined3d_light *light)
Definition: device.c:1583
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int num_contained_ps_consts_b
void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsigned int rect_count, const RECT *rects)
Definition: device.c:2147
#define LIGHTMAP_SIZE
HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture)
Definition: device.c:3519
static int state
Definition: maze.c:121
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: _list.h:228
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define HIGHEST_TRANSFORMSTATE
GLenum src
Definition: glext.h:6340
void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index)
Definition: device.c:1920
void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
Definition: stateblock.c:977
BOOL vs_consts_b[WINED3D_MAX_CONSTS_B]
void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned int viewport_count, const struct wined3d_viewport *viewports)
Definition: device.c:1934
GLboolean enable
Definition: glext.h:11120
ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
Definition: shader.c:3396
#define InterlockedIncrement
Definition: armddk.h:53
#define WINED3D_STATE_NO_REF
#define CDECL
Definition: compat.h:21
struct wined3d_d3d_limits limits
struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I]
#define ARRAY_SIZE(a)
Definition: main.h:24
enum wined3d_format_id index_format
#define f
Definition: ke_i.h:83
static void stateblock_init_lights(struct wined3d_stateblock *stateblock, struct list *light_map)
Definition: stateblock.c:401
struct wined3d_device * device
static const DWORD pixel_states_texture[]
Definition: stateblock.c:99
#define MAX_STREAMS
unsigned int num_contained_sampler_states
wined3d_transform_state
Definition: wined3d.h:655
unsigned int UINT
Definition: ndis.h:50
#define WINED3DVERTEXTEXTURESAMPLER0
Definition: wined3d.h:1027
#define WINED3D_MAX_CONSTS_B
void CDECL wined3d_device_set_material(struct wined3d_device *device, const struct wined3d_material *material)
Definition: device.c:1852
ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access_view *view)
Definition: view.c:966
DWORD contained_ps_consts_b[WINED3D_MAX_CONSTS_B]
#define WINED3D_STATE_INIT_DEFAULT
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
unsigned int num_contained_transform_states
unsigned int ULONG
Definition: retypes.h:1
#define WINEHIGHEST_RENDER_STATE
Definition: wined3d.h:397
GLuint GLenum GLenum transform
Definition: glext.h:9407
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1219
static void state_init_default(struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
Definition: stateblock.c:1120
struct wined3d_viewport viewports[WINED3D_MAX_VIEWPORTS]
static const DWORD vertex_states_render[]
Definition: stateblock.c:136
void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:683
struct StageState contained_tss_states[MAX_TEXTURES *(WINED3D_HIGHEST_TEXTURE_STATE+1)]
unsigned int index_offset
ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
Definition: view.c:671
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE+1]
#define LIST_ENTRY(type)
Definition: queue.h:175
void wined3d_state_enable_light(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, struct wined3d_light_info *light_info, BOOL enable)
Definition: stateblock.c:581
void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader)
Definition: device.c:2549
void CDECL wined3d_device_set_sampler_state(struct wined3d_device *device, UINT sampler_idx, enum wined3d_sampler_state state, DWORD value)
Definition: device.c:2092
ULONG CDECL wined3d_stateblock_incref(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:419
DWORD render_states[WINEHIGHEST_RENDER_STATE+1]
#define memset(x, y, z)
Definition: compat.h:39
struct wined3d_gl_limits limits
static const DWORD pixel_states_render[]
Definition: stateblock.c:31
ULONG CDECL wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration)
ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
Definition: texture.c:1190
static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, DWORD vs_consts, DWORD ps_consts)
Definition: stateblock.c:204
void * object
Definition: jmemsys.h:48
HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable)
Definition: device.c:1744
unsigned int num_contained_vs_consts_b
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum map
Definition: glfuncs.h:262
HRESULT CDECL wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider)
Definition: device.c:1454
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static const DWORD pixel_states_sampler[]
Definition: stateblock.c:120
GLuint sampler
Definition: glext.h:7283