-
Notifications
You must be signed in to change notification settings - Fork 463
Expand file tree
/
Copy pathgh-9916.slang
More file actions
49 lines (41 loc) · 1.71 KB
/
Copy pathgh-9916.slang
File metadata and controls
49 lines (41 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//TEST:SIMPLE(filecheck=CHECK): -target spirv-asm -stage fragment -entry fragmentMain -O3
//TEST:SIMPLE(filecheck=CHECK_BINDLESS): -target spirv-asm -stage fragment -entry fragmentMain -capability spvBindlessTextureNV -DUSE_BINDLESS_NV
// A global DescriptorHandle constant lowers to a module-scope descriptor-handle
// representation cast. SPIR-V emission should treat that cast as transparent.
static const DescriptorHandle<SamplerState> kSampler =
DescriptorHandle<SamplerState>(uint2(3, 4));
static const uint2 kSamplerBits = (uint2)kSampler;
#ifdef USE_BINDLESS_NV
static const DescriptorHandle<Texture2D<float4>> kTexture =
DescriptorHandle<Texture2D<float4>>(uint64_t(5));
static const uint64_t kTextureBits = (uint64_t)kTexture;
#endif
struct FragmentInput
{
float4 position : SV_Position;
float2 uv : TEXCOORD0;
};
struct Args
{
DescriptorHandle<Texture2D<float4>> texture;
};
[[vk::push_constant]] uniform Args args;
[shader("fragment")]
float4 fragmentMain(FragmentInput input) : SV_Target
{
#ifdef USE_BINDLESS_NV
float2 uv = input.uv + float2(float(uint(kTextureBits)), 0.0) * 0.000001;
return kTexture.Sample(kSampler, uv);
#else
float2 uv = input.uv + float2(float(kSamplerBits.x), float(kSamplerBits.y)) * 0.000001;
return args.texture.Sample(kSampler, uv);
#endif
}
// CHECK-DAG: %[[F3:[A-Za-z0-9_]+]] = OpConstant %float {{3\.000[0-9]*e-06}}
// CHECK-DAG: %[[F4:[A-Za-z0-9_]+]] = OpConstant %float {{3\.999[0-9]*e-06}}
// CHECK-DAG: OpConstantComposite %v2float %[[F3]] %[[F4]]
// CHECK: OpImageSampleImplicitLod
// CHECK_BINDLESS: OpCapability BindlessTextureNV
// CHECK_BINDLESS: OpConstant %ulong 5
// CHECK_BINDLESS: OpConvertUToSampledImageNV
// CHECK_BINDLESS: OpImageSampleImplicitLod