diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 89b7598ad46..5bbde06c6b4 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -2092,6 +2092,299 @@ static void test_effect_variable_type_class(ID3D10Device *device) effect->lpVtbl->Release(effect); } +/* + * test_effect_constant_buffer_stride + */ +#if 0 +cbuffer cb1 +{ + float a1; + float b1; + float c1; + float d1; +}; +cbuffer cb2 +{ + float a2; + float2 b2; +}; +cbuffer cb3 +{ + float2 a3; + float3 b3; +}; +cbuffer cb4 +{ + float2 a4; + float3 b4; + float2 c4; +}; +cbuffer cb5 +{ + float2 a5; + float2 b5; + float3 c5; +}; +cbuffer cb6 +{ + float2 a6 : packoffset(c0); + float3 b6 : packoffset(c1); + float2 c6 : packoffset(c0.z); +}; +cbuffer cb7 +{ + float2 a7 : packoffset(c0); + float3 b7 : packoffset(c1); + float2 c7 : packoffset(c2); +}; +cbuffer cb8 +{ + float2 a8 : packoffset(c0); + float3 b8 : packoffset(c0.y); + float4 c8 : packoffset(c2); +}; +cbuffer cb9 +{ + float2 a9 : packoffset(c0); + float2 b9 : packoffset(c0.y); + float2 c9 : packoffset(c0.z); +}; +cbuffer cb10 +{ + float4 a10 : packoffset(c2); +}; +cbuffer cb11 +{ + struct { + float4 a11; + float b11; + } s11; + float c11; +}; +cbuffer cb12 +{ + float c12; + struct { + float b12; + float4 a12; + } s12; +}; +cbuffer cb13 +{ + float a13; + struct { + float b13; + } s13; +}; +cbuffer cb14 +{ + struct { + float a14; + } s14; + struct { + float b14; + } t14; +}; +cbuffer cb15 +{ + float2 a15[2] : packoffset(c0); +}; +#endif +static DWORD fx_test_ecbs[] = { +0x43425844, 0x615d7d77, 0x21289d92, 0xe9e8d98e, +0xcae7b74e, 0x00000001, 0x00000855, 0x00000001, +0x00000024, 0x30315846, 0x00000829, 0xfeff1001, +0x0000000f, 0x00000024, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000285, +0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00316263, +0x616f6c66, 0x00080074, 0x00010000, 0x00000000, +0x00040000, 0x00100000, 0x00040000, 0x09090000, +0x31610000, 0x00316200, 0x64003163, 0x62630031, +0x32610032, 0x6f6c6600, 0x00327461, 0x0000003d, +0x00000001, 0x00000000, 0x00000008, 0x00000010, +0x00000008, 0x0000110a, 0x63003262, 0x61003362, +0x6c660033, 0x3374616f, 0x00006a00, 0x00000100, +0x00000000, 0x00000c00, 0x00001000, 0x00000c00, +0x00190a00, 0x00336200, 0x00346263, 0x62003461, +0x34630034, 0x35626300, 0x00356100, 0x63003562, +0x62630035, 0x36610036, 0x00366200, 0x63003663, +0x61003762, 0x37620037, 0x00376300, 0x00386263, +0x62003861, 0x6c660038, 0x3474616f, 0x0000ce00, +0x00000100, 0x00000000, 0x00001000, 0x00001000, +0x00001000, 0x00210a00, 0x00386300, 0x00396263, +0x62003961, 0x39630039, 0x31626300, 0x31610030, +0x62630030, 0x3c003131, 0x616e6e75, 0x3e64656d, +0x31316100, 0x31316200, 0x00010f00, 0x00000300, +0x00000000, 0x00001400, 0x00002000, 0x00001400, +0x00000200, 0x00011900, 0x00000000, 0x00000000, +0x0000d500, 0x00011d00, 0x00000000, 0x00001000, +0x00000e00, 0x31317300, 0x31316300, 0x31626300, +0x31630032, 0x31620032, 0x31610032, 0x010f0032, +0x00030000, 0x00000000, 0x00200000, 0x00200000, +0x00140000, 0x00020000, 0x016e0000, 0x00000000, +0x00000000, 0x000e0000, 0x01720000, 0x00000000, +0x00100000, 0x00d50000, 0x31730000, 0x62630032, +0x61003331, 0x62003331, 0x0f003331, 0x03000001, +0x00000000, 0x04000000, 0x10000000, 0x04000000, +0x01000000, 0xbf000000, 0x00000001, 0x00000000, +0x0e000000, 0x73000000, 0x63003331, 0x00343162, +0x00343161, 0x0000010f, 0x00000003, 0x00000000, +0x00000004, 0x00000010, 0x00000004, 0x00000001, +0x000001f8, 0x00000000, 0x00000000, 0x0000000e, +0x00343173, 0x00343162, 0x0000010f, 0x00000003, +0x00000000, 0x00000004, 0x00000010, 0x00000004, +0x00000001, 0x0000022c, 0x00000000, 0x00000000, +0x0000000e, 0x00343174, 0x35316263, 0x00003d00, +0x00000100, 0x00000200, 0x00001800, 0x00001000, +0x00001000, 0x00110a00, 0x35316100, 0x00000400, +0x00001000, 0x00000000, 0x00000400, 0xffffff00, +0x000000ff, 0x00002a00, 0x00000e00, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00002d00, 0x00000e00, 0x00000000, 0x00000400, +0x00000000, 0x00000000, 0x00000000, 0x00003000, +0x00000e00, 0x00000000, 0x00000800, 0x00000000, +0x00000000, 0x00000000, 0x00003300, 0x00000e00, +0x00000000, 0x00000c00, 0x00000000, 0x00000000, +0x00000000, 0x00003600, 0x00001000, 0x00000000, +0x00000200, 0xffffff00, 0x000000ff, 0x00003a00, +0x00000e00, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00006000, 0x00004400, +0x00000000, 0x00000400, 0x00000000, 0x00000000, +0x00000000, 0x00006300, 0x00002000, 0x00000000, +0x00000200, 0xffffff00, 0x000000ff, 0x00006700, +0x00004400, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00008d00, 0x00007100, +0x00000000, 0x00001000, 0x00000000, 0x00000000, +0x00000000, 0x00009000, 0x00003000, 0x00000000, +0x00000300, 0xffffff00, 0x000000ff, 0x00009400, +0x00004400, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00009700, 0x00007100, +0x00000000, 0x00001000, 0x00000000, 0x00000000, +0x00000000, 0x00009a00, 0x00004400, 0x00000000, +0x00002000, 0x00000000, 0x00000000, 0x00000000, +0x00009d00, 0x00002000, 0x00000000, 0x00000300, +0xffffff00, 0x000000ff, 0x0000a100, 0x00004400, +0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x0000a400, 0x00004400, 0x00000000, +0x00000800, 0x00000000, 0x00000000, 0x00000000, +0x0000a700, 0x00007100, 0x00000000, 0x00001000, +0x00000000, 0x00000000, 0x00000000, 0x0000aa00, +0x00002000, 0x00000000, 0x00000300, 0xffffff00, +0x000000ff, 0x0000ae00, 0x00004400, 0x00000000, +0x00000000, 0x00000000, 0x00000400, 0x00000000, +0x0000b100, 0x00007100, 0x00000000, 0x00001000, +0x00000000, 0x00000400, 0x00000000, 0x0000b400, +0x00004400, 0x00000000, 0x00000800, 0x00000000, +0x00000400, 0x00000000, 0x0000b700, 0x00003000, +0x00000000, 0x00000300, 0xffffff00, 0x000000ff, +0x0000bb00, 0x00004400, 0x00000000, 0x00000000, +0x00000000, 0x00000400, 0x00000000, 0x0000be00, +0x00007100, 0x00000000, 0x00001000, 0x00000000, +0x00000400, 0x00000000, 0x0000c100, 0x00004400, +0x00000000, 0x00002000, 0x00000000, 0x00000400, +0x00000000, 0x0000c400, 0x00003000, 0x00000000, +0x00000300, 0xffffff00, 0x000000ff, 0x0000c800, +0x00004400, 0x00000000, 0x00000000, 0x00000000, +0x00000400, 0x00000000, 0x0000cb00, 0x00007100, +0x00000000, 0x00000400, 0x00000000, 0x00000400, +0x00000000, 0x0000f100, 0x0000d500, 0x00000000, +0x00002000, 0x00000000, 0x00000400, 0x00000000, +0x0000f400, 0x00001000, 0x00000000, 0x00000300, +0xffffff00, 0x000000ff, 0x0000f800, 0x00004400, +0x00000000, 0x00000000, 0x00000000, 0x00000400, +0x00000000, 0x0000fb00, 0x00004400, 0x00000000, +0x00000400, 0x00000000, 0x00000400, 0x00000000, +0x0000fe00, 0x00004400, 0x00000000, 0x00000800, +0x00000000, 0x00000400, 0x00000000, 0x00010100, +0x00003000, 0x00000000, 0x00000100, 0xffffff00, +0x000000ff, 0x00010600, 0x0000d500, 0x00000000, +0x00002000, 0x00000000, 0x00000400, 0x00000000, +0x00010a00, 0x00002000, 0x00000000, 0x00000200, +0xffffff00, 0x000000ff, 0x00015d00, 0x00012100, +0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00016100, 0x00000e00, 0x00000000, +0x00001400, 0x00000000, 0x00000000, 0x00000000, +0x00016500, 0x00003000, 0x00000000, 0x00000200, +0xffffff00, 0x000000ff, 0x00016a00, 0x00000e00, +0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x0001b200, 0x00017600, 0x00000000, +0x00001000, 0x00000000, 0x00000000, 0x00000000, +0x0001b600, 0x00002000, 0x00000000, 0x00000200, +0xffffff00, 0x000000ff, 0x0001bb00, 0x00000e00, +0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x0001ef00, 0x0001c300, 0x00000000, +0x00001000, 0x00000000, 0x00000000, 0x00000000, +0x0001f300, 0x00002000, 0x00000000, 0x00000200, +0xffffff00, 0x000000ff, 0x00022800, 0x0001fc00, +0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00025c00, 0x00023000, 0x00000000, +0x00001000, 0x00000000, 0x00000000, 0x00000000, +0x00026000, 0x00002000, 0x00000000, 0x00000100, +0xffffff00, 0x000000ff, 0x00028100, 0x00026500, +0x00000000, 0x00000000, 0x00000000, 0x00000400, +0x00000000, 0x00000000, +}; + +static void test_effect_constant_buffer_stride(ID3D10Device *device) +{ + ID3D10Effect *effect; + ID3D10EffectConstantBuffer *constantbuffer; + ID3D10EffectType *type; + D3D10_EFFECT_TYPE_DESC tdesc; + HRESULT hr; + unsigned int i; + + static const struct { + unsigned int m; /* members */ + unsigned int p; /* packed size */ + unsigned int u; /* unpacked size */ + unsigned int s; /* stride */ + } tv_ecbs[] = { + {4, 0x10, 0x10, 0x10}, + {2, 0xc, 0x10, 0x10}, + {2, 0x14, 0x20, 0x20}, + {3, 0x1c, 0x30, 0x30}, + {3, 0x1c, 0x20, 0x20}, + {3, 0x1c, 0x20, 0x20}, + {3, 0x1c, 0x30, 0x30}, + {3, 0x24, 0x30, 0x30}, + {3, 0x18, 0x10, 0x10}, + {1, 0x10, 0x30, 0x30}, + {2, 0x18, 0x20, 0x20}, + {2, 0x18, 0x30, 0x30}, + {2, 0x8, 0x20, 0x20}, + {2, 0x8, 0x20, 0x20}, + {1, 0x10, 0x20, 0x20}, + }; + + hr = D3D10CreateEffectFromMemory(fx_test_ecbs, fx_test_ecbs[6], 0, device, NULL, &effect); + ok(SUCCEEDED(hr), "D3D10CreateEffectFromMemory failed (%x)\n", hr); + + for (i=0; ilpVtbl->GetConstantBufferByIndex(effect, i); + type = constantbuffer->lpVtbl->GetType(constantbuffer); + + hr = type->lpVtbl->GetDesc(type, &tdesc); + ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); + + ok(strcmp(tdesc.TypeName, "cbuffer") == 0, "TypeName is \"%s\", expected \"cbuffer\"\n", tdesc.TypeName); + ok(tdesc.Class == D3D10_SVC_OBJECT, "Class is %x, expected %x\n", tdesc.Class, D3D10_SVC_OBJECT); + ok(tdesc.Type == D3D10_SVT_CBUFFER, "Type is %x, expected %x\n", tdesc.Type, D3D10_SVT_CBUFFER); + ok(tdesc.Elements == 0, "Elements is %u, expected 0\n", tdesc.Elements); + ok(tdesc.Members == tv_ecbs[i].m, "Members is %u, expected %u\n", tdesc.Members, tv_ecbs[i].m); + ok(tdesc.Rows == 0, "Rows is %u, expected 0\n", tdesc.Rows); + ok(tdesc.Columns == 0, "Columns is %u, expected 0\n", tdesc.Columns); + ok(tdesc.PackedSize == tv_ecbs[i].p, "PackedSize is %#x, expected %#x\n", tdesc.PackedSize, tv_ecbs[i].p); + ok(tdesc.UnpackedSize == tv_ecbs[i].u, "UnpackedSize is %#x, expected %#x\n", tdesc.UnpackedSize, tv_ecbs[i].u); + ok(tdesc.Stride == tv_ecbs[i].s, "Stride is %#x, expected %#x\n", tdesc.Stride, tv_ecbs[i].s); + } + + effect->lpVtbl->Release(effect); +} + START_TEST(effect) { ID3D10Device *device; @@ -2109,6 +2402,7 @@ START_TEST(effect) test_effect_variable_member(device); test_effect_variable_element(device); test_effect_variable_type_class(device); + test_effect_constant_buffer_stride(device); refcount = ID3D10Device_Release(device); ok(!refcount, "Device has %u references left\n", refcount);