Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/tests/asm.c | 171 ++++++++++++++++++++++---------------- 1 file changed, 98 insertions(+), 73 deletions(-)
diff --git a/dlls/d3dx9_36/tests/asm.c b/dlls/d3dx9_36/tests/asm.c index bfc84b2f9c2..3faebb4d69f 100644 --- a/dlls/d3dx9_36/tests/asm.c +++ b/dlls/d3dx9_36/tests/asm.c @@ -81,31 +81,46 @@ static void delete_directory(const char *name) RemoveDirectoryA(path); }
+struct test_include +{ + ID3DXInclude ID3DXInclude_iface; + BOOL terminated_data; +}; + +static inline struct test_include *impl_from_ID3DXInclude(ID3DXInclude *iface) +{ + return CONTAINING_RECORD(iface, struct test_include, ID3DXInclude_iface); +} + static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE include_type, const char *filename, const void *parent_data, const void **data, UINT *bytes) { - char *buffer; static const char shader[] = "#include "incl.vsh"\n" "mov REGISTER, v0\n"; static const char include[] = "#define REGISTER r0\nvs.1.1\n"; static const char include2[] = "#include "incl3.vsh"\n"; static const char include3[] = "vs.1.1\n"; + struct test_include *test_include = impl_from_ID3DXInclude(iface); + unsigned int size; + char *buffer;
trace("filename %s.\n", filename); trace("parent_data %p: %s.\n", parent_data, parent_data ? (char *)parent_data : "(null)");
if (!strcmp(filename, "shader.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(shader)); - memcpy(buffer, shader, sizeof(shader)); - *bytes = sizeof(shader); + size = test_include->terminated_data ? sizeof(shader) : sizeof(shader) - 1; + buffer = HeapAlloc(GetProcessHeap(), 0, size); + memcpy(buffer, shader, size); + *bytes = size; } else if (!strcmp(filename, "incl.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include)); - memcpy(buffer, include, sizeof(include)); - *bytes = sizeof(include); + size = test_include->terminated_data ? sizeof(include) : sizeof(include) - 1; + buffer = HeapAlloc(GetProcessHeap(), 0, size); + memcpy(buffer, include, size); + *bytes = size; /* This is included from the first D3DXAssembleShader with non-null ID3DXInclude test * (parent_data == NULL) and from shader.vsh / shader[] (with matching parent_data). * Allow both cases. */ @@ -113,24 +128,27 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE } else if (!strcmp(filename, "incl2.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include2)); - memcpy(buffer, include2, sizeof(include2)); - *bytes = sizeof(include2); + size = test_include->terminated_data ? sizeof(include2) : sizeof(include2) - 1; + buffer = HeapAlloc(GetProcessHeap(), 0, size); + memcpy(buffer, include2, size); + *bytes = size; } else if (!strcmp(filename, "incl3.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include3)); - memcpy(buffer, include3, sizeof(include3)); - *bytes = sizeof(include3); + size = test_include->terminated_data ? sizeof(include3) : sizeof(include3) - 1; + buffer = HeapAlloc(GetProcessHeap(), 0, size); + memcpy(buffer, include3, size); + *bytes = size; /* Also check for the correct parent_data content */ - ok(parent_data != NULL && !strncmp(include2, parent_data, strlen(include2)), "wrong parent_data value\n"); + ok(parent_data != NULL && !strncmp(include2, parent_data, strlen(include2)), "wrong parent_data value.\n"); } else if (!strcmp(filename, "include/incl3.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include)); - memcpy(buffer, include, sizeof(include)); - *bytes = sizeof(include); - ok(!parent_data, "wrong parent_data value\n"); + size = test_include->terminated_data ? sizeof(include) : sizeof(include) - 1; + buffer = HeapAlloc(GetProcessHeap(), 0, size); + memcpy(buffer, include, size); + *bytes = size; + ok(!parent_data, "wrong parent_data value.\n"); } else { @@ -147,15 +165,12 @@ static HRESULT WINAPI testD3DXInclude_close(ID3DXInclude *iface, const void *dat return S_OK; }
-static const struct ID3DXIncludeVtbl D3DXInclude_Vtbl = { +static const struct ID3DXIncludeVtbl test_include_vtbl = +{ testD3DXInclude_open, testD3DXInclude_close };
-struct D3DXIncludeImpl { - ID3DXInclude ID3DXInclude_iface; -}; - static void assembleshader_test(void) { static const char test1[] = @@ -180,8 +195,6 @@ static void assembleshader_test(void) "vs.1.1\n"; static const char testincl4_wrong[] = "#error "wrong include"\n"; - HRESULT hr; - ID3DXBuffer *shader, *messages; static const D3DXMACRO defines[] = { { "DEF1", "10 + 15" @@ -193,8 +206,11 @@ static void assembleshader_test(void) NULL, NULL } }; - struct D3DXIncludeImpl include; char shader_vsh_path[MAX_PATH], shader3_vsh_path[MAX_PATH]; + ID3DXBuffer *shader, *messages; + struct test_include include; + unsigned int i; + HRESULT hr;
/* pDefines test */ shader = NULL; @@ -229,56 +245,65 @@ static void assembleshader_test(void) }
/* pInclude test */ - shader = NULL; - messages = NULL; - include.ID3DXInclude_iface.lpVtbl = &D3DXInclude_Vtbl; - hr = D3DXAssembleShader(testshader, strlen(testshader), NULL, &include.ID3DXInclude_iface, - D3DXSHADER_SKIPVALIDATION, &shader, &messages); - ok(hr == D3D_OK, "pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); - if(messages) { - trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); - ID3DXBuffer_Release(messages); - } - if(shader) ID3DXBuffer_Release(shader); + for (i = 0; i < 2; ++i) + { + shader = NULL; + messages = NULL; + include.ID3DXInclude_iface.lpVtbl = &test_include_vtbl; + include.terminated_data = !!i; + hr = D3DXAssembleShader(testshader, strlen(testshader), NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + ok(hr == D3D_OK, "pInclude test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if (messages) + { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader);
- /* "unexpected #include file from memory" test */ - shader = NULL; - messages = NULL; - hr = D3DXAssembleShader(testshader, strlen(testshader), - NULL, NULL, D3DXSHADER_SKIPVALIDATION, - &shader, &messages); - ok(hr == D3DXERR_INVALIDDATA, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); - if(messages) { - trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); - ID3DXBuffer_Release(messages); - } - if(shader) ID3DXBuffer_Release(shader); + /* "unexpected #include file from memory" test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShader(testshader, strlen(testshader), NULL, NULL, D3DXSHADER_SKIPVALIDATION, + &shader, &messages); + ok(hr == D3DXERR_INVALIDDATA, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if (messages) + { + trace("D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader);
- /* recursive #include test */ - shader = NULL; - messages = NULL; - hr = D3DXAssembleShader(testshader2, strlen(testshader2), NULL, &include.ID3DXInclude_iface, - D3DXSHADER_SKIPVALIDATION, &shader, &messages); - todo_wine ok(hr == D3D_OK, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); - if(messages) { - trace("recursive D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); - ID3DXBuffer_Release(messages); - } - if(shader) ID3DXBuffer_Release(shader); + /* recursive #include test */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShader(testshader2, strlen(testshader2), NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + todo_wine ok(hr == D3D_OK, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000FFFF); + if (messages) + { + trace("recursive D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader);
- /* #include with a path. */ - shader = NULL; - messages = NULL; - hr = D3DXAssembleShader(testshader3, strlen(testshader3), NULL, &include.ID3DXInclude_iface, - D3DXSHADER_SKIPVALIDATION, &shader, &messages); - ok(hr == D3D_OK, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000ffff); - if (messages) - { - trace("Path search D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); - ID3DXBuffer_Release(messages); + /* #include with a path. */ + shader = NULL; + messages = NULL; + hr = D3DXAssembleShader(testshader3, strlen(testshader3), NULL, &include.ID3DXInclude_iface, + D3DXSHADER_SKIPVALIDATION, &shader, &messages); + ok(hr == D3D_OK, "D3DXAssembleShader test failed with error 0x%x - %d\n", hr, hr & 0x0000ffff); + if (messages) + { + trace("Path search D3DXAssembleShader messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages)); + ID3DXBuffer_Release(messages); + } + if (shader) + ID3DXBuffer_Release(shader); } - if (shader) - ID3DXBuffer_Release(shader);
if (create_file("shader.vsh", testshader, sizeof(testshader) - 1, shader_vsh_path)) { @@ -443,7 +468,7 @@ static void d3dxpreprocess_test(void) HRESULT hr; ID3DXBuffer *shader, *messages; char shader_vsh_path[MAX_PATH], shader3_vsh_path[MAX_PATH]; - static struct D3DXIncludeImpl include = {{&D3DXInclude_Vtbl}}; + static struct test_include include = {{&test_include_vtbl}, TRUE};
if (create_file("shader.vsh", testshader, sizeof(testshader) - 1, shader_vsh_path)) {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/asmshader.l | 2 +- dlls/d3dcompiler_43/asmshader.y | 43 ++++++++++++++++++++++++++------- dlls/d3dcompiler_43/tests/asm.c | 25 +++++++++++++------ 3 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/dlls/d3dcompiler_43/asmshader.l b/dlls/d3dcompiler_43/asmshader.l index 63ecddd1899..81718556787 100644 --- a/dlls/d3dcompiler_43/asmshader.l +++ b/dlls/d3dcompiler_43/asmshader.l @@ -96,7 +96,7 @@ NEWLINE (\n)|(\r\n)
COMMA ","
-IMMVAL -?(([0-9]+.?)|([0-9]*.[0-9]+))(f)? +IMMVAL (([0-9]+.?)|([0-9]*.[0-9]+))(f)?
ANY (.)
diff --git a/dlls/d3dcompiler_43/asmshader.y b/dlls/d3dcompiler_43/asmshader.y index 00c98b1dbc3..cdc75c18a3e 100644 --- a/dlls/d3dcompiler_43/asmshader.y +++ b/dlls/d3dcompiler_43/asmshader.y @@ -304,6 +304,8 @@ int asmshader_lex(void); %type <rel_reg> rel_reg %type <reg> predicate %type <immval> immsum +%type <immval> signed_integer +%type <immval> signed_float %type <sregs> sregs
%% @@ -713,11 +715,11 @@ instruction: INSTR_ADD omods dreg ',' sregs asm_ctx.line_no); set_parse_status(&asm_ctx.status, PARSE_WARN); } - | INSTR_DEF REG_CONSTFLOAT ',' IMMVAL ',' IMMVAL ',' IMMVAL ',' IMMVAL + | INSTR_DEF REG_CONSTFLOAT ',' signed_float ',' signed_float ',' signed_float ',' signed_float { asm_ctx.funcs->constF(&asm_ctx, $2, $4.val, $6.val, $8.val, $10.val); } - | INSTR_DEFI REG_CONSTINT ',' IMMVAL ',' IMMVAL ',' IMMVAL ',' IMMVAL + | INSTR_DEFI REG_CONSTINT ',' signed_integer ',' signed_integer ',' signed_integer ',' signed_integer { asm_ctx.funcs->constI(&asm_ctx, $2, $4.val, $6.val, $8.val, $10.val); } @@ -1387,23 +1389,46 @@ rel_reg: /* empty */ $$.swizzle = $5; }
-immsum: IMMVAL +immsum: signed_integer + | immsum '+' signed_integer { - if(!$1.integer) { + $$.val = $1.val + $3.val; + } + | immsum '-' signed_integer + { + $$.val = $1.val - $3.val; + } + +signed_integer: + IMMVAL + { + if (!$1.integer) + { asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n", - asm_ctx.line_no, $1.val); + asm_ctx.line_no, $1.val); set_parse_status(&asm_ctx.status, PARSE_ERR); } $$.val = $1.val; } - | immsum '+' IMMVAL + | '-' IMMVAL { - if(!$3.integer) { + if (!$2.integer) + { asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n", - asm_ctx.line_no, $3.val); + asm_ctx.line_no, $2.val); set_parse_status(&asm_ctx.status, PARSE_ERR); } - $$.val = $1.val + $3.val; + $$.val = -$2.val; + } + +signed_float: + IMMVAL + { + $$.val = $1.val; + } + | '-' IMMVAL + { + $$.val = -$2.val; }
smod: SMOD_BIAS diff --git a/dlls/d3dcompiler_43/tests/asm.c b/dlls/d3dcompiler_43/tests/asm.c index 25471b51673..d4826ed0771 100644 --- a/dlls/d3dcompiler_43/tests/asm.c +++ b/dlls/d3dcompiler_43/tests/asm.c @@ -34,7 +34,6 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena struct shader_test { const char *text; const DWORD bytes[128]; - BOOL todo; };
static void dump_shader(DWORD *shader) { @@ -60,7 +59,6 @@ static void exec_tests(const char *name, struct shader_test tests[], unsigned in messages = NULL; hr = D3DAssemble(tests[i].text, strlen(tests[i].text), NULL, NULL, NULL, D3DCOMPILE_SKIP_VALIDATION, &shader, &messages); - todo_wine_if(tests[i].todo) ok(hr == S_OK, "Test %s, shader %u: D3DAssemble failed with error %#lx - %ld.\n", name, i, hr, hr & 0xffff); if(messages) { trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages)); @@ -214,7 +212,6 @@ static void vs_1_1_test(void) { "def c12, 0, -1, -0.5, 1024\n", {0xfffe0101, 0x00000051, 0xa00f000c, 0x00000000, 0xbf800000, 0xbf000000, 0x44800000, 0x0000ffff}, - TRUE }, { /* shader 14: writemasks, swizzles */ "vs_1_1\n" @@ -758,12 +755,11 @@ static void vs_2_0_test(void) { }, { /* shader 22 */ "vs_2_0\n" - "defi i0, -1, 1, 10, 0\n" + "defi i0, - 1, 1, 10, 0\n" "defi i1, 0, 40, 30, 10\n", {0xfffe0200, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a, 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e, 0x0000000a, 0x0000ffff}, - TRUE }, { /* shader 23 */ "vs_2_0\n" @@ -976,7 +972,6 @@ static void ps_2_x_test(void) { {0xffff0201, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a, 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e, 0x0000000a, 0x0000ffff}, - TRUE }, { /* shader 2 */ "ps_2_x\n" @@ -1177,7 +1172,12 @@ static void vs_3_0_test(void) { {0xfffe0300, 0x04000002, 0x800f0000, 0x90e42014, 0xf0e40800, 0x80e40002, 0x0000ffff} }, - + { /* shader 15 */ + "vs.3.0\n" + "add r0, v0[aL + 1 + 3], r2\n", + {0xfffe0300, 0x04000002, 0x800f0000, 0x90e42004, 0xf0e40800, 0x80e40002, + 0x0000ffff} + }, };
exec_tests("vs_3_0", tests, ARRAY_SIZE(tests)); @@ -1408,6 +1408,17 @@ static void failure_test(void) { /* shader 43: */ "ps_2_0\n" "texm3x3vspec t3, t0\n", + /* shader 44: expression in defi not allowed */ + "vs_2_0\n" + "defi i0, -1 - 1, 1, 10, 0\n" + "defi i1, 0, 40, 30, 10\n", + /* shader 45: '-' not allowed inside relative addressing operands */ + "vs.3.0\n" + "add r0, v0[aL - 3 + 5], r2\n", + /* shader 46 */ + "vs_2_0\n" + "defi i0, 1.0, 1.1, 10.2, 0.3\n" + "defi i1, 0, 40, 30, 10\n", }; HRESULT hr; unsigned int i;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=113531
Your paranoid android.
=== debian11 (build log) ===
01b0:err:d3d:wined3d_debug_callback 0016C650: "0:43(1): error: error index must be >= 0". 01b0:fixme:d3d_shader:print_glsl_info_log 0:43(1): error: error index must be >= 0 01b0:err:d3d:wined3d_debug_callback 0016C650: "0:43(1): error: error index must be >= 0". 01b0:fixme:d3d_shader:print_glsl_info_log 0:43(1): error: error index must be >= 0 01b0:err:d3d:wined3d_debug_callback 0016C6A8: "0:43(1): error: error index must be >= 0". 01b0:fixme:d3d_shader:print_glsl_info_log 0:43(1): error: error index must be >= 0 01b0:err:d3d:wined3d_debug_callback 0016C6A8: "0:43(1): error: error index must be >= 0". 01b0:fixme:d3d_shader:print_glsl_info_log 0:43(1): error: error index must be >= 0
=== debian11 (build log) ===
01b4:err:d3d:wined3d_debug_callback 0027CFB0: "0:43(1): error: error index must be >= 0". 01b4:fixme:d3d_shader:print_glsl_info_log 0:43(1): error: error index must be >= 0 01b4:err:d3d:wined3d_debug_callback 0027CFB0: "0:43(1): error: error index must be >= 0". 01b4:fixme:d3d_shader:print_glsl_info_log 0:43(1): error: error index must be >= 0 01b8:err:d3d:wined3d_debug_callback 0000000000079FD0: "0:43(1): error: error index must be >= 0". 01b8:fixme:d3d_shader:print_glsl_info_log 0:43(1): error: error index must be >= 0 01b8:err:d3d:wined3d_debug_callback 0000000000079FD0: "0:43(1): error: error index must be >= 0". 01b8:fixme:d3d_shader:print_glsl_info_log 0:43(1): error: error index must be >= 0
From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/effect.c | 99 ++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 48 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index db95e6b592b..13ce63c9f04 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -436,10 +436,13 @@ state_table[] = {SC_SETSAMPLER, 0, "Sampler"}, };
-static inline void read_dword(const char **ptr, DWORD *d) +static inline DWORD read_dword(const char **ptr) { - memcpy(d, *ptr, sizeof(*d)); - *ptr += sizeof(*d); + DWORD d; + + memcpy(&d, *ptr, sizeof(d)); + *ptr += sizeof(d); + return d; }
static void skip_dword_unknown(const char **ptr, unsigned int count) @@ -450,7 +453,7 @@ static void skip_dword_unknown(const char **ptr, unsigned int count) WARN("Skipping %u unknown DWORDs:\n", count); for (i = 0; i < count; ++i) { - read_dword(ptr, &d); + d = read_dword(ptr); WARN("\t0x%08x\n", d); } } @@ -5112,7 +5115,7 @@ static HRESULT d3dx_parse_sampler(struct d3dx_effect *effect, struct d3dx_sample HRESULT hr; UINT i;
- read_dword(ptr, &sampler->state_count); + sampler->state_count = read_dword(ptr); TRACE("Count: %u\n", sampler->state_count);
sampler->states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler->states) * sampler->state_count); @@ -5212,7 +5215,7 @@ static HRESULT d3dx_parse_value(struct d3dx_effect *effect, struct d3dx_paramete case D3DXPT_TEXTURECUBE: case D3DXPT_PIXELSHADER: case D3DXPT_VERTEXSHADER: - read_dword(ptr, ¶m->object_id); + param->object_id = read_dword(ptr); TRACE("Id: %u\n", param->object_id); objects[param->object_id].param = param; param->data = value; @@ -5309,7 +5312,7 @@ static HRESULT d3dx9_parse_name(char **name, const char *ptr) { DWORD size;
- read_dword(&ptr, &size); + size = read_dword(&ptr); TRACE("Name size: %#x\n", size);
if (!size) @@ -5345,7 +5348,7 @@ static HRESULT d3dx9_copy_data(struct d3dx_effect *effect, unsigned int object_i object->data = NULL; }
- read_dword(ptr, &object->size); + object->size = read_dword(ptr); TRACE("Data size: %#x.\n", object->size);
if (!object->size) @@ -5459,13 +5462,13 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx
if (!parent) { - read_dword(ptr, (DWORD *)¶m->type); + param->type = read_dword(ptr); TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
- read_dword(ptr, (DWORD *)¶m->class); + param->class = read_dword(ptr); TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Type name offset: %#x\n", offset); hr = d3dx9_parse_name(¶m->name, data + offset); if (hr != D3D_OK) @@ -5474,7 +5477,7 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx goto err_out; }
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Type semantic offset: %#x\n", offset); hr = d3dx9_parse_name(¶m->semantic, data + offset); if (hr != D3D_OK) @@ -5483,16 +5486,16 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx goto err_out; }
- read_dword(ptr, ¶m->element_count); + param->element_count = read_dword(ptr); TRACE("Elements: %u\n", param->element_count);
switch (param->class) { case D3DXPC_VECTOR: - read_dword(ptr, ¶m->columns); + param->columns = read_dword(ptr); TRACE("Columns: %u\n", param->columns);
- read_dword(ptr, ¶m->rows); + param->rows = read_dword(ptr); TRACE("Rows: %u\n", param->rows);
/* sizeof(DWORD) * rows * columns */ @@ -5502,10 +5505,10 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx case D3DXPC_SCALAR: case D3DXPC_MATRIX_ROWS: case D3DXPC_MATRIX_COLUMNS: - read_dword(ptr, ¶m->rows); + param->rows = read_dword(ptr); TRACE("Rows: %u\n", param->rows);
- read_dword(ptr, ¶m->columns); + param->columns = read_dword(ptr); TRACE("Columns: %u\n", param->columns);
/* sizeof(DWORD) * rows * columns */ @@ -5513,7 +5516,7 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx break;
case D3DXPC_STRUCT: - read_dword(ptr, ¶m->member_count); + param->member_count = read_dword(ptr); TRACE("Members: %u\n", param->member_count); break;
@@ -5651,7 +5654,7 @@ static HRESULT d3dx_parse_effect_annotation(struct d3dx_effect *effect, struct d
anno->flags = D3DX_PARAMETER_ANNOTATION;
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Typedef offset: %#x\n", offset); ptr2 = data + offset; hr = d3dx_parse_effect_typedef(effect, anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION); @@ -5661,7 +5664,7 @@ static HRESULT d3dx_parse_effect_annotation(struct d3dx_effect *effect, struct d return hr; }
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Value offset: %#x\n", offset); hr = d3dx_parse_init_value(effect, anno, data, data + offset, objects); if (hr != D3D_OK) @@ -5685,7 +5688,7 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s
state->type = ST_CONSTANT;
- read_dword(ptr, &state->operation); + state->operation = read_dword(ptr); if (state->operation >= ARRAY_SIZE(state_table)) { WARN("Unknown state operation %u.\n", state->operation); @@ -5694,10 +5697,10 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s
TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name);
- read_dword(ptr, &state->index); + state->index = read_dword(ptr); TRACE("Index: %#x\n", state->index);
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Typedef offset: %#x\n", offset); ptr2 = data + offset; hr = d3dx_parse_effect_typedef(effect, param, data, &ptr2, NULL, 0); @@ -5707,7 +5710,7 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s goto err_out; }
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Value offset: %#x\n", offset); hr = d3dx_parse_init_value(effect, param, data, data + offset, objects); if (hr != D3D_OK) @@ -5757,17 +5760,17 @@ static HRESULT d3dx_parse_effect_parameter(struct d3dx_effect *effect, struct d3 unsigned int i; const char *ptr2;
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Typedef offset: %#x.\n", offset); ptr2 = data + offset;
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Value offset: %#x.\n", offset);
- read_dword(ptr, ¶m->param.flags); + param->param.flags = read_dword(ptr); TRACE("Flags: %#x.\n", param->param.flags);
- read_dword(ptr, ¶m->annotation_count); + param->annotation_count = read_dword(ptr); TRACE("Annotation count: %u.\n", param->annotation_count);
hr = d3dx_parse_effect_typedef(effect, ¶m->param, data, &ptr2, NULL, param->param.flags); @@ -5831,7 +5834,7 @@ static HRESULT d3dx_parse_effect_pass(struct d3dx_effect *effect, struct d3dx_pa struct d3dx_state *states = NULL; char *name = NULL;
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Pass name offset: %#x\n", offset); hr = d3dx9_parse_name(&name, data + offset); if (hr != D3D_OK) @@ -5840,10 +5843,10 @@ static HRESULT d3dx_parse_effect_pass(struct d3dx_effect *effect, struct d3dx_pa goto err_out; }
- read_dword(ptr, &pass->annotation_count); + pass->annotation_count = read_dword(ptr); TRACE("Annotation count: %u\n", pass->annotation_count);
- read_dword(ptr, &pass->state_count); + pass->state_count = read_dword(ptr); TRACE("State count: %u\n", pass->state_count);
if (pass->annotation_count) @@ -5927,7 +5930,7 @@ static HRESULT d3dx_parse_effect_technique(struct d3dx_effect *effect, struct d3 unsigned int i; char *name = NULL;
- read_dword(ptr, &offset); + offset = read_dword(ptr); TRACE("Technique name offset: %#x\n", offset); hr = d3dx9_parse_name(&name, data + offset); if (hr != D3D_OK) @@ -5936,10 +5939,10 @@ static HRESULT d3dx_parse_effect_technique(struct d3dx_effect *effect, struct d3 goto err_out; }
- read_dword(ptr, &technique->annotation_count); + technique->annotation_count = read_dword(ptr); TRACE("Annotation count: %u\n", technique->annotation_count);
- read_dword(ptr, &technique->pass_count); + technique->pass_count = read_dword(ptr); TRACE("Pass count: %u\n", technique->pass_count);
if (technique->annotation_count) @@ -6123,19 +6126,19 @@ static HRESULT d3dx_parse_resource(struct d3dx_effect *effect, const char *data, struct d3dx_object *object; HRESULT hr = E_FAIL;
- read_dword(ptr, &technique_index); + technique_index = read_dword(ptr); TRACE("technique_index: %u\n", technique_index);
- read_dword(ptr, &index); + index = read_dword(ptr); TRACE("index: %u\n", index);
- read_dword(ptr, &element_index); + element_index = read_dword(ptr); TRACE("element_index: %u\n", element_index);
- read_dword(ptr, &state_index); + state_index = read_dword(ptr); TRACE("state_index: %u\n", state_index);
- read_dword(ptr, &usage); + usage = read_dword(ptr); TRACE("usage: %u\n", usage);
if (technique_index == 0xffffffff) @@ -6308,15 +6311,15 @@ static HRESULT d3dx_parse_effect(struct d3dx_effect *effect, const char *data, U HRESULT hr; UINT i;
- read_dword(&ptr, &effect->parameter_count); + effect->parameter_count = read_dword(&ptr); TRACE("Parameter count: %u.\n", effect->parameter_count);
- read_dword(&ptr, &effect->technique_count); + effect->technique_count = read_dword(&ptr); TRACE("Technique count: %u.\n", effect->technique_count);
skip_dword_unknown(&ptr, 1);
- read_dword(&ptr, &effect->object_count); + effect->object_count = read_dword(&ptr); TRACE("Object count: %u.\n", effect->object_count);
effect->objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, @@ -6375,17 +6378,17 @@ static HRESULT d3dx_parse_effect(struct d3dx_effect *effect, const char *data, U } }
- read_dword(&ptr, &stringcount); + stringcount = read_dword(&ptr); TRACE("String count: %u.\n", stringcount);
- read_dword(&ptr, &resourcecount); + resourcecount = read_dword(&ptr); TRACE("Resource count: %u.\n", resourcecount);
for (i = 0; i < stringcount; ++i) { DWORD id;
- read_dword(&ptr, &id); + id = read_dword(&ptr); TRACE("id: %u.\n", id);
if (FAILED(hr = d3dx9_copy_data(effect, id, &ptr))) @@ -6526,7 +6529,7 @@ static HRESULT d3dx9_effect_init_from_dxbc(struct d3dx_effect *effect,
list_init(&effect->parameter_block_list);
- read_dword(&ptr, &tag); + tag = read_dword(&ptr); TRACE("Tag: %x\n", tag);
if (!(flags & D3DXFX_NOT_CLONEABLE)) @@ -6570,7 +6573,7 @@ static HRESULT d3dx9_effect_init_from_dxbc(struct d3dx_effect *effect, goto fail; } } - read_dword(&ptr, &offset); + offset = read_dword(&ptr); TRACE("Offset: %x\n", offset);
hr = d3dx_parse_effect(effect, ptr, data_size, offset, skip_constants, skip_constants_count); @@ -6669,7 +6672,7 @@ static HRESULT d3dx9_effect_init(struct d3dx_effect *effect, struct IDirect3DDev effect, device, data, data_size, defines, include, flags, errors, pool, debugstr_a(skip_constants_string));
- read_dword(&ptr, &tag); + tag = read_dword(&ptr);
if (tag == d3dx9_effect_version(9, 1)) return d3dx9_effect_init_from_dxbc(effect, device, data, data_size, flags, pool, skip_constants_string);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 16 +- dlls/d3dx9_36/effect.c | 268 +++++++++++++++++----------------- 2 files changed, 141 insertions(+), 143 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 6972c1d0ce0..44bcda0271a 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -318,13 +318,13 @@ struct d3dx_parameter void *data; D3DXPARAMETER_CLASS class; D3DXPARAMETER_TYPE type; - UINT rows; - UINT columns; - UINT element_count; - UINT member_count; - DWORD flags; - UINT bytes; - DWORD object_id; + unsigned int rows; + unsigned int columns; + unsigned int element_count; + unsigned int member_count; + uint32_t flags; + unsigned int bytes; + unsigned int object_id;
struct d3dx_parameter *members; char *semantic; @@ -336,7 +336,7 @@ struct d3dx_parameter struct d3dx_top_level_parameter { struct d3dx_parameter param; - UINT annotation_count; + unsigned int annotation_count; struct d3dx_parameter *annotations; ULONG64 update_version; ULONG64 *version_counter; diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 13ce63c9f04..b15ac514a1e 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -105,7 +105,7 @@ enum STATE_TYPE
struct d3dx_object { - UINT size; + unsigned int size; void *data; struct d3dx_parameter *param; BOOL creation_failed; @@ -113,8 +113,8 @@ struct d3dx_object
struct d3dx_state { - UINT operation; - UINT index; + unsigned int operation; + unsigned int index; enum STATE_TYPE type; struct d3dx_parameter parameter; struct d3dx_parameter *referenced_param; @@ -129,8 +129,8 @@ struct d3dx_sampler struct d3dx_pass { char *name; - UINT state_count; - UINT annotation_count; + unsigned int state_count; + unsigned int annotation_count;
struct d3dx_state *states; struct d3dx_parameter *annotations; @@ -141,8 +141,8 @@ struct d3dx_pass struct d3dx_technique { char *name; - UINT pass_count; - UINT annotation_count; + unsigned int pass_count; + unsigned int annotation_count;
struct d3dx_parameter *annotations; struct d3dx_pass *passes; @@ -436,25 +436,25 @@ state_table[] = {SC_SETSAMPLER, 0, "Sampler"}, };
-static inline DWORD read_dword(const char **ptr) +static inline uint32_t read_u32(const char **ptr) { - DWORD d; + uint32_t u;
- memcpy(&d, *ptr, sizeof(d)); - *ptr += sizeof(d); - return d; + memcpy(&u, *ptr, sizeof(u)); + *ptr += sizeof(u); + return u; }
-static void skip_dword_unknown(const char **ptr, unsigned int count) +static void skip_u32_unknown(const char **ptr, unsigned int count) { unsigned int i; - DWORD d; + uint32_t u;
WARN("Skipping %u unknown DWORDs:\n", count); for (i = 0; i < count; ++i) { - d = read_dword(ptr); - WARN("\t0x%08x\n", d); + u = read_u32(ptr); + WARN("\t0x%08x\n", u); } }
@@ -5115,7 +5115,7 @@ static HRESULT d3dx_parse_sampler(struct d3dx_effect *effect, struct d3dx_sample HRESULT hr; UINT i;
- sampler->state_count = read_dword(ptr); + sampler->state_count = read_u32(ptr); TRACE("Count: %u\n", sampler->state_count);
sampler->states = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sampler->states) * sampler->state_count); @@ -5215,7 +5215,7 @@ static HRESULT d3dx_parse_value(struct d3dx_effect *effect, struct d3dx_paramete case D3DXPT_TEXTURECUBE: case D3DXPT_PIXELSHADER: case D3DXPT_VERTEXSHADER: - param->object_id = read_dword(ptr); + param->object_id = read_u32(ptr); TRACE("Id: %u\n", param->object_id); objects[param->object_id].param = param; param->data = value; @@ -5310,10 +5310,10 @@ static HRESULT d3dx_parse_init_value(struct d3dx_effect *effect, struct d3dx_par
static HRESULT d3dx9_parse_name(char **name, const char *ptr) { - DWORD size; + unsigned int size;
- size = read_dword(&ptr); - TRACE("Name size: %#x\n", size); + size = read_u32(&ptr); + TRACE("Name size: %#x.\n", size);
if (!size) { @@ -5348,7 +5348,7 @@ static HRESULT d3dx9_copy_data(struct d3dx_effect *effect, unsigned int object_i object->data = NULL; }
- object->size = read_dword(ptr); + object->size = read_u32(ptr); TRACE("Data size: %#x.\n", object->size);
if (!object->size) @@ -5454,7 +5454,7 @@ static void add_param_to_tree(struct d3dx_effect *effect, struct d3dx_parameter static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx_parameter *param, const char *data, const char **ptr, struct d3dx_parameter *parent, UINT flags) { - DWORD offset; + uint32_t offset; HRESULT hr; UINT i;
@@ -5462,14 +5462,14 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx
if (!parent) { - param->type = read_dword(ptr); - TRACE("Type: %s\n", debug_d3dxparameter_type(param->type)); + param->type = read_u32(ptr); + TRACE("Type: %s.\n", debug_d3dxparameter_type(param->type));
- param->class = read_dword(ptr); - TRACE("Class: %s\n", debug_d3dxparameter_class(param->class)); + param->class = read_u32(ptr); + TRACE("Class: %s.\n", debug_d3dxparameter_class(param->class));
- offset = read_dword(ptr); - TRACE("Type name offset: %#x\n", offset); + offset = read_u32(ptr); + TRACE("Type name offset: %#x.\n", offset); hr = d3dx9_parse_name(¶m->name, data + offset); if (hr != D3D_OK) { @@ -5477,8 +5477,8 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx goto err_out; }
- offset = read_dword(ptr); - TRACE("Type semantic offset: %#x\n", offset); + offset = read_u32(ptr); + TRACE("Type semantic offset: %#x.\n", offset); hr = d3dx9_parse_name(¶m->semantic, data + offset); if (hr != D3D_OK) { @@ -5486,17 +5486,17 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx goto err_out; }
- param->element_count = read_dword(ptr); - TRACE("Elements: %u\n", param->element_count); + param->element_count = read_u32(ptr); + TRACE("Elements: %u.\n", param->element_count);
switch (param->class) { case D3DXPC_VECTOR: - param->columns = read_dword(ptr); - TRACE("Columns: %u\n", param->columns); + param->columns = read_u32(ptr); + TRACE("Columns: %u.\n", param->columns);
- param->rows = read_dword(ptr); - TRACE("Rows: %u\n", param->rows); + param->rows = read_u32(ptr); + TRACE("Rows: %u.\n", param->rows);
/* sizeof(DWORD) * rows * columns */ param->bytes = 4 * param->rows * param->columns; @@ -5505,19 +5505,19 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx case D3DXPC_SCALAR: case D3DXPC_MATRIX_ROWS: case D3DXPC_MATRIX_COLUMNS: - param->rows = read_dword(ptr); - TRACE("Rows: %u\n", param->rows); + param->rows = read_u32(ptr); + TRACE("Rows: %u.\n", param->rows);
- param->columns = read_dword(ptr); - TRACE("Columns: %u\n", param->columns); + param->columns = read_u32(ptr); + TRACE("Columns: %u.\n", param->columns);
/* sizeof(DWORD) * rows * columns */ param->bytes = 4 * param->rows * param->columns; break;
case D3DXPC_STRUCT: - param->member_count = read_dword(ptr); - TRACE("Members: %u\n", param->member_count); + param->member_count = read_u32(ptr); + TRACE("Members: %u.\n", param->member_count); break;
case D3DXPC_OBJECT: @@ -5543,13 +5543,13 @@ static HRESULT d3dx_parse_effect_typedef(struct d3dx_effect *effect, struct d3dx break;
default: - FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type)); + FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(param->type)); break; } break;
default: - FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class)); + FIXME("Unhandled class %s.\n", debug_d3dxparameter_class(param->class)); break; } } @@ -5648,28 +5648,28 @@ err_out: static HRESULT d3dx_parse_effect_annotation(struct d3dx_effect *effect, struct d3dx_parameter *anno, const char *data, const char **ptr, struct d3dx_object *objects) { - DWORD offset; const char *ptr2; + uint32_t offset; HRESULT hr;
anno->flags = D3DX_PARAMETER_ANNOTATION;
- offset = read_dword(ptr); - TRACE("Typedef offset: %#x\n", offset); + offset = read_u32(ptr); + TRACE("Typedef offset: %#x.\n", offset); ptr2 = data + offset; hr = d3dx_parse_effect_typedef(effect, anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION); if (hr != D3D_OK) { - WARN("Failed to parse type definition\n"); + WARN("Failed to parse type definition.\n"); return hr; }
- offset = read_dword(ptr); - TRACE("Value offset: %#x\n", offset); + offset = read_u32(ptr); + TRACE("Value offset: %#x.\n", offset); hr = d3dx_parse_init_value(effect, anno, data, data + offset, objects); if (hr != D3D_OK) { - WARN("Failed to parse value\n"); + WARN("Failed to parse value.\n"); return hr; }
@@ -5682,26 +5682,25 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s struct d3dx_parameter *param = &state->parameter; enum STATE_CLASS state_class; const char *ptr2; + uint32_t offset; void *new_data; - DWORD offset; HRESULT hr;
state->type = ST_CONSTANT;
- state->operation = read_dword(ptr); + state->operation = read_u32(ptr); if (state->operation >= ARRAY_SIZE(state_table)) { WARN("Unknown state operation %u.\n", state->operation); return D3DERR_INVALIDCALL; } + TRACE("Operation: %#x (%s).\n", state->operation, state_table[state->operation].name);
- TRACE("Operation: %#x (%s)\n", state->operation, state_table[state->operation].name); - - state->index = read_dword(ptr); - TRACE("Index: %#x\n", state->index); + state->index = read_u32(ptr); + TRACE("Index: %#x.\n", state->index);
- offset = read_dword(ptr); - TRACE("Typedef offset: %#x\n", offset); + offset = read_u32(ptr); + TRACE("Typedef offset: %#x.\n", offset); ptr2 = data + offset; hr = d3dx_parse_effect_typedef(effect, param, data, &ptr2, NULL, 0); if (hr != D3D_OK) @@ -5710,8 +5709,8 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s goto err_out; }
- offset = read_dword(ptr); - TRACE("Value offset: %#x\n", offset); + offset = read_u32(ptr); + TRACE("Value offset: %#x.\n", offset); hr = d3dx_parse_init_value(effect, param, data, data + offset, objects); if (hr != D3D_OK) { @@ -5755,22 +5754,22 @@ err_out: static HRESULT d3dx_parse_effect_parameter(struct d3dx_effect *effect, struct d3dx_top_level_parameter *param, const char *data, const char **ptr, struct d3dx_object *objects) { - DWORD offset; - HRESULT hr; - unsigned int i; const char *ptr2; + uint32_t offset; + unsigned int i; + HRESULT hr;
- offset = read_dword(ptr); + offset = read_u32(ptr); TRACE("Typedef offset: %#x.\n", offset); ptr2 = data + offset;
- offset = read_dword(ptr); + offset = read_u32(ptr); TRACE("Value offset: %#x.\n", offset);
- param->param.flags = read_dword(ptr); + param->param.flags = read_u32(ptr); TRACE("Flags: %#x.\n", param->param.flags);
- param->annotation_count = read_dword(ptr); + param->annotation_count = read_u32(ptr); TRACE("Annotation count: %u.\n", param->annotation_count);
hr = d3dx_parse_effect_typedef(effect, ¶m->param, data, &ptr2, NULL, param->param.flags); @@ -5828,26 +5827,26 @@ err_out: static HRESULT d3dx_parse_effect_pass(struct d3dx_effect *effect, struct d3dx_pass *pass, const char *data, const char **ptr, struct d3dx_object *objects) { - DWORD offset; - HRESULT hr; - unsigned int i; struct d3dx_state *states = NULL; char *name = NULL; + uint32_t offset; + unsigned int i; + HRESULT hr;
- offset = read_dword(ptr); - TRACE("Pass name offset: %#x\n", offset); + offset = read_u32(ptr); + TRACE("Pass name offset: %#x.\n", offset); hr = d3dx9_parse_name(&name, data + offset); if (hr != D3D_OK) { - WARN("Failed to parse name\n"); + WARN("Failed to parse name.\n"); goto err_out; }
- pass->annotation_count = read_dword(ptr); - TRACE("Annotation count: %u\n", pass->annotation_count); + pass->annotation_count = read_u32(ptr); + TRACE("Annotation count: %u.\n", pass->annotation_count);
- pass->state_count = read_dword(ptr); - TRACE("State count: %u\n", pass->state_count); + pass->state_count = read_u32(ptr); + TRACE("State count: %u.\n", pass->state_count);
if (pass->annotation_count) { @@ -5925,13 +5924,13 @@ err_out: static HRESULT d3dx_parse_effect_technique(struct d3dx_effect *effect, struct d3dx_technique *technique, const char *data, const char **ptr, struct d3dx_object *objects) { - DWORD offset; - HRESULT hr; - unsigned int i; char *name = NULL; + uint32_t offset; + unsigned int i; + HRESULT hr;
- offset = read_dword(ptr); - TRACE("Technique name offset: %#x\n", offset); + offset = read_u32(ptr); + TRACE("Technique name offset: %#x.\n", offset); hr = d3dx9_parse_name(&name, data + offset); if (hr != D3D_OK) { @@ -5939,11 +5938,11 @@ static HRESULT d3dx_parse_effect_technique(struct d3dx_effect *effect, struct d3 goto err_out; }
- technique->annotation_count = read_dword(ptr); - TRACE("Annotation count: %u\n", technique->annotation_count); + technique->annotation_count = read_u32(ptr); + TRACE("Annotation count: %u.\n", technique->annotation_count);
- technique->pass_count = read_dword(ptr); - TRACE("Pass count: %u\n", technique->pass_count); + technique->pass_count = read_u32(ptr); + TRACE("Pass count: %u.\n", technique->pass_count);
if (technique->annotation_count) { @@ -6062,15 +6061,15 @@ static HRESULT d3dx9_create_object(struct d3dx_effect *effect, struct d3dx_objec static HRESULT d3dx_parse_array_selector(struct d3dx_effect *effect, struct d3dx_state *state, const char **skip_constants, unsigned int skip_constants_count) { - DWORD string_size; struct d3dx_parameter *param = &state->parameter; struct d3dx_object *object = &effect->objects[param->object_id]; char *ptr = object->data; + uint32_t string_size; HRESULT ret;
TRACE("Parsing array entry selection state for parameter %p.\n", param);
- string_size = *(DWORD *)ptr; + string_size = *(uint32_t *)ptr; state->referenced_param = get_parameter_by_name(effect, NULL, ptr + 4); if (state->referenced_param) { @@ -6081,12 +6080,12 @@ static HRESULT d3dx_parse_array_selector(struct d3dx_effect *effect, struct d3dx FIXME("Referenced parameter %s not found.\n", ptr + 4); return D3DXERR_INVALIDDATA; } - TRACE("Unknown DWORD: 0x%.8x.\n", *(DWORD *)(ptr + string_size)); + TRACE("Unknown u32: 0x%.8x.\n", *(uint32_t *)(ptr + string_size));
- if (string_size % sizeof(DWORD)) + if (string_size % sizeof(uint32_t)) FIXME("Unaligned string_size %u.\n", string_size); - if (FAILED(ret = d3dx_create_param_eval(effect, (DWORD *)(ptr + string_size) + 1, - object->size - (string_size + sizeof(DWORD)), D3DXPT_INT, ¶m->param_eval, + if (FAILED(ret = d3dx_create_param_eval(effect, (uint32_t *)(ptr + string_size) + 1, + object->size - (string_size + sizeof(uint32_t)), D3DXPT_INT, ¶m->param_eval, get_version_counter_ptr(effect), NULL, 0))) return ret; ret = D3D_OK; @@ -6119,27 +6118,26 @@ static HRESULT d3dx_parse_array_selector(struct d3dx_effect *effect, struct d3dx static HRESULT d3dx_parse_resource(struct d3dx_effect *effect, const char *data, const char **ptr, const char **skip_constants, unsigned int skip_constants_count) { - DWORD technique_index; - DWORD index, state_index, usage, element_index; - struct d3dx_state *state; + unsigned int index, state_index, usage, element_index, technique_index; struct d3dx_parameter *param; struct d3dx_object *object; + struct d3dx_state *state; HRESULT hr = E_FAIL;
- technique_index = read_dword(ptr); - TRACE("technique_index: %u\n", technique_index); + technique_index = read_u32(ptr); + TRACE("technique_index: %u.\n", technique_index);
- index = read_dword(ptr); - TRACE("index: %u\n", index); + index = read_u32(ptr); + TRACE("index: %u.\n", index);
- element_index = read_dword(ptr); - TRACE("element_index: %u\n", element_index); + element_index = read_u32(ptr); + TRACE("element_index: %u.\n", element_index);
- state_index = read_dword(ptr); - TRACE("state_index: %u\n", state_index); + state_index = read_u32(ptr); + TRACE("state_index: %u.\n", state_index);
- usage = read_dword(ptr); - TRACE("usage: %u\n", usage); + usage = read_u32(ptr); + TRACE("usage: %u.\n", usage);
if (technique_index == 0xffffffff) { @@ -6148,7 +6146,7 @@ static HRESULT d3dx_parse_resource(struct d3dx_effect *effect, const char *data,
if (index >= effect->parameter_count) { - FIXME("Index out of bounds: index %u >= parameter_count %u\n", index, effect->parameter_count); + FIXME("Index out of bounds: index %u >= parameter_count %u.\n", index, effect->parameter_count); return E_FAIL; }
@@ -6157,7 +6155,7 @@ static HRESULT d3dx_parse_resource(struct d3dx_effect *effect, const char *data, { if (element_index >= parameter->element_count && parameter->element_count != 0) { - FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index, parameter->element_count); + FIXME("Index out of bounds: element_index %u >= element_count %u.\n", element_index, parameter->element_count); return E_FAIL; }
@@ -6168,7 +6166,7 @@ static HRESULT d3dx_parse_resource(struct d3dx_effect *effect, const char *data, sampler = parameter->data; if (state_index >= sampler->state_count) { - FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, sampler->state_count); + FIXME("Index out of bounds: state_index %u >= state_count %u.\n", state_index, sampler->state_count); return E_FAIL; }
@@ -6189,14 +6187,14 @@ static HRESULT d3dx_parse_resource(struct d3dx_effect *effect, const char *data, technique = &effect->techniques[technique_index]; if (index >= technique->pass_count) { - FIXME("Index out of bounds: index %u >= pass_count %u\n", index, technique->pass_count); + FIXME("Index out of bounds: index %u >= pass_count %u.\n", index, technique->pass_count); return E_FAIL; }
pass = &technique->passes[index]; if (state_index >= pass->state_count) { - FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index, pass->state_count); + FIXME("Index out of bounds: state_index %u >= state_count %u.\n", state_index, pass->state_count); return E_FAIL; }
@@ -6290,7 +6288,7 @@ static HRESULT d3dx_parse_resource(struct d3dx_effect *effect, const char *data, break;
default: - FIXME("Unknown usage %x\n", usage); + FIXME("Unknown usage %u.\n", usage); break; }
@@ -6304,22 +6302,22 @@ static BOOL param_set_top_level_param(void *top_level_param, struct d3dx_paramet }
static HRESULT d3dx_parse_effect(struct d3dx_effect *effect, const char *data, UINT data_size, - DWORD start, const char **skip_constants, unsigned int skip_constants_count) + uint32_t start, const char **skip_constants, unsigned int skip_constants_count) { + unsigned int string_count, resource_count; const char *ptr = data + start; - UINT stringcount, resourcecount; + unsigned int i; HRESULT hr; - UINT i;
- effect->parameter_count = read_dword(&ptr); + effect->parameter_count = read_u32(&ptr); TRACE("Parameter count: %u.\n", effect->parameter_count);
- effect->technique_count = read_dword(&ptr); + effect->technique_count = read_u32(&ptr); TRACE("Technique count: %u.\n", effect->technique_count);
- skip_dword_unknown(&ptr, 1); + skip_u32_unknown(&ptr, 1);
- effect->object_count = read_dword(&ptr); + effect->object_count = read_u32(&ptr); TRACE("Object count: %u.\n", effect->object_count);
effect->objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, @@ -6378,17 +6376,17 @@ static HRESULT d3dx_parse_effect(struct d3dx_effect *effect, const char *data, U } }
- stringcount = read_dword(&ptr); - TRACE("String count: %u.\n", stringcount); + string_count = read_u32(&ptr); + TRACE("String count: %u.\n", string_count);
- resourcecount = read_dword(&ptr); - TRACE("Resource count: %u.\n", resourcecount); + resource_count = read_u32(&ptr); + TRACE("Resource count: %u.\n", resource_count);
- for (i = 0; i < stringcount; ++i) + for (i = 0; i < string_count; ++i) { - DWORD id; + unsigned int id;
- id = read_dword(&ptr); + id = read_u32(&ptr); TRACE("id: %u.\n", id);
if (FAILED(hr = d3dx9_copy_data(effect, id, &ptr))) @@ -6401,7 +6399,7 @@ static HRESULT d3dx_parse_effect(struct d3dx_effect *effect, const char *data, U } }
- for (i = 0; i < resourcecount; ++i) + for (i = 0; i < resource_count; ++i) { TRACE("parse resource %u.\n", i);
@@ -6518,7 +6516,7 @@ static HRESULT d3dx9_effect_init_from_dxbc(struct d3dx_effect *effect, char *skip_constants_buffer = NULL; const char **skip_constants = NULL; const char *ptr = data; - DWORD tag, offset; + uint32_t tag, offset; unsigned int i, j; HRESULT hr;
@@ -6529,8 +6527,8 @@ static HRESULT d3dx9_effect_init_from_dxbc(struct d3dx_effect *effect,
list_init(&effect->parameter_block_list);
- tag = read_dword(&ptr); - TRACE("Tag: %x\n", tag); + tag = read_u32(&ptr); + TRACE("Tag: %#x.\n", tag);
if (!(flags & D3DXFX_NOT_CLONEABLE)) { @@ -6573,8 +6571,8 @@ static HRESULT d3dx9_effect_init_from_dxbc(struct d3dx_effect *effect, goto fail; } } - offset = read_dword(&ptr); - TRACE("Offset: %x\n", offset); + offset = read_u32(&ptr); + TRACE("Offset: %#x.\n", offset);
hr = d3dx_parse_effect(effect, ptr, data_size, offset, skip_constants, skip_constants_count); if (hr != D3D_OK) @@ -6664,15 +6662,15 @@ static HRESULT d3dx9_effect_init(struct d3dx_effect *effect, struct IDirect3DDev #endif ID3DBlob *bytecode = NULL, *temp_errors = NULL; const char *ptr = data; + unsigned int tag; HRESULT hr; - DWORD tag;
TRACE("effect %p, device %p, data %p, data_size %lu, defines %p, include %p, flags %#x, errors %p, " "pool %p, skip_constants %s.\n", effect, device, data, data_size, defines, include, flags, errors, pool, debugstr_a(skip_constants_string));
- tag = read_dword(&ptr); + tag = read_u32(&ptr);
if (tag == d3dx9_effect_version(9, 1)) return d3dx9_effect_init_from_dxbc(effect, device, data, data_size, flags, pool, skip_constants_string);
From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 3 ++- dlls/d3dx9_36/mesh.c | 2 +- dlls/d3dx9_36/shader.c | 21 +++++++++++---------- dlls/d3dx9_36/surface.c | 6 +++--- dlls/d3dx9_36/volume.c | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 44bcda0271a..7ee754b104a 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -230,7 +230,8 @@ static inline BOOL is_param_type_sampler(D3DXPARAMETER_TYPE type) /* Returns the smallest power of 2 which is greater than or equal to num */ static inline uint32_t make_pow2(uint32_t num) { - uint32_t index; + DWORD index; + return BitScanReverse(&index, num - 1) ? 1u << (index + 1) : 1; }
diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c index 6cfe97492f3..f74fba6e424 100644 --- a/dlls/d3dx9_36/mesh.c +++ b/dlls/d3dx9_36/mesh.c @@ -54,7 +54,7 @@ struct d3dx9_mesh IDirect3DVertexBuffer9 *vertex_buffer; IDirect3DIndexBuffer9 *index_buffer; DWORD *attrib_buffer; - int attrib_buffer_lock_count; + LONG attrib_buffer_lock_count; DWORD attrib_table_size; D3DXATTRIBUTERANGE *attrib_table; }; diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c index 2241455898e..eae01674c0a 100644 --- a/dlls/d3dx9_36/shader.c +++ b/dlls/d3dx9_36/shader.c @@ -281,7 +281,7 @@ static HRESULT WINAPI d3dx_include_from_file_open(ID3DXInclude *iface, D3DXINCLU if(!buffer) goto error; *buffer = pathname; - if(!ReadFile(file, buffer + 1, size, bytes, NULL)) + if (!ReadFile(file, buffer + 1, size, (DWORD *)bytes, NULL)) goto error;
*data = buffer + 1; @@ -339,11 +339,11 @@ HRESULT WINAPI D3DXAssembleShaderFromFileA(const char *filename, const D3DXMACRO HRESULT WINAPI D3DXAssembleShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages) { - const void *buffer; - DWORD len; - HRESULT hr; struct d3dx_include_from_file include_from_file; + const void *buffer; + unsigned int len; char *filename_a; + HRESULT hr;
TRACE("filename %s, defines %p, include %p, flags %#x, shader %p, error_messages %p.\n", debugstr_w(filename), defines, include, flags, shader, error_messages); @@ -475,11 +475,12 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO ID3DXInclude *include, const char *entrypoint, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_messages, ID3DXConstantTable **constant_table) { - const void *buffer; - DWORD len, filename_len; - HRESULT hr; struct d3dx_include_from_file include_from_file; + unsigned int filename_len; + const void *buffer; char *filename_a; + HRESULT hr; + UINT len;
TRACE("filename %s, defines %p, include %p, entrypoint %s, profile %s, " "flags %#x, shader %p, error_messages %p, constant_table %p.\n", @@ -603,11 +604,11 @@ HRESULT WINAPI D3DXPreprocessShaderFromFileA(const char *filename, const D3DXMAC HRESULT WINAPI D3DXPreprocessShaderFromFileW(const WCHAR *filename, const D3DXMACRO *defines, ID3DXInclude *include, ID3DXBuffer **shader, ID3DXBuffer **error_messages) { - const void *buffer; - DWORD len; - HRESULT hr; struct d3dx_include_from_file include_from_file; + const void *buffer; char *filename_a; + HRESULT hr; + UINT len;
TRACE("filename %s, defines %p, include %p, shader %p, error_messages %p.\n", debugstr_w(filename), defines, include, shader, error_messages); diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 2ca6f093b55..39733d3ef7e 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -1391,7 +1391,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileW(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, const WCHAR *src_file, const RECT *src_rect, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info) { - UINT data_size; + DWORD data_size; void *data; HRESULT hr;
@@ -1417,7 +1417,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromResourceA(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, HMODULE src_module, const char *resource, const RECT *src_rect, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info) { - UINT data_size; + DWORD data_size; HRSRC resinfo; void *data;
@@ -1445,7 +1445,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromResourceW(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, HMODULE src_module, const WCHAR *resource, const RECT *src_rect, DWORD filter, D3DCOLOR color_key, D3DXIMAGE_INFO *src_info) { - UINT data_size; + DWORD data_size; HRSRC resinfo; void *data;
diff --git a/dlls/d3dx9_36/volume.c b/dlls/d3dx9_36/volume.c index 93afaa16b10..d601650cff5 100644 --- a/dlls/d3dx9_36/volume.c +++ b/dlls/d3dx9_36/volume.c @@ -60,9 +60,9 @@ HRESULT WINAPI D3DXLoadVolumeFromFileW(IDirect3DVolume9 *dst_volume, D3DCOLOR color_key, D3DXIMAGE_INFO *info) { + DWORD data_size; HRESULT hr; void *data; - UINT data_size;
TRACE("(%p, %p, %p, %s, %p, %#x, %#x, %p)\n", dst_volume, dst_palette, dst_box, debugstr_w(filename), src_box,
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=113530
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w7u_adm (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w7u_el (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w8 (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w8adm (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w864 (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w1064v1809 (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w1064 (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w1064_tsign (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w10pro64 (32 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w864 (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w1064v1809 (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w1064 (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w1064_2qxl (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w1064_tsign (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w10pro64 (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w10pro64_ar (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w10pro64_he (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w10pro64_ja (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
=== w10pro64_zh_CN (64 bit report) ===
d3dx9_36: asm.c:284: Test failed: D3DXAssembleShader test failed with error 0x88760b59 - 2905
On Wed, Apr 27, 2022 at 10:58 AM Marvin testbot@winehq.org wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=113530
Your paranoid android.
Let's ignore the first two patches of the series for the time being...