Skip to content

Commit 7962053

Browse files
committed
Address comments and add tests
1 parent 6048db8 commit 7962053

36 files changed

Lines changed: 1092 additions & 8 deletions

File tree

tools/clang/lib/SPIRV/LowerTypeVisitor.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,12 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
862862
loweredType = spvContext.getUIntType(32);
863863
}
864864

865+
// Drop the "SampledTexture" prefix.
866+
StringRef suffix = name.drop_front(14);
865867
const spv::Dim dimension =
866-
name.count("1D") > 0 ? spv::Dim::Dim1D : spv::Dim::Dim2D;
867-
const bool isArray = name.count("Array") > 0;
868-
const bool isMS = name.count("MS") > 0;
868+
suffix.startswith("1D") ? spv::Dim::Dim1D : spv::Dim::Dim2D;
869+
const bool isArray = suffix.endswith("Array");
870+
const bool isMS = suffix.find("MS") != StringRef::npos;
869871

870872
const auto *imageType = spvContext.getImageType(
871873
loweredType, dimension, ImageType::WithDepth::No, isArray, isMS,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
5+
6+
vk::SampledTexture1D<float4> tex1d;
7+
8+
void main() {
9+
// CHECK: OpStore %pos1 %uint_1
10+
uint pos1 = 1;
11+
12+
// CHECK: [[pos1:%[a-zA-Z0-9_]+]] = OpLoad %uint %pos1
13+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
14+
// CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_1d_image [[tex1_load]]
15+
// CHECK: [[fetch_result:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image]] [[pos1]] Lod %uint_0
16+
// CHECK: OpStore %a1 [[fetch_result]]
17+
float4 a1 = tex1d[pos1];
18+
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %dxc -T ps_6_8 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
5+
6+
vk::SampledTexture1D<float4> tex1d;
7+
8+
void main() {
9+
// CHECK: OpStore %x %float_0_5
10+
float x = 0.5;
11+
12+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
13+
// CHECK: [[x:%[a-zA-Z0-9_]+]] = OpLoad %float %x
14+
// CHECK: [[lod_query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[x]]
15+
// CHECK: [[unclamped_lod:%[a-zA-Z0-9_]+]] = OpCompositeExtract %float [[lod_query]] 1
16+
// CHECK: OpStore %lod1 [[unclamped_lod]]
17+
float lod1 = tex1d.CalculateLevelOfDetailUnclamped(x);
18+
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
5+
6+
vk::SampledTexture1D<float4> tex1d;
7+
8+
void main() {
9+
// CHECK: OpStore %x %float_0_5
10+
float x = 0.5;
11+
12+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
13+
// CHECK: [[x:%[a-zA-Z0-9_]+]] = OpLoad %float %x
14+
// CHECK: [[lod_query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[x]]
15+
// CHECK: [[lod:%[a-zA-Z0-9_]+]] = OpCompositeExtract %float [[lod_query]] 0
16+
// CHECK: OpStore %lod [[lod]]
17+
float lod = tex1d.CalculateLevelOfDetail(x);
18+
19+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
// RUN: not %dxc -T ps_6_0 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=ERROR
3+
4+
// CHECK: OpCapability ImageQuery
5+
6+
// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown
7+
// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]]
8+
9+
vk::SampledTexture1D<float4> tex1d;
10+
11+
void main() {
12+
uint mipLevel = 1;
13+
uint width, height, numLevels, elements, numSamples;
14+
15+
// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
16+
// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_1d_image]] [[t1_load]]
17+
// CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQuerySizeLod %uint [[image1]] %int_0
18+
// CHECK-NEXT: OpStore %width [[query1]]
19+
tex1d.GetDimensions(width);
20+
21+
// CHECK: [[t2_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
22+
// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_1d_image]] [[t2_load]]
23+
// CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel
24+
// CHECK-NEXT: [[query2:%[0-9]+]] = OpImageQuerySizeLod %uint [[image2]] [[mip]]
25+
// CHECK-NEXT: OpStore %width [[query2]]
26+
// CHECK-NEXT: [[query_level_2:%[0-9]+]] = OpImageQueryLevels %uint [[image2]]
27+
// CHECK-NEXT: OpStore %numLevels [[query_level_2]]
28+
tex1d.GetDimensions(mipLevel, width, numLevels);
29+
30+
float f_width, f_height, f_numLevels;
31+
// CHECK: [[t3_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
32+
// CHECK-NEXT: [[image3:%[0-9]+]] = OpImage [[type_1d_image]] [[t3_load]]
33+
// CHECK-NEXT: [[query3:%[0-9]+]] = OpImageQuerySizeLod %uint [[image3]] %int_0
34+
// CHECK-NEXT: [[f_query3:%[0-9]+]] = OpConvertUToF %float [[query3]]
35+
// CHECK-NEXT: OpStore %f_width [[f_query3]]
36+
tex1d.GetDimensions(f_width);
37+
38+
// CHECK: [[t4_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
39+
// CHECK-NEXT: [[image4:%[0-9]+]] = OpImage [[type_1d_image]] [[t4_load]]
40+
// CHECK-NEXT: [[mip4:%[0-9]+]] = OpLoad %uint %mipLevel
41+
// CHECK-NEXT: [[query4:%[0-9]+]] = OpImageQuerySizeLod %uint [[image4]] [[mip4]]
42+
// CHECK-NEXT: [[f_query4:%[0-9]+]] = OpConvertUToF %float [[query4]]
43+
// CHECK-NEXT: OpStore %f_width [[f_query4]]
44+
// CHECK-NEXT: [[query_level_4:%[0-9]+]] = OpImageQueryLevels %uint [[image4]]
45+
// CHECK-NEXT: [[f_query_level_4:%[0-9]+]] = OpConvertUToF %float [[query_level_4]]
46+
// CHECK-NEXT: OpStore %f_numLevels [[f_query_level_4]]
47+
tex1d.GetDimensions(mipLevel, f_width, f_numLevels);
48+
49+
int i_width, i_height, i_numLevels;
50+
// CHECK: [[t5_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
51+
// CHECK-NEXT: [[image5:%[0-9]+]] = OpImage [[type_1d_image]] [[t5_load]]
52+
// CHECK-NEXT: [[query5:%[0-9]+]] = OpImageQuerySizeLod %uint [[image5]] %int_0
53+
// CHECK-NEXT: [[query5_i:%[0-9]+]] = OpBitcast %int [[query5]]
54+
// CHECK-NEXT: OpStore %i_width [[query5_i]]
55+
tex1d.GetDimensions(i_width);
56+
57+
// CHECK: [[t6_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
58+
// CHECK-NEXT: [[image6:%[0-9]+]] = OpImage [[type_1d_image]] [[t6_load]]
59+
// CHECK-NEXT: [[mip6:%[0-9]+]] = OpLoad %uint %mipLevel
60+
// CHECK-NEXT: [[query6:%[0-9]+]] = OpImageQuerySizeLod %uint [[image6]] [[mip6]]
61+
// CHECK-NEXT: [[query6_i:%[0-9]+]] = OpBitcast %int [[query6]]
62+
// CHECK-NEXT: OpStore %i_width [[query6_i]]
63+
// CHECK-NEXT: [[query_level_6:%[0-9]+]] = OpImageQueryLevels %uint [[image6]]
64+
// CHECK-NEXT: [[query_level_6_i:%[0-9]+]] = OpBitcast %int [[query_level_6]]
65+
// CHECK-NEXT: OpStore %i_numLevels [[query_level_6_i]]
66+
tex1d.GetDimensions(mipLevel, i_width, i_numLevels);
67+
68+
#ifdef ERROR
69+
// ERROR: error: no matching member function for call to 'GetDimensions'
70+
tex1d.GetDimensions(mipLevel, 0, height, numLevels);
71+
72+
// ERROR: error: no matching member function for call to 'GetDimensions'
73+
tex1d.GetDimensions(width, 20);
74+
#endif
75+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
5+
6+
vk::SampledTexture1D<float4> tex1d;
7+
8+
float4 main(int2 location3: A) : SV_Target {
9+
// CHECK: %location3 = OpFunctionParameter %_ptr_Function_v2int
10+
11+
// CHECK: [[location3:%[a-zA-Z0-9_]+]] = OpLoad %v2int %location3
12+
// CHECK: [[coord:%[a-zA-Z0-9_]+]] = OpCompositeExtract %int [[location3]] 0
13+
// CHECK: [[mip_level:%[a-zA-Z0-9_]+]] = OpCompositeExtract %int [[location3]] 1
14+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
15+
// CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_1d_image [[tex1_load]]
16+
// CHECK: [[fetch_result:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image]] [[coord]] Lod [[mip_level]]
17+
// CHECK: OpStore %val1 [[fetch_result]]
18+
float4 val1 = tex1d.Load(location3);
19+
20+
// CHECK: [[location3_2:%[a-zA-Z0-9_]+]] = OpLoad %v2int %location3
21+
// CHECK: [[coord_2:%[a-zA-Z0-9_]+]] = OpCompositeExtract %int [[location3_2]] 0
22+
// CHECK: [[mip_level_2:%[a-zA-Z0-9_]+]] = OpCompositeExtract %int [[location3_2]] 1
23+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
24+
// CHECK: [[tex_image_2:%[a-zA-Z0-9_]+]] = OpImage %type_1d_image [[tex2_load]]
25+
// CHECK: [[fetch_result_2:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image_2]] [[coord_2]] Lod|ConstOffset [[mip_level_2]] %int_1
26+
// CHECK: OpStore %val2 [[fetch_result_2]]
27+
float4 val2 = tex1d.Load(location3, 1);
28+
29+
/////////////////////////////////
30+
/// Using the Status argument ///
31+
/////////////////////////////////
32+
33+
// CHECK: [[location3_3:%[a-zA-Z0-9_]+]] = OpLoad %v2int %location3
34+
// CHECK: [[coord_3:%[a-zA-Z0-9_]+]] = OpCompositeExtract %int [[location3_3]] 0
35+
// CHECK: [[mip_level_3:%[a-zA-Z0-9_]+]] = OpCompositeExtract %int [[location3_3]] 1
36+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
37+
// CHECK: [[tex_image_3:%[a-zA-Z0-9_]+]] = OpImage %type_1d_image [[tex3_load]]
38+
// CHECK: [[sparse_fetch_result:%[a-zA-Z0-9_]+]] = OpImageSparseFetch %SparseResidencyStruct [[tex_image_3]] [[coord_3]] Lod|ConstOffset [[mip_level_3]] %int_1
39+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sparse_fetch_result]] 0
40+
// CHECK: OpStore %status [[status_0]]
41+
42+
// CHECK: [[sampled_texel:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[sparse_fetch_result]] 1
43+
// CHECK: OpStore %val3 [[sampled_texel]]
44+
uint status;
45+
float4 val3 = tex1d.Load(location3, 1, status);
46+
47+
return 1.0;
48+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
5+
6+
vk::SampledTexture1D<float4> tex1d;
7+
8+
void main() {
9+
// CHECK: OpStore %pos1 %uint_1
10+
11+
uint pos1 = 1;
12+
13+
// CHECK: [[pos1:%[a-zA-Z0-9_]+]] = OpLoad %uint %pos1
14+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
15+
// CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_1d_image [[tex1_load]]
16+
// CHECK: [[fetch_result:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image]] [[pos1]] Lod %uint_2
17+
// CHECK: OpStore %a1 [[fetch_result]]
18+
float4 a1 = tex1d.mips[2][pos1];
19+
20+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
5+
6+
vk::SampledTexture1D<float4> tex1d;
7+
8+
float4 main() : SV_Target {
9+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
10+
// CHECK: [[sampled_result:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex1_load]] %float_0_5 Bias %float_0_5
11+
// CHECK: OpStore %val1 [[sampled_result]]
12+
float4 val1 = tex1d.SampleBias(0.5, 0.5f);
13+
14+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
15+
// CHECK: [[sampled_result_2:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex2_load]] %float_0_5 Bias|ConstOffset %float_0_5 %int_2
16+
// CHECK: OpStore %val2 [[sampled_result_2]]
17+
float4 val2 = tex1d.SampleBias(0.5, 0.5f, 2);
18+
19+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
20+
// CHECK: [[sampled_result_3:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex3_load]] %float_0_5 Bias|ConstOffset|MinLod %float_0_5 %int_2 %float_2_5
21+
// CHECK: OpStore %val3 [[sampled_result_3]]
22+
float4 val3 = tex1d.SampleBias(0.5, 0.5f, 2, 2.5f);
23+
24+
25+
// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
26+
// CHECK: [[sampled_result_4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[tex4_load]] %float_0_5 Bias|ConstOffset|MinLod %float_0_5 %int_2 %float_2_5
27+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result_4]] 0
28+
// CHECK: OpStore %status [[status_0]]
29+
// CHECK: [[sampled_texel:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[sampled_result_4]] 1
30+
// CHECK: OpStore %val4 [[sampled_texel]]
31+
uint status;
32+
float4 val4 = tex1d.SampleBias(0.5, 0.5f, 2, 2.5f, status);
33+
34+
return 1.0;
35+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
5+
6+
vk::SampledTexture1D<float4> tex1d;
7+
8+
float4 main() : SV_Target {
9+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
10+
// CHECK: [[sampled_result:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex1_load]] %float_0_5 %float_1 Bias %float_0_5
11+
// CHECK: OpStore %val1 [[sampled_result]]
12+
float val1 = tex1d.SampleCmpBias(0.5, 1.0f, 0.5f);
13+
14+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
15+
// CHECK: [[sampled_result_2:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex2_load]] %float_0_5 %float_1 Bias|ConstOffset %float_0_5 %int_2
16+
// CHECK: OpStore %val2 [[sampled_result_2]]
17+
float val2 = tex1d.SampleCmpBias(0.5, 1.0f, 0.5f, 2);
18+
19+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
20+
// CHECK: [[sampled_result_3:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex3_load]] %float_0_5 %float_1 Bias|ConstOffset|MinLod %float_0_5 %int_2 %float_2_5
21+
// CHECK: OpStore %val3 [[sampled_result_3]]
22+
float val3 = tex1d.SampleCmpBias(0.5, 1.0f, 0.5f, 2, 2.5f);
23+
24+
// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
25+
// CHECK: [[sampled_result_4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefImplicitLod %SparseResidencyStruct [[tex4_load]] %float_0_5 %float_1 Bias|ConstOffset|MinLod %float_0_5 %int_2 %float_2_5
26+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result_4]] 0
27+
// CHECK: OpStore %status [[status_0]]
28+
// CHECK: [[sampled_value:%[a-zA-Z0-9_]+]] = OpCompositeExtract %float [[sampled_result_4]] 1
29+
// CHECK: OpStore %val4 [[sampled_value]]
30+
uint status;
31+
float val4 = tex1d.SampleCmpBias(0.5, 1.0f, 0.5f, 2, 2.5f, status);
32+
33+
return 1.0;
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image
5+
6+
vk::SampledTexture1D<float4> tex1d;
7+
8+
float4 main() : SV_Target {
9+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
10+
// CHECK: [[sampled_result:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1_load]] %float_0_5 %float_1 Grad %float_1 %float_2
11+
// CHECK: OpStore %val1 [[sampled_result]]
12+
float val1 = tex1d.SampleCmpGrad(0.5, 1.0f, 1, 2);
13+
14+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
15+
// CHECK: [[sampled_result_2:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex2_load]] %float_0_5 %float_1 Grad|ConstOffset %float_1 %float_2 %int_2
16+
// CHECK: OpStore %val2 [[sampled_result_2]]
17+
float val2 = tex1d.SampleCmpGrad(0.5, 1.0f, 1, 2, 2);
18+
19+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
20+
// CHECK: [[sampled_result_3:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex3_load]] %float_0_5 %float_1 Grad|ConstOffset|MinLod %float_1 %float_2 %int_2 %float_0_5
21+
// CHECK: OpStore %val3 [[sampled_result_3]]
22+
float val3 = tex1d.SampleCmpGrad(0.5, 1.0f, 1, 2, 2, 0.5);
23+
24+
// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
25+
// CHECK: [[sampled_result_4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefExplicitLod %SparseResidencyStruct [[tex4_load]] %float_0_5 %float_1 Grad|ConstOffset|MinLod %float_1 %float_2 %int_2 %float_0_5
26+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result_4]] 0
27+
// CHECK: OpStore %status [[status_0]]
28+
// CHECK: [[sampled_value:%[a-zA-Z0-9_]+]] = OpCompositeExtract %float [[sampled_result_4]] 1
29+
// CHECK: OpStore %val4 [[sampled_value]]
30+
uint status;
31+
float val4 = tex1d.SampleCmpGrad(0.5, 1.0f, 1, 2, 2, 0.5, status);
32+
33+
return 1.0;
34+
}

0 commit comments

Comments
 (0)