From 2c665f79a74f1479df71ce2eff891186f62aff8b Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 19 Jan 2022 13:29:07 +0300 Subject: [PATCH] d3d10/effect: Store state variables references in their own arrays. Signed-off-by: Nikolay Sivov Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- dlls/d3d10/d3d10_private.h | 1 + dlls/d3d10/effect.c | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index 924ed94426c..4ccbb81f78d 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -127,6 +127,7 @@ struct d3d10_effect_state_object_variable ID3D10SamplerState *sampler; IUnknown *object; } object; + unsigned int index; struct d3d10_effect_prop_dependencies dependencies; }; diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 3b3196a2168..ba7c3590b64 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -3024,6 +3024,7 @@ static HRESULT create_state_object(struct d3d10_effect_variable *v) static HRESULT parse_fx10_object_variable(const char *data, size_t data_size, const char **ptr, BOOL shared_type_desc, struct d3d10_effect_variable *v) { + struct d3d10_effect_var_array *vars; struct d3d10_effect_variable *var; unsigned int i, j, element_count; HRESULT hr; @@ -3137,12 +3138,38 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size, return E_FAIL; } + switch (v->type->basetype) + { + case D3D10_SVT_DEPTHSTENCIL: + vars = &v->effect->ds_states; + break; + case D3D10_SVT_BLEND: + vars = &v->effect->blend_states; + break; + case D3D10_SVT_RASTERIZER: + vars = &v->effect->rs_states; + break; + case D3D10_SVT_SAMPLER: + vars = &v->effect->samplers; + break; + default: + ; + } + for (i = 0; i < element_count; ++i) { unsigned int prop_count; var = d3d10_array_get_element(v, i); + if (vars->current >= vars->count) + { + WARN("Wrong variable array size for %#x.\n", v->type->basetype); + return E_FAIL; + } + var->u.state.index = vars->current; + vars->v[vars->current++] = var; + read_dword(ptr, &prop_count); TRACE("State object property count: %#x.\n", prop_count); @@ -3558,6 +3585,30 @@ static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD d return E_OUTOFMEMORY; } + if (!(e->samplers.v = heap_calloc(e->samplers.count, sizeof(*e->samplers.v)))) + { + ERR("Failed to allocate samplers array.\n"); + return E_OUTOFMEMORY; + } + + if (!(e->blend_states.v = heap_calloc(e->blend_states.count, sizeof(*e->blend_states.v)))) + { + ERR("Failed to allocate blend states array.\n"); + return E_OUTOFMEMORY; + } + + if (!(e->ds_states.v = heap_calloc(e->ds_states.count, sizeof(*e->ds_states.v)))) + { + ERR("Failed to allocate depth stencil states array.\n"); + return E_OUTOFMEMORY; + } + + if (!(e->rs_states.v = heap_calloc(e->rs_states.count, sizeof(*e->rs_states.v)))) + { + ERR("Failed to allocate rasterizer states array.\n"); + return E_OUTOFMEMORY; + } + if (!(e->techniques = heap_calloc(e->technique_count, sizeof(*e->techniques)))) { ERR("Failed to allocate techniques memory\n");