Module: vkd3d Branch: master Commit: ef9ae22ed03f5bfb85730e9362e79e9ee7c88514 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/ef9ae22ed03f5bfb85730e9362e79e...
Author: Francisco Casas fcasas@codeweavers.com Date: Tue Mar 19 15:35:59 2024 -0300
vkd3d-shader/hlsl: Store state block on pass variables.
---
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 466908cd..5bed9c7e 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -115,6 +115,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 4fa7fe1c..3cb98b76 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -426,6 +426,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 c52bd49e..0d3003f4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1117,7 +1117,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; @@ -1127,6 +1127,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); @@ -5592,9 +5597,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 40e383aa..3963dfaa 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 e8e5fbf5..aedbbfb1 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