Skip to content

Commit 5a5c6f0

Browse files
committed
Add tests for SampledTexture3d
1 parent 1a95ec8 commit 5a5c6f0

11 files changed

Lines changed: 397 additions & 3 deletions

tools/clang/lib/SPIRV/LowerTypeVisitor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,9 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
864864
constexpr size_t sampledTexturePrefixLength = sizeof("SampledTexture") - 1;
865865
StringRef suffix = name.drop_front(sampledTexturePrefixLength);
866866
const spv::Dim dimension =
867-
suffix.startswith("1D") ? spv::Dim::Dim1D : (suffix.startswith("2D")
868-
? spv::Dim::Dim2D
869-
: spv::Dim::Dim3D);
867+
suffix.startswith("1D")
868+
? spv::Dim::Dim1D
869+
: (suffix.startswith("2D") ? spv::Dim::Dim2D : spv::Dim::Dim3D);
870870
const bool isArray = suffix.endswith("Array");
871871
const bool isMS = suffix.find("MS") != StringRef::npos;
872872

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s
2+
// RUN: not %dxc -T ps_6_7 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
3+
4+
// CHECK: %type_3d_image = OpTypeImage %float 3D 0 0 0 1 Unknown
5+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_3d_image
6+
7+
vk::SampledTexture3D<float4> tex3d;
8+
9+
struct S { int a; };
10+
11+
void main() {
12+
uint3 pos1 = uint3(1, 2, 3);
13+
14+
// CHECK: [[pos1:%[a-zA-Z0-9_]+]] = OpLoad %v3uint %pos1
15+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex3d
16+
// CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_3d_image [[tex1_load]]
17+
// CHECK: [[fetch_result:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image]] [[pos1]] Lod %uint_0
18+
// CHECK: OpStore %a1 [[fetch_result]]
19+
float4 a1 = tex3d[pos1];
20+
21+
#ifdef ERROR
22+
S s = { 1 };
23+
// CHECK-ERROR: error: no viable overloaded operator[]
24+
float4 val2 = tex3d[s];
25+
26+
int2 i2 = int2(1, 2);
27+
// CHECK-ERROR: error: no viable overloaded operator[]
28+
float4 val3 = tex3d[i2];
29+
30+
int i1 = 1;
31+
// CHECK-ERROR: error: no viable overloaded operator[]
32+
float4 val4 = tex3d[i1];
33+
#endif
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %dxc -T ps_6_8 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: OpCapability ImageQuery
4+
5+
// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
6+
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]
7+
8+
vk::SampledTexture3D<float4> tex3d;
9+
10+
void main() {
11+
float3 xyz = float3(0.5, 0.5, 0.5);
12+
13+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
14+
// CHECK-NEXT: [[xyz_load:%[a-zA-Z0-9_]+]] = OpLoad %v3float %xyz
15+
// CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[xyz_load]]
16+
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query]] 1
17+
float lod1 = tex3d.CalculateLevelOfDetailUnclamped(xyz);
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: OpCapability ImageQuery
4+
5+
// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
6+
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]
7+
8+
vk::SampledTexture3D<float4> tex3d;
9+
10+
void main() {
11+
float3 xyz = float3(0.5, 0.5, 0.5);
12+
13+
// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
14+
// CHECK-NEXT: [[xyz_load:%[a-zA-Z0-9_]+]] = OpLoad %v3float %xyz
15+
// CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1]] [[xyz_load]]
16+
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query]] 0
17+
float lod = tex3d.CalculateLevelOfDetail(xyz);
18+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
7+
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]
8+
9+
vk::SampledTexture3D<float4> tex3d;
10+
11+
void main() {
12+
uint mipLevel = 1;
13+
uint width, height, depth, numLevels;
14+
15+
// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
16+
// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_3d_image]] [[t1_load]]
17+
// CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image1]] %int_0
18+
// CHECK-NEXT: [[query1_0:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 0
19+
// CHECK-NEXT: OpStore %width [[query1_0]]
20+
// CHECK-NEXT: [[query1_1:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 1
21+
// CHECK-NEXT: OpStore %height [[query1_1]]
22+
// CHECK-NEXT: [[query1_2:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 2
23+
// CHECK-NEXT: OpStore %depth [[query1_2]]
24+
tex3d.GetDimensions(width, height, depth);
25+
26+
// CHECK: [[t2_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
27+
// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_3d_image]] [[t2_load]]
28+
// CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel
29+
// CHECK-NEXT: [[query2:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image2]] [[mip]]
30+
// CHECK-NEXT: [[query2_0:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 0
31+
// CHECK-NEXT: OpStore %width [[query2_0]]
32+
// CHECK-NEXT: [[query2_1:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 1
33+
// CHECK-NEXT: OpStore %height [[query2_1]]
34+
// CHECK-NEXT: [[query2_2:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 2
35+
// CHECK-NEXT: OpStore %depth [[query2_2]]
36+
// CHECK-NEXT: [[query_level_2:%[0-9]+]] = OpImageQueryLevels %uint [[image2]]
37+
// CHECK-NEXT: OpStore %numLevels [[query_level_2]]
38+
tex3d.GetDimensions(mipLevel, width, height, depth, numLevels);
39+
40+
float f_width, f_height, f_depth, f_numLevels;
41+
// CHECK: [[t3_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
42+
// CHECK-NEXT: [[image3:%[0-9]+]] = OpImage [[type_3d_image]] [[t3_load]]
43+
// CHECK-NEXT: [[query3:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image3]] %int_0
44+
// CHECK-NEXT: [[query3_0:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 0
45+
// CHECK-NEXT: [[f_query3_0:%[0-9]+]] = OpConvertUToF %float [[query3_0]]
46+
// CHECK-NEXT: OpStore %f_width [[f_query3_0]]
47+
// CHECK-NEXT: [[query3_1:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 1
48+
// CHECK-NEXT: [[f_query3_1:%[0-9]+]] = OpConvertUToF %float [[query3_1]]
49+
// CHECK-NEXT: OpStore %f_height [[f_query3_1]]
50+
// CHECK-NEXT: [[query3_2:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 2
51+
// CHECK-NEXT: [[f_query3_2:%[0-9]+]] = OpConvertUToF %float [[query3_2]]
52+
// CHECK-NEXT: OpStore %f_depth [[f_query3_2]]
53+
tex3d.GetDimensions(f_width, f_height, f_depth);
54+
55+
// CHECK: [[t4_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
56+
// CHECK-NEXT: [[image4:%[0-9]+]] = OpImage [[type_3d_image]] [[t4_load]]
57+
// CHECK-NEXT: [[mip4:%[0-9]+]] = OpLoad %uint %mipLevel
58+
// CHECK-NEXT: [[query4:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image4]] [[mip4]]
59+
// CHECK-NEXT: [[query4_0:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 0
60+
// CHECK-NEXT: [[f_query4_0:%[0-9]+]] = OpConvertUToF %float [[query4_0]]
61+
// CHECK-NEXT: OpStore %f_width [[f_query4_0]]
62+
// CHECK-NEXT: [[query4_1:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 1
63+
// CHECK-NEXT: [[f_query4_1:%[0-9]+]] = OpConvertUToF %float [[query4_1]]
64+
// CHECK-NEXT: OpStore %f_height [[f_query4_1]]
65+
// CHECK-NEXT: [[query4_2:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 2
66+
// CHECK-NEXT: [[f_query4_2:%[0-9]+]] = OpConvertUToF %float [[query4_2]]
67+
// CHECK-NEXT: OpStore %f_depth [[f_query4_2]]
68+
// CHECK-NEXT: [[query_level_4:%[0-9]+]] = OpImageQueryLevels %uint [[image4]]
69+
// CHECK-NEXT: [[f_query_level_4:%[0-9]+]] = OpConvertUToF %float [[query_level_4]]
70+
// CHECK-NEXT: OpStore %f_numLevels [[f_query_level_4]]
71+
tex3d.GetDimensions(mipLevel, f_width, f_height, f_depth, f_numLevels);
72+
73+
int i_width, i_height, i_depth, i_numLevels;
74+
// CHECK: [[t5_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
75+
// CHECK-NEXT: [[image5:%[0-9]+]] = OpImage [[type_3d_image]] [[t5_load]]
76+
// CHECK-NEXT: [[query5:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image5]] %int_0
77+
// CHECK-NEXT: [[query5_0:%[0-9]+]] = OpCompositeExtract %uint [[query5]] 0
78+
// CHECK-NEXT: [[query5_0_i:%[0-9]+]] = OpBitcast %int [[query5_0]]
79+
// CHECK-NEXT: OpStore %i_width [[query5_0_i]]
80+
// CHECK-NEXT: [[query5_1:%[0-9]+]] = OpCompositeExtract %uint [[query5]] 1
81+
// CHECK-NEXT: [[query5_1_i:%[0-9]+]] = OpBitcast %int [[query5_1]]
82+
// CHECK-NEXT: OpStore %i_height [[query5_1_i]]
83+
// CHECK-NEXT: [[query5_2:%[0-9]+]] = OpCompositeExtract %uint [[query5]] 2
84+
// CHECK-NEXT: [[query5_2_i:%[0-9]+]] = OpBitcast %int [[query5_2]]
85+
// CHECK-NEXT: OpStore %i_depth [[query5_2_i]]
86+
tex3d.GetDimensions(i_width, i_height, i_depth);
87+
88+
// CHECK: [[t6_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
89+
// CHECK-NEXT: [[image6:%[0-9]+]] = OpImage [[type_3d_image]] [[t6_load]]
90+
// CHECK-NEXT: [[mip6:%[0-9]+]] = OpLoad %uint %mipLevel
91+
// CHECK-NEXT: [[query6:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image6]] [[mip6]]
92+
// CHECK-NEXT: [[query6_0:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 0
93+
// CHECK-NEXT: [[query6_0_i:%[0-9]+]] = OpBitcast %int [[query6_0]]
94+
// CHECK-NEXT: OpStore %i_width [[query6_0_i]]
95+
// CHECK-NEXT: [[query6_1:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 1
96+
// CHECK-NEXT: [[query6_1_i:%[0-9]+]] = OpBitcast %int [[query6_1]]
97+
// CHECK-NEXT: OpStore %i_height [[query6_1_i]]
98+
// CHECK-NEXT: [[query6_2:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 2
99+
// CHECK-NEXT: [[query6_2_i:%[0-9]+]] = OpBitcast %int [[query6_2]]
100+
// CHECK-NEXT: OpStore %i_depth [[query6_2_i]]
101+
// CHECK-NEXT: [[query_level_6:%[0-9]+]] = OpImageQueryLevels %uint [[image6]]
102+
// CHECK-NEXT: [[query_level_6_i:%[0-9]+]] = OpBitcast %int [[query_level_6]]
103+
// CHECK-NEXT: OpStore %i_numLevels [[query_level_6_i]]
104+
tex3d.GetDimensions(mipLevel, i_width, i_height, i_depth, i_numLevels);
105+
106+
#ifdef ERROR
107+
// ERROR: error: Output argument must be an l-value
108+
tex3d.GetDimensions(mipLevel, 0, height, depth, numLevels);
109+
110+
// ERROR: error: Output argument must be an l-value
111+
tex3d.GetDimensions(width, 20, depth);
112+
#endif
113+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: [[v3ic:%[0-9]+]] = OpConstantComposite %v3int %int_1 %int_2 %int_3
4+
5+
// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
6+
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]
7+
8+
vk::SampledTexture3D<float4> tex3d;
9+
10+
float4 main(int4 location4: A) : SV_Target {
11+
uint status;
12+
13+
// CHECK: [[loc:%[0-9]+]] = OpLoad %v4int %location4
14+
// CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v3int [[loc]] [[loc]] 0 1 2
15+
// CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 3
16+
// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
17+
// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_3d_image]] [[tex]]
18+
// CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod [[lod_0]]
19+
float4 val1 = tex3d.Load(location4);
20+
21+
// CHECK: [[loc:%[0-9]+]] = OpLoad %v4int %location4
22+
// CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v3int [[loc]] [[loc]] 0 1 2
23+
// CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 3
24+
// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
25+
// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_3d_image]] [[tex]]
26+
// CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod|ConstOffset [[lod_0]] [[v3ic]]
27+
float4 val2 = tex3d.Load(location4, int3(1, 2, 3));
28+
29+
/////////////////////////////////
30+
/// Using the Status argument ///
31+
/////////////////////////////////
32+
33+
// CHECK: [[loc:%[0-9]+]] = OpLoad %v4int %location4
34+
// CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v3int [[loc]] [[loc]] 0 1 2
35+
// CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 3
36+
// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
37+
// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_3d_image]] [[tex]]
38+
// CHECK-NEXT:[[structResult:%[0-9]+]] = OpImageSparseFetch %SparseResidencyStruct [[tex_img]] [[coord_0]] Lod|ConstOffset [[lod_0]] [[v3ic]]
39+
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0
40+
// CHECK-NEXT: OpStore %status [[status]]
41+
// CHECK-NEXT: [[v4result:%[0-9]+]] = OpCompositeExtract %v4float [[structResult]] 1
42+
// CHECK-NEXT: OpStore %val3 [[v4result]]
43+
float4 val3 = tex3d.Load(location4, int3(1, 2, 3), status);
44+
45+
return 1.0;
46+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: %type_3d_image = OpTypeImage %float 3D 0 0 0 1 Unknown
4+
// CHECK: %type_sampled_image = OpTypeSampledImage %type_3d_image
5+
6+
vk::SampledTexture3D<float4> tex3d;
7+
8+
void main() {
9+
uint3 pos1 = uint3(1, 2, 3);
10+
11+
// CHECK: [[pos1:%[a-zA-Z0-9_]+]] = OpLoad %v3uint %pos1
12+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex3d
13+
// CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_3d_image [[tex1_load]]
14+
// CHECK: [[fetch_result:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image]] [[pos1]] Lod %uint_2
15+
// CHECK: OpStore %a1 [[fetch_result]]
16+
float4 a1 = tex3d.mips[2][pos1];
17+
}
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: OpCapability MinLod
4+
// CHECK: OpCapability SparseResidency
5+
6+
// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0
7+
// CHECK: [[v3ic:%[0-9]+]] = OpConstantComposite %v3int %int_2 %int_3 %int_1
8+
9+
// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
10+
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]
11+
12+
vk::SampledTexture3D<float4> tex3d;
13+
14+
float4 main() : SV_Target {
15+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
16+
// CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex1_load]] [[v3fc]] Bias %float_0_5
17+
float4 val1 = tex3d.SampleBias(float3(0.5, 0.25, 0), 0.5f);
18+
19+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
20+
// CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex2_load]] [[v3fc]] Bias|ConstOffset %float_0_5 [[v3ic]]
21+
float4 val2 = tex3d.SampleBias(float3(0.5, 0.25, 0), 0.5f, int3(2, 3, 1));
22+
23+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
24+
// CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex3_load]] [[v3fc]] Bias|ConstOffset|MinLod %float_0_5 [[v3ic]] %float_2_5
25+
float4 val3 = tex3d.SampleBias(float3(0.5, 0.25, 0), 0.5f, int3(2, 3, 1), 2.5f);
26+
27+
// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
28+
// CHECK: [[sampled_result4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[tex4_load]] [[v3fc]] Bias|ConstOffset|MinLod %float_0_5 [[v3ic]] %float_2_5
29+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result4]] 0
30+
// CHECK: OpStore %status [[status_0]]
31+
uint status;
32+
float4 val4 = tex3d.SampleBias(float3(0.5, 0.25, 0), 0.5f, int3(2, 3, 1), 2.5f, status);
33+
34+
return 1.0;
35+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: OpCapability MinLod
4+
// CHECK: OpCapability SparseResidency
5+
6+
// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0
7+
// CHECK: [[v3f_1:%[0-9]+]] = OpConstantComposite %v3float %float_1 %float_1 %float_1
8+
// CHECK: [[v3f_2:%[0-9]+]] = OpConstantComposite %v3float %float_2 %float_2 %float_2
9+
// CHECK: [[v3ic:%[0-9]+]] = OpConstantComposite %v3int %int_2 %int_3 %int_1
10+
11+
// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
12+
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]
13+
14+
vk::SampledTexture3D<float4> tex3d;
15+
16+
float4 main() : SV_Target {
17+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
18+
// CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1_load]] [[v3fc]] Grad [[v3f_1]] [[v3f_2]]
19+
float4 val1 = tex3d.SampleGrad(float3(0.5, 0.25, 0), float3(1, 1, 1), float3(2, 2, 2));
20+
21+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
22+
// CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex2_load]] [[v3fc]] Grad|ConstOffset [[v3f_1]] [[v3f_2]] [[v3ic]]
23+
float4 val2 = tex3d.SampleGrad(float3(0.5, 0.25, 0), float3(1, 1, 1), float3(2, 2, 2), int3(2, 3, 1));
24+
25+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
26+
// CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex3_load]] [[v3fc]] Grad|ConstOffset|MinLod [[v3f_1]] [[v3f_2]] [[v3ic]] %float_0_5
27+
float4 val3 = tex3d.SampleGrad(float3(0.5, 0.25, 0), float3(1, 1, 1), float3(2, 2, 2), int3(2, 3, 1), 0.5);
28+
29+
// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
30+
// CHECK: [[sampled_result4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleExplicitLod %SparseResidencyStruct [[tex4_load]] [[v3fc]] Grad|ConstOffset|MinLod [[v3f_1]] [[v3f_2]] [[v3ic]] %float_0_5
31+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result4]] 0
32+
// CHECK: OpStore %status [[status_0]]
33+
// CHECK: [[sampled_texel:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[sampled_result4]] 1
34+
// CHECK: OpStore %val4 [[sampled_texel]]
35+
uint status;
36+
float4 val4 = tex3d.SampleGrad(float3(0.5, 0.25, 0), float3(1, 1, 1), float3(2, 2, 2), int3(2, 3, 1), 0.5, status);
37+
38+
return 1.0;
39+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: OpCapability SparseResidency
4+
5+
// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0
6+
// CHECK: [[v3ic:%[0-9]+]] = OpConstantComposite %v3int %int_2 %int_3 %int_1
7+
8+
// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
9+
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]
10+
11+
vk::SampledTexture3D<float4> tex3d;
12+
13+
float4 main() : SV_Target {
14+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
15+
// CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1_load]] [[v3fc]] Lod %float_0_5
16+
float4 val1 = tex3d.SampleLevel(float3(0.5, 0.25, 0), 0.5f);
17+
18+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
19+
// CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex2_load]] [[v3fc]] Lod|ConstOffset %float_0_5 [[v3ic]]
20+
float4 val2 = tex3d.SampleLevel(float3(0.5, 0.25, 0), 0.5f, int3(2, 3, 1));
21+
22+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
23+
// CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSparseSampleExplicitLod %SparseResidencyStruct [[tex3_load]] [[v3fc]] Lod|ConstOffset %float_0_5 [[v3ic]]
24+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result3]] 0
25+
// CHECK: OpStore %status [[status_0]]
26+
uint status;
27+
float4 val3 = tex3d.SampleLevel(float3(0.5, 0.25, 0), 0.5f, int3(2, 3, 1), status);
28+
29+
return 1.0;
30+
}

0 commit comments

Comments
 (0)