Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 56 ++++++++++++++++++++++++--------------- dlls/d3d10/tests/effect.c | 53 +++++++++++++++++++++++++----------- 2 files changed, 72 insertions(+), 37 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 668efcda666..71660eb399e 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -526,6 +526,35 @@ static BOOL copy_name(const char *ptr, char **name) return TRUE; }
+static struct d3d10_effect_variable * d3d10_effect_get_buffer_by_name(struct d3d10_effect *effect, + const char *name) +{ + ID3D10EffectVariable *v; + unsigned int i; + + for (i = 0; i < effect->local_buffer_count; ++i) + { + struct d3d10_effect_variable *l = &effect->local_buffers[i]; + if (l->name && !strcmp(l->name, name)) + { + TRACE("Found local buffer %s.\n", debugstr_a(name)); + return l; + } + } + + if (effect->pool) + { + if ((v = (ID3D10EffectVariable *)effect->pool->lpVtbl->GetConstantBufferByName(effect->pool, name)) + && v->lpVtbl->IsValid(v)) + { + TRACE("Found shared buffer %s.\n", debugstr_a(name)); + return impl_from_ID3D10EffectVariable(v); + } + } + + return NULL; +} + static HRESULT get_fx10_shader_resources(struct d3d10_effect_variable *v, const void *data, size_t data_size) { struct d3d10_effect_shader_variable *sv = &v->u.shader; @@ -557,16 +586,7 @@ static HRESULT get_fx10_shader_resources(struct d3d10_effect_variable *v, const { case D3D10_SIT_CBUFFER: case D3D10_SIT_TBUFFER: - for (y = 0; y < v->effect->local_buffer_count; ++y) - { - var = &v->effect->local_buffers[y]; - - if (!strcmp(bind_desc.Name, var->name)) - { - sr->variable = var; - break; - } - } + sr->variable = d3d10_effect_get_buffer_by_name(v->effect, bind_desc.Name); break;
case D3D10_SIT_SAMPLER: @@ -3316,24 +3336,16 @@ static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetCon const char *name) { struct d3d10_effect *effect = impl_from_ID3D10Effect(iface); - unsigned int i; + struct d3d10_effect_variable *v;
TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
- for (i = 0; i < effect->local_buffer_count; ++i) + if ((v = d3d10_effect_get_buffer_by_name(effect, name))) { - struct d3d10_effect_variable *l = &effect->local_buffers[i]; - - if (l->name && !strcmp(l->name, name)) - { - TRACE("Returning buffer %p.\n", l); - return (ID3D10EffectConstantBuffer *)&l->ID3D10EffectVariable_iface; - } + TRACE("Returning buffer %p.\n", v); + return (ID3D10EffectConstantBuffer *)&v->ID3D10EffectVariable_iface; }
- if (effect->pool) - return effect->pool->lpVtbl->GetConstantBufferByName(effect->pool, name); - WARN("Invalid name specified\n");
return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface; diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index e833fc09799..a1ec44a0a16 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6294,22 +6294,27 @@ shared BlendState s_blendstate; shared Texture s_texture; shared PixelShader ps;
+float4 VS( float4 pos : POSITION ) : SV_POSITION +{ + return f1.xxxx; +} + technique10 tech_child { pass P0 { SetPixelShader(ps); - SetVertexShader(NULL); + SetVertexShader(CompileShader(vs_4_0, VS())); SetGeometryShader(NULL); } }; #endif static DWORD fx_test_pool_child[] = { - 0x43425844, 0xa11d7cb2, 0x41f20697, 0x14a62983, 0x43b9f39c, 0x00000001, 0x0000029f, 0x00000001, - 0x00000024, 0x30315846, 0x00000273, 0xfeff1001, 0x00000002, 0x00000002, 0x00000000, 0x00000001, - 0x00000002, 0x00000003, 0x00000001, 0x00000103, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x62635f6c, + 0x43425844, 0xa46943b7, 0x1a80ed65, 0x3602c2be, 0xfe502f4e, 0x00000001, 0x000004d7, 0x00000001, + 0x00000024, 0x30315846, 0x000004ab, 0xfeff1001, 0x00000002, 0x00000002, 0x00000000, 0x00000001, + 0x00000002, 0x00000003, 0x00000001, 0x0000033b, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x62635f6c, 0x6f6c6600, 0x09007461, 0x01000000, 0x00000000, 0x04000000, 0x10000000, 0x04000000, 0x09000000, 0x66000009, 0x4f430030, 0x30524f4c, 0x635f6c00, 0x66003262, 0x5f730033, 0x66006263, 0x32660031, 0x4c4f4300, 0x0031524f, 0x6e656c42, 0x61745364, 0x50006574, 0x02000000, 0x00000000, 0x00000000, @@ -6317,16 +6322,34 @@ static DWORD fx_test_pool_child[] = 0x00657275, 0x00000084, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000009, 0x65745f73, 0x72757478, 0x69500065, 0x536c6578, 0x65646168, 0x00b20072, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00050000, 0x73700000, 0x63657400, 0x68635f68, 0x00646c69, - 0x01003050, 0x02000000, 0x00000000, 0x01000000, 0x02000000, 0x00000000, 0x04000000, 0x10000000, - 0x00000000, 0x01000000, 0xff000000, 0x00ffffff, 0x2b000000, 0x0f000000, 0x2e000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x35000000, 0x10000000, 0x00000000, 0x01000000, 0xff000000, - 0x00ffffff, 0x3b000000, 0x0f000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x3e000000, 0x10000000, 0x00000000, 0x02000000, 0xff000000, 0x43ffffff, 0x0f000000, 0x2e000000, - 0x00000000, 0x00000000, 0x00000000, 0x46000000, 0x0f000000, 0x49000000, 0x04000000, 0x00000000, - 0x00000000, 0x77000000, 0x5b000000, 0x00000000, 0xff000000, 0xa8ffffff, 0x8c000000, 0x00000000, - 0xff000000, 0xdaffffff, 0xbe000000, 0x00000000, 0xff000000, 0xddffffff, 0x01000000, 0x00000000, - 0xe8000000, 0x03000000, 0x00000000, 0x07000000, 0x00000000, 0x02000000, 0xda000000, 0x06000000, - 0x00000000, 0x01000000, 0xeb000000, 0x08000000, 0x00000000, 0x01000000, 0xf7000000, 0x00000000, + 0x38003050, 0x44000002, 0x2d434258, 0x4237b3f1, 0x252579b9, 0x2c27ed59, 0x014a8013, 0x38000000, + 0x05000002, 0x34000000, 0x08000000, 0x3c000001, 0x70000001, 0xbc000001, 0x52000001, 0xcc464544, + 0x01000000, 0x44000000, 0x01000000, 0x1c000000, 0x00000000, 0x00fffe04, 0xa3000001, 0x3c000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x00000000, 0x73000000, + 0x0062635f, 0x3cababab, 0x02000000, 0x5c000000, 0x10000000, 0x00000000, 0x00000000, 0x8c000000, + 0x00000000, 0x04000000, 0x02000000, 0x90000000, 0x00000000, 0xa0000000, 0x04000000, 0x04000000, + 0x00000000, 0x90000000, 0x00000000, 0x66000000, 0x00ab0031, 0x01000300, 0x00000100, 0x00000000, + 0x66000000, 0x694d0032, 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, + 0x706d6f43, 0x72656c69, 0x2e303120, 0x49ab0031, 0x2c4e4753, 0x01000000, 0x08000000, 0x20000000, + 0x00000000, 0x00000000, 0x03000000, 0x00000000, 0x0f000000, 0x50000000, 0x5449534f, 0x004e4f49, + 0x4fababab, 0x2c4e4753, 0x01000000, 0x08000000, 0x20000000, 0x00000000, 0x01000000, 0x03000000, + 0x00000000, 0x0f000000, 0x53000000, 0x4f505f56, 0x49544953, 0x53004e4f, 0x44524448, 0x40000000, + 0x11000100, 0x59000000, 0x46040000, 0x0000208e, 0x01000000, 0x67000000, 0xf2040000, 0x00001020, + 0x01000000, 0x36000000, 0xf2060000, 0x00001020, 0x06000000, 0x00002080, 0x00000000, 0x3e000000, + 0x53010000, 0x74544154, 0x02000000, 0x00000000, 0x00000000, 0x01000000, 0x00000000, 0x00000000, + 0x00000000, 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xeb000000, + 0x00000000, 0x01000000, 0x02000000, 0x00000000, 0x04000000, 0x10000000, 0x00000000, 0x01000000, + 0xff000000, 0x00ffffff, 0x2b000000, 0x0f000000, 0x2e000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x35000000, 0x10000000, 0x00000000, 0x01000000, 0xff000000, 0x00ffffff, 0x3b000000, + 0x0f000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3e000000, 0x10000000, + 0x00000000, 0x02000000, 0xff000000, 0x43ffffff, 0x0f000000, 0x2e000000, 0x00000000, 0x00000000, + 0x00000000, 0x46000000, 0x0f000000, 0x49000000, 0x04000000, 0x00000000, 0x00000000, 0x77000000, + 0x5b000000, 0x00000000, 0xff000000, 0xa8ffffff, 0x8c000000, 0x00000000, 0xff000000, 0xdaffffff, + 0xbe000000, 0x00000000, 0xff000000, 0xddffffff, 0x01000000, 0x00000000, 0xe8000000, 0x03000000, + 0x00000000, 0x07000000, 0x00000000, 0x02000000, 0xda000000, 0x06000000, 0x00000000, 0x07000000, + 0x27000000, 0x08000003, 0x00000000, 0x01000000, 0x2f000000, 0x00000003, };
static void test_effect_pool(void)