Skip to content

Commit c140840

Browse files
luciechoidamyanpCopilotV-FEXrtkpyzhov
authored
[SPIR-V][vk::SampledTexture] #5. Add remaining .Sample...() methods for vk::SampledTexture2D` type. (microsoft#8098)
Part of microsoft#7979 Implement remaining sample methods methods for `vk::SampledTexture2D`: ```hlsl float Object.SampleCmp(float Location, float CompareValue, [, int Offset], [, float Clamp] [, out uint Status]); float Object.SampleCmpLevelZero(float Location, float CompareValue, [, int Offset], [, out uint Status]); float Object.SampleCmpLevel(float Location, float CompareValue, float LOD, [, int Offset], [, out uint Status]); float Object.SampleGrad(float Location, float DDX, float DDY, [, int Offset], [, float Clamp] [, out uint Status]); float Object.SampleCompGrad(float Location, float CompareValue, float DDX, float DDY, [, int Offset], [, float Clamp] [, out uint Status]); float Object.SampleCompBias(float Location, float CompareValue, float Bias, [, int Offset], [, float Clamp] [, out uint Status]); PARAM_TYPE Object.SampleBias(float Location, float Bias, [, int Offset], [, float Clamp], [, out uint Status]); PARAM_TYPE Object.SampleLevel(float Location, float LOD, [, int Offset], [, out uint Status]); ``` --------- Co-authored-by: Damyan Pepper <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ashley Coleman <[email protected]> Co-authored-by: kpyzhov <[email protected]> Co-authored-by: Konstantin <[email protected]> Co-authored-by: Steven Perron <[email protected]> Co-authored-by: Alex Sepkowski <[email protected]>
1 parent 6f759a3 commit c140840

18 files changed

Lines changed: 540 additions & 164 deletions

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 203 additions & 132 deletions
Large diffs are not rendered by default.

tools/clang/test/CodeGenSPIRV/texture.array.sample-bias.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ float4 main(int2 offset : A) : SV_Target {
4343
float4 val3 = t3.SampleBias(gSampler, float4(1, 2, 3, 1), 0.5);
4444

4545
float clamp;
46-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
47-
// CHECK-NEXT: [[t1_0:%[0-9]+]] = OpLoad %type_1d_image_array %t1
46+
// CHECK: [[t1_0:%[0-9]+]] = OpLoad %type_1d_image_array %t1
4847
// CHECK-NEXT: [[gSampler_2:%[0-9]+]] = OpLoad %type_sampler %gSampler
48+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
4949
// CHECK-NEXT: [[sampledImg_2:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1_0]] [[gSampler_2]]
5050
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg_2]] [[v2fc]] Bias|ConstOffset|MinLod %float_0_5 %int_1 [[clamp]]
5151
float4 val4 = t1.SampleBias(gSampler, float2(1, 1), 0.5, 1, clamp);
@@ -57,9 +57,9 @@ float4 main(int2 offset : A) : SV_Target {
5757
float4 val5 = t3.SampleBias(gSampler, float4(1, 2, 3, 1), 0.5, /*clamp*/ 2.5f);
5858

5959
uint status;
60-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
61-
// CHECK-NEXT: [[t1_1:%[0-9]+]] = OpLoad %type_1d_image_array %t1
60+
// CHECK: [[t1_1:%[0-9]+]] = OpLoad %type_1d_image_array %t1
6261
// CHECK-NEXT: [[gSampler_4:%[0-9]+]] = OpLoad %type_sampler %gSampler
62+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
6363
// CHECK-NEXT: [[sampledImg_4:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1_1]] [[gSampler_4]]
6464
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[sampledImg_4]] [[v2fc]] Bias|ConstOffset|MinLod %float_0_5 %int_1 [[clamp_0]]
6565
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0

