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); }