llvm / llvm/llvm-project

[HLSL][SPIRV] Handle resource `Load(int, out uint)` and `CheckAccessFullyMapped` when targeting SPIR-V

Open
#166,954 1 comment 0 reactions 0 assignees View on GitHub
backend:SPIR-V HLSL
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

All of the HLSL buffer (and texture) types have overloads of Load like [RWBuffer::Load(int, out uint)](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/rwbuffer-load-float-uint-). We have implementations of these using builtins, but the builtins are currently only handled correctly for DirectX.

[DXC maps these loads to OpImageSparseRead](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#load-1), and uses `OpImageSparseTexelsResident` on the resulting status for `CheckAccessFullyMapped`. Note that in DirectX we've implemented the Load function as-if it calls CheckAccessFullyMapped implicitly, which I believe also matches the behaviour of DXC, and thus we've implemented CheckAccessFullyMapped as simply a cast from uint to bool. I haven't looked into whether this makes sense for SPIR-V too.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing HLSL Load builtin handling for DirectX and comparing it with DXC's SPIR-V mapping described in the issue. Determine how the load result and CheckAccessFullyMapped status should be represented for SPIR-V, then verify the behavior with the relevant compiler or SPIR-V tests; done means both overload handling and status checks work when targeting SPIR-V.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.