From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v3 (Matteo): minor clean up
dlls/d3d10/effect.c | 22 ++++- dlls/d3d10/tests/effect.c | 182 ++++++++++++++++---------------------- 2 files changed, 97 insertions(+), 107 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 86ef50aac01..e121ad9cac2 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1330,12 +1330,28 @@ static HRESULT parse_fx10_variable_head(const char *data, size_t data_size, static HRESULT parse_fx10_annotation(const char *data, size_t data_size, const char **ptr, struct d3d10_effect_variable *a) { + DWORD offset; HRESULT hr;
if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, a))) return hr;
- skip_dword_unknown("annotation", ptr, 1); + read_dword(ptr, &offset); + TRACE("Annotation value is at offset %#x.\n", offset); + + switch (a->type->basetype) + { + case D3D10_SVT_STRING: + if (!fx10_copy_string(data, data_size, offset, (char **)&a->u.buffer.local_buffer)) + { + ERR("Failed to copy name.\n"); + return E_OUTOFMEMORY; + } + break; + + default: + FIXME("Unhandled object type %#x.\n", a->type->basetype); + }
/* mark the variable as annotation */ a->flag = D3D10_EFFECT_VARIABLE_ANNOTATION; @@ -2826,6 +2842,10 @@ static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v) heap_free(v->u.resource.srv); break;
+ case D3D10_SVT_STRING: + heap_free(v->u.buffer.local_buffer); + break; + default: break; } diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index fc0b8180b97..18560705049 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -1161,7 +1161,7 @@ static void test_effect_variable_element(void) * test_effect_variable_type_class */ #if 0 -cbuffer cb <String s = "STRING";> +cbuffer cb <String s = "STRING"; String s2 = "STRING"; > { float f; vector <int, 2> i; @@ -1186,109 +1186,60 @@ GeometryShader gs[2]; PixelShader ps; VertexShader vs[1]; #endif -static DWORD fx_test_evtc[] = { -0x43425844, 0xc04c50cb, 0x0afeb4ef, 0xbb93f346, -0x97a29499, 0x00000001, 0x00000659, 0x00000001, -0x00000024, 0x30315846, 0x0000062d, 0xfeff1001, -0x00000001, 0x00000004, 0x00000011, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x000003d9, -0x00000000, 0x00000008, 0x00000001, 0x00000001, -0x00000001, 0x00000001, 0x00000001, 0x00000001, -0x00000004, 0x00000000, 0x00000000, 0x53006263, -0x6e697274, 0x00070067, 0x00020000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00010000, -0x00730000, 0x49525453, 0x6600474e, 0x74616f6c, -0x00003300, 0x00000100, 0x00000000, 0x00000400, -0x00001000, 0x00000400, 0x00090900, 0x69006600, -0x0032746e, 0x00000057, 0x00000001, 0x00000000, -0x00000008, 0x00000010, 0x00000008, 0x00001112, -0x69750069, 0x7832746e, 0x007a0033, 0x00010000, -0x00000000, 0x00280000, 0x00300000, 0x00180000, -0x5a1b0000, 0x00750000, 0x6c6f6f62, 0x00337832, -0x000000a0, 0x00000001, 0x00000000, 0x0000001c, -0x00000020, 0x00000018, 0x00001a23, 0x6c420062, -0x53646e65, 0x65746174, 0x0000c600, 0x00000200, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000200, 0x656c6200, 0x4400646e, 0x68747065, -0x6e657453, 0x536c6963, 0x65746174, 0x0000f300, -0x00000200, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000300, 0x70656400, 0x74736874, -0x69636e65, 0x6152006c, 0x72657473, 0x72657a69, -0x74617453, 0x012e0065, 0x00020000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00040000, -0x61720000, 0x53007473, 0x6c706d61, 0x74537265, -0x00657461, 0x0000015f, 0x00000002, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000015, -0x006d6173, 0x646e6552, 0x61547265, 0x74656772, -0x77656956, 0x00018c00, 0x00000200, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00001300, -0x76747200, 0x70654400, 0x74536874, 0x69636e65, -0x6569566c, 0x01bd0077, 0x00020000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00140000, -0x73640000, 0x65540076, 0x72757478, 0x00443165, -0x000001ee, 0x00000002, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x0000000a, 0x54003174, -0x75747865, 0x44316572, 0x61727241, 0x02170079, -0x00020000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x000b0000, 0x31740000, 0x65540061, -0x72757478, 0x00443265, 0x00000246, 0x00000002, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x0000000c, 0x54003274, 0x75747865, 0x44326572, -0x6f00534d, 0x02000002, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x0e000000, 0x74000000, -0x736d6432, 0x78655400, 0x65727574, 0x72414432, -0x00796172, 0x0000029d, 0x00000002, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x0000000d, -0x00613274, 0x74786554, 0x32657275, 0x41534d44, -0x79617272, 0x0002cc00, 0x00000200, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000f00, -0x64327400, 0x0061736d, 0x74786554, 0x33657275, -0x03000044, 0x00020000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00100000, 0x33740000, -0x78655400, 0x65727574, 0x65627543, 0x00032900, -0x00000200, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00001100, 0x00717400, 0x6d6f6547, -0x79727465, 0x64616853, 0x54007265, 0x02000003, -0x02000000, 0x00000000, 0x00000000, 0x00000000, -0x07000000, 0x67000000, 0x69500073, 0x536c6578, -0x65646168, 0x03820072, 0x00020000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00050000, -0x73700000, 0x72655600, 0x53786574, 0x65646168, -0x03ad0072, 0x00020000, 0x00010000, 0x00000000, -0x00000000, 0x00000000, 0x00060000, 0x73760000, -0x00000400, 0x00006000, 0x00000000, 0x00000400, -0xffffff00, 0x000001ff, 0x00002a00, 0x00000e00, -0x00002c00, 0x00005500, 0x00003900, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00007800, 0x00005c00, 0x00000000, 0x00000400, -0x00000000, 0x00000000, 0x00000000, 0x00009e00, -0x00008200, 0x00000000, 0x00001000, 0x00000000, -0x00000000, 0x00000000, 0x0000c400, 0x0000a800, -0x00000000, 0x00004000, 0x00000000, 0x00000000, -0x00000000, 0x0000ed00, 0x0000d100, 0x00000000, -0xffffff00, 0x000000ff, 0x00000000, 0x00012100, -0x00010500, 0x00000000, 0xffffff00, 0x000000ff, -0x00000000, 0x00015a00, 0x00013e00, 0x00000000, -0xffffff00, 0x000000ff, 0x00000000, 0x00018800, -0x00016c00, 0x00000000, 0xffffff00, 0x000000ff, -0x00000000, 0x0001b900, 0x00019d00, 0x00000000, -0xffffff00, 0x000000ff, 0x0001ea00, 0x0001ce00, -0x00000000, 0xffffff00, 0x000000ff, 0x00021400, -0x0001f800, 0x00000000, 0xffffff00, 0x000000ff, -0x00024200, 0x00022600, 0x00000000, 0xffffff00, -0x000000ff, 0x00026c00, 0x00025000, 0x00000000, -0xffffff00, 0x000000ff, 0x00029700, 0x00027b00, -0x00000000, 0xffffff00, 0x000000ff, 0x0002c800, -0x0002ac00, 0x00000000, 0xffffff00, 0x000000ff, -0x0002f900, 0x0002dd00, 0x00000000, 0xffffff00, -0x000000ff, 0x00032600, 0x00030a00, 0x00000000, -0xffffff00, 0x000000ff, 0x00035100, 0x00033500, -0x00000000, 0xffffff00, 0x000000ff, 0x00037f00, -0x00036300, 0x00000000, 0xffffff00, 0x000000ff, -0x00000000, 0x00000000, 0x0003aa00, 0x00038e00, -0x00000000, 0xffffff00, 0x000000ff, 0x00000000, -0x0003d600, 0x0003ba00, 0x00000000, 0xffffff00, -0x000000ff, 0x00000000, 0x00000000, +static DWORD fx_test_evtc[] = +{ +0x43425844, 0x16ff7a62, 0x6eb690dc, 0x60dd5ba4, 0x903b0ce7, 0x00000001, 0x00000668, 0x00000001, +0x00000024, 0x30315846, 0x0000063c, 0xfeff1001, 0x00000001, 0x00000004, 0x00000011, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x000003dc, 0x00000000, 0x00000008, 0x00000001, 0x00000001, +0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000004, 0x00000000, 0x00000000, 0x53006263, +0x6e697274, 0x00070067, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, +0x00730000, 0x49525453, 0x7300474e, 0x6c660032, 0x0074616f, 0x00000036, 0x00000001, 0x00000000, +0x00000004, 0x00000010, 0x00000004, 0x00000909, 0x6e690066, 0x5a003274, 0x01000000, 0x00000000, +0x08000000, 0x10000000, 0x08000000, 0x12000000, 0x69000011, 0x6e697500, 0x33783274, 0x00007d00, +0x00000100, 0x00000000, 0x00002800, 0x00003000, 0x00001800, 0x005a1b00, 0x62007500, 0x326c6f6f, +0xa3003378, 0x01000000, 0x00000000, 0x1c000000, 0x20000000, 0x18000000, 0x23000000, 0x6200001a, +0x656c4200, 0x7453646e, 0x00657461, 0x000000c9, 0x00000002, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000002, 0x6e656c62, 0x65440064, 0x53687470, 0x636e6574, 0x74536c69, 0x00657461, +0x000000f6, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x74706564, +0x65747368, 0x6c69636e, 0x73615200, 0x69726574, 0x5372657a, 0x65746174, 0x00013100, 0x00000200, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000400, 0x73617200, 0x61530074, 0x656c706d, +0x61745372, 0x62006574, 0x02000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x15000000, +0x73000000, 0x52006d61, 0x65646e65, 0x72615472, 0x56746567, 0x00776569, 0x0000018f, 0x00000002, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000013, 0x00767472, 0x74706544, 0x65745368, +0x6c69636e, 0x77656956, 0x0001c000, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00001400, 0x76736400, 0x78655400, 0x65727574, 0xf1004431, 0x02000001, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x0a000000, 0x74000000, 0x65540031, 0x72757478, 0x41443165, 0x79617272, +0x00021a00, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000b00, 0x61317400, +0x78655400, 0x65727574, 0x49004432, 0x02000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x0c000000, 0x74000000, 0x65540032, 0x72757478, 0x4d443265, 0x02720053, 0x00020000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x000e0000, 0x32740000, 0x00736d64, 0x74786554, 0x32657275, +0x72724144, 0xa0007961, 0x02000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0d000000, +0x74000000, 0x54006132, 0x75747865, 0x44326572, 0x7241534d, 0x00796172, 0x000002cf, 0x00000002, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x6d643274, 0x54006173, 0x75747865, +0x44336572, 0x00030300, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001000, +0x00337400, 0x74786554, 0x43657275, 0x00656275, 0x0000032c, 0x00000002, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000011, 0x47007174, 0x656d6f65, 0x53797274, 0x65646168, 0x03570072, +0x00020000, 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00070000, 0x73670000, 0x78695000, +0x68536c65, 0x72656461, 0x00038500, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000500, 0x00737000, 0x74726556, 0x68537865, 0x72656461, 0x0003b000, 0x00000200, 0x00000100, +0x00000000, 0x00000000, 0x00000000, 0x00000600, 0x00737600, 0x00000004, 0x00000060, 0x00000000, +0x00000004, 0xffffffff, 0x00000002, 0x0000002a, 0x0000000e, 0x0000002c, 0x00000033, 0x0000000e, +0x0000002c, 0x00000058, 0x0000003c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x0000007b, 0x0000005f, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x000000a1, +0x00000085, 0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x000000c7, 0x000000ab, +0x00000000, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0x000000f0, 0x000000d4, 0x00000000, +0xffffffff, 0x00000000, 0x00000000, 0x00000124, 0x00000108, 0x00000000, 0xffffffff, 0x00000000, +0x00000000, 0x0000015d, 0x00000141, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x0000018b, +0x0000016f, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x000001bc, 0x000001a0, 0x00000000, +0xffffffff, 0x00000000, 0x000001ed, 0x000001d1, 0x00000000, 0xffffffff, 0x00000000, 0x00000217, +0x000001fb, 0x00000000, 0xffffffff, 0x00000000, 0x00000245, 0x00000229, 0x00000000, 0xffffffff, +0x00000000, 0x0000026f, 0x00000253, 0x00000000, 0xffffffff, 0x00000000, 0x0000029a, 0x0000027e, +0x00000000, 0xffffffff, 0x00000000, 0x000002cb, 0x000002af, 0x00000000, 0xffffffff, 0x00000000, +0x000002fc, 0x000002e0, 0x00000000, 0xffffffff, 0x00000000, 0x00000329, 0x0000030d, 0x00000000, +0xffffffff, 0x00000000, 0x00000354, 0x00000338, 0x00000000, 0xffffffff, 0x00000000, 0x00000382, +0x00000366, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x000003ad, 0x00000391, +0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x000003d9, 0x000003bd, 0x00000000, 0xffffffff, +0x00000000, 0x00000000, };
static BOOL is_valid_check(BOOL a, BOOL b) @@ -1382,6 +1333,7 @@ static void check_as(ID3D10EffectVariable *variable)
static void test_effect_variable_type_class(void) { + ID3D10EffectStringVariable *string_var; ID3D10Effect *effect; ID3D10EffectConstantBuffer *constantbuffer, *null_buffer, *parent; ID3D10EffectVariable *variable; @@ -1392,6 +1344,7 @@ static void test_effect_variable_type_class(void) ULONG refcount; HRESULT hr; unsigned int variable_nr = 0; + const char *str1, *str2;
if (!(device = create_device())) { @@ -1413,7 +1366,7 @@ static void test_effect_variable_type_class(void) ok(strcmp(vd.Name, "cb") == 0, "Name is "%s", expected "cb"\n", vd.Name); ok(vd.Semantic == NULL, "Semantic is "%s", expected NULL\n", vd.Semantic); ok(vd.Flags == 0, "Type is %u, expected 0\n", vd.Flags); - ok(vd.Annotations == 1, "Elements is %u, expected 1\n", vd.Annotations); + ok(vd.Annotations == 2, "Unexpected Annotations %u.\n", vd.Annotations); ok(vd.BufferOffset == 0, "Members is %u, expected 0\n", vd.BufferOffset); ok(vd.ExplicitBindPoint == 0, "ExplicitBindPoint is %u, expected 0\n", vd.ExplicitBindPoint);
@@ -1437,7 +1390,6 @@ static void test_effect_variable_type_class(void) ok(td.UnpackedSize == 0x60, "UnpackedSize is %#x, expected 0x60\n", td.UnpackedSize); ok(td.Stride == 0x60, "Stride is %#x, expected 0x60\n", td.Stride);
- /* check annotation a */ variable = constantbuffer->lpVtbl->GetAnnotationByIndex(constantbuffer, 0); hr = variable->lpVtbl->GetDesc(variable, &vd); ok(SUCCEEDED(hr), "GetDesc failed (%x)\n", hr); @@ -1469,6 +1421,24 @@ static void test_effect_variable_type_class(void) ok(td.UnpackedSize == 0x0, "UnpackedSize is %#x, expected 0x0\n", td.UnpackedSize); ok(td.Stride == 0x0, "Stride is %#x, expected 0x0\n", td.Stride);
+ string_var = variable->lpVtbl->AsString(variable); + hr = string_var->lpVtbl->GetString(string_var, &str1); +todo_wine + ok(SUCCEEDED(hr), "GetString failed, hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ok(!strcmp(str1, "STRING"), "Unexpected value %s.\n", str1); + + variable = constantbuffer->lpVtbl->GetAnnotationByIndex(constantbuffer, 1); + string_var = variable->lpVtbl->AsString(variable); + hr = string_var->lpVtbl->GetString(string_var, &str2); +todo_wine + ok(SUCCEEDED(hr), "GetString failed, hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + ok(str2 != str1, "Unexpected string pointer.\n"); + ok(!strcmp(str2, "STRING"), "Unexpected value %s.\n", str1); + } + /* check float f */ variable = constantbuffer->lpVtbl->GetMemberByIndex(constantbuffer, variable_nr++); hr = variable->lpVtbl->GetDesc(variable, &vd);