Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 76 +++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 44 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1ab56fba0..920bb520c 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1513,6 +1513,16 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t if (type->type != HLSL_CLASS_MATRIX) check_invalid_matrix_modifiers(ctx, modifiers, v->loc);
+ if (modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)) + { + struct vkd3d_string_buffer *string; + + if ((string = hlsl_modifiers_to_string(ctx, modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)))) + hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, + "Modifiers '%s' are not allowed on non-parameter variables.", string->buffer); + hlsl_release_string_buffer(ctx, string); + } + if (!(var = hlsl_new_var(ctx, v->name, type, v->loc, &v->semantic, modifiers, &v->reg_reservation))) { free_parse_variable_def(v); @@ -2413,8 +2423,6 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
%type <if_body> if_body
-%type <modifiers> input_mod -%type <modifiers> input_mods %type <modifiers> var_modifiers
%type <name> any_identifier @@ -2791,54 +2799,21 @@ param_list: }
parameter: - input_mods var_modifiers type any_identifier colon_attribute + var_modifiers type any_identifier colon_attribute { struct hlsl_type *type; - unsigned int modifiers = $2; + unsigned int modifiers = $1;
- if (!(type = apply_type_modifiers(ctx, $3, &modifiers, @2))) + if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT;
- $$.modifiers = $1 ? $1 : HLSL_STORAGE_IN; - $$.modifiers |= modifiers; + $$.modifiers = modifiers; + if (!($$.modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT))) + $$.modifiers |= HLSL_STORAGE_IN; $$.type = type; - $$.name = $4; - $$.semantic = $5.semantic; - $$.reg_reservation = $5.reg_reservation; - } - -input_mods: - %empty - { - $$ = 0; - } - | input_mods input_mod - { - if ($1 & $2) - { - struct vkd3d_string_buffer *string; - - if ((string = hlsl_modifiers_to_string(ctx, $2))) - hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, - "Modifier "%s" was already specified.", string->buffer); - hlsl_release_string_buffer(ctx, string); - YYABORT; - } - $$ = $1 | $2; - } - -input_mod: - KW_IN - { - $$ = HLSL_STORAGE_IN; - } - | KW_OUT - { - $$ = HLSL_STORAGE_OUT; - } - | KW_INOUT - { - $$ = HLSL_STORAGE_IN | HLSL_STORAGE_OUT; + $$.name = $3; + $$.semantic = $4.semantic; + $$.reg_reservation = $4.reg_reservation; }
texture_type: @@ -3202,6 +3177,19 @@ var_modifiers: { $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_COLUMN_MAJOR, @1); } + | KW_IN var_modifiers + { + $$ = add_modifiers(ctx, $2, HLSL_STORAGE_IN, @1); + } + | KW_OUT var_modifiers + { + $$ = add_modifiers(ctx, $2, HLSL_STORAGE_OUT, @1); + } + | KW_INOUT var_modifiers + { + $$ = add_modifiers(ctx, $2, HLSL_STORAGE_IN | HLSL_STORAGE_OUT, @1); + } +
complex_initializer: initializer_expr
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 1 - libs/vkd3d-shader/hlsl_codegen.c | 9 ++++++--- libs/vkd3d-shader/hlsl_sm4.c | 9 ++++++++- 3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 64cfe5342..8845be374 100644 --- a/Makefile.am +++ b/Makefile.am @@ -352,7 +352,6 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/logic-operations.shader_test \ tests/max.shader_test \ - tests/nointerpolation.shader_test \ tests/sampler-offset.shader_test \ tests/trigonometry.shader_test endif diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 98be3aebf..a6a574a70 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -34,7 +34,8 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru /* Use the synthetic name for the temp, rather than the uniform, so that we * can write the uniform name into the shader reflection data. */
- if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type, temp->loc, NULL, 0, &temp->reg_reservation))) + if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type, + temp->loc, NULL, temp->modifiers, &temp->reg_reservation))) return; list_add_before(&temp->scope_entry, &uniform->scope_entry); list_add_tail(&ctx->extern_vars, &uniform->extern_entry); @@ -76,7 +77,8 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; } new_semantic.index = semantic->index; - if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, var->loc, &new_semantic, 0, NULL))) + if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), + type, var->loc, &new_semantic, var->modifiers, NULL))) { hlsl_release_string_buffer(ctx, name); vkd3d_free((void *)new_semantic.name); @@ -147,7 +149,8 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; } new_semantic.index = semantic->index; - if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, var->loc, &new_semantic, 0, NULL))) + if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), + type, var->loc, &new_semantic, var->modifiers, NULL))) { vkd3d_free((void *)new_semantic.name); hlsl_release_string_buffer(ctx, name); diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index ed1f5519d..95ea299cf 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1203,7 +1203,14 @@ static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b }
if (profile->type == VKD3D_SHADER_TYPE_PIXEL) - instr.opcode |= VKD3DSIM_LINEAR << VKD3D_SM4_INTERPOLATION_MODE_SHIFT; + { + enum vkd3d_shader_interpolation_mode mode = VKD3DSIM_LINEAR; + + if (var->modifiers & HLSL_STORAGE_NOINTERPOLATION) + mode = VKD3DSIM_CONSTANT; + + instr.opcode |= mode << VKD3D_SM4_INTERPOLATION_MODE_SHIFT; + } } else {
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- It's not really related to this patch, but it seems that in the nointerpolation test only the second "nointerpolation" modifier is significant, i.e., the one on the pixel shader. If I erase the "nointerpolation" modifiers on the vertex shader, the test still passes, both on Windows and on vkd3d. Any reason not to remove it?
Il 22/03/22 22:59, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 1 - libs/vkd3d-shader/hlsl_codegen.c | 9 ++++++--- libs/vkd3d-shader/hlsl_sm4.c | 9 ++++++++- 3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 64cfe5342..8845be374 100644 --- a/Makefile.am +++ b/Makefile.am @@ -352,7 +352,6 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/logic-operations.shader_test \ tests/max.shader_test \
- tests/nointerpolation.shader_test \ tests/sampler-offset.shader_test \ tests/trigonometry.shader_test endif
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 98be3aebf..a6a574a70 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -34,7 +34,8 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru /* Use the synthetic name for the temp, rather than the uniform, so that we * can write the uniform name into the shader reflection data. */
- if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type, temp->loc, NULL, 0, &temp->reg_reservation)))
- if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type,
temp->loc, NULL, temp->modifiers, &temp->reg_reservation))) return; list_add_before(&temp->scope_entry, &uniform->scope_entry); list_add_tail(&ctx->extern_vars, &uniform->extern_entry);
@@ -76,7 +77,8 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; } new_semantic.index = semantic->index;
- if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, var->loc, &new_semantic, 0, NULL)))
- if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
type, var->loc, &new_semantic, var->modifiers, NULL))) { hlsl_release_string_buffer(ctx, name); vkd3d_free((void *)new_semantic.name);
@@ -147,7 +149,8 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; } new_semantic.index = semantic->index;
- if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, var->loc, &new_semantic, 0, NULL)))
- if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
type, var->loc, &new_semantic, var->modifiers, NULL))) { vkd3d_free((void *)new_semantic.name); hlsl_release_string_buffer(ctx, name);
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index ed1f5519d..95ea299cf 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1203,7 +1203,14 @@ static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b }
if (profile->type == VKD3D_SHADER_TYPE_PIXEL)
instr.opcode |= VKD3DSIM_LINEAR << VKD3D_SM4_INTERPOLATION_MODE_SHIFT;
{
enum vkd3d_shader_interpolation_mode mode = VKD3DSIM_LINEAR;
if (var->modifiers & HLSL_STORAGE_NOINTERPOLATION)
mode = VKD3DSIM_CONSTANT;
instr.opcode |= mode << VKD3D_SM4_INTERPOLATION_MODE_SHIFT;
} } else {
On 3/23/22 08:10, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
It's not really related to this patch, but it seems that in the nointerpolation test only the second "nointerpolation" modifier is significant, i.e., the one on the pixel shader. If I erase the "nointerpolation" modifiers on the vertex shader, the test still passes, both on Windows and on vkd3d. Any reason not to remove it?
Yes, interpolation modifiers only affect pixel shaders. I don't see much reason to include or exclude it from the vertex shader in these tests.
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 22, 2022 7:17 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 1 - libs/vkd3d-shader/hlsl_codegen.c | 9 ++++++--- libs/vkd3d-shader/hlsl_sm4.c | 9 ++++++++- 3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 64cfe5342..8845be374 100644 --- a/Makefile.am +++ b/Makefile.am @@ -352,7 +352,6 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/logic-operations.shader_test \ tests/max.shader_test \
- tests/nointerpolation.shader_test \
tests/sampler-offset.shader_test \ tests/trigonometry.shader_test endif diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 98be3aebf..a6a574a70 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -34,7 +34,8 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru /* Use the synthetic name for the temp, rather than the uniform, so that we
- can write the uniform name into the shader reflection data. */
- if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type, temp->loc, NULL, 0,
&temp->reg_reservation)))
- if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type,
- temp->loc, NULL, temp->modifiers, &temp->reg_reservation)))
return; list_add_before(&temp->scope_entry, &uniform->scope_entry); list_add_tail(&ctx->extern_vars, &uniform->extern_entry); @@ -76,7 +77,8 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; } new_semantic.index = semantic->index;
- if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, var->loc, &new_semantic, 0,
NULL)))
- if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
- type, var->loc, &new_semantic, var->modifiers, NULL)))
{ hlsl_release_string_buffer(ctx, name); vkd3d_free((void *)new_semantic.name); @@ -147,7 +149,8 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; } new_semantic.index = semantic->index;
- if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, var->loc, &new_semantic,
0, NULL)))
- if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
- type, var->loc, &new_semantic, var->modifiers, NULL)))
{ vkd3d_free((void *)new_semantic.name); hlsl_release_string_buffer(ctx, name); diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index ed1f5519d..95ea299cf 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1203,7 +1203,14 @@ static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b }
if (profile->type == VKD3D_SHADER_TYPE_PIXEL)
- instr.opcode |= VKD3DSIM_LINEAR << VKD3D_SM4_INTERPOLATION_MODE_SHIFT;
- {
- enum vkd3d_shader_interpolation_mode mode = VKD3DSIM_LINEAR;
- if (var->modifiers & HLSL_STORAGE_NOINTERPOLATION)
- mode = VKD3DSIM_CONSTANT;
- instr.opcode |= mode << VKD3D_SM4_INTERPOLATION_MODE_SHIFT;
- }
} else { -- 2.35.1
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 95ea299cf..bc7d966c2 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -25,6 +25,20 @@
static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_block *block);
+static bool type_is_integer(const struct hlsl_type *type) +{ + switch (type->base_type) + { + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + return true; + + default: + return false; + } +} + bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic, bool output, enum vkd3d_sm4_register_type *type, enum vkd3d_sm4_swizzle_type *swizzle_type, bool *has_idx) { @@ -1206,7 +1220,7 @@ static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b { enum vkd3d_shader_interpolation_mode mode = VKD3DSIM_LINEAR;
- if (var->modifiers & HLSL_STORAGE_NOINTERPOLATION) + if ((var->modifiers & HLSL_STORAGE_NOINTERPOLATION) || type_is_integer(var->data_type)) mode = VKD3DSIM_CONSTANT;
instr.opcode |= mode << VKD3D_SM4_INTERPOLATION_MODE_SHIFT; @@ -1419,20 +1433,6 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
-static bool type_is_integer(const struct hlsl_type *type) -{ - switch (type->base_type) - { - case HLSL_TYPE_BOOL: - case HLSL_TYPE_INT: - case HLSL_TYPE_UINT: - return true; - - default: - return false; - } -} - static bool type_is_float(const struct hlsl_type *type) { return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 22/03/22 22:59, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 95ea299cf..bc7d966c2 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -25,6 +25,20 @@
static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_block *block);
+static bool type_is_integer(const struct hlsl_type *type) +{
- switch (type->base_type)
- {
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
return true;
default:
return false;
- }
+}
- bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic, bool output, enum vkd3d_sm4_register_type *type, enum vkd3d_sm4_swizzle_type *swizzle_type, bool *has_idx) {
@@ -1206,7 +1220,7 @@ static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b { enum vkd3d_shader_interpolation_mode mode = VKD3DSIM_LINEAR;
if (var->modifiers & HLSL_STORAGE_NOINTERPOLATION)
if ((var->modifiers & HLSL_STORAGE_NOINTERPOLATION) || type_is_integer(var->data_type)) mode = VKD3DSIM_CONSTANT; instr.opcode |= mode << VKD3D_SM4_INTERPOLATION_MODE_SHIFT;
@@ -1419,20 +1433,6 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
-static bool type_is_integer(const struct hlsl_type *type) -{
- switch (type->base_type)
- {
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
return true;
default:
return false;
- }
-}
- static bool type_is_float(const struct hlsl_type *type) { return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 22, 2022 7:17 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 95ea299cf..bc7d966c2 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -25,6 +25,20 @@
static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_block *block);
+static bool type_is_integer(const struct hlsl_type *type) +{
- switch (type->base_type)
- {
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- return true;
- default:
- return false;
- }
+}
bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic, bool output, enum vkd3d_sm4_register_type *type, enum vkd3d_sm4_swizzle_type *swizzle_type, bool *has_idx) { @@ -1206,7 +1220,7 @@ static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b { enum vkd3d_shader_interpolation_mode mode = VKD3DSIM_LINEAR;
- if (var->modifiers & HLSL_STORAGE_NOINTERPOLATION)
- if ((var->modifiers & HLSL_STORAGE_NOINTERPOLATION) || type_is_integer(var->data_type))
mode = VKD3DSIM_CONSTANT;
instr.opcode |= mode << VKD3D_SM4_INTERPOLATION_MODE_SHIFT; @@ -1419,20 +1433,6 @@ static void write_sm4_sample(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer write_sm4_instruction(buffer, &instr); }
-static bool type_is_integer(const struct hlsl_type *type) -{
- switch (type->base_type)
- {
- case HLSL_TYPE_BOOL:
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- return true;
- default:
- return false;
- }
-}
static bool type_is_float(const struct hlsl_type *type) { return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF; -- 2.35.1
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index bc7d966c2..234394b14 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1629,6 +1629,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, write_sm4_binary_op(buffer, VKD3D_SM4_OP_ADD, &expr->node, arg1, arg2); break;
+ case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IADD, &expr->node, arg1, arg2); + break; + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 %s addition expression.", dst_type_string->buffer); }
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 22/03/22 22:59, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index bc7d966c2..234394b14 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1629,6 +1629,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, write_sm4_binary_op(buffer, VKD3D_SM4_OP_ADD, &expr->node, arg1, arg2); break;
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IADD, &expr->node, arg1, arg2);
break;
default: hlsl_fixme(ctx, &expr->node.loc, "SM4 %s addition expression.", dst_type_string->buffer); }
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 22, 2022 7:17 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index bc7d966c2..234394b14 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1629,6 +1629,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, write_sm4_binary_op(buffer, VKD3D_SM4_OP_ADD, &expr->node, arg1, arg2); break;
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- write_sm4_binary_op(buffer, VKD3D_SM4_OP_IADD, &expr->node, arg1, arg2);
- break;
default: hlsl_fixme(ctx, &expr->node.loc, "SM4 %s addition expression.", dst_type_string->buffer); } -- 2.35.1
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- The next patch has a trivial conflict when applied on current upstream + previous signoffs. I'll resend the rebased version with the next batch.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.y | 8 +++++--- libs/vkd3d-shader/hlsl_codegen.c | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 59aca8fc2..fe702bdb9 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -152,6 +152,7 @@ struct hlsl_struct_field struct hlsl_type *type; const char *name; struct hlsl_semantic semantic; + unsigned int modifiers; unsigned int reg_offset;
size_t name_bytecode_offset; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 920bb520c..77490c110 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -667,7 +667,8 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_ return new_type; }
-static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *type, struct list *fields) +static struct list *gen_struct_fields(struct hlsl_ctx *ctx, + struct hlsl_type *type, unsigned int modifiers, struct list *fields) { struct parse_variable_def *v, *v_next; struct hlsl_struct_field *field; @@ -694,6 +695,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty field->loc = v->loc; field->name = v->name; field->semantic = v->semantic; + field->modifiers = modifiers; if (v->initializer.args_count) { hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field."); @@ -2636,7 +2638,7 @@ field:
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT; - if (modifiers) + if (modifiers & ~HLSL_STORAGE_NOINTERPOLATION) { struct vkd3d_string_buffer *string;
@@ -2645,7 +2647,7 @@ field: "Modifiers '%s' are not allowed on struct fields.", string->buffer); hlsl_release_string_buffer(ctx, string); } - $$ = gen_struct_fields(ctx, type, $3); + $$ = gen_struct_fields(ctx, type, modifiers, $3); }
func_declaration: diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index a6a574a70..b6a8e393f 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -59,7 +59,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru }
static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var, - struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic) + struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct hlsl_semantic *semantic) { struct vkd3d_string_buffer *name; struct hlsl_semantic new_semantic; @@ -78,7 +78,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct } new_semantic.index = semantic->index; if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), - type, var->loc, &new_semantic, var->modifiers, NULL))) + type, var->loc, &new_semantic, modifiers, NULL))) { hlsl_release_string_buffer(ctx, name); vkd3d_free((void *)new_semantic.name); @@ -113,7 +113,8 @@ static void prepend_input_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, if (field->type->type == HLSL_CLASS_STRUCT) prepend_input_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset); else if (field->semantic.name) - prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); + prepend_input_copy(ctx, instrs, var, field->type, + field_offset + field->reg_offset, field->modifiers, &field->semantic); else hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); @@ -127,11 +128,11 @@ static void prepend_input_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st if (var->data_type->type == HLSL_CLASS_STRUCT) prepend_input_struct_copy(ctx, instrs, var, var->data_type, 0); else if (var->semantic.name) - prepend_input_copy(ctx, instrs, var, var->data_type, 0, &var->semantic); + prepend_input_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic); }
static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var, - struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic) + struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct hlsl_semantic *semantic) { struct vkd3d_string_buffer *name; struct hlsl_semantic new_semantic; @@ -150,7 +151,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct } new_semantic.index = semantic->index; if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), - type, var->loc, &new_semantic, var->modifiers, NULL))) + type, var->loc, &new_semantic, modifiers, NULL))) { vkd3d_free((void *)new_semantic.name); hlsl_release_string_buffer(ctx, name); @@ -185,7 +186,8 @@ static void append_output_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, if (field->type->type == HLSL_CLASS_STRUCT) append_output_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset); else if (field->semantic.name) - append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); + append_output_copy(ctx, instrs, var, field->type, + field_offset + field->reg_offset, field->modifiers, &field->semantic); else hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); @@ -200,7 +202,7 @@ static void append_output_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st if (var->data_type->type == HLSL_CLASS_STRUCT) append_output_struct_copy(ctx, instrs, var, var->data_type, 0); else if (var->semantic.name) - append_output_copy(ctx, instrs, var, var->data_type, 0, &var->semantic); + append_output_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic); }
static bool transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *),
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 22/03/22 22:59, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.y | 8 +++++--- libs/vkd3d-shader/hlsl_codegen.c | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 59aca8fc2..fe702bdb9 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -152,6 +152,7 @@ struct hlsl_struct_field struct hlsl_type *type; const char *name; struct hlsl_semantic semantic;
unsigned int modifiers; unsigned int reg_offset;
size_t name_bytecode_offset;
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 920bb520c..77490c110 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -667,7 +667,8 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_ return new_type; }
-static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *type, struct list *fields) +static struct list *gen_struct_fields(struct hlsl_ctx *ctx,
{ struct parse_variable_def *v, *v_next; struct hlsl_struct_field *field;struct hlsl_type *type, unsigned int modifiers, struct list *fields)
@@ -694,6 +695,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty field->loc = v->loc; field->name = v->name; field->semantic = v->semantic;
field->modifiers = modifiers; if (v->initializer.args_count) { hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field.");
@@ -2636,7 +2638,7 @@ field:
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT;
if (modifiers)
if (modifiers & ~HLSL_STORAGE_NOINTERPOLATION) { struct vkd3d_string_buffer *string;
@@ -2645,7 +2647,7 @@ field: "Modifiers '%s' are not allowed on struct fields.", string->buffer); hlsl_release_string_buffer(ctx, string); }
$$ = gen_struct_fields(ctx, type, $3);
$$ = gen_struct_fields(ctx, type, modifiers, $3); }
func_declaration:
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index a6a574a70..b6a8e393f 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -59,7 +59,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru }
static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var,
struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic)
{ struct vkd3d_string_buffer *name; struct hlsl_semantic new_semantic;struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct hlsl_semantic *semantic)
@@ -78,7 +78,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct } new_semantic.index = semantic->index; if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
type, var->loc, &new_semantic, var->modifiers, NULL)))
type, var->loc, &new_semantic, modifiers, NULL))) { hlsl_release_string_buffer(ctx, name); vkd3d_free((void *)new_semantic.name);
@@ -113,7 +113,8 @@ static void prepend_input_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, if (field->type->type == HLSL_CLASS_STRUCT) prepend_input_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset); else if (field->semantic.name)
prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic);
prepend_input_copy(ctx, instrs, var, field->type,
field_offset + field->reg_offset, field->modifiers, &field->semantic); else hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name);
@@ -127,11 +128,11 @@ static void prepend_input_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st if (var->data_type->type == HLSL_CLASS_STRUCT) prepend_input_struct_copy(ctx, instrs, var, var->data_type, 0); else if (var->semantic.name)
prepend_input_copy(ctx, instrs, var, var->data_type, 0, &var->semantic);
prepend_input_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic);
}
static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var,
struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic)
{ struct vkd3d_string_buffer *name; struct hlsl_semantic new_semantic;struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct hlsl_semantic *semantic)
@@ -150,7 +151,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct } new_semantic.index = semantic->index; if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
type, var->loc, &new_semantic, var->modifiers, NULL)))
type, var->loc, &new_semantic, modifiers, NULL))) { vkd3d_free((void *)new_semantic.name); hlsl_release_string_buffer(ctx, name);
@@ -185,7 +186,8 @@ static void append_output_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, if (field->type->type == HLSL_CLASS_STRUCT) append_output_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset); else if (field->semantic.name)
append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic);
append_output_copy(ctx, instrs, var, field->type,
field_offset + field->reg_offset, field->modifiers, &field->semantic); else hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name);
@@ -200,7 +202,7 @@ static void append_output_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st if (var->data_type->type == HLSL_CLASS_STRUCT) append_output_struct_copy(ctx, instrs, var, var->data_type, 0); else if (var->semantic.name)
append_output_copy(ctx, instrs, var, var->data_type, 0, &var->semantic);
append_output_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic);
}
static bool transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *),
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 22, 2022 7:17 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.y | 8 +++++--- libs/vkd3d-shader/hlsl_codegen.c | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 59aca8fc2..fe702bdb9 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -152,6 +152,7 @@ struct hlsl_struct_field struct hlsl_type *type; const char *name; struct hlsl_semantic semantic;
- unsigned int modifiers;
unsigned int reg_offset;
size_t name_bytecode_offset; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 920bb520c..77490c110 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -667,7 +667,8 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_ return new_type; }
-static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *type, struct list *fields) +static struct list *gen_struct_fields(struct hlsl_ctx *ctx,
- struct hlsl_type *type, unsigned int modifiers, struct list *fields)
{ struct parse_variable_def *v, *v_next; struct hlsl_struct_field *field; @@ -694,6 +695,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty field->loc = v->loc; field->name = v->name; field->semantic = v->semantic;
- field->modifiers = modifiers;
if (v->initializer.args_count) { hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field."); @@ -2636,7 +2638,7 @@ field:
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT;
- if (modifiers)
- if (modifiers & ~HLSL_STORAGE_NOINTERPOLATION)
{ struct vkd3d_string_buffer *string;
@@ -2645,7 +2647,7 @@ field: "Modifiers '%s' are not allowed on struct fields.", string->buffer); hlsl_release_string_buffer(ctx, string); }
- $$ = gen_struct_fields(ctx, type, $3);
- $$ = gen_struct_fields(ctx, type, modifiers, $3);
}
func_declaration: diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index a6a574a70..b6a8e393f 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -59,7 +59,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru }
static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var,
- struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic)
- struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct
hlsl_semantic *semantic) { struct vkd3d_string_buffer *name; struct hlsl_semantic new_semantic; @@ -78,7 +78,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct } new_semantic.index = semantic->index; if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
- type, var->loc, &new_semantic, var->modifiers, NULL)))
- type, var->loc, &new_semantic, modifiers, NULL)))
{ hlsl_release_string_buffer(ctx, name); vkd3d_free((void *)new_semantic.name); @@ -113,7 +113,8 @@ static void prepend_input_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, if (field->type->type == HLSL_CLASS_STRUCT) prepend_input_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset); else if (field->semantic.name)
- prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset,
&field->semantic);
- prepend_input_copy(ctx, instrs, var, field->type,
- field_offset + field->reg_offset, field->modifiers, &field->semantic);
else hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); @@ -127,11 +128,11 @@ static void prepend_input_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st if (var->data_type->type == HLSL_CLASS_STRUCT) prepend_input_struct_copy(ctx, instrs, var, var->data_type, 0); else if (var->semantic.name)
- prepend_input_copy(ctx, instrs, var, var->data_type, 0, &var->semantic);
- prepend_input_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic);
}
static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var,
- struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic)
- struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct
hlsl_semantic *semantic) { struct vkd3d_string_buffer *name; struct hlsl_semantic new_semantic; @@ -150,7 +151,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct } new_semantic.index = semantic->index; if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer),
- type, var->loc, &new_semantic, var->modifiers, NULL)))
- type, var->loc, &new_semantic, modifiers, NULL)))
{ vkd3d_free((void *)new_semantic.name); hlsl_release_string_buffer(ctx, name); @@ -185,7 +186,8 @@ static void append_output_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, if (field->type->type == HLSL_CLASS_STRUCT) append_output_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset); else if (field->semantic.name)
- append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset,
&field->semantic);
- append_output_copy(ctx, instrs, var, field->type,
- field_offset + field->reg_offset, field->modifiers, &field->semantic);
else hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); @@ -200,7 +202,7 @@ static void append_output_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st if (var->data_type->type == HLSL_CLASS_STRUCT) append_output_struct_copy(ctx, instrs, var, var->data_type, 0); else if (var->semantic.name)
- append_output_copy(ctx, instrs, var, var->data_type, 0, &var->semantic);
- append_output_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic);
}
static bool transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *), -- 2.35.1
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 1 + tests/d3d12.c | 152 ------------------ tests/shader-interstage-interface.shader_test | 56 +++++++ tests/shader_runner.c | 4 + 4 files changed, 61 insertions(+), 152 deletions(-) create mode 100644 tests/shader-interstage-interface.shader_test
diff --git a/Makefile.am b/Makefile.am index 8845be374..6e7737be1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -115,6 +115,7 @@ vkd3d_shader_tests = \ tests/sampler.shader_test \ tests/sampler-offset.shader_test \ tests/saturate.shader_test \ + tests/shader-interstage-interface.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ tests/swizzle-2.shader_test \ diff --git a/tests/d3d12.c b/tests/d3d12.c index 29bd40c87..5352cc35b 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10931,157 +10931,6 @@ static void test_discard_instruction(void) destroy_test_context(&context); }
-static void test_shader_interstage_interface(void) -{ - static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; - ID3D12GraphicsCommandList *command_list; - D3D12_INPUT_LAYOUT_DESC input_layout; - struct test_context_desc desc; - D3D12_VERTEX_BUFFER_VIEW vbv; - struct test_context context; - ID3D12CommandQueue *queue; - ID3D12Resource *vb; - - static const DWORD vs_code[] = - { -#if 0 - struct vertex - { - float4 position : SV_Position; - float2 t0 : TEXCOORD0; - nointerpolation float t1 : TEXCOORD1; - uint t2 : TEXCOORD2; - uint t3 : TEXCOORD3; - float t4 : TEXCOORD4; - }; - - void main(in vertex vin, out vertex vout) - { - vout = vin; - } -#endif - 0x43425844, 0x561ea178, 0x7b8f454c, 0x69091b4f, 0xf28d9a01, 0x00000001, 0x000002c0, 0x00000003, - 0x0000002c, 0x000000e4, 0x0000019c, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, - 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000a4, 0x00000000, 0x00000000, - 0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002, - 0x00000101, 0x000000a4, 0x00000002, 0x00000000, 0x00000001, 0x00000003, 0x00000101, 0x000000a4, - 0x00000003, 0x00000000, 0x00000001, 0x00000004, 0x00000101, 0x000000a4, 0x00000004, 0x00000000, - 0x00000003, 0x00000005, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, - 0xababab00, 0x4e47534f, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x00000001, - 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000, 0x00000003, 0x00000001, - 0x00000c03, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001, 0x00000b04, 0x000000a4, - 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000e01, 0x000000a4, 0x00000002, 0x00000000, - 0x00000001, 0x00000002, 0x00000d02, 0x000000a4, 0x00000003, 0x00000000, 0x00000001, 0x00000002, - 0x00000b04, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, 0xababab00, 0x58454853, - 0x0000011c, 0x00010050, 0x00000047, 0x0100086a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, - 0x00101032, 0x00000001, 0x0300005f, 0x00101012, 0x00000002, 0x0300005f, 0x00101012, 0x00000003, - 0x0300005f, 0x00101012, 0x00000004, 0x0300005f, 0x00101012, 0x00000005, 0x04000067, 0x001020f2, - 0x00000000, 0x00000001, 0x03000065, 0x00102032, 0x00000001, 0x03000065, 0x00102042, 0x00000001, - 0x03000065, 0x00102012, 0x00000002, 0x03000065, 0x00102022, 0x00000002, 0x03000065, 0x00102042, - 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102032, - 0x00000001, 0x00101046, 0x00000001, 0x05000036, 0x00102042, 0x00000001, 0x0010100a, 0x00000005, - 0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000002, 0x05000036, 0x00102022, 0x00000002, - 0x0010100a, 0x00000003, 0x05000036, 0x00102042, 0x00000002, 0x0010100a, 0x00000004, 0x0100003e, - }; - static const D3D12_SHADER_BYTECODE vs = {vs_code, sizeof(vs_code)}; - static const DWORD ps_code[] = - { -#if 0 - void main(float4 position : SV_Position, float2 t0 : TEXCOORD0, - nointerpolation float t1 : TEXCOORD1, uint t2 : TEXCOORD2, - uint t3 : TEXCOORD3, float t4 : TEXCOORD4, out float4 o : SV_Target) - { - o.x = t0.y + t1; - o.y = t2 + t3; - o.z = t4; - o.w = t0.x; - } -#endif - 0x43425844, 0x21076b15, 0x493d36f1, 0x0cd125d6, 0x1e92c724, 0x00000001, 0x000001e0, 0x00000003, - 0x0000002c, 0x000000e4, 0x00000118, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, - 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000, - 0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001, - 0x00000404, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000101, 0x000000a4, - 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000202, 0x000000a4, 0x00000003, 0x00000000, - 0x00000001, 0x00000002, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, - 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, - 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000c0, - 0x00000050, 0x00000030, 0x0100086a, 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x00101042, - 0x00000001, 0x03000862, 0x00101012, 0x00000002, 0x03000862, 0x00101022, 0x00000002, 0x03000862, - 0x00101042, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700001e, - 0x00100012, 0x00000000, 0x0010101a, 0x00000002, 0x0010102a, 0x00000002, 0x05000056, 0x00102022, - 0x00000000, 0x0010000a, 0x00000000, 0x07000000, 0x00102012, 0x00000000, 0x0010101a, 0x00000001, - 0x0010100a, 0x00000002, 0x05000036, 0x001020c2, 0x00000000, 0x001012a6, 0x00000001, 0x0100003e, - }; - static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; - static const D3D12_INPUT_ELEMENT_DESC layout_desc[] = - { - {"SV_POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT, 0, 16, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 2, DXGI_FORMAT_R32_UINT, 0, 20, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 3, DXGI_FORMAT_R32_UINT, 0, 24, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 4, DXGI_FORMAT_R32_FLOAT, 0, 28, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - }; - static const struct - { - struct vec2 position; - struct vec2 t0; - float t1; - unsigned int t2; - unsigned int t3; - float t4; - } - quad[] = - { - {{-1.0f, -1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f}, - {{-1.0f, 1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f}, - {{ 1.0f, -1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f}, - {{ 1.0f, 1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f}, - }; - static const struct vec4 expected_result = {10.0f, 8.0f, 7.0f, 3.0f}; - - memset(&desc, 0, sizeof(desc)); - desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT; - desc.no_root_signature = true; - if (!init_test_context(&context, &desc)) - return; - command_list = context.list; - queue = context.queue; - - context.root_signature = create_empty_root_signature(context.device, - D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT); - - input_layout.pInputElementDescs = layout_desc; - input_layout.NumElements = ARRAY_SIZE(layout_desc); - context.pipeline_state = create_pipeline_state(context.device, - context.root_signature, desc.rt_format, &vs, &ps, &input_layout); - - vb = create_upload_buffer(context.device, sizeof(quad), quad); - - vbv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(vb); - vbv.StrideInBytes = sizeof(*quad); - vbv.SizeInBytes = sizeof(quad); - - ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL); - - ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); - ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); - ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state); - ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - ID3D12GraphicsCommandList_IASetVertexBuffers(command_list, 0, 1, &vbv); - ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); - ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); - ID3D12GraphicsCommandList_DrawInstanced(command_list, 4, 1, 0, 0); - - transition_resource_state(command_list, context.render_target, - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - check_sub_resource_vec4(context.render_target, 0, queue, command_list, &expected_result, 0); - - ID3D12Resource_Release(vb); - destroy_test_context(&context); -} - static void test_shader_input_output_components(void) { D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc; @@ -36125,7 +35974,6 @@ START_TEST(d3d12) run_test(test_shader_instructions); run_test(test_compute_shader_instructions); run_test(test_discard_instruction); - run_test(test_shader_interstage_interface); run_test(test_shader_input_output_components); run_test(test_root_signature_byte_code); run_test(test_cs_constant_buffer); diff --git a/tests/shader-interstage-interface.shader_test b/tests/shader-interstage-interface.shader_test new file mode 100644 index 000000000..584b88cf9 --- /dev/null +++ b/tests/shader-interstage-interface.shader_test @@ -0,0 +1,56 @@ +[require] +shader model >= 4.0 + +[input layout] +0 r32g32 float SV_POSITION +0 r32g32 float TEXCOORD 0 +0 r32 float TEXCOORD 1 +1 r32 uint TEXCOORD 2 +1 r32 uint TEXCOORD 3 +0 r32 float TEXCOORD 4 + +[vertex buffer 0] +-1.0 -1.0 3.0 5.0 5.0 7.0 +-1.0 1.0 3.0 5.0 5.0 7.0 + 1.0 -1.0 3.0 5.0 5.0 7.0 + 1.0 1.0 3.0 5.0 5.0 7.0 + +[vertex buffer 1] +format r32 uint +2 6 +2 6 +2 6 +2 6 + +[vertex shader] + +struct vertex +{ + float4 position : SV_Position; + float2 t0 : TEXCOORD0; + nointerpolation float t1 : TEXCOORD1; + uint t2 : TEXCOORD2; + uint t3 : TEXCOORD3; + float t4 : TEXCOORD4; +}; + +void main(in vertex vin, out vertex vout) +{ + vout = vin; +} + +[pixel shader] + +void main(float4 position : SV_Position, float2 t0 : TEXCOORD0, + nointerpolation float t1 : TEXCOORD1, uint t2 : TEXCOORD2, + uint t3 : TEXCOORD3, float t4 : TEXCOORD4, out float4 o : SV_Target) +{ + o.x = t0.y + t1; + o.y = t2 + t3; + o.z = t4; + o.w = t0.x; +} + +[test] +draw triangle strip 4 +probe all rgba (10.0, 8.0, 7.0, 3.0) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 99f2a22f8..d3d131164 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -149,9 +149,11 @@ static DXGI_FORMAT parse_format(const char *line, enum texture_data_type *data_t formats[] = { {"r32g32b32a32 float", TEXTURE_DATA_FLOAT, 16, DXGI_FORMAT_R32G32B32A32_FLOAT}, + {"r32g32 float", TEXTURE_DATA_FLOAT, 8, DXGI_FORMAT_R32G32_FLOAT}, {"r32g32 uint", TEXTURE_DATA_UINT, 8, DXGI_FORMAT_R32G32_UINT}, {"r32 float", TEXTURE_DATA_FLOAT, 4, DXGI_FORMAT_R32_FLOAT}, {"r32 sint", TEXTURE_DATA_SINT, 4, DXGI_FORMAT_R32_SINT}, + {"r32 uint", TEXTURE_DATA_UINT, 4, DXGI_FORMAT_R32_UINT}, }; unsigned int i;
@@ -344,6 +346,8 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
if (match_string(line, "triangle list", &line)) topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + else if (match_string(line, "triangle strip", &line)) + topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; else fatal_error("Unknown primitive topology '%s'.\n", line);
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 22/03/22 22:59, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 1 + tests/d3d12.c | 152 ------------------ tests/shader-interstage-interface.shader_test | 56 +++++++ tests/shader_runner.c | 4 + 4 files changed, 61 insertions(+), 152 deletions(-) create mode 100644 tests/shader-interstage-interface.shader_test
diff --git a/Makefile.am b/Makefile.am index 8845be374..6e7737be1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -115,6 +115,7 @@ vkd3d_shader_tests = \ tests/sampler.shader_test \ tests/sampler-offset.shader_test \ tests/saturate.shader_test \
- tests/shader-interstage-interface.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ tests/swizzle-2.shader_test \
diff --git a/tests/d3d12.c b/tests/d3d12.c index 29bd40c87..5352cc35b 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10931,157 +10931,6 @@ static void test_discard_instruction(void) destroy_test_context(&context); }
-static void test_shader_interstage_interface(void) -{
- static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
- ID3D12GraphicsCommandList *command_list;
- D3D12_INPUT_LAYOUT_DESC input_layout;
- struct test_context_desc desc;
- D3D12_VERTEX_BUFFER_VIEW vbv;
- struct test_context context;
- ID3D12CommandQueue *queue;
- ID3D12Resource *vb;
- static const DWORD vs_code[] =
- {
-#if 0
struct vertex
{
float4 position : SV_Position;
float2 t0 : TEXCOORD0;
nointerpolation float t1 : TEXCOORD1;
uint t2 : TEXCOORD2;
uint t3 : TEXCOORD3;
float t4 : TEXCOORD4;
};
void main(in vertex vin, out vertex vout)
{
vout = vin;
}
-#endif
0x43425844, 0x561ea178, 0x7b8f454c, 0x69091b4f, 0xf28d9a01, 0x00000001, 0x000002c0, 0x00000003,
0x0000002c, 0x000000e4, 0x0000019c, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000a4, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
0x00000101, 0x000000a4, 0x00000002, 0x00000000, 0x00000001, 0x00000003, 0x00000101, 0x000000a4,
0x00000003, 0x00000000, 0x00000001, 0x00000004, 0x00000101, 0x000000a4, 0x00000004, 0x00000000,
0x00000003, 0x00000005, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
0xababab00, 0x4e47534f, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x00000001,
0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
0x00000c03, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001, 0x00000b04, 0x000000a4,
0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000e01, 0x000000a4, 0x00000002, 0x00000000,
0x00000001, 0x00000002, 0x00000d02, 0x000000a4, 0x00000003, 0x00000000, 0x00000001, 0x00000002,
0x00000b04, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, 0xababab00, 0x58454853,
0x0000011c, 0x00010050, 0x00000047, 0x0100086a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
0x00101032, 0x00000001, 0x0300005f, 0x00101012, 0x00000002, 0x0300005f, 0x00101012, 0x00000003,
0x0300005f, 0x00101012, 0x00000004, 0x0300005f, 0x00101012, 0x00000005, 0x04000067, 0x001020f2,
0x00000000, 0x00000001, 0x03000065, 0x00102032, 0x00000001, 0x03000065, 0x00102042, 0x00000001,
0x03000065, 0x00102012, 0x00000002, 0x03000065, 0x00102022, 0x00000002, 0x03000065, 0x00102042,
0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102032,
0x00000001, 0x00101046, 0x00000001, 0x05000036, 0x00102042, 0x00000001, 0x0010100a, 0x00000005,
0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000002, 0x05000036, 0x00102022, 0x00000002,
0x0010100a, 0x00000003, 0x05000036, 0x00102042, 0x00000002, 0x0010100a, 0x00000004, 0x0100003e,
- };
- static const D3D12_SHADER_BYTECODE vs = {vs_code, sizeof(vs_code)};
- static const DWORD ps_code[] =
- {
-#if 0
void main(float4 position : SV_Position, float2 t0 : TEXCOORD0,
nointerpolation float t1 : TEXCOORD1, uint t2 : TEXCOORD2,
uint t3 : TEXCOORD3, float t4 : TEXCOORD4, out float4 o : SV_Target)
{
o.x = t0.y + t1;
o.y = t2 + t3;
o.z = t4;
o.w = t0.x;
}
-#endif
0x43425844, 0x21076b15, 0x493d36f1, 0x0cd125d6, 0x1e92c724, 0x00000001, 0x000001e0, 0x00000003,
0x0000002c, 0x000000e4, 0x00000118, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001,
0x00000404, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000101, 0x000000a4,
0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000202, 0x000000a4, 0x00000003, 0x00000000,
0x00000001, 0x00000002, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000c0,
0x00000050, 0x00000030, 0x0100086a, 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x00101042,
0x00000001, 0x03000862, 0x00101012, 0x00000002, 0x03000862, 0x00101022, 0x00000002, 0x03000862,
0x00101042, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700001e,
0x00100012, 0x00000000, 0x0010101a, 0x00000002, 0x0010102a, 0x00000002, 0x05000056, 0x00102022,
0x00000000, 0x0010000a, 0x00000000, 0x07000000, 0x00102012, 0x00000000, 0x0010101a, 0x00000001,
0x0010100a, 0x00000002, 0x05000036, 0x001020c2, 0x00000000, 0x001012a6, 0x00000001, 0x0100003e,
- };
- static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)};
- static const D3D12_INPUT_ELEMENT_DESC layout_desc[] =
- {
{"SV_POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
{"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT, 0, 16, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
{"TEXCOORD", 2, DXGI_FORMAT_R32_UINT, 0, 20, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
{"TEXCOORD", 3, DXGI_FORMAT_R32_UINT, 0, 24, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
{"TEXCOORD", 4, DXGI_FORMAT_R32_FLOAT, 0, 28, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
- };
- static const struct
- {
struct vec2 position;
struct vec2 t0;
float t1;
unsigned int t2;
unsigned int t3;
float t4;
- }
- quad[] =
- {
{{-1.0f, -1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f},
{{-1.0f, 1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f},
{{ 1.0f, -1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f},
{{ 1.0f, 1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f},
- };
- static const struct vec4 expected_result = {10.0f, 8.0f, 7.0f, 3.0f};
- memset(&desc, 0, sizeof(desc));
- desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT;
- desc.no_root_signature = true;
- if (!init_test_context(&context, &desc))
return;
- command_list = context.list;
- queue = context.queue;
- context.root_signature = create_empty_root_signature(context.device,
D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
- input_layout.pInputElementDescs = layout_desc;
- input_layout.NumElements = ARRAY_SIZE(layout_desc);
- context.pipeline_state = create_pipeline_state(context.device,
context.root_signature, desc.rt_format, &vs, &ps, &input_layout);
- vb = create_upload_buffer(context.device, sizeof(quad), quad);
- vbv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(vb);
- vbv.StrideInBytes = sizeof(*quad);
- vbv.SizeInBytes = sizeof(quad);
- ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
- ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL);
- ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
- ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
- ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
- ID3D12GraphicsCommandList_IASetVertexBuffers(command_list, 0, 1, &vbv);
- ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
- ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
- ID3D12GraphicsCommandList_DrawInstanced(command_list, 4, 1, 0, 0);
- transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
- check_sub_resource_vec4(context.render_target, 0, queue, command_list, &expected_result, 0);
- ID3D12Resource_Release(vb);
- destroy_test_context(&context);
-}
- static void test_shader_input_output_components(void) { D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc;
@@ -36125,7 +35974,6 @@ START_TEST(d3d12) run_test(test_shader_instructions); run_test(test_compute_shader_instructions); run_test(test_discard_instruction);
- run_test(test_shader_interstage_interface); run_test(test_shader_input_output_components); run_test(test_root_signature_byte_code); run_test(test_cs_constant_buffer);
diff --git a/tests/shader-interstage-interface.shader_test b/tests/shader-interstage-interface.shader_test new file mode 100644 index 000000000..584b88cf9 --- /dev/null +++ b/tests/shader-interstage-interface.shader_test @@ -0,0 +1,56 @@ +[require] +shader model >= 4.0
+[input layout] +0 r32g32 float SV_POSITION +0 r32g32 float TEXCOORD 0 +0 r32 float TEXCOORD 1 +1 r32 uint TEXCOORD 2 +1 r32 uint TEXCOORD 3 +0 r32 float TEXCOORD 4
+[vertex buffer 0] +-1.0 -1.0 3.0 5.0 5.0 7.0 +-1.0 1.0 3.0 5.0 5.0 7.0
- 1.0 -1.0 3.0 5.0 5.0 7.0
- 1.0 1.0 3.0 5.0 5.0 7.0
+[vertex buffer 1] +format r32 uint +2 6 +2 6 +2 6 +2 6
+[vertex shader]
+struct vertex +{
- float4 position : SV_Position;
- float2 t0 : TEXCOORD0;
- nointerpolation float t1 : TEXCOORD1;
- uint t2 : TEXCOORD2;
- uint t3 : TEXCOORD3;
- float t4 : TEXCOORD4;
+};
+void main(in vertex vin, out vertex vout) +{
- vout = vin;
+}
+[pixel shader]
+void main(float4 position : SV_Position, float2 t0 : TEXCOORD0,
nointerpolation float t1 : TEXCOORD1, uint t2 : TEXCOORD2,
uint t3 : TEXCOORD3, float t4 : TEXCOORD4, out float4 o : SV_Target)
+{
- o.x = t0.y + t1;
- o.y = t2 + t3;
- o.z = t4;
- o.w = t0.x;
+}
+[test] +draw triangle strip 4 +probe all rgba (10.0, 8.0, 7.0, 3.0) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 99f2a22f8..d3d131164 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -149,9 +149,11 @@ static DXGI_FORMAT parse_format(const char *line, enum texture_data_type *data_t formats[] = { {"r32g32b32a32 float", TEXTURE_DATA_FLOAT, 16, DXGI_FORMAT_R32G32B32A32_FLOAT},
{"r32g32 float", TEXTURE_DATA_FLOAT, 8, DXGI_FORMAT_R32G32_FLOAT}, {"r32g32 uint", TEXTURE_DATA_UINT, 8, DXGI_FORMAT_R32G32_UINT}, {"r32 float", TEXTURE_DATA_FLOAT, 4, DXGI_FORMAT_R32_FLOAT}, {"r32 sint", TEXTURE_DATA_SINT, 4, DXGI_FORMAT_R32_SINT},
{"r32 uint", TEXTURE_DATA_UINT, 4, DXGI_FORMAT_R32_UINT}, }; unsigned int i;
@@ -344,6 +346,8 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
if (match_string(line, "triangle list", &line)) topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
else if (match_string(line, "triangle strip", &line))
topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; else fatal_error("Unknown primitive topology '%s'.\n", line);
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- I don't think it is wrong as it is, but I would have found more idiomatic to put the check in declare_vars() outside of the loop iterating over all the variable declarations, given that it doesn't depend on the specific declaration. This way if multiple variables are declared with in or out modifiers in the same statement (as in "in int x, y, z;") the error message is uselessly outputted many times.
Il 22/03/22 22:59, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.y | 76 +++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 44 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1ab56fba0..920bb520c 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1513,6 +1513,16 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t if (type->type != HLSL_CLASS_MATRIX) check_invalid_matrix_modifiers(ctx, modifiers, v->loc);
if (modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT))
{
struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT))))
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers '%s' are not allowed on non-parameter variables.", string->buffer);
hlsl_release_string_buffer(ctx, string);
}
if (!(var = hlsl_new_var(ctx, v->name, type, v->loc, &v->semantic, modifiers, &v->reg_reservation))) { free_parse_variable_def(v);
@@ -2413,8 +2423,6 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
%type <if_body> if_body
-%type <modifiers> input_mod -%type <modifiers> input_mods %type <modifiers> var_modifiers
%type <name> any_identifier @@ -2791,54 +2799,21 @@ param_list: }
parameter:
input_mods var_modifiers type any_identifier colon_attribute
var_modifiers type any_identifier colon_attribute { struct hlsl_type *type;
unsigned int modifiers = $2;
unsigned int modifiers = $1;
if (!(type = apply_type_modifiers(ctx, $3, &modifiers, @2)))
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT;
$$.modifiers = $1 ? $1 : HLSL_STORAGE_IN;
$$.modifiers |= modifiers;
$$.modifiers = modifiers;
if (!($$.modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)))
$$.modifiers |= HLSL_STORAGE_IN; $$.type = type;
$$.name = $4;
$$.semantic = $5.semantic;
$$.reg_reservation = $5.reg_reservation;
}
-input_mods:
%empty
{
$$ = 0;
}
- | input_mods input_mod
{
if ($1 & $2)
{
struct vkd3d_string_buffer *string;
if ((string = hlsl_modifiers_to_string(ctx, $2)))
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifier \"%s\" was already specified.", string->buffer);
hlsl_release_string_buffer(ctx, string);
YYABORT;
}
$$ = $1 | $2;
}
-input_mod:
KW_IN
{
$$ = HLSL_STORAGE_IN;
}
- | KW_OUT
{
$$ = HLSL_STORAGE_OUT;
}
- | KW_INOUT
{
$$ = HLSL_STORAGE_IN | HLSL_STORAGE_OUT;
$$.name = $3;
$$.semantic = $4.semantic;
$$.reg_reservation = $4.reg_reservation; }
texture_type:
@@ -3202,6 +3177,19 @@ var_modifiers: { $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_COLUMN_MAJOR, @1); }
| KW_IN var_modifiers
{
$$ = add_modifiers(ctx, $2, HLSL_STORAGE_IN, @1);
}
| KW_OUT var_modifiers
{
$$ = add_modifiers(ctx, $2, HLSL_STORAGE_OUT, @1);
}
| KW_INOUT var_modifiers
{
$$ = add_modifiers(ctx, $2, HLSL_STORAGE_IN | HLSL_STORAGE_OUT, @1);
}
complex_initializer: initializer_expr
On 3/23/22 07:44, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
I don't think it is wrong as it is, but I would have found more idiomatic to put the check in declare_vars() outside of the loop iterating over all the variable declarations, given that it doesn't depend on the specific declaration. This way if multiple variables are declared with in or out modifiers in the same statement (as in "in int x, y, z;") the error message is uselessly outputted many times.
I don't know about idiomatic, but yes, they should be moved for the reason you describe. It's a preëxisting issue, though, for what it's worth.
Hi,
Il 24/03/22 17:41, Zebediah Figura ha scritto:
On 3/23/22 07:44, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
I don't think it is wrong as it is, but I would have found more idiomatic to put the check in declare_vars() outside of the loop iterating over all the variable declarations, given that it doesn't depend on the specific declaration. This way if multiple variables are declared with in or out modifiers in the same statement (as in "in int x, y, z;") the error message is uselessly outputted many times.
I don't know about idiomatic, but yes, they should be moved for the reason you describe. It's a preëxisting issue, though, for what it's worth.
I don't understand why you say it's preexisting: it's a block of code that you're adding, and that you might have added a few lines above, isn't it? Am I missing something?
BTW, I agree it can be fixed in a later commit anyway.
Giovanni.
On 3/25/22 02:39, Giovanni Mascellani wrote:
Hi,
Il 24/03/22 17:41, Zebediah Figura ha scritto:
On 3/23/22 07:44, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
I don't think it is wrong as it is, but I would have found more idiomatic to put the check in declare_vars() outside of the loop iterating over all the variable declarations, given that it doesn't depend on the specific declaration. This way if multiple variables are declared with in or out modifiers in the same statement (as in "in int x, y, z;") the error message is uselessly outputted many times.
I don't know about idiomatic, but yes, they should be moved for the reason you describe. It's a preëxisting issue, though, for what it's worth.
I don't understand why you say it's preexisting: it's a block of code that you're adding, and that you might have added a few lines above, isn't it? Am I missing something?
Eh, it's not exactly preëxisting, but the same problem was already there for matrices.
I'll just send a new patch...
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 22, 2022 6:59 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.y | 76 +++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 44 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1ab56fba0..920bb520c 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1513,6 +1513,16 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t if (type->type != HLSL_CLASS_MATRIX) check_invalid_matrix_modifiers(ctx, modifiers, v->loc);
- if (modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT))
- {
- struct vkd3d_string_buffer *string;
- if ((string = hlsl_modifiers_to_string(ctx, modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT))))
- hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
- "Modifiers '%s' are not allowed on non-parameter variables.", string->buffer);
- hlsl_release_string_buffer(ctx, string);
- }
if (!(var = hlsl_new_var(ctx, v->name, type, v->loc, &v->semantic, modifiers, &v->reg_reservation))) { free_parse_variable_def(v); @@ -2413,8 +2423,6 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
%type <if_body> if_body
-%type <modifiers> input_mod -%type <modifiers> input_mods %type <modifiers> var_modifiers
%type <name> any_identifier @@ -2791,54 +2799,21 @@ param_list: }
parameter:
- input_mods var_modifiers type any_identifier colon_attribute
- var_modifiers type any_identifier colon_attribute
{ struct hlsl_type *type;
- unsigned int modifiers = $2;
- unsigned int modifiers = $1;
- if (!(type = apply_type_modifiers(ctx, $3, &modifiers, @2)))
- if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
YYABORT;
- $$.modifiers = $1 ? $1 : HLSL_STORAGE_IN;
- $$.modifiers |= modifiers;
- $$.modifiers = modifiers;
- if (!($$.modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)))
- $$.modifiers |= HLSL_STORAGE_IN;
$$.type = type;
- $$.name = $4;
- $$.semantic = $5.semantic;
- $$.reg_reservation = $5.reg_reservation;
- }
-input_mods:
- %empty
- {
- $$ = 0;
- }
- | input_mods input_mod
- {
- if ($1 & $2)
- {
- struct vkd3d_string_buffer *string;
- if ((string = hlsl_modifiers_to_string(ctx, $2)))
- hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
- "Modifier "%s" was already specified.", string->buffer);
- hlsl_release_string_buffer(ctx, string);
- YYABORT;
- }
- $$ = $1 | $2;
- }
-input_mod:
- KW_IN
- {
- $$ = HLSL_STORAGE_IN;
- }
- | KW_OUT
- {
- $$ = HLSL_STORAGE_OUT;
- }
- | KW_INOUT
- {
- $$ = HLSL_STORAGE_IN | HLSL_STORAGE_OUT;
- $$.name = $3;
- $$.semantic = $4.semantic;
- $$.reg_reservation = $4.reg_reservation;
}
texture_type: @@ -3202,6 +3177,19 @@ var_modifiers: { $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_COLUMN_MAJOR, @1); }
- | KW_IN var_modifiers
- {
- $$ = add_modifiers(ctx, $2, HLSL_STORAGE_IN, @1);
- }
- | KW_OUT var_modifiers
- {
- $$ = add_modifiers(ctx, $2, HLSL_STORAGE_OUT, @1);
- }
- | KW_INOUT var_modifiers
- {
- $$ = add_modifiers(ctx, $2, HLSL_STORAGE_IN | HLSL_STORAGE_OUT, @1);
- }
complex_initializer: initializer_expr -- 2.35.1
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Assuming you mean to handle the issue pointed out by Giovanni in a followup patch.