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