[all-commits] [llvm/llvm-project] 68173c: [HLSL][SPRIV] Handle signed RWBuffer correctly (#1...

Steven Perron via All-commits all-commits at lists.llvm.org
Wed Jul 2 09:10:08 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 68173c80915955bae8cfc697a98d5d7888f09c67
      https://github.com/llvm/llvm-project/commit/68173c80915955bae8cfc697a98d5d7888f09c67
  Author: Steven Perron <stevenperron at google.com>
  Date:   2025-07-02 (Wed, 02 Jul 2025)

  Changed paths:
    M clang/lib/CodeGen/Targets/SPIR.cpp
    M clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl
    M clang/test/CodeGenHLSL/builtins/RWBuffer-subscript.hlsl
    M llvm/docs/SPIRVUsage.rst
    M llvm/lib/IR/Type.cpp
    M llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
    M llvm/lib/Target/SPIRV/SPIRVBuiltins.td
    M llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
    M llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
    M llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h
    M llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
    A llvm/test/CodeGen/SPIRV/hlsl-resources/MixedBufferLoadStore.ll
    A llvm/test/CodeGen/SPIRV/hlsl-resources/SignedBufferLoadStore.ll
    A llvm/test/CodeGen/SPIRV/hlsl-resources/UnsignedBufferLoadStore.ll

  Log Message:
  -----------
  [HLSL][SPRIV] Handle signed RWBuffer correctly (#144774)

In Vulkan, the signedness of the accesses to images has to match the
signedness of the backing image.
    
See

https://docs.vulkan.org/spec/latest/chapters/textures.html#textures-input,
where it says the behaviour is undefined if
    
> the signedness of any read or sample operation does not match the
signedness of the image’s format.
    
Users who define say an `RWBuffer<int>` will create a Vulkan image with
a signed integer format. So the HLSL that is generated must match that
expecation.
    
The solution we use is to generate a `spirv.SignedImage` target type for
signed integer instead of `spirv.Image`. The two types are otherwise the
same.
    
The backend will add the `signExtend` image operand to access to the
image to ensure the image is access as a signed image.
    
Fixes #144580



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list