ir3: Folding of u32->u16 conversion of isam dest changes the result (the dest is not truncated)
It seems that:
isaml.base0 (u16)(x)hr0.x
doesn't just truncate the upper 16 bit of the result, but clamps? it or whatever. So it isn't equal to:
isaml.base0 (u32)(x)r0.w
(sy)cov.u32u16 hr0.x, r0.w
Changing (u16)
to (s16)
doesn't help.
The above means that folding 16 bit dest conversion via nir_fold_16bit_tex_image
is not valid for us.
Found when debugging the incorrect rendering of "Injustice 2". Reproducer:
#!amber
SHADER compute compute_shader_1 GLSL TARGET_ENV spv1.5
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(set = 0, binding = 0) uniform usamplerBuffer t34;
layout(set = 0, binding = 1) buffer block {
uint res;
};
void main()
{
res = uint(unpackHalf2x16(texelFetch(t34, 0).x & 65535u).x);
}
END
BUFFER texel_buf DATA_TYPE R32_UINT DATA
1164341248
1160593408
1156628480
1755134783
END
BUFFER res_buf DATA_TYPE R32_UINT DATA
0 0 0 0
END
PIPELINE compute pipeline_1
ATTACH compute_shader_1
BIND BUFFER texel_buf AS uniform_texel_buffer DESCRIPTOR_SET 0 BINDING 0
BIND BUFFER res_buf AS storage DESCRIPTOR_SET 0 BINDING 1
END
RUN pipeline_1 1 1 1
EXPECT res_buf IDX 0 EQ 8192