From: Francisco Casas Subject: [PATCH vkd3d v5 4/6] vkd3d-shader/hlsl: Check texture dimension type on method calls. Message-Id: <20220127183126.92970-4-fcasas@codeweavers.com> Date: Thu, 27 Jan 2022 15:31:24 -0300 Signed-off-by: Francisco Casas --- Note that for multi-sampled textures (and only for multi-sampled textures) the Load method requires the sample index as argument 2, and thus, can accept from 3 to 4 arguments. While multi-sampled textures won't be parsed yet, I added a FIXME as a reminder that the behaviour is rather different, this also allowed to be more precise in the succesive fixmes. Signed-off-by: Francisco Casas --- 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 18126032..2f1bd447 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1837,12 +1837,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, @@ -1850,7 +1859,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], @@ -1863,7 +1874,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; @@ -1913,8 +1926,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; -- 2.25.1