diff options
author | Finn Plummer <finn.c.plum@gmail.com> | 2025-06-05 10:18:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-05 10:18:49 -0700 |
commit | b3ed4288bd2a7e7f4d0494793b64c81df6e93f95 (patch) | |
tree | 4dce79b3c207ac73b28cbd088ff8be4bcc139187 /clang | |
parent | 7ce315d14aa5c084574cc3a17552625f322e1d16 (diff) | |
download | llvm-b3ed4288bd2a7e7f4d0494793b64c81df6e93f95.zip llvm-b3ed4288bd2a7e7f4d0494793b64c81df6e93f95.tar.gz llvm-b3ed4288bd2a7e7f4d0494793b64c81df6e93f95.tar.bz2 |
[HLSL][RootSignature] Metadata generation of StaticSampler (#142642)
Implements metadata generation of a Root Signature from its in-memory
representation. It follows the same style as:
https://github.com/llvm/llvm-project/pull/139633.
This pr handles `StaticSamplers`. It also handles converting the else-if
chain into a `std::visit` to allow for future compiler warnings when
adding additional `RootElement` variants.
The metadata follows the format described
[here](https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#metadata-schema).
- Implement `BuildStaticSampler` into HLSLRootSignature.h
- Add sample testcases demonstrating functionality
Note: there is no validation of metadata nodes as the
`llvm::hlsl::rootsig::RootElement` that generates it will have already
been validated.
Resolves https://github.com/llvm/llvm-project/issues/126586
Diffstat (limited to 'clang')
-rw-r--r-- | clang/test/CodeGenHLSL/RootSignature.hlsl | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/clang/test/CodeGenHLSL/RootSignature.hlsl b/clang/test/CodeGenHLSL/RootSignature.hlsl index 34caa3e..ca843ff 100644 --- a/clang/test/CodeGenHLSL/RootSignature.hlsl +++ b/clang/test/CodeGenHLSL/RootSignature.hlsl @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -o - %s | FileCheck %s // CHECK: !dx.rootsignatures = !{![[#EMPTY_ENTRY:]], ![[#DT_ENTRY:]], -// CHECK-SAME: ![[#RF_ENTRY:]], ![[#RC_ENTRY:]], ![[#RD_ENTRY:]]} +// CHECK-SAME: ![[#RF_ENTRY:]], ![[#RC_ENTRY:]], ![[#RD_ENTRY:]], ![[#SS_ENTRY:]]} // CHECK: ![[#EMPTY_ENTRY]] = !{ptr @EmptyEntry, ![[#EMPTY:]]} // CHECK: ![[#EMPTY]] = !{} @@ -66,6 +66,40 @@ void RootConstantsEntry() {} [numthreads(1,1,1)] void RootDescriptorsEntry() {} +// CHECK: ![[#SS_ENTRY]] = !{ptr @StaticSamplerEntry, ![[#SS_RS:]]} +// CHECK: ![[#SS_RS]] = !{![[#STATIC_SAMPLER:]]} + +// checking filter = 0x4 +// CHECK: ![[#STATIC_SAMPLER]] = !{!"StaticSampler", i32 4, + +// checking texture address[U|V|W] +// CHECK-SAME: i32 2, i32 3, i32 5, + +// checking mipLODBias, maxAnisotropy, comparisonFunc, borderColor +// CHECK-SAME: float 0x40403999A0000000, i32 9, i32 3, i32 2, + +// checking minLOD, maxLOD +// CHECK-SAME: float -1.280000e+02, float 1.280000e+02, + +// checking register, space and visibility +// CHECK-SAME: i32 42, i32 0, i32 0} + +#define SampleStaticSampler \ + "StaticSampler(s42, " \ + " filter = FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT, " \ + " addressU = TEXTURE_ADDRESS_MIRROR, " \ + " addressV = TEXTURE_ADDRESS_CLAMP, " \ + " addressW = TEXTURE_ADDRESS_MIRRORONCE, " \ + " mipLODBias = 32.45f, maxAnisotropy = 9, " \ + " comparisonFunc = COMPARISON_EQUAL, " \ + " borderColor = STATIC_BORDER_COLOR_OPAQUE_WHITE, " \ + " minLOD = -128.f, maxLOD = 128.f, " \ + " space = 0, visibility = SHADER_VISIBILITY_ALL, " \ + ")" +[shader("compute"), RootSignature(SampleStaticSampler)] +[numthreads(1,1,1)] +void StaticSamplerEntry() {} + // Sanity test to ensure no root is added for this function as there is only // two entries in !dx.roosignatures [shader("compute")] |