Skip to content

ir3: Don't use 16b coords for texel buffer sampling

What does this MR do and why?

{i}sam{*} treats 16b coords as signed instead of unsigned, so it would return 0 e.g. for offset 32768.

All other cases I think should be fine since for all other images the size limits are less than 32768 in a single dimension.

A simple reproducer (amber script):

#!amber

SHADER compute compute_shader GLSL
#version 450

#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require
#extension GL_EXT_shader_16bit_storage : require

layout(set = 0, binding = 0) buffer block {
    int value;
    u16vec2 offset;
};

layout(set = 0, binding = 1) uniform itextureBuffer s1;

void
main()
{
    value = texelFetch(s1, offset.x).x;
}
END

BUFFER buf_in DATA_TYPE R16G16_SINT SIZE 65536 FILL 7

BUFFER buf_out DATA_TYPE uint16 DATA 0 0 32768 32769 END

PIPELINE compute pipeline
  ATTACH compute_shader

  BIND BUFFER buf_out AS storage DESCRIPTOR_SET 0 BINDING 0
  BIND BUFFER buf_in AS uniform_texel_buffer DESCRIPTOR_SET 0 BINDING 1
END

RUN pipeline 1 1 1

EXPECT buf_out IDX 0 EQ 7

Merge request reports

Loading