From b382d1843dd5bfb29f7c91adb65a48cd5dbd3858 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 19 Mar 2024 10:46:31 +0100 Subject: [PATCH] vkd3d-shader/fx: Accept texture types when writing fx_2_0 effects. Signed-off-by: Nikolay Sivov --- libs/vkd3d-shader/fx.c | 44 ++++++++++++++++++++ tests/hlsl/effect-variables-fx_2.shader_test | 13 ++++++ 2 files changed, 57 insertions(+) diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 75fa3a3f..9424a568 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -649,6 +649,7 @@ static uint32_t write_fx_2_parameter(const struct hlsl_type *type, const char *n case HLSL_TYPE_INT: case HLSL_TYPE_UINT: case HLSL_TYPE_VOID: + case HLSL_TYPE_TEXTURE: break; default: hlsl_fixme(ctx, &ctx->location, "Writing parameter type %u is not implemented.", @@ -772,6 +773,46 @@ static uint32_t write_fx_2_initial_value(const struct hlsl_ir_var *var, struct f return offset; } +static bool is_type_supported_fx_2(const struct hlsl_type *type) +{ + type = hlsl_get_multiarray_element_type(type); + + if (type->class == HLSL_CLASS_STRUCT) + return true; + + switch (type->base_type) + { + case HLSL_TYPE_FLOAT: + case HLSL_TYPE_HALF: + case HLSL_TYPE_DOUBLE: + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + case HLSL_TYPE_BOOL: + case HLSL_TYPE_PIXELSHADER: + case HLSL_TYPE_VERTEXSHADER: + case HLSL_TYPE_STRING: + return true; + case HLSL_TYPE_TEXTURE: + case HLSL_TYPE_SAMPLER: + switch (type->sampler_dim) + { + case HLSL_SAMPLER_DIM_1D: + case HLSL_SAMPLER_DIM_2D: + case HLSL_SAMPLER_DIM_3D: + case HLSL_SAMPLER_DIM_CUBE: + case HLSL_SAMPLER_DIM_GENERIC: + return true; + default: + ; + } + break; + default: + return false; + } + + return false; +} + static void write_fx_2_parameters(struct fx_write_context *fx) { struct vkd3d_bytecode_buffer *buffer = &fx->structured; @@ -785,6 +826,9 @@ static void write_fx_2_parameters(struct fx_write_context *fx) LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry) { + if (!is_type_supported_fx_2(var->data_type)) + continue; + desc_offset = write_fx_2_parameter(var->data_type, var->name, &var->semantic, fx); value_offset = write_fx_2_initial_value(var, fx); diff --git a/tests/hlsl/effect-variables-fx_2.shader_test b/tests/hlsl/effect-variables-fx_2.shader_test index 570d855a..8e9fd4d5 100644 --- a/tests/hlsl/effect-variables-fx_2.shader_test +++ b/tests/hlsl/effect-variables-fx_2.shader_test @@ -11,3 +11,16 @@ uint _uint; technique { } + +[effect] +Texture tex1; +texture tex2; +teXture tex3; +Texture2DMS tex4; +Texture1D tex5; +Texture2D tex6; +Texture3D tex7; + +technique +{ +}