Note for patch 7:
See https://docs.microsoft.com/en-us/windows/win32/api/d3d10/ns-d3d10-d3d10_mapp... :
A block-compressed texture is encoded in 4x4 blocks (see virtual size vs physical size) ; therefore, RowPitch is the number of bytes in a block of 4x4 texels.
From: Ziqing Hui zhui@codeweavers.com
Passing NULL profile to effect creation will crash wine for now. So we have to skip these tests in wine. --- dlls/d3dx10_43/tests/d3dx10.c | 100 ++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index ee969608d2b..eeb3e020318 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -541,6 +541,35 @@ static const BYTE test_wmp_data[] = 0xff, 0xff, 0xff, 0xff };
+static const BYTE test_fx[] = +{ + 0x44, 0x58, 0x42, 0x43, 0x95, 0x89, 0xe1, 0xa2, 0xcc, 0x97, 0x05, 0x54, 0x73, 0x9d, 0x0b, 0x67, + 0x90, 0xe1, 0x7f, 0x77, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x46, 0x58, 0x31, 0x30, 0xde, 0x00, 0x00, 0x00, 0x01, 0x10, 0xff, 0xfe, + 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x62, 0x00, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x09, 0x00, + 0x00, 0x66, 0x31, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, + 0x66, 0x32, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x30, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, + 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +/* Source code of test_fx. */ +static const char *test_fx_source = +"cbuffer cb : register(b1)\n" +"{\n" +" float f1 : SV_POSITION;\n" +" float f2 : COLOR0;\n" +"}\n"; + static const struct test_image { const BYTE *data; @@ -3932,6 +3961,76 @@ todo_wine { ok(!refcount, "Unexpected refcount.\n"); }
+static void test_create_effect_from_memory(void) +{ + ID3D10Device *device; + ID3D10Effect *effect; + ID3D10Blob *errors; + ULONG refcount; + HRESULT hr; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + /* Test NULL data. */ + if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ + { + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromMemory(NULL, 0, NULL, NULL, NULL, NULL, + 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + /* Test NULL device. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromMemory(test_fx, sizeof(test_fx), NULL, NULL, NULL, NULL, + 0x0, 0x0, NULL, NULL, NULL, &effect, &errors, NULL); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + /* Test creating texture from compiled shader. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromMemory(test_fx, sizeof(test_fx), NULL, NULL, NULL, NULL, + 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!errors, "Got unexpected errors %p.\n", errors); + ok(!!effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + effect->lpVtbl->Release(effect); + + /* Test creating texture from source without setting profile. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromMemory(test_fx_source, strlen(test_fx_source) + 1, NULL, NULL, NULL, NULL, + 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr); + ok(!!errors && errors != (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + ID3D10Blob_Release(errors); + } + + /* Test creating texture from source. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromMemory(test_fx_source, strlen(test_fx_source) + 1, NULL, NULL, NULL, "fx_4_0", + 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); + todo_wine ok(!!effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + if (hr == S_OK) + effect->lpVtbl->Release(effect); + + refcount = ID3D10Device_Release(device); + ok(!refcount, "Got unexpected refcount %#lx.\n", refcount); +} + static void test_create_effect_from_resource(void) { ID3D10Device *device; @@ -3966,5 +4065,6 @@ START_TEST(d3dx10) test_create_texture(); test_font(); test_sprite(); + test_create_effect_from_memory(); test_create_effect_from_resource(); }
From: Ziqing Hui zhui@codeweavers.com
--- dlls/d3dx10_43/tests/d3dx10.c | 106 ++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index eeb3e020318..9ebed240caa 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -4031,6 +4031,111 @@ static void test_create_effect_from_memory(void) ok(!refcount, "Got unexpected refcount %#lx.\n", refcount); }
+static void test_create_effect_from_file(void) +{ + static const WCHAR *test_file_name = L"test.fx"; + WCHAR path[MAX_PATH]; + ID3D10Device *device; + ID3D10Effect *effect; + ID3D10Blob *errors; + ULONG refcount; + HRESULT hr; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + /* Test NULL file name. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromFileW(NULL, NULL, NULL, NULL, 0x0, 0x0, + device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromFileA(NULL, NULL, NULL, NULL, 0x0, 0x0, + device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + /* Test non-existent file. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromFileW(L"deadbeef", NULL, NULL, NULL, 0x0, 0x0, + device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromFileA("deadbeef", NULL, NULL, NULL, 0x0, 0x0, + device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + /* Test creating texture from compiled shader file. */ + if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ + { + create_file(test_file_name, test_fx, sizeof(test_fx), path); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromFileW(path, NULL, NULL, NULL, 0x0, 0x0, + device, NULL, NULL, &effect, &errors, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!errors, "Got unexpected errors %p.\n", errors); + ok(!!effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + effect->lpVtbl->Release(effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromFileA(get_str_a(path), NULL, NULL, NULL, 0x0, 0x0, + device, NULL, NULL, &effect, &errors, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!errors, "Got unexpected errors %p.\n", errors); + ok(!!effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + effect->lpVtbl->Release(effect); + + delete_file(test_file_name); + } + + /* Test creating texture from source file. */ + create_file(test_file_name, test_fx_source, strlen(test_fx_source) + 1, path); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromFileW(path, NULL, NULL, "fx_4_0", 0x0, 0x0, + device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); + todo_wine ok(effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + if (hr == S_OK) + effect->lpVtbl->Release(effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromFileA(get_str_a(path), NULL, NULL, "fx_4_0", 0x0, 0x0, + device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); + todo_wine ok(effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + if (hr == S_OK) + effect->lpVtbl->Release(effect); + + delete_file(test_file_name); + + refcount = ID3D10Device_Release(device); + ok(!refcount, "Got unexpected refcount %#lx.\n", refcount); +} + static void test_create_effect_from_resource(void) { ID3D10Device *device; @@ -4066,5 +4171,6 @@ START_TEST(d3dx10) test_font(); test_sprite(); test_create_effect_from_memory(); + test_create_effect_from_file(); test_create_effect_from_resource(); }
From: Ziqing Hui zhui@codeweavers.com
--- dlls/d3dx10_43/tests/d3dx10.c | 109 ++++++++++++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 9ebed240caa..90c0eb4d777 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -4138,8 +4138,11 @@ static void test_create_effect_from_file(void)
static void test_create_effect_from_resource(void) { + static const WCHAR *test_resource_name = L"test.fx"; + HMODULE resource_module; ID3D10Device *device; ID3D10Effect *effect; + ID3D10Blob *errors; ULONG refcount; HRESULT hr;
@@ -4149,12 +4152,110 @@ static void test_create_effect_from_resource(void) return; }
- hr = D3DX10CreateEffectFromResourceA(GetModuleHandleA(NULL), "resource", NULL, NULL, NULL, - "fx_4_0", 0, 0, device, NULL, NULL, &effect, NULL, NULL); - ok(hr == D3DX10_ERR_INVALID_DATA, "Unexpected hr %#lx.\n", hr); + /* Test NULL module. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceW(NULL, NULL, NULL, NULL, NULL, NULL, + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceA(NULL, NULL, NULL, NULL, NULL, NULL, + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + /* Test NULL resource name. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceW(GetModuleHandleW(NULL), NULL, NULL, NULL, NULL, NULL, + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceA(GetModuleHandleA(NULL), NULL, NULL, NULL, NULL, NULL, + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + /* Test non-existent resource name. */ + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceW(GetModuleHandleW(NULL), L"deadbeef", NULL, NULL, NULL, NULL, + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceA(GetModuleHandleA(NULL), "deadbeef", NULL, NULL, NULL, NULL, + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#lx.\n", hr); + ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + + /* Test creating texture from compiled shader resource. */ + if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ + { + resource_module = create_resource_module(test_resource_name, test_fx, sizeof(test_fx)); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceW(resource_module, test_resource_name, NULL, NULL, NULL, NULL, + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!errors, "Got unexpected errors %p.\n", errors); + ok(!!effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + effect->lpVtbl->Release(effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceA(resource_module, get_str_a(test_resource_name), NULL, NULL, NULL, NULL, + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!errors, "Got unexpected errors %p.\n", errors); + ok(!!effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + effect->lpVtbl->Release(effect); + + delete_resource_module(test_resource_name, resource_module); + } + + /* Test creating texture from source resource. */ + resource_module = create_resource_module(test_resource_name, test_fx_source, strlen(test_fx_source) + 1); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceW(resource_module, test_resource_name, NULL, NULL, NULL, "fx_4_0", + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); + todo_wine ok(effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + if (hr == S_OK) + effect->lpVtbl->Release(effect); + + errors = (ID3D10Blob *)0xdeadbeef; + effect = (ID3D10Effect *)0xdeadbeef; + hr = D3DX10CreateEffectFromResourceA(resource_module, get_str_a(test_resource_name), NULL, NULL, NULL, "fx_4_0", + 0, 0, device, NULL, NULL, &effect, &errors, NULL); + todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); + todo_wine ok(effect && effect != (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); + if (hr == S_OK) + effect->lpVtbl->Release(effect); + + delete_resource_module(test_resource_name, resource_module);
refcount = ID3D10Device_Release(device); - ok(!refcount, "Unexpected refcount.\n"); + ok(!refcount, "Got unexpected refcount %#lx.\n", refcount); }
START_TEST(d3dx10)
From: Ziqing Hui zhui@codeweavers.com
--- dlls/d3dx10_43/compiler.c | 63 +++++++++++++++++++++-------------- dlls/d3dx10_43/tests/d3dx10.c | 4 +-- 2 files changed, 40 insertions(+), 27 deletions(-)
diff --git a/dlls/d3dx10_43/compiler.c b/dlls/d3dx10_43/compiler.c index c66eb679a8f..3ac961e907f 100644 --- a/dlls/d3dx10_43/compiler.c +++ b/dlls/d3dx10_43/compiler.c @@ -28,25 +28,19 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
- -HRESULT WINAPI D3DX10CreateEffectFromMemory(const void *data, SIZE_T datasize, const char *filename, +static HRESULT create_effect(const void *data, SIZE_T datasize, const char *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, UINT shader_flags, UINT effect_flags, ID3D10Device *device, ID3D10EffectPool *effect_pool, - ID3DX10ThreadPump *pump, ID3D10Effect **effect, ID3D10Blob **errors, HRESULT *hresult) + ID3D10Effect **effect, ID3D10Blob **errors) { ID3D10Blob *code; HRESULT hr;
- TRACE("data %p, datasize %Iu, filename %s, defines %p, include %p, profile %s, shader_flags %#x," - "effect_flags %#x, device %p, effect_pool %p, pump %p, effect %p, errors %p, hresult %p.\n", - data, datasize, debugstr_a(filename), defines, include, debugstr_a(profile), - shader_flags, effect_flags, device, effect_pool, pump, effect, errors, hresult); - - if (pump) - FIXME("Asynchronous mode is not supported.\n"); + if (!data || !device) + return E_FAIL;
- if (!include) - include = D3D_COMPILE_STANDARD_FILE_INCLUDE; + if (errors) + *errors = NULL;
if (FAILED(hr = D3DCompile(data, datasize, filename, defines, include, "main", profile, shader_flags, effect_flags, &code, errors))) @@ -62,12 +56,34 @@ HRESULT WINAPI D3DX10CreateEffectFromMemory(const void *data, SIZE_T datasize, c return hr; }
+HRESULT WINAPI D3DX10CreateEffectFromMemory(const void *data, SIZE_T datasize, const char *filename, + const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, + UINT shader_flags, UINT effect_flags, ID3D10Device *device, ID3D10EffectPool *effect_pool, + ID3DX10ThreadPump *pump, ID3D10Effect **effect, ID3D10Blob **errors, HRESULT *hresult) +{ + TRACE("data %p, datasize %Iu, filename %s, defines %p, include %p, profile %s, shader_flags %#x," + "effect_flags %#x, device %p, effect_pool %p, pump %p, effect %p, errors %p, hresult %p.\n", + data, datasize, debugstr_a(filename), defines, include, debugstr_a(profile), + shader_flags, effect_flags, device, effect_pool, pump, effect, errors, hresult); + + if (pump) + FIXME("Asynchronous mode is not supported.\n"); + + if (!include) + include = D3D_COMPILE_STANDARD_FILE_INCLUDE; + + return create_effect(data, datasize, filename, defines, include, profile, + shader_flags, effect_flags, device, effect_pool, effect, errors); +} + HRESULT WINAPI D3DX10CreateEffectFromFileW(const WCHAR *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, UINT shader_flags, UINT effect_flags, ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3DX10ThreadPump *pump, ID3D10Effect **effect, ID3D10Blob **errors, HRESULT *hresult) { - ID3D10Blob *code; + char filename_a[MAX_PATH]; + void *buffer = NULL; + DWORD size = 0; HRESULT hr;
TRACE("filename %s, defines %p, include %p, profile %s, shader_flags %#x, effect_flags %#x, " @@ -81,17 +97,14 @@ HRESULT WINAPI D3DX10CreateEffectFromFileW(const WCHAR *filename, const D3D10_SH if (!include) include = D3D_COMPILE_STANDARD_FILE_INCLUDE;
- if (FAILED(hr = D3DCompileFromFile(filename, defines, include, "main", profile, shader_flags, - effect_flags, &code, errors))) + if (SUCCEEDED((hr = load_file(filename, &buffer, &size)))) { - WARN("Effect compilation failed, hr %#lx.\n", hr); - return hr; + WideCharToMultiByte(CP_ACP, 0, filename, -1, filename_a, sizeof(filename_a), NULL, NULL); + hr = create_effect(buffer, size, filename_a, defines, include, profile, + shader_flags, effect_flags, device, effect_pool, effect, errors); + free(buffer); }
- hr = D3D10CreateEffectFromMemory(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code), - effect_flags, device, effect_pool, effect); - ID3D10Blob_Release(code); - return hr; }
@@ -144,8 +157,8 @@ HRESULT WINAPI D3DX10CreateEffectFromResourceA(HMODULE module, const char *resou if (FAILED(hr)) return hr;
- return D3DX10CreateEffectFromMemory(data, size, filename, defines, include, profile, - shader_flags, effect_flags, device, effect_pool, pump, effect, errors, hresult); + return create_effect(data, size, filename, defines, include, profile, + shader_flags, effect_flags, device, effect_pool, effect, errors); }
HRESULT WINAPI D3DX10CreateEffectFromResourceW(HMODULE module, const WCHAR *resource_name, @@ -178,8 +191,8 @@ HRESULT WINAPI D3DX10CreateEffectFromResourceW(HMODULE module, const WCHAR *reso WideCharToMultiByte(CP_ACP, 0, filenameW, -1, filename, len, NULL, NULL); }
- hr = D3DX10CreateEffectFromMemory(data, size, filename, defines, include, profile, - shader_flags, effect_flags, device, effect_pool, pump, effect, errors, hresult); + hr = create_effect(data, size, filename, defines, include, profile, + shader_flags, effect_flags, device, effect_pool, effect, errors); free(filename); return hr; } diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 90c0eb4d777..df82bfa003f 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -4069,7 +4069,7 @@ static void test_create_effect_from_file(void) effect = (ID3D10Effect *)0xdeadbeef; hr = D3DX10CreateEffectFromFileW(L"deadbeef", NULL, NULL, NULL, 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); - todo_wine ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); + ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
@@ -4077,7 +4077,7 @@ static void test_create_effect_from_file(void) effect = (ID3D10Effect *)0xdeadbeef; hr = D3DX10CreateEffectFromFileA("deadbeef", NULL, NULL, NULL, 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); - todo_wine ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); + ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#lx.\n", hr); todo_wine ok(!errors, "Got unexpected errors %p.\n", errors); ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
From: Ziqing Hui zhui@codeweavers.com
--- dlls/d3dx10_43/compiler.c | 32 ++++++++++++++++++++++++-------- dlls/d3dx10_43/tests/d3dx10.c | 14 +++----------- 2 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/dlls/d3dx10_43/compiler.c b/dlls/d3dx10_43/compiler.c index 3ac961e907f..684615eb192 100644 --- a/dlls/d3dx10_43/compiler.c +++ b/dlls/d3dx10_43/compiler.c @@ -28,12 +28,17 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
+#define D3DERR_INVALIDCALL 0x8876086c + static HRESULT create_effect(const void *data, SIZE_T datasize, const char *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, UINT shader_flags, UINT effect_flags, ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect, ID3D10Blob **errors) { - ID3D10Blob *code; + const char dxbc[] = {'D','X','B','C'}; + ID3D10Blob *code = NULL; + void *buffer; + SIZE_T size; HRESULT hr;
if (!data || !device) @@ -42,17 +47,28 @@ static HRESULT create_effect(const void *data, SIZE_T datasize, const char *file if (errors) *errors = NULL;
- if (FAILED(hr = D3DCompile(data, datasize, filename, defines, include, "main", profile, - shader_flags, effect_flags, &code, errors))) + buffer = (void *)data; + size = datasize; + + /* Effect is not compiled. */ + if (datasize < sizeof(dxbc) || memcmp(dxbc, data, sizeof(dxbc)) != 0) { - WARN("Effect compilation failed, hr %#lx.\n", hr); - return hr; + if (!profile) + return D3DERR_INVALIDCALL; + if (FAILED(hr = D3DCompile(data, datasize, filename, defines, include, "main", profile, + shader_flags, effect_flags, &code, errors))) + { + WARN("Effect compilation failed, hr %#lx.\n", hr); + return hr; + } + buffer = ID3D10Blob_GetBufferPointer(code); + size = ID3D10Blob_GetBufferSize(code); }
- hr = D3D10CreateEffectFromMemory(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code), - effect_flags, device, effect_pool, effect); - ID3D10Blob_Release(code); + hr = D3D10CreateEffectFromMemory(buffer, size, effect_flags, device, effect_pool, effect);
+ if (code) + ID3D10Blob_Release(code); return hr; }
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index df82bfa003f..99350197acd 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -3976,8 +3976,6 @@ static void test_create_effect_from_memory(void) }
/* Test NULL data. */ - if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ - { errors = (ID3D10Blob *)0xdeadbeef; effect = (ID3D10Effect *)0xdeadbeef; hr = D3DX10CreateEffectFromMemory(NULL, 0, NULL, NULL, NULL, NULL, @@ -4011,10 +4009,10 @@ static void test_create_effect_from_memory(void) hr = D3DX10CreateEffectFromMemory(test_fx_source, strlen(test_fx_source) + 1, NULL, NULL, NULL, NULL, 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr); - ok(!!errors && errors != (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); + todo_wine ok(!!errors && errors != (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect); - ID3D10Blob_Release(errors); - } + if (errors && errors != (ID3D10Blob *)0xdeadbeef) + ID3D10Blob_Release(errors);
/* Test creating texture from source. */ errors = (ID3D10Blob *)0xdeadbeef; @@ -4082,8 +4080,6 @@ static void test_create_effect_from_file(void) ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
/* Test creating texture from compiled shader file. */ - if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ - { create_file(test_file_name, test_fx, sizeof(test_fx), path);
errors = (ID3D10Blob *)0xdeadbeef; @@ -4105,7 +4101,6 @@ static void test_create_effect_from_file(void) effect->lpVtbl->Release(effect);
delete_file(test_file_name); - }
/* Test creating texture from source file. */ create_file(test_file_name, test_fx_source, strlen(test_fx_source) + 1, path); @@ -4204,8 +4199,6 @@ static void test_create_effect_from_resource(void) ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
/* Test creating texture from compiled shader resource. */ - if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ - { resource_module = create_resource_module(test_resource_name, test_fx, sizeof(test_fx));
errors = (ID3D10Blob *)0xdeadbeef; @@ -4227,7 +4220,6 @@ static void test_create_effect_from_resource(void) effect->lpVtbl->Release(effect);
delete_resource_module(test_resource_name, resource_module); - }
/* Test creating texture from source resource. */ resource_module = create_resource_module(test_resource_name, test_fx_source, strlen(test_fx_source) + 1);
From: Ziqing Hui zhui@codeweavers.com
--- dlls/d3dx10_43/compiler.c | 5 ++++- dlls/d3dx10_43/tests/d3dx10.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx10_43/compiler.c b/dlls/d3dx10_43/compiler.c index 684615eb192..957fb006542 100644 --- a/dlls/d3dx10_43/compiler.c +++ b/dlls/d3dx10_43/compiler.c @@ -107,6 +107,9 @@ HRESULT WINAPI D3DX10CreateEffectFromFileW(const WCHAR *filename, const D3D10_SH debugstr_w(filename), defines, include, debugstr_a(profile), shader_flags, effect_flags, device, effect_pool, pump, effect, errors, hresult);
+ if (!filename) + return E_FAIL; + if (pump) FIXME("Asynchronous mode is not supported.\n");
@@ -139,7 +142,7 @@ HRESULT WINAPI D3DX10CreateEffectFromFileA(const char *filename, const D3D10_SHA device, effect_pool, pump, effect, errors, hresult);
if (!filename) - return E_INVALIDARG; + return E_FAIL;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0); if (!(filenameW = malloc(len * sizeof(*filenameW)))) diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 99350197acd..3ca2a7884a4 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -4050,7 +4050,7 @@ static void test_create_effect_from_file(void) effect = (ID3D10Effect *)0xdeadbeef; hr = D3DX10CreateEffectFromFileW(NULL, NULL, NULL, NULL, 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); - todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
@@ -4058,7 +4058,7 @@ static void test_create_effect_from_file(void) effect = (ID3D10Effect *)0xdeadbeef; hr = D3DX10CreateEffectFromFileA(NULL, NULL, NULL, NULL, 0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL); - todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); + ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr); ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors); ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
From: Ziqing Hui zhui@codeweavers.com
A block-compressed texture is encoded in 4x4 blocks. Therefore, pitch is the number of bytes in a block of 4x4 texels. --- dlls/d3dx10_43/texture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index 88efdf585b4..9752f3e1560 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -857,9 +857,10 @@ HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO
if (is_block_compressed(img_info.Format)) { + stride *= 4; if (FAILED(hr = IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICDdsFrameDecode, (void **)&dds_frame))) goto end; - if (FAILED(hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, stride * 4, frame_size, buffer))) + if (FAILED(hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, stride, frame_size, buffer))) goto end; } else
I don't know if you were aware of MR !332, which is basically an alternative to this MR. I think I generally prefer your version but there might be some comments on that one that are relevant here too.
I have a bunch of nitpicks that I'm going to comment inline.
Matteo Bruni (@Mystral) commented about dlls/d3dx10_43/tests/d3dx10.c:
- 0x24, 0x00, 0x00, 0x00, 0x46, 0x58, 0x31, 0x30, 0xde, 0x00, 0x00, 0x00, 0x01, 0x10, 0xff, 0xfe,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x62, 0x00, 0x66,
- 0x6c, 0x6f, 0x61, 0x74, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x09, 0x00,
- 0x00, 0x66, 0x31, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00,
- 0x66, 0x32, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x30, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
- 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
I'd prefer if this was stored as a DWORD array (or other 4-byte data type) instead, like e.g. the shaders from the d3d11 tests.
BTW the size in bytes of the array above doesn't seem to be divisible by 4, which doesn't sound right for DXBC shaders.
Matteo Bruni (@Mystral) commented about dlls/d3dx10_43/tests/d3dx10.c:
- 0x66, 0x32, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x30, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
- 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+/* Source code of test_fx. */ +static const char *test_fx_source = +"cbuffer cb : register(b1)\n" +"{\n" +" float f1 : SV_POSITION;\n" +" float f2 : COLOR0;\n" +"}\n";
We usually put the shader source above the compiled version. This is fine, but might as well move it up for consistency...
Matteo Bruni (@Mystral) commented about dlls/d3dx10_43/tests/d3dx10.c:
- hr = D3DX10CreateEffectFromMemory(NULL, 0, NULL, NULL, NULL, NULL,
0x0, 0x0, device, NULL, NULL, &effect, &errors, NULL);
- ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
- ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors);
- ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
- /* Test NULL device. */
- errors = (ID3D10Blob *)0xdeadbeef;
- effect = (ID3D10Effect *)0xdeadbeef;
- hr = D3DX10CreateEffectFromMemory(test_fx, sizeof(test_fx), NULL, NULL, NULL, NULL,
0x0, 0x0, NULL, NULL, NULL, &effect, &errors, NULL);
- ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
- ok(errors == (ID3D10Blob *)0xdeadbeef, "Got unexpected errors %p.\n", errors);
- ok(effect == (ID3D10Effect *)0xdeadbeef, "Got unexpected effect %p.\n", effect);
- /* Test creating texture from compiled shader. */
Typo "texture" instead of "effect" (or something) here and in many other comments.
Matteo Bruni (@Mystral) commented about dlls/d3dx10_43/compiler.c:
if (errors) *errors = NULL;
- if (FAILED(hr = D3DCompile(data, datasize, filename, defines, include, "main", profile,
shader_flags, effect_flags, &code, errors)))
- buffer = (void *)data;
- size = datasize;
- /* Effect is not compiled. */
- if (datasize < sizeof(dxbc) || memcmp(dxbc, data, sizeof(dxbc)) != 0)
We usually do without the explicit "!= 0".
Matteo Bruni (@Mystral) commented about dlls/d3dx10_43/texture.c:
if (is_block_compressed(img_info.Format)) {
stride *= 4; if (FAILED(hr = IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICDdsFrameDecode, (void **)&dds_frame))) goto end;
if (FAILED(hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, stride * 4, frame_size, buffer)))
} elseif (FAILED(hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, stride, frame_size, buffer))) goto end;
Two things about this commit. This could use a test demonstrating that the old behavior is wrong and that this patch makes it right. Also, this should probably be on a separate MR.
On Thu Aug 25 22:21:45 2022 +0000, Matteo Bruni wrote:
I'd prefer if this was stored as a DWORD array (or other 4-byte data type) instead, like e.g. the shaders from the d3d11 tests. BTW the size in bytes of the array above doesn't seem to be divisible by 4, which doesn't sound right for DXBC shaders.
I compiled this shader like this on Windows:
`fxc /Qstrip_debug /Qstrip_reflect /T fx_4_0 /Fo test_fx test_fx_source`
It do give me a result shader of 266 bytes.
PS, My fxc version:
`Microsoft (R) Direct3D Shader Compiler 10.1 (using C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\D3DCOMPILER_47.dll) Copyright (C) 2013 Microsoft. All rights reserved.`
On Fri Aug 26 04:25:25 2022 +0000, Ziqing Hui wrote:
I compiled this shader like this on Windows: `fxc /Qstrip_debug /Qstrip_reflect /T fx_4_0 /Fo test_fx test_fx_source` It do give me a result shader of 266 bytes. If it's 266 bytes, it cannot be store as a DWORD array. PS, My fxc version: `Microsoft (R) Direct3D Shader Compiler 10.1 (using C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\D3DCOMPILER_47.dll) Copyright (C) 2013 Microsoft. All rights reserved.`
Interesting. I've always used the /Fx option (with a different fxc version, but that doesn't seem to matter) which outputs the bytecode grouped in DWORDs and for this shader I get 268 bytes worth of data with it, while indeed /Fo gives a 266 byte output. I guess I was thinking about the older <= d3d9 bytecode format, the one used for d3d10+ doesn't have that constraint technically (the format is generally DWORD-oriented but there is no alignment guarantee for individual chunks or the whole shader).
In the end, I think I'd still prefer to have the shaders stored as DWORDs, to be consistent with the existing tests.
On Fri Aug 26 17:48:12 2022 +0000, Matteo Bruni wrote:
Interesting. I've always used the /Fx option (with a different fxc version, but that doesn't seem to matter) which outputs the bytecode grouped in DWORDs and for this shader I get 268 bytes worth of data with it, while indeed /Fo gives a 266 byte output. I guess I was thinking about the older <= d3d9 bytecode format, the one used for d3d10+ doesn't have that constraint technically (the format is generally DWORD-oriented but there is no alignment guarantee for individual chunks or the whole shader). In the end, I think I'd still prefer to have the shaders stored as DWORDs, to be consistent with the existing tests.
I tried the 268 bytes. However, the tests will fail on Windows for 268 bytes.
This line will fail on Windows: tests/d3dx10_43.c: line 4002. It returns E_FAIL for 268 bytes. Return S_OK for 266 bytes as expected.
I guess maybe /Fx option just output DWORDs even if its actual shader size is not DWORD aligned. It adds 2 bytes 0 to the end of the output to satisfy DWORD alignment. While the actual shader doesn't contains the 2 bytes.
On Sat Aug 27 05:38:26 2022 +0000, Ziqing Hui wrote:
I tried the 268 bytes. However, the tests will fail on Windows for 268 bytes. This line will fail on Windows: tests/d3dx10_43.c: line 4002. It returns E_FAIL for 268 bytes. Return S_OK for 266 bytes as expected. I guess maybe /Fx option just output DWORDs even if its actual shader size is not DWORD aligned. It adds 2 bytes 0 to the end of the output to satisfy DWORD alignment. While the actual shader doesn't contains the 2 bytes.
If I want to store 266 bytes as DWORDs, what should I do? Store it as a 268 bytes array and reduce data size by 2 when calling effect creation functions?
Like:
``` static const DWORD test_fx[] = { 288 bytes };
test_create_effect_from_memory { D3DX10CreateEffectFromMemory(sizeof(test_fx) - 2) } ```
On Sat Aug 27 05:47:05 2022 +0000, Ziqing Hui wrote:
If I want to store 266 bytes as DWORDs, what should I do? Store it as a 268 bytes array and reduce data size by 2 when calling effect creation functions? Like:
static const DWORD test_fx[] = { 288 bytes }; test_create_effect_from_memory { D3DX10CreateEffectFromMemory(sizeof(test_fx) - 2) }
Nah, let's just keep this as it is now, no reason to make everything more complicated.
I guess this is just something peculiar to fx_4_0 effects, surprised that I never encountered it before. I'll do some further digging locally.