Skip to content

Commit 1f63535

Browse files
authored
[SPIR-V][vk::SampledTexture] #8. Support vk::SampledTexture2DArray type. (microsoft#8188)
Part of microsoft#7979 `vk::SampledTexture2DArray` takes coordinate of vector size 3. The function definitions are equivalent to that of `Texture2DArray`, just without `Sampler` argument.
1 parent ca7587b commit 1f63535

30 files changed

Lines changed: 598 additions & 350 deletions

include/dxc/dxcapi.internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ enum LEGAL_INTRINSIC_COMPTYPES {
141141
#ifdef ENABLE_SPIRV_CODEGEN
142142
LICOMPTYPE_VK_BUFFER_POINTER = 56,
143143
LICOMPTYPE_VK_SAMPLED_TEXTURE2D = 57,
144-
LICOMPTYPE_COUNT = 58
144+
LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY = 58,
145+
LICOMPTYPE_COUNT = 59
145146
#else
146147
LICOMPTYPE_COUNT = 56
147148
#endif

tools/clang/lib/AST/ASTContextHLSL.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,6 @@ CXXRecordDecl *hlsl::DeclareVkSampledTextureType(ASTContext &context,
13761376
DeclContext *declContext,
13771377
llvm::StringRef hlslTypeName,
13781378
QualType defaultParamType) {
1379-
// TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Later
1380-
// generalize these to all SampledTexture types.
13811379
BuiltinTypeDeclBuilder Builder(declContext, hlslTypeName,
13821380
TagDecl::TagKind::TTK_Struct);
13831381

tools/clang/lib/SPIRV/AstTypeProbe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ bool isSampledTexture(QualType type) {
931931
const auto name = rt->getDecl()->getName();
932932
// TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Add
933933
// other sampled texture types as needed.
934-
if (name == "SampledTexture2D")
934+
if (name == "SampledTexture2D" || name == "SampledTexture2DArray")
935935
return true;
936936
}
937937
return false;

tools/clang/lib/SPIRV/LowerTypeVisitor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
849849
assert(visitedTypeStack.size() == visitedTypeStackSize);
850850
return pointerType;
851851
}
852-
if (name == "SampledTexture2D") {
852+
if (name == "SampledTexture2D" || name == "SampledTexture2DArray") {
853853
const auto sampledType = hlsl::GetHLSLResourceResultType(type);
854854
auto loweredType = lowerType(getElementType(astContext, sampledType), rule,
855855
/*isRowMajor*/ llvm::None, srcLoc);
@@ -860,10 +860,11 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
860860
loweredType = spvContext.getUIntType(32);
861861
}
862862

863+
const bool isArray = (name == "SampledTexture2DArray");
864+
863865
const auto *imageType = spvContext.getImageType(
864-
loweredType, spv::Dim::Dim2D, ImageType::WithDepth::No,
865-
false /* array */, false /* ms */, ImageType::WithSampler::Yes,
866-
spv::ImageFormat::Unknown);
866+
loweredType, spv::Dim::Dim2D, ImageType::WithDepth::No, isArray,
867+
false /* ms */, ImageType::WithSampler::Yes, spv::ImageFormat::Unknown);
867868
return spvContext.getSampledImageType(imageType);
868869
}
869870
emitError("unknown type %0 in vk namespace", srcLoc) << type;

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4394,6 +4394,7 @@ SpirvEmitter::processBufferTextureGetDimensions(const CXXMemberCallExpr *expr) {
43944394
if ((typeName == "Texture1D" && numArgs > 1) ||
43954395
(typeName == "Texture2D" && numArgs > 2) ||
43964396
(typeName == "SampledTexture2D" && numArgs > 2) ||
4397+
(typeName == "SampledTexture2DArray" && numArgs > 3) ||
43974398
(typeName == "TextureCube" && numArgs > 2) ||
43984399
(typeName == "Texture3D" && numArgs > 3) ||
43994400
(typeName == "Texture1DArray" && numArgs > 2) ||

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ enum ArBasicKind {
201201
AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID,
202202
AR_OBJECT_VK_BUFFER_POINTER,
203203
AR_OBJECT_VK_SAMPLED_TEXTURE2D,
204+
AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY,
204205
#endif // ENABLE_SPIRV_CODEGEN
205206
// SPIRV change ends
206207

@@ -562,6 +563,7 @@ const UINT g_uBasicKindProps[] = {
562563
BPROP_OBJECT, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID use recordType
563564
BPROP_OBJECT, // AR_OBJECT_VK_BUFFER_POINTER use recordType
564565
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D
566+
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY
565567
#endif // ENABLE_SPIRV_CODEGEN
566568
// SPIRV change ends
567569

@@ -1272,6 +1274,8 @@ static const ArBasicKind g_VKBufferPointerCT[] = {AR_OBJECT_VK_BUFFER_POINTER,
12721274
AR_BASIC_UNKNOWN};
12731275
static const ArBasicKind g_VKSampledTexture2DCT[] = {
12741276
AR_OBJECT_VK_SAMPLED_TEXTURE2D, AR_BASIC_UNKNOWN};
1277+
static const ArBasicKind g_VKSampledTexture2DArrayCT[] = {
1278+
AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, AR_BASIC_UNKNOWN};
12751279
#endif
12761280

12771281
// Basic kinds, indexed by a LEGAL_INTRINSIC_COMPTYPES value.
@@ -1334,8 +1338,9 @@ const ArBasicKind *g_LegalIntrinsicCompTypes[] = {
13341338
g_LinAlgCT, // LICOMPTYPE_LINALG
13351339
g_BuiltInTrianglePositionsCT, // LICOMPTYPE_BUILTIN_TRIANGLE_POSITIONS
13361340
#ifdef ENABLE_SPIRV_CODEGEN
1337-
g_VKBufferPointerCT, // LICOMPTYPE_VK_BUFFER_POINTER
1338-
g_VKSampledTexture2DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D
1341+
g_VKBufferPointerCT, // LICOMPTYPE_VK_BUFFER_POINTER
1342+
g_VKSampledTexture2DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D
1343+
g_VKSampledTexture2DArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY
13391344
#endif
13401345
};
13411346
static_assert(
@@ -1396,6 +1401,7 @@ static const ArBasicKind g_ArBasicKindsAsTypes[] = {
13961401
AR_OBJECT_VK_INTEGRAL_CONSTANT, AR_OBJECT_VK_LITERAL,
13971402
AR_OBJECT_VK_SPV_INTRINSIC_TYPE, AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID,
13981403
AR_OBJECT_VK_BUFFER_POINTER, AR_OBJECT_VK_SAMPLED_TEXTURE2D,
1404+
AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY,
13991405
#endif // ENABLE_SPIRV_CODEGEN
14001406
// SPIRV change ends
14011407

@@ -1508,6 +1514,7 @@ static const uint8_t g_ArBasicKindsTemplateCount[] = {
15081514
1, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID
15091515
2, // AR_OBJECT_VK_BUFFER_POINTER
15101516
1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D
1517+
1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY
15111518
#endif // ENABLE_SPIRV_CODEGEN
15121519
// SPIRV change ends
15131520

@@ -1662,6 +1669,7 @@ static const SubscriptOperatorRecord g_ArBasicKindsSubscripts[] = {
16621669
{0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID
16631670
{0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_BUFFER_POINTER
16641671
{2, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D
1672+
{3, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY
16651673
#endif // ENABLE_SPIRV_CODEGEN
16661674
// SPIRV change ends
16671675

@@ -1832,6 +1840,7 @@ static const char *g_ArBasicTypeNames[] = {
18321840
"ext_result_id",
18331841
"BufferPointer",
18341842
"SampledTexture2D",
1843+
"SampledTexture2DArray",
18351844
#endif // ENABLE_SPIRV_CODEGEN
18361845
// SPIRV change ends
18371846

@@ -2489,6 +2498,10 @@ static void GetIntrinsicMethods(ArBasicKind kind,
24892498
*intrinsics = g_VkSampledTexture2DMethods;
24902499
*intrinsicCount = _countof(g_VkSampledTexture2DMethods);
24912500
break;
2501+
case AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY:
2502+
*intrinsics = g_VkSampledTexture2DArrayMethods;
2503+
*intrinsicCount = _countof(g_VkSampledTexture2DArrayMethods);
2504+
break;
24922505
#endif
24932506
case AR_OBJECT_HIT_OBJECT:
24942507
*intrinsics = g_DxHitObjectMethods;
@@ -4094,13 +4107,14 @@ class HLSLExternalSource : public ExternalSemaSource {
40944107
recordDecl = DeclareVkBufferPointerType(*m_context, m_vkNSDecl);
40954108
recordDecl->setImplicit(true);
40964109
m_vkBufferPointerTemplateDecl = recordDecl->getDescribedClassTemplate();
4097-
} else if (kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D) {
4110+
} else if (kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D ||
4111+
kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY) {
40984112
if (!m_vkNSDecl)
40994113
continue;
41004114
QualType float4Type =
41014115
LookupVectorType(HLSLScalarType::HLSLScalarType_float, 4);
41024116
recordDecl = DeclareVkSampledTextureType(
4103-
*m_context, m_vkNSDecl, "SampledTexture2D", float4Type);
4117+
*m_context, m_vkNSDecl, g_ArBasicTypeNames[kind], float4Type);
41044118
if (Attr)
41054119
recordDecl->addAttr(Attr);
41064120
m_vkSampledTextureTemplateDecl =
@@ -5060,6 +5074,9 @@ class HLSLExternalSource : public ExternalSemaSource {
50605074
ResClass = DXIL::ResourceClass::UAV;
50615075
return true;
50625076
case AR_OBJECT_TEXTURE2D_ARRAY:
5077+
#ifdef ENABLE_SPIRV_CODEGEN
5078+
case AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY:
5079+
#endif
50635080
ResKind = DXIL::ResourceKind::Texture2DArray;
50645081
ResClass = DXIL::ResourceClass::SRV;
50655082
return true;

tools/clang/test/CodeGenSPIRV/vk.sampledtexture.access.hlsl

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,29 @@
22

33
// CHECK: [[cu12:%[0-9]+]] = OpConstantComposite %v2uint %uint_1 %uint_2
44

5-
// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
6-
// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]]
7-
// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]]
5+
// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
6+
// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
7+
// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown
8+
// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]]
89

9-
// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant
10-
11-
vk::SampledTexture2D<float4> tex1 : register(t1);
10+
vk::SampledTexture2D<float4> tex2d;
11+
vk::SampledTexture2DArray<float4> tex2dArray;
1212

1313
void main() {
1414
// CHECK: OpStore %pos1 [[cu12]]
1515
// CHECK-NEXT: [[pos1:%[0-9]+]] = OpLoad %v2uint %pos1
16-
// CHECK-NEXT: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]]
17-
// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image_1]] [[tex1_load]]
16+
// CHECK-NEXT: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d
17+
// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image]] [[tex1_load]]
1818
// CHECK-NEXT: [[result1:%[0-9]+]] = OpImageFetch %v4float [[tex_img]] [[pos1]] Lod %uint_0
1919
// CHECK-NEXT: OpStore %a1 [[result1]]
2020
uint2 pos1 = uint2(1,2);
21-
float4 a1 = tex1[pos1];
21+
float4 a1 = tex2d[pos1];
22+
23+
// CHECK: [[pos2:%[0-9]+]] = OpLoad %v3uint %pos2
24+
// CHECK-NEXT: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray
25+
// CHECK-NEXT: [[tex2_img:%[0-9]+]] = OpImage [[type_2d_image_array]] [[tex2_load]]
26+
// CHECK-NEXT: [[result2:%[0-9]+]] = OpImageFetch %v4float [[tex2_img]] [[pos2]] Lod %uint_0
27+
// CHECK-NEXT: OpStore %a2 [[result2]]
28+
uint3 pos2 = uint3(1,2,3);
29+
float4 a2 = tex2dArray[pos2];
2230
}

tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
// CHECK: OpCapability ImageQuery
44

5-
vk::SampledTexture2D<float4> t1 : register(t0);
5+
// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
6+
// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
7+
// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown
8+
// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]]
69

7-
// CHECK: %type_2d_image = OpTypeImage %float 2D 0 0 0 1 Unknown
8-
// CHECK: %type_sampled_image = OpTypeSampledImage %type_2d_image
9-
// CHECK: [[ptr:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant %type_sampled_image
10-
11-
// CHECK: %t1 = OpVariable [[ptr]] UniformConstant
10+
vk::SampledTexture2D<float4> tex2d;
11+
vk::SampledTexture2DArray<float4> tex2dArray;
1212

1313
void main() {
1414
float2 xy = float2(0.5, 0.5);
1515

16-
//CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %t1
16+
//CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d
1717
//CHECK-NEXT: [[xy_load:%[a-zA-Z0-9_]+]] = OpLoad %v2float %xy
18-
//CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1]] [[xy_load]]
18+
//CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[xy_load]]
1919
//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query]] 1
20-
float lod1 = t1.CalculateLevelOfDetailUnclamped(xy);
20+
float lod1 = tex2d.CalculateLevelOfDetailUnclamped(xy);
21+
22+
//CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray
23+
//CHECK-NEXT: [[xy_load_2:%[a-zA-Z0-9_]+]] = OpLoad %v2float %xy
24+
//CHECK-NEXT: [[query2:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex2_load]] [[xy_load_2]]
25+
//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query2]] 1
26+
float lod2 = tex2dArray.CalculateLevelOfDetailUnclamped(xy);
2127
}

tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
// CHECK: OpCapability ImageQuery
44

5-
vk::SampledTexture2D<float4> t1 : register(t0);
5+
// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
6+
// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
7+
// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown
8+
// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]]
69

7-
// CHECK: %type_2d_image = OpTypeImage %float 2D 0 0 0 1 Unknown
8-
// CHECK: %type_sampled_image = OpTypeSampledImage %type_2d_image
9-
// CHECK: [[ptr:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant %type_sampled_image
10-
11-
// CHECK: %t1 = OpVariable [[ptr]] UniformConstant
10+
vk::SampledTexture2D<float4> tex2d;
11+
vk::SampledTexture2DArray<float4> tex2dArray;
1212

1313
void main() {
1414
float2 xy = float2(0.5, 0.5);
1515

16-
//CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %t1
16+
//CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d
1717
//CHECK-NEXT: [[xy_load:%[a-zA-Z0-9_]+]] = OpLoad %v2float %xy
1818
//CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1]] [[xy_load]]
1919
//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query]] 0
20-
float lod = t1.CalculateLevelOfDetail(xy);
20+
float lod = tex2d.CalculateLevelOfDetail(xy);
21+
22+
//CHECK: [[tex2:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray
23+
//CHECK-NEXT: [[xy_load_2:%[a-zA-Z0-9_]+]] = OpLoad %v2float %xy
24+
//CHECK-NEXT: [[query2:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex2]] [[xy_load_2]]
25+
//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query2]] 0
26+
float lod2 = tex2dArray.CalculateLevelOfDetail(xy);
2127
}

tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,35 @@
44

55
// CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25
66
// CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3
7+
// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0
78

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]]
9+
// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
10+
// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
11+
// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown
12+
// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]]
1113

12-
// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant
13-
14-
vk::SampledTexture2D<float4> tex1 : register(t0);
14+
vk::SampledTexture2D<float4> tex2d;
15+
vk::SampledTexture2DArray<float4> tex2dArray;
1516

1617
float4 main() : SV_Target {
17-
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]]
18+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d
1819
// 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+
float val1 = tex2d.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f);
2021

21-
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]]
22+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d
2223
// 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+
float val2 = tex2d.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3));
2425

25-
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]]
26+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d
2627
// CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefExplicitLod %SparseResidencyStruct [[tex3_load]] [[v2fc]] %float_2 Lod|ConstOffset %float_1 [[v2ic]]
2728
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result3]] 0
2829
// CHECK: OpStore %status [[status_0]]
2930
uint status;
30-
float val3 = tex1.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3), status);
31+
float val3 = tex2d.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3), status);
32+
33+
// CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray
34+
// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[load_arr1]] [[v3fc]] %float_2 Lod %float_1
35+
float val4 = tex2dArray.SampleCmpLevel(float3(0.5, 0.25, 0), 2.0f, 1.0f);
36+
3137
return 1.0;
3238
}

0 commit comments

Comments
 (0)