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)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 101 ++++++++++++++++----------- dlls/d3d10/tests/effect.c | 143 ++++++++++++++++++++++---------------- 2 files changed, 143 insertions(+), 101 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 71660eb399e..70a99601eea 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -555,14 +555,66 @@ static struct d3d10_effect_variable * d3d10_effect_get_buffer_by_name(struct d3d return NULL; }
+static struct d3d10_effect_variable * d3d10_effect_get_variable_by_name(const 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]; + unsigned int j; + + for (j = 0; j < l->type->member_count; ++j) + { + struct d3d10_effect_variable *v = &l->members[j]; + + if (v->name && !strcmp(v->name, name)) + { + TRACE("Returning local buffer member variable %s.\n", debugstr_a(name)); + return v; + } + } + } + + for (i = 0; i < effect->local_variable_count; ++i) + { + struct d3d10_effect_variable *v = &effect->local_variables[i]; + + if (v->name && !strcmp(v->name, name)) + { + TRACE("Returning local variable %s.\n", debugstr_a(name)); + return v; + } + } + + if (effect->pool) + { + if ((v = (ID3D10EffectVariable *)effect->pool->lpVtbl->GetVariableByName(effect->pool, name)) + && v->lpVtbl->IsValid(v)) + { + TRACE("Found shared variable %s.\n", debugstr_a(name)); + return impl_from_ID3D10EffectVariable(v); + } + } + + return NULL; +} + +static struct d3d10_effect_variable * d3d10_effect_get_shader_resource_variable_by_name( + const struct d3d10_effect *effect, const char *name) +{ + return d3d10_effect_get_variable_by_name(effect, name); +} + 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; struct d3d10_effect_shader_resource *sr; D3D10_SHADER_INPUT_BIND_DESC bind_desc; - struct d3d10_effect_variable *var; D3D10_SHADER_DESC desc; - unsigned int i, y; + unsigned int i;
sv->reflection->lpVtbl->GetDesc(sv->reflection, &desc); sv->resource_count = desc.BoundResources; @@ -591,16 +643,8 @@ static HRESULT get_fx10_shader_resources(struct d3d10_effect_variable *v, const
case D3D10_SIT_SAMPLER: case D3D10_SIT_TEXTURE: - for (y = 0; y < v->effect->local_variable_count; ++y) - { - var = &v->effect->local_variables[y]; - - if (!strcmp(bind_desc.Name, var->name)) - { - sr->variable = var; - break; - } - } + sr->variable = d3d10_effect_get_shader_resource_variable_by_name(v->effect, + bind_desc.Name); break;
default: @@ -3393,7 +3437,7 @@ static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableB 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));
@@ -3403,37 +3447,12 @@ static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableB return &null_variable.ID3D10EffectVariable_iface; }
- for (i = 0; i < effect->local_buffer_count; ++i) - { - struct d3d10_effect_variable *l = &effect->local_buffers[i]; - unsigned int j; - - for (j = 0; j < l->type->member_count; ++j) - { - struct d3d10_effect_variable *v = &l->members[j]; - - if (v->name && !strcmp(v->name, name)) - { - TRACE("Returning variable %p.\n", v); - return &v->ID3D10EffectVariable_iface; - } - } - } - - for (i = 0; i < effect->local_variable_count; ++i) + if ((v = d3d10_effect_get_variable_by_name(effect, name))) { - struct d3d10_effect_variable *v = &effect->local_variables[i]; - - if (v->name && !strcmp(v->name, name)) - { - TRACE("Returning variable %p.\n", v); - return &v->ID3D10EffectVariable_iface; - } + TRACE("Returning variable %p.\n", v); + return &v->ID3D10EffectVariable_iface; }
- if (effect->pool) - return effect->pool->lpVtbl->GetVariableByName(effect->pool, name); - WARN("Invalid name specified\n");
return &null_variable.ID3D10EffectVariable_iface; diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index a1ec44a0a16..60be8186f8b 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6237,7 +6237,7 @@ cbuffer s_cb };
BlendState s_blendstate; -Texture s_texture; +Texture2D s_texture; PixelShader ps;
technique10 tech @@ -6252,24 +6252,25 @@ technique10 tech #endif static DWORD fx_test_pool[] = { - 0x43425844, 0x465314db, 0xd8433ab8, 0x34f3adc3, 0x03610f3e, 0x00000001, 0x00000240, 0x00000001, - 0x00000024, 0x30315846, 0x00000214, 0xfeff1001, 0x00000001, 0x00000002, 0x00000003, 0x00000000, - 0x00000000, 0x00000000, 0x00000001, 0x000000ec, 0x00000000, 0x00000001, 0x00000000, 0x00000001, + 0x43425844, 0x92a09896, 0xbc72ed33, 0x77194b8a, 0xb1132991, 0x00000001, 0x00000242, 0x00000001, + 0x00000024, 0x30315846, 0x00000216, 0xfeff1001, 0x00000001, 0x00000002, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x000000ee, 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x62635f73, 0x6f6c6600, 0x09007461, 0x01000000, 0x00000000, 0x04000000, 0x10000000, 0x04000000, 0x09000000, 0x66000009, 0x4f430031, 0x30524f4c, 0x00326600, 0x4f4c4f43, 0x42003152, 0x646e656c, 0x74617453, 0x003f0065, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00020000, 0x5f730000, - 0x6e656c62, 0x61747364, 0x74006574, 0x75747865, 0x73006572, 0x02000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x09000000, 0x73000000, 0x7865745f, 0x65727574, 0x78695000, 0x68536c65, - 0x72656461, 0x0000a100, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000500, - 0x00737000, 0x68636574, 0x00305000, 0x00000001, 0x00000002, 0x00000000, 0x00000001, 0x00000002, - 0x00000000, 0x00000004, 0x00000010, 0x00000000, 0x00000002, 0xffffffff, 0x00000000, 0x0000002b, - 0x0000000f, 0x0000002e, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000035, 0x0000000f, - 0x00000038, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000066, 0x0000004a, 0x00000000, - 0xffffffff, 0x00000000, 0x00000000, 0x00000097, 0x0000007b, 0x00000000, 0xffffffff, 0x00000000, - 0x000000c9, 0x000000ad, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x000000cc, 0x00000001, - 0x00000000, 0x000000d1, 0x00000003, 0x00000000, 0x00000007, 0x00000000, 0x00000002, 0x000000c9, - 0x00000006, 0x00000000, 0x00000001, 0x000000d4, 0x00000008, 0x00000000, 0x00000001, 0x000000e0, + 0x6e656c62, 0x61747364, 0x54006574, 0x75747865, 0x44326572, 0x00007300, 0x00000200, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000c00, 0x745f7300, 0x75747865, 0x50006572, 0x6c657869, + 0x64616853, 0xa3007265, 0x02000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05000000, + 0x70000000, 0x65740073, 0x50006863, 0x00010030, 0x00020000, 0x00000000, 0x00010000, 0x00020000, + 0x00000000, 0x00040000, 0x00100000, 0x00000000, 0x00020000, 0xffff0000, 0x0000ffff, 0x002b0000, + 0x000f0000, 0x002e0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00350000, 0x000f0000, + 0x00380000, 0x00040000, 0x00000000, 0x00000000, 0x00000000, 0x00660000, 0x004a0000, 0x00000000, + 0xffff0000, 0x0000ffff, 0x00000000, 0x00990000, 0x007d0000, 0x00000000, 0xffff0000, 0x0000ffff, + 0x00cb0000, 0x00af0000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000, 0x00ce0000, 0x00010000, + 0x00000000, 0x00d30000, 0x00030000, 0x00000000, 0x00070000, 0x00000000, 0x00020000, 0x00cb0000, + 0x00060000, 0x00000000, 0x00010000, 0x00d60000, 0x00080000, 0x00000000, 0x00010000, 0x00e20000, + 0x00000000, };
/* Compiled as a child with /Gch (D3DCOMPILE_EFFECT_CHILD_EFFECT) */ @@ -6291,7 +6292,7 @@ cbuffer l_cb2 };
shared BlendState s_blendstate; -shared Texture s_texture; +shared Texture2D s_texture; shared PixelShader ps;
float4 VS( float4 pos : POSITION ) : SV_POSITION @@ -6299,6 +6300,13 @@ float4 VS( float4 pos : POSITION ) : SV_POSITION return f1.xxxx; }
+float4 PS( float4 pos : SV_POSITION ) : SV_Target +{ + return s_texture.Load(int3(0,0,0)); +} + +PixelShader vs = CompileShader(ps_4_0, PS()); + technique10 tech_child { pass P0 @@ -6311,45 +6319,61 @@ technique10 tech_child #endif static DWORD fx_test_pool_child[] = { - 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, + 0x43425844, 0xfbf00688, 0x8af86d85, 0x759a5832, 0x320fdd75, 0x00000001, 0x000006e0, 0x00000001, + 0x00000024, 0x30315846, 0x000006b4, 0xfeff1001, 0x00000002, 0x00000002, 0x00000001, 0x00000001, + 0x00000002, 0x00000003, 0x00000001, 0x0000052c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 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, - 0x00000000, 0x00000000, 0x02000000, 0x73000000, 0x656c625f, 0x7473646e, 0x00657461, 0x74786574, - 0x00657275, 0x00000084, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000009, - 0x65745f73, 0x72757478, 0x69500065, 0x536c6578, 0x65646168, 0x00b20072, 0x00020000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00050000, 0x73700000, 0x63657400, 0x68635f68, 0x00646c69, - 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, + 0x66000009, 0x4f430030, 0x30524f4c, 0x635f6c00, 0x66003262, 0x69500033, 0x536c6578, 0x65646168, + 0x003e0072, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00050000, 0x73760000, + 0x0001e800, 0x42584400, 0x8d083943, 0x1caa8131, 0x88ca8b86, 0xbdb25507, 0x000001d8, 0x0001e800, + 0x00000500, 0x00003400, 0x0000ac00, 0x0000e000, 0x00011400, 0x00016c00, 0x45445200, 0x00007046, + 0x00000000, 0x00000000, 0x00000100, 0x00001c00, 0xff040000, 0x000100ff, 0x00004600, 0x00003c00, + 0x00000200, 0x00000500, 0x00000400, 0xffffff00, 0x000000ff, 0x00000100, 0x00000c00, 0x745f7300, + 0x75747865, 0x4d006572, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, + 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, 0x475349ab, 0x00002c4e, 0x00000100, 0x00000800, + 0x00002000, 0x00000000, 0x00000100, 0x00000300, 0x00000000, 0x00000f00, 0x5f565300, 0x49534f50, + 0x4e4f4954, 0x47534f00, 0x00002c4e, 0x00000100, 0x00000800, 0x00002000, 0x00000000, 0x00000000, + 0x00000300, 0x00000000, 0x00000f00, 0x5f565300, 0x67726154, 0xab007465, 0x444853ab, 0x00005052, + 0x00004000, 0x00001400, 0x00185800, 0x10700004, 0x00000000, 0x00555500, 0x00006500, 0x1020f203, + 0x00000000, 0x00002d00, 0x1020f20a, 0x00000000, 0x00400200, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x107e4600, 0x00000000, 0x00003e00, 0x41545301, 0x00007454, 0x00000200, 0x00000000, + 0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x635f7300, 0x31660062, 0x00326600, 0x4f4c4f43, 0x42003152, + 0x646e656c, 0x74617453, 0x02670065, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00020000, 0x5f730000, 0x6e656c62, 0x61747364, 0x54006574, 0x75747865, 0x44326572, 0x00029b00, + 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000c00, 0x745f7300, 0x75747865, + 0x70006572, 0x65740073, 0x635f6863, 0x646c6968, 0x00305000, 0x00000238, 0x43425844, 0x37b3f12d, + 0x2579b942, 0x27ed5925, 0x4a80132c, 0x00000001, 0x00000238, 0x00000005, 0x00000034, 0x00000108, + 0x0000013c, 0x00000170, 0x000001bc, 0x46454452, 0x000000cc, 0x00000001, 0x00000044, 0x00000001, + 0x0000001c, 0xfffe0400, 0x00000100, 0x000000a3, 0x0000003c, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x62635f73, 0xababab00, 0x0000003c, 0x00000002, + 0x0000005c, 0x00000010, 0x00000000, 0x00000000, 0x0000008c, 0x00000000, 0x00000004, 0x00000002, + 0x00000090, 0x00000000, 0x000000a0, 0x00000004, 0x00000004, 0x00000000, 0x00000090, 0x00000000, + 0xab003166, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x4d003266, 0x6f726369, 0x74666f73, + 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, + 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, + 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, + 0x5449534f, 0x004e4f49, 0x52444853, 0x00000044, 0x00010040, 0x00000011, 0x04000059, 0x00208e46, + 0x00000000, 0x00000001, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x06000036, 0x001020f2, + 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x00000002, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000002dc, 0x00000000, 0x00000001, 0x00000002, + 0x00000000, 0x00000004, 0x00000010, 0x00000000, 0x00000001, 0xffffffff, 0x00000000, 0x0000002b, + 0x0000000f, 0x0000002e, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000035, 0x00000010, + 0x00000000, 0x00000001, 0xffffffff, 0x00000000, 0x0000003b, 0x0000000f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000066, 0x0000004a, 0x00000000, 0xffffffff, 0x00000069, + 0x00000000, 0x00000255, 0x00000010, 0x00000000, 0x00000002, 0xffffffff, 0x0000025a, 0x0000000f, + 0x0000002e, 0x00000000, 0x00000000, 0x00000000, 0x0000025d, 0x0000000f, 0x00000260, 0x00000004, + 0x00000000, 0x00000000, 0x0000028e, 0x00000272, 0x00000000, 0xffffffff, 0x000002c1, 0x000002a5, + 0x00000000, 0xffffffff, 0x000002cb, 0x0000004a, 0x00000000, 0xffffffff, 0x000002ce, 0x00000001, + 0x00000000, 0x000002d9, 0x00000003, 0x00000000, 0x00000007, 0x00000000, 0x00000002, 0x000002cb, + 0x00000006, 0x00000000, 0x00000007, 0x00000518, 0x00000008, 0x00000000, 0x00000001, 0x00000520, };
static void test_effect_pool(void) @@ -6571,7 +6595,7 @@ todo_wine ok(desc.ConstantBuffers == 2, "Unexpected buffer count %u.\n", desc.ConstantBuffers); ok(desc.SharedConstantBuffers == 1, "Unexpected shared buffer count %u.\n", desc.SharedConstantBuffers); - ok(desc.GlobalVariables == 2, "Unexpected variables count %u.\n", desc.GlobalVariables); + ok(desc.GlobalVariables == 3, "Unexpected variables count %u.\n", desc.GlobalVariables); ok(desc.SharedGlobalVariables == 5, "Unexpected shared variables count %u.\n", desc.SharedGlobalVariables);
@@ -6627,21 +6651,20 @@ todo_wine v = child_effect->lpVtbl->GetVariableByIndex(child_effect, 2); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "f1"), "Unexpected name %s.\n", var_desc.Name); -todo_wine - ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + ok(!strcmp(var_desc.Name, "vs"), "Unexpected name %s.\n", var_desc.Name); + ok(!var_desc.Flags, "Unexpected flags %#x.\n", var_desc.Flags);
v = child_effect->lpVtbl->GetVariableByIndex(child_effect, 3); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "f2"), "Unexpected name %s.\n", var_desc.Name); + ok(!strcmp(var_desc.Name, "f1"), "Unexpected name %s.\n", var_desc.Name); todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = child_effect->lpVtbl->GetVariableByIndex(child_effect, 4); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "s_blendstate"), "Unexpected name %s.\n", var_desc.Name); + ok(!strcmp(var_desc.Name, "f2"), "Unexpected name %s.\n", var_desc.Name); todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
On Tue, Sep 28, 2021 at 2:23 PM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/effect.c | 101 ++++++++++++++++----------- dlls/d3d10/tests/effect.c | 143 ++++++++++++++++++++++---------------- 2 files changed, 143 insertions(+), 101 deletions(-)
diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index a1ec44a0a16..60be8186f8b 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6237,7 +6237,7 @@ cbuffer s_cb };
BlendState s_blendstate; -Texture s_texture; +Texture2D s_texture; PixelShader ps;
I'm curious if that change made any difference.
technique10 tech @@ -6252,24 +6252,25 @@ technique10 tech #endif static DWORD fx_test_pool[] = {
- 0x43425844, 0x465314db, 0xd8433ab8, 0x34f3adc3, 0x03610f3e, 0x00000001, 0x00000240, 0x00000001,
- 0x00000024, 0x30315846, 0x00000214, 0xfeff1001, 0x00000001, 0x00000002, 0x00000003, 0x00000000,
- 0x00000000, 0x00000000, 0x00000001, 0x000000ec, 0x00000000, 0x00000001, 0x00000000, 0x00000001,
- 0x43425844, 0x92a09896, 0xbc72ed33, 0x77194b8a, 0xb1132991, 0x00000001, 0x00000242, 0x00000001,
- 0x00000024, 0x30315846, 0x00000216, 0xfeff1001, 0x00000001, 0x00000002, 0x00000003, 0x00000000,
- 0x00000000, 0x00000000, 0x00000001, 0x000000ee, 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x62635f73, 0x6f6c6600, 0x09007461, 0x01000000, 0x00000000, 0x04000000, 0x10000000, 0x04000000, 0x09000000, 0x66000009, 0x4f430031, 0x30524f4c, 0x00326600, 0x4f4c4f43, 0x42003152, 0x646e656c, 0x74617453, 0x003f0065, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00020000, 0x5f730000,
- 0x6e656c62, 0x61747364, 0x74006574, 0x75747865, 0x73006572, 0x02000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x09000000, 0x73000000, 0x7865745f, 0x65727574, 0x78695000, 0x68536c65,
- 0x72656461, 0x0000a100, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000500,
- 0x00737000, 0x68636574, 0x00305000, 0x00000001, 0x00000002, 0x00000000, 0x00000001, 0x00000002,
- 0x00000000, 0x00000004, 0x00000010, 0x00000000, 0x00000002, 0xffffffff, 0x00000000, 0x0000002b,
- 0x0000000f, 0x0000002e, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000035, 0x0000000f,
- 0x00000038, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000066, 0x0000004a, 0x00000000,
- 0xffffffff, 0x00000000, 0x00000000, 0x00000097, 0x0000007b, 0x00000000, 0xffffffff, 0x00000000,
- 0x000000c9, 0x000000ad, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x000000cc, 0x00000001,
- 0x00000000, 0x000000d1, 0x00000003, 0x00000000, 0x00000007, 0x00000000, 0x00000002, 0x000000c9,
- 0x00000006, 0x00000000, 0x00000001, 0x000000d4, 0x00000008, 0x00000000, 0x00000001, 0x000000e0,
- 0x6e656c62, 0x61747364, 0x54006574, 0x75747865, 0x44326572, 0x00007300, 0x00000200, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000c00, 0x745f7300, 0x75747865, 0x50006572, 0x6c657869,
- 0x64616853, 0xa3007265, 0x02000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05000000,
- 0x70000000, 0x65740073, 0x50006863, 0x00010030, 0x00020000, 0x00000000, 0x00010000, 0x00020000,
- 0x00000000, 0x00040000, 0x00100000, 0x00000000, 0x00020000, 0xffff0000, 0x0000ffff, 0x002b0000,
- 0x000f0000, 0x002e0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00350000, 0x000f0000,
- 0x00380000, 0x00040000, 0x00000000, 0x00000000, 0x00000000, 0x00660000, 0x004a0000, 0x00000000,
- 0xffff0000, 0x0000ffff, 0x00000000, 0x00990000, 0x007d0000, 0x00000000, 0xffff0000, 0x0000ffff,
- 0x00cb0000, 0x00af0000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000, 0x00ce0000, 0x00010000,
- 0x00000000, 0x00d30000, 0x00030000, 0x00000000, 0x00070000, 0x00000000, 0x00020000, 0x00cb0000,
- 0x00060000, 0x00000000, 0x00010000, 0x00d60000, 0x00080000, 0x00000000, 0x00010000, 0x00e20000,
- 0x00000000,
};
/* Compiled as a child with /Gch (D3DCOMPILE_EFFECT_CHILD_EFFECT) */ @@ -6291,7 +6292,7 @@ cbuffer l_cb2 };
shared BlendState s_blendstate; -shared Texture s_texture; +shared Texture2D s_texture; shared PixelShader ps;
float4 VS( float4 pos : POSITION ) : SV_POSITION @@ -6299,6 +6300,13 @@ float4 VS( float4 pos : POSITION ) : SV_POSITION return f1.xxxx; }
+float4 PS( float4 pos : SV_POSITION ) : SV_Target +{
- return s_texture.Load(int3(0,0,0));
+}
+PixelShader vs = CompileShader(ps_4_0, PS());
Of course it doesn't matter but I'd rather not use "vs" for a pixel shader variable name...
On 9/30/21 10:03 PM, Matteo Bruni wrote:
BlendState s_blendstate; -Texture s_texture; +Texture2D s_texture; PixelShader ps;
I'm curious if that change made any difference.
It has to match "shared" type I think. And I believe I had to change from "Texture", to get Load() call to compile. I have to admit, I don't understand what non-specific "Texture" type implies exactly. Does it mean I can use any texture type for it?
+float4 PS( float4 pos : SV_POSITION ) : SV_Target +{
- return s_texture.Load(int3(0,0,0));
+}
+PixelShader vs = CompileShader(ps_4_0, PS()); Of course it doesn't matter but I'd rather not use "vs" for a pixel shader variable name...
Eh, of course.
On Thu, Sep 30, 2021 at 9:16 PM Nikolay Sivov nsivov@codeweavers.com wrote:
On 9/30/21 10:03 PM, Matteo Bruni wrote:
BlendState s_blendstate; -Texture s_texture; +Texture2D s_texture; PixelShader ps;
I'm curious if that change made any difference.
It has to match "shared" type I think. And I believe I had to change from "Texture", to get Load() call to compile. I have to admit, I don't understand what non-specific "Texture" type implies exactly. Does it mean I can use any texture type for it?
Probably? It's to be figured out. FWIW compiling the same shader without the Texture -> Texture2D change with fxc gives me
error X3087: texture object does not have methods
which means the generic Texture object can't be used as is. Maybe it can be if it's "specialized" (e.g. by redeclaring it as a specific texture type) in the parent shader or something?
+float4 PS( float4 pos : SV_POSITION ) : SV_Target +{
- return s_texture.Load(int3(0,0,0));
+}
+PixelShader vs = CompileShader(ps_4_0, PS());
Of course it doesn't matter but I'd rather not use "vs" for a pixel shader variable name...
Eh, of course.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 50 ++++++++++++++++++------------- dlls/d3d10/tests/effect.c | 62 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 20 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 70a99601eea..910b05990c1 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -3973,6 +3973,29 @@ static void update_buffer(ID3D10Device *device, struct d3d10_effect_variable *v) b->changed = FALSE; }
+static void set_sampler(ID3D10Device *device, D3D10_SHADER_VARIABLE_TYPE shader_type, + struct d3d10_effect_variable *v, unsigned int bind_point) +{ + switch (shader_type) + { + case D3D10_SVT_VERTEXSHADER: + ID3D10Device_VSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler); + break; + + case D3D10_SVT_PIXELSHADER: + ID3D10Device_PSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler); + break; + + case D3D10_SVT_GEOMETRYSHADER: + ID3D10Device_GSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler); + break; + + default: + WARN("Incorrect shader type to bind sampler.\n"); + break; + } +} + static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShaderVariable *variable) { struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(variable); @@ -3980,7 +4003,7 @@ static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShad struct d3d10_effect_shader_resource *sr; struct d3d10_effect_variable *rsrc_v; ID3D10ShaderResourceView **srv; - unsigned int i; + unsigned int i, j;
for (i = 0; i < sv->resource_count; ++i) { @@ -4045,27 +4068,14 @@ static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShad break;
case D3D10_SIT_SAMPLER: - switch (v->type->basetype) + if (!rsrc_v->type->element_count) { - case D3D10_SVT_VERTEXSHADER: - ID3D10Device_VSSetSamplers(device, sr->bind_point, sr->bind_count, - &rsrc_v->u.state.object.sampler); - break; - - case D3D10_SVT_PIXELSHADER: - ID3D10Device_PSSetSamplers(device, sr->bind_point, sr->bind_count, - &rsrc_v->u.state.object.sampler); - break; - - case D3D10_SVT_GEOMETRYSHADER: - ID3D10Device_GSSetSamplers(device, sr->bind_point, sr->bind_count, - &rsrc_v->u.state.object.sampler); - break; - - default: - WARN("Incorrect shader type to bind sampler.\n"); - break; + set_sampler(device, v->type->basetype, rsrc_v, sr->bind_point); + break; } + + for (j = 0; j < sr->bind_count; ++j) + set_sampler(device, v->type->basetype, &rsrc_v->elements[i], sr->bind_point + i); break;
default: diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 60be8186f8b..fbb93a986d6 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -5769,6 +5769,55 @@ static DWORD fx_test_resource_variable[] = 0x00070000, 0x02120000, 0x00070000, 0x00000000, 0x00070000, 0x057a0000, 0x00000000, };
+#if 0 +Texture2D t_a[2]; + +SamplerState s[2]; + +float4 PS( float4 pos : SV_POSITION ) : SV_Target +{ + return t_a[1].Sample(s[1], float2(0, 0)); +} + +technique10 rsrc_test +{ + pass p0 + { + SetPixelShader(CompileShader(ps_4_0, PS())); + } +} +#endif +static DWORD fx_test_resource_variable2[] = +{ + 0x43425844, 0x055f98c6, 0xcd0b04a0, 0xee35cd46, 0x0a70c2c4, 0x00000001, 0x0000035a, 0x00000001, + 0x00000024, 0x30315846, 0x0000032e, 0xfeff1001, 0x00000000, 0x00000000, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x0000028a, 0x00000000, 0x00000002, 0x00000000, 0x00000000, + 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x74786554, + 0x32657275, 0x00040044, 0x00020000, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x000c0000, + 0x5f740000, 0x61530061, 0x656c706d, 0x61745372, 0x2e006574, 0x02000000, 0x02000000, 0x00000000, + 0x00000000, 0x00000000, 0x15000000, 0x73000000, 0x72737200, 0x65745f63, 0x70007473, 0x02180030, + 0x58440000, 0x718f4342, 0xdf558dcf, 0xd9639eeb, 0x7d65d020, 0x0001bc1f, 0x02180000, 0x00050000, + 0x00340000, 0x00c80000, 0x00fc0000, 0x01300000, 0x019c0000, 0x44520000, 0x008c4645, 0x00000000, + 0x00000000, 0x00020000, 0x001c0000, 0x04000000, 0x0100ffff, 0x00620000, 0x005c0000, 0x00030000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00020000, 0x00000000, 0x005e0000, 0x00020000, + 0x00050000, 0x00040000, 0xffff0000, 0x0000ffff, 0x00020000, 0x000c0000, 0x00730000, 0x00615f74, + 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, + 0x31207265, 0x00312e30, 0x5349abab, 0x002c4e47, 0x00010000, 0x00080000, 0x00200000, 0x00000000, + 0x00010000, 0x00030000, 0x00000000, 0x000f0000, 0x56530000, 0x534f505f, 0x4f495449, 0x534f004e, + 0x002c4e47, 0x00010000, 0x00080000, 0x00200000, 0x00000000, 0x00000000, 0x00030000, 0x00000000, + 0x000f0000, 0x56530000, 0x7261545f, 0x00746567, 0x4853abab, 0x00645244, 0x00400000, 0x00190000, + 0x005a0000, 0x60000300, 0x00010010, 0x18580000, 0x70000400, 0x00010010, 0x55550000, 0x00650000, + 0x20f20300, 0x00000010, 0x00450000, 0x20f20c00, 0x00000010, 0x40020000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x7e460000, 0x00010010, 0x60000000, 0x00010010, 0x003e0000, 0x54530100, + 0x00745441, 0x00020000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000, + 0x00010000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00660000, 0x00000000, + 0x002a0000, 0x000e0000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00570000, 0x003b0000, 0x00000000, + 0xffff0000, 0x0000ffff, 0x00000000, 0x00000000, 0x00590000, 0x00010000, 0x00000000, 0x00630000, + 0x00010000, 0x00000000, 0x00070000, 0x00000000, 0x00070000, 0x02820000, 0x00000000, +}; + static void create_effect_texture_resource(ID3D10Device *device, ID3D10ShaderResourceView **srv, ID3D10Texture2D **tex) { @@ -5938,6 +5987,19 @@ static void test_effect_resource_variable(void)
effect->lpVtbl->Release(effect);
+ hr = create_effect(fx_test_resource_variable2, 0, device, NULL, &effect); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + technique = effect->lpVtbl->GetTechniqueByName(effect, "rsrc_test"); + ok(!!technique, "Got unexpected technique %p.\n", technique); + pass = technique->lpVtbl->GetPassByName(technique, "p0"); + ok(!!pass, "Got unexpected pass %p.\n", pass); + + hr = pass->lpVtbl->Apply(pass, 0); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + effect->lpVtbl->Release(effect); + refcount = ID3D10Device_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); }
On Tue, Sep 28, 2021 at 2:23 PM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/effect.c | 50 ++++++++++++++++++------------- dlls/d3d10/tests/effect.c | 62 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 20 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 70a99601eea..910b05990c1 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -3973,6 +3973,29 @@ static void update_buffer(ID3D10Device *device, struct d3d10_effect_variable *v) b->changed = FALSE; }
+static void set_sampler(ID3D10Device *device, D3D10_SHADER_VARIABLE_TYPE shader_type,
struct d3d10_effect_variable *v, unsigned int bind_point)
+{
- switch (shader_type)
- {
case D3D10_SVT_VERTEXSHADER:
ID3D10Device_VSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler);
break;
case D3D10_SVT_PIXELSHADER:
ID3D10Device_PSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler);
break;
case D3D10_SVT_GEOMETRYSHADER:
ID3D10Device_GSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler);
break;
default:
WARN("Incorrect shader type to bind sampler.\n");
break;
- }
+}
static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShaderVariable *variable) { struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(variable); @@ -3980,7 +4003,7 @@ static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShad struct d3d10_effect_shader_resource *sr; struct d3d10_effect_variable *rsrc_v; ID3D10ShaderResourceView **srv;
- unsigned int i;
unsigned int i, j;
for (i = 0; i < sv->resource_count; ++i) {
@@ -4045,27 +4068,14 @@ static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShad break;
case D3D10_SIT_SAMPLER:
switch (v->type->basetype)
if (!rsrc_v->type->element_count) {
case D3D10_SVT_VERTEXSHADER:
ID3D10Device_VSSetSamplers(device, sr->bind_point, sr->bind_count,
&rsrc_v->u.state.object.sampler);
break;
case D3D10_SVT_PIXELSHADER:
ID3D10Device_PSSetSamplers(device, sr->bind_point, sr->bind_count,
&rsrc_v->u.state.object.sampler);
break;
case D3D10_SVT_GEOMETRYSHADER:
ID3D10Device_GSSetSamplers(device, sr->bind_point, sr->bind_count,
&rsrc_v->u.state.object.sampler);
break;
default:
WARN("Incorrect shader type to bind sampler.\n");
break;
set_sampler(device, v->type->basetype, rsrc_v, sr->bind_point);
break; }
for (j = 0; j < sr->bind_count; ++j)
set_sampler(device, v->type->basetype, &rsrc_v->elements[i], sr->bind_point + i);
I think you wanted to use j rather than i in this set_sampler() call.
Which tells me we want to improve the test so that only the correct version succeeds, probably by checking the results of PSGetSamplers() and setting a non-0 explicit bind point.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/d3d10_private.h | 1 + dlls/d3d10/effect.c | 26 +++++++--- dlls/d3d10/tests/effect.c | 100 +++++++++++++++++++++++++------------ 3 files changed, 88 insertions(+), 39 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index e7ecfb73a64..38733862753 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -259,6 +259,7 @@ struct d3d10_effect_anonymous_shader enum d3d10_effect_flags { D3D10_EFFECT_OPTIMIZED = 0x1, + D3D10_EFFECT_IS_POOL = 0x2, };
/* ID3D10Effect */ diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 910b05990c1..3690dddf78b 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1405,6 +1405,9 @@ static HRESULT parse_fx10_variable_head(const char *data, size_t data_size,
v->explicit_bind_point = ~0u;
+ if (v->effect->flags & D3D10_EFFECT_IS_POOL) + v->flag |= D3D10_EFFECT_VARIABLE_POOLED; + return copy_variableinfo_from_type(v); }
@@ -1435,7 +1438,7 @@ static HRESULT parse_fx10_annotation(const char *data, size_t data_size, }
/* mark the variable as annotation */ - a->flag = D3D10_EFFECT_VARIABLE_ANNOTATION; + a->flag |= D3D10_EFFECT_VARIABLE_ANNOTATION;
return S_OK; } @@ -2083,7 +2086,7 @@ static HRESULT parse_fx10_technique(const char *data, size_t data_size, static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size, const char **ptr, BOOL local, struct d3d10_effect_variable *v) { - DWORD offset, default_value_offset; + DWORD offset, flags, default_value_offset; HRESULT hr;
if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, v))) @@ -2104,8 +2107,10 @@ static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size,
read_dword(ptr, &default_value_offset);
- read_dword(ptr, &v->flag); - TRACE("Variable flag: %#x.\n", v->flag); + read_dword(ptr, &flags); + TRACE("Variable flags: %#x.\n", flags); + + v->flag |= flags;
if (local) { @@ -2451,6 +2456,9 @@ static HRESULT parse_fx10_buffer(const char *data, size_t data_size, const char read_dword(ptr, &l->explicit_bind_point); TRACE("%s buffer explicit bind point: %#x.\n", prefix, l->explicit_bind_point);
+ if (l->effect->flags & D3D10_EFFECT_IS_POOL) + l->flag |= D3D10_EFFECT_VARIABLE_POOLED; + if (local) { read_dword(ptr, &l->annotation_count); @@ -8590,7 +8598,7 @@ static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry }
static HRESULT d3d10_create_effect(void *data, SIZE_T data_size, ID3D10Device *device, - ID3D10Effect *pool, const ID3D10EffectVtbl *vtbl, struct d3d10_effect **effect) + ID3D10Effect *pool, unsigned int flags, struct d3d10_effect **effect) { struct d3d10_effect *object; HRESULT hr; @@ -8599,12 +8607,14 @@ static HRESULT d3d10_create_effect(void *data, SIZE_T data_size, ID3D10Device *d return E_OUTOFMEMORY;
wine_rb_init(&object->types, d3d10_effect_type_compare); - object->ID3D10Effect_iface.lpVtbl = vtbl; + object->ID3D10Effect_iface.lpVtbl = flags & D3D10_EFFECT_IS_POOL ? + &d3d10_effect_pool_effect_vtbl : &d3d10_effect_vtbl; object->ID3D10EffectPool_iface.lpVtbl = &d3d10_effect_pool_vtbl; object->refcount = 1; ID3D10Device_AddRef(device); object->device = device; object->pool = pool; + object->flags = flags; if (pool) pool->lpVtbl->AddRef(pool);
hr = d3d10_effect_parse(object, data, data_size); @@ -8643,7 +8653,7 @@ HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT fl } }
- if (FAILED(hr = d3d10_create_effect(data, data_size, device, pool, &d3d10_effect_vtbl, &object))) + if (FAILED(hr = d3d10_create_effect(data, data_size, device, pool, 0, &object))) { WARN("Failed to create an effect, hr %#x.\n", hr); } @@ -8697,7 +8707,7 @@ HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UIN data, data_size, fx_flags, device, effect_pool);
if (FAILED(hr = d3d10_create_effect(data, data_size, device, NULL, - &d3d10_effect_pool_effect_vtbl, &object))) + D3D10_EFFECT_IS_POOL, &object))) { WARN("Failed to create an effect, hr %#x.\n", hr); return hr; diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index fbb93a986d6..3497d0cb248 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -1519,7 +1519,7 @@ static void test_effect_variable_type_class(void)
ok(strcmp(vd.Name, "s") == 0, "Name is "%s", expected "s"\n", vd.Name); ok(vd.Semantic == NULL, "Semantic is "%s", expected NULL\n", vd.Semantic); - ok(vd.Flags == 2, "Flags is %u, expected 2\n", vd.Flags); + ok(vd.Flags == D3D10_EFFECT_VARIABLE_ANNOTATION, "Unexpected flags %#x.\n", vd.Flags); ok(vd.Annotations == 0, "Annotations is %u, expected 0\n", vd.Annotations); ok(vd.BufferOffset == 0, "BufferOffset is %u, expected 0\n", vd.BufferOffset); ok(vd.ExplicitBindPoint == 0, "ExplicitBindPoint is %u, expected 0\n", vd.ExplicitBindPoint); @@ -6292,7 +6292,7 @@ static void test_effect_shader_object(void) }
#if 0 -cbuffer s_cb +cbuffer s_cb <String s = "value"; > { float f1 : COLOR0; float f2 : COLOR1; @@ -6302,6 +6302,11 @@ BlendState s_blendstate; Texture2D s_texture; PixelShader ps;
+float4 VS( float4 pos : POSITION ) : SV_POSITION +{ + return f1.xxxx; +} + technique10 tech { pass P0 @@ -6310,29 +6315,54 @@ technique10 tech SetVertexShader(NULL); SetGeometryShader(NULL); } + + pass P1 + { + SetVertexShader(CompileShader(vs_4_0, VS())); + } }; #endif static DWORD fx_test_pool[] = { - 0x43425844, 0x92a09896, 0xbc72ed33, 0x77194b8a, 0xb1132991, 0x00000001, 0x00000242, 0x00000001, - 0x00000024, 0x30315846, 0x00000216, 0xfeff1001, 0x00000001, 0x00000002, 0x00000003, 0x00000000, - 0x00000000, 0x00000000, 0x00000001, 0x000000ee, 0x00000000, 0x00000001, 0x00000000, 0x00000001, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x62635f73, - 0x6f6c6600, 0x09007461, 0x01000000, 0x00000000, 0x04000000, 0x10000000, 0x04000000, 0x09000000, - 0x66000009, 0x4f430031, 0x30524f4c, 0x00326600, 0x4f4c4f43, 0x42003152, 0x646e656c, 0x74617453, - 0x003f0065, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00020000, 0x5f730000, - 0x6e656c62, 0x61747364, 0x54006574, 0x75747865, 0x44326572, 0x00007300, 0x00000200, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000c00, 0x745f7300, 0x75747865, 0x50006572, 0x6c657869, - 0x64616853, 0xa3007265, 0x02000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05000000, - 0x70000000, 0x65740073, 0x50006863, 0x00010030, 0x00020000, 0x00000000, 0x00010000, 0x00020000, - 0x00000000, 0x00040000, 0x00100000, 0x00000000, 0x00020000, 0xffff0000, 0x0000ffff, 0x002b0000, - 0x000f0000, 0x002e0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00350000, 0x000f0000, - 0x00380000, 0x00040000, 0x00000000, 0x00000000, 0x00000000, 0x00660000, 0x004a0000, 0x00000000, - 0xffff0000, 0x0000ffff, 0x00000000, 0x00990000, 0x007d0000, 0x00000000, 0xffff0000, 0x0000ffff, - 0x00cb0000, 0x00af0000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000, 0x00ce0000, 0x00010000, - 0x00000000, 0x00d30000, 0x00030000, 0x00000000, 0x00070000, 0x00000000, 0x00020000, 0x00cb0000, - 0x00060000, 0x00000000, 0x00010000, 0x00d60000, 0x00080000, 0x00000000, 0x00010000, 0x00e20000, - 0x00000000, + 0x43425844, 0x5a29c5ce, 0xa6970df1, 0x3b2ae8f2, 0x7b225509, 0x00000001, 0x000004dc, 0x00000001, + 0x00000024, 0x30315846, 0x000004b0, 0xfeff1001, 0x00000001, 0x00000002, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000360, 0x00000000, 0x00000001, 0x00000000, 0x00000001, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000001, 0x00000000, 0x62635f73, + 0x72745300, 0x00676e69, 0x00000009, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x61760073, 0x0065756c, 0x616f6c66, 0x00340074, 0x00010000, 0x00000000, 0x00040000, + 0x00100000, 0x00040000, 0x09090000, 0x31660000, 0x4c4f4300, 0x0030524f, 0x43003266, 0x524f4c4f, + 0x6c420031, 0x53646e65, 0x65746174, 0x00006a00, 0x00000200, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000200, 0x625f7300, 0x646e656c, 0x74617473, 0x65540065, 0x72757478, 0x00443265, + 0x0000009e, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x65745f73, + 0x72757478, 0x69500065, 0x536c6578, 0x65646168, 0x00ce0072, 0x00020000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00050000, 0x73700000, 0x63657400, 0x30500068, 0x00000100, 0x00000200, + 0x00000000, 0x00000100, 0x00000200, 0x00000000, 0x00315000, 0x00000238, 0x43425844, 0x37b3f12d, + 0x2579b942, 0x27ed5925, 0x4a80132c, 0x00000001, 0x00000238, 0x00000005, 0x00000034, 0x00000108, + 0x0000013c, 0x00000170, 0x000001bc, 0x46454452, 0x000000cc, 0x00000001, 0x00000044, 0x00000001, + 0x0000001c, 0xfffe0400, 0x00000100, 0x000000a3, 0x0000003c, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x62635f73, 0xababab00, 0x0000003c, 0x00000002, + 0x0000005c, 0x00000010, 0x00000000, 0x00000000, 0x0000008c, 0x00000000, 0x00000004, 0x00000002, + 0x00000090, 0x00000000, 0x000000a0, 0x00000004, 0x00000004, 0x00000000, 0x00000090, 0x00000000, + 0xab003166, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x4d003266, 0x6f726369, 0x74666f73, + 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, + 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, + 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, + 0x5449534f, 0x004e4f49, 0x52444853, 0x00000044, 0x00010040, 0x00000011, 0x04000059, 0x00208e46, + 0x00000000, 0x00000001, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x06000036, 0x001020f2, + 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x00000002, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000011c, 0x00000000, 0x00000004, 0x00000010, + 0x00000000, 0x00000002, 0xffffffff, 0x00000001, 0x0000002c, 0x00000010, 0x0000002e, 0x00000056, + 0x0000003a, 0x00000059, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000060, 0x0000003a, + 0x00000063, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000091, 0x00000075, 0x00000000, + 0xffffffff, 0x00000000, 0x00000000, 0x000000c4, 0x000000a8, 0x00000000, 0xffffffff, 0x00000000, + 0x000000f6, 0x000000da, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x000000f9, 0x00000002, + 0x00000000, 0x000000fe, 0x00000003, 0x00000000, 0x00000007, 0x00000000, 0x00000002, 0x000000f6, + 0x00000006, 0x00000000, 0x00000001, 0x00000101, 0x00000008, 0x00000000, 0x00000001, 0x0000010d, + 0x00000119, 0x00000001, 0x00000000, 0x00000006, 0x00000000, 0x00000007, 0x00000358, };
/* Compiled as a child with /Gch (D3DCOMPILE_EFFECT_CHILD_EFFECT) */ @@ -6447,8 +6477,8 @@ static void test_effect_pool(void) ID3D10EffectPool *pool, *pool2; ID3D10EffectConstantBuffer *cb; ID3D10EffectShaderVariable *sv; + ID3D10EffectVariable *v, *a; ID3D10EffectTechnique *t; - ID3D10EffectVariable *v; ID3D10EffectPass *pass; D3D10_EFFECT_DESC desc; ID3D10Buffer *buffer; @@ -6526,28 +6556,41 @@ todo_wine hr = cb->lpVtbl->GetDesc(cb, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_cb"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + a = cb->lpVtbl->GetAnnotationByIndex(cb, 0); + ok(a->lpVtbl->IsValid(a), "Expected valid annotation.\n"); + hr = a->lpVtbl->GetDesc(a, &var_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!strcmp(var_desc.Name, "s"), "Unexpected name %s.\n", var_desc.Name); + ok(var_desc.Flags == (D3D10_EFFECT_VARIABLE_POOLED | D3D10_EFFECT_VARIABLE_ANNOTATION), + "Unexpected flags %#x.\n", var_desc.Flags); + + t = effect->lpVtbl->GetTechniqueByIndex(effect, 0); + pass = t->lpVtbl->GetPassByName(t, "P1"); + ok(pass->lpVtbl->IsValid(pass), "Expected valid pass.\n"); + hr = pass->lpVtbl->GetVertexShaderDesc(pass, &shader_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = shader_desc.pShaderVariable->lpVtbl->GetDesc(shader_desc.pShaderVariable, &var_desc); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!strcmp(var_desc.Name, "$Anonymous"), "Unexpected name %s.\n", var_desc.Name); + ok(!var_desc.Flags, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "s_blendstate"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_blendstate"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "s_texture"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_texture"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "ps"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "ps"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
t = effect->lpVtbl->GetTechniqueByIndex(effect, 0); @@ -6687,7 +6730,6 @@ todo_wine hr = cb->lpVtbl->GetDesc(cb, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_cb"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
/* Pool techniques are not accessible */ @@ -6720,21 +6762,18 @@ todo_wine hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "f1"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = child_effect->lpVtbl->GetVariableByIndex(child_effect, 4); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "f2"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = child_effect->lpVtbl->GetVariableByName(child_effect, "s_texture"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_texture"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = child_effect->lpVtbl->GetVariableBySemantic(child_effect, "COLOR0"); @@ -6747,7 +6786,6 @@ todo_wine hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "f2"), "Unexpected name %s.\n", var_desc.Name); -todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
child_effect->lpVtbl->Release(child_effect);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/d3d10_private.h | 1 - 1 file changed, 1 deletion(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index 38733862753..648a7b0240a 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -223,7 +223,6 @@ struct d3d10_effect_pass
struct d3d10_effect_technique *technique; char *name; - DWORD start; DWORD object_count; DWORD annotation_count; struct d3d10_effect_object *objects;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/d3d10_private.h | 2 ++ dlls/d3d10/effect.c | 40 ++++---------------------------------- 2 files changed, 6 insertions(+), 36 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index 648a7b0240a..f980007427f 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -83,6 +83,7 @@ struct d3d10_effect_object ID3D10VertexShader *vs; ID3D10PixelShader *ps; ID3D10GeometryShader *gs; + IUnknown *object; } object; };
@@ -136,6 +137,7 @@ struct d3d10_effect_state_object_variable ID3D10DepthStencilState *depth_stencil; ID3D10BlendState *blend; ID3D10SamplerState *sampler; + IUnknown *object; } object; };
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 3690dddf78b..27d482b1fef 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -3017,23 +3017,11 @@ static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v) break;
case D3D10_SVT_DEPTHSTENCIL: - if (v->u.state.object.depth_stencil) - ID3D10DepthStencilState_Release(v->u.state.object.depth_stencil); - break; - case D3D10_SVT_BLEND: - if (v->u.state.object.blend) - ID3D10BlendState_Release(v->u.state.object.blend); - break; - case D3D10_SVT_RASTERIZER: - if (v->u.state.object.rasterizer) - ID3D10RasterizerState_Release(v->u.state.object.rasterizer); - break; - case D3D10_SVT_SAMPLER: - if (v->u.state.object.sampler) - ID3D10SamplerState_Release(v->u.state.object.sampler); + if (v->u.state.object.object) + IUnknown_Release(v->u.state.object.object); break;
case D3D10_SVT_TEXTURE1D: @@ -3076,33 +3064,13 @@ static void d3d10_effect_object_destroy(struct d3d10_effect_object *o) switch (o->type) { case D3D10_EOT_RASTERIZER_STATE: - if (o->object.rs) - ID3D10RasterizerState_Release(o->object.rs); - break; - case D3D10_EOT_DEPTH_STENCIL_STATE: - if (o->object.ds) - ID3D10DepthStencilState_Release(o->object.ds); - break; - case D3D10_EOT_BLEND_STATE: - if (o->object.bs) - ID3D10BlendState_Release(o->object.bs); - break; - case D3D10_EOT_VERTEXSHADER: - if (o->object.vs) - ID3D10VertexShader_Release(o->object.vs); - break; - case D3D10_EOT_PIXELSHADER: - if (o->object.ps) - ID3D10PixelShader_Release(o->object.ps); - break; - case D3D10_EOT_GEOMETRYSHADER: - if (o->object.gs) - ID3D10GeometryShader_Release(o->object.gs); + if (o->object.object) + IUnknown_Release(o->object.object); break;
default:
On Tue, Sep 28, 2021 at 2:23 PM Nikolay Sivov nsivov@codeweavers.com wrote:
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;
+}
I wonder if it would be nicer to just loop through the pool effect's buffers instead, or at least call d3d10_effect_get_buffer_by_name() directly.
On 9/30/21 10:03 PM, Matteo Bruni wrote:
On Tue, Sep 28, 2021 at 2:23 PM Nikolay Sivov nsivov@codeweavers.com wrote:
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;
+}
I wonder if it would be nicer to just loop through the pool effect's buffers instead, or at least call d3d10_effect_get_buffer_by_name() directly.
Yes, I have no problems with that. Making sure, do you mean storing "struct d3d10_effect*" for pool, instead of an interface pointer?
On Thu, Sep 30, 2021 at 9:11 PM Nikolay Sivov nsivov@codeweavers.com wrote:
On 9/30/21 10:03 PM, Matteo Bruni wrote:
On Tue, Sep 28, 2021 at 2:23 PM Nikolay Sivov nsivov@codeweavers.com wrote:
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;
+}
I wonder if it would be nicer to just loop through the pool effect's buffers instead, or at least call d3d10_effect_get_buffer_by_name() directly.
Yes, I have no problems with that. Making sure, do you mean storing "struct d3d10_effect*" for pool, instead of an interface pointer?
Probably, if it doesn't make other stuff more complicated (it shouldn't). I guess you could check that native doesn't support "custom" pools either, just to be sure that we won't ever need to go back on this.
On 9/30/21 10:18 PM, Matteo Bruni wrote:
On Thu, Sep 30, 2021 at 9:11 PM Nikolay Sivov nsivov@codeweavers.com wrote:
On 9/30/21 10:03 PM, Matteo Bruni wrote:
On Tue, Sep 28, 2021 at 2:23 PM Nikolay Sivov nsivov@codeweavers.com wrote:
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;
+}
I wonder if it would be nicer to just loop through the pool effect's buffers instead, or at least call d3d10_effect_get_buffer_by_name() directly.
Yes, I have no problems with that. Making sure, do you mean storing "struct d3d10_effect*" for pool, instead of an interface pointer?
Probably, if it doesn't make other stuff more complicated (it shouldn't). I guess you could check that native doesn't support "custom" pools either, just to be sure that we won't ever need to go back on this.
I could try testing that, but that can only get so far, because internal assumptions could be tricky to observe. For example, when you reference a buffer from a child effect, and update it, there is not API way to trigger d3d buffer update. Now that might go a "proper" way via some internal interface, but given that even QueryInterface is not really working, I'd be surprised they made such extra effort. Probably easiest way is to try custom pool interface, and see if any methods are called at all, expect for addref. If nothing gets called from top level object, that obviously means such change will be safe.
On Thu, Sep 30, 2021 at 9:26 PM Nikolay Sivov nsivov@codeweavers.com wrote:
On 9/30/21 10:18 PM, Matteo Bruni wrote:
On Thu, Sep 30, 2021 at 9:11 PM Nikolay Sivov nsivov@codeweavers.com wrote:
On 9/30/21 10:03 PM, Matteo Bruni wrote:
On Tue, Sep 28, 2021 at 2:23 PM Nikolay Sivov nsivov@codeweavers.com wrote:
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;
+}
I wonder if it would be nicer to just loop through the pool effect's buffers instead, or at least call d3d10_effect_get_buffer_by_name() directly.
Yes, I have no problems with that. Making sure, do you mean storing "struct d3d10_effect*" for pool, instead of an interface pointer?
Probably, if it doesn't make other stuff more complicated (it shouldn't). I guess you could check that native doesn't support "custom" pools either, just to be sure that we won't ever need to go back on this.
I could try testing that, but that can only get so far, because internal assumptions could be tricky to observe. For example, when you reference a buffer from a child effect, and update it, there is not API way to trigger d3d buffer update. Now that might go a "proper" way via some internal interface, but given that even QueryInterface is not really working, I'd be surprised they made such extra effort. Probably easiest way is to try custom pool interface, and see if any methods are called at all, expect for addref. If nothing gets called from top level object, that obviously means such change will be safe.
Yeah, I was thinking of something along those lines.