From 75afa731df8111fa07e3ba248eea9fd4fe894cec Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Thu, 27 Jan 2022 15:31:24 -0300 Subject: [PATCH] vkd3d-shader/hlsl: Check texture dimension type on method calls. Signed-off-by: Francisco Casas Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Matteo Bruni Signed-off-by: Giovanni Mascellani Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/hlsl.y | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index d51b56ec..f861011e 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1871,12 +1871,21 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl /* Only HLSL_IR_LOAD can return an object. */ object_load = hlsl_ir_load(object); - if (!strcmp(name, "Load")) + if (!strcmp(name, "Load") + && object_type->sampler_dim != HLSL_SAMPLER_DIM_CUBE + && object_type->sampler_dim != HLSL_SAMPLER_DIM_CUBEARRAY) { const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim); struct hlsl_ir_resource_load *load; struct hlsl_ir_node *coords; + if (object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS + || object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY) + { + FIXME("'Load' method for multi-sample textures.\n"); + return false; + } + if (params->args_count < 1 || params->args_count > 3) { hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, @@ -1884,7 +1893,9 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl return false; } if (params->args_count >= 2) - FIXME("Ignoring index and/or offset parameter(s).\n"); + hlsl_fixme(ctx, loc, "Offset parameter."); + if (params->args_count == 3) + hlsl_fixme(ctx, loc, "Tiled resource status argument."); /* +1 for the mipmap level */ if (!(coords = add_implicit_conversion(ctx, instrs, params->args[0], @@ -1897,7 +1908,9 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl list_add_tail(instrs, &load->node.entry); return true; } - else if (!strcmp(name, "Sample")) + else if (!strcmp(name, "Sample") + && object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMS + && object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMSARRAY) { const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim); const struct hlsl_type *sampler_type; @@ -1947,8 +1960,12 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl list_add_tail(instrs, &load->node.entry); return true; } - else if (!strcmp(name, "Gather") || !strcmp(name, "GatherRed") || !strcmp(name, "GatherBlue") + else if ((!strcmp(name, "Gather") || !strcmp(name, "GatherRed") || !strcmp(name, "GatherBlue") || !strcmp(name, "GatherGreen") || !strcmp(name, "GatherAlpha")) + && (object_type->sampler_dim == HLSL_SAMPLER_DIM_2D + || object_type->sampler_dim == HLSL_SAMPLER_DIM_2DARRAY + || object_type->sampler_dim == HLSL_SAMPLER_DIM_CUBE + || object_type->sampler_dim == HLSL_SAMPLER_DIM_CUBEARRAY)) { const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim); enum hlsl_resource_load_type load_type;