Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 112 ++++++++++++++++++++++++++ 1 file changed, 112 insertions(+)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 7f391833f39..0e50084fb91 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -730,6 +730,117 @@ static void test_array_dimensions(void) release_test_context(&test_context); }
+static void check_constant_desc(const char *prefix, const D3DXCONSTANT_DESC *desc, const D3DXCONSTANT_DESC *expect) +{ + ok(!strcmp(desc->Name, expect->Name), "%s: got Name %s.\n", prefix, debugstr_a(desc->Name)); + ok(desc->RegisterSet == expect->RegisterSet, "%s: got RegisterSet %#x.\n", prefix, desc->RegisterSet); + ok(desc->RegisterCount == expect->RegisterCount, "%s: got RegisterCount %u.\n", prefix, desc->RegisterCount); + ok(desc->Class == expect->Class, "%s: got Class %#x.\n", prefix, desc->Class); + ok(desc->Type == expect->Type, "%s: got Type %#x.\n", prefix, desc->Type); + ok(desc->Rows == expect->Rows, "%s: got Rows %u.\n", prefix, desc->Rows); + ok(desc->Columns == expect->Columns, "%s: got Columns %u.\n", prefix, desc->Columns); + ok(desc->Elements == expect->Elements, "%s: got Elements %u.\n", prefix, desc->Elements); + ok(desc->StructMembers == expect->StructMembers, "%s: got StructMembers %u.\n", prefix, desc->StructMembers); + ok(desc->Bytes == expect->Bytes, "%s: got Bytes %u.\n", prefix, desc->Bytes); + ok(!desc->DefaultValue, "%s: got DefaultValue %p.\n", prefix, desc->DefaultValue); +} + +static void test_constant_table(void) +{ + static const char *source = + "uniform float4 a;\n" + "uniform float b;\n" + "uniform float unused;\n" + "uniform float3x1 c;\n" + "uniform row_major float3x1 d;\n" + "uniform uint e;\n" + "uniform struct\n" + "{\n" + " float2x2 a;\n" + " float b;\n" + " float c;\n" + "} f;\n" + "uniform float g[5];\n" + "float4 main(uniform float4 h) : COLOR\n" + "{\n" + " return a + b + c._31 + d._31 + f.c + g[e] + h;\n" + "}"; + + D3DXCONSTANTTABLE_DESC table_desc; + ID3DXConstantTable *constants; + D3DXHANDLE handle, field; + D3DXCONSTANT_DESC desc; + ID3D10Blob *ps_code; + unsigned int i, j; + HRESULT hr; + UINT count; + + static const D3DXCONSTANT_DESC expect_constants[] = + { + {"$h", D3DXRS_FLOAT4, 0, 1, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 1, 0, 16}, + {"a", D3DXRS_FLOAT4, 0, 1, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 1, 0, 16}, + {"b", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0, 4}, + {"c", D3DXRS_FLOAT4, 0, 1, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 3, 1, 1, 0, 12}, + {"d", D3DXRS_FLOAT4, 0, 3, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 1, 1, 0, 12}, + {"e", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_INT, 1, 1, 1, 0, 4}, + {"f", D3DXRS_FLOAT4, 0, 4, D3DXPC_STRUCT, D3DXPT_VOID, 1, 6, 1, 3, 24}, + {"g", D3DXRS_FLOAT4, 0, 5, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 5, 0, 20}, + }; + + static const D3DXCONSTANT_DESC expect_fields[] = + { + {"a", D3DXRS_FLOAT4, 0, 2, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 2, 2, 1, 0, 16}, + {"b", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0, 4}, + {"c", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0, 4}, + }; + + todo_wine ps_code = compile_shader(source, "ps_2_0"); + if (!ps_code) + return; + + hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants); + ok(hr == D3D_OK, "Got hr %#x.\n", hr); + + hr = ID3DXConstantTable_GetDesc(constants, &table_desc); + ok(hr == D3D_OK, "Got hr %#x.\n", hr); + ok(table_desc.Version == D3DPS_VERSION(2, 0), "Got Version %#x.\n", table_desc.Version); + ok(table_desc.Constants == 8, "Got %u constants.\n", table_desc.Constants); + + for (i = 0; i < table_desc.Constants; ++i) + { + char prefix[30]; + + handle = ID3DXConstantTable_GetConstant(constants, NULL, i); + ok(!!handle, "Failed to get constant.\n"); + memset(&desc, 0xcc, sizeof(desc)); + count = 1; + hr = ID3DXConstantTable_GetConstantDesc(constants, handle, &desc, &count); + ok(hr == D3D_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + sprintf(prefix, "Test %u", i); + check_constant_desc(prefix, &desc, &expect_constants[i]); + + if (!strcmp(desc.Name, "f")) + { + for (j = 0; j < ARRAY_SIZE(expect_fields); ++j) + { + field = ID3DXConstantTable_GetConstant(constants, handle, j); + ok(!!field, "Failed to get constant.\n"); + memset(&desc, 0xcc, sizeof(desc)); + count = 1; + hr = ID3DXConstantTable_GetConstantDesc(constants, field, &desc, &count); + ok(hr == D3D_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + sprintf(prefix, "Test %u, %u", i, j); + check_constant_desc(prefix, &desc, &expect_fields[j]); + } + } + } + + ID3DXConstantTable_Release(constants); + ID3D10Blob_Release(ps_code); +} + static void test_fail(void) { static const char *tests[] = @@ -874,5 +985,6 @@ START_TEST(hlsl_d3d9) test_comma(); test_return(); test_array_dimensions(); + test_constant_table(); test_fail(); }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/tests/hlsl_d3d11.c | 174 +++++++++++++++++++++++++ 1 file changed, 174 insertions(+)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c index ed95457f1c7..8975268c544 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c @@ -523,6 +523,178 @@ static void test_trig(void) release_test_context(&test_context); }
+static void check_type_desc(const char *prefix, const D3D11_SHADER_TYPE_DESC *type, + const D3D11_SHADER_TYPE_DESC *expect) +{ + ok(type->Class == expect->Class, "%s: got class %#x.\n", prefix, type->Class); + ok(type->Type == expect->Type, "%s: got type %#x.\n", prefix, type->Type); + ok(type->Rows == expect->Rows, "%s: got %u rows.\n", prefix, type->Rows); + ok(type->Columns == expect->Columns, "%s: got %u columns.\n", prefix, type->Columns); + ok(type->Elements == expect->Elements, "%s: got %u elements.\n", prefix, type->Elements); + ok(type->Members == expect->Members, "%s: got %u members.\n", prefix, type->Members); + ok(type->Offset == expect->Offset, "%s: got %u members.\n", prefix, type->Members); + ok(!strcmp(type->Name, expect->Name), "%s: got name %s.\n", prefix, debugstr_a(type->Name)); +} + +static void test_reflection(void) +{ + ID3D11ShaderReflectionConstantBuffer *cbuffer; + ID3D11ShaderReflectionType *type, *field; + D3D11_SHADER_BUFFER_DESC buffer_desc; + ID3D11ShaderReflectionVariable *var; + D3D11_SHADER_VARIABLE_DESC var_desc; + ID3D11ShaderReflection *reflection; + D3D11_SHADER_TYPE_DESC type_desc; + unsigned int i, j, k; + ID3D10Blob *vs_code; + ULONG refcount; + HRESULT hr; + + static const char vs_source[] = + "typedef uint uint_t;\n" + "cbuffer b1\n" + "{\n" + " float a;\n" + " float2 b;\n" + " float4 c;\n" + " float d;\n" + " struct\n" + " {\n" + " float4 a;\n" + " float b;\n" + " float c;\n" + " } s;\n" + " float g;\n" + " float h[2];\n" + " int i;\n" + " uint_t j;\n" + " float3x1 k;\n" + " row_major float3x1 l;\n" + "};\n" + "\n" + "float m;\n" + "\n" + "float4 main(uniform float4 n) : SV_POSITION\n" + "{\n" + " return l._31 + m + n;\n" + "}"; + + struct shader_variable + { + D3D11_SHADER_VARIABLE_DESC var_desc; + D3D11_SHADER_TYPE_DESC type_desc; + }; + + static const D3D11_SHADER_TYPE_DESC field_types[] = + { + {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}, + {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 16, "float"}, + {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 20, "float"}, + }; + + static const struct shader_variable globals_vars = + {{"m", 0, 4, D3D_SVF_USED}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}}; + static const struct shader_variable params_vars = + {{"n", 0, 16, D3D_SVF_USED}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}}; + static const struct shader_variable buffer_vars[] = + { + {{"a", 0, 4}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}}, + {{"b", 4, 8}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 2, 0, 0, 0, "float2"}}, + {{"c", 16, 16}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}}, + {{"d", 32, 4}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}}, + {{"s", 48, 24}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 6, 0, 3, 0, "<unnamed>"}}, + {{"g", 72, 4}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}}, + {{"h", 80, 20}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 2, 0, 0, "float"}}, + {{"i", 100, 4}, {D3D_SVC_SCALAR, D3D_SVT_INT, 1, 1, 0, 0, 0, "int"}}, + {{"j", 104, 4}, {D3D_SVC_SCALAR, D3D_SVT_UINT, 1, 1, 0, 0, 0, "uint_t"}}, + {{"k", 112, 12}, {D3D_SVC_MATRIX_COLUMNS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}}, + {{"l", 128, 36, D3D_SVF_USED}, {D3D_SVC_MATRIX_ROWS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}}, + }; + + static const struct + { + D3D11_SHADER_BUFFER_DESC desc; + const struct shader_variable *vars; + } + vs_buffers[] = + { + {{"$Globals", D3D_CT_CBUFFER, 1, 16}, &globals_vars}, + {{"$Params", D3D_CT_CBUFFER, 1, 16}, ¶ms_vars}, + {{"b1", D3D_CT_CBUFFER, ARRAY_SIZE(buffer_vars), 176}, buffer_vars}, + }; + + todo_wine vs_code = compile_shader(vs_source, "vs_5_0"); + if (!vs_code) + return; + + hr = pD3DReflect(ID3D10Blob_GetBufferPointer(vs_code), ID3D10Blob_GetBufferSize(vs_code), + &IID_ID3D11ShaderReflection, (void **)&reflection); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(vs_buffers); ++i) + { + cbuffer = reflection->lpVtbl->GetConstantBufferByIndex(reflection, i); + hr = cbuffer->lpVtbl->GetDesc(cbuffer, &buffer_desc); + ok(hr == S_OK, "Test %u: got hr %#x.\n", i, hr); + ok(!strcmp(buffer_desc.Name, vs_buffers[i].desc.Name), + "Test %u: got name %s.\n", i, debugstr_a(buffer_desc.Name)); + ok(buffer_desc.Type == vs_buffers[i].desc.Type, "Test %u: got type %#x.\n", i, buffer_desc.Type); + ok(buffer_desc.Variables == vs_buffers[i].desc.Variables, + "Test %u: got %u variables.\n", i, buffer_desc.Variables); + ok(buffer_desc.Size == vs_buffers[i].desc.Size, "Test %u: got size %u.\n", i, buffer_desc.Size); + ok(buffer_desc.uFlags == vs_buffers[i].desc.uFlags, "Test %u: got flags %#x.\n", i, buffer_desc.uFlags); + + for (j = 0; j < buffer_desc.Variables; ++j) + { + const struct shader_variable *expect = &vs_buffers[i].vars[j]; + char prefix[40]; + + var = cbuffer->lpVtbl->GetVariableByIndex(cbuffer, j); + hr = var->lpVtbl->GetDesc(var, &var_desc); + ok(hr == S_OK, "Test %u, %u: got hr %#x.\n", i, j, hr); + ok(!strcmp(var_desc.Name, expect->var_desc.Name), + "Test %u, %u: got name %s.\n", i, j, debugstr_a(var_desc.Name)); + ok(var_desc.StartOffset == expect->var_desc.StartOffset, "Test %u, %u: got offset %u.\n", + i, j, var_desc.StartOffset); + ok(var_desc.Size == expect->var_desc.Size, "Test %u, %u: got size %u.\n", i, j, var_desc.Size); + ok(var_desc.uFlags == expect->var_desc.uFlags, "Test %u, %u: got flags %#x.\n", i, j, var_desc.uFlags); + ok(!var_desc.DefaultValue, "Test %u, %u: got default value %p.\n", i, j, var_desc.DefaultValue); + + type = var->lpVtbl->GetType(var); + hr = type->lpVtbl->GetDesc(type, &type_desc); + ok(hr == S_OK, "Test %u, %u: got hr %#x.\n", i, j, hr); + sprintf(prefix, "Test %u, %u", i, j); + check_type_desc(prefix, &type_desc, &expect->type_desc); + + if (!strcmp(type_desc.Name, "<unnamed>")) + { + for (k = 0; k < ARRAY_SIZE(field_types); ++k) + { + field = type->lpVtbl->GetMemberTypeByIndex(type, k); + hr = field->lpVtbl->GetDesc(field, &type_desc); + ok(hr == S_OK, "Test %u, %u, %u: got hr %#x.\n", i, j, k, hr); + sprintf(prefix, "Test %u, %u, %u", i, j, k); + check_type_desc(prefix, &type_desc, &field_types[k]); + } + } + } + } + + cbuffer = reflection->lpVtbl->GetConstantBufferByName(reflection, "$Params"); + + hr = cbuffer->lpVtbl->GetDesc(cbuffer, &buffer_desc); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!strcmp(buffer_desc.Name, "$Params"), "Got unexpected name %s.\n", debugstr_a(buffer_desc.Name)); + ok(buffer_desc.Type == D3D_CT_CBUFFER, "Got unexpected type %#x.\n", buffer_desc.Type); + ok(buffer_desc.Variables == 1, "Got %u variables.\n", buffer_desc.Variables); + ok(buffer_desc.Size == 16, "Got unexpected size %u.\n", buffer_desc.Size); + ok(!buffer_desc.uFlags, "Got unexpected flags %#x.\n", buffer_desc.uFlags); + + ID3D10Blob_Release(vs_code); + refcount = reflection->lpVtbl->Release(reflection); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); +} + static BOOL load_d3dcompiler(void) { HMODULE module; @@ -548,6 +720,8 @@ START_TEST(hlsl_d3d11) return; }
+ test_reflection(); + if (!(mod = LoadLibraryA("d3d11.dll"))) { skip("Direct3D 11 is not available.\n");
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=67036
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 Task: Patch failed to apply
This is a type modifier, and thus does not make a lot of sense on a variable.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index a24d29e5df8..498ca4bb59d 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -129,15 +129,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) BOOL ret;
TRACE("Declaring variable %s.\n", decl->name); - if (decl->data_type->type == HLSL_CLASS_MATRIX) - { - if (!(decl->modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR))) - { - decl->modifiers |= hlsl_ctx.matrix_majority == HLSL_ROW_MAJOR - ? HLSL_MODIFIER_ROW_MAJOR : HLSL_MODIFIER_COLUMN_MAJOR; - } - } - else + if (decl->data_type->type != HLSL_CLASS_MATRIX) check_invalid_matrix_modifiers(decl->modifiers, decl->loc);
if (local)
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=67037
Your paranoid android.
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 Task: Patch failed to apply
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 7 +++++++ dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 5 +++++ 2 files changed, 12 insertions(+)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 498ca4bb59d..59e0df9d8c0 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -1322,8 +1322,15 @@ func_declaration: func_prototype compound_statement pop_scope(&hlsl_ctx); }
+ /* var_modifiers is necessary to avoid shift/reduce conflicts. */ func_prototype: var_modifiers type var_identifier '(' parameters ')' colon_attribute { + if ($1) + { + hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR, + "unexpected modifiers on a function"); + YYABORT; + } if (get_variable(hlsl_ctx.globals, $3)) { hlsl_report_message(get_location(&@3), diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 0e50084fb91..96823750eea 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -924,6 +924,11 @@ static void test_fail(void) " float a[(x = 2)];\n" " return float4(0, 0, 0, 0);\n" "}", + + "uniform float4 test() : SV_TARGET\n" + "{\n" + " return float4(0, 0, 0, 0);\n" + "}", };
static const char *targets[] = {"ps_2_0", "ps_3_0", "ps_4_0"};
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=67038
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:924 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:924 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:924 Task: Patch failed to apply
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 96 ++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 34 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 59e0df9d8c0..6a5dddf5d40 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -168,7 +168,21 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) return TRUE; }
-static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *loc); +static DWORD add_modifiers(DWORD modifiers, DWORD mod, const struct source_location loc) +{ + if (modifiers & mod) + { + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "modifier '%s' already specified", debug_modifiers(mod)); + return modifiers; + } + if (mod & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR) + && modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)) + { + hlsl_report_message(loc, HLSL_LEVEL_ERROR, "more than one matrix majority keyword"); + return modifiers; + } + return modifiers | mod; +}
static BOOL add_type_to_scope(struct hlsl_scope *scope, struct hlsl_type *def) { @@ -602,7 +616,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, local = FALSE; }
- if (var->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer.args_count) + if (type->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer.args_count) { hlsl_report_message(v->loc, HLSL_LEVEL_ERROR, "const variable without initializer"); free_declaration(var); @@ -703,6 +717,21 @@ static BOOL add_struct_field(struct list *fields, struct hlsl_struct_field *fiel return TRUE; }
+static struct hlsl_type *apply_type_modifiers(struct hlsl_type *type, DWORD *modifiers, struct source_location loc) +{ + struct hlsl_type *new_type; + + if (!(*modifiers & HLSL_TYPE_MODIFIERS_MASK)) + return type; + + if (!(new_type = clone_hlsl_type(type))) + return NULL; + + new_type->modifiers = add_modifiers(new_type->modifiers, *modifiers, loc); + *modifiers &= ~HLSL_TYPE_MODIFIERS_MASK; + return new_type; +} + static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, struct list *fields) { struct parse_variable_def *v, *v_next; @@ -1301,7 +1330,12 @@ fields_list: /* Empty */
field: var_modifiers type variables_def ';' { - $$ = gen_struct_fields($2, $1, $3); + struct hlsl_type *type; + DWORD modifiers = $1; + + if (!(type = apply_type_modifiers($2, &modifiers, get_location(&@1)))) + YYABORT; + $$ = gen_struct_fields(type, modifiers, $3); } | unnamed_struct_spec variables_def ';' { @@ -1449,9 +1483,15 @@ param_list: parameter
parameter: input_mods var_modifiers type any_identifier colon_attribute { + struct hlsl_type *type; + DWORD modifiers = $2; + + if (!(type = apply_type_modifiers($3, &modifiers, get_location(&@2)))) + YYABORT; + $$.modifiers = $1 ? $1 : HLSL_MODIFIER_IN; - $$.modifiers |= $2; - $$.type = $3; + $$.modifiers |= modifiers; + $$.type = type; $$.name = $4; $$.semantic = $5.semantic; $$.reg_reservation = $5.reg_reservation; @@ -1639,7 +1679,12 @@ type_spec: any_identifier array
declaration: var_modifiers type variables_def ';' { - $$ = declare_vars($2, $1, $3); + struct hlsl_type *type; + DWORD modifiers = $1; + + if (!(type = apply_type_modifiers($2, &modifiers, get_location(&@1)))) + YYABORT; + $$ = declare_vars(type, modifiers, $3); }
variables_def_optional: /* Empty */ @@ -1717,47 +1762,47 @@ var_modifiers: /* Empty */ } | KW_EXTERN var_modifiers { - $$ = add_modifier($2, HLSL_STORAGE_EXTERN, &@1); + $$ = add_modifiers($2, HLSL_STORAGE_EXTERN, get_location(&@1)); } | KW_NOINTERPOLATION var_modifiers { - $$ = add_modifier($2, HLSL_STORAGE_NOINTERPOLATION, &@1); + $$ = add_modifiers($2, HLSL_STORAGE_NOINTERPOLATION, get_location(&@1)); } | KW_PRECISE var_modifiers { - $$ = add_modifier($2, HLSL_MODIFIER_PRECISE, &@1); + $$ = add_modifiers($2, HLSL_MODIFIER_PRECISE, get_location(&@1)); } | KW_SHARED var_modifiers { - $$ = add_modifier($2, HLSL_STORAGE_SHARED, &@1); + $$ = add_modifiers($2, HLSL_STORAGE_SHARED, get_location(&@1)); } | KW_GROUPSHARED var_modifiers { - $$ = add_modifier($2, HLSL_STORAGE_GROUPSHARED, &@1); + $$ = add_modifiers($2, HLSL_STORAGE_GROUPSHARED, get_location(&@1)); } | KW_STATIC var_modifiers { - $$ = add_modifier($2, HLSL_STORAGE_STATIC, &@1); + $$ = add_modifiers($2, HLSL_STORAGE_STATIC, get_location(&@1)); } | KW_UNIFORM var_modifiers { - $$ = add_modifier($2, HLSL_STORAGE_UNIFORM, &@1); + $$ = add_modifiers($2, HLSL_STORAGE_UNIFORM, get_location(&@1)); } | KW_VOLATILE var_modifiers { - $$ = add_modifier($2, HLSL_STORAGE_VOLATILE, &@1); + $$ = add_modifiers($2, HLSL_STORAGE_VOLATILE, get_location(&@1)); } | KW_CONST var_modifiers { - $$ = add_modifier($2, HLSL_MODIFIER_CONST, &@1); + $$ = add_modifiers($2, HLSL_MODIFIER_CONST, get_location(&@1)); } | KW_ROW_MAJOR var_modifiers { - $$ = add_modifier($2, HLSL_MODIFIER_ROW_MAJOR, &@1); + $$ = add_modifiers($2, HLSL_MODIFIER_ROW_MAJOR, get_location(&@1)); } | KW_COLUMN_MAJOR var_modifiers { - $$ = add_modifier($2, HLSL_MODIFIER_COLUMN_MAJOR, &@1); + $$ = add_modifiers($2, HLSL_MODIFIER_COLUMN_MAJOR, get_location(&@1)); }
complex_initializer: initializer_expr @@ -2486,23 +2531,6 @@ static struct source_location get_location(const struct YYLTYPE *l) return loc; }
-static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *l) -{ - if (modifiers & mod) - { - hlsl_report_message(get_location(l), HLSL_LEVEL_ERROR, - "modifier '%s' already specified", debug_modifiers(mod)); - return modifiers; - } - if (mod & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR) - && modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)) - { - hlsl_report_message(get_location(l), HLSL_LEVEL_ERROR, "more than one matrix majority keyword"); - return modifiers; - } - return modifiers | mod; -} - static void dump_function_decl(struct wine_rb_entry *entry, void *context) { struct hlsl_ir_function_decl *func = WINE_RB_ENTRY_VALUE(entry, struct hlsl_ir_function_decl, entry);
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=67039
Your paranoid android.
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:924 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:924 Task: Patch failed to apply
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=67035
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/tests/hlsl_d3d9.c:874 Task: Patch failed to apply