[PATCH] D124232: [AMDGPU] Use d16 flag for image.sample instructions

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 28 02:37:58 PDT 2022


sebastian-ne accepted this revision.
sebastian-ne added a comment.
This revision is now accepted and ready to land.

In D124232#3479333 <https://reviews.llvm.org/D124232#3479333>, @piotr wrote:

> In D124232#3477435 <https://reviews.llvm.org/D124232#3477435>, @sebastian-ne wrote:
>
>> I wanted to add this combine before, but I don’t think there is a way to add d16 to an instruction without potentially breaking the code.
>> The reason is, when an image_sample has the d16 flag enabled, it will use f32→f16 truncation //or// i32→i16 truncation, depending on the texture format in the descriptor.
>>
>> Combining image_sample+fptrunc to image_sample d16 works fine for float textures, but I assume we don’t know at compile time if a texture is an integer or float texture.
>> The application may interpret stored values as float and does an fptrunc, but the texture is actually defined as an integer texture, so the hardware uses an integer trunc instead, giving different results.
>
> Are you aware of any examples that would fail with this patch? At least in Vulkan, the image format must match the sampled type.

I see, I didn’t know the type on the intrinsic always matches the type of the texture. Sorry for the noise.
It would be nice to have the same combine with integer textures.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124232/new/

https://reviews.llvm.org/D124232



More information about the llvm-commits mailing list