Skip to content
Snippets Groups Projects
Commit 91e7eeb1 authored by Nikolay Sivov's avatar Nikolay Sivov
Browse files

vkd3d-shader/hlsl: Add an explicit cast to uint for array index access.


Signed-off-by: default avatarNikolay Sivov <nsivov@codeweavers.com>
parent 46a1b66d
Branches array_index
No related tags found
No related merge requests found
Pipeline #27755 passed with warnings
......@@ -49,6 +49,7 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
case HLSL_CLASS_ARRAY:
{
unsigned int size = hlsl_type_get_array_element_reg_size(type->e.array.type, regset);
struct hlsl_ir_node *cast;
if (regset == HLSL_REGSET_NUMERIC)
{
......@@ -60,7 +61,11 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
return NULL;
hlsl_block_add_instr(block, c);
if (!(idx_offset = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, c, idx)))
if (!(cast = hlsl_new_cast(ctx, idx, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc)))
return NULL;
hlsl_block_add_instr(block, cast);
if (!(idx_offset = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, c, cast)))
return NULL;
hlsl_block_add_instr(block, idx_offset);
......
......@@ -247,3 +247,14 @@ todo(sm<4 | glsl) draw quad
if(sm<4) todo probe (0,0) rgba (1.0, 1.0, 1.0, 1.0)
if(sm>=4 & sm<6) todo probe (0,0) rgba (4.0, 4.0, 4.0, 4.0)
if(sm>=6) probe (0,0) rgba (4.0, 3.0, 2.0, 1.0)
[require]
shader model >= 4.0
[pixel shader]
float4 f[2];
float4 main(uint index : INDEX) : sv_target
{
return f[index];
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment