From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/fx.c | 30 +++++++++++++----------- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + tests/hlsl/technique-fx_2.shader_test | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index bc70d5220..5ba24e6dc 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -179,7 +179,6 @@ static void fx_write_context_init(struct hlsl_ctx *ctx, const struct fx_write_co static int fx_write_context_cleanup(struct fx_write_context *fx) { struct type_entry *type, *next_type; - int status = fx->status;
rb_destroy(&fx->strings, string_storage_destroy, NULL);
@@ -189,7 +188,7 @@ static int fx_write_context_cleanup(struct fx_write_context *fx) vkd3d_free(type); }
- return status; + return fx->ctx->result; }
static bool technique_matches_version(const struct hlsl_ir_var *var, const struct fx_write_context *fx) @@ -643,15 +642,18 @@ static int hlsl_fx_2_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out) vkd3d_free(fx.unstructured.data); vkd3d_free(fx.structured.data);
- if (!fx.status) + if (!fx.technique_count) + hlsl_error(ctx, &ctx->location, VKD3D_SHADER_ERROR_HLSL_MISSING_TECHNIQUE, "No techniques found."); + + if (fx.status < 0) + ctx->result = fx.status; + + if (!ctx->result) { out->code = buffer.data; out->size = buffer.size; }
- if (fx.status < 0) - ctx->result = fx.status; - return fx_write_context_cleanup(&fx); }
@@ -870,15 +872,15 @@ static int hlsl_fx_4_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
set_status(&fx, buffer.status);
- if (!fx.status) + if (fx.status < 0) + ctx->result = fx.status; + + if (!ctx->result) { out->code = buffer.data; out->size = buffer.size; }
- if (fx.status < 0) - ctx->result = fx.status; - return fx_write_context_cleanup(&fx); }
@@ -933,15 +935,15 @@ static int hlsl_fx_5_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
set_status(&fx, buffer.status);
- if (!fx.status) + if (fx.status < 0) + ctx->result = fx.status; + + if (!ctx->result) { out->code = buffer.data; out->size = buffer.size; }
- if (fx.status < 0) - ctx->result = fx.status; - return fx_write_context_cleanup(&fx); }
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 4b322b95b..8dca450f6 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -148,6 +148,7 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_HLSL_INCONSISTENT_SAMPLER = 5026, VKD3D_SHADER_ERROR_HLSL_NON_FINITE_RESULT = 5027, VKD3D_SHADER_ERROR_HLSL_DUPLICATE_SWITCH_CASE = 5028, + VKD3D_SHADER_ERROR_HLSL_MISSING_TECHNIQUE = 5029,
VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300, VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301, diff --git a/tests/hlsl/technique-fx_2.shader_test b/tests/hlsl/technique-fx_2.shader_test index 3b71d0a3b..35963cd04 100644 --- a/tests/hlsl/technique-fx_2.shader_test +++ b/tests/hlsl/technique-fx_2.shader_test @@ -86,7 +86,7 @@ technique10 }
% Effects without techniques are not allowed for fx_2_0 -[effect fail todo] +[effect fail] float4 f;
% fx_5_0 keyword fails with fx_2_0 profile