From: Francisco Casas fcasas@codeweavers.com
--- libs/vkd3d-shader/fx.c | 3 +++ libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.y | 11 ++++++++--- tests/hlsl/annotations.shader_test | 4 ++-- tests/hlsl/fxgroup-syntax.shader_test | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 9424a5685..aff1b9a8e 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -114,6 +114,9 @@ static uint32_t write_string(const char *string, struct fx_write_context *fx)
static void write_pass(struct hlsl_ir_var *var, struct fx_write_context *fx) { + if (var->state_block_count) + hlsl_fixme(fx->ctx, &var->loc, "Write state block assignments."); + fx->ops->write_pass(var, fx); }
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index e8acc7552..ab1d5e47e 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -425,6 +425,7 @@ struct hlsl_ir_var
/* A dynamic array containing the state block on the variable's declaration, if any. * An array variable may contain multiple state blocks. + * A technique pass will always contain one. * These are only really used for effect profiles. */ struct hlsl_state_block **state_blocks; unsigned int state_block_count; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index d0f74ceea..2486f7542 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1132,7 +1132,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct hlsl_func_parameters }
static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *annotations, - const struct vkd3d_shader_location *loc) + struct hlsl_state_block *state_block, const struct vkd3d_shader_location *loc) { struct hlsl_ir_var *var; struct hlsl_type *type; @@ -1142,6 +1142,11 @@ static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope * return false; var->annotations = annotations;
+ var->state_blocks = hlsl_alloc(ctx, sizeof(*var->state_blocks)); + var->state_blocks[0] = state_block; + var->state_block_count = 1; + var->state_block_capacity = 1; + if (!hlsl_add_var(ctx, var, false)) { struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name); @@ -5627,9 +5632,9 @@ name_opt: | any_identifier
pass: - KW_PASS name_opt annotations_opt '{' '}' + KW_PASS name_opt annotations_opt '{' state_block_start state_block '}' { - if (!add_pass(ctx, $2, $3, &@1)) + if (!add_pass(ctx, $2, $3, $6, &@1)) YYABORT; }
diff --git a/tests/hlsl/annotations.shader_test b/tests/hlsl/annotations.shader_test index 40e383aa3..3963dfaaf 100644 --- a/tests/hlsl/annotations.shader_test +++ b/tests/hlsl/annotations.shader_test @@ -7,14 +7,14 @@ shader model < 6.0 technique10 t1 < int a = 1; > {} technique10 t2 < int a = 2; int t1 = 3; int t2 = 4; > {}
-[effect] +[effect todo] // Annotations on passes technique10 t1 < int a = 1; > { pass < int t1 = 2; > {} }
-[effect] +[effect todo] // Using names from the global scope float a;
diff --git a/tests/hlsl/fxgroup-syntax.shader_test b/tests/hlsl/fxgroup-syntax.shader_test index e8e5fbf59..aedbbfb11 100644 --- a/tests/hlsl/fxgroup-syntax.shader_test +++ b/tests/hlsl/fxgroup-syntax.shader_test @@ -1,5 +1,5 @@ % Test complex effect groups syntax -[pixel shader fail(sm>=6) todo] +[pixel shader fail(sm>=6)] fxgroup group1 { technique10