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+ }
0 commit comments