Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
v2: added explicit test to show a difference between Set*Shader(NULL) and no shader being set.
dlls/d3d10/d3d10_private.h | 15 --- dlls/d3d10/effect.c | 185 +++++++++++++------------------------ dlls/d3d10/tests/effect.c | 22 +++++ 3 files changed, 86 insertions(+), 136 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index 6979d2a114e..fbcc36e5e06 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -73,19 +73,6 @@ struct d3d10_matrix float m[4][4]; };
-struct d3d10_effect_object -{ - struct d3d10_effect_pass *pass; - enum d3d10_effect_object_type type; - union - { - ID3D10VertexShader *vs; - ID3D10PixelShader *ps; - ID3D10GeometryShader *gs; - IUnknown *object; - } object; -}; - struct d3d10_effect_shader_resource { D3D10_SHADER_INPUT_TYPE in_type; @@ -236,9 +223,7 @@ struct d3d10_effect_pass
struct d3d10_effect_technique *technique; char *name; - DWORD object_count; DWORD annotation_count; - struct d3d10_effect_object *objects; struct d3d10_effect_variable *annotations;
struct d3d10_effect_pass_shader_desc vs; diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 0ba906375d7..d4e44a7f419 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1734,17 +1734,17 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, }
static HRESULT parse_fx10_object(const char *data, size_t data_size, - const char **ptr, struct d3d10_effect_object *o) + const char **ptr, struct d3d10_effect_pass *pass) { ID3D10EffectVariable *variable = &null_variable.ID3D10EffectVariable_iface; const char *data_ptr = NULL; DWORD offset, sodecl_offset; enum d3d10_effect_object_operation operation; HRESULT hr; - struct d3d10_effect *effect = o->pass->technique->effect; + struct d3d10_effect *effect = pass->technique->effect; ID3D10Effect *e = &effect->ID3D10Effect_iface; struct d3d10_effect_variable *v; - DWORD tmp, variable_idx = 0; + DWORD tmp, object_type, variable_idx = 0; const char *name; size_t name_len;
@@ -1754,8 +1754,8 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, return E_FAIL; }
- read_dword(ptr, &o->type); - TRACE("Effect object is of type %#x.\n", o->type); + read_dword(ptr, &object_type); + TRACE("Effect object is of type %#x.\n", object_type);
read_dword(ptr, &tmp); TRACE("Effect object index %#x.\n", tmp); @@ -1771,7 +1771,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, case D3D10_EOO_CONST: TRACE("Copy variable values\n");
- switch (o->type) + switch (object_type) { case D3D10_EOT_VERTEXSHADER: TRACE("Vertex shader\n"); @@ -1789,7 +1789,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, break;
case D3D10_EOT_STENCIL_REF: - if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &o->pass->stencil_ref)) + if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &pass->stencil_ref)) { ERR("Failed to read stencil ref.\n"); return E_FAIL; @@ -1797,7 +1797,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, break;
case D3D10_EOT_SAMPLE_MASK: - if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &o->pass->sample_mask)) + if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &pass->sample_mask)) { FIXME("Failed to read sample mask.\n"); return E_FAIL; @@ -1805,7 +1805,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, break;
case D3D10_EOT_BLEND_FACTOR: - if (!read_value_list(data, data_size, offset, D3D10_SVT_FLOAT, 0, 4, &o->pass->blend_factor[0])) + if (!read_value_list(data, data_size, offset, D3D10_SVT_FLOAT, 0, 4, &pass->blend_factor[0])) { FIXME("Failed to read blend factor.\n"); return E_FAIL; @@ -1813,7 +1813,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, break;
default: - FIXME("Unhandled object type %#x\n", o->type); + FIXME("Unhandled object type %#x\n", object_type); return E_FAIL; } break; @@ -1873,7 +1873,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, read_dword(&data_ptr, &sodecl_offset);
if (FAILED(hr = parse_fx10_anonymous_shader(effect, - &effect->anonymous_shaders[effect->anonymous_shader_current], o->type))) + &effect->anonymous_shaders[effect->anonymous_shader_current], object_type))) return hr;
v = &effect->anonymous_shaders[effect->anonymous_shader_current].shader; @@ -1893,7 +1893,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, TRACE("Stream output declaration: %s.\n", debugstr_a(v->u.shader.stream_output_declaration)); }
- switch (o->type) + switch (object_type) { case D3D10_EOT_VERTEXSHADER: case D3D10_EOT_PIXELSHADER: @@ -1903,7 +1903,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, break;
default: - FIXME("Unhandled object type %#x\n", o->type); + FIXME("Unhandled object type %#x\n", object_type); return E_FAIL; } break; @@ -1913,7 +1913,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, return E_FAIL; }
- switch (o->type) + switch (object_type) { case D3D10_EOT_RASTERIZER_STATE: { @@ -1927,10 +1927,10 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, if (v->type->element_count) { if (variable_idx >= v->type->element_count) return E_FAIL; - o->pass->rasterizer = &v->elements[variable_idx]; + pass->rasterizer = &v->elements[variable_idx]; } else - o->pass->rasterizer = v; + pass->rasterizer = v; break; }
@@ -1946,10 +1946,10 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, if (v->type->element_count) { if (variable_idx >= v->type->element_count) return E_FAIL; - o->pass->depth_stencil = &v->elements[variable_idx]; + pass->depth_stencil = &v->elements[variable_idx]; } else - o->pass->depth_stencil = v; + pass->depth_stencil = v; break; }
@@ -1965,40 +1965,34 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, if (v->type->element_count) { if (variable_idx >= v->type->element_count) return E_FAIL; - o->pass->blend = &v->elements[variable_idx]; + pass->blend = &v->elements[variable_idx]; } else - o->pass->blend = v; + pass->blend = v; break; }
case D3D10_EOT_VERTEXSHADER: { ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable); - if (FAILED(hr = sv->lpVtbl->GetVertexShader(sv, variable_idx, &o->object.vs))) - return hr; - o->pass->vs.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); - o->pass->vs.index = variable_idx; + pass->vs.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); + pass->vs.index = variable_idx; break; }
case D3D10_EOT_PIXELSHADER: { ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable); - if (FAILED(hr = sv->lpVtbl->GetPixelShader(sv, variable_idx, &o->object.ps))) - return hr; - o->pass->ps.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); - o->pass->ps.index = variable_idx; + pass->ps.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); + pass->ps.index = variable_idx; break; }
case D3D10_EOT_GEOMETRYSHADER: { ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable); - if (FAILED(hr = sv->lpVtbl->GetGeometryShader(sv, variable_idx, &o->object.gs))) - return hr; - o->pass->gs.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); - o->pass->gs.index = variable_idx; + pass->gs.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); + pass->gs.index = variable_idx; break; }
@@ -2008,7 +2002,7 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, break;
default: - FIXME("Unhandled object type %#x.\n", o->type); + FIXME("Unhandled object type %#x.\n", object_type); return E_FAIL; }
@@ -2018,9 +2012,9 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, static HRESULT parse_fx10_pass(const char *data, size_t data_size, const char **ptr, struct d3d10_effect_pass *p) { + DWORD offset, object_count; HRESULT hr = S_OK; unsigned int i; - DWORD offset;
read_dword(ptr, &offset); TRACE("Pass name at offset %#x.\n", offset); @@ -2032,8 +2026,8 @@ static HRESULT parse_fx10_pass(const char *data, size_t data_size, } TRACE("Pass name: %s.\n", debugstr_a(p->name));
- read_dword(ptr, &p->object_count); - TRACE("Pass has %u effect objects.\n", p->object_count); + read_dword(ptr, &object_count); + TRACE("Pass has %u effect objects.\n", object_count);
read_dword(ptr, &p->annotation_count); TRACE("Pass has %u annotations.\n", p->annotation_count); @@ -2045,23 +2039,13 @@ static HRESULT parse_fx10_pass(const char *data, size_t data_size, return hr; }
- if (!(p->objects = heap_calloc(p->object_count, sizeof(*p->objects)))) - { - ERR("Failed to allocate effect objects memory.\n"); - return E_OUTOFMEMORY; - } - p->vs.shader = &null_shader_variable; p->ps.shader = &null_shader_variable; p->gs.shader = &null_shader_variable;
- for (i = 0; i < p->object_count; ++i) + for (i = 0; i < object_count; ++i) { - struct d3d10_effect_object *o = &p->objects[i]; - - o->pass = p; - - if (FAILED(hr = parse_fx10_object(data, data_size, ptr, o))) + if (FAILED(hr = parse_fx10_object(data, data_size, ptr, p))) return hr; }
@@ -2927,42 +2911,6 @@ HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T d return parse_dxbc(data, data_size, fx10_chunk_handler, This); }
-static HRESULT d3d10_effect_object_apply(struct d3d10_effect_object *o) -{ - ID3D10Device *device = o->pass->technique->effect->device; - - TRACE("effect object %p, type %#x.\n", o, o->type); - - switch(o->type) - { - case D3D10_EOT_RASTERIZER_STATE: - case D3D10_EOT_DEPTH_STENCIL_STATE: - case D3D10_EOT_BLEND_STATE: - case D3D10_EOT_STENCIL_REF: - case D3D10_EOT_BLEND_FACTOR: - case D3D10_EOT_SAMPLE_MASK: - break; - - case D3D10_EOT_VERTEXSHADER: - ID3D10Device_VSSetShader(device, o->object.vs); - return S_OK; - - case D3D10_EOT_PIXELSHADER: - ID3D10Device_PSSetShader(device, o->object.ps); - return S_OK; - - case D3D10_EOT_GEOMETRYSHADER: - ID3D10Device_GSSetShader(device, o->object.gs); - return S_OK; - - default: - FIXME("Unhandled effect object type %#x.\n", o->type); - return E_FAIL; - } - - return S_OK; -} - static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_variable *s, D3D10_SHADER_VARIABLE_TYPE type) { @@ -3087,25 +3035,6 @@ static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v) } }
-static void d3d10_effect_object_destroy(struct d3d10_effect_object *o) -{ - switch (o->type) - { - case D3D10_EOT_RASTERIZER_STATE: - case D3D10_EOT_DEPTH_STENCIL_STATE: - case D3D10_EOT_BLEND_STATE: - case D3D10_EOT_VERTEXSHADER: - case D3D10_EOT_PIXELSHADER: - case D3D10_EOT_GEOMETRYSHADER: - if (o->object.object) - IUnknown_Release(o->object.object); - break; - - default: - break; - } -} - static void d3d10_effect_pass_destroy(struct d3d10_effect_pass *p) { unsigned int i; @@ -3114,15 +3043,6 @@ static void d3d10_effect_pass_destroy(struct d3d10_effect_pass *p)
heap_free(p->name);
- if (p->objects) - { - for (i = 0; i < p->object_count; ++i) - { - d3d10_effect_object_destroy(&p->objects[i]); - } - heap_free(p->objects); - } - if (p->annotations) { for (i = 0; i < p->annotation_count; ++i) @@ -4109,12 +4029,35 @@ static void apply_shader_resources(ID3D10Device *device, struct d3d10_effect_var } }
+static void d3d10_effect_pass_set_shader(struct d3d10_effect_pass *pass, + const struct d3d10_effect_pass_shader_desc *shader_desc) +{ + ID3D10Device *device = pass->technique->effect->device; + struct d3d10_effect_variable *v = shader_desc->shader; + + if (v->type->element_count) + v = &v->elements[shader_desc->index]; + + switch (v->type->basetype) + { + case D3D10_SVT_VERTEXSHADER: + ID3D10Device_VSSetShader(device, v->u.shader.shader.vs); + break; + case D3D10_SVT_PIXELSHADER: + ID3D10Device_PSSetShader(device, v->u.shader.shader.ps); + break; + case D3D10_SVT_GEOMETRYSHADER: + ID3D10Device_GSSetShader(device, v->u.shader.shader.gs); + break; + default: + WARN("Unexpected shader type %u.\n", v->type->basetype); + } +} + static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_Apply(ID3D10EffectPass *iface, UINT flags) { struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface); ID3D10Device *device = pass->technique->effect->device; - HRESULT hr = S_OK; - unsigned int i;
TRACE("iface %p, flags %#x\n", iface, flags);
@@ -4134,14 +4077,14 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_Apply(ID3D10EffectPass *iface if (pass->blend) ID3D10Device_OMSetBlendState(device, pass->blend->u.state.object.blend, pass->blend_factor, pass->sample_mask); + if (pass->vs.shader != &null_shader_variable) + d3d10_effect_pass_set_shader(pass, &pass->vs); + if (pass->ps.shader != &null_shader_variable) + d3d10_effect_pass_set_shader(pass, &pass->ps); + if (pass->gs.shader != &null_shader_variable) + d3d10_effect_pass_set_shader(pass, &pass->gs);
- for (i = 0; i < pass->object_count; ++i) - { - hr = d3d10_effect_object_apply(&pass->objects[i]); - if (FAILED(hr)) break; - } - - return hr; + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_ComputeStateBlockMask(ID3D10EffectPass *iface, diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 781abb46745..6ad3f7421f4 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -2909,6 +2909,7 @@ static void test_effect_local_shader(void) D3D10_EFFECT_DESC effect_desc; ID3D10EffectShaderVariable *null_shader, *null_anon_vs, *null_anon_ps, *null_anon_gs, *p3_anon_vs, *p3_anon_ps, *p3_anon_gs, *p6_vs, *p6_ps, *p6_gs, *gs, *ps, *vs; + ID3D10PixelShader *ps_d3d, *ps_d3d_2; D3D10_EFFECT_SHADER_DESC shaderdesc; D3D10_SIGNATURE_PARAMETER_DESC sign; D3D10_STATE_BLOCK_MASK mask; @@ -3005,6 +3006,12 @@ if (0) hr = p->lpVtbl->GetGeometryShaderDesc(p, NULL); ok(hr == E_INVALIDARG, "GetGeometryShaderDesc got %x, expected %x\n", hr, E_INVALIDARG);
+ v = effect->lpVtbl->GetVariableByName(effect, "p"); + ps = v->lpVtbl->AsShader(v); + + hr = ps->lpVtbl->GetPixelShader(ps, 0, &ps_d3d); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + /* get the null_shader_variable */ v = effect->lpVtbl->GetVariableByIndex(effect, 10000); null_shader = v->lpVtbl->AsShader(v); @@ -3024,6 +3031,13 @@ if (0) ret = D3D10StateBlockMaskGetSetting(&mask, D3D10_DST_GS, 0); ok(!ret, "Unexpected mask.\n");
+ ID3D10Device_PSSetShader(device, ps_d3d); + hr = p->lpVtbl->Apply(p, 0); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ID3D10Device_PSGetShader(device, &ps_d3d_2); + ok(ps_d3d_2 == ps_d3d, "Unexpected shader object.\n"); + ID3D10PixelShader_Release(ps_d3d_2); + hr = p->lpVtbl->GetVertexShaderDesc(p, &pdesc); ok(hr == S_OK, "GetVertexShaderDesc got %x, expected %x\n", hr, S_OK); ok(pdesc.pShaderVariable == null_shader, "Got %p, expected %p\n", pdesc.pShaderVariable, null_shader); @@ -3051,6 +3065,12 @@ if (0) /* pass 1 */ p = t->lpVtbl->GetPassByIndex(t, 1);
+ ID3D10Device_PSSetShader(device, ps_d3d); + hr = p->lpVtbl->Apply(p, 0); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ID3D10Device_PSGetShader(device, &ps_d3d_2); + ok(!ps_d3d_2, "Unexpected shader object.\n"); + /* pass 1 vertexshader */ hr = p->lpVtbl->GetVertexShaderDesc(p, &pdesc); ok(hr == S_OK, "GetVertexShaderDesc got %x, expected %x\n", hr, S_OK); @@ -3881,6 +3901,8 @@ todo_wine
effect->lpVtbl->Release(effect);
+ ID3D10PixelShader_Release(ps_d3d); + refcount = ID3D10Device_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/tests/effect.c | 231 +++++++++++++++++++++++++++++++++++++- 1 file changed, 230 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 6ad3f7421f4..6724fcd4992 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6097,18 +6097,149 @@ static void test_effect_resource_variable(void) ok(!refcount, "Device has %u references left.\n", refcount); }
+#if 0 +cbuffer cb <string s = "cb_a"; > +{ + float f1 : COLOR0 <string s = "f1_a"; >; +}; + +BlendState blendstate <string s = "bs_a"; >; +Texture2D tex <string s = "tex_a"; >; +PixelShader ps <string s = "ps_a"; >; +VertexShader vs <string s = "vs_a"; >; +GeometryShader gs <string s = "gs_a"; >; +DepthStencilState ds <string s = "ds_a"; >; +RasterizerState rs <string s = "rs_a"; >; +SamplerState s <string s = "s_a"; >; +RenderTargetView rtv <string s = "rtv_a"; >; +DepthStencilView dsv <string s = "dsv_a"; >; + +technique10 tech <string s = "tech_a"; > +{ + pass P0 <string s = "P0_a"; > + { + } +}; +#endif +static DWORD fx_test_annotations[] = +{ + 0x43425844, 0x2b3e08d4, 0xe3eda7bb, 0x36982de8, 0x0dcab1aa, 0x00000001, 0x000004c6, 0x00000001, + 0x00000024, 0x30315846, 0x0000049a, 0xfeff1001, 0x00000001, 0x00000001, 0x0000000a, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000276, 0x00000000, 0x00000001, 0x00000001, 0x00000001, + 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000003, 0x00000000, 0x00000000, 0x53006263, + 0x6e697274, 0x00070067, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, + 0x00730000, 0x615f6263, 0x6f6c6600, 0x31007461, 0x01000000, 0x00000000, 0x04000000, 0x10000000, + 0x04000000, 0x09000000, 0x66000009, 0x4f430031, 0x30524f4c, 0x5f316600, 0x6c420061, 0x53646e65, + 0x65746174, 0x00006200, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000200, + 0x656c6200, 0x7473646e, 0x00657461, 0x615f7362, 0x78655400, 0x65727574, 0x99004432, 0x02000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0c000000, 0x74000000, 0x74007865, 0x615f7865, + 0x78695000, 0x68536c65, 0x72656461, 0x0000c900, 0x00000200, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000500, 0x00737000, 0x615f7370, 0x72655600, 0x53786574, 0x65646168, 0x00f90072, + 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00060000, 0x73760000, 0x5f737600, + 0x65470061, 0x74656d6f, 0x68537972, 0x72656461, 0x00012a00, 0x00000200, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000700, 0x00736700, 0x615f7367, 0x70654400, 0x74536874, 0x69636e65, + 0x6174536c, 0x5d006574, 0x02000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03000000, + 0x64000000, 0x73640073, 0x5200615f, 0x65747361, 0x657a6972, 0x61745372, 0x93006574, 0x02000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04000000, 0x72000000, 0x73720073, 0x5300615f, + 0x6c706d61, 0x74537265, 0x00657461, 0x000001c7, 0x00000002, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000015, 0x00615f73, 0x646e6552, 0x61547265, 0x74656772, 0x77656956, 0x0001f400, + 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001300, 0x76747200, 0x76747200, + 0x4400615f, 0x68747065, 0x6e657453, 0x566c6963, 0x00776569, 0x0000022b, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000014, 0x00767364, 0x5f767364, 0x65740061, 0x74006863, + 0x5f686365, 0x30500061, 0x5f305000, 0x00040061, 0x00100000, 0x00000000, 0x00010000, 0xffff0000, + 0x0001ffff, 0x002a0000, 0x000e0000, 0x002c0000, 0x00530000, 0x00370000, 0x00560000, 0x00000000, + 0x00000000, 0x00000000, 0x00010000, 0x002a0000, 0x000e0000, 0x005d0000, 0x00890000, 0x006d0000, + 0x00000000, 0xffff0000, 0x0000ffff, 0x00010000, 0x002a0000, 0x000e0000, 0x00940000, 0x00bf0000, + 0x00a30000, 0x00000000, 0xffff0000, 0x0001ffff, 0x002a0000, 0x000e0000, 0x00c30000, 0x00f10000, + 0x00d50000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00010000, 0x002a0000, 0x000e0000, 0x00f40000, + 0x01220000, 0x01060000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00010000, 0x002a0000, 0x000e0000, + 0x01250000, 0x01550000, 0x01390000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00010000, 0x002a0000, + 0x000e0000, 0x01580000, 0x018b0000, 0x016f0000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00010000, + 0x002a0000, 0x000e0000, 0x018e0000, 0x01bf0000, 0x01a30000, 0x00000000, 0xffff0000, 0x0000ffff, + 0x00010000, 0x002a0000, 0x000e0000, 0x01c20000, 0x002a0000, 0x01d40000, 0x00000000, 0xffff0000, + 0x0000ffff, 0x00010000, 0x002a0000, 0x000e0000, 0x01f00000, 0x02210000, 0x02050000, 0x00000000, + 0xffff0000, 0x0001ffff, 0x002a0000, 0x000e0000, 0x02250000, 0x02580000, 0x023c0000, 0x00000000, + 0xffff0000, 0x0001ffff, 0x002a0000, 0x000e0000, 0x025c0000, 0x02620000, 0x00010000, 0x00010000, + 0x002a0000, 0x000e0000, 0x02670000, 0x026e0000, 0x00000000, 0x00010000, 0x002a0000, 0x000e0000, + 0x02710000, 0x00000000, +}; + +static void test_effect_annotations(void) +{ + D3D10_EFFECT_VARIABLE_DESC var_desc; + ID3D10EffectConstantBuffer *cb; + D3D10_EFFECT_DESC effect_desc; + ID3D10EffectTechnique *tech; + ID3D10EffectVariable *v, *a; + ID3D10EffectPass *pass; + ID3D10Effect *effect; + ID3D10Device *device; + ULONG i, refcount; + HRESULT hr; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + hr = create_effect(fx_test_annotations, 0, device, NULL, &effect); + ok(SUCCEEDED(hr), "Failed to create an effect.\n"); + + cb = effect->lpVtbl->GetConstantBufferByName(effect, "cb"); + a = cb->lpVtbl->GetAnnotationByName(cb, "s"); + ok(a->lpVtbl->IsValid(a), "Expected valid variable.\n"); + a = cb->lpVtbl->GetAnnotationByName(cb, "S"); + ok(!a->lpVtbl->IsValid(a), "Unexpected valid variable.\n"); + + effect->lpVtbl->GetDesc(effect, &effect_desc); + for (i = 0; i < effect_desc.GlobalVariables; ++i) + { + v = effect->lpVtbl->GetVariableByIndex(effect, i); + hr = v->lpVtbl->GetDesc(v, &var_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(var_desc.Annotations == 1, "Unexpected annotations count %u.\n", var_desc.Annotations); + v = v->lpVtbl->GetAnnotationByName(v, "s"); + ok(v->lpVtbl->IsValid(v), "Expected valid variable.\n"); + a = cb->lpVtbl->GetAnnotationByName(cb, "S"); + ok(!a->lpVtbl->IsValid(a), "Unexpected valid variable.\n"); + } + + tech = effect->lpVtbl->GetTechniqueByIndex(effect, 0); + ok(tech->lpVtbl->IsValid(tech), "Expected valid technique.\n"); + a = tech->lpVtbl->GetAnnotationByName(tech, "s"); + ok(a->lpVtbl->IsValid(a), "Expected valid variable.\n"); + a = tech->lpVtbl->GetAnnotationByName(tech, "S"); + ok(!a->lpVtbl->IsValid(a), "Unexpected valid variable.\n"); + + pass = tech->lpVtbl->GetPassByIndex(tech, 0); + ok(pass->lpVtbl->IsValid(pass), "Expected valid technique.\n"); + a = pass->lpVtbl->GetAnnotationByName(pass, "s"); + ok(a->lpVtbl->IsValid(a), "Expected valid variable.\n"); + a = pass->lpVtbl->GetAnnotationByName(pass, "S"); + ok(!a->lpVtbl->IsValid(a), "Unexpected valid variable.\n"); + + effect->lpVtbl->Release(effect); + + refcount = ID3D10Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + static void test_effect_optimize(void) { D3D10_EFFECT_SHADER_DESC shaderdesc; + D3D10_EFFECT_VARIABLE_DESC var_desc; + ID3D10EffectConstantBuffer *cb; ID3D10EffectShaderVariable *gs; D3D10_TECHNIQUE_DESC tech_desc; + D3D10_EFFECT_DESC effect_desc; ID3D10EffectTechnique *tech; D3D10_PASS_DESC pass_desc; ID3D10EffectVariable *v; ID3D10EffectPass *pass; ID3D10Effect *effect; ID3D10Device *device; - ULONG refcount; + ULONG i, refcount; HRESULT hr; BOOL ret;
@@ -6187,6 +6318,103 @@ static void test_effect_optimize(void)
effect->lpVtbl->Release(effect);
+ /* Annotations are stripped. */ + hr = create_effect(fx_test_annotations, 0, device, NULL, &effect); + ok(SUCCEEDED(hr), "Failed to create an effect.\n"); + + cb = effect->lpVtbl->GetConstantBufferByName(effect, "cb"); + hr = cb->lpVtbl->GetDesc(cb, &var_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(var_desc.Annotations == 1, "Unexpected annotations count %u.\n", var_desc.Annotations); + v = cb->lpVtbl->GetAnnotationByName(cb, "s"); + ok(v->lpVtbl->IsValid(v), "Expected valid variable.\n"); + + effect->lpVtbl->GetDesc(effect, &effect_desc); + + for (i = 0; i < effect_desc.GlobalVariables; ++i) + { + v = effect->lpVtbl->GetVariableByIndex(effect, i); + hr = v->lpVtbl->GetDesc(v, &var_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(var_desc.Annotations == 1, "Unexpected annotations count %u.\n", var_desc.Annotations); + v = v->lpVtbl->GetAnnotationByName(v, "s"); + ok(v->lpVtbl->IsValid(v), "Expected valid variable.\n"); + } + + tech = effect->lpVtbl->GetTechniqueByIndex(effect, 0); + hr = tech->lpVtbl->GetDesc(tech, &tech_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(tech_desc.Annotations == 1, "Unexpected annotations count %u.\n", tech_desc.Annotations); + v = tech->lpVtbl->GetAnnotationByName(tech, "s"); + ok(v->lpVtbl->IsValid(v), "Expected valid variable.\n"); + + pass = tech->lpVtbl->GetPassByIndex(tech, 0); + ok(pass->lpVtbl->IsValid(pass), "Expected valid technique.\n"); + hr = pass->lpVtbl->GetDesc(pass, &pass_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(pass_desc.Annotations == 1, "Unexpected annotations count %u.\n", pass_desc.Annotations); + v = pass->lpVtbl->GetAnnotationByName(pass, "s"); + ok(v->lpVtbl->IsValid(v), "Expected valid variable.\n"); + + effect->lpVtbl->GetDesc(effect, &effect_desc); + + for (i = 0; i < effect_desc.GlobalVariables; ++i) + { + v = effect->lpVtbl->GetVariableByIndex(effect, i); + hr = v->lpVtbl->GetDesc(v, &var_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(var_desc.Annotations == 1, "Unexpected annotations count %u.\n", var_desc.Annotations); + v = v->lpVtbl->GetAnnotationByName(v, "s"); + ok(v->lpVtbl->IsValid(v), "Expected valid variable.\n"); + } + + hr = effect->lpVtbl->Optimize(effect); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + cb = effect->lpVtbl->GetConstantBufferByIndex(effect, 0); + hr = cb->lpVtbl->GetDesc(cb, &var_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); +todo_wine { + ok(!var_desc.Annotations, "Unexpected annotations count %u.\n", var_desc.Annotations); + v = cb->lpVtbl->GetAnnotationByName(cb, "s"); + ok(!v->lpVtbl->IsValid(v), "Expected valid variable.\n"); +} + + effect->lpVtbl->GetDesc(effect, &effect_desc); + + for (i = 0; i < effect_desc.GlobalVariables; ++i) + { + v = effect->lpVtbl->GetVariableByIndex(effect, i); + hr = v->lpVtbl->GetDesc(v, &var_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + todo_wine { + ok(!var_desc.Annotations, "Unexpected annotations count %u.\n", var_desc.Annotations); + v = v->lpVtbl->GetAnnotationByName(v, "s"); + ok(!v->lpVtbl->IsValid(v), "Expected valid variable.\n"); + } + } + + tech = effect->lpVtbl->GetTechniqueByIndex(effect, 0); + hr = tech->lpVtbl->GetDesc(tech, &tech_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); +todo_wine { + ok(!tech_desc.Annotations, "Unexpected annotations count %u.\n", tech_desc.Annotations); + v = tech->lpVtbl->GetAnnotationByName(tech, "s"); + ok(!v->lpVtbl->IsValid(v), "Expected valid variable.\n"); +} + + pass = tech->lpVtbl->GetPassByIndex(tech, 0); + ok(pass->lpVtbl->IsValid(pass), "Expected valid technique.\n"); + hr = pass->lpVtbl->GetDesc(pass, &pass_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); +todo_wine { + ok(!pass_desc.Annotations, "Unexpected annotations count %u.\n", pass_desc.Annotations); + v = pass->lpVtbl->GetAnnotationByName(pass, "s"); + ok(!v->lpVtbl->IsValid(v), "Expected valid variable.\n"); +} + + effect->lpVtbl->Release(effect); + refcount = ID3D10Device_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); } @@ -7019,6 +7247,7 @@ START_TEST(effect) test_effect_vector_variable(); test_effect_matrix_variable(); test_effect_resource_variable(); + test_effect_annotations(); test_effect_optimize(); test_effect_shader_description(); test_effect_shader_object();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/d3d10_private.h | 15 ++- dlls/d3d10/effect.c | 220 ++++++++++++++----------------------- 2 files changed, 92 insertions(+), 143 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index fbcc36e5e06..e5659507eeb 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -181,6 +181,12 @@ struct d3d10_effect_type_member struct d3d10_effect_type *type; };
+struct d3d10_effect_annotations +{ + struct d3d10_effect_variable *elements; + unsigned int count; +}; + /* ID3D10EffectVariable */ struct d3d10_effect_variable { @@ -192,14 +198,13 @@ struct d3d10_effect_variable char *name; char *semantic; DWORD buffer_offset; - DWORD annotation_count; DWORD flag; DWORD data_size; DWORD explicit_bind_point; struct d3d10_effect *effect; struct d3d10_effect_variable *elements; struct d3d10_effect_variable *members; - struct d3d10_effect_variable *annotations; + struct d3d10_effect_annotations annotations;
union { @@ -223,8 +228,7 @@ struct d3d10_effect_pass
struct d3d10_effect_technique *technique; char *name; - DWORD annotation_count; - struct d3d10_effect_variable *annotations; + struct d3d10_effect_annotations annotations;
struct d3d10_effect_pass_shader_desc vs; struct d3d10_effect_pass_shader_desc ps; @@ -244,10 +248,9 @@ struct d3d10_effect_technique
struct d3d10_effect *effect; char *name; + struct d3d10_effect_annotations annotations; DWORD pass_count; - DWORD annotation_count; struct d3d10_effect_pass *passes; - struct d3d10_effect_variable *annotations; };
struct d3d10_effect_anonymous_shader diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index d4e44a7f419..6cc51aa00e3 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1439,21 +1439,20 @@ static HRESULT parse_fx10_annotation(const char *data, size_t data_size, }
static HRESULT parse_fx10_annotations(const char *data, size_t data_size, const char **ptr, - struct d3d10_effect *effect, unsigned int annotation_count, - struct d3d10_effect_variable **annotations) + struct d3d10_effect *effect, struct d3d10_effect_annotations *annotations) { unsigned int i; HRESULT hr;
- if (!(*annotations = heap_calloc(annotation_count, sizeof(**annotations)))) + if (!(annotations->elements = heap_calloc(annotations->count, sizeof(*annotations->elements)))) { ERR("Failed to allocate annotations memory.\n"); return E_OUTOFMEMORY; }
- for (i = 0; i < annotation_count; ++i) + for (i = 0; i < annotations->count; ++i) { - struct d3d10_effect_variable *a = &(*annotations)[i]; + struct d3d10_effect_variable *a = &annotations->elements[i];
a->effect = effect; a->buffer = &null_local_buffer; @@ -2029,11 +2028,11 @@ static HRESULT parse_fx10_pass(const char *data, size_t data_size, read_dword(ptr, &object_count); TRACE("Pass has %u effect objects.\n", object_count);
- read_dword(ptr, &p->annotation_count); - TRACE("Pass has %u annotations.\n", p->annotation_count); + read_dword(ptr, &p->annotations.count); + TRACE("Pass has %u annotations.\n", p->annotations.count);
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, p->technique->effect, - p->annotation_count, &p->annotations))) + &p->annotations))) { ERR("Failed to parse pass annotations, hr %#x.\n", hr); return hr; @@ -2072,11 +2071,11 @@ static HRESULT parse_fx10_technique(const char *data, size_t data_size, read_dword(ptr, &t->pass_count); TRACE("Technique has %u passes\n", t->pass_count);
- read_dword(ptr, &t->annotation_count); - TRACE("Technique has %u annotations.\n", t->annotation_count); + read_dword(ptr, &t->annotations.count); + TRACE("Technique has %u annotations.\n", t->annotations.count);
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, t->effect, - t->annotation_count, &t->annotations))) + &t->annotations))) { ERR("Failed to parse technique annotations, hr %#x.\n", hr); return hr; @@ -2136,11 +2135,11 @@ static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size, if (default_value_offset) FIXME("Set default variable value.\n");
- read_dword(ptr, &v->annotation_count); - TRACE("Variable has %u annotations.\n", v->annotation_count); + read_dword(ptr, &v->annotations.count); + TRACE("Variable has %u annotations.\n", v->annotations.count);
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, v->effect, - v->annotation_count, &v->annotations))) + &v->annotations))) { ERR("Failed to parse variable annotations, hr %#x.\n", hr); return hr; @@ -2347,11 +2346,11 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size, return E_FAIL; }
- read_dword(ptr, &v->annotation_count); - TRACE("Variable has %u annotations.\n", v->annotation_count); + read_dword(ptr, &v->annotations.count); + TRACE("Variable has %u annotations.\n", v->annotations.count);
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, v->effect, - v->annotation_count, &v->annotations))) + &v->annotations))) { ERR("Failed to parse variable annotations, hr %#x.\n", hr); return hr; @@ -2481,11 +2480,11 @@ static HRESULT parse_fx10_buffer(const char *data, size_t data_size, const char
if (local) { - read_dword(ptr, &l->annotation_count); - TRACE("Local buffer has %u annotations.\n", l->annotation_count); + read_dword(ptr, &l->annotations.count); + TRACE("Local buffer has %u annotations.\n", l->annotations.count);
if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, l->effect, - l->annotation_count, &l->annotations))) + &l->annotations))) { ERR("Failed to parse buffer annotations, hr %#x.\n", hr); return hr; @@ -2947,6 +2946,19 @@ static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_vari heap_free(s->resources); }
+static void d3d10_effect_annotations_destroy(struct d3d10_effect_annotations *a) +{ + unsigned int i; + + if (!a->elements) return; + + for (i = 0; i < a->count; ++i) + d3d10_effect_variable_destroy(&a->elements[i]); + heap_free(a->elements); + a->elements = NULL; + a->count = 0; +} + static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v) { unsigned int i, elem_count; @@ -2955,14 +2967,7 @@ static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v)
heap_free(v->name); heap_free(v->semantic); - if (v->annotations) - { - for (i = 0; i < v->annotation_count; ++i) - { - d3d10_effect_variable_destroy(&v->annotations[i]); - } - heap_free(v->annotations); - } + d3d10_effect_annotations_destroy(&v->annotations);
if (v->members) { @@ -3037,20 +3042,10 @@ static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v)
static void d3d10_effect_pass_destroy(struct d3d10_effect_pass *p) { - unsigned int i; - TRACE("pass %p\n", p);
heap_free(p->name); - - if (p->annotations) - { - for (i = 0; i < p->annotation_count; ++i) - { - d3d10_effect_variable_destroy(&p->annotations[i]); - } - heap_free(p->annotations); - } + d3d10_effect_annotations_destroy(&p->annotations); }
static void d3d10_effect_technique_destroy(struct d3d10_effect_technique *t) @@ -3069,14 +3064,7 @@ static void d3d10_effect_technique_destroy(struct d3d10_effect_technique *t) heap_free(t->passes); }
- if (t->annotations) - { - for (i = 0; i < t->annotation_count; ++i) - { - d3d10_effect_variable_destroy(&t->annotations[i]); - } - heap_free(t->annotations); - } + d3d10_effect_annotations_destroy(&t->annotations); }
static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable *l) @@ -3098,15 +3086,7 @@ static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable *l) if (l->type) d3d10_effect_type_destroy(&l->type->entry, NULL);
- if (l->annotations) - { - for (i = 0; i < l->annotation_count; ++i) - { - d3d10_effect_variable_destroy(&l->annotations[i]); - } - heap_free(l->annotations); - } - + d3d10_effect_annotations_destroy(&l->annotations); heap_free(l->u.buffer.local_buffer);
if (l->u.buffer.buffer) @@ -3596,73 +3576,87 @@ static BOOL STDMETHODCALLTYPE d3d10_effect_technique_IsValid(ID3D10EffectTechniq static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_GetDesc(ID3D10EffectTechnique *iface, D3D10_TECHNIQUE_DESC *desc) { - struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface); + struct d3d10_effect_technique *tech = impl_from_ID3D10EffectTechnique(iface);
TRACE("iface %p, desc %p\n", iface, desc);
- if(This == &null_technique) + if (tech == &null_technique) { WARN("Null technique specified\n"); return E_FAIL; }
- if(!desc) + if (!desc) { WARN("Invalid argument specified\n"); return E_INVALIDARG; }
- desc->Name = This->name; - desc->Passes = This->pass_count; - desc->Annotations = This->annotation_count; + desc->Name = tech->name; + desc->Passes = tech->pass_count; + desc->Annotations = tech->annotations.count;
return S_OK; }
-static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByIndex( - ID3D10EffectTechnique *iface, UINT index) +static ID3D10EffectVariable * d3d10_annotation_get_by_index(const struct d3d10_effect_annotations *annotations, + unsigned int index) { - struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface); struct d3d10_effect_variable *a;
- TRACE("iface %p, index %u\n", iface, index); - - if (index >= This->annotation_count) + if (index >= annotations->count) { WARN("Invalid index specified\n"); return &null_variable.ID3D10EffectVariable_iface; }
- a = &This->annotations[index]; + a = &annotations->elements[index];
- TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name)); + TRACE("Returning annotation %p, name %s.\n", a, debugstr_a(a->name));
return &a->ID3D10EffectVariable_iface; }
-static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByName( - ID3D10EffectTechnique *iface, const char *name) +static ID3D10EffectVariable * d3d10_annotation_get_by_name(const struct d3d10_effect_annotations *annotations, + const char *name) { - struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface); unsigned int i;
- TRACE("iface %p, name %s.\n", iface, debugstr_a(name)); - - for (i = 0; i < This->annotation_count; ++i) + for (i = 0; i < annotations->count; ++i) { - struct d3d10_effect_variable *a = &This->annotations[i]; + struct d3d10_effect_variable *a = &annotations->elements[i]; if (a->name && !strcmp(a->name, name)) { - TRACE("Returning annotation %p\n", a); + TRACE("Returning annotation %p.\n", a); return &a->ID3D10EffectVariable_iface; } }
- WARN("Invalid name specified\n"); + WARN("Invalid name specified.\n");
return &null_variable.ID3D10EffectVariable_iface; }
+static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByIndex( + ID3D10EffectTechnique *iface, UINT index) +{ + struct d3d10_effect_technique *tech = impl_from_ID3D10EffectTechnique(iface); + + TRACE("iface %p, index %u\n", iface, index); + + return d3d10_annotation_get_by_index(&tech->annotations, index); +} + +static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByName( + ID3D10EffectTechnique *iface, const char *name) +{ + struct d3d10_effect_technique *tech = impl_from_ID3D10EffectTechnique(iface); + + TRACE("iface %p, name %s.\n", iface, debugstr_a(name)); + + return d3d10_annotation_get_by_name(&tech->annotations, name); +} + static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByIndex(ID3D10EffectTechnique *iface, UINT index) { @@ -3768,7 +3762,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetDesc(ID3D10EffectPass *ifa s = &pass->vs.shader->u.shader;
desc->Name = pass->name; - desc->Annotations = pass->annotation_count; + desc->Annotations = pass->annotations.count; if (s->input_signature) { desc->pIAInputSignature = ID3D10Blob_GetBufferPointer(s->input_signature); @@ -3864,45 +3858,21 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetPixelShaderDesc(ID3D10Effe static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByIndex(ID3D10EffectPass *iface, UINT index) { - struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface); - struct d3d10_effect_variable *a; + struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
TRACE("iface %p, index %u\n", iface, index);
- if (index >= This->annotation_count) - { - WARN("Invalid index specified\n"); - return &null_variable.ID3D10EffectVariable_iface; - } - - a = &This->annotations[index]; - - TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name)); - - return &a->ID3D10EffectVariable_iface; + return d3d10_annotation_get_by_index(&pass->annotations, index); }
static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByName(ID3D10EffectPass *iface, const char *name) { - struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface); - unsigned int i; + struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
- for (i = 0; i < This->annotation_count; ++i) - { - struct d3d10_effect_variable *a = &This->annotations[i]; - if (a->name && !strcmp(a->name, name)) - { - TRACE("Returning annotation %p\n", a); - return &a->ID3D10EffectVariable_iface; - } - } - - WARN("Invalid name specified\n"); - - return &null_variable.ID3D10EffectVariable_iface; + return d3d10_annotation_get_by_name(&pass->annotations, name); }
static void update_buffer(ID3D10Device *device, struct d3d10_effect_variable *v) @@ -4166,7 +4136,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetDesc(ID3D10EffectVaria desc->Name = v->name; desc->Semantic = v->semantic; desc->Flags = v->flag; - desc->Annotations = v->annotation_count; + desc->Annotations = v->annotations.count; desc->BufferOffset = v->buffer_offset;
if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT) @@ -4178,45 +4148,21 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetDesc(ID3D10EffectVaria static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByIndex( ID3D10EffectVariable *iface, UINT index) { - struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface); - struct d3d10_effect_variable *a; + struct d3d10_effect_variable *var = impl_from_ID3D10EffectVariable(iface);
TRACE("iface %p, index %u\n", iface, index);
- if (index >= This->annotation_count) - { - WARN("Invalid index specified\n"); - return &null_variable.ID3D10EffectVariable_iface; - } - - a = &This->annotations[index]; - - TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name)); - - return &a->ID3D10EffectVariable_iface; + return d3d10_annotation_get_by_index(&var->annotations, index); }
static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByName( ID3D10EffectVariable *iface, const char *name) { - struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface); - unsigned int i; + struct d3d10_effect_variable *var = impl_from_ID3D10EffectVariable(iface);
TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
- for (i = 0; i < This->annotation_count; ++i) - { - struct d3d10_effect_variable *a = &This->annotations[i]; - if (a->name && !strcmp(a->name, name)) - { - TRACE("Returning annotation %p\n", a); - return &a->ID3D10EffectVariable_iface; - } - } - - WARN("Invalid name specified\n"); - - return &null_variable.ID3D10EffectVariable_iface; + return d3d10_annotation_get_by_name(&var->annotations, name); }
static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByIndex(
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Very nice.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 95 +++++++++++++++++++++++++++- dlls/d3d10/tests/effect.c | 128 +++++++++++++++++++++++++++----------- 2 files changed, 182 insertions(+), 41 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 6cc51aa00e3..1e144bb1c56 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1669,13 +1669,59 @@ static BOOL read_value_list(const char *data, size_t data_size, DWORD offset, return TRUE; }
+static BOOL is_object_property(const struct d3d10_effect_state_property_info *property_info) +{ + switch (property_info->type) + { + case D3D10_SVT_RASTERIZER: + case D3D10_SVT_DEPTHSTENCIL: + case D3D10_SVT_BLEND: + case D3D10_SVT_RENDERTARGETVIEW: + case D3D10_SVT_DEPTHSTENCILVIEW: + case D3D10_SVT_VERTEXSHADER: + case D3D10_SVT_PIXELSHADER: + case D3D10_SVT_GEOMETRYSHADER: + case D3D10_SVT_TEXTURE: + return TRUE; + default: + return FALSE; + } +} + +static BOOL is_object_property_type_matching(const struct d3d10_effect_state_property_info *property_info, + const struct d3d10_effect_variable *v) +{ + if (property_info->type == v->type->basetype) return TRUE; + + switch (v->type->basetype) + { + case D3D10_SVT_TEXTURE1D: + case D3D10_SVT_TEXTURE1DARRAY: + case D3D10_SVT_TEXTURE2D: + case D3D10_SVT_TEXTURE2DARRAY: + case D3D10_SVT_TEXTURE2DMS: + case D3D10_SVT_TEXTURE2DMSARRAY: + case D3D10_SVT_TEXTURE3D: + case D3D10_SVT_TEXTURECUBE: + if (property_info->type == D3D10_SVT_TEXTURE) return TRUE; + /* fallthrough */ + default: + return FALSE; + } +} + static BOOL parse_fx10_state_group(const char *data, size_t data_size, - const char **ptr, enum d3d10_effect_container_type container_type, void *container) + const char **ptr, enum d3d10_effect_container_type container_type, + struct d3d10_effect *effect, void *container) { const struct d3d10_effect_state_property_info *property_info; + struct d3d10_effect_variable *variable; UINT value_offset, operation; + const char *name; + size_t name_len; unsigned int i; DWORD count; + void *dst; UINT idx; UINT id;
@@ -1710,19 +1756,62 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, return FALSE; }
+ dst = (char *)container + property_info->offset; + switch (operation) { case D3D10_EOO_CONST:
/* Constant values output directly to backing store. */ if (!read_value_list(data, data_size, value_offset, property_info->type, idx, - property_info->size, (char *)container + property_info->offset)) + property_info->size, dst)) { ERR("Failed to read values for property %#x.\n", id); return FALSE; } break;
+ case D3D10_EOO_VAR: + + /* Variable. */ + if (!fx10_get_string(data, data_size, value_offset, &name, &name_len)) + { + WARN("Failed to get variable name.\n"); + return E_FAIL; + } + TRACE("Variable name %s.\n", debugstr_a(name)); + + if (!(variable = d3d10_effect_get_variable_by_name(effect, name))) + { + WARN("Couldn't find variable %s.\n", debugstr_a(name)); + return FALSE; + } + + if (is_object_property(property_info)) + { + if (variable->type->element_count) + { + WARN("Unexpected array variable value %s.\n", debugstr_a(name)); + return FALSE; + } + + if (!is_object_property_type_matching(property_info, variable)) + { + WARN("Object type mismatch. Variable type %#x, property type %#x.\n", + variable->type->basetype, property_info->type); + return FALSE; + } + + *(void **)dst = variable; + } + else + { + FIXME("Assigning variables to numeric fields is not supported.\n"); + return FALSE; + } + + break; + default: FIXME("Unhandled operation %#x.\n", operation); return E_FAIL; @@ -2329,7 +2418,7 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size,
memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size); if (!parse_fx10_state_group(data, data_size, ptr, get_var_container_type(var), - &var->u.state.desc)) + var->effect, &var->u.state.desc)) { ERR("Failed to read property list.\n"); return E_FAIL; diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 6724fcd4992..b8d3f8ca95c 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -4126,6 +4126,26 @@ SamplerState sampler0 Texture = NULL; /* 0x37 */ };
+Texture t0; +Texture1D t1; +Texture1DArray t1a; +Texture2D t2; +Texture2DArray t2a; +Texture2DMS<float4, 4> t2dms; +Texture2DMSArray <float4, 4> t2dmsa; +Texture3D t3; +TextureCube tq; + +SamplerState sampler1 { Texture = t0; }; +SamplerState sampler2 { Texture = t1; }; +SamplerState sampler2a { Texture = t1a; }; +SamplerState sampler3 { Texture = t2; }; +SamplerState sampler3a { Texture = t2a; }; +SamplerState sampler4 { Texture = t2dms; }; +SamplerState sampler4a { Texture = t2dmsa; }; +SamplerState sampler5 { Texture = t3; }; +SamplerState sampler6 { Texture = tq; }; + technique10 tech0 { pass pass0 @@ -4138,10 +4158,10 @@ technique10 tech0 #endif static DWORD fx_test_state_groups[] = { - 0x43425844, 0xf231bc81, 0x3edcd6f4, 0x932fe6e0, 0x86fbdec1, 0x00000001, 0x0000078f, 0x00000001, - 0x00000024, 0x30315846, 0x00000763, 0xfeff1001, 0x00000000, 0x00000000, 0x00000004, 0x00000000, - 0x00000000, 0x00000000, 0x00000001, 0x0000035f, 0x00000000, 0x00000000, 0x00000001, 0x00000001, - 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x74736152, + 0x43425844, 0x6465b74f, 0x34238546, 0x33c65cd8, 0xec32db01, 0x00000001, 0x00000b8c, 0x00000001, + 0x00000024, 0x30315846, 0x00000b60, 0xfeff1001, 0x00000000, 0x00000000, 0x00000016, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000540, 0x00000000, 0x00000009, 0x00000001, 0x00000001, + 0x00000001, 0x0000000a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x74736152, 0x7a697265, 0x74537265, 0x00657461, 0x00000004, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x74736172, 0x6174735f, 0x01006574, 0x02000000, 0x02000000, 0x01000000, 0x02000000, 0x02000000, 0x01000000, 0x04000000, 0x01000000, 0x01000000, 0x02000000, 0xfc000000, @@ -4166,39 +4186,71 @@ static DWORD fx_test_state_groups[] = 0x01000000, 0x02000000, 0xff000000, 0x01ffffff, 0x03000000, 0x04000000, 0x01000000, 0x02000000, 0x08000000, 0x04000000, 0x01000000, 0x00000000, 0x013f8000, 0x00000000, 0x01400000, 0x00000000, 0x01404000, 0x00000000, 0x01408000, 0x03000000, 0x06000000, 0x01000000, 0x03000000, 0x05000000, - 0x01000000, 0x02000000, 0x00000000, 0x74000000, 0x30686365, 0x73617000, 0x04003073, 0x01000000, - 0x00000000, 0x013f0000, 0x9a000000, 0x013f1999, 0x33000000, 0x013f3333, 0xcd000000, 0x013f4ccc, - 0x03000000, 0xff000000, 0x010000ff, 0x01000000, 0x00000000, 0x303f8000, 0x14000000, 0x00000000, - 0xff000000, 0x0affffff, 0x0c000000, 0x00000000, 0x01000000, 0x3b000000, 0x0d000000, 0x00000000, - 0x01000000, 0x47000000, 0x0e000000, 0x00000000, 0x01000000, 0x53000000, 0x0f000000, 0x00000000, - 0x01000000, 0x5f000000, 0x10000000, 0x00000000, 0x01000000, 0x6b000000, 0x11000000, 0x00000000, - 0x01000000, 0x77000000, 0x12000000, 0x00000000, 0x01000000, 0x83000000, 0x13000000, 0x00000000, - 0x01000000, 0x8f000000, 0x14000000, 0x00000000, 0x01000000, 0x9b000000, 0x15000000, 0x00000000, - 0x01000000, 0xa7000000, 0x00000000, 0xe1000000, 0xc5000000, 0x00000000, 0xff000000, 0x0effffff, - 0x16000000, 0x00000000, 0x01000000, 0xea000000, 0x17000000, 0x00000000, 0x01000000, 0xf6000000, - 0x18000000, 0x00000000, 0x01000000, 0x02000000, 0x19000001, 0x00000000, 0x01000000, 0x0e000000, - 0x1a000001, 0x00000000, 0x01000000, 0x1a000000, 0x1b000001, 0x00000000, 0x01000000, 0x26000000, - 0x1c000001, 0x00000000, 0x01000000, 0x32000000, 0x1d000001, 0x00000000, 0x01000000, 0x3e000000, - 0x1e000001, 0x00000000, 0x01000000, 0x4a000000, 0x1f000001, 0x00000000, 0x01000000, 0x56000000, - 0x20000001, 0x00000000, 0x01000000, 0x62000000, 0x21000001, 0x00000000, 0x01000000, 0x6e000000, - 0x22000001, 0x00000000, 0x01000000, 0x7a000000, 0x23000001, 0x00000000, 0x01000000, 0x86000000, - 0x00000001, 0xb9000000, 0x9d000001, 0x00000001, 0xff000000, 0x0bffffff, 0x24000000, 0x00000000, - 0x01000000, 0xc5000000, 0x25000001, 0x00000000, 0x01000000, 0xd1000000, 0x25000001, 0x07000000, - 0x01000000, 0xdd000000, 0x26000001, 0x00000000, 0x01000000, 0xe9000000, 0x27000001, 0x00000000, - 0x01000000, 0xf5000000, 0x28000001, 0x00000000, 0x01000000, 0x01000000, 0x29000002, 0x00000000, - 0x01000000, 0x0d000000, 0x2a000002, 0x00000000, 0x01000000, 0x19000000, 0x2b000002, 0x00000000, - 0x01000000, 0x25000000, 0x2c000002, 0x00000000, 0x01000000, 0x31000000, 0x2c000002, 0x07000000, - 0x01000000, 0x3d000000, 0x00000002, 0x72000000, 0x56000002, 0x00000002, 0xff000000, 0x0bffffff, - 0x2d000000, 0x00000000, 0x01000000, 0x7b000000, 0x2e000002, 0x00000000, 0x01000000, 0x87000000, - 0x2f000002, 0x00000000, 0x01000000, 0x93000000, 0x30000002, 0x00000000, 0x01000000, 0x9f000000, - 0x31000002, 0x00000000, 0x01000000, 0xab000000, 0x32000002, 0x00000000, 0x01000000, 0xb7000000, - 0x33000002, 0x00000000, 0x01000000, 0xc3000000, 0x34000002, 0x00000000, 0x01000000, 0xcf000000, - 0x35000002, 0x00000000, 0x01000000, 0xf3000000, 0x36000002, 0x00000000, 0x01000000, 0xff000000, - 0x37000002, 0x00000000, 0x01000000, 0x0b000000, 0x00000003, 0x17000000, 0x01000003, 0x00000000, - 0x1d000000, 0x06000003, 0x00000000, 0x0a000000, 0x00000000, 0x01000000, 0x23000000, 0x0b000003, - 0x00000000, 0x01000000, 0x47000000, 0x02000003, 0x00000000, 0x02000000, 0xb9000000, 0x09000001, - 0x00000000, 0x01000000, 0x53000000, 0x01000003, 0x00000000, 0x02000000, 0xe1000000, 0x00000000, - 0x00000000, 0x02000000, 0x30000000, 0x00000000, + 0x01000000, 0x02000000, 0x00000000, 0x74000000, 0x75747865, 0x17006572, 0x02000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x09000000, 0x74000000, 0x65540030, 0x72757478, 0x00443165, + 0x0000033e, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000a, 0x54003174, + 0x75747865, 0x44316572, 0x61727241, 0x03670079, 0x00020000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x000b0000, 0x31740000, 0x65540061, 0x72757478, 0x00443265, 0x00000396, 0x00000002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x54003274, 0x75747865, 0x44326572, + 0x61727241, 0x03bf0079, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000d0000, + 0x32740000, 0x65540061, 0x72757478, 0x4d443265, 0x03ee0053, 0x00020000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x000e0000, 0x32740000, 0x00736d64, 0x74786554, 0x32657275, 0x41534d44, + 0x79617272, 0x00041c00, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000f00, + 0x64327400, 0x0061736d, 0x74786554, 0x33657275, 0x04500044, 0x00020000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00100000, 0x33740000, 0x78655400, 0x65727574, 0x65627543, 0x00047900, + 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001100, 0x00717400, 0x706d6173, + 0x3172656c, 0x6d617300, 0x72656c70, 0x61730032, 0x656c706d, 0x00613272, 0x706d6173, 0x3372656c, + 0x6d617300, 0x72656c70, 0x73006133, 0x6c706d61, 0x00347265, 0x706d6173, 0x3472656c, 0x61730061, + 0x656c706d, 0x73003572, 0x6c706d61, 0x00367265, 0x68636574, 0x61700030, 0x00307373, 0x00000004, + 0x00000001, 0x3f000000, 0x00000001, 0x3f19999a, 0x00000001, 0x3f333333, 0x00000001, 0x3f4ccccd, + 0x00000001, 0x00000003, 0x0000ffff, 0x00000001, 0x00000001, 0x3f800000, 0x00000030, 0x00000014, + 0x00000000, 0xffffffff, 0x0000000a, 0x0000000c, 0x00000000, 0x00000001, 0x0000003b, 0x0000000d, + 0x00000000, 0x00000001, 0x00000047, 0x0000000e, 0x00000000, 0x00000001, 0x00000053, 0x0000000f, + 0x00000000, 0x00000001, 0x0000005f, 0x00000010, 0x00000000, 0x00000001, 0x0000006b, 0x00000011, + 0x00000000, 0x00000001, 0x00000077, 0x00000012, 0x00000000, 0x00000001, 0x00000083, 0x00000013, + 0x00000000, 0x00000001, 0x0000008f, 0x00000014, 0x00000000, 0x00000001, 0x0000009b, 0x00000015, + 0x00000000, 0x00000001, 0x000000a7, 0x00000000, 0x000000e1, 0x000000c5, 0x00000000, 0xffffffff, + 0x0000000e, 0x00000016, 0x00000000, 0x00000001, 0x000000ea, 0x00000017, 0x00000000, 0x00000001, + 0x000000f6, 0x00000018, 0x00000000, 0x00000001, 0x00000102, 0x00000019, 0x00000000, 0x00000001, + 0x0000010e, 0x0000001a, 0x00000000, 0x00000001, 0x0000011a, 0x0000001b, 0x00000000, 0x00000001, + 0x00000126, 0x0000001c, 0x00000000, 0x00000001, 0x00000132, 0x0000001d, 0x00000000, 0x00000001, + 0x0000013e, 0x0000001e, 0x00000000, 0x00000001, 0x0000014a, 0x0000001f, 0x00000000, 0x00000001, + 0x00000156, 0x00000020, 0x00000000, 0x00000001, 0x00000162, 0x00000021, 0x00000000, 0x00000001, + 0x0000016e, 0x00000022, 0x00000000, 0x00000001, 0x0000017a, 0x00000023, 0x00000000, 0x00000001, + 0x00000186, 0x00000000, 0x000001b9, 0x0000019d, 0x00000000, 0xffffffff, 0x0000000b, 0x00000024, + 0x00000000, 0x00000001, 0x000001c5, 0x00000025, 0x00000000, 0x00000001, 0x000001d1, 0x00000025, + 0x00000007, 0x00000001, 0x000001dd, 0x00000026, 0x00000000, 0x00000001, 0x000001e9, 0x00000027, + 0x00000000, 0x00000001, 0x000001f5, 0x00000028, 0x00000000, 0x00000001, 0x00000201, 0x00000029, + 0x00000000, 0x00000001, 0x0000020d, 0x0000002a, 0x00000000, 0x00000001, 0x00000219, 0x0000002b, + 0x00000000, 0x00000001, 0x00000225, 0x0000002c, 0x00000000, 0x00000001, 0x00000231, 0x0000002c, + 0x00000007, 0x00000001, 0x0000023d, 0x00000000, 0x00000272, 0x00000256, 0x00000000, 0xffffffff, + 0x0000000b, 0x0000002d, 0x00000000, 0x00000001, 0x0000027b, 0x0000002e, 0x00000000, 0x00000001, + 0x00000287, 0x0000002f, 0x00000000, 0x00000001, 0x00000293, 0x00000030, 0x00000000, 0x00000001, + 0x0000029f, 0x00000031, 0x00000000, 0x00000001, 0x000002ab, 0x00000032, 0x00000000, 0x00000001, + 0x000002b7, 0x00000033, 0x00000000, 0x00000001, 0x000002c3, 0x00000034, 0x00000000, 0x00000001, + 0x000002cf, 0x00000035, 0x00000000, 0x00000001, 0x000002f3, 0x00000036, 0x00000000, 0x00000001, + 0x000002ff, 0x00000037, 0x00000000, 0x00000001, 0x0000030b, 0x00000000, 0x0000033b, 0x0000031f, + 0x00000000, 0xffffffff, 0x00000000, 0x00000364, 0x00000348, 0x00000000, 0xffffffff, 0x00000000, + 0x00000392, 0x00000376, 0x00000000, 0xffffffff, 0x00000000, 0x000003bc, 0x000003a0, 0x00000000, + 0xffffffff, 0x00000000, 0x000003ea, 0x000003ce, 0x00000000, 0xffffffff, 0x00000000, 0x00000416, + 0x000003fa, 0x00000000, 0xffffffff, 0x00000000, 0x00000449, 0x0000042d, 0x00000000, 0xffffffff, + 0x00000000, 0x00000476, 0x0000045a, 0x00000000, 0xffffffff, 0x00000000, 0x000004a1, 0x00000485, + 0x00000000, 0xffffffff, 0x00000000, 0x000004a4, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, + 0x00000037, 0x00000000, 0x00000002, 0x0000033b, 0x00000000, 0x000004ad, 0x00000256, 0x00000000, + 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000364, 0x00000000, 0x000004b6, + 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000392, + 0x00000000, 0x000004c0, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, + 0x00000002, 0x000003bc, 0x00000000, 0x000004c9, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, + 0x00000037, 0x00000000, 0x00000002, 0x000003ea, 0x00000000, 0x000004d3, 0x00000256, 0x00000000, + 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000416, 0x00000000, 0x000004dc, + 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000449, + 0x00000000, 0x000004e6, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, + 0x00000002, 0x00000476, 0x00000000, 0x000004ef, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, + 0x00000037, 0x00000000, 0x00000002, 0x000004a1, 0x00000000, 0x000004f8, 0x00000001, 0x00000000, + 0x000004fe, 0x00000006, 0x00000000, 0x0000000a, 0x00000000, 0x00000001, 0x00000504, 0x0000000b, + 0x00000000, 0x00000001, 0x00000528, 0x00000002, 0x00000000, 0x00000002, 0x000001b9, 0x00000009, + 0x00000000, 0x00000001, 0x00000534, 0x00000001, 0x00000000, 0x00000002, 0x000000e1, 0x00000000, + 0x00000000, 0x00000002, 0x00000030, };
static void test_effect_state_groups(void) @@ -4244,7 +4296,7 @@ static void test_effect_state_groups(void) effect_desc.ConstantBuffers); ok(effect_desc.SharedConstantBuffers == 0, "Unexpected shared constant buffers count %u.\n", effect_desc.SharedConstantBuffers); - ok(effect_desc.GlobalVariables == 4, "Unexpected global variables count %u.\n", + ok(effect_desc.GlobalVariables == 22, "Unexpected global variables count %u.\n", effect_desc.GlobalVariables); ok(effect_desc.SharedGlobalVariables == 0, "Unexpected shared global variables count %u.\n", effect_desc.SharedGlobalVariables);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
On Fri, Oct 8, 2021 at 7:13 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/effect.c | 95 +++++++++++++++++++++++++++- dlls/d3d10/tests/effect.c | 128 +++++++++++++++++++++++++++----------- 2 files changed, 182 insertions(+), 41 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 6cc51aa00e3..1e144bb1c56 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1669,13 +1669,59 @@ static BOOL read_value_list(const char *data, size_t data_size, DWORD offset, return TRUE; }
+static BOOL is_object_property(const struct d3d10_effect_state_property_info *property_info) +{
- switch (property_info->type)
- {
case D3D10_SVT_RASTERIZER:
case D3D10_SVT_DEPTHSTENCIL:
case D3D10_SVT_BLEND:
case D3D10_SVT_RENDERTARGETVIEW:
case D3D10_SVT_DEPTHSTENCILVIEW:
case D3D10_SVT_VERTEXSHADER:
case D3D10_SVT_PIXELSHADER:
case D3D10_SVT_GEOMETRYSHADER:
case D3D10_SVT_TEXTURE:
return TRUE;
default:
return FALSE;
- }
+}
I don't know if, or how much, this list of object types is going to grow but it might be easier to list the numeric types instead.
@@ -2329,7 +2418,7 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size,
memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size); if (!parse_fx10_state_group(data, data_size, ptr, get_var_container_type(var),
&var->u.state.desc))
var->effect, &var->u.state.desc))
Probably at some point we should introduce an explicit variable field in struct d3d10_effect_state_object_variable instead of abusing the other fields of the desc union.
On 10/13/21 2:48 PM, Matteo Bruni wrote:
On Fri, Oct 8, 2021 at 7:13 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/effect.c | 95 +++++++++++++++++++++++++++- dlls/d3d10/tests/effect.c | 128 +++++++++++++++++++++++++++----------- 2 files changed, 182 insertions(+), 41 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 6cc51aa00e3..1e144bb1c56 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1669,13 +1669,59 @@ static BOOL read_value_list(const char *data, size_t data_size, DWORD offset, return TRUE; }
+static BOOL is_object_property(const struct d3d10_effect_state_property_info *property_info) +{
- switch (property_info->type)
- {
case D3D10_SVT_RASTERIZER:
case D3D10_SVT_DEPTHSTENCIL:
case D3D10_SVT_BLEND:
case D3D10_SVT_RENDERTARGETVIEW:
case D3D10_SVT_DEPTHSTENCILVIEW:
case D3D10_SVT_VERTEXSHADER:
case D3D10_SVT_PIXELSHADER:
case D3D10_SVT_GEOMETRYSHADER:
case D3D10_SVT_TEXTURE:
return TRUE;
default:
return FALSE;
- }
+}
I don't know if, or how much, this list of object types is going to grow but it might be easier to list the numeric types instead.
It won't grow. But yes, there are ways to improve either size or readability. It could list scalar types instead, or property ids. Or properties could be marked in static table instead with some flag.
@@ -2329,7 +2418,7 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size,
memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size); if (!parse_fx10_state_group(data, data_size, ptr, get_var_container_type(var),
&var->u.state.desc))
var->effect, &var->u.state.desc))
Probably at some point we should introduce an explicit variable field in struct d3d10_effect_state_object_variable instead of abusing the other fields of the desc union.
I don't understand what you're suggesting. To have a separate storage to write to, instead of a union?
On Thu, Oct 14, 2021 at 7:42 AM Nikolay Sivov nsivov@codeweavers.com wrote:
On 10/13/21 2:48 PM, Matteo Bruni wrote:
On Fri, Oct 8, 2021 at 7:13 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/effect.c | 95 +++++++++++++++++++++++++++- dlls/d3d10/tests/effect.c | 128 +++++++++++++++++++++++++++----------- 2 files changed, 182 insertions(+), 41 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 6cc51aa00e3..1e144bb1c56 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1669,13 +1669,59 @@ static BOOL read_value_list(const char *data, size_t data_size, DWORD offset, return TRUE; }
+static BOOL is_object_property(const struct d3d10_effect_state_property_info *property_info) +{
- switch (property_info->type)
- {
case D3D10_SVT_RASTERIZER:
case D3D10_SVT_DEPTHSTENCIL:
case D3D10_SVT_BLEND:
case D3D10_SVT_RENDERTARGETVIEW:
case D3D10_SVT_DEPTHSTENCILVIEW:
case D3D10_SVT_VERTEXSHADER:
case D3D10_SVT_PIXELSHADER:
case D3D10_SVT_GEOMETRYSHADER:
case D3D10_SVT_TEXTURE:
return TRUE;
default:
return FALSE;
- }
+}
I don't know if, or how much, this list of object types is going to grow but it might be easier to list the numeric types instead.
It won't grow. But yes, there are ways to improve either size or readability. It could list scalar types instead, or property ids. Or properties could be marked in static table instead with some flag.
@@ -2329,7 +2418,7 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size,
memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size); if (!parse_fx10_state_group(data, data_size, ptr, get_var_container_type(var),
&var->u.state.desc))
var->effect, &var->u.state.desc))
Probably at some point we should introduce an explicit variable field in struct d3d10_effect_state_object_variable instead of abusing the other fields of the desc union.
I don't understand what you're suggesting. To have a separate storage to write to, instead of a union?
Not necessarily; what I was thinking is adding a new "struct d3d10_effect_variable *variable;" entry to the desc member of struct d3d10_effect_state_object_variable (or perhaps to a new union with desc as the other member). Assuming I understand how this is supposed to be used eventually.
I see now that probably I should have put the comment right below the "*(void **)dst = variable;" line instead.
On 10/14/21 11:44 AM, Matteo Bruni wrote:
On Thu, Oct 14, 2021 at 7:42 AM Nikolay Sivov nsivov@codeweavers.com wrote:
On 10/13/21 2:48 PM, Matteo Bruni wrote:
On Fri, Oct 8, 2021 at 7:13 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/effect.c | 95 +++++++++++++++++++++++++++- dlls/d3d10/tests/effect.c | 128 +++++++++++++++++++++++++++----------- 2 files changed, 182 insertions(+), 41 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 6cc51aa00e3..1e144bb1c56 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1669,13 +1669,59 @@ static BOOL read_value_list(const char *data, size_t data_size, DWORD offset, return TRUE; }
+static BOOL is_object_property(const struct d3d10_effect_state_property_info *property_info) +{
- switch (property_info->type)
- {
case D3D10_SVT_RASTERIZER:
case D3D10_SVT_DEPTHSTENCIL:
case D3D10_SVT_BLEND:
case D3D10_SVT_RENDERTARGETVIEW:
case D3D10_SVT_DEPTHSTENCILVIEW:
case D3D10_SVT_VERTEXSHADER:
case D3D10_SVT_PIXELSHADER:
case D3D10_SVT_GEOMETRYSHADER:
case D3D10_SVT_TEXTURE:
return TRUE;
default:
return FALSE;
- }
+}
I don't know if, or how much, this list of object types is going to grow but it might be easier to list the numeric types instead.
It won't grow. But yes, there are ways to improve either size or readability. It could list scalar types instead, or property ids. Or properties could be marked in static table instead with some flag.
@@ -2329,7 +2418,7 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size,
memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size); if (!parse_fx10_state_group(data, data_size, ptr, get_var_container_type(var),
&var->u.state.desc))
var->effect, &var->u.state.desc))
Probably at some point we should introduce an explicit variable field in struct d3d10_effect_state_object_variable instead of abusing the other fields of the desc union.
I don't understand what you're suggesting. To have a separate storage to write to, instead of a union?
Not necessarily; what I was thinking is adding a new "struct d3d10_effect_variable *variable;" entry to the desc member of struct d3d10_effect_state_object_variable (or perhaps to a new union with desc as the other member). Assuming I understand how this is supposed to be used eventually.
I see now that probably I should have put the comment right below the "*(void **)dst = variable;" line instead.
Right now for state objects, *dst = variable is only used for .Texture field. Setting variable to a numeric field will fail, if you're talking about this case, another single "variable" field won't make a difference, because you can have multiple fields updated through variables, or same array field elements updated through a number of variables.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 142 +++++++++++++++++++++++++++++---- dlls/d3d10/tests/effect.c | 161 +++++++++++++++++++++++++------------- 2 files changed, 233 insertions(+), 70 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 1e144bb1c56..6f3ece24e79 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1710,17 +1710,19 @@ static BOOL is_object_property_type_matching(const struct d3d10_effect_state_pro } }
-static BOOL parse_fx10_state_group(const char *data, size_t data_size, +static HRESULT parse_fx10_property_assignment(const char *data, size_t data_size, const char **ptr, enum d3d10_effect_container_type container_type, struct d3d10_effect *effect, void *container) { const struct d3d10_effect_state_property_info *property_info; + UINT value_offset, sodecl_offset, operation; struct d3d10_effect_variable *variable; - UINT value_offset, operation; + unsigned int i, variable_idx; + const char *data_ptr; const char *name; size_t name_len; - unsigned int i; DWORD count; + HRESULT hr; void *dst; UINT idx; UINT id; @@ -1738,7 +1740,7 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, if (!(property_info = get_property_info(id))) { FIXME("Failed to find property info for property %#x.\n", id); - return FALSE; + return E_FAIL; }
TRACE("Property %s[%#x] = value list @ offset %#x.\n", @@ -1747,13 +1749,13 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, if (property_info->container_type != container_type) { ERR("Invalid container type %#x for property %#x.\n", container_type, id); - return FALSE; + return E_FAIL; }
if (idx >= property_info->count) { ERR("Invalid index %#x for property %#x.\n", idx, id); - return FALSE; + return E_FAIL; }
dst = (char *)container + property_info->offset; @@ -1767,7 +1769,7 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, property_info->size, dst)) { ERR("Failed to read values for property %#x.\n", id); - return FALSE; + return E_FAIL; } break;
@@ -1784,7 +1786,7 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, if (!(variable = d3d10_effect_get_variable_by_name(effect, name))) { WARN("Couldn't find variable %s.\n", debugstr_a(name)); - return FALSE; + return E_FAIL; }
if (is_object_property(property_info)) @@ -1792,14 +1794,14 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, if (variable->type->element_count) { WARN("Unexpected array variable value %s.\n", debugstr_a(name)); - return FALSE; + return E_FAIL; }
if (!is_object_property_type_matching(property_info, variable)) { WARN("Object type mismatch. Variable type %#x, property type %#x.\n", variable->type->basetype, property_info->type); - return FALSE; + return E_FAIL; }
*(void **)dst = variable; @@ -1807,18 +1809,128 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, else { FIXME("Assigning variables to numeric fields is not supported.\n"); - return FALSE; + return E_FAIL; }
break;
+ case D3D10_EOO_CONST_INDEX: + + /* Array variable, constant index. */ + if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size)) + { + WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size); + return E_FAIL; + } + data_ptr = data + value_offset; + read_dword(&data_ptr, &value_offset); + read_dword(&data_ptr, &variable_idx); + + if (!fx10_get_string(data, data_size, value_offset, &name, &name_len)) + { + WARN("Failed to get variable name.\n"); + return E_FAIL; + } + + TRACE("Variable name %s[%u].\n", debugstr_a(name), variable_idx); + + if (!(variable = d3d10_effect_get_variable_by_name(effect, name))) + { + WARN("Couldn't find variable %s.\n", debugstr_a(name)); + return E_FAIL; + } + + /* Has to be an array */ + if (!variable->type->element_count || variable_idx >= variable->type->element_count) + { + WARN("Invalid array size %u.\n", variable->type->element_count); + return E_FAIL; + } + + if (is_object_property(property_info)) + { + if (!is_object_property_type_matching(property_info, variable)) + { + WARN("Object type mismatch. Variable type %#x, property type %#x.\n", + variable->type->basetype, property_info->type); + return E_FAIL; + } + + *(void **)dst = &variable->elements[variable_idx]; + } + else + { + FIXME("Assigning indexed variables to numeric fields is not supported.\n"); + return E_FAIL; + } + + break; + + case D3D10_EOO_ANONYMOUS_SHADER: + + /* Anonymous shader */ + if (effect->anonymous_shader_current >= effect->anonymous_shader_count) + { + ERR("Anonymous shader count is wrong!\n"); + return E_FAIL; + } + + if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size)) + { + WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size); + return E_FAIL; + } + data_ptr = data + value_offset; + read_dword(&data_ptr, &value_offset); + read_dword(&data_ptr, &sodecl_offset); + + TRACE("Effect object starts at offset %#x.\n", value_offset); + + if (FAILED(hr = parse_fx10_anonymous_shader(effect, + &effect->anonymous_shaders[effect->anonymous_shader_current], property_info->id))) + return hr; + + variable = &effect->anonymous_shaders[effect->anonymous_shader_current].shader; + ++effect->anonymous_shader_current; + + if (sodecl_offset) + { + TRACE("Anonymous shader stream output declaration at offset %#x.\n", sodecl_offset); + if (!fx10_copy_string(data, data_size, sodecl_offset, + &variable->u.shader.stream_output_declaration)) + { + ERR("Failed to copy stream output declaration.\n"); + return E_FAIL; + } + + TRACE("Stream output declaration: %s.\n", debugstr_a(variable->u.shader.stream_output_declaration)); + } + + switch (property_info->id) + { + case D3D10_EOT_VERTEXSHADER: + case D3D10_EOT_PIXELSHADER: + case D3D10_EOT_GEOMETRYSHADER: + if (FAILED(hr = parse_fx10_shader(data, data_size, value_offset, variable))) + return hr; + break; + + default: + FIXME("Unhandled object type %#x\n", property_info->id); + return E_FAIL; + } + + *(void **)dst = variable; + + break; + default: FIXME("Unhandled operation %#x.\n", operation); return E_FAIL; } }
- return TRUE; + return S_OK; }
static HRESULT parse_fx10_object(const char *data, size_t data_size, @@ -2417,11 +2529,11 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size, var = v;
memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size); - if (!parse_fx10_state_group(data, data_size, ptr, get_var_container_type(var), - var->effect, &var->u.state.desc)) + if (FAILED(hr = parse_fx10_property_assignment(data, data_size, ptr, + get_var_container_type(var), var->effect, &var->u.state.desc))) { ERR("Failed to read property list.\n"); - return E_FAIL; + return hr; }
if (FAILED(hr = create_state_object(var))) diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index b8d3f8ca95c..893d0375015 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -4146,6 +4146,26 @@ SamplerState sampler4a { Texture = t2dmsa; }; SamplerState sampler5 { Texture = t3; }; SamplerState sampler6 { Texture = tq; };
+Texture t0_a[3]; +Texture1D t1_a[3]; +Texture1DArray t1a_a[3]; +Texture2D t2_a[3]; +Texture2DArray t2a_a[3]; +Texture2DMS<float4, 4> t2dms_a[3]; +Texture2DMSArray <float4, 4> t2dmsa_a[3]; +Texture3D t3_a[3]; +TextureCube tq_a[3]; + +SamplerState sampler7 { Texture = t0_a[0]; }; +SamplerState sampler8 { Texture = t1_a[1]; }; +SamplerState sampler9 { Texture = t1a_a[2]; }; +SamplerState sampler10 { Texture = t2_a[0]; }; +SamplerState sampler11 { Texture = t2a_a[1]; }; +SamplerState sampler12 { Texture = t2dms_a[2]; }; +SamplerState sampler13 { Texture = t2dmsa_a[0]; }; +SamplerState sampler14 { Texture = t3_a[1]; }; +SamplerState sampler15 { Texture = tq_a[2]; }; + technique10 tech0 { pass pass0 @@ -4158,10 +4178,10 @@ technique10 tech0 #endif static DWORD fx_test_state_groups[] = { - 0x43425844, 0x6465b74f, 0x34238546, 0x33c65cd8, 0xec32db01, 0x00000001, 0x00000b8c, 0x00000001, - 0x00000024, 0x30315846, 0x00000b60, 0xfeff1001, 0x00000000, 0x00000000, 0x00000016, 0x00000000, - 0x00000000, 0x00000000, 0x00000001, 0x00000540, 0x00000000, 0x00000009, 0x00000001, 0x00000001, - 0x00000001, 0x0000000a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x74736152, + 0x43425844, 0xad712d25, 0xfbcf4136, 0x61248434, 0xe6cabf4a, 0x00000001, 0x00000f79, 0x00000001, + 0x00000024, 0x30315846, 0x00000f4d, 0xfeff1001, 0x00000000, 0x00000000, 0x00000028, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000711, 0x00000000, 0x00000024, 0x00000001, 0x00000001, + 0x00000001, 0x00000013, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x74736152, 0x7a697265, 0x74537265, 0x00657461, 0x00000004, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x74736172, 0x6174735f, 0x01006574, 0x02000000, 0x02000000, 0x01000000, 0x02000000, 0x02000000, 0x01000000, 0x04000000, 0x01000000, 0x01000000, 0x02000000, 0xfc000000, @@ -4201,56 +4221,87 @@ static DWORD fx_test_state_groups[] = 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001100, 0x00717400, 0x706d6173, 0x3172656c, 0x6d617300, 0x72656c70, 0x61730032, 0x656c706d, 0x00613272, 0x706d6173, 0x3372656c, 0x6d617300, 0x72656c70, 0x73006133, 0x6c706d61, 0x00347265, 0x706d6173, 0x3472656c, 0x61730061, - 0x656c706d, 0x73003572, 0x6c706d61, 0x00367265, 0x68636574, 0x61700030, 0x00307373, 0x00000004, - 0x00000001, 0x3f000000, 0x00000001, 0x3f19999a, 0x00000001, 0x3f333333, 0x00000001, 0x3f4ccccd, - 0x00000001, 0x00000003, 0x0000ffff, 0x00000001, 0x00000001, 0x3f800000, 0x00000030, 0x00000014, - 0x00000000, 0xffffffff, 0x0000000a, 0x0000000c, 0x00000000, 0x00000001, 0x0000003b, 0x0000000d, - 0x00000000, 0x00000001, 0x00000047, 0x0000000e, 0x00000000, 0x00000001, 0x00000053, 0x0000000f, - 0x00000000, 0x00000001, 0x0000005f, 0x00000010, 0x00000000, 0x00000001, 0x0000006b, 0x00000011, - 0x00000000, 0x00000001, 0x00000077, 0x00000012, 0x00000000, 0x00000001, 0x00000083, 0x00000013, - 0x00000000, 0x00000001, 0x0000008f, 0x00000014, 0x00000000, 0x00000001, 0x0000009b, 0x00000015, - 0x00000000, 0x00000001, 0x000000a7, 0x00000000, 0x000000e1, 0x000000c5, 0x00000000, 0xffffffff, - 0x0000000e, 0x00000016, 0x00000000, 0x00000001, 0x000000ea, 0x00000017, 0x00000000, 0x00000001, - 0x000000f6, 0x00000018, 0x00000000, 0x00000001, 0x00000102, 0x00000019, 0x00000000, 0x00000001, - 0x0000010e, 0x0000001a, 0x00000000, 0x00000001, 0x0000011a, 0x0000001b, 0x00000000, 0x00000001, - 0x00000126, 0x0000001c, 0x00000000, 0x00000001, 0x00000132, 0x0000001d, 0x00000000, 0x00000001, - 0x0000013e, 0x0000001e, 0x00000000, 0x00000001, 0x0000014a, 0x0000001f, 0x00000000, 0x00000001, - 0x00000156, 0x00000020, 0x00000000, 0x00000001, 0x00000162, 0x00000021, 0x00000000, 0x00000001, - 0x0000016e, 0x00000022, 0x00000000, 0x00000001, 0x0000017a, 0x00000023, 0x00000000, 0x00000001, - 0x00000186, 0x00000000, 0x000001b9, 0x0000019d, 0x00000000, 0xffffffff, 0x0000000b, 0x00000024, - 0x00000000, 0x00000001, 0x000001c5, 0x00000025, 0x00000000, 0x00000001, 0x000001d1, 0x00000025, - 0x00000007, 0x00000001, 0x000001dd, 0x00000026, 0x00000000, 0x00000001, 0x000001e9, 0x00000027, - 0x00000000, 0x00000001, 0x000001f5, 0x00000028, 0x00000000, 0x00000001, 0x00000201, 0x00000029, - 0x00000000, 0x00000001, 0x0000020d, 0x0000002a, 0x00000000, 0x00000001, 0x00000219, 0x0000002b, - 0x00000000, 0x00000001, 0x00000225, 0x0000002c, 0x00000000, 0x00000001, 0x00000231, 0x0000002c, - 0x00000007, 0x00000001, 0x0000023d, 0x00000000, 0x00000272, 0x00000256, 0x00000000, 0xffffffff, - 0x0000000b, 0x0000002d, 0x00000000, 0x00000001, 0x0000027b, 0x0000002e, 0x00000000, 0x00000001, - 0x00000287, 0x0000002f, 0x00000000, 0x00000001, 0x00000293, 0x00000030, 0x00000000, 0x00000001, - 0x0000029f, 0x00000031, 0x00000000, 0x00000001, 0x000002ab, 0x00000032, 0x00000000, 0x00000001, - 0x000002b7, 0x00000033, 0x00000000, 0x00000001, 0x000002c3, 0x00000034, 0x00000000, 0x00000001, - 0x000002cf, 0x00000035, 0x00000000, 0x00000001, 0x000002f3, 0x00000036, 0x00000000, 0x00000001, - 0x000002ff, 0x00000037, 0x00000000, 0x00000001, 0x0000030b, 0x00000000, 0x0000033b, 0x0000031f, - 0x00000000, 0xffffffff, 0x00000000, 0x00000364, 0x00000348, 0x00000000, 0xffffffff, 0x00000000, - 0x00000392, 0x00000376, 0x00000000, 0xffffffff, 0x00000000, 0x000003bc, 0x000003a0, 0x00000000, - 0xffffffff, 0x00000000, 0x000003ea, 0x000003ce, 0x00000000, 0xffffffff, 0x00000000, 0x00000416, - 0x000003fa, 0x00000000, 0xffffffff, 0x00000000, 0x00000449, 0x0000042d, 0x00000000, 0xffffffff, - 0x00000000, 0x00000476, 0x0000045a, 0x00000000, 0xffffffff, 0x00000000, 0x000004a1, 0x00000485, - 0x00000000, 0xffffffff, 0x00000000, 0x000004a4, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, - 0x00000037, 0x00000000, 0x00000002, 0x0000033b, 0x00000000, 0x000004ad, 0x00000256, 0x00000000, - 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000364, 0x00000000, 0x000004b6, - 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000392, - 0x00000000, 0x000004c0, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, - 0x00000002, 0x000003bc, 0x00000000, 0x000004c9, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, - 0x00000037, 0x00000000, 0x00000002, 0x000003ea, 0x00000000, 0x000004d3, 0x00000256, 0x00000000, - 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000416, 0x00000000, 0x000004dc, - 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, 0x00000002, 0x00000449, - 0x00000000, 0x000004e6, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, 0x00000037, 0x00000000, - 0x00000002, 0x00000476, 0x00000000, 0x000004ef, 0x00000256, 0x00000000, 0xffffffff, 0x00000001, - 0x00000037, 0x00000000, 0x00000002, 0x000004a1, 0x00000000, 0x000004f8, 0x00000001, 0x00000000, - 0x000004fe, 0x00000006, 0x00000000, 0x0000000a, 0x00000000, 0x00000001, 0x00000504, 0x0000000b, - 0x00000000, 0x00000001, 0x00000528, 0x00000002, 0x00000000, 0x00000002, 0x000001b9, 0x00000009, - 0x00000000, 0x00000001, 0x00000534, 0x00000001, 0x00000000, 0x00000002, 0x000000e1, 0x00000000, - 0x00000000, 0x00000002, 0x00000030, + 0x656c706d, 0x73003572, 0x6c706d61, 0x00367265, 0x00000317, 0x00000002, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000009, 0x615f3074, 0x00033e00, 0x00000200, 0x00000300, 0x00000000, + 0x00000000, 0x00000000, 0x00000a00, 0x5f317400, 0x03670061, 0x00020000, 0x00030000, 0x00000000, + 0x00000000, 0x00000000, 0x000b0000, 0x31740000, 0x00615f61, 0x00000396, 0x00000002, 0x00000003, + 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x615f3274, 0x0003bf00, 0x00000200, 0x00000300, + 0x00000000, 0x00000000, 0x00000000, 0x00000d00, 0x61327400, 0xee00615f, 0x02000003, 0x03000000, + 0x00000000, 0x00000000, 0x00000000, 0x0e000000, 0x74000000, 0x736d6432, 0x1c00615f, 0x02000004, + 0x03000000, 0x00000000, 0x00000000, 0x00000000, 0x0f000000, 0x74000000, 0x736d6432, 0x00615f61, + 0x00000450, 0x00000002, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x615f3374, + 0x00047900, 0x00000200, 0x00000300, 0x00000000, 0x00000000, 0x00000000, 0x00001100, 0x5f717400, + 0x61730061, 0x656c706d, 0x14003772, 0x00000005, 0x73000000, 0x6c706d61, 0x00387265, 0x00000535, + 0x00000001, 0x706d6173, 0x3972656c, 0x00055600, 0x00000200, 0x6d617300, 0x72656c70, 0x78003031, + 0x00000005, 0x73000000, 0x6c706d61, 0x31317265, 0x00059900, 0x00000100, 0x6d617300, 0x72656c70, + 0xbb003231, 0x02000005, 0x73000000, 0x6c706d61, 0x33317265, 0x0005df00, 0x00000000, 0x6d617300, + 0x72656c70, 0x04003431, 0x01000006, 0x73000000, 0x6c706d61, 0x35317265, 0x00062500, 0x00000200, + 0x63657400, 0x70003068, 0x30737361, 0x00000400, 0x00000100, 0x00000000, 0x0000013f, 0x19999a00, + 0x0000013f, 0x33333300, 0x0000013f, 0x4ccccd00, 0x0000013f, 0x00000300, 0x00ffff00, 0x00000100, + 0x00000100, 0x80000000, 0x0000303f, 0x00001400, 0x00000000, 0xffffff00, 0x00000aff, 0x00000c00, + 0x00000000, 0x00000100, 0x00003b00, 0x00000d00, 0x00000000, 0x00000100, 0x00004700, 0x00000e00, + 0x00000000, 0x00000100, 0x00005300, 0x00000f00, 0x00000000, 0x00000100, 0x00005f00, 0x00001000, + 0x00000000, 0x00000100, 0x00006b00, 0x00001100, 0x00000000, 0x00000100, 0x00007700, 0x00001200, + 0x00000000, 0x00000100, 0x00008300, 0x00001300, 0x00000000, 0x00000100, 0x00008f00, 0x00001400, + 0x00000000, 0x00000100, 0x00009b00, 0x00001500, 0x00000000, 0x00000100, 0x0000a700, 0x00000000, + 0x0000e100, 0x0000c500, 0x00000000, 0xffffff00, 0x00000eff, 0x00001600, 0x00000000, 0x00000100, + 0x0000ea00, 0x00001700, 0x00000000, 0x00000100, 0x0000f600, 0x00001800, 0x00000000, 0x00000100, + 0x00010200, 0x00001900, 0x00000000, 0x00000100, 0x00010e00, 0x00001a00, 0x00000000, 0x00000100, + 0x00011a00, 0x00001b00, 0x00000000, 0x00000100, 0x00012600, 0x00001c00, 0x00000000, 0x00000100, + 0x00013200, 0x00001d00, 0x00000000, 0x00000100, 0x00013e00, 0x00001e00, 0x00000000, 0x00000100, + 0x00014a00, 0x00001f00, 0x00000000, 0x00000100, 0x00015600, 0x00002000, 0x00000000, 0x00000100, + 0x00016200, 0x00002100, 0x00000000, 0x00000100, 0x00016e00, 0x00002200, 0x00000000, 0x00000100, + 0x00017a00, 0x00002300, 0x00000000, 0x00000100, 0x00018600, 0x00000000, 0x0001b900, 0x00019d00, + 0x00000000, 0xffffff00, 0x00000bff, 0x00002400, 0x00000000, 0x00000100, 0x0001c500, 0x00002500, + 0x00000000, 0x00000100, 0x0001d100, 0x00002500, 0x00000700, 0x00000100, 0x0001dd00, 0x00002600, + 0x00000000, 0x00000100, 0x0001e900, 0x00002700, 0x00000000, 0x00000100, 0x0001f500, 0x00002800, + 0x00000000, 0x00000100, 0x00020100, 0x00002900, 0x00000000, 0x00000100, 0x00020d00, 0x00002a00, + 0x00000000, 0x00000100, 0x00021900, 0x00002b00, 0x00000000, 0x00000100, 0x00022500, 0x00002c00, + 0x00000000, 0x00000100, 0x00023100, 0x00002c00, 0x00000700, 0x00000100, 0x00023d00, 0x00000000, + 0x00027200, 0x00025600, 0x00000000, 0xffffff00, 0x00000bff, 0x00002d00, 0x00000000, 0x00000100, + 0x00027b00, 0x00002e00, 0x00000000, 0x00000100, 0x00028700, 0x00002f00, 0x00000000, 0x00000100, + 0x00029300, 0x00003000, 0x00000000, 0x00000100, 0x00029f00, 0x00003100, 0x00000000, 0x00000100, + 0x0002ab00, 0x00003200, 0x00000000, 0x00000100, 0x0002b700, 0x00003300, 0x00000000, 0x00000100, + 0x0002c300, 0x00003400, 0x00000000, 0x00000100, 0x0002cf00, 0x00003500, 0x00000000, 0x00000100, + 0x0002f300, 0x00003600, 0x00000000, 0x00000100, 0x0002ff00, 0x00003700, 0x00000000, 0x00000100, + 0x00030b00, 0x00000000, 0x00033b00, 0x00031f00, 0x00000000, 0xffffff00, 0x000000ff, 0x00036400, + 0x00034800, 0x00000000, 0xffffff00, 0x000000ff, 0x00039200, 0x00037600, 0x00000000, 0xffffff00, + 0x000000ff, 0x0003bc00, 0x0003a000, 0x00000000, 0xffffff00, 0x000000ff, 0x0003ea00, 0x0003ce00, + 0x00000000, 0xffffff00, 0x000000ff, 0x00041600, 0x0003fa00, 0x00000000, 0xffffff00, 0x000000ff, + 0x00044900, 0x00042d00, 0x00000000, 0xffffff00, 0x000000ff, 0x00047600, 0x00045a00, 0x00000000, + 0xffffff00, 0x000000ff, 0x0004a100, 0x00048500, 0x00000000, 0xffffff00, 0x000000ff, 0x0004a400, + 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000200, 0x00033b00, + 0x00000000, 0x0004ad00, 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, + 0x00000200, 0x00036400, 0x00000000, 0x0004b600, 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, + 0x00003700, 0x00000000, 0x00000200, 0x00039200, 0x00000000, 0x0004c000, 0x00025600, 0x00000000, + 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000200, 0x0003bc00, 0x00000000, 0x0004c900, + 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000200, 0x0003ea00, + 0x00000000, 0x0004d300, 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, + 0x00000200, 0x00041600, 0x00000000, 0x0004dc00, 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, + 0x00003700, 0x00000000, 0x00000200, 0x00044900, 0x00000000, 0x0004e600, 0x00025600, 0x00000000, + 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000200, 0x00047600, 0x00000000, 0x0004ef00, + 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000200, 0x0004a100, + 0x00000000, 0x00051400, 0x0004f800, 0x00000000, 0xffffff00, 0x000000ff, 0x00053500, 0x00051900, + 0x00000000, 0xffffff00, 0x000000ff, 0x00055600, 0x00053a00, 0x00000000, 0xffffff00, 0x000000ff, + 0x00057800, 0x00055c00, 0x00000000, 0xffffff00, 0x000000ff, 0x00059900, 0x00057d00, 0x00000000, + 0xffffff00, 0x000000ff, 0x0005bb00, 0x00059f00, 0x00000000, 0xffffff00, 0x000000ff, 0x0005df00, + 0x0005c300, 0x00000000, 0xffffff00, 0x000000ff, 0x00060400, 0x0005e800, 0x00000000, 0xffffff00, + 0x000000ff, 0x00062500, 0x00060900, 0x00000000, 0xffffff00, 0x000000ff, 0x00062a00, 0x00025600, + 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000300, 0x00063300, 0x00000000, + 0x00063b00, 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000300, + 0x00064400, 0x00000000, 0x00064c00, 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, + 0x00000000, 0x00000300, 0x00065500, 0x00000000, 0x00065d00, 0x00025600, 0x00000000, 0xffffff00, + 0x000001ff, 0x00003700, 0x00000000, 0x00000300, 0x00066700, 0x00000000, 0x00066f00, 0x00025600, + 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000300, 0x00067900, 0x00000000, + 0x00068100, 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000300, + 0x00068b00, 0x00000000, 0x00069300, 0x00025600, 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, + 0x00000000, 0x00000300, 0x00069d00, 0x00000000, 0x0006a500, 0x00025600, 0x00000000, 0xffffff00, + 0x000001ff, 0x00003700, 0x00000000, 0x00000300, 0x0006af00, 0x00000000, 0x0006b700, 0x00025600, + 0x00000000, 0xffffff00, 0x000001ff, 0x00003700, 0x00000000, 0x00000300, 0x0006c100, 0x00000000, + 0x0006c900, 0x00000100, 0x00000000, 0x0006cf00, 0x00000600, 0x00000000, 0x00000a00, 0x00000000, + 0x00000100, 0x0006d500, 0x00000b00, 0x00000000, 0x00000100, 0x0006f900, 0x00000200, 0x00000000, + 0x00000200, 0x0001b900, 0x00000900, 0x00000000, 0x00000100, 0x00070500, 0x00000100, 0x00000000, + 0x00000200, 0x0000e100, 0x00000000, 0x00000000, 0x00000200, 0x00003000, 0x00000000, };
static void test_effect_state_groups(void) @@ -4296,7 +4347,7 @@ static void test_effect_state_groups(void) effect_desc.ConstantBuffers); ok(effect_desc.SharedConstantBuffers == 0, "Unexpected shared constant buffers count %u.\n", effect_desc.SharedConstantBuffers); - ok(effect_desc.GlobalVariables == 22, "Unexpected global variables count %u.\n", + ok(effect_desc.GlobalVariables == 40, "Unexpected global variables count %u.\n", effect_desc.GlobalVariables); ok(effect_desc.SharedGlobalVariables == 0, "Unexpected shared global variables count %u.\n", effect_desc.SharedGlobalVariables);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
On Fri, Oct 8, 2021 at 7:14 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/effect.c | 142 +++++++++++++++++++++++++++++---- dlls/d3d10/tests/effect.c | 161 +++++++++++++++++++++++++------------- 2 files changed, 233 insertions(+), 70 deletions(-)
I have a couple of general comments, not really directed at this patch (in fact here you're syncing up two functions so it's kind of the special case where you don't want to follow them) but more as a heads up.
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 1e144bb1c56..6f3ece24e79 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1710,17 +1710,19 @@ static BOOL is_object_property_type_matching(const struct d3d10_effect_state_pro } }
-static BOOL parse_fx10_state_group(const char *data, size_t data_size, +static HRESULT parse_fx10_property_assignment(const char *data, size_t data_size, const char **ptr, enum d3d10_effect_container_type container_type, struct d3d10_effect *effect, void *container) { const struct d3d10_effect_state_property_info *property_info;
- UINT value_offset, sodecl_offset, operation; struct d3d10_effect_variable *variable;
- UINT value_offset, operation;
- unsigned int i, variable_idx;
- const char *data_ptr; const char *name; size_t name_len;
- unsigned int i; DWORD count;
- HRESULT hr; void *dst; UINT idx; UINT id;
As far as I'm concerned, you can just use "unsigned int" (or uint32_t, where it makes sense) instead of UINT / DWORD for new variables.
@@ -1807,18 +1809,128 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, else { FIXME("Assigning variables to numeric fields is not supported.\n");
return FALSE;
return E_FAIL; } break;
case D3D10_EOO_CONST_INDEX:
/* Array variable, constant index. */
if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size))
{
WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size);
return E_FAIL;
}
data_ptr = data + value_offset;
read_dword(&data_ptr, &value_offset);
read_dword(&data_ptr, &variable_idx);
if (!fx10_get_string(data, data_size, value_offset, &name, &name_len))
{
WARN("Failed to get variable name.\n");
return E_FAIL;
}
TRACE("Variable name %s[%u].\n", debugstr_a(name), variable_idx);
if (!(variable = d3d10_effect_get_variable_by_name(effect, name)))
{
WARN("Couldn't find variable %s.\n", debugstr_a(name));
return E_FAIL;
}
/* Has to be an array */
if (!variable->type->element_count || variable_idx >= variable->type->element_count)
{
WARN("Invalid array size %u.\n", variable->type->element_count);
return E_FAIL;
}
if (is_object_property(property_info))
{
if (!is_object_property_type_matching(property_info, variable))
{
WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
variable->type->basetype, property_info->type);
return E_FAIL;
}
*(void **)dst = &variable->elements[variable_idx];
}
else
{
FIXME("Assigning indexed variables to numeric fields is not supported.\n");
return E_FAIL;
}
break;
case D3D10_EOO_ANONYMOUS_SHADER:
/* Anonymous shader */
if (effect->anonymous_shader_current >= effect->anonymous_shader_count)
{
ERR("Anonymous shader count is wrong!\n");
return E_FAIL;
}
if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size))
{
WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size);
return E_FAIL;
}
data_ptr = data + value_offset;
read_dword(&data_ptr, &value_offset);
read_dword(&data_ptr, &sodecl_offset);
TRACE("Effect object starts at offset %#x.\n", value_offset);
if (FAILED(hr = parse_fx10_anonymous_shader(effect,
&effect->anonymous_shaders[effect->anonymous_shader_current], property_info->id)))
return hr;
variable = &effect->anonymous_shaders[effect->anonymous_shader_current].shader;
++effect->anonymous_shader_current;
I see nothing wrong with simply using the postincrement operator in the previous assignment instead.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 572 ++++++++++++++------------------------------ 1 file changed, 176 insertions(+), 396 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 6f3ece24e79..047d0438377 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -145,6 +145,7 @@ static inline struct d3d10_effect_variable *impl_from_ID3D10EffectShaderVariable enum d3d10_effect_container_type { D3D10_C_NONE, + D3D10_C_PASS, D3D10_C_RASTERIZER, D3D10_C_DEPTHSTENCIL, D3D10_C_BLEND, @@ -172,10 +173,27 @@ struct d3d10_effect_state_property_info UINT count; enum d3d10_effect_container_type container_type; LONG offset; + LONG index_offset; };
static const struct d3d10_effect_state_property_info property_info[] = { + {0x00, "Pass.RasterizerState", D3D10_SVT_RASTERIZER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, rasterizer) }, + {0x01, "Pass.DepthStencilState", D3D10_SVT_DEPTHSTENCIL, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, depth_stencil) }, + {0x02, "Pass.BlendState", D3D10_SVT_BLEND, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, blend) }, + {0x03, "Pass.RenderTargets", D3D10_SVT_RENDERTARGETVIEW, 1, 8, D3D10_C_PASS, ~0u }, + {0x04, "Pass.DepthStencilView", D3D10_SVT_DEPTHSTENCILVIEW, 1, 1, D3D10_C_PASS, ~0u }, + {0x05, "Pass.Unknown5", D3D10_SVT_VOID, 0, 0, D3D10_C_PASS, ~0u }, + {0x06, "Pass.VertexShader", D3D10_SVT_VERTEXSHADER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, vs.shader), + FIELD_OFFSET(struct d3d10_effect_pass, vs.index) }, + {0x07, "Pass.PixelShader", D3D10_SVT_PIXELSHADER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, ps.shader), + FIELD_OFFSET(struct d3d10_effect_pass, ps.index) }, + {0x08, "Pass.GeometryShader", D3D10_SVT_GEOMETRYSHADER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, gs.shader), + FIELD_OFFSET(struct d3d10_effect_pass, gs.index) }, + {0x09, "Pass.StencilRef", D3D10_SVT_UINT, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, stencil_ref) }, + {0x0a, "Pass.BlendFactor", D3D10_SVT_FLOAT, 4, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, blend_factor) }, + {0x0b, "Pass.SampleMask", D3D10_SVT_UINT, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, sample_mask) }, + {0x0c, "RasterizerState.FillMode", D3D10_SVT_INT, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, FillMode) }, {0x0d, "RasterizerState.CullMode", D3D10_SVT_INT, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, CullMode) }, {0x0e, "RasterizerState.FrontCounterClockwise", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, FrontCounterClockwise) }, @@ -186,6 +204,7 @@ static const struct d3d10_effect_state_property_info property_info[] = {0x13, "RasterizerState.ScissorEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, ScissorEnable) }, {0x14, "RasterizerState.MultisampleEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, MultisampleEnable) }, {0x15, "RasterizerState.AntialiasedLineEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, AntialiasedLineEnable) }, + {0x16, "DepthStencilState.DepthEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthEnable) }, {0x17, "DepthStencilState.DepthWriteMask", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthWriteMask) }, {0x18, "DepthStencilState.DepthFunc", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthFunc) }, @@ -200,6 +219,7 @@ static const struct d3d10_effect_state_property_info property_info[] = {0x21, "DepthStencilState.BackFaceStencilDepthFail", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilDepthFailOp) }, {0x22, "DepthStencilState.BackFaceStencilPass", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilPassOp) }, {0x23, "DepthStencilState.BackFaceStencilFunc", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilFunc) }, + {0x24, "BlendState.AlphaToCoverageEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, AlphaToCoverageEnable) }, {0x25, "BlendState.BlendEnable", D3D10_SVT_BOOL, 1, 8, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, BlendEnable) }, {0x26, "BlendState.SrcBlend", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, SrcBlend) }, @@ -209,6 +229,7 @@ static const struct d3d10_effect_state_property_info property_info[] = {0x2a, "BlendState.DestBlendAlpha", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, DestBlendAlpha) }, {0x2b, "BlendState.BlendOpAlpha", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, BlendOpAlpha) }, {0x2c, "BlendState.RenderTargetWriteMask", D3D10_SVT_UINT8, 1, 8, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, RenderTargetWriteMask) }, + {0x2d, "SamplerState.Filter", D3D10_SVT_INT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.Filter) }, {0x2e, "SamplerState.AddressU", D3D10_SVT_INT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.AddressU) }, {0x2f, "SamplerState.AddressV", D3D10_SVT_INT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.AddressV) }, @@ -1657,6 +1678,18 @@ static BOOL read_value_list(const char *data, size_t data_size, DWORD offset, return FALSE; break;
+ case D3D10_SVT_VERTEXSHADER: + *(void **)out_data = &anonymous_vs; + break; + + case D3D10_SVT_PIXELSHADER: + *(void **)out_data = &anonymous_ps; + break; + + case D3D10_SVT_GEOMETRYSHADER: + *(void **)out_data = &anonymous_gs; + break; + case D3D10_SVT_TEXTURE: break;
@@ -1717,492 +1750,227 @@ static HRESULT parse_fx10_property_assignment(const char *data, size_t data_size const struct d3d10_effect_state_property_info *property_info; UINT value_offset, sodecl_offset, operation; struct d3d10_effect_variable *variable; - unsigned int i, variable_idx; + unsigned int variable_idx, *dst_index; const char *data_ptr; const char *name; size_t name_len; - DWORD count; HRESULT hr; void *dst; UINT idx; UINT id;
- read_dword(ptr, &count); - TRACE("Property count: %#x.\n", count); + read_dword(ptr, &id); + read_dword(ptr, &idx); + read_dword(ptr, &operation); + read_dword(ptr, &value_offset);
- for (i = 0; i < count; ++i) + if (!(property_info = get_property_info(id))) { - read_dword(ptr, &id); - read_dword(ptr, &idx); - read_dword(ptr, &operation); - read_dword(ptr, &value_offset); - - if (!(property_info = get_property_info(id))) - { - FIXME("Failed to find property info for property %#x.\n", id); - return E_FAIL; - } - - TRACE("Property %s[%#x] = value list @ offset %#x.\n", - property_info->name, idx, value_offset); - - if (property_info->container_type != container_type) - { - ERR("Invalid container type %#x for property %#x.\n", container_type, id); - return E_FAIL; - } - - if (idx >= property_info->count) - { - ERR("Invalid index %#x for property %#x.\n", idx, id); - return E_FAIL; - } - - dst = (char *)container + property_info->offset; - - switch (operation) - { - case D3D10_EOO_CONST: - - /* Constant values output directly to backing store. */ - if (!read_value_list(data, data_size, value_offset, property_info->type, idx, - property_info->size, dst)) - { - ERR("Failed to read values for property %#x.\n", id); - return E_FAIL; - } - break; - - case D3D10_EOO_VAR: - - /* Variable. */ - if (!fx10_get_string(data, data_size, value_offset, &name, &name_len)) - { - WARN("Failed to get variable name.\n"); - return E_FAIL; - } - TRACE("Variable name %s.\n", debugstr_a(name)); - - if (!(variable = d3d10_effect_get_variable_by_name(effect, name))) - { - WARN("Couldn't find variable %s.\n", debugstr_a(name)); - return E_FAIL; - } - - if (is_object_property(property_info)) - { - if (variable->type->element_count) - { - WARN("Unexpected array variable value %s.\n", debugstr_a(name)); - return E_FAIL; - } - - if (!is_object_property_type_matching(property_info, variable)) - { - WARN("Object type mismatch. Variable type %#x, property type %#x.\n", - variable->type->basetype, property_info->type); - return E_FAIL; - } - - *(void **)dst = variable; - } - else - { - FIXME("Assigning variables to numeric fields is not supported.\n"); - return E_FAIL; - } - - break; + FIXME("Failed to find property info for property %#x.\n", id); + return E_FAIL; + }
- case D3D10_EOO_CONST_INDEX: + TRACE("Property %s[%#x] = value list @ offset %#x.\n", + property_info->name, idx, value_offset);
- /* Array variable, constant index. */ - if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size)) - { - WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size); - return E_FAIL; - } - data_ptr = data + value_offset; - read_dword(&data_ptr, &value_offset); - read_dword(&data_ptr, &variable_idx); + if (property_info->container_type != container_type) + { + ERR("Invalid container type %#x for property %#x.\n", container_type, id); + return E_FAIL; + }
- if (!fx10_get_string(data, data_size, value_offset, &name, &name_len)) - { - WARN("Failed to get variable name.\n"); - return E_FAIL; - } + if (idx >= property_info->count) + { + ERR("Invalid index %#x for property %#x.\n", idx, id); + return E_FAIL; + }
- TRACE("Variable name %s[%u].\n", debugstr_a(name), variable_idx); + if (property_info->offset == ~0u) + { + ERR("Unsupported property %#x.\n", id); + return E_NOTIMPL; + }
- if (!(variable = d3d10_effect_get_variable_by_name(effect, name))) - { - WARN("Couldn't find variable %s.\n", debugstr_a(name)); - return E_FAIL; - } + dst = (char *)container + property_info->offset; + dst_index = (unsigned int *)((char *)container + property_info->index_offset);
- /* Has to be an array */ - if (!variable->type->element_count || variable_idx >= variable->type->element_count) - { - WARN("Invalid array size %u.\n", variable->type->element_count); - return E_FAIL; - } + switch (operation) + { + case D3D10_EOO_CONST:
- if (is_object_property(property_info)) - { - if (!is_object_property_type_matching(property_info, variable)) - { - WARN("Object type mismatch. Variable type %#x, property type %#x.\n", - variable->type->basetype, property_info->type); - return E_FAIL; - } + /* Constant values output directly to backing store. */ + if (!read_value_list(data, data_size, value_offset, property_info->type, idx, + property_info->size, dst)) + { + ERR("Failed to read values for property %#x.\n", id); + return E_FAIL; + } + break;
- *(void **)dst = &variable->elements[variable_idx]; - } - else - { - FIXME("Assigning indexed variables to numeric fields is not supported.\n"); - return E_FAIL; - } + case D3D10_EOO_VAR:
- break; + /* Variable. */ + if (!fx10_get_string(data, data_size, value_offset, &name, &name_len)) + { + WARN("Failed to get variable name.\n"); + return E_FAIL; + } + TRACE("Variable name %s.\n", debugstr_a(name));
- case D3D10_EOO_ANONYMOUS_SHADER: + if (!(variable = d3d10_effect_get_variable_by_name(effect, name))) + { + WARN("Couldn't find variable %s.\n", debugstr_a(name)); + return E_FAIL; + }
- /* Anonymous shader */ - if (effect->anonymous_shader_current >= effect->anonymous_shader_count) + if (is_object_property(property_info)) + { + if (variable->type->element_count) { - ERR("Anonymous shader count is wrong!\n"); + WARN("Unexpected array variable value %s.\n", debugstr_a(name)); return E_FAIL; }
- if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size)) + if (!is_object_property_type_matching(property_info, variable)) { - WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size); + WARN("Object type mismatch. Variable type %#x, property type %#x.\n", + variable->type->basetype, property_info->type); return E_FAIL; } - data_ptr = data + value_offset; - read_dword(&data_ptr, &value_offset); - read_dword(&data_ptr, &sodecl_offset); - - TRACE("Effect object starts at offset %#x.\n", value_offset); - - if (FAILED(hr = parse_fx10_anonymous_shader(effect, - &effect->anonymous_shaders[effect->anonymous_shader_current], property_info->id))) - return hr; - - variable = &effect->anonymous_shaders[effect->anonymous_shader_current].shader; - ++effect->anonymous_shader_current; - - if (sodecl_offset) - { - TRACE("Anonymous shader stream output declaration at offset %#x.\n", sodecl_offset); - if (!fx10_copy_string(data, data_size, sodecl_offset, - &variable->u.shader.stream_output_declaration)) - { - ERR("Failed to copy stream output declaration.\n"); - return E_FAIL; - } - - TRACE("Stream output declaration: %s.\n", debugstr_a(variable->u.shader.stream_output_declaration)); - } - - switch (property_info->id) - { - case D3D10_EOT_VERTEXSHADER: - case D3D10_EOT_PIXELSHADER: - case D3D10_EOT_GEOMETRYSHADER: - if (FAILED(hr = parse_fx10_shader(data, data_size, value_offset, variable))) - return hr; - break; - - default: - FIXME("Unhandled object type %#x\n", property_info->id); - return E_FAIL; - }
*(void **)dst = variable; - - break; - - default: - FIXME("Unhandled operation %#x.\n", operation); + } + else + { + FIXME("Assigning variables to numeric fields is not supported.\n"); return E_FAIL; - } - } - - return S_OK; -} - -static HRESULT parse_fx10_object(const char *data, size_t data_size, - const char **ptr, struct d3d10_effect_pass *pass) -{ - ID3D10EffectVariable *variable = &null_variable.ID3D10EffectVariable_iface; - const char *data_ptr = NULL; - DWORD offset, sodecl_offset; - enum d3d10_effect_object_operation operation; - HRESULT hr; - struct d3d10_effect *effect = pass->technique->effect; - ID3D10Effect *e = &effect->ID3D10Effect_iface; - struct d3d10_effect_variable *v; - DWORD tmp, object_type, variable_idx = 0; - const char *name; - size_t name_len; - - if (!require_space(*ptr - data, 4, sizeof(DWORD), data_size)) - { - WARN("Invalid offset %#lx (data size %#lx).\n", (long)(*ptr - data), (long)data_size); - return E_FAIL; - } - - read_dword(ptr, &object_type); - TRACE("Effect object is of type %#x.\n", object_type); - - read_dword(ptr, &tmp); - TRACE("Effect object index %#x.\n", tmp); - - read_dword(ptr, &operation); - TRACE("Effect object operation %#x.\n", operation); + }
- read_dword(ptr, &offset); - TRACE("Effect object idx is at offset %#x.\n", offset); + break;
- switch(operation) - { - case D3D10_EOO_CONST: - TRACE("Copy variable values\n"); + case D3D10_EOO_CONST_INDEX:
- switch (object_type) + /* Array variable, constant index. */ + if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size)) { - case D3D10_EOT_VERTEXSHADER: - TRACE("Vertex shader\n"); - variable = &anonymous_vs.ID3D10EffectVariable_iface; - break; - - case D3D10_EOT_PIXELSHADER: - TRACE("Pixel shader\n"); - variable = &anonymous_ps.ID3D10EffectVariable_iface; - break; - - case D3D10_EOT_GEOMETRYSHADER: - TRACE("Geometry shader\n"); - variable = &anonymous_gs.ID3D10EffectVariable_iface; - break; - - case D3D10_EOT_STENCIL_REF: - if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &pass->stencil_ref)) - { - ERR("Failed to read stencil ref.\n"); - return E_FAIL; - } - break; - - case D3D10_EOT_SAMPLE_MASK: - if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &pass->sample_mask)) - { - FIXME("Failed to read sample mask.\n"); - return E_FAIL; - } - break; - - case D3D10_EOT_BLEND_FACTOR: - if (!read_value_list(data, data_size, offset, D3D10_SVT_FLOAT, 0, 4, &pass->blend_factor[0])) - { - FIXME("Failed to read blend factor.\n"); - return E_FAIL; - } - break; - - default: - FIXME("Unhandled object type %#x\n", object_type); - return E_FAIL; + WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size); + return E_FAIL; } - break; + data_ptr = data + value_offset; + read_dword(&data_ptr, &value_offset); + read_dword(&data_ptr, &variable_idx);
- case D3D10_EOO_VAR: - /* This is a local object, we've parsed in parse_fx10_local_object. */ - if (!fx10_get_string(data, data_size, offset, &name, &name_len)) + if (!fx10_get_string(data, data_size, value_offset, &name, &name_len)) { WARN("Failed to get variable name.\n"); return E_FAIL; } - TRACE("Variable name %s.\n", debugstr_a(name));
- variable = e->lpVtbl->GetVariableByName(e, name); - break; + TRACE("Variable name %s[%u].\n", debugstr_a(name), variable_idx);
- case D3D10_EOO_CONST_INDEX: - /* This is a local object, we've parsed in parse_fx10_local_object, which has an array index. */ - if (offset >= data_size || !require_space(offset, 2, sizeof(DWORD), data_size)) + if (!(variable = d3d10_effect_get_variable_by_name(effect, name))) { - WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size); + WARN("Couldn't find variable %s.\n", debugstr_a(name)); return E_FAIL; } - data_ptr = data + offset; - read_dword(&data_ptr, &offset); - read_dword(&data_ptr, &variable_idx);
- if (!fx10_get_string(data, data_size, offset, &name, &name_len)) + /* Has to be an array */ + if (!variable->type->element_count || variable_idx >= variable->type->element_count) { - WARN("Failed to get variable name.\n"); + WARN("Invalid array size %u.\n", variable->type->element_count); return E_FAIL; }
- TRACE("Variable name %s[%u].\n", debugstr_a(name), variable_idx); + if (is_object_property(property_info)) + { + if (!is_object_property_type_matching(property_info, variable)) + { + WARN("Object type mismatch. Variable type %#x, property type %#x.\n", + variable->type->basetype, property_info->type); + return E_FAIL; + } + + /* Shader variables are special, they are referenced via array, with index stored separately. */ + switch (property_info->type) + { + case D3D10_SVT_VERTEXSHADER: + case D3D10_SVT_PIXELSHADER: + case D3D10_SVT_GEOMETRYSHADER: + *(void **)dst = variable; + *dst_index = variable_idx; + break; + default: + *(void **)dst = &variable->elements[variable_idx]; + } + } + else + { + FIXME("Assigning indexed variables to numeric fields is not supported.\n"); + return E_FAIL; + }
- variable = e->lpVtbl->GetVariableByName(e, name); break;
case D3D10_EOO_ANONYMOUS_SHADER: - TRACE("Anonymous shader\n");
- /* check anonymous_shader_current for validity */ + /* Anonymous shader */ if (effect->anonymous_shader_current >= effect->anonymous_shader_count) { ERR("Anonymous shader count is wrong!\n"); return E_FAIL; }
- if (offset >= data_size || !require_space(offset, 2, sizeof(DWORD), data_size)) + if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size)) { - WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size); + WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size); return E_FAIL; } - data_ptr = data + offset; - read_dword(&data_ptr, &offset); - TRACE("Effect object starts at offset %#x.\n", offset); + data_ptr = data + value_offset; + read_dword(&data_ptr, &value_offset); read_dword(&data_ptr, &sodecl_offset);
+ TRACE("Effect object starts at offset %#x.\n", value_offset); + if (FAILED(hr = parse_fx10_anonymous_shader(effect, - &effect->anonymous_shaders[effect->anonymous_shader_current], object_type))) + &effect->anonymous_shaders[effect->anonymous_shader_current], property_info->id))) return hr;
- v = &effect->anonymous_shaders[effect->anonymous_shader_current].shader; - variable = &v->ID3D10EffectVariable_iface; + variable = &effect->anonymous_shaders[effect->anonymous_shader_current].shader; ++effect->anonymous_shader_current;
if (sodecl_offset) { TRACE("Anonymous shader stream output declaration at offset %#x.\n", sodecl_offset); if (!fx10_copy_string(data, data_size, sodecl_offset, - &v->u.shader.stream_output_declaration)) + &variable->u.shader.stream_output_declaration)) { ERR("Failed to copy stream output declaration.\n"); - return E_OUTOFMEMORY; + return E_FAIL; }
- TRACE("Stream output declaration: %s.\n", debugstr_a(v->u.shader.stream_output_declaration)); + TRACE("Stream output declaration: %s.\n", debugstr_a(variable->u.shader.stream_output_declaration)); }
- switch (object_type) + switch (property_info->id) { case D3D10_EOT_VERTEXSHADER: case D3D10_EOT_PIXELSHADER: case D3D10_EOT_GEOMETRYSHADER: - if (FAILED(hr = parse_fx10_shader(data, data_size, offset, v))) + if (FAILED(hr = parse_fx10_shader(data, data_size, value_offset, variable))) return hr; break;
default: - FIXME("Unhandled object type %#x\n", object_type); + FIXME("Unhandled object type %#x\n", property_info->id); return E_FAIL; } - break;
- default: - FIXME("Unhandled operation %#x.\n", operation); - return E_FAIL; - } + *(void **)dst = variable;
- switch (object_type) - { - case D3D10_EOT_RASTERIZER_STATE: - { - ID3D10EffectRasterizerVariable *rv = variable->lpVtbl->AsRasterizer(variable); - if (!rv->lpVtbl->IsValid(rv)) - { - WARN("Invalid variable type.\n"); - return E_FAIL; - } - v = impl_from_ID3D10EffectVariable(variable); - if (v->type->element_count) - { - if (variable_idx >= v->type->element_count) return E_FAIL; - pass->rasterizer = &v->elements[variable_idx]; - } - else - pass->rasterizer = v; - break; - } - - case D3D10_EOT_DEPTH_STENCIL_STATE: - { - ID3D10EffectDepthStencilVariable *dv = variable->lpVtbl->AsDepthStencil(variable); - if (!dv->lpVtbl->IsValid(dv)) - { - WARN("Invalid variable type.\n"); - return E_FAIL; - } - v = impl_from_ID3D10EffectVariable(variable); - if (v->type->element_count) - { - if (variable_idx >= v->type->element_count) return E_FAIL; - pass->depth_stencil = &v->elements[variable_idx]; - } - else - pass->depth_stencil = v; - break; - } - - case D3D10_EOT_BLEND_STATE: - { - ID3D10EffectBlendVariable *bv = variable->lpVtbl->AsBlend(variable); - if (!bv->lpVtbl->IsValid(bv)) - { - WARN("Invalid variable type.\n"); - return E_FAIL; - } - v = impl_from_ID3D10EffectVariable(variable); - if (v->type->element_count) - { - if (variable_idx >= v->type->element_count) return E_FAIL; - pass->blend = &v->elements[variable_idx]; - } - else - pass->blend = v; - break; - } - - case D3D10_EOT_VERTEXSHADER: - { - ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable); - pass->vs.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); - pass->vs.index = variable_idx; - break; - } - - case D3D10_EOT_PIXELSHADER: - { - ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable); - pass->ps.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); - pass->ps.index = variable_idx; - break; - } - - case D3D10_EOT_GEOMETRYSHADER: - { - ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable); - pass->gs.shader = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)sv); - pass->gs.index = variable_idx; - break; - } - - case D3D10_EOT_STENCIL_REF: - case D3D10_EOT_BLEND_FACTOR: - case D3D10_EOT_SAMPLE_MASK: break;
default: - FIXME("Unhandled object type %#x.\n", object_type); + FIXME("Unhandled operation %#x.\n", operation); return E_FAIL; }
@@ -2213,8 +1981,8 @@ static HRESULT parse_fx10_pass(const char *data, size_t data_size, const char **ptr, struct d3d10_effect_pass *p) { DWORD offset, object_count; - HRESULT hr = S_OK; unsigned int i; + HRESULT hr;
read_dword(ptr, &offset); TRACE("Pass name at offset %#x.\n", offset); @@ -2245,8 +2013,12 @@ static HRESULT parse_fx10_pass(const char *data, size_t data_size,
for (i = 0; i < object_count; ++i) { - if (FAILED(hr = parse_fx10_object(data, data_size, ptr, p))) + if (FAILED(hr = parse_fx10_property_assignment(data, data_size, ptr, + D3D10_C_PASS, p->technique->effect, p))) + { + WARN("Failed to parse pass assignment %u, hr %#x.\n", i, hr); return hr; + } }
return hr; @@ -2395,7 +2167,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) { - unsigned int i; + unsigned int i, j; HRESULT hr; DWORD offset;
@@ -2522,18 +2294,26 @@ static HRESULT parse_fx10_object_variable(const char *data, size_t data_size, for (i = 0; i < count; ++i) { struct d3d10_effect_variable *var; + unsigned int prop_count;
if (v->type->element_count) var = &v->elements[i]; else var = v;
+ read_dword(ptr, &prop_count); + TRACE("State object property count: %#x.\n", prop_count); + memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size); - if (FAILED(hr = parse_fx10_property_assignment(data, data_size, ptr, - get_var_container_type(var), var->effect, &var->u.state.desc))) + + for (j = 0; j < prop_count; ++j) { - ERR("Failed to read property list.\n"); - return hr; + if (FAILED(hr = parse_fx10_property_assignment(data, data_size, ptr, + get_var_container_type(var), var->effect, &var->u.state.desc))) + { + ERR("Failed to read property list.\n"); + return hr; + } }
if (FAILED(hr = create_state_object(var)))
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 047d0438377..9d8e4ee4568 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -176,7 +176,7 @@ struct d3d10_effect_state_property_info LONG index_offset; };
-static const struct d3d10_effect_state_property_info property_info[] = +static const struct d3d10_effect_state_property_info property_infos[] = { {0x00, "Pass.RasterizerState", D3D10_SVT_RASTERIZER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, rasterizer) }, {0x01, "Pass.DepthStencilState", D3D10_SVT_DEPTHSTENCIL, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, depth_stencil) }, @@ -1540,19 +1540,6 @@ static HRESULT parse_fx10_anonymous_shader(struct d3d10_effect *e, struct d3d10_ return S_OK; }
-static const struct d3d10_effect_state_property_info *get_property_info(UINT id) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(property_info); ++i) - { - if (property_info[i].id == id) - return &property_info[i]; - } - - return NULL; -} - static const struct d3d10_effect_state_storage_info *get_storage_info(D3D_SHADER_VARIABLE_TYPE id) { unsigned int i; @@ -1764,14 +1751,14 @@ static HRESULT parse_fx10_property_assignment(const char *data, size_t data_size read_dword(ptr, &operation); read_dword(ptr, &value_offset);
- if (!(property_info = get_property_info(id))) + if (id >= ARRAY_SIZE(property_infos)) { - FIXME("Failed to find property info for property %#x.\n", id); + FIXME("Unknown property id %#x.\n", id); return E_FAIL; } + property_info = &property_infos[id];
- TRACE("Property %s[%#x] = value list @ offset %#x.\n", - property_info->name, idx, value_offset); + TRACE("Property %s[%#x] = value list @ offset %#x.\n", property_info->name, idx, value_offset);
if (property_info->container_type != container_type) {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- The property_infos[] name is a bit awkward but I don't have any great suggestions for alternatives. Changing the name of the local property_info variable instead is quite a lot of churn, so I guess let's go with this.