tools/clang/test/CodeGenSPIRV/texture.array.sample-cmp.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ float4 main(int2 offset: A, float comparator: B) : SV_Target {
3939
float val3 = t3.SampleCmp(gSampler, float4(1, 2, 3, 1), comparator);
4040

4141
float clamp;
42-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
43-
// CHECK-NEXT: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image_array %t2
42+
// CHECK: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image_array %t2
4443
// CHECK-NEXT: [[gSampler_2:%[0-9]+]] = OpLoad %type_sampler %gSampler
4544
// CHECK-NEXT: [[comparator_2:%[0-9]+]] = OpLoad %float %comparator
45+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
4646
// CHECK-NEXT: [[sampledImg_2:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_0]] [[gSampler_2]]
4747
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleDrefImplicitLod %float [[sampledImg_2]] [[v3fc]] [[comparator_2]] ConstOffset|MinLod [[v2ic]] [[clamp]]
4848
float val4 = t2.SampleCmp(gSampler, float3(1, 2, 1), comparator, 1, clamp);
@@ -55,10 +55,10 @@ float4 main(int2 offset: A, float comparator: B) : SV_Target {
5555
float val5 = t3.SampleCmp(gSampler, float4(1, 2, 3, 1), comparator, /*clamp*/ 1.5);
5656

5757
uint status;
58-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
59-
// CHECK-NEXT: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image_array %t2
58+
// CHECK: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image_array %t2
6059
// CHECK-NEXT: [[gSampler_4:%[0-9]+]] = OpLoad %type_sampler %gSampler
6160
// CHECK-NEXT: [[comparator_4:%[0-9]+]] = OpLoad %float %comparator
61+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
6262
// CHECK-NEXT: [[sampledImg_4:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_1]] [[gSampler_4]]
6363
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleDrefImplicitLod %SparseResidencyStruct [[sampledImg_4]] [[v3fc]] [[comparator_4]] ConstOffset|MinLod [[v2ic]] [[clamp_0]]
6464
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0

tools/clang/test/CodeGenSPIRV/texture.array.sample-grad.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ float4 main(int2 offset : A) : SV_Target {
5454
float4 val4 = t2.SampleGrad(gSampler, float3(1, 1, 1), float2(2, 2), float2(3, 3), 1, /*clamp*/2.5);
5555

5656
float clamp;
57-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
58-
// CHECK-NEXT: [[t3_0:%[0-9]+]] = OpLoad %type_cube_image_array %t3
57+
// CHECK: [[t3_0:%[0-9]+]] = OpLoad %type_cube_image_array %t3
5958
// CHECK-NEXT: [[gSampler_3:%[0-9]+]] = OpLoad %type_sampler %gSampler
59+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
6060
// CHECK-NEXT: [[sampledImg_3:%[0-9]+]] = OpSampledImage %type_sampled_image_1 [[t3_0]] [[gSampler_3]]
6161
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleExplicitLod %v4float [[sampledImg_3]] [[v4f_1]] Grad|MinLod [[v3f_2]] [[v3f_3]] [[clamp]]
6262
float4 val5 = t3.SampleGrad(gSampler, float4(1, 1, 1, 1), float3(2, 2, 2), float3(3, 3, 3), clamp);
@@ -72,9 +72,9 @@ float4 main(int2 offset : A) : SV_Target {
7272
// CHECK-NEXT: OpStore %val6 [[result]]
7373
float4 val6 = t2.SampleGrad(gSampler, float3(1, 1, 1), float2(2, 2), float2(3, 3), 1, /*clamp*/2.5, status);
7474

75-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
76-
// CHECK-NEXT: [[t3_1:%[0-9]+]] = OpLoad %type_cube_image_array %t3
75+
// CHECK: [[t3_1:%[0-9]+]] = OpLoad %type_cube_image_array %t3
7776
// CHECK-NEXT: [[gSampler_5:%[0-9]+]] = OpLoad %type_sampler %gSampler
77+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
7878
// CHECK-NEXT: [[sampledImg_5:%[0-9]+]] = OpSampledImage %type_sampled_image_1 [[t3_1]] [[gSampler_5]]
7979
// CHECK-NEXT: [[structResult_0:%[0-9]+]] = OpImageSparseSampleExplicitLod %SparseResidencyStruct [[sampledImg_5]] [[v4f_1]] Grad|MinLod [[v3f_2]] [[v3f_3]] [[clamp_0]]
8080
// CHECK-NEXT: [[status_0:%[0-9]+]] = OpCompositeExtract %uint [[structResult_0]] 0

tools/clang/test/CodeGenSPIRV/texture.array.sample.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ float4 main() : SV_Target {
4242
float4 val3 = t3.Sample(gSampler, float4(0.5, 0.25, 0.125, 1));
4343

4444
float clamp;
45-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
46-
// CHECK-NEXT: [[t1_0:%[0-9]+]] = OpLoad %type_1d_image_array %t1
45+
// CHECK: [[t1_0:%[0-9]+]] = OpLoad %type_1d_image_array %t1
4746
// CHECK-NEXT: [[gSampler_2:%[0-9]+]] = OpLoad %type_sampler %gSampler
47+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
4848
// CHECK-NEXT: [[sampledImg_2:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1_0]] [[gSampler_2]]
4949
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg_2]] [[v2fc]] ConstOffset|MinLod %int_1 [[clamp]]
5050
float4 val4 = t1.Sample(gSampler, float2(0.5, 1), 1, clamp);
@@ -56,9 +56,9 @@ float4 main() : SV_Target {
5656
float4 val5 = t3.Sample(gSampler, float4(0.5, 0.25, 0.125, 1), /*clamp*/ 1.5);
5757

5858
uint status;
59-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
60-
// CHECK-NEXT: [[t1_1:%[0-9]+]] = OpLoad %type_1d_image_array %t1
59+
// CHECK: [[t1_1:%[0-9]+]] = OpLoad %type_1d_image_array %t1
6160
// CHECK-NEXT: [[gSampler_4:%[0-9]+]] = OpLoad %type_sampler %gSampler
61+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
6262
// CHECK-NEXT: [[sampledImg_4:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1_1]] [[gSampler_4]]
6363
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[sampledImg_4]] [[v2fc]] ConstOffset|MinLod %int_1 [[clamp_0]]
6464
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0

tools/clang/test/CodeGenSPIRV/texture.sample-bias.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ float4 main(int3 offset: A) : SV_Target {
5151
float4 val4 = t4.SampleBias(gSampler, float3(1, 2, 3), 0.5);
5252

5353
float clamp;
54-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
55-
// CHECK-NEXT: [[t3_0:%[0-9]+]] = OpLoad %type_3d_image %t3
54+
// CHECK: [[t3_0:%[0-9]+]] = OpLoad %type_3d_image %t3
5655
// CHECK-NEXT: [[gSampler_3:%[0-9]+]] = OpLoad %type_sampler %gSampler
56+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
5757
// CHECK-NEXT: [[sampledImg_3:%[0-9]+]] = OpSampledImage %type_sampled_image_1 [[t3_0]] [[gSampler_3]]
5858
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg_3]] [[v3fc]] Bias|ConstOffset|MinLod %float_0_5 [[v3ic]] [[clamp]]
5959
float4 val5 = t3.SampleBias(gSampler, float3(1, 2, 3), 0.5, 1, clamp);
@@ -65,9 +65,9 @@ float4 main(int3 offset: A) : SV_Target {
6565
float4 val6 = t4.SampleBias(gSampler, float3(1, 2, 3), 0.5, /*clamp*/ 2.5);
6666

6767
uint status;
68-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
69-
// CHECK-NEXT: [[t3_1:%[0-9]+]] = OpLoad %type_3d_image %t3
68+
// CHECK: [[t3_1:%[0-9]+]] = OpLoad %type_3d_image %t3
7069
// CHECK-NEXT: [[gSampler_5:%[0-9]+]] = OpLoad %type_sampler %gSampler
70+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
7171
// CHECK-NEXT: [[sampledImg_5:%[0-9]+]] = OpSampledImage %type_sampled_image_1 [[t3_1]] [[gSampler_5]]
7272
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[sampledImg_5]] [[v3fc]] Bias|ConstOffset|MinLod %float_0_5 [[v3ic]] [[clamp_0]]
7373
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0

tools/clang/test/CodeGenSPIRV/texture.sample-cmp.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ float4 main(int2 offset: A, float comparator: B) : SV_Target {
3939
float val4 = t4.SampleCmp(gSampler, float3(1, 2, 3), comparator);
4040

4141
float clamp;
42-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
43-
// CHECK-NEXT: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image %t2
42+
// CHECK: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image %t2
4443
// CHECK-NEXT: [[gSampler_2:%[0-9]+]] = OpLoad %type_sampler %gSampler
4544
// CHECK-NEXT: [[comparator_2:%[0-9]+]] = OpLoad %float %comparator
45+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
4646
// CHECK-NEXT: [[sampledImg_2:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_0]] [[gSampler_2]]
4747
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleDrefImplicitLod %float [[sampledImg_2]] [[v2fc]] [[comparator_2]] ConstOffset|MinLod [[v2ic]] [[clamp]]
4848
float val5 = t2.SampleCmp(gSampler, float2(1, 2), comparator, 1, clamp);
@@ -55,10 +55,10 @@ float4 main(int2 offset: A, float comparator: B) : SV_Target {
5555
float val6 = t4.SampleCmp(gSampler, float3(1, 2, 3), comparator, /*clamp*/2.5);
5656

5757
uint status;
58-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
59-
// CHECK-NEXT: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image %t2
58+
// CHECK: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image %t2
6059
// CHECK-NEXT: [[gSampler_4:%[0-9]+]] = OpLoad %type_sampler %gSampler
6160
// CHECK-NEXT: [[comparator_4:%[0-9]+]] = OpLoad %float %comparator
61+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
6262
// CHECK-NEXT: [[sampledImg_4:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_1]] [[gSampler_4]]
6363
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleDrefImplicitLod %SparseResidencyStruct [[sampledImg_4]] [[v2fc]] [[comparator_4]] ConstOffset|MinLod [[v2ic]] [[clamp_0]]
6464
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0

tools/clang/test/CodeGenSPIRV/texture.sample-grad.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ float4 main(int2 offset : A) : SV_Target {
5555
float4 val4 = t4.SampleGrad(gSampler, float3(1, 1, 1), float3(2, 2, 2), float3(3, 3, 3));
5656

5757
float clamp;
58-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
59-
// CHECK-NEXT: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image %t2
58+
// CHECK: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image %t2
6059
// CHECK-NEXT: [[gSampler_3:%[0-9]+]] = OpLoad %type_sampler %gSampler
60+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
6161
// CHECK-NEXT: [[sampledImg_3:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_0]] [[gSampler_3]]
6262
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleExplicitLod %v4float [[sampledImg_3]] [[v2f_1]] Grad|ConstOffset|MinLod [[v2f_2]] [[v2f_3]] [[v2i_3]] [[clamp]]
6363
float4 val5 = t2.SampleGrad(gSampler, float2(1, 1), float2(2, 2), float2(3, 3), 3, clamp);
@@ -69,9 +69,9 @@ float4 main(int2 offset : A) : SV_Target {
6969
float4 val6 = t4.SampleGrad(gSampler, float3(1, 1, 1), float3(2, 2, 2), float3(3, 3, 3), /*clamp*/3.5);
7070

7171
uint status;
72-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
73-
// CHECK-NEXT: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image %t2
72+
// CHECK: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image %t2
7473
// CHECK-NEXT: [[gSampler_5:%[0-9]+]] = OpLoad %type_sampler %gSampler
74+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
7575
// CHECK-NEXT: [[sampledImg_5:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_1]] [[gSampler_5]]
7676
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleExplicitLod %SparseResidencyStruct [[sampledImg_5]] [[v2f_1]] Grad|ConstOffset|MinLod [[v2f_2]] [[v2f_3]] [[v2i_3]] [[clamp_0]]
7777
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0

tools/clang/test/CodeGenSPIRV/texture.sample.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ float4 main(int2 offset: A) : SV_Target {
5151
float4 val4 = t4.Sample(gSampler, float3(0.5, 0.25, 0.3));
5252

5353
float clamp;
54-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
55-
// CHECK-NEXT: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image %t2
54+
// CHECK: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image %t2
5655
// CHECK-NEXT: [[gSampler_3:%[0-9]+]] = OpLoad %type_sampler %gSampler
56+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
5757
// CHECK-NEXT: [[sampledImg_3:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_0]] [[gSampler_3]]
5858
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg_3]] [[v2fc]] ConstOffset|MinLod [[v2ic]] [[clamp]]
5959
float4 val5 = t2.Sample(gSampler, float2(0.5, 0.25), int2(2, 3), clamp);
@@ -65,9 +65,9 @@ float4 main(int2 offset: A) : SV_Target {
6565
float4 val6 = t4.Sample(gSampler, float3(0.5, 0.25, 0.3), /*clamp*/ 2.0f);
6666

6767
uint status;
68-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
69-
// CHECK-NEXT: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image %t2
68+
// CHECK: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image %t2
7069
// CHECK-NEXT: [[gSampler_5:%[0-9]+]] = OpLoad %type_sampler %gSampler
70+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
7171
// CHECK-NEXT: [[sampledImg_5:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_1]] [[gSampler_5]]
7272
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[sampledImg_5]] [[v2fc]] ConstOffset|MinLod [[v2ic]] [[clamp_0]]
7373
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: OpCapability SparseResidency
4+
5+
// CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25
6+
// CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3
7+
8+
// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
9+
// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]]
10+
// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]]
11+
12+
// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant
13+
14+
vk::SampledTexture2D<float4> tex1 : register(t0);
15+
16+
float4 main() : SV_Target {
17+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]]
18+
// CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1_load]] [[v2fc]] %float_2 Lod %float_1
19+
float val1 = tex1.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f);
20+
21+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]]
22+
// CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex2_load]] [[v2fc]] %float_2 Lod|ConstOffset %float_1 [[v2ic]]
23+
float val2 = tex1.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3));
24+
25+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]]
26+
// CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefExplicitLod %SparseResidencyStruct [[tex3_load]] [[v2fc]] %float_2 Lod|ConstOffset %float_1 [[v2ic]]
27+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result3]] 0
28+
// CHECK: OpStore %status [[status_0]]
29+
uint status;
30+
float val3 = tex1.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3), status);
31+
return 1.0;
32+
}

0 commit comments

Comments
 (0)