From 16294e517451b365d791be863897c4fdace45ddd Mon Sep 17 00:00:00 2001 From: luciechoi Date: Tue, 24 Feb 2026 02:04:09 +0000 Subject: [PATCH 1/4] Implement vk::SampledTexture2DArray --- include/dxc/dxcapi.internal.h | 3 +- tools/clang/lib/AST/ASTContextHLSL.cpp | 2 - tools/clang/lib/SPIRV/AstTypeProbe.cpp | 2 +- tools/clang/lib/SPIRV/LowerTypeVisitor.cpp | 9 +- tools/clang/lib/SPIRV/SpirvEmitter.cpp | 1 + tools/clang/lib/Sema/SemaHLSL.cpp | 23 ++++- .../vk.sampledtexture.access.hlsl | 26 +++-- ...ampledtexture.calculate-lod-unclamped.hlsl | 24 +++-- .../vk.sampledtexture.calculate-lod.hlsl | 22 +++-- .../vk.sampledtexture.cmp-level.hlsl | 30 +++--- .../vk.sampledtexture.gather-alpha.hlsl | 43 +++++---- .../vk.sampledtexture.gather-blue.hlsl | 42 ++++---- .../vk.sampledtexture.gather-cmp-red.hlsl | 44 +++++---- .../vk.sampledtexture.gather-cmp.hlsl | 33 ++++--- .../vk.sampledtexture.gather-green.hlsl | 43 +++++---- .../vk.sampledtexture.gather-red.hlsl | 43 +++++---- .../vk.sampledtexture.gather.hlsl | 40 ++++---- .../vk.sampledtexture.get-dimensions.hlsl | 75 ++++++++++----- .../CodeGenSPIRV/vk.sampledtexture.load.hlsl | 41 ++++---- .../vk.sampledtexture.mips-access.hlsl | 25 +++-- .../vk.sampledtexture.sample-bias.hlsl | 30 +++--- .../vk.sampledtexture.sample-cmp-bias.hlsl | 30 +++--- .../vk.sampledtexture.sample-cmp-grad.hlsl | 29 +++--- ....sampledtexture.sample-cmp-level-zero.hlsl | 30 +++--- .../vk.sampledtexture.sample-cmp.hlsl | 35 ++++--- .../vk.sampledtexture.sample-grad.hlsl | 35 ++++--- .../vk.sampledtexture.sample-level.hlsl | 32 ++++--- .../vk.sampledtexture.sample.hlsl | 50 +++++----- utils/hct/gen_intrin_main.txt | 96 +++++++++++++++++++ utils/hct/hctdb.py | 2 +- 30 files changed, 593 insertions(+), 347 deletions(-) diff --git a/include/dxc/dxcapi.internal.h b/include/dxc/dxcapi.internal.h index 7a83dd6d01..ca4b892748 100644 --- a/include/dxc/dxcapi.internal.h +++ b/include/dxc/dxcapi.internal.h @@ -141,7 +141,8 @@ enum LEGAL_INTRINSIC_COMPTYPES { #ifdef ENABLE_SPIRV_CODEGEN LICOMPTYPE_VK_BUFFER_POINTER = 56, LICOMPTYPE_VK_SAMPLED_TEXTURE2D = 57, - LICOMPTYPE_COUNT = 58 + LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY = 58, + LICOMPTYPE_COUNT = 59 #else LICOMPTYPE_COUNT = 56 #endif diff --git a/tools/clang/lib/AST/ASTContextHLSL.cpp b/tools/clang/lib/AST/ASTContextHLSL.cpp index 1482d09a3f..bc9aa85ad6 100644 --- a/tools/clang/lib/AST/ASTContextHLSL.cpp +++ b/tools/clang/lib/AST/ASTContextHLSL.cpp @@ -1376,8 +1376,6 @@ CXXRecordDecl *hlsl::DeclareVkSampledTextureType(ASTContext &context, DeclContext *declContext, llvm::StringRef hlslTypeName, QualType defaultParamType) { - // TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Later - // generalize these to all SampledTexture types. BuiltinTypeDeclBuilder Builder(declContext, hlslTypeName, TagDecl::TagKind::TTK_Struct); diff --git a/tools/clang/lib/SPIRV/AstTypeProbe.cpp b/tools/clang/lib/SPIRV/AstTypeProbe.cpp index 48c3012501..6833b443f9 100644 --- a/tools/clang/lib/SPIRV/AstTypeProbe.cpp +++ b/tools/clang/lib/SPIRV/AstTypeProbe.cpp @@ -931,7 +931,7 @@ bool isSampledTexture(QualType type) { const auto name = rt->getDecl()->getName(); // TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Add // other sampled texture types as needed. - if (name == "SampledTexture2D") + if (name == "SampledTexture2D" || name == "SampledTexture2DArray") return true; } return false; diff --git a/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp b/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp index 38d2adf166..f057507834 100644 --- a/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp +++ b/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp @@ -849,7 +849,7 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace( assert(visitedTypeStack.size() == visitedTypeStackSize); return pointerType; } - if (name == "SampledTexture2D") { + if (name == "SampledTexture2D" || name == "SampledTexture2DArray") { const auto sampledType = hlsl::GetHLSLResourceResultType(type); auto loweredType = lowerType(getElementType(astContext, sampledType), rule, /*isRowMajor*/ llvm::None, srcLoc); @@ -860,10 +860,11 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace( loweredType = spvContext.getUIntType(32); } + const bool isArray = (name == "SampledTexture2DArray"); + const auto *imageType = spvContext.getImageType( - loweredType, spv::Dim::Dim2D, ImageType::WithDepth::No, - false /* array */, false /* ms */, ImageType::WithSampler::Yes, - spv::ImageFormat::Unknown); + loweredType, spv::Dim::Dim2D, ImageType::WithDepth::No, isArray, + false /* ms */, ImageType::WithSampler::Yes, spv::ImageFormat::Unknown); return spvContext.getSampledImageType(imageType); } emitError("unknown type %0 in vk namespace", srcLoc) << type; diff --git a/tools/clang/lib/SPIRV/SpirvEmitter.cpp b/tools/clang/lib/SPIRV/SpirvEmitter.cpp index ad4fe19238..7eedd5de99 100644 --- a/tools/clang/lib/SPIRV/SpirvEmitter.cpp +++ b/tools/clang/lib/SPIRV/SpirvEmitter.cpp @@ -4394,6 +4394,7 @@ SpirvEmitter::processBufferTextureGetDimensions(const CXXMemberCallExpr *expr) { if ((typeName == "Texture1D" && numArgs > 1) || (typeName == "Texture2D" && numArgs > 2) || (typeName == "SampledTexture2D" && numArgs > 2) || + (typeName == "SampledTexture2DArray" && numArgs > 3) || (typeName == "TextureCube" && numArgs > 2) || (typeName == "Texture3D" && numArgs > 3) || (typeName == "Texture1DArray" && numArgs > 2) || diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index d3ed9482de..c1e21872f3 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -201,6 +201,7 @@ enum ArBasicKind { AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID, AR_OBJECT_VK_BUFFER_POINTER, AR_OBJECT_VK_SAMPLED_TEXTURE2D, + AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -562,6 +563,7 @@ const UINT g_uBasicKindProps[] = { BPROP_OBJECT, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID use recordType BPROP_OBJECT, // AR_OBJECT_VK_BUFFER_POINTER use recordType BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D + BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -1272,6 +1274,8 @@ static const ArBasicKind g_VKBufferPointerCT[] = {AR_OBJECT_VK_BUFFER_POINTER, AR_BASIC_UNKNOWN}; static const ArBasicKind g_VKSampledTexture2DCT[] = { AR_OBJECT_VK_SAMPLED_TEXTURE2D, AR_BASIC_UNKNOWN}; +static const ArBasicKind g_VKSampledTexture2DArrayCT[] = { + AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, AR_BASIC_UNKNOWN}; #endif // Basic kinds, indexed by a LEGAL_INTRINSIC_COMPTYPES value. @@ -1334,8 +1338,9 @@ const ArBasicKind *g_LegalIntrinsicCompTypes[] = { g_LinAlgCT, // LICOMPTYPE_LINALG g_BuiltInTrianglePositionsCT, // LICOMPTYPE_BUILTIN_TRIANGLE_POSITIONS #ifdef ENABLE_SPIRV_CODEGEN - g_VKBufferPointerCT, // LICOMPTYPE_VK_BUFFER_POINTER - g_VKSampledTexture2DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D + g_VKBufferPointerCT, // LICOMPTYPE_VK_BUFFER_POINTER + g_VKSampledTexture2DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D + g_VKSampledTexture2DArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY #endif }; static_assert( @@ -1396,6 +1401,7 @@ static const ArBasicKind g_ArBasicKindsAsTypes[] = { AR_OBJECT_VK_INTEGRAL_CONSTANT, AR_OBJECT_VK_LITERAL, AR_OBJECT_VK_SPV_INTRINSIC_TYPE, AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID, AR_OBJECT_VK_BUFFER_POINTER, AR_OBJECT_VK_SAMPLED_TEXTURE2D, + AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -1508,6 +1514,7 @@ static const uint8_t g_ArBasicKindsTemplateCount[] = { 1, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID 2, // AR_OBJECT_VK_BUFFER_POINTER 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D + 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -1662,6 +1669,7 @@ static const SubscriptOperatorRecord g_ArBasicKindsSubscripts[] = { {0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID {0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_BUFFER_POINTER {2, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D + {3, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -1832,6 +1840,7 @@ static const char *g_ArBasicTypeNames[] = { "ext_result_id", "BufferPointer", "SampledTexture2D", + "SampledTexture2DArray", #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -2489,6 +2498,10 @@ static void GetIntrinsicMethods(ArBasicKind kind, *intrinsics = g_VkSampledTexture2DMethods; *intrinsicCount = _countof(g_VkSampledTexture2DMethods); break; + case AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY: + *intrinsics = g_VkSampledTexture2DArrayMethods; + *intrinsicCount = _countof(g_VkSampledTexture2DArrayMethods); + break; #endif case AR_OBJECT_HIT_OBJECT: *intrinsics = g_DxHitObjectMethods; @@ -4094,13 +4107,14 @@ class HLSLExternalSource : public ExternalSemaSource { recordDecl = DeclareVkBufferPointerType(*m_context, m_vkNSDecl); recordDecl->setImplicit(true); m_vkBufferPointerTemplateDecl = recordDecl->getDescribedClassTemplate(); - } else if (kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D) { + } else if (kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D || + kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY) { if (!m_vkNSDecl) continue; QualType float4Type = LookupVectorType(HLSLScalarType::HLSLScalarType_float, 4); recordDecl = DeclareVkSampledTextureType( - *m_context, m_vkNSDecl, "SampledTexture2D", float4Type); + *m_context, m_vkNSDecl, g_ArBasicTypeNames[kind], float4Type); if (Attr) recordDecl->addAttr(Attr); m_vkSampledTextureTemplateDecl = @@ -5060,6 +5074,7 @@ class HLSLExternalSource : public ExternalSemaSource { ResClass = DXIL::ResourceClass::UAV; return true; case AR_OBJECT_TEXTURE2D_ARRAY: + case AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY: ResKind = DXIL::ResourceKind::Texture2DArray; ResClass = DXIL::ResourceClass::SRV; return true; diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.access.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.access.hlsl index cd5d443eeb..afd60d101a 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.access.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.access.hlsl @@ -2,21 +2,29 @@ // CHECK: [[cu12:%[0-9]+]] = OpConstantComposite %v2uint %uint_1 %uint_2 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; void main() { // CHECK: OpStore %pos1 [[cu12]] // CHECK-NEXT: [[pos1:%[0-9]+]] = OpLoad %v2uint %pos1 -// CHECK-NEXT: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image_1]] [[tex1_load]] +// CHECK-NEXT: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image]] [[tex1_load]] // CHECK-NEXT: [[result1:%[0-9]+]] = OpImageFetch %v4float [[tex_img]] [[pos1]] Lod %uint_0 // CHECK-NEXT: OpStore %a1 [[result1]] uint2 pos1 = uint2(1,2); - float4 a1 = tex1[pos1]; + float4 a1 = tex2d[pos1]; + +// CHECK: [[pos2:%[0-9]+]] = OpLoad %v3uint %pos2 +// CHECK-NEXT: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK-NEXT: [[tex2_img:%[0-9]+]] = OpImage [[type_2d_image_array]] [[tex2_load]] +// CHECK-NEXT: [[result2:%[0-9]+]] = OpImageFetch %v4float [[tex2_img]] [[pos2]] Lod %uint_0 +// CHECK-NEXT: OpStore %a2 [[result2]] + uint3 pos2 = uint3(1,2,3); + float4 a2 = tex2dArray[pos2]; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl index aebc57738b..e390cf26f3 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl @@ -2,20 +2,26 @@ // CHECK: OpCapability ImageQuery -vk::SampledTexture2D t1 : register(t0); +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: %type_2d_image = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: %type_sampled_image = OpTypeSampledImage %type_2d_image -// CHECK: [[ptr:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant %type_sampled_image - -// CHECK: %t1 = OpVariable [[ptr]] UniformConstant +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; void main() { float2 xy = float2(0.5, 0.5); -//CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %t1 +//CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d //CHECK-NEXT: [[xy_load:%[a-zA-Z0-9_]+]] = OpLoad %v2float %xy -//CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1]] [[xy_load]] +//CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[xy_load]] //CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query]] 1 - float lod1 = t1.CalculateLevelOfDetailUnclamped(xy); + float lod1 = tex2d.CalculateLevelOfDetailUnclamped(xy); + +//CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +//CHECK-NEXT: [[xy_load_2:%[a-zA-Z0-9_]+]] = OpLoad %v2float %xy +//CHECK-NEXT: [[query2:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex2_load]] [[xy_load_2]] +//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query2]] 1 + float lod2 = tex2dArray.CalculateLevelOfDetailUnclamped(xy); } \ No newline at end of file diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl index 01d3efb5aa..15aaaf1956 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl @@ -2,20 +2,26 @@ // CHECK: OpCapability ImageQuery -vk::SampledTexture2D t1 : register(t0); +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: %type_2d_image = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: %type_sampled_image = OpTypeSampledImage %type_2d_image -// CHECK: [[ptr:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant %type_sampled_image - -// CHECK: %t1 = OpVariable [[ptr]] UniformConstant +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; void main() { float2 xy = float2(0.5, 0.5); -//CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %t1 +//CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d //CHECK-NEXT: [[xy_load:%[a-zA-Z0-9_]+]] = OpLoad %v2float %xy //CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1]] [[xy_load]] //CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query]] 0 - float lod = t1.CalculateLevelOfDetail(xy); + float lod = tex2d.CalculateLevelOfDetail(xy); + +//CHECK: [[tex2:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +//CHECK-NEXT: [[xy_load_2:%[a-zA-Z0-9_]+]] = OpLoad %v2float %xy +//CHECK-NEXT: [[query2:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex2]] [[xy_load_2]] +//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query2]] 0 + float lod2 = tex2dArray.CalculateLevelOfDetail(xy); } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl index 4dd8dec8af..d645ce5464 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl @@ -4,29 +4,35 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1_load]] [[v2fc]] %float_2 Lod %float_1 - float val1 = tex1.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f); + float val1 = tex2d.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex2_load]] [[v2fc]] %float_2 Lod|ConstOffset %float_1 [[v2ic]] - float val2 = tex1.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3)); + float val2 = tex2d.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3)); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefExplicitLod %SparseResidencyStruct [[tex3_load]] [[v2fc]] %float_2 Lod|ConstOffset %float_1 [[v2ic]] // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result3]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float val3 = tex1.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3), status); + float val3 = tex2d.SampleCmpLevel(float2(0.5, 0.25), 2.0f, 1.0f, int2(2,3), status); + +// CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[load_arr1]] [[v3fc]] %float_2 Lod %float_1 + float val4 = tex2dArray.SampleCmpLevel(float3(0.5, 0.25, 0), 2.0f, 1.0f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-alpha.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-alpha.hlsl index e08c9a770c..f4faea0f8a 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-alpha.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-alpha.hlsl @@ -4,51 +4,54 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[type_struct_result:%[a-zA-Z0-9_]+]] = OpTypeStruct %uint %v4float - -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { uint status; float4 val = 0; -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_alpha:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_3 // CHECK: OpStore %val [[val_alpha]] - val = tex1.GatherAlpha(float2(0.5, 0.25)); + val = tex2d.GatherAlpha(float2(0.5, 0.25)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_alpha_o:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_3 ConstOffset [[v2ic]] // CHECK: OpStore %val [[val_alpha_o]] - val = tex1.GatherAlpha(float2(0.5, 0.25), int2(2, 3)); + val = tex2d.GatherAlpha(float2(0.5, 0.25), int2(2, 3)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_alpha_o4:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_3 ConstOffsets [[const_offsets:%[a-zA-Z0-9_]+]] // CHECK: OpStore %val [[val_alpha_o4]] - val = tex1.GatherAlpha(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); + val = tex2d.GatherAlpha(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_alpha_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %int_3 ConstOffset [[v2ic]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_alpha_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %int_3 ConstOffset [[v2ic]] // CHECK: [[status_alpha_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_alpha_s]] 0 // CHECK: OpStore %status [[status_alpha_s]] // CHECK: [[res_alpha_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_alpha_s]] 1 // CHECK: OpStore %val [[res_alpha_s]] - val = tex1.GatherAlpha(float2(0.5, 0.25), int2(2, 3), status); + val = tex2d.GatherAlpha(float2(0.5, 0.25), int2(2, 3), status); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_alpha_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %int_3 ConstOffsets [[const_offsets]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_alpha_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %int_3 ConstOffsets [[const_offsets]] // CHECK: [[status_alpha_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_alpha_o4_s]] 0 // CHECK: OpStore %status [[status_alpha_o4_s]] // CHECK: [[res_alpha_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_alpha_o4_s]] 1 // CHECK: OpStore %val [[res_alpha_o4_s]] - val = tex1.GatherAlpha(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + val = tex2d.GatherAlpha(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[val_alpha_array:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex2_load]] [[v3fc]] %int_3 None + val = tex2dArray.GatherAlpha(float3(0.5, 0.25, 0)); return val; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-blue.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-blue.hlsl index cdf3e1eb6b..387b1cf71f 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-blue.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-blue.hlsl @@ -4,51 +4,55 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[type_struct_result:%[a-zA-Z0-9_]+]] = OpTypeStruct %uint %v4float +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); float4 main() : SV_Target { uint status; float4 val = 0; -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_blue:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_2 // CHECK: OpStore %val [[val_blue]] - val = tex1.GatherBlue(float2(0.5, 0.25)); + val = tex2d.GatherBlue(float2(0.5, 0.25)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_blue_o:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_2 ConstOffset [[v2ic]] // CHECK: OpStore %val [[val_blue_o]] - val = tex1.GatherBlue(float2(0.5, 0.25), int2(2, 3)); + val = tex2d.GatherBlue(float2(0.5, 0.25), int2(2, 3)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_blue_o4:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_2 ConstOffsets [[const_offsets:%[a-zA-Z0-9_]+]] // CHECK: OpStore %val [[val_blue_o4]] - val = tex1.GatherBlue(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); + val = tex2d.GatherBlue(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_blue_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %int_2 ConstOffset [[v2ic]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_blue_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %int_2 ConstOffset [[v2ic]] // CHECK: [[status_blue_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_blue_s]] 0 // CHECK: OpStore %status [[status_blue_s]] // CHECK: [[res_blue_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_blue_s]] 1 // CHECK: OpStore %val [[res_blue_s]] - val = tex1.GatherBlue(float2(0.5, 0.25), int2(2, 3), status); + val = tex2d.GatherBlue(float2(0.5, 0.25), int2(2, 3), status); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_blue_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %int_2 ConstOffsets [[const_offsets]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_blue_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %int_2 ConstOffsets [[const_offsets]] // CHECK: [[status_blue_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_blue_o4_s]] 0 // CHECK: OpStore %status [[status_blue_o4_s]] // CHECK: [[res_blue_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_blue_o4_s]] 1 // CHECK: OpStore %val [[res_blue_o4_s]] - val = tex1.GatherBlue(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + val = tex2d.GatherBlue(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[val_blue_array:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex2_load]] [[v3fc]] %int_2 None + val = tex2dArray.GatherBlue(float3(0.5, 0.25, 0)); return val; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp-red.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp-red.hlsl index fb3fd22114..a742f28820 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp-red.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp-red.hlsl @@ -4,51 +4,55 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[type_struct_result:%[a-zA-Z0-9_]+]] = OpTypeStruct %uint %v4float - -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { uint status; float4 val = 0; -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_red:%[a-zA-Z0-9_]+]] = OpImageDrefGather %v4float [[tex1_load]] [[v2fc]] %float_0_5 None // CHECK: OpStore %val [[val_red]] - val = tex1.GatherCmpRed(float2(0.5, 0.25), 0.5); + val = tex2d.GatherCmpRed(float2(0.5, 0.25), 0.5); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_red_o:%[a-zA-Z0-9_]+]] = OpImageDrefGather %v4float [[tex1_load]] [[v2fc]] %float_0_5 ConstOffset [[v2ic]] // CHECK: OpStore %val [[val_red_o]] - val = tex1.GatherCmpRed(float2(0.5, 0.25), 0.5, int2(2, 3)); + val = tex2d.GatherCmpRed(float2(0.5, 0.25), 0.5, int2(2, 3)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_red_o4:%[a-zA-Z0-9_]+]] = OpImageDrefGather %v4float [[tex1_load]] [[v2fc]] %float_0_5 ConstOffsets [[const_offsets:%[a-zA-Z0-9_]+]] // CHECK: OpStore %val [[val_red_o4]] - val = tex1.GatherCmpRed(float2(0.5, 0.25), 0.5, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); + val = tex2d.GatherCmpRed(float2(0.5, 0.25), 0.5, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_cmp_s:%[a-zA-Z0-9_]+]] = OpImageSparseDrefGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %float_0_5 ConstOffset [[v2ic]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_cmp_s:%[a-zA-Z0-9_]+]] = OpImageSparseDrefGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %float_0_5 ConstOffset [[v2ic]] // CHECK: [[status_cmp_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_cmp_s]] 0 // CHECK: OpStore %status [[status_cmp_s]] // CHECK: [[res_cmp_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_cmp_s]] 1 // CHECK: OpStore %val [[res_cmp_s]] - val = tex1.GatherCmpRed(float2(0.5, 0.25), 0.5, int2(2, 3), status); + val = tex2d.GatherCmpRed(float2(0.5, 0.25), 0.5, int2(2, 3), status); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_cmp_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseDrefGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %float_0_5 ConstOffsets [[const_offsets]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_cmp_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseDrefGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %float_0_5 ConstOffsets [[const_offsets]] // CHECK: [[status_cmp_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_cmp_o4_s]] 0 // CHECK: OpStore %status [[status_cmp_o4_s]] // CHECK: [[res_cmp_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_cmp_o4_s]] 1 // CHECK: OpStore %val [[res_cmp_o4_s]] - val = tex1.GatherCmpRed(float2(0.5, 0.25), 0.5, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + val = tex2d.GatherCmpRed(float2(0.5, 0.25), 0.5, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[val_red_array:%[a-zA-Z0-9_]+]] = OpImageDrefGather %v4float [[tex2_load]] [[v3fc]] %float_0_5 None +// CHECK: OpStore %val [[val_red_array]] + val = tex2dArray.GatherCmpRed(float3(0.5, 0.25, 0), 0.5); return val; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp.hlsl index 346669f05d..199e89f721 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-cmp.hlsl @@ -4,37 +4,42 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_1 %int_2 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] -// CHECK: [[type_struct_result:%[a-zA-Z0-9_]+]] = OpTypeStruct %uint %v4float +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { uint status; float4 val = 0; -// CHECK: [[tex1_load_1:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load_1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_1:%[a-zA-Z0-9_]+]] = OpImageDrefGather %v4float [[tex1_load_1]] [[v2fc]] %float_0_5 // CHECK: OpStore %val [[val_1]] - val = tex1.GatherCmp(float2(0.5, 0.25), 0.5); + val = tex2d.GatherCmp(float2(0.5, 0.25), 0.5); -// CHECK: [[tex1_load_2:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load_2:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_2:%[a-zA-Z0-9_]+]] = OpImageDrefGather %v4float [[tex1_load_2]] [[v2fc]] %float_0_5 ConstOffset [[v2ic]] // CHECK: OpStore %val [[val_2]] - val = tex1.GatherCmp(float2(0.5, 0.25), 0.5, int2(1, 2)); + val = tex2d.GatherCmp(float2(0.5, 0.25), 0.5, int2(1, 2)); -// CHECK: [[tex1_load_3:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_struct:%[a-zA-Z0-9_]+]] = OpImageSparseDrefGather [[type_struct_result]] [[tex1_load_3]] [[v2fc]] %float_0_5 ConstOffset [[v2ic]] +// CHECK: [[tex1_load_3:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_struct:%[a-zA-Z0-9_]+]] = OpImageSparseDrefGather %SparseResidencyStruct [[tex1_load_3]] [[v2fc]] %float_0_5 ConstOffset [[v2ic]] // CHECK: [[status_1:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_struct]] 0 // CHECK: OpStore %status [[status_1]] // CHECK: [[res_1:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_struct]] 1 // CHECK: OpStore %val [[res_1]] - val = tex1.GatherCmp(float2(0.5, 0.25), 0.5, int2(1, 2), status); + val = tex2d.GatherCmp(float2(0.5, 0.25), 0.5, int2(1, 2), status); + +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[val_3:%[a-zA-Z0-9_]+]] = OpImageDrefGather %v4float [[tex2_load]] [[v3fc]] %float_0_5 None +// CHECK: OpStore %val [[val_3]] + val = tex2dArray.GatherCmp(float3(0.5, 0.25, 0), 0.5); return val; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-green.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-green.hlsl index d9fd0cb94d..29e87b9214 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-green.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-green.hlsl @@ -4,51 +4,54 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[type_struct_result:%[a-zA-Z0-9_]+]] = OpTypeStruct %uint %v4float - -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { uint status; float4 val = 0; -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_green:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_1 // CHECK: OpStore %val [[val_green]] - val = tex1.GatherGreen(float2(0.5, 0.25)); + val = tex2d.GatherGreen(float2(0.5, 0.25)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_green_o:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_1 ConstOffset [[v2ic]] // CHECK: OpStore %val [[val_green_o]] - val = tex1.GatherGreen(float2(0.5, 0.25), int2(2, 3)); + val = tex2d.GatherGreen(float2(0.5, 0.25), int2(2, 3)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_green_o4:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_1 ConstOffsets [[const_offsets:%[a-zA-Z0-9_]+]] // CHECK: OpStore %val [[val_green_o4]] - val = tex1.GatherGreen(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); + val = tex2d.GatherGreen(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_green_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %int_1 ConstOffset [[v2ic]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_green_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %int_1 ConstOffset [[v2ic]] // CHECK: [[status_green_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_green_s]] 0 // CHECK: OpStore %status [[status_green_s]] // CHECK: [[res_green_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_green_s]] 1 // CHECK: OpStore %val [[res_green_s]] - val = tex1.GatherGreen(float2(0.5, 0.25), int2(2, 3), status); + val = tex2d.GatherGreen(float2(0.5, 0.25), int2(2, 3), status); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_green_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %int_1 ConstOffsets [[const_offsets]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_green_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %int_1 ConstOffsets [[const_offsets]] // CHECK: [[status_green_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_green_o4_s]] 0 // CHECK: OpStore %status [[status_green_o4_s]] // CHECK: [[res_green_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_green_o4_s]] 1 // CHECK: OpStore %val [[res_green_o4_s]] - val = tex1.GatherGreen(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + val = tex2d.GatherGreen(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[val_green_array:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex2_load]] [[v3fc]] %int_1 None + val = tex2dArray.GatherGreen(float3(0.5, 0.25, 0)); return val; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-red.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-red.hlsl index 5a70e3fb63..a449e11577 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-red.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-red.hlsl @@ -4,51 +4,54 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[type_struct_result:%[a-zA-Z0-9_]+]] = OpTypeStruct %uint %v4float - -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { uint status; float4 val = 0; -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_red:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_0 // CHECK: OpStore %val [[val_red]] - val = tex1.GatherRed(float2(0.5, 0.25)); + val = tex2d.GatherRed(float2(0.5, 0.25)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_red_o:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_0 ConstOffset [[v2ic]] // CHECK: OpStore %val [[val_red_o]] - val = tex1.GatherRed(float2(0.5, 0.25), int2(2, 3)); + val = tex2d.GatherRed(float2(0.5, 0.25), int2(2, 3)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[val_red_o4:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_0 ConstOffsets [[const_offsets:%[a-zA-Z0-9_]+]] // CHECK: OpStore %val [[val_red_o4]] - val = tex1.GatherRed(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); + val = tex2d.GatherRed(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8)); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_red_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %int_0 ConstOffset [[v2ic]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_red_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %int_0 ConstOffset [[v2ic]] // CHECK: [[status_red_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_red_s]] 0 // CHECK: OpStore %status [[status_red_s]] // CHECK: [[res_red_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_red_s]] 1 // CHECK: OpStore %val [[res_red_s]] - val = tex1.GatherRed(float2(0.5, 0.25), int2(2, 3), status); + val = tex2d.GatherRed(float2(0.5, 0.25), int2(2, 3), status); -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[val_red_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather [[type_struct_result]] [[tex1_load]] [[v2fc]] %int_0 ConstOffsets [[const_offsets]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[val_red_o4_s:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex1_load]] [[v2fc]] %int_0 ConstOffsets [[const_offsets]] // CHECK: [[status_red_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val_red_o4_s]] 0 // CHECK: OpStore %status [[status_red_o4_s]] // CHECK: [[res_red_o4_s:%[a-zA-Z0-9_]+]] = OpCompositeExtract %v4float [[val_red_o4_s]] 1 // CHECK: OpStore %val [[res_red_o4_s]] - val = tex1.GatherRed(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + val = tex2d.GatherRed(float2(0.5, 0.25), int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status); + +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[val_red_array:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex2_load]] [[v3fc]] %int_0 None + val = tex2dArray.GatherRed(float3(0.5, 0.25, 0)); return val; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather.hlsl index f7a26c153a..b2a4536368 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather.hlsl @@ -4,39 +4,39 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_uint:%[a-zA-Z0-9_]+]] = OpTypeImage %uint 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image_uint:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_uint]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[type_2d_image_2:%[a-zA-Z0-9_]+]] = OpTypeImage %uint 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_2:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_2]] -// CHECK: [[ptr_type_2:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_2]] - -// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float - -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant -// CHECK: [[tex2:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_2]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); -vk::SampledTexture2D tex2 : register(t2); +vk::SampledTexture2D tex2df4; +vk::SampledTexture2D tex2duint; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2df4 // CHECK: [[val1:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex1_load]] [[v2fc]] %int_0 None - float4 val1 = tex1.Gather(float2(0.5, 0.25)); + float4 val1 = tex2df4.Gather(float2(0.5, 0.25)); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_2]] [[tex2]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_uint]] %tex2duint // CHECK: [[val2:%[a-zA-Z0-9_]+]] = OpImageGather %v4uint [[tex2_load]] [[v2fc]] %int_0 ConstOffset [[v2ic]] - uint4 val2 = tex2.Gather(float2(0.5, 0.25), int2(2, 3)); + uint4 val2 = tex2duint.Gather(float2(0.5, 0.25), int2(2, 3)); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2df4 // CHECK: [[val3:%[a-zA-Z0-9_]+]] = OpImageSparseGather %SparseResidencyStruct [[tex3_load]] [[v2fc]] %int_0 ConstOffset [[v2ic]] // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[val3]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float4 val3 = tex1.Gather(float2(0.5, 0.25), int2(2, 3), status); + float4 val3 = tex2df4.Gather(float2(0.5, 0.25), int2(2, 3), status); + +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[val4:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex3_load]] [[v3fc]] %int_0 None + float4 val4 = tex2dArray.Gather(float3(0.5, 0.25, 0)); return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl index cf98bd8649..33dc2e9561 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl @@ -3,23 +3,29 @@ // CHECK: OpCapability ImageQuery -vk::SampledTexture2D t1; +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] + +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; void main() { uint mipLevel = 1; - uint width, height, numLevels; + uint width, height, numLevels, elements; -// CHECK: [[t1_load:%[0-9]+]] = OpLoad %type_sampled_image %t1 -// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage %type_2d_image [[t1_load]] +// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] // CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQuerySizeLod %v2uint [[image1]] %int_0 // CHECK-NEXT: [[query1_0:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 0 // CHECK-NEXT: OpStore %width [[query1_0]] // CHECK-NEXT: [[query1_1:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 1 // CHECK-NEXT: OpStore %height [[query1_1]] - t1.GetDimensions(width, height); + tex2d.GetDimensions(width, height); -// CHECK: [[t1_load:%[0-9]+]] = OpLoad %type_sampled_image %t1 -// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage %type_2d_image [[t1_load]] +// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] // CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel // CHECK-NEXT: [[query2:%[0-9]+]] = OpImageQuerySizeLod %v2uint [[image2]] [[mip]] // CHECK-NEXT: [[query2_0:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 0 @@ -28,11 +34,36 @@ void main() { // CHECK-NEXT: OpStore %height [[query2_1]] // CHECK-NEXT: [[query_level_2:%[0-9]+]] = OpImageQueryLevels %uint [[image2]] // CHECK-NEXT: OpStore %numLevels [[query_level_2]] - t1.GetDimensions(mipLevel, width, height, numLevels); + tex2d.GetDimensions(mipLevel, width, height, numLevels); + +// CHECK: [[t2_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK-NEXT: [[image3:%[0-9]+]] = OpImage [[type_2d_image_array]] [[t2_load]] +// CHECK-NEXT: [[query3:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image3]] %int_0 +// CHECK-NEXT: [[query3_0:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 0 +// CHECK-NEXT: OpStore %width [[query3_0]] +// CHECK-NEXT: [[query3_1:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 1 +// CHECK-NEXT: OpStore %height [[query3_1]] +// CHECK-NEXT: [[query3_2:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 2 +// CHECK-NEXT: OpStore %elements [[query3_2]] + tex2dArray.GetDimensions(width, height, elements); + +// CHECK: [[t2_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK-NEXT: [[image4:%[0-9]+]] = OpImage %type_2d_image_array [[t2_load]] +// CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel +// CHECK-NEXT: [[query4:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image4]] [[mip]] +// CHECK-NEXT: [[query4_0:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 0 +// CHECK-NEXT: OpStore %width [[query4_0]] +// CHECK-NEXT: [[query4_1:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 1 +// CHECK-NEXT: OpStore %height [[query4_1]] +// CHECK-NEXT: [[query4_2:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 2 +// CHECK-NEXT: OpStore %elements [[query4_2]] +// CHECK-NEXT: [[query_level_4:%[0-9]+]] = OpImageQueryLevels %uint [[image4]] +// CHECK-NEXT: OpStore %numLevels [[query_level_4]] + tex2dArray.GetDimensions(mipLevel, width, height, elements, numLevels); float f_width, f_height, f_numLevels; -// CHECK: [[t1_load:%[0-9]+]] = OpLoad %type_sampled_image %t1 -// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage %type_2d_image [[t1_load]] +// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] // CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQuerySizeLod %v2uint [[image1]] %int_0 // CHECK-NEXT: [[query1_0:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 0 // CHECK-NEXT: [[f_query1_0:%[0-9]+]] = OpConvertUToF %float [[query1_0]] @@ -40,10 +71,10 @@ void main() { // CHECK-NEXT: [[query1_1:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 1 // CHECK-NEXT: [[f_query1_1:%[0-9]+]] = OpConvertUToF %float [[query1_1]] // CHECK-NEXT: OpStore %f_height [[f_query1_1]] - t1.GetDimensions(f_width, f_height); + tex2d.GetDimensions(f_width, f_height); -// CHECK: [[t1_load:%[0-9]+]] = OpLoad %type_sampled_image %t1 -// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage %type_2d_image [[t1_load]] +// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] // CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel // CHECK-NEXT: [[query2:%[0-9]+]] = OpImageQuerySizeLod %v2uint [[image2]] [[mip]] // CHECK-NEXT: [[query2_0:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 0 @@ -55,11 +86,11 @@ void main() { // CHECK-NEXT: [[query_level_2:%[0-9]+]] = OpImageQueryLevels %uint [[image2]] // CHECK-NEXT: [[f_query_level_2:%[0-9]+]] = OpConvertUToF %float [[query_level_2]] // CHECK-NEXT: OpStore %f_numLevels [[f_query_level_2]] - t1.GetDimensions(mipLevel, f_width, f_height, f_numLevels); + tex2d.GetDimensions(mipLevel, f_width, f_height, f_numLevels); int i_width, i_height, i_numLevels; -// CHECK: [[t1_load:%[0-9]+]] = OpLoad %type_sampled_image %t1 -// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage %type_2d_image [[t1_load]] +// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] // CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQuerySizeLod %v2uint [[image1]] %int_0 // CHECK-NEXT: [[query1_0:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 0 // CHECK-NEXT: [[query_0_int:%[0-9]+]] = OpBitcast %int [[query1_0]] @@ -67,10 +98,10 @@ void main() { // CHECK-NEXT: [[query1_1:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 1 // CHECK-NEXT: [[query_1_int:%[0-9]+]] = OpBitcast %int [[query1_1]] // CHECK-NEXT: OpStore %i_height [[query_1_int]] - t1.GetDimensions(i_width, i_height); + tex2d.GetDimensions(i_width, i_height); -// CHECK: [[t1_load:%[0-9]+]] = OpLoad %type_sampled_image %t1 -// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage %type_2d_image [[t1_load]] +// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] // CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel // CHECK-NEXT: [[query2:%[0-9]+]] = OpImageQuerySizeLod %v2uint [[image2]] [[mip]] // CHECK-NEXT: [[query2_0:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 0 @@ -82,13 +113,13 @@ void main() { // CHECK-NEXT: [[query_level_2:%[0-9]+]] = OpImageQueryLevels %uint [[image2]] // CHECK-NEXT: [[query_level_2_int:%[0-9]+]] = OpBitcast %int [[query_level_2]] // CHECK-NEXT: OpStore %i_numLevels [[query_level_2_int]] - t1.GetDimensions(mipLevel, i_width, i_height, i_numLevels); + tex2d.GetDimensions(mipLevel, i_width, i_height, i_numLevels); #ifdef ERROR // ERROR: error: Output argument must be an l-value - t1.GetDimensions(mipLevel, 0, height, numLevels); + tex2d.GetDimensions(mipLevel, 0, height, numLevels); // ERROR: error: Output argument must be an l-value - t1.GetDimensions(width, 20); + tex2d.GetDimensions(width, 20); #endif } \ No newline at end of file diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl index 8ecd9e70a3..a5e085cb00 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl @@ -1,48 +1,57 @@ // RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s - -vk::SampledTexture2D tex2D_F4 : register(t1); - -// CHECK: OpCapability SparseResidency - // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_1 %int_2 -// CHECK: %SparseResidencyStruct = OpTypeStruct %uint %v4float +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -float4 main(int3 location: A) : SV_Target { +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; + +float4 main(int3 location3: A, int4 location4: B) : SV_Target { uint status; -// CHECK: [[loc:%[0-9]+]] = OpLoad %v3int %location +// CHECK: [[loc:%[0-9]+]] = OpLoad %v3int %location3 // CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v2int [[loc]] [[loc]] 0 1 // CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 2 -// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad %type_sampled_image %tex2D_F4 +// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage %type_2d_image [[tex]] // CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod [[lod_0]] - float4 val1 = tex2D_F4.Load(location); + float4 val1 = tex2d.Load(location3); -// CHECK: [[loc:%[0-9]+]] = OpLoad %v3int %location +// CHECK: [[loc:%[0-9]+]] = OpLoad %v3int %location3 // CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v2int [[loc]] [[loc]] 0 1 // CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 2 -// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad %type_sampled_image %tex2D_F4 +// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage %type_2d_image [[tex]] // CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod|ConstOffset [[lod_0]] [[v2ic]] - float4 val2 = tex2D_F4.Load(location, int2(1, 2)); + float4 val2 = tex2d.Load(location3, int2(1, 2)); ///////////////////////////////// /// Using the Status argument /// ///////////////////////////////// -// CHECK: [[loc:%[0-9]+]] = OpLoad %v3int %location +// CHECK: [[loc:%[0-9]+]] = OpLoad %v3int %location3 // CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v2int [[loc]] [[loc]] 0 1 // CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 2 -// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad %type_sampled_image %tex2D_F4 +// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage %type_2d_image [[tex]] // CHECK-NEXT:[[structResult:%[0-9]+]] = OpImageSparseFetch %SparseResidencyStruct [[tex_img]] [[coord_0]] Lod|ConstOffset [[lod_0]] [[v2ic]] // CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0 // CHECK-NEXT: OpStore %status [[status]] // CHECK-NEXT: [[v4result:%[0-9]+]] = OpCompositeExtract %v4float [[structResult]] 1 // CHECK-NEXT: OpStore %val3 [[v4result]] - float4 val3 = tex2D_F4.Load(location, int2(1, 2), status); + float4 val3 = tex2d.Load(location3, int2(1, 2), status); + +// CHECK: [[loc:%[0-9]+]] = OpLoad %v4int %location4 +// CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v3int [[loc]] [[loc]] 0 1 2 +// CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 3 +// CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image_array]] [[tex]] +// CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod [[lod_0]] + float4 val4 = tex2dArray.Load(location4); return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl index 2e76fe4b61..7858278db9 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl @@ -2,21 +2,28 @@ // CHECK: [[cu12:%[0-9]+]] = OpConstantComposite %v2uint %uint_1 %uint_2 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t1); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; void main() { // CHECK: OpStore %pos1 [[cu12]] // CHECK-NEXT: [[pos1:%[0-9]+]] = OpLoad %v2uint %pos1 -// CHECK-NEXT: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image_1]] [[tex1_load]] +// CHECK-NEXT: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image]] [[tex1_load]] // CHECK-NEXT: [[result1:%[0-9]+]] = OpImageFetch %v4float [[tex_img]] [[pos1]] Lod %uint_2 // CHECK-NEXT: OpStore %a1 [[result1]] uint2 pos1 = uint2(1,2); - float4 a1 = tex1.mips[2][pos1]; + float4 a1 = tex2d.mips[2][pos1]; + +// CHECK: [[pos2:%[0-9]+]] = OpLoad %v3uint %pos2 +// CHECK-NEXT: [[load_arr:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK-NEXT: [[img_arr:%[a-zA-Z0-9_]+]] = OpImage [[type_2d_image_array]] [[load_arr]] +// CHECK-NEXT: [[res_arr:%[0-9]+]] = OpImageFetch %v4float [[img_arr]] [[pos2]] Lod %uint_3 + uint3 pos2 = uint3(1, 2, 4); + float4 a2 = tex2dArray.mips[3][pos2]; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl index a233394f6e..bd10307de7 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl @@ -5,29 +5,35 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex1_load]] [[v2fc]] Bias|ConstOffset %float_0_5 [[v2ic]] - float4 val1 = tex1.SampleBias(float2(0.5, 0.25), 0.5f, int2(2, 3)); + float4 val1 = tex2d.SampleBias(float2(0.5, 0.25), 0.5f, int2(2, 3)); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex2_load]] [[v2fc]] Bias|ConstOffset|MinLod %float_0_5 [[v2ic]] %float_2_5 - float4 val2 = tex1.SampleBias(float2(0.5, 0.25), 0.5f, int2(2, 3), 2.5f); + float4 val2 = tex2d.SampleBias(float2(0.5, 0.25), 0.5f, int2(2, 3), 2.5f); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[tex3_load]] [[v2fc]] Bias|ConstOffset|MinLod %float_0_5 [[v2ic]] %float_2_5 // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result3]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float4 val3 = tex1.SampleBias(float2(0.5, 0.25), 0.5f, int2(2, 3), 2.5f, status); + float4 val3 = tex2d.SampleBias(float2(0.5, 0.25), 0.5f, int2(2, 3), 2.5f, status); + +// CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[load_arr1]] [[v3fc]] Bias|ConstOffset %float_0_5 [[v2ic]] + float4 val4 = tex2dArray.SampleBias(float3(0.5, 0.25, 0), 0.5f, int2(2, 3)); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl index e302d88a50..0180f2c7b3 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl @@ -5,29 +5,35 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex1_load]] [[v2fc]] %float_1 Bias|ConstOffset %float_0_5 [[v2ic]] - float val1 = tex1.SampleCmpBias(float2(0.5, 0.25), 1.0f, 0.5f, int2(2, 3)); + float val1 = tex2d.SampleCmpBias(float2(0.5, 0.25), 1.0f, 0.5f, int2(2, 3)); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex2_load]] [[v2fc]] %float_1 Bias|ConstOffset|MinLod %float_0_5 [[v2ic]] %float_2_5 - float val2 = tex1.SampleCmpBias(float2(0.5, 0.25), 1.0f, 0.5f, int2(2, 3), 2.5f); + float val2 = tex2d.SampleCmpBias(float2(0.5, 0.25), 1.0f, 0.5f, int2(2, 3), 2.5f); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefImplicitLod %SparseResidencyStruct [[tex3_load]] [[v2fc]] %float_1 Bias|ConstOffset|MinLod %float_0_5 [[v2ic]] %float_2_5 // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result3]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float val3 = tex1.SampleCmpBias(float2(0.5, 0.25), 1.0f, 0.5f, int2(2, 3), 2.5f, status); + float val3 = tex2d.SampleCmpBias(float2(0.5, 0.25), 1.0f, 0.5f, int2(2, 3), 2.5f, status); + +// CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad {{.*}} %tex2dArray +// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[load_arr1]] [[v3fc]] %float_1 Bias|ConstOffset %float_0_5 [[v2ic]] + float val4 = tex2dArray.SampleCmpBias(float3(0.5, 0.25, 0), 1.0f, 0.5f, int2(2, 3)); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl index 4acca8a42e..efec4730cb 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl @@ -8,32 +8,33 @@ // CHECK: [[v2f_2:%[0-9]+]] = OpConstantComposite %v2float %float_2 %float_2 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1_load]] [[v2fc]] %float_1 Grad [[v2f_1]] [[v2f_2]] - float val1 = tex1.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2)); + float val1 = tex2d.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2)); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex2_load]] [[v2fc]] %float_1 Grad|ConstOffset [[v2f_1]] [[v2f_2]] [[v2ic]] - float val2 = tex1.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2), int2(2,3)); + float val2 = tex2d.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2), int2(2,3)); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex3_load]] [[v2fc]] %float_1 Grad|ConstOffset|MinLod [[v2f_1]] [[v2f_2]] [[v2ic]] %float_0_5 - float val3 = tex1.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2), int2(2,3), 0.5); + float val3 = tex2d.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2), int2(2,3), 0.5); -// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefExplicitLod %SparseResidencyStruct [[tex4_load]] [[v2fc]] %float_1 Grad|ConstOffset|MinLod [[v2f_1]] [[v2f_2]] [[v2ic]] %float_0_5 // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result4]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float val4 = tex1.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2), int2(2,3), 0.5, status); + float val4 = tex2d.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2), int2(2,3), 0.5, status); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl index b7475a7fca..39b525b888 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl @@ -4,29 +4,35 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1_load]] [[v2fc]] %float_2 Lod %float_0 - float val1 = tex1.SampleCmpLevelZero(float2(0.5, 0.25), 2.0f); + float val1 = tex2d.SampleCmpLevelZero(float2(0.5, 0.25), 2.0f); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex2_load]] [[v2fc]] %float_2 Lod|ConstOffset %float_0 [[v2ic]] - float val2 = tex1.SampleCmpLevelZero(float2(0.5, 0.25), 2.0f, int2(2,3)); + float val2 = tex2d.SampleCmpLevelZero(float2(0.5, 0.25), 2.0f, int2(2,3)); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefExplicitLod %SparseResidencyStruct [[tex3_load]] [[v2fc]] %float_2 Lod|ConstOffset %float_0 [[v2ic]] // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result3]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float val3 = tex1.SampleCmpLevelZero(float2(0.5, 0.25), 2.0f, int2(2,3), status); + float val3 = tex2d.SampleCmpLevelZero(float2(0.5, 0.25), 2.0f, int2(2,3), status); + +// CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[load_arr1]] [[v3fc]] %float_2 Lod %float_0 + float val4 = tex2dArray.SampleCmpLevelZero(float3(0.5, 0.25, 0), 2.0f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl index 3fc5798b09..8d6da78479 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl @@ -5,33 +5,38 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex1_load]] [[v2fc]] %float_2 - float val1 = tex1.SampleCmp(float2(0.5, 0.25), 2.0f); + float val1 = tex2d.SampleCmp(float2(0.5, 0.25), 2.0f); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex2_load]] [[v2fc]] %float_2 ConstOffset [[v2ic]] - float val2 = tex1.SampleCmp(float2(0.5, 0.25), 2.0f, int2(2,3)); + float val2 = tex2d.SampleCmp(float2(0.5, 0.25), 2.0f, int2(2,3)); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex3_load]] [[v2fc]] %float_2 ConstOffset|MinLod [[v2ic]] %float_0_5 - float val3 = tex1.SampleCmp(float2(0.5, 0.25), 2.0f, int2(2,3), 0.5); + float val3 = tex2d.SampleCmp(float2(0.5, 0.25), 2.0f, int2(2,3), 0.5); -// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleDrefImplicitLod %SparseResidencyStruct [[tex4_load]] [[v2fc]] %float_2 ConstOffset|MinLod [[v2ic]] %float_0_5 // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result4]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float val4 = tex1.SampleCmp(float2(0.5, 0.25), 2.0f, int2(2,3), 0.5, status); - return 1.0; + float val4 = tex2d.SampleCmp(float2(0.5, 0.25), 2.0f, int2(2,3), 0.5, status); + +// CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[load_arr1]] [[v3fc]] %float_2 + float val5 = tex2dArray.SampleCmp(float3(0.5, 0.25, 0), 2.0f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl index 829e148c02..94bb03e7e4 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl @@ -7,32 +7,39 @@ // CHECK: [[v2f_1:%[0-9]+]] = OpConstantComposite %v2float %float_1 %float_1 // CHECK: [[v2f_2:%[0-9]+]] = OpConstantComposite %v2float %float_2 %float_2 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1_load]] [[v2fc]] Grad [[v2f_1]] [[v2f_2]] - float4 val1 = tex1.SampleGrad(float2(0.5, 0.25), float2(1, 1), float2(2, 2)); + float4 val1 = tex2d.SampleGrad(float2(0.5, 0.25), float2(1, 1), float2(2, 2)); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex2_load]] [[v2fc]] Grad|ConstOffset [[v2f_1]] [[v2f_2]] [[v2ic]] - float4 val2 = tex1.SampleGrad(float2(0.5, 0.25), float2(1, 1), float2(2, 2), int2(2,3)); + float4 val2 = tex2d.SampleGrad(float2(0.5, 0.25), float2(1, 1), float2(2, 2), int2(2,3)); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex3_load]] [[v2fc]] Grad|ConstOffset|MinLod [[v2f_1]] [[v2f_2]] [[v2ic]] %float_0_5 - float4 val3 = tex1.SampleGrad(float2(0.5, 0.25), float2(1, 1), float2(2, 2), int2(2,3), 0.5); -// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] + float4 val3 = tex2d.SampleGrad(float2(0.5, 0.25), float2(1, 1), float2(2, 2), int2(2,3), 0.5); + +// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleExplicitLod %SparseResidencyStruct [[tex4_load]] [[v2fc]] Grad|ConstOffset|MinLod [[v2f_1]] [[v2f_2]] [[v2ic]] %float_0_5 // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result4]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float4 val4 = tex1.SampleGrad(float2(0.5, 0.25), float2(1, 1), float2(2, 2), int2(2,3), 0.5, status); + float4 val4 = tex2d.SampleGrad(float2(0.5, 0.25), float2(1, 1), float2(2, 2), int2(2,3), 0.5, status); + +// CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[load_arr1]] [[v3fc]] Grad [[v2f_1]] [[v2f_2]] + float4 val5 = tex2dArray.SampleGrad(float3(0.5, 0.25, 0), float2(1, 1), float2(2, 2)); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl index a0c885b9ed..ee10dc3878 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl @@ -4,29 +4,35 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); +vk::SampledTexture2D tex2d; +vk::SampledTexture2DArray tex2dArray; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] -// CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1_load]] [[v2fc]] Lod|ConstOffset %float_0_5 [[v2ic]] - float4 val1 = tex1.SampleLevel(float2(0.5, 0.25), 0.5f, int2(2, 3)); +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d +// CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1_load]] [[v2fc]] Lod %float_0_5 + float4 val1 = tex2d.SampleLevel(float2(0.5, 0.25), 0.5f); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex2_load]] [[v2fc]] Lod|ConstOffset %float_0_5 [[v2ic]] - float4 val2 = tex1.SampleLevel(float2(0.5, 0.25), 0.5f, int2(2, 3)); + float4 val2 = tex2d.SampleLevel(float2(0.5, 0.25), 0.5f, int2(2, 3)); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSparseSampleExplicitLod %SparseResidencyStruct [[tex3_load]] [[v2fc]] Lod|ConstOffset %float_0_5 [[v2ic]] // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result3]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float4 val3 = tex1.SampleLevel(float2(0.5, 0.25), 0.5f, int2(2, 3), status); + float4 val3 = tex2d.SampleLevel(float2(0.5, 0.25), 0.5f, int2(2, 3), status); + +// CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[load_arr1]] [[v3fc]] Lod %float_0_5 + float4 val4 = tex2dArray.SampleLevel(float3(0.5, 0.25, 0), 0.5f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl index ee4051f45c..2d1654d30e 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl @@ -5,46 +5,48 @@ // CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 -// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]] -// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]] +// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] +// CHECK: [[type_2d_image_uint:%[a-zA-Z0-9_]+]] = OpTypeImage %uint 2D 0 0 0 1 Unknown +// CHECK: [[type_2d_sampled_image_uint:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_uint]] +// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown +// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] -// CHECK: [[type_2d_image_2:%[a-zA-Z0-9_]+]] = OpTypeImage %uint 2D 0 0 0 1 Unknown -// CHECK: [[type_sampled_image_2:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_2]] -// CHECK: [[ptr_type_2:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_2]] - -// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant -// CHECK: [[tex2:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant -// CHECK: [[tex3:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_2]] UniformConstant - -vk::SampledTexture2D tex1 : register(t0); -vk::SampledTexture2D tex2 : register(t1); -vk::SampledTexture2D tex3 : register(t2); +vk::SampledTexture2D tex2df4; +vk::SampledTexture2D tex2duint; +vk::SampledTexture2DArray tex2dArray; +vk::SampledTexture2D tex2d_default; float4 main() : SV_Target { -// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]] +// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2df4 // CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex1_load]] [[v2fc]] None - float4 val1 = tex1.Sample(float2(0.5, 0.25)); + float4 val1 = tex2df4.Sample(float2(0.5, 0.25)); -// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex2]] +// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d_default // CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex2_load]] [[v2fc]] ConstOffset [[v2ic]] - float4 val2 = tex2.Sample(float2(0.5, 0.25), int2(2, 3)); + float4 val2 = tex2d_default.Sample(float2(0.5, 0.25), int2(2, 3)); -// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex2]] +// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2df4 // CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex3_load]] [[v2fc]] ConstOffset|MinLod [[v2ic]] %float_1 - float4 val3 = tex2.Sample(float2(0.5, 0.25), int2(2, 3), 1.0f); + float4 val3 = tex2df4.Sample(float2(0.5, 0.25), int2(2, 3), 1.0f); -// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex2]] +// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2df4 // CHECK: [[sampled_result4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[tex4_load]] [[v2fc]] ConstOffset|MinLod [[v2ic]] %float_1 // CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result4]] 0 // CHECK: OpStore %status [[status_0]] uint status; - float4 val4 = tex2.Sample(float2(0.5, 0.25), int2(2, 3), 1.0f, status); + float4 val4 = tex2df4.Sample(float2(0.5, 0.25), int2(2, 3), 1.0f, status); -// CHECK: [[tex5_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_2]] [[tex3]] +// CHECK: [[tex5_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_uint]] %tex2duint // CHECK: [[sampled_result5:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4uint [[tex5_load]] [[v2fc]] None // CHECK: [[val5:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result5]] 0 - uint val5 = tex3.Sample(float2(0.5, 0.25)); + uint val5 = tex2duint.Sample(float2(0.5, 0.25)); + +// CHECK: [[texArr_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray +// CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[texArr_load]] [[v3fc]] None + float4 val6 = tex2dArray.Sample(float3(0.5, 0.25, 0)); + return 1.0; } diff --git a/utils/hct/gen_intrin_main.txt b/utils/hct/gen_intrin_main.txt index b37b1fb7e3..59e4c9382f 100644 --- a/utils/hct/gen_intrin_main.txt +++ b/utils/hct/gen_intrin_main.txt @@ -1318,3 +1318,99 @@ namespace VkSampledTexture2DMethods { $match<0, -1> void<4> [[]] GatherCmpBlue(in float<2> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_comp_blue_o4_s; $match<0, -1> void<4> [[]] GatherCmpAlpha(in float<2> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_comp_alpha_o4_s; } namespace + + +namespace VkSampledTexture2DArrayMethods { + float [[ro]] CalculateLevelOfDetail(in float<2> x) : tex2d_t_calc_lod_array; + float [[ro]] CalculateLevelOfDetailUnclamped(in float<2> x) : tex2d_t_calc_lod_unclamped_array; + $match<0, -1> void<4> [[ro]] Gather(in float<3> x) : tex2d_t_gather_array; + $match<0, -1> void<4> [[ro]] Gather(in float<3> x, in int<2> o) : tex2d_t_gather_array_o; + $match<0, -1> void<4> [[ro]] GatherAlpha(in float<3> x) : tex2d_t_gather_alpha_array; + $match<0, -1> void<4> [[ro]] GatherAlpha(in float<3> x, in int<2> o) : tex2d_t_gather_alpha_array_o; + $match<0, -1> void<4> [[ro]] GatherAlpha(in float<3> x, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4) : tex2d_t_gather_alpha_array_o4; + $match<0, -1> void<4> [[ro]] GatherBlue(in float<3> x) : tex2d_t_gather_blue_array; + $match<0, -1> void<4> [[ro]] GatherBlue(in float<3> x, in int<2> o) : tex2d_t_gather_blue_array_o; + $match<0, -1> void<4> [[ro]] GatherBlue(in float<3> x, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4) : tex2d_t_gather_blue_array_o4; + $match<0, -1> void<4> [[ro]] GatherCmp(in float<3> x, in float compareValue) : tex2d_t_gather_comp_array; + $match<0, -1> void<4> [[ro]] GatherCmp(in float<3> x, in float compareValue, in int<2> o) : tex2d_t_gather_comp_array_o; + $match<0, -1> void<4> [[ro]] GatherCmpAlpha(in float<3> x, in float compareValue) : tex2d_t_gather_comp_alpha_array; + $match<0, -1> void<4> [[ro]] GatherCmpAlpha(in float<3> x, in float compareValue, in int<2> o) : tex2d_t_gather_comp_alpha_array_o; + $match<0, -1> void<4> [[ro]] GatherCmpAlpha(in float<3> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4) : tex2d_t_gather_comp_alpha_array_o4; + $match<0, -1> void<4> [[ro]] GatherCmpBlue(in float<3> x, in float compareValue) : tex2d_t_gather_comp_blue_array; + $match<0, -1> void<4> [[ro]] GatherCmpBlue(in float<3> x, in float compareValue, in int<2> o) : tex2d_t_gather_comp_blue_array_o; + $match<0, -1> void<4> [[ro]] GatherCmpBlue(in float<3> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4) : tex2d_t_gather_comp_blue_array_o4; + $match<0, -1> void<4> [[ro]] GatherCmpGreen(in float<3> x, in float compareValue) : tex2d_t_gather_comp_green_array; + $match<0, -1> void<4> [[ro]] GatherCmpGreen(in float<3> x, in float compareValue, in int<2> o) : tex2d_t_gather_comp_green_array_o; + $match<0, -1> void<4> [[ro]] GatherCmpGreen(in float<3> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4) : tex2d_t_gather_comp_green_array_o4; + $match<0, -1> void<4> [[ro]] GatherCmpRed(in float<3> x, in float compareValue) : tex2d_t_gather_comp_red_array; + $match<0, -1> void<4> [[ro]] GatherCmpRed(in float<3> x, in float compareValue, in int<2> o) : tex2d_t_gather_comp_red_array_o; + $match<0, -1> void<4> [[ro]] GatherCmpRed(in float<3> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4) : tex2d_t_gather_comp_red_array_o4; + $match<0, -1> void<4> [[ro]] GatherGreen(in float<3> x) : tex2d_t_gather_green_array; + $match<0, -1> void<4> [[ro]] GatherGreen(in float<3> x, in int<2> o) : tex2d_t_gather_green_array_o; + $match<0, -1> void<4> [[ro]] GatherGreen(in float<3> x, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4) : tex2d_t_gather_green_array_o4; + $match<0, -1> void<4> [[ro]] GatherRed(in float<3> x) : tex2d_t_gather_red_array; + $match<0, -1> void<4> [[ro]] GatherRed(in float<3> x, in int<2> o) : tex2d_t_gather_red_array_o; + $match<0, -1> void<4> [[ro]] GatherRed(in float<3> x, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4) : tex2d_t_gather_red_array_o4; + void [[]] GetDimensions(in uint x, out uint_only width, out $type2 height, out $type2 elements, out $type2 levels) : resinfo_uint; + void [[]] GetDimensions(in uint x, out float_like width, out $type2 height, out $type2 elements, out $type2 levels) : resinfo; + void [[]] GetDimensions(out uint_only width, out $type1 height, out $type1 elements) : resinfo_uint_o; + void [[]] GetDimensions(out float_like width, out $type1 height, out $type1 elements) : resinfo_o; + $classT [[ro]] Load(in int<4> x) : tex2d_t_load_array; + $classT [[ro]] Load(in int<4> x, in int<2> o) : tex2d_t_load_array_o; + $classT [[]] Load(in int<4> x, in int<2> o, out uint_only status) : tex2d_t_load_array_o_s; + $classT [[ro]] Sample(in float<3> x) : tex2d_t_array; + $classT [[ro]] Sample(in float<3> x, in int<2> o) : tex2d_t_array_o; + $classT [[ro]] SampleBias(in float<3> x, in float bias) : tex2d_t_bias_array; + $classT [[ro]] SampleBias(in float<3> x, in float bias, in int<2> o) : tex2d_t_bias_array_o; + float_like [[ro]] SampleCmp(in float<3> x, in float compareValue) : tex2d_t_comp_array; + float_like [[ro]] SampleCmp(in float<3> x, in float compareValue, in int<2> o) : tex2d_t_comp_array_o; + float_like [[ro]] SampleCmpBias(in float<3> x, in float compareValue, in float bias) : tex2d_t_comp_bias_array; + float_like [[ro]] SampleCmpBias(in float<3> x, in float compareValue, in float bias, in int<2> o) : tex2d_t_comp_bias_array_o; + float_like [[ro]] SampleCmpGrad(in float<3> x, in float compareValue, in $match<2, 2> float<2> ddx, in $match<2, 2> float<2> ddy) : tex2d_t_comp_dd_array; + float_like [[ro]] SampleCmpGrad(in float<3> x, in float compareValue, in $match<2, 2> float<2> ddx, in $match<2, 2> float<2> ddy, in int<2> o) : tex2d_t_comp_dd_array_o; + float_like [[ro]] SampleCmpLevel(in float<3> x, in float compareValue, in float lod); + float_like [[ro]] SampleCmpLevel(in float<3> x, in float compareValue, in float lod, in int<2> o); + float_like [[ro]] SampleCmpLevelZero(in float<3> x, in float compareValue) : tex2d_t_comp_lz_array; + float_like [[ro]] SampleCmpLevelZero(in float<3> x, in float compareValue, in int<2> o) : tex2d_t_comp_lz_array_o; + $classT [[ro]] SampleGrad(in float<3> x, in $match<2, 2> float<2> ddx, in $match<2, 2> float<2> ddy) : tex2d_t_dd_array; + $classT [[ro]] SampleGrad(in float<3> x, in $match<2, 2> float<2> ddx, in $match<2, 2> float<2> ddy, in int<2> o) : tex2d_t_dd_array_o; + $classT [[ro]] SampleLevel(in float<3> x, in float lod) : tex2d_t_lod_array; + $classT [[ro]] SampleLevel(in float<3> x, in float lod, in int<2> o) : tex2d_t_lod_array_o; + $classT [[ro]] Sample(in float<3> x, in int<2> o, in float clamp) : tex2d_t_array_o_cl; + $classT [[]] Sample(in float<3> x, in int<2> o, in float clamp, out uint_only status) : tex2d_t_array_o_cl_s; + float_like [[ro]] SampleCmp(in float<3> x, in float compareValue, in int<2> o, in float clamp) : tex2d_t_comp_array_o_cl; + float_like [[]] SampleCmp(in float<3> x, in float compareValue, in int<2> o, in float clamp, out uint_only status) : tex2d_t_comp_array_o_cl_s; + float_like [[ro]] SampleCmpBias(in float<3> x, in float compareValue, in float bias, in int<2> o, in float clamp) : tex2d_t_comp_bias_array_o_cl; + float_like [[]] SampleCmpBias(in float<3> x, in float compareValue, in float bias, in int<2> o, in float clamp, out uint_only status) : tex2d_t_comp_bias_array_o_cl_s; + float_like [[ro]] SampleCmpGrad(in float<3> x, in float compareValue, in $match<2, 2> float<2> ddx, in $match<2, 2> float<2> ddy, in int<2> o, in float clamp) : tex2d_t_comp_dd_array_o_cl; + float_like [[]] SampleCmpGrad(in float<3> x, in float compareValue, in $match<2, 2> float<2> ddx, in $match<2, 2> float<2> ddy, in int<2> o, in float clamp, out uint_only status) : tex2d_t_comp_dd_array_o_cl_s; + float_like [[]] SampleCmpLevel(in float<3> x, in float compareValue, in float lod, in int<2> o, out uint_only status); + float_like [[]] SampleCmpLevelZero(in float<3> x, in float compareValue, in int<2> o, out uint_only status) : tex2d_t_comp_array_o_s; + $classT [[]] SampleLevel(in float<3> x, in float lod, in int<2> o, out uint_only status) : tex2d_t_lod_array_o_s; + $classT [[ro]] SampleBias(in float<3> x, in float bias, in int<2> o, in float clamp) : tex2d_t_bias_array_o_cl; + $classT [[]] SampleBias(in float<3> x, in float bias, in int<2> o, in float clamp, out uint_only status) : tex2d_t_bias_array_o_cl_s; + $classT [[ro]] SampleGrad(in float<3> x, in $match<2, 2> float<2> ddx, in $match<2, 2> float<2> ddy, in int<2> o, in float clamp) : tex2d_t_dd_array_o_cl; + $classT [[]] SampleGrad(in float<3> x, in $match<2, 2> float<2> ddx, in $match<2, 2> float<2> ddy, in int<2> o, in float clamp, out uint_only status) : tex2d_t_dd_array_o_cl_s; + $match<0, -1> void<4> [[]] Gather(in float<3> x, in int<2> o, out uint_only status) : tex2d_t_gather_array_o_s; + $match<0, -1> void<4> [[]] GatherRed(in float<3> x, in int<2> o, out uint_only status) : tex2d_t_gather_red_array_o_s; + $match<0, -1> void<4> [[]] GatherRed(in float<3> x, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_red_array_o4_s; + $match<0, -1> void<4> [[]] GatherGreen(in float<3> x, in int<2> o, out uint_only status) : tex2d_t_gather_green_array_o_s; + $match<0, -1> void<4> [[]] GatherGreen(in float<3> x, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_green_array_o4_s; + $match<0, -1> void<4> [[]] GatherBlue(in float<3> x, in int<2> o, out uint_only status) : tex2d_t_gather_blue_array_o_s; + $match<0, -1> void<4> [[]] GatherBlue(in float<3> x, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_blue_array_o4_s; + $match<0, -1> void<4> [[]] GatherAlpha(in float<3> x, in int<2> o, out uint_only status) : tex2d_t_gather_alpha_array_o_s; + $match<0, -1> void<4> [[]] GatherAlpha(in float<3> x, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_alpha_array_o4_s; + $match<0, -1> void<4> [[]] GatherCmp(in float<3> x, in float compareValue, in int<2> o, out uint_only status) : tex2d_t_gather_comp_array_o_s; + $match<0, -1> void<4> [[]] GatherCmpRed(in float<3> x, in float compareValue, in int<2> o, out uint_only status) : tex2d_t_gather_comp_red_array_o_s; + $match<0, -1> void<4> [[]] GatherCmpGreen(in float<3> x, in float compareValue, in int<2> o, out uint_only status) : tex2d_t_gather_comp_green_array_o_s; + $match<0, -1> void<4> [[]] GatherCmpBlue(in float<3> x, in float compareValue, in int<2> o, out uint_only status) : tex2d_t_gather_comp_blue_array_o_s; + $match<0, -1> void<4> [[]] GatherCmpAlpha(in float<3> x, in float compareValue, in int<2> o, out uint_only status) : tex2d_t_gather_comp_alpha_array_o_s; + $match<0, -1> void<4> [[]] GatherCmpRed(in float<3> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_comp_red_array_o4_s; + $match<0, -1> void<4> [[]] GatherCmpGreen(in float<3> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_comp_green_array_o4_s; + $match<0, -1> void<4> [[]] GatherCmpBlue(in float<3> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_comp_blue_array_o4_s; + $match<0, -1> void<4> [[]] GatherCmpAlpha(in float<3> x, in float compareValue, in int<2> o1, in int<2> o2, in int<2> o3, in int<2> o4, out uint_only status) : tex2d_t_gather_comp_alpha_array_o4_s; + $match<0, -1> void<4> [[ro]] GatherRaw(in float<3> x); + $match<0, -1> void<4> [[ro]] GatherRaw(in float<3> x, in int<2> o); + $match<0, -1> void<4> [[]] GatherRaw(in float<3> x, in int<2> o, out uint_only status); +} namespace + diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 2675ab5c5c..71f035e059 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -9651,7 +9651,7 @@ def load_intrinsics(self, intrinsic_defs): acceleration_struct | ray_desc | RayQuery | DxHitObject | Node\w* | RWNode\w* | EmptyNode\w* | AnyNodeOutput\w* | NodeOutputRecord\w* | GroupShared\w* | - VkBufferPointer | LinAlgMatrix | VkSampledTexture2D + VkBufferPointer | LinAlgMatrix | VkSampledTexture2D | VkSampledTexture2DArray $)""", flags=re.VERBOSE, ) From 92e04d102df40d5d33ea7f9d6e031154bb124fc8 Mon Sep 17 00:00:00 2001 From: luciechoi Date: Wed, 4 Mar 2026 19:40:30 +0000 Subject: [PATCH 2/4] Address copilot comments --- tools/clang/lib/Sema/SemaHLSL.cpp | 2 ++ .../test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl | 2 +- tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index c1e21872f3..1ab813afb0 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -5074,7 +5074,9 @@ class HLSLExternalSource : public ExternalSemaSource { ResClass = DXIL::ResourceClass::UAV; return true; case AR_OBJECT_TEXTURE2D_ARRAY: +#ifdef ENABLE_SPIRV_CODEGEN case AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY: +#endif ResKind = DXIL::ResourceKind::Texture2DArray; ResClass = DXIL::ResourceClass::SRV; return true; diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl index 33dc2e9561..fb7fff01f1 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl @@ -48,7 +48,7 @@ void main() { tex2dArray.GetDimensions(width, height, elements); // CHECK: [[t2_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray -// CHECK-NEXT: [[image4:%[0-9]+]] = OpImage %type_2d_image_array [[t2_load]] +// CHECK-NEXT: [[image4:%[0-9]+]] = OpImage [[type_2d_image_array]] [[t2_load]] // CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel // CHECK-NEXT: [[query4:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image4]] [[mip]] // CHECK-NEXT: [[query4_0:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 0 diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl index a5e085cb00..930b4a96f4 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl @@ -17,7 +17,7 @@ float4 main(int3 location3: A, int4 location4: B) : SV_Target { // CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v2int [[loc]] [[loc]] 0 1 // CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 2 // CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d -// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage %type_2d_image [[tex]] +// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image]] [[tex]] // CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod [[lod_0]] float4 val1 = tex2d.Load(location3); @@ -25,7 +25,7 @@ float4 main(int3 location3: A, int4 location4: B) : SV_Target { // CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v2int [[loc]] [[loc]] 0 1 // CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 2 // CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d -// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage %type_2d_image [[tex]] +// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image]] [[tex]] // CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod|ConstOffset [[lod_0]] [[v2ic]] float4 val2 = tex2d.Load(location3, int2(1, 2)); @@ -37,7 +37,7 @@ float4 main(int3 location3: A, int4 location4: B) : SV_Target { // CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v2int [[loc]] [[loc]] 0 1 // CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[loc]] 2 // CHECK-NEXT: [[tex:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d -// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage %type_2d_image [[tex]] +// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image]] [[tex]] // CHECK-NEXT:[[structResult:%[0-9]+]] = OpImageSparseFetch %SparseResidencyStruct [[tex_img]] [[coord_0]] Lod|ConstOffset [[lod_0]] [[v2ic]] // CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0 // CHECK-NEXT: OpStore %status [[status]] From d2a72785c2bcec403f28cb8abc8a0a43a588b913 Mon Sep 17 00:00:00 2001 From: luciechoi Date: Thu, 26 Feb 2026 23:16:58 +0000 Subject: [PATCH 3/4] SampledTexture2DMS, SampledTexture2DMSArray --- include/dxc/dxcapi.internal.h | 4 +- .../clang/include/clang/SPIRV/AstTypeProbe.h | 4 + tools/clang/lib/SPIRV/AstTypeProbe.cpp | 12 +- tools/clang/lib/SPIRV/LowerTypeVisitor.cpp | 12 +- tools/clang/lib/SPIRV/SpirvEmitter.cpp | 22 ++- tools/clang/lib/Sema/SemaHLSL.cpp | 43 +++++- .../vk.sampledtexture.get-dimensions.hlsl | 32 ++++- ...vk.sampledtexture.get-sample-position.hlsl | 130 ++++++++++++++++++ .../CodeGenSPIRV/vk.sampledtexture.load.hlsl | 24 ++++ .../vk.sampledtexture.sample-access.hlsl | 29 ++++ utils/hct/gen_intrin_main.txt | 18 +++ 11 files changed, 314 insertions(+), 16 deletions(-) create mode 100644 tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-sample-position.hlsl create mode 100644 tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-access.hlsl diff --git a/include/dxc/dxcapi.internal.h b/include/dxc/dxcapi.internal.h index ca4b892748..80c218ed0d 100644 --- a/include/dxc/dxcapi.internal.h +++ b/include/dxc/dxcapi.internal.h @@ -142,7 +142,9 @@ enum LEGAL_INTRINSIC_COMPTYPES { LICOMPTYPE_VK_BUFFER_POINTER = 56, LICOMPTYPE_VK_SAMPLED_TEXTURE2D = 57, LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY = 58, - LICOMPTYPE_COUNT = 59 + LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS = 59, + LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS_ARRAY = 60, + LICOMPTYPE_COUNT = 61 #else LICOMPTYPE_COUNT = 56 #endif diff --git a/tools/clang/include/clang/SPIRV/AstTypeProbe.h b/tools/clang/include/clang/SPIRV/AstTypeProbe.h index 1479075f12..214df82d45 100644 --- a/tools/clang/include/clang/SPIRV/AstTypeProbe.h +++ b/tools/clang/include/clang/SPIRV/AstTypeProbe.h @@ -257,6 +257,10 @@ bool isTexture(QualType); /// Texture2DMSArray type. bool isTextureMS(QualType); +/// \brief Returns true if the given type is an HLSL SampledTexture2DMS or +/// SampledTexture2DMSArray type. +bool isSampledTextureMS(QualType); + /// \brief Returns true if the given type is an HLSL SampledTexture type. bool isSampledTexture(QualType); diff --git a/tools/clang/lib/SPIRV/AstTypeProbe.cpp b/tools/clang/lib/SPIRV/AstTypeProbe.cpp index 6833b443f9..ea92107890 100644 --- a/tools/clang/lib/SPIRV/AstTypeProbe.cpp +++ b/tools/clang/lib/SPIRV/AstTypeProbe.cpp @@ -931,7 +931,8 @@ bool isSampledTexture(QualType type) { const auto name = rt->getDecl()->getName(); // TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Add // other sampled texture types as needed. - if (name == "SampledTexture2D" || name == "SampledTexture2DArray") + if (name == "SampledTexture2D" || name == "SampledTexture2DArray" || + name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") return true; } return false; @@ -946,6 +947,15 @@ bool isTextureMS(QualType type) { return false; } +bool isSampledTextureMS(QualType type) { + if (const auto *rt = type->getAs()) { + const auto name = rt->getDecl()->getName(); + if (name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") + return true; + } + return false; +} + bool isSampler(QualType type) { if (const auto *rt = type->getAs()) { const auto name = rt->getDecl()->getName(); diff --git a/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp b/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp index f057507834..907cc0655f 100644 --- a/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp +++ b/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp @@ -849,7 +849,8 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace( assert(visitedTypeStack.size() == visitedTypeStackSize); return pointerType; } - if (name == "SampledTexture2D" || name == "SampledTexture2DArray") { + if (name == "SampledTexture2D" || name == "SampledTexture2DArray" || + name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") { const auto sampledType = hlsl::GetHLSLResourceResultType(type); auto loweredType = lowerType(getElementType(astContext, sampledType), rule, /*isRowMajor*/ llvm::None, srcLoc); @@ -860,11 +861,14 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace( loweredType = spvContext.getUIntType(32); } - const bool isArray = (name == "SampledTexture2DArray"); + const bool isArray = + (name == "SampledTexture2DArray" || name == "SampledTexture2DMSArray"); + const bool isMS = + (name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray"); const auto *imageType = spvContext.getImageType( - loweredType, spv::Dim::Dim2D, ImageType::WithDepth::No, isArray, - false /* ms */, ImageType::WithSampler::Yes, spv::ImageFormat::Unknown); + loweredType, spv::Dim::Dim2D, ImageType::WithDepth::No, isArray, isMS, + ImageType::WithSampler::Yes, spv::ImageFormat::Unknown); return spvContext.getSampledImageType(imageType); } emitError("unknown type %0 in vk namespace", srcLoc) << type; diff --git a/tools/clang/lib/SPIRV/SpirvEmitter.cpp b/tools/clang/lib/SPIRV/SpirvEmitter.cpp index 7eedd5de99..2f61757df7 100644 --- a/tools/clang/lib/SPIRV/SpirvEmitter.cpp +++ b/tools/clang/lib/SPIRV/SpirvEmitter.cpp @@ -4283,9 +4283,21 @@ SpirvInstruction *SpirvEmitter::processRWByteAddressBufferAtomicMethods( SpirvInstruction * SpirvEmitter::processGetSamplePosition(const CXXMemberCallExpr *expr) { const auto *object = expr->getImplicitObjectArgument()->IgnoreParens(); + auto *objectInstr = loadIfGLValue(object); + if (isSampledTexture(object->getType())) { + LowerTypeVisitor lowerTypeVisitor(astContext, spvContext, spirvOptions, + spvBuilder); + const SpirvType *spvType = + lowerTypeVisitor.lowerType(object->getType(), SpirvLayoutRule::Void, + llvm::None, expr->getExprLoc()); + const auto *sampledType = cast(spvType); + const SpirvType *imgType = sampledType->getImageType(); + objectInstr = spvBuilder.createUnaryOp(spv::Op::OpImage, imgType, + objectInstr, expr->getExprLoc()); + } auto *sampleCount = spvBuilder.createImageQuery( spv::Op::OpImageQuerySamples, astContext.UnsignedIntTy, - expr->getExprLoc(), loadIfGLValue(object)); + expr->getExprLoc(), objectInstr); if (!spirvOptions.noWarnEmulatedFeatures) emitWarning("GetSamplePosition is emulated using many SPIR-V instructions " "due to lack of direct SPIR-V equivalent, so it only supports " @@ -4403,7 +4415,8 @@ SpirvEmitter::processBufferTextureGetDimensions(const CXXMemberCallExpr *expr) { mipLevel = expr->getArg(0); numLevels = expr->getArg(numArgs - 1); } - if (isTextureMS(type)) { + + if (isSampledTextureMS(type) || isTextureMS(type)) { numSamples = expr->getArg(numArgs - 1); } @@ -4744,7 +4757,7 @@ SpirvInstruction *SpirvEmitter::processBufferTextureLoad( // For Texture2DMS and Texture2DMSArray, Sample must be used rather than Lod. SpirvInstruction *sampleNumber = nullptr; - if (isTextureMS(type) || isSubpassInputMS(type)) { + if (isSampledTextureMS(type) || isTextureMS(type) || isSubpassInputMS(type)) { sampleNumber = lod; lod = nullptr; } @@ -6509,7 +6522,8 @@ SpirvEmitter::processBufferTextureLoad(const CXXMemberCallExpr *expr) { const auto numArgs = expr->getNumArgs(); const auto *locationArg = expr->getArg(0); - const bool textureMS = isTextureMS(objectType); + const bool textureMS = + isTextureMS(objectType) || isSampledTextureMS(objectType); const bool hasStatusArg = expr->getArg(numArgs - 1)->getType()->isUnsignedIntegerType(); auto *status = hasStatusArg ? doExpr(expr->getArg(numArgs - 1)) : nullptr; diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index 1ab813afb0..f04b54db89 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -202,6 +202,8 @@ enum ArBasicKind { AR_OBJECT_VK_BUFFER_POINTER, AR_OBJECT_VK_SAMPLED_TEXTURE2D, AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, + AR_OBJECT_VK_SAMPLED_TEXTURE2DMS, + AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY, #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -564,6 +566,8 @@ const UINT g_uBasicKindProps[] = { BPROP_OBJECT, // AR_OBJECT_VK_BUFFER_POINTER use recordType BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY + BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS + BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -1276,6 +1280,10 @@ static const ArBasicKind g_VKSampledTexture2DCT[] = { AR_OBJECT_VK_SAMPLED_TEXTURE2D, AR_BASIC_UNKNOWN}; static const ArBasicKind g_VKSampledTexture2DArrayCT[] = { AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, AR_BASIC_UNKNOWN}; +static const ArBasicKind g_VKSampledTexture2DMSCT[] = { + AR_OBJECT_VK_SAMPLED_TEXTURE2DMS, AR_BASIC_UNKNOWN}; +static const ArBasicKind g_VKSampledTexture2DMSArrayCT[] = { + AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY, AR_BASIC_UNKNOWN}; #endif // Basic kinds, indexed by a LEGAL_INTRINSIC_COMPTYPES value. @@ -1338,9 +1346,11 @@ const ArBasicKind *g_LegalIntrinsicCompTypes[] = { g_LinAlgCT, // LICOMPTYPE_LINALG g_BuiltInTrianglePositionsCT, // LICOMPTYPE_BUILTIN_TRIANGLE_POSITIONS #ifdef ENABLE_SPIRV_CODEGEN - g_VKBufferPointerCT, // LICOMPTYPE_VK_BUFFER_POINTER - g_VKSampledTexture2DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D - g_VKSampledTexture2DArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY + g_VKBufferPointerCT, // LICOMPTYPE_VK_BUFFER_POINTER + g_VKSampledTexture2DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D + g_VKSampledTexture2DArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY + g_VKSampledTexture2DMSCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS + g_VKSampledTexture2DMSArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS_ARRAY #endif }; static_assert( @@ -1401,7 +1411,8 @@ static const ArBasicKind g_ArBasicKindsAsTypes[] = { AR_OBJECT_VK_INTEGRAL_CONSTANT, AR_OBJECT_VK_LITERAL, AR_OBJECT_VK_SPV_INTRINSIC_TYPE, AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID, AR_OBJECT_VK_BUFFER_POINTER, AR_OBJECT_VK_SAMPLED_TEXTURE2D, - AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, + AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURE2DMS, + AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY, #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -1515,6 +1526,8 @@ static const uint8_t g_ArBasicKindsTemplateCount[] = { 2, // AR_OBJECT_VK_BUFFER_POINTER 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY + 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS + 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -1670,6 +1683,8 @@ static const SubscriptOperatorRecord g_ArBasicKindsSubscripts[] = { {0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_BUFFER_POINTER {2, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D {3, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY + {2, MipsFalse, SampleTrue}, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS + {3, MipsFalse, SampleTrue}, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -1841,6 +1856,8 @@ static const char *g_ArBasicTypeNames[] = { "BufferPointer", "SampledTexture2D", "SampledTexture2DArray", + "SampledTexture2DMS", + "SampledTexture2DMSArray", #endif // ENABLE_SPIRV_CODEGEN // SPIRV change ends @@ -2502,6 +2519,14 @@ static void GetIntrinsicMethods(ArBasicKind kind, *intrinsics = g_VkSampledTexture2DArrayMethods; *intrinsicCount = _countof(g_VkSampledTexture2DArrayMethods); break; + case AR_OBJECT_VK_SAMPLED_TEXTURE2DMS: + *intrinsics = g_VkSampledTexture2DMSMethods; + *intrinsicCount = _countof(g_VkSampledTexture2DMSMethods); + break; + case AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY: + *intrinsics = g_VkSampledTexture2DMSArrayMethods; + *intrinsicCount = _countof(g_VkSampledTexture2DMSArrayMethods); + break; #endif case AR_OBJECT_HIT_OBJECT: *intrinsics = g_DxHitObjectMethods; @@ -4108,7 +4133,9 @@ class HLSLExternalSource : public ExternalSemaSource { recordDecl->setImplicit(true); m_vkBufferPointerTemplateDecl = recordDecl->getDescribedClassTemplate(); } else if (kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D || - kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY) { + kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY || + kind == AR_OBJECT_VK_SAMPLED_TEXTURE2DMS || + kind == AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY) { if (!m_vkNSDecl) continue; QualType float4Type = @@ -5103,6 +5130,9 @@ class HLSLExternalSource : public ExternalSemaSource { ResClass = DXIL::ResourceClass::SRV; return true; case AR_OBJECT_TEXTURE2DMS: +#ifdef ENABLE_SPIRV_CODEGEN + case AR_OBJECT_VK_SAMPLED_TEXTURE2DMS: +#endif ResKind = DXIL::ResourceKind::Texture2DMS; ResClass = DXIL::ResourceClass::SRV; return true; @@ -5111,6 +5141,9 @@ class HLSLExternalSource : public ExternalSemaSource { ResClass = DXIL::ResourceClass::UAV; return true; case AR_OBJECT_TEXTURE2DMS_ARRAY: +#ifdef ENABLE_SPIRV_CODEGEN + case AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY: +#endif ResKind = DXIL::ResourceKind::Texture2DMSArray; ResClass = DXIL::ResourceClass::SRV; return true; diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl index fb7fff01f1..f43e65c640 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl @@ -7,13 +7,19 @@ // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +// CHECK: [[type_2d_image_ms:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 1 1 Unknown +// CHECK: [[type_2d_sampled_image_ms:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms]] +// CHECK: [[type_2d_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 1 1 Unknown +// CHECK: [[type_2d_sampled_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms_array]] vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; +vk::SampledTexture2DMS tex2dMS; +vk::SampledTexture2DMSArray tex2dMSArray; void main() { uint mipLevel = 1; - uint width, height, numLevels, elements; + uint width, height, numLevels, elements, numSamples; // CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] @@ -61,6 +67,30 @@ void main() { // CHECK-NEXT: OpStore %numLevels [[query_level_4]] tex2dArray.GetDimensions(mipLevel, width, height, elements, numLevels); +// CHECK: [[t3_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image_ms]] %tex2dMS +// CHECK-NEXT: [[image5:%[0-9]+]] = OpImage [[type_2d_image_ms]] [[t3_load]] +// CHECK-NEXT: [[query5:%[0-9]+]] = OpImageQuerySize %v2uint [[image5]] +// CHECK-NEXT: [[query5_0:%[0-9]+]] = OpCompositeExtract %uint [[query5]] 0 +// CHECK-NEXT: OpStore %width [[query5_0]] +// CHECK-NEXT: [[query5_1:%[0-9]+]] = OpCompositeExtract %uint [[query5]] 1 +// CHECK-NEXT: OpStore %height [[query5_1]] +// CHECK-NEXT: [[query5_samples:%[0-9]+]] = OpImageQuerySamples %uint [[image5]] +// CHECK-NEXT: OpStore %numSamples [[query5_samples]] + tex2dMS.GetDimensions(width, height, numSamples); + +// CHECK: [[t4_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image_ms_array]] %tex2dMSArray +// CHECK-NEXT: [[image6:%[0-9]+]] = OpImage [[type_2d_image_ms_array]] [[t4_load]] +// CHECK-NEXT: [[query6:%[0-9]+]] = OpImageQuerySize %v3uint [[image6]] +// CHECK-NEXT: [[query6_0:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 0 +// CHECK-NEXT: OpStore %width [[query6_0]] +// CHECK-NEXT: [[query6_1:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 1 +// CHECK-NEXT: OpStore %height [[query6_1]] +// CHECK-NEXT: [[query6_2:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 2 +// CHECK-NEXT: OpStore %elements [[query6_2]] +// CHECK-NEXT: [[query6_samples:%[0-9]+]] = OpImageQuerySamples %uint [[image6]] +// CHECK-NEXT: OpStore %numSamples [[query6_samples]] + tex2dMSArray.GetDimensions(width, height, elements, numSamples); + float f_width, f_height, f_numLevels; // CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-sample-position.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-sample-position.hlsl new file mode 100644 index 0000000000..277ff069f8 --- /dev/null +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-sample-position.hlsl @@ -0,0 +1,130 @@ +// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s + +// CHECK-DAG: [[type_2d_image_ms:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 1 1 Unknown +// CHECK-DAG: [[type_2d_sampled_image_ms:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms]] +// CHECK-DAG: [[type_2d_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 1 1 Unknown +// CHECK-DAG: [[type_2d_sampled_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms_array]] + +// CHECK-DAG: [[pos2_0:%[0-9]+]] = OpConstantComposite %v2float %float_0_25 %float_0_25 +// CHECK-DAG: [[pos2_1:%[0-9]+]] = OpConstantComposite %v2float %float_n0_25 %float_n0_25 +// CHECK-DAG: [[pos2:%[0-9]+]] = OpConstantComposite %_arr_v2float_uint_2 [[pos2_0]] [[pos2_1]] + +// CHECK-DAG: [[pos4_0:%[0-9]+]] = OpConstantComposite %v2float %float_n0_125 %float_n0_375 +// CHECK-DAG: [[pos4_1:%[0-9]+]] = OpConstantComposite %v2float %float_0_375 %float_n0_125 +// CHECK-DAG: [[pos4_2:%[0-9]+]] = OpConstantComposite %v2float %float_n0_375 %float_0_125 +// CHECK-DAG: [[pos4_3:%[0-9]+]] = OpConstantComposite %v2float %float_0_125 %float_0_375 +// CHECK-DAG: [[pos4:%[0-9]+]] = OpConstantComposite %_arr_v2float_uint_4 [[pos4_0]] [[pos4_1]] [[pos4_2]] [[pos4_3]] + +// CHECK-DAG: [[pos8_0:%[0-9]+]] = OpConstantComposite %v2float %float_0_0625 %float_n0_1875 +// CHECK-DAG: [[pos8_1:%[0-9]+]] = OpConstantComposite %v2float %float_n0_0625 %float_0_1875 +// CHECK-DAG: [[pos8_2:%[0-9]+]] = OpConstantComposite %v2float %float_0_3125 %float_0_0625 +// CHECK-DAG: [[pos8_3:%[0-9]+]] = OpConstantComposite %v2float %float_n0_1875 %float_n0_3125 +// CHECK-DAG: [[pos8_4:%[0-9]+]] = OpConstantComposite %v2float %float_n0_3125 %float_0_3125 +// CHECK-DAG: [[pos8_5:%[0-9]+]] = OpConstantComposite %v2float %float_n0_4375 %float_n0_0625 +// CHECK-DAG: [[pos8_6:%[0-9]+]] = OpConstantComposite %v2float %float_0_1875 %float_0_4375 +// CHECK-DAG: [[pos8_7:%[0-9]+]] = OpConstantComposite %v2float %float_0_4375 %float_n0_4375 +// CHECK-DAG: [[pos8:%[0-9]+]] = OpConstantComposite %_arr_v2float_uint_8 [[pos8_0]] [[pos8_1]] [[pos8_2]] [[pos8_3]] [[pos8_4]] [[pos8_5]] [[pos8_6]] [[pos8_7]] + +// CHECK-DAG: [[pos16_00:%[0-9]+]] = OpConstantComposite %v2float %float_0_0625 %float_0_0625 +// CHECK-DAG: [[pos16_01:%[0-9]+]] = OpConstantComposite %v2float %float_n0_0625 %float_n0_1875 +// CHECK-DAG: [[pos16_02:%[0-9]+]] = OpConstantComposite %v2float %float_n0_1875 %float_0_125 +// CHECK-DAG: [[pos16_03:%[0-9]+]] = OpConstantComposite %v2float %float_0_25 %float_n0_0625 +// CHECK-DAG: [[pos16_04:%[0-9]+]] = OpConstantComposite %v2float %float_n0_3125 %float_n0_125 +// CHECK-DAG: [[pos16_05:%[0-9]+]] = OpConstantComposite %v2float %float_0_125 %float_0_3125 +// CHECK-DAG: [[pos16_06:%[0-9]+]] = OpConstantComposite %v2float %float_0_3125 %float_0_1875 +// CHECK-DAG: [[pos16_07:%[0-9]+]] = OpConstantComposite %v2float %float_0_1875 %float_n0_3125 +// CHECK-DAG: [[pos16_08:%[0-9]+]] = OpConstantComposite %v2float %float_n0_125 %float_0_375 +// CHECK-DAG: [[pos16_09:%[0-9]+]] = OpConstantComposite %v2float %float_0 %float_n0_4375 +// CHECK-DAG: [[pos16_10:%[0-9]+]] = OpConstantComposite %v2float %float_n0_25 %float_n0_375 +// CHECK-DAG: [[pos16_11:%[0-9]+]] = OpConstantComposite %v2float %float_n0_375 %float_0_25 +// CHECK-DAG: [[pos16_12:%[0-9]+]] = OpConstantComposite %v2float %float_n0_5 %float_0 +// CHECK-DAG: [[pos16_13:%[0-9]+]] = OpConstantComposite %v2float %float_0_4375 %float_n0_25 +// CHECK-DAG: [[pos16_14:%[0-9]+]] = OpConstantComposite %v2float %float_0_375 %float_0_4375 +// CHECK-DAG: [[pos16_15:%[0-9]+]] = OpConstantComposite %v2float %float_n0_4375 %float_n0_5 +// CHECK-DAG: [[pos16:%[0-9]+]] = OpConstantComposite %_arr_v2float_uint_16 [[pos16_00]] [[pos16_01]] [[pos16_02]] [[pos16_03]] [[pos16_04]] [[pos16_05]] [[pos16_06]] [[pos16_07]] [[pos16_08]] [[pos16_09]] [[pos16_10]] [[pos16_11]] [[pos16_12]] [[pos16_13]] [[pos16_14]] [[pos16_15]] + +// CHECK-DAG: [[zero:%[0-9]+]] = OpConstantComposite %v2float %float_0 %float_0 + +vk::SampledTexture2DMS tex2dMS; +vk::SampledTexture2DMSArray tex2dMSArray; + +void main(int index : INDEX) { +// CHECK: %var_GetSamplePosition_data_2 = OpVariable %_ptr_Function__arr_v2float_uint_2 Function +// CHECK: %var_GetSamplePosition_data_4 = OpVariable %_ptr_Function__arr_v2float_uint_4 Function +// CHECK: %var_GetSamplePosition_data_8 = OpVariable %_ptr_Function__arr_v2float_uint_8 Function +// CHECK: %var_GetSamplePosition_data_16 = OpVariable %_ptr_Function__arr_v2float_uint_16 Function +// CHECK: %var_GetSamplePosition_result = OpVariable %_ptr_Function_v2float Function + +// CHECK: [[tex_ms:%[0-9]+]] = OpLoad [[type_2d_sampled_image_ms]] %tex2dMS +// CHECK-NEXT: [[img_ms:%[0-9]+]] = OpImage [[type_2d_image_ms]] [[tex_ms]] +// CHECK-NEXT:[[count_ms:%[0-9]+]] = OpImageQuerySamples %uint [[img_ms]] +// CHECK-NEXT: [[index:%[0-9]+]] = OpLoad %int %index +// CHECK-NEXT: OpStore %var_GetSamplePosition_data_2 [[pos2]] +// CHECK-NEXT: OpStore %var_GetSamplePosition_data_4 [[pos4]] +// CHECK-NEXT: OpStore %var_GetSamplePosition_data_8 [[pos8]] +// CHECK-NEXT: OpStore %var_GetSamplePosition_data_16 [[pos16]] + +// CHECK-NEXT: [[eq2:%[0-9]+]] = OpIEqual %bool [[count_ms]] %uint_2 +// CHECK-NEXT: OpSelectionMerge %if_GetSamplePosition_merge2 None +// CHECK-NEXT: OpBranchConditional [[eq2]] %if_GetSamplePosition_then2 %if_GetSamplePosition_else2 + +// CHECK-NEXT: %if_GetSamplePosition_then2 = OpLabel +// CHECK-NEXT: [[ac:%[0-9]+]] = OpAccessChain %_ptr_Function_v2float %var_GetSamplePosition_data_2 [[index]] +// CHECK-NEXT: [[val:%[0-9]+]] = OpLoad %v2float [[ac]] +// CHECK-NEXT: OpStore %var_GetSamplePosition_result [[val]] +// CHECK-NEXT: OpBranch %if_GetSamplePosition_merge2 + +// CHECK-NEXT: %if_GetSamplePosition_else2 = OpLabel +// CHECK-NEXT: [[eq4:%[0-9]+]] = OpIEqual %bool [[count_ms]] %uint_4 +// CHECK-NEXT: OpSelectionMerge %if_GetSamplePosition_merge4 None +// CHECK-NEXT: OpBranchConditional [[eq4]] %if_GetSamplePosition_then4 %if_GetSamplePosition_else4 + +// CHECK-NEXT: %if_GetSamplePosition_then4 = OpLabel +// CHECK-NEXT: [[ac_0:%[0-9]+]] = OpAccessChain %_ptr_Function_v2float %var_GetSamplePosition_data_4 [[index]] +// CHECK-NEXT: [[val_0:%[0-9]+]] = OpLoad %v2float [[ac_0]] +// CHECK-NEXT: OpStore %var_GetSamplePosition_result [[val_0]] +// CHECK-NEXT: OpBranch %if_GetSamplePosition_merge4 + +// CHECK-NEXT: %if_GetSamplePosition_else4 = OpLabel +// CHECK-NEXT: [[eq8:%[0-9]+]] = OpIEqual %bool [[count_ms]] %uint_8 +// CHECK-NEXT: OpSelectionMerge %if_GetSamplePosition_merge8 None +// CHECK-NEXT: OpBranchConditional [[eq8]] %if_GetSamplePosition_then8 %if_GetSamplePosition_else8 + +// CHECK-NEXT: %if_GetSamplePosition_then8 = OpLabel +// CHECK-NEXT: [[ac_1:%[0-9]+]] = OpAccessChain %_ptr_Function_v2float %var_GetSamplePosition_data_8 [[index]] +// CHECK-NEXT: [[val_1:%[0-9]+]] = OpLoad %v2float [[ac_1]] +// CHECK-NEXT: OpStore %var_GetSamplePosition_result [[val_1]] +// CHECK-NEXT: OpBranch %if_GetSamplePosition_merge8 + +// CHECK-NEXT: %if_GetSamplePosition_else8 = OpLabel +// CHECK-NEXT: [[eq16:%[0-9]+]] = OpIEqual %bool [[count_ms]] %uint_16 +// CHECK-NEXT: OpSelectionMerge %if_GetSamplePosition_merge16 None +// CHECK-NEXT: OpBranchConditional [[eq16]] %if_GetSamplePosition_then16 %if_GetSamplePosition_else16 + +// CHECK-NEXT: %if_GetSamplePosition_then16 = OpLabel +// CHECK-NEXT: [[ac_2:%[0-9]+]] = OpAccessChain %_ptr_Function_v2float %var_GetSamplePosition_data_16 [[index]] +// CHECK-NEXT: [[val_2:%[0-9]+]] = OpLoad %v2float [[ac_2]] +// CHECK-NEXT: OpStore %var_GetSamplePosition_result [[val_2]] +// CHECK-NEXT: OpBranch %if_GetSamplePosition_merge16 + +// CHECK-NEXT: %if_GetSamplePosition_else16 = OpLabel +// CHECK-NEXT: OpStore %var_GetSamplePosition_result [[zero]] +// CHECK-NEXT: OpBranch %if_GetSamplePosition_merge16 + +// CHECK-NEXT: %if_GetSamplePosition_merge16 = OpLabel +// CHECK-NEXT: OpBranch %if_GetSamplePosition_merge8 +// CHECK-NEXT: %if_GetSamplePosition_merge8 = OpLabel +// CHECK-NEXT: OpBranch %if_GetSamplePosition_merge4 +// CHECK-NEXT: %if_GetSamplePosition_merge4 = OpLabel +// CHECK-NEXT: OpBranch %if_GetSamplePosition_merge2 +// CHECK-NEXT: %if_GetSamplePosition_merge2 = OpLabel +// CHECK-NEXT: [[val_3:%[0-9]+]] = OpLoad %v2float %var_GetSamplePosition_result +// CHECK-NEXT: OpStore %posMS [[val_3]] + float2 posMS = tex2dMS.GetSamplePosition(index); + +// CHECK: [[tex_msa:%[0-9]+]] = OpLoad [[type_2d_sampled_image_ms_array]] %tex2dMSArray +// CHECK-NEXT: [[img_msa:%[0-9]+]] = OpImage [[type_2d_image_ms_array]] [[tex_msa]] +// CHECK-NEXT:[[count_msa:%[0-9]+]] = OpImageQuerySamples %uint [[img_msa]] + float2 posMSArray = tex2dMSArray.GetSamplePosition(index); + +} diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl index 930b4a96f4..e522c82ce6 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl @@ -6,9 +6,15 @@ // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +// CHECK: [[type_2d_image_ms:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 1 1 Unknown +// CHECK: [[type_2d_sampled_image_ms:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms]] +// CHECK: [[type_2d_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 1 1 Unknown +// CHECK: [[type_2d_sampled_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms_array]] vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; +vk::SampledTexture2DMS tex2dMS; +vk::SampledTexture2DMSArray tex2dMSArray; float4 main(int3 location3: A, int4 location4: B) : SV_Target { uint status; @@ -53,5 +59,23 @@ float4 main(int3 location3: A, int4 location4: B) : SV_Target { // CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod [[lod_0]] float4 val4 = tex2dArray.Load(location4); +// CHECK: [[loc_ms:%[0-9]+]] = OpLoad %v3int %location3 +// CHECK-NEXT:[[coord_ms:%[0-9]+]] = OpVectorShuffle %v2int [[loc_ms]] [[loc_ms]] 0 1 +// CHECK-NEXT:[[sample_ms_ptr:%[0-9]+]] = OpAccessChain %_ptr_Function_int %location3 %int_2 +// CHECK-NEXT: [[sample_ms:%[0-9]+]] = OpLoad %int [[sample_ms_ptr]] +// CHECK-NEXT: [[tex_ms:%[0-9]+]] = OpLoad [[type_2d_sampled_image_ms]] %tex2dMS +// CHECK-NEXT:[[tex_ms_img:%[0-9]+]] = OpImage [[type_2d_image_ms]] [[tex_ms]] +// CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_ms_img]] [[coord_ms]] Sample [[sample_ms]] + float4 val5 = tex2dMS.Load(location3.xy, location3.z); + +// CHECK: [[loc_msa:%[0-9]+]] = OpLoad %v4int %location4 +// CHECK-NEXT:[[coord_msa:%[0-9]+]] = OpVectorShuffle %v3int [[loc_msa]] [[loc_msa]] 0 1 2 +// CHECK-NEXT:[[sample_msa_ptr:%[0-9]+]] = OpAccessChain %_ptr_Function_int %location4 %int_3 +// CHECK-NEXT: [[sample_msa:%[0-9]+]] = OpLoad %int [[sample_msa_ptr]] +// CHECK-NEXT: [[tex_msa:%[0-9]+]] = OpLoad [[type_2d_sampled_image_ms_array]] %tex2dMSArray +// CHECK-NEXT:[[tex_msa_img:%[0-9]+]] = OpImage [[type_2d_image_ms_array]] [[tex_msa]] +// CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_msa_img]] [[coord_msa]] Sample [[sample_msa]] + float4 val6 = tex2dMSArray.Load(location4.xyz, location4.w); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-access.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-access.hlsl new file mode 100644 index 0000000000..246c1a5b53 --- /dev/null +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-access.hlsl @@ -0,0 +1,29 @@ +// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s + +// CHECK: [[type_2d_image_ms:%[a-zA-Z0-9_]+]] = OpTypeImage %int 2D 0 0 1 1 Unknown +// CHECK: [[type_2d_sampled_image_ms:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms]] +// CHECK: [[type_2d_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 1 1 Unknown +// CHECK: [[type_2d_sampled_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms_array]] + +vk::SampledTexture2DMS tex2dMS; +vk::SampledTexture2DMSArray tex2dMSArray; + +void main() { + uint2 pos2 = uint2(1,2); + +// CHECK: [[pos2:%[0-9]+]] = OpLoad %v2uint %pos2 +// CHECK-NEXT: [[tex1:%[0-9]+]] = OpLoad [[type_2d_sampled_image_ms]] %tex2dMS +// CHECK-NEXT: [[img1:%[0-9]+]] = OpImage [[type_2d_image_ms]] [[tex1]] +// CHECK-NEXT: [[f1:%[0-9]+]] = OpImageFetch %v4int [[img1]] [[pos2]] Sample %uint_3 +// CHECK-NEXT: [[val1:%[0-9]+]] = OpVectorShuffle %v3int [[f1]] [[f1]] 0 1 2 +// CHECK-NEXT: OpStore %a1 [[val1]] + int3 a1 = tex2dMS.sample[3][pos2]; + +// CHECK: [[pos3:%[0-9]+]] = OpLoad %v3uint %pos3 +// CHECK-NEXT: [[tex2:%[0-9]+]] = OpLoad [[type_2d_sampled_image_ms_array]] %tex2dMSArray +// CHECK-NEXT: [[img2:%[0-9]+]] = OpImage [[type_2d_image_ms_array]] [[tex2]] +// CHECK-NEXT: [[f2:%[0-9]+]] = OpImageFetch %v4float [[img2]] [[pos3]] Sample %uint_4 +// CHECK-NEXT: OpStore %a2 [[f2]] + uint3 pos3 = uint3(1,2,3); + float4 a2 = tex2dMSArray.sample[4][pos3]; +} diff --git a/utils/hct/gen_intrin_main.txt b/utils/hct/gen_intrin_main.txt index 59e4c9382f..4173e1ca52 100644 --- a/utils/hct/gen_intrin_main.txt +++ b/utils/hct/gen_intrin_main.txt @@ -1414,3 +1414,21 @@ namespace VkSampledTexture2DArrayMethods { $match<0, -1> void<4> [[]] GatherRaw(in float<3> x, in int<2> o, out uint_only status); } namespace +namespace VkSampledTexture2DMSMethods { + void [[]] GetDimensions(out uint_only width, out $type1 height, out $type2 samples) : resinfo_uint_o; + void [[]] GetDimensions(out float_like width, out $type1 height, out $type2 samples) : resinfo_o; + float_like<2> [[ro]] GetSamplePosition(in int s) : samplepos; + $classT [[]] Load(in int<2> x, in int s) : texture2d_ms; + $classT [[]] Load(in int<2> x, in int s, in int<2> o) : texture2d_ms_o; + $classT [[]] Load(in int<2> x, in int s, in int<2> o, out uint_only status) : texture2d_ms_o_s; +} namespace + + +namespace VkSampledTexture2DMSArrayMethods { + void [[]] GetDimensions(out uint_only width, out $type1 height, out $type1 elements, out $type1 samples) : resinfo_uint_o; + void [[]] GetDimensions(out float_like width, out $type1 height, out $type1 elements, out $type1 samples) : resinfo_o; + float_like<2> [[ro]] GetSamplePosition(in int s) : samplepos; + $classT [[ro]] Load(in int<3> x, in int s) : texture2darray_ms; + $classT [[ro]] Load(in int<3> x, in int s, in int<2> o) : texture2darray_ms_o; + $classT [[]] Load(in int<3> x, in int s, in int<2> o, out uint_only status) : texture2darray_ms_o_s; +} namespace \ No newline at end of file From 26674de1b94aa1d53e22772729ae98c08e9241dc Mon Sep 17 00:00:00 2001 From: luciechoi Date: Fri, 27 Feb 2026 21:06:46 +0000 Subject: [PATCH 4/4] SampledTexture1D, SampledTexture1DArray --- include/dxc/dxcapi.internal.h | 12 ++- tools/clang/lib/SPIRV/AstTypeProbe.cpp | 4 +- tools/clang/lib/SPIRV/LowerTypeVisitor.cpp | 13 +-- tools/clang/lib/SPIRV/SpirvEmitter.cpp | 2 + tools/clang/lib/Sema/SemaHLSL.cpp | 41 +++++++- ...ampledtexture.calculate-lod-unclamped.hlsl | 16 +++ .../vk.sampledtexture.calculate-lod.hlsl | 16 +++ .../vk.sampledtexture.cmp-level.hlsl | 14 +++ .../vk.sampledtexture.get-dimensions.hlsl | 21 ++++ .../CodeGenSPIRV/vk.sampledtexture.load.hlsl | 24 +++++ .../vk.sampledtexture.mips-access.hlsl | 20 +++- .../vk.sampledtexture.sample-bias.hlsl | 14 +++ .../vk.sampledtexture.sample-cmp-bias.hlsl | 14 +++ .../vk.sampledtexture.sample-cmp-grad.hlsl | 14 +++ ....sampledtexture.sample-cmp-level-zero.hlsl | 14 +++ .../vk.sampledtexture.sample-cmp.hlsl | 14 +++ .../vk.sampledtexture.sample-grad.hlsl | 14 +++ .../vk.sampledtexture.sample-level.hlsl | 14 +++ .../vk.sampledtexture.sample.hlsl | 14 +++ utils/hct/gen_intrin_main.txt | 97 ++++++++++++++++++- utils/hct/hctdb.py | 2 +- 21 files changed, 374 insertions(+), 20 deletions(-) diff --git a/include/dxc/dxcapi.internal.h b/include/dxc/dxcapi.internal.h index 80c218ed0d..5d84e64e30 100644 --- a/include/dxc/dxcapi.internal.h +++ b/include/dxc/dxcapi.internal.h @@ -140,11 +140,13 @@ enum LEGAL_INTRINSIC_COMPTYPES { #ifdef ENABLE_SPIRV_CODEGEN LICOMPTYPE_VK_BUFFER_POINTER = 56, - LICOMPTYPE_VK_SAMPLED_TEXTURE2D = 57, - LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY = 58, - LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS = 59, - LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS_ARRAY = 60, - LICOMPTYPE_COUNT = 61 + LICOMPTYPE_VK_SAMPLED_TEXTURE1D = 57, + LICOMPTYPE_VK_SAMPLED_TEXTURE1D_ARRAY = 58, + LICOMPTYPE_VK_SAMPLED_TEXTURE2D = 59, + LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY = 60, + LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS = 61, + LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS_ARRAY = 62, + LICOMPTYPE_COUNT = 63 #else LICOMPTYPE_COUNT = 56 #endif diff --git a/tools/clang/lib/SPIRV/AstTypeProbe.cpp b/tools/clang/lib/SPIRV/AstTypeProbe.cpp index ea92107890..ec73eefe92 100644 --- a/tools/clang/lib/SPIRV/AstTypeProbe.cpp +++ b/tools/clang/lib/SPIRV/AstTypeProbe.cpp @@ -931,7 +931,9 @@ bool isSampledTexture(QualType type) { const auto name = rt->getDecl()->getName(); // TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Add // other sampled texture types as needed. - if (name == "SampledTexture2D" || name == "SampledTexture2DArray" || + + if (name == "SampledTexture1D" || name == "SampledTexture1DArray" || + name == "SampledTexture2D" || name == "SampledTexture2DArray" || name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") return true; } diff --git a/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp b/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp index 907cc0655f..d4fadbacea 100644 --- a/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp +++ b/tools/clang/lib/SPIRV/LowerTypeVisitor.cpp @@ -849,7 +849,8 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace( assert(visitedTypeStack.size() == visitedTypeStackSize); return pointerType; } - if (name == "SampledTexture2D" || name == "SampledTexture2DArray" || + if (name == "SampledTexture1D" || name == "SampledTexture1DArray" || + name == "SampledTexture2D" || name == "SampledTexture2DArray" || name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") { const auto sampledType = hlsl::GetHLSLResourceResultType(type); auto loweredType = lowerType(getElementType(astContext, sampledType), rule, @@ -861,13 +862,13 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace( loweredType = spvContext.getUIntType(32); } - const bool isArray = - (name == "SampledTexture2DArray" || name == "SampledTexture2DMSArray"); - const bool isMS = - (name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray"); + const spv::Dim dimension = + name.count("1D") > 0 ? spv::Dim::Dim1D : spv::Dim::Dim2D; + const bool isArray = name.count("Array") > 0; + const bool isMS = name.count("MS") > 0; const auto *imageType = spvContext.getImageType( - loweredType, spv::Dim::Dim2D, ImageType::WithDepth::No, isArray, isMS, + loweredType, dimension, ImageType::WithDepth::No, isArray, isMS, ImageType::WithSampler::Yes, spv::ImageFormat::Unknown); return spvContext.getSampledImageType(imageType); } diff --git a/tools/clang/lib/SPIRV/SpirvEmitter.cpp b/tools/clang/lib/SPIRV/SpirvEmitter.cpp index 2f61757df7..ad3d2115f2 100644 --- a/tools/clang/lib/SPIRV/SpirvEmitter.cpp +++ b/tools/clang/lib/SPIRV/SpirvEmitter.cpp @@ -4405,6 +4405,8 @@ SpirvEmitter::processBufferTextureGetDimensions(const CXXMemberCallExpr *expr) { if ((typeName == "Texture1D" && numArgs > 1) || (typeName == "Texture2D" && numArgs > 2) || + (typeName == "SampledTexture1D" && numArgs > 1) || + (typeName == "SampledTexture1DArray" && numArgs > 2) || (typeName == "SampledTexture2D" && numArgs > 2) || (typeName == "SampledTexture2DArray" && numArgs > 3) || (typeName == "TextureCube" && numArgs > 2) || diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index f04b54db89..2b03117c4e 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -200,6 +200,8 @@ enum ArBasicKind { AR_OBJECT_VK_SPV_INTRINSIC_TYPE, AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID, AR_OBJECT_VK_BUFFER_POINTER, + AR_OBJECT_VK_SAMPLED_TEXTURE1D, + AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURE2D, AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURE2DMS, @@ -564,6 +566,8 @@ const UINT g_uBasicKindProps[] = { BPROP_OBJECT, // AR_OBJECT_VK_SPV_INTRINSIC_TYPE use recordType BPROP_OBJECT, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID use recordType BPROP_OBJECT, // AR_OBJECT_VK_BUFFER_POINTER use recordType + BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE1D + BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS @@ -1276,6 +1280,10 @@ static const ArBasicKind g_LinAlgMatrixCT[] = {AR_OBJECT_LINALG_MATRIX, #ifdef ENABLE_SPIRV_CODEGEN static const ArBasicKind g_VKBufferPointerCT[] = {AR_OBJECT_VK_BUFFER_POINTER, AR_BASIC_UNKNOWN}; +static const ArBasicKind g_VKSampledTexture1DCT[] = { + AR_OBJECT_VK_SAMPLED_TEXTURE1D, AR_BASIC_UNKNOWN}; +static const ArBasicKind g_VKSampledTexture1DArrayCT[] = { + AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY, AR_BASIC_UNKNOWN}; static const ArBasicKind g_VKSampledTexture2DCT[] = { AR_OBJECT_VK_SAMPLED_TEXTURE2D, AR_BASIC_UNKNOWN}; static const ArBasicKind g_VKSampledTexture2DArrayCT[] = { @@ -1347,6 +1355,8 @@ const ArBasicKind *g_LegalIntrinsicCompTypes[] = { g_BuiltInTrianglePositionsCT, // LICOMPTYPE_BUILTIN_TRIANGLE_POSITIONS #ifdef ENABLE_SPIRV_CODEGEN g_VKBufferPointerCT, // LICOMPTYPE_VK_BUFFER_POINTER + g_VKSampledTexture1DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE1D + g_VKSampledTexture1DArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE1D_ARRAY g_VKSampledTexture2DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D g_VKSampledTexture2DArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY g_VKSampledTexture2DMSCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS @@ -1410,7 +1420,8 @@ static const ArBasicKind g_ArBasicKindsAsTypes[] = { AR_OBJECT_VK_SPIRV_TYPE, AR_OBJECT_VK_SPIRV_OPAQUE_TYPE, AR_OBJECT_VK_INTEGRAL_CONSTANT, AR_OBJECT_VK_LITERAL, AR_OBJECT_VK_SPV_INTRINSIC_TYPE, AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID, - AR_OBJECT_VK_BUFFER_POINTER, AR_OBJECT_VK_SAMPLED_TEXTURE2D, + AR_OBJECT_VK_BUFFER_POINTER, AR_OBJECT_VK_SAMPLED_TEXTURE1D, + AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURE2D, AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURE2DMS, AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY, #endif // ENABLE_SPIRV_CODEGEN @@ -1524,6 +1535,8 @@ static const uint8_t g_ArBasicKindsTemplateCount[] = { 1, // AR_OBJECT_VK_SPV_INTRINSIC_TYPE 1, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID 2, // AR_OBJECT_VK_BUFFER_POINTER + 1, // AR_OBJECT_VK_SAMPLED_TEXTURE1D + 1, // AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY 1, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS @@ -1681,6 +1694,8 @@ static const SubscriptOperatorRecord g_ArBasicKindsSubscripts[] = { {0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_SPV_INTRINSIC_TYPE {0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID {0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_BUFFER_POINTER + {1, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE1D + {2, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY {2, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D {3, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY {2, MipsFalse, SampleTrue}, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS @@ -1854,6 +1869,8 @@ static const char *g_ArBasicTypeNames[] = { "ext_type", "ext_result_id", "BufferPointer", + "SampledTexture1D", + "SampledTexture1DArray", "SampledTexture2D", "SampledTexture2DArray", "SampledTexture2DMS", @@ -2511,6 +2528,14 @@ static void GetIntrinsicMethods(ArBasicKind kind, *intrinsicCount = _countof(g_RayQueryMethods); break; #ifdef ENABLE_SPIRV_CODEGEN + case AR_OBJECT_VK_SAMPLED_TEXTURE1D: + *intrinsics = g_VkSampledTexture1DMethods; + *intrinsicCount = _countof(g_VkSampledTexture1DMethods); + break; + case AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY: + *intrinsics = g_VkSampledTexture1DArrayMethods; + *intrinsicCount = _countof(g_VkSampledTexture1DArrayMethods); + break; case AR_OBJECT_VK_SAMPLED_TEXTURE2D: *intrinsics = g_VkSampledTexture2DMethods; *intrinsicCount = _countof(g_VkSampledTexture2DMethods); @@ -4132,7 +4157,9 @@ class HLSLExternalSource : public ExternalSemaSource { recordDecl = DeclareVkBufferPointerType(*m_context, m_vkNSDecl); recordDecl->setImplicit(true); m_vkBufferPointerTemplateDecl = recordDecl->getDescribedClassTemplate(); - } else if (kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D || + } else if (kind == AR_OBJECT_VK_SAMPLED_TEXTURE1D || + kind == AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY || + kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D || kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY || kind == AR_OBJECT_VK_SAMPLED_TEXTURE2DMS || kind == AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY) { @@ -4966,7 +4993,9 @@ class HLSLExternalSource : public ExternalSemaSource { case AR_OBJECT_LEGACY_EFFECT: // used for all legacy effect object types case AR_OBJECT_TEXTURE1D: + case AR_OBJECT_VK_SAMPLED_TEXTURE1D: case AR_OBJECT_TEXTURE1D_ARRAY: + case AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY: case AR_OBJECT_TEXTURE2D: case AR_OBJECT_TEXTURE2D_ARRAY: case AR_OBJECT_TEXTURE3D: @@ -5071,6 +5100,9 @@ class HLSLExternalSource : public ExternalSemaSource { DXASSERT_VALIDBASICKIND(BasicKind); switch (BasicKind) { case AR_OBJECT_TEXTURE1D: +#ifdef ENABLE_SPIRV_CODEGEN + case AR_OBJECT_VK_SAMPLED_TEXTURE1D: +#endif ResKind = DXIL::ResourceKind::Texture1D; ResClass = DXIL::ResourceClass::SRV; return true; @@ -5080,6 +5112,9 @@ class HLSLExternalSource : public ExternalSemaSource { ResClass = DXIL::ResourceClass::UAV; return true; case AR_OBJECT_TEXTURE1D_ARRAY: +#ifdef ENABLE_SPIRV_CODEGEN + case AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY: +#endif ResKind = DXIL::ResourceKind::Texture1DArray; ResClass = DXIL::ResourceClass::SRV; return true; @@ -11669,7 +11704,9 @@ void hlsl::DiagnoseRegisterType(clang::Sema *self, clang::SourceLocation loc, break; case AR_OBJECT_TEXTURE1D: + case AR_OBJECT_VK_SAMPLED_TEXTURE1D: case AR_OBJECT_TEXTURE1D_ARRAY: + case AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY: case AR_OBJECT_TEXTURE2D: case AR_OBJECT_TEXTURE2D_ARRAY: case AR_OBJECT_TEXTURE3D: diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl index e390cf26f3..e02229ce98 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod-unclamped.hlsl @@ -2,11 +2,17 @@ // CHECK: OpCapability ImageQuery +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -24,4 +30,14 @@ void main() { //CHECK-NEXT: [[query2:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex2_load]] [[xy_load_2]] //CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query2]] 1 float lod2 = tex2dArray.CalculateLevelOfDetailUnclamped(xy); + +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK-NEXT: [[query1d:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1d_load]] %float_0_5 +// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1d]] 1 + float lod3 = tex1d.CalculateLevelOfDetailUnclamped(0.5); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK-NEXT: [[query1da:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1da_load]] %float_0_5 +// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1da]] 1 + float lod4 = tex1dArray.CalculateLevelOfDetailUnclamped(0.5); } \ No newline at end of file diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl index 15aaaf1956..084ab906c1 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.calculate-lod.hlsl @@ -2,11 +2,17 @@ // CHECK: OpCapability ImageQuery +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -24,4 +30,14 @@ void main() { //CHECK-NEXT: [[query2:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex2]] [[xy_load_2]] //CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query2]] 0 float lod2 = tex2dArray.CalculateLevelOfDetail(xy); + +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK-NEXT: [[query1d:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1d_load]] %float_0_5 +// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1d]] 0 + float lod3 = tex1d.CalculateLevelOfDetail(0.5); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK-NEXT: [[query1da:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1da_load]] %float_0_5 +// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1da]] 0 + float lod4 = tex1dArray.CalculateLevelOfDetail(0.5); } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl index d645ce5464..680ca99f7d 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.cmp-level.hlsl @@ -6,11 +6,17 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 // CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -34,5 +40,13 @@ float4 main() : SV_Target { // CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[load_arr1]] [[v3fc]] %float_2 Lod %float_1 float val4 = tex2dArray.SampleCmpLevel(float3(0.5, 0.25, 0), 2.0f, 1.0f); +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_result_1d:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1d_load]] %float_0_5 %float_2 Lod %float_1 + float val5 = tex1d.SampleCmpLevel(0.5, 2.0f, 1.0f); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_result_1da:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1da_load]] {{%[0-9]+}} %float_2 Lod %float_1 + float val6 = tex1dArray.SampleCmpLevel(float2(0.5, 0), 2.0f, 1.0f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl index f43e65c640..ee362118dd 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.get-dimensions.hlsl @@ -3,6 +3,10 @@ // CHECK: OpCapability ImageQuery +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown @@ -12,6 +16,8 @@ // CHECK: [[type_2d_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 1 1 Unknown // CHECK: [[type_2d_sampled_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; vk::SampledTexture2DMS tex2dMS; @@ -130,6 +136,21 @@ void main() { // CHECK-NEXT: OpStore %i_height [[query_1_int]] tex2d.GetDimensions(i_width, i_height); +// CHECK: [[t1d_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK-NEXT: [[image1d:%[0-9]+]] = OpImage [[type_1d_image]] [[t1d_load]] +// CHECK-NEXT: [[query1d:%[0-9]+]] = OpImageQuerySizeLod %uint [[image1d]] %int_0 +// CHECK-NEXT: OpStore %width [[query1d]] + tex1d.GetDimensions(width); + +// CHECK: [[t1da_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK-NEXT: [[image1da:%[0-9]+]] = OpImage [[type_1d_image_array]] [[t1da_load]] +// CHECK-NEXT: [[query1da:%[0-9]+]] = OpImageQuerySizeLod %v2uint [[image1da]] %int_0 +// CHECK-NEXT: [[query1da0:%[0-9]+]] = OpCompositeExtract %uint [[query1da]] 0 +// CHECK-NEXT: OpStore %width [[query1da0]] +// CHECK-NEXT: [[query1da1:%[0-9]+]] = OpCompositeExtract %uint [[query1da]] 1 +// CHECK-NEXT: OpStore %elements [[query1da1]] + tex1dArray.GetDimensions(width, elements); + // CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_2d_image]] [[t1_load]] // CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl index e522c82ce6..d88100b7af 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.load.hlsl @@ -2,6 +2,10 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_1 %int_2 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown @@ -11,6 +15,8 @@ // CHECK: [[type_2d_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 1 1 Unknown // CHECK: [[type_2d_sampled_image_ms_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_ms_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; vk::SampledTexture2DMS tex2dMS; @@ -77,5 +83,23 @@ float4 main(int3 location3: A, int4 location4: B) : SV_Target { // CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_msa_img]] [[coord_msa]] Sample [[sample_msa]] float4 val6 = tex2dMSArray.Load(location4.xyz, location4.w); +// CHECK: [[loc:%[0-9]+]] = OpLoad %v3int %location3 +// CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v2int [[loc]] [[loc]] 0 1 +// CHECK-NEXT: [[coord_1:%[0-9]+]] = OpCompositeExtract %int [[coord_0]] 0 +// CHECK-NEXT: [[lod_1:%[0-9]+]] = OpCompositeExtract %int [[coord_0]] 1 +// CHECK-NEXT: [[tex_1d:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK-NEXT: [[tex_1d_img:%[0-9]+]] = OpImage %type_1d_image [[tex_1d]] +// CHECK-NEXT: {{[%0-9]+}} = OpImageFetch %v4float [[tex_1d_img]] [[coord_1]] Lod [[lod_1]] + float4 val7 = tex1d.Load(location3.xy); + +// CHECK: [[loc_arr:%[0-9]+]] = OpLoad %v4int %location4 +// CHECK-NEXT: [[coord_0:%[0-9]+]] = OpVectorShuffle %v3int [[loc_arr]] [[loc_arr]] 0 1 2 +// CHECK-NEXT: [[coord_1:%[0-9]+]] = OpVectorShuffle %v2int [[coord_0]] [[coord_0]] 0 1 +// CHECK-NEXT: [[lod_0:%[0-9]+]] = OpCompositeExtract %int [[coord_0]] 2 +// CHECK-NEXT: [[tex_1d_arr:%[0-9]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK-NEXT: [[tex_1d_arr_img:%[0-9]+]] = OpImage %type_1d_image_array [[tex_1d_arr]] +// CHECK-NEXT: {{[%0-9]+}} = OpImageFetch %v4float [[tex_1d_arr_img]] [[coord_1]] Lod [[lod_0]] + float4 val8 = tex1dArray.Load(location4.xyz); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl index 7858278db9..dc1df57c60 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.mips-access.hlsl @@ -2,17 +2,22 @@ // CHECK: [[cu12:%[0-9]+]] = OpConstantComposite %v2uint %uint_1 %uint_2 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; void main() { -// CHECK: OpStore %pos1 [[cu12]] -// CHECK-NEXT: [[pos1:%[0-9]+]] = OpLoad %v2uint %pos1 +// CHECK: [[pos1:%[0-9]+]] = OpLoad %v2uint %pos1 // CHECK-NEXT: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image]] %tex2d // CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_2d_image]] [[tex1_load]] // CHECK-NEXT: [[result1:%[0-9]+]] = OpImageFetch %v4float [[tex_img]] [[pos1]] Lod %uint_2 @@ -26,4 +31,15 @@ void main() { // CHECK-NEXT: [[res_arr:%[0-9]+]] = OpImageFetch %v4float [[img_arr]] [[pos2]] Lod %uint_3 uint3 pos2 = uint3(1, 2, 4); float4 a2 = tex2dArray.mips[3][pos2]; + +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK-NEXT: [[tex1d_img:%[a-zA-Z0-9_]+]] = OpImage [[type_1d_image]] [[tex1d_load]] +// CHECK-NEXT: [[result1d:%[0-9]+]] = OpImageFetch %v4float [[tex1d_img]] %uint_1 Lod %uint_2 + float4 a3 = tex1d.mips[2][1]; + +// CHECK: [[pos1:%[0-9]+]] = OpLoad %v2uint %pos1 +// CHECK-NEXT: [[tex1d_arr_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK-NEXT: [[tex1d_arr_img:%[a-zA-Z0-9]+]] = OpImage [[type_1d_image_array]] [[tex1d_arr_load]] +// CHECK-NEXT: [[result1d_arr:%[0-9]+]] = OpImageFetch %v4float [[tex1d_arr_img]] [[pos1]] Lod %uint_3 + float4 a4 = tex1dArray.mips[3][pos1]; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl index bd10307de7..b84ce2eab3 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-bias.hlsl @@ -7,11 +7,17 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 // CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -35,5 +41,13 @@ float4 main() : SV_Target { // CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[load_arr1]] [[v3fc]] Bias|ConstOffset %float_0_5 [[v2ic]] float4 val4 = tex2dArray.SampleBias(float3(0.5, 0.25, 0), 0.5f, int2(2, 3)); +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_1d:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex1d_load]] %float_0_5 Bias|ConstOffset %float_0_5 %int_1 + float4 val5 = tex1d.SampleBias(0.5, 0.5f, 1); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_1da:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex1da_load]] {{%[0-9]+}} Bias|ConstOffset %float_0_5 %int_1 + float4 val6 = tex1dArray.SampleBias(float2(0.5, 0), 0.5f, 1); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl index 0180f2c7b3..7f94a71fc6 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-bias.hlsl @@ -7,11 +7,17 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 // CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -35,5 +41,13 @@ float4 main() : SV_Target { // CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[load_arr1]] [[v3fc]] %float_1 Bias|ConstOffset %float_0_5 [[v2ic]] float val4 = tex2dArray.SampleCmpBias(float3(0.5, 0.25, 0), 1.0f, 0.5f, int2(2, 3)); +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_1d:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex1d_load]] %float_0_5 %float_1 Bias %float_0_5 + float val5 = tex1d.SampleCmpBias(0.5, 1.0f, 0.5f); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_1da:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex1da_load]] {{%[0-9]+}} %float_1 Bias %float_0_5 + float val6 = tex1dArray.SampleCmpBias(float2(0.5, 0), 1.0f, 0.5f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl index efec4730cb..4035d4c045 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-grad.hlsl @@ -8,11 +8,17 @@ // CHECK: [[v2f_2:%[0-9]+]] = OpConstantComposite %v2float %float_2 %float_2 // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -36,5 +42,13 @@ float4 main() : SV_Target { uint status; float val4 = tex2d.SampleCmpGrad(float2(0.5, 0.25), 1.0f, float2(1, 1), float2(2, 2), int2(2,3), 0.5, status); +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_1d:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1d_load]] %float_0_5 %float_1 Grad %float_1 %float_2 + float val5 = tex1d.SampleCmpGrad(0.5, 1.0f, 1.0f, 2.0f); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_1da:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1da_load]] {{%[0-9]+}} %float_1 Grad %float_1 %float_2 + float val6 = tex1dArray.SampleCmpGrad(float2(0.5, 0), 1.0f, 1.0f, 2.0f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl index 39b525b888..642bdb5c45 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp-level-zero.hlsl @@ -6,11 +6,17 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 // CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -34,5 +40,13 @@ float4 main() : SV_Target { // CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[load_arr1]] [[v3fc]] %float_2 Lod %float_0 float val4 = tex2dArray.SampleCmpLevelZero(float3(0.5, 0.25, 0), 2.0f); +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_1d:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1d_load]] %float_0_5 %float_2 Lod %float_0 + float val5 = tex1d.SampleCmpLevelZero(0.5, 2.0f); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_1da:%[a-zA-Z0-9_]+]] = OpImageSampleDrefExplicitLod %float [[tex1da_load]] {{%[0-9]+}} %float_2 Lod %float_0 + float val6 = tex1dArray.SampleCmpLevelZero(float2(0.5, 0), 2.0f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl index 8d6da78479..f1adda2960 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-cmp.hlsl @@ -7,11 +7,17 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 // CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -38,5 +44,13 @@ float4 main() : SV_Target { // CHECK: [[load_arr1:%[a-zA-Z0-9_]+]] = OpLoad [[type_2d_sampled_image_array]] %tex2dArray // CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[load_arr1]] [[v3fc]] %float_2 float val5 = tex2dArray.SampleCmp(float3(0.5, 0.25, 0), 2.0f); + +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_1d:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex1d_load]] %float_0_5 %float_2 + float val6 = tex1d.SampleCmp(0.5, 2.0f); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_1da:%[a-zA-Z0-9_]+]] = OpImageSampleDrefImplicitLod %float [[tex1da_load]] {{%[0-9]+}} %float_2 + float val7 = tex1dArray.SampleCmp(float2(0.5, 0), 2.0f); return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl index 94bb03e7e4..e3d1d1abf6 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-grad.hlsl @@ -9,11 +9,17 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 // CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -41,5 +47,13 @@ float4 main() : SV_Target { // CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[load_arr1]] [[v3fc]] Grad [[v2f_1]] [[v2f_2]] float4 val5 = tex2dArray.SampleGrad(float3(0.5, 0.25, 0), float2(1, 1), float2(2, 2)); +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_1d:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1d_load]] %float_0_5 Grad %float_1 %float_2 + float4 val6 = tex1d.SampleGrad(0.5, 1.0, 2.0); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_1da:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1da_load]] {{%[0-9]+}} Grad %float_1 %float_2 + float4 val7 = tex1dArray.SampleGrad(float2(0.5, 0), 1.0, 2.0); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl index ee10dc3878..8c0570fcff 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample-level.hlsl @@ -6,11 +6,17 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 // CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2d; vk::SampledTexture2DArray tex2dArray; @@ -34,5 +40,13 @@ float4 main() : SV_Target { // CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[load_arr1]] [[v3fc]] Lod %float_0_5 float4 val4 = tex2dArray.SampleLevel(float3(0.5, 0.25, 0), 0.5f); +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_1d:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1d_load]] %float_0_5 Lod %float_0_5 + float4 val5 = tex1d.SampleLevel(0.5, 0.5f); + +// CHECK: [[tex1da_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_1da:%[a-zA-Z0-9_]+]] = OpImageSampleExplicitLod %v4float [[tex1da_load]] {{%[0-9]+}} Lod %float_0_5 + float4 val6 = tex1dArray.SampleLevel(float2(0.5, 0), 0.5f); + return 1.0; } diff --git a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl index 2d1654d30e..aec0f2984e 100644 --- a/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl +++ b/tools/clang/test/CodeGenSPIRV/vk.sampledtexture.sample.hlsl @@ -7,6 +7,10 @@ // CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3 // CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0 +// CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown +// CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] +// CHECK: [[type_1d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 1 0 1 Unknown +// CHECK: [[type_1d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image_array]] // CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown // CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]] // CHECK: [[type_2d_image_uint:%[a-zA-Z0-9_]+]] = OpTypeImage %uint 2D 0 0 0 1 Unknown @@ -14,6 +18,8 @@ // CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown // CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]] +vk::SampledTexture1D tex1d; +vk::SampledTexture1DArray tex1dArray; vk::SampledTexture2D tex2df4; vk::SampledTexture2D tex2duint; vk::SampledTexture2DArray tex2dArray; @@ -48,5 +54,13 @@ float4 main() : SV_Target { // CHECK: [[sampled_arr1:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[texArr_load]] [[v3fc]] None float4 val6 = tex2dArray.Sample(float3(0.5, 0.25, 0)); +// CHECK: [[tex1d_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image]] %tex1d +// CHECK: [[sampled_result_1d:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex1d_load]] %float_0_5 None + float4 val7 = tex1d.Sample(0.5); + +// CHECK: [[tex1dArr_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_1d_sampled_image_array]] %tex1dArray +// CHECK: [[sampled_result_1d_arr:%[a-zA-Z0-9]+]] = OpImageSampleImplicitLod %v4float [[tex1dArr_load]] [[v2fc]] None + float4 val8 = tex1dArray.Sample(float2(0.5, 0.25)); + return 1.0; } diff --git a/utils/hct/gen_intrin_main.txt b/utils/hct/gen_intrin_main.txt index 4173e1ca52..530665a53c 100644 --- a/utils/hct/gen_intrin_main.txt +++ b/utils/hct/gen_intrin_main.txt @@ -1226,7 +1226,97 @@ namespace VkSubpassInputMSMethods { $classT [[]] SubpassLoad(in int sample) : subpassinputms_load; } namespace -// SPIRV Change Ends +namespace VkSampledTexture1DMethods { + // Use float for DXIL don't support f16 on CalcLOD. + float [[ro]] CalculateLevelOfDetail(in float<1> x) : tex1d_t_calc_lod; + float [[ro]] CalculateLevelOfDetailUnclamped(in float<1> x) : tex1d_t_calc_lod_unclamped; + void [[]] GetDimensions(in uint x, out uint_only width, out $type2 levels) : resinfo_uint; + void [[]] GetDimensions(in uint x, out float_like width, out $type2 levels) : resinfo; + void [[]] GetDimensions(out uint_only width) : resinfo_o; + void [[]] GetDimensions(out float_like width) : resinfo_o; + $classT [[ro]] Load(in int<2> x) : tex1d_t_load; + $classT [[ro]] Load(in int<2> x, in int<1> o) : tex1d_t_load_o; + $classT [[]] Load(in int<2> x, in int<1> o, out uint_only status) : tex1d_t_load_o_s; + $classT [[ro]] Sample(in float<1> x) : tex1d_t; + $classT [[ro]] Sample(in float<1> x, in int<1> o) : tex1d_t_o; + $classT [[ro]] SampleBias(in float<1> x, in float bias) : tex1d_t_bias; + $classT [[ro]] SampleBias(in float<1> x, in float bias, in int<1> o) : tex1d_t_bias_o; + float_like [[ro]] SampleCmp(in float<1> x, in float compareValue) : tex1d_t_comp; + float_like [[ro]] SampleCmp(in float<1> x, in float compareValue, in int<1> o) : tex1d_t_comp_o; + float_like [[ro]] SampleCmpBias(in float<1> x, in float compareValue, in float bias) : tex1d_t_comp_bias; + float_like [[ro]] SampleCmpBias(in float<1> x, in float compareValue, in float bias, in int<1> o) : tex1d_t_comp_bias_o; + float_like [[ro]] SampleCmpGrad(in float<1> x, in float compareValue, in $type1 ddx, in $type1 ddy) : tex1d_t_comp_dd; + float_like [[ro]] SampleCmpGrad(in float<1> x, in float compareValue, in $type1 ddx, in $type1 ddy, in int<1> o) : tex1d_t_comp_dd_o; + float_like [[ro]] SampleCmpLevel(in float<1> x, in float compareValue, in float lod); + float_like [[ro]] SampleCmpLevel(in float<1> x, in float compareValue, in float lod, in int<1> o); + float_like [[ro]] SampleCmpLevelZero(in float<1> x, in float compareValue) : tex1d_t_comp_lz; + float_like [[ro]] SampleCmpLevelZero(in float<1> x, in float compareValue, in int<1> o) : tex1d_t_comp_lz_o; + $classT [[ro]] SampleGrad(in float<1> x, in $type1 ddx, in $type1 ddy) : tex1d_t_dd; + $classT [[ro]] SampleGrad(in float<1> x, in $type1 ddx, in $type1 ddy, in int<1> o) : tex1d_t_dd_o; + $classT [[ro]] SampleLevel(in float<1> x, in float lod) : tex1d_t_lod; + $classT [[ro]] SampleLevel(in float<1> x, in float lod, in int<1> o) : tex1d_t_lod_o; + $classT [[ro]] Sample(in float<1> x, in int<1> o, in float clamp) : tex1d_t_o_cl; + $classT [[]] Sample(in float<1> x, in int<1> o, in float clamp, out uint_only status) : tex1d_t_o_cl_s; + float_like [[ro]] SampleCmp(in float<1> x, in float compareValue, in int<1> o, in float clamp) : tex1d_t_comp_o_cl; + float_like [[]] SampleCmp(in float<1> x, in float compareValue, in int<1> o, in float clamp, out uint_only status) : tex1d_t_comp_o_cl_s; + float_like [[ro]] SampleCmpBias(in float<1> x, in float compareValue, in float bias, in int<1> o, in float clamp) : tex1d_t_comp_bias_o_cl; + float_like [[]] SampleCmpBias(in float<1> x, in float compareValue, in float bias, in int<1> o, in float clamp, out uint_only status) : tex1d_t_comp_bias_o_cl_s; + float_like [[ro]] SampleCmpGrad(in float<1> x, in float compareValue, in $type1 ddx, in $type1 ddy, in int<1> o, in float clamp) : tex1d_t_comp_dd_o_cl; + float_like [[]] SampleCmpGrad(in float<1> x, in float compareValue, in $type1 ddx, in $type1 ddy, in int<1> o, in float clamp, out uint_only status) : tex1d_t_comp_dd_o_cl_s; + float_like [[]] SampleCmpLevel(in float<1> x, in float compareValue, in float lod, in int<1> o, out uint_only status); + float_like [[]] SampleCmpLevelZero(in float<1> x, in float compareValue, in int<1> o, out uint_only status) : tex1d_t_comp_o_s; + $classT [[]] SampleLevel(in float<1> x, in float lod, in int<1> o, out uint_only status) : tex1d_t_lod_o_s; + $classT [[ro]] SampleBias(in float<1> x, in float bias, in int<1> o, in float clamp) : tex1d_t_bias_o_cl; + $classT [[]] SampleBias(in float<1> x, in float bias, in int<1> o, in float clamp, out uint_only status) : tex1d_t_bias_o_cl_s; + $classT [[]] SampleGrad(in float<1> x, in $type1 ddx, in $type1 ddy, in int<1> o, in float clamp) : tex1d_t_dd_o_cl; + $classT [[]] SampleGrad(in float<1> x, in $type1 ddx, in $type1 ddy, in int<1> o, in float clamp, out uint_only status) : tex1d_t_dd_o_cl_s; +} namespace + +namespace VkSampledTexture1DArrayMethods { + +float [[ro]] CalculateLevelOfDetail(in float<1> x) : tex1d_t_calc_lod_array; +float [[ro]] CalculateLevelOfDetailUnclamped(in float<1> x) : tex1d_t_calc_lod_unclamped_array; +void [[]] GetDimensions(in uint x, out uint_only width, out $type2 elements, out $type2 levels) : resinfo_uint; +void [[]] GetDimensions(in uint x, out float_like width, out $type2 elements, out $type2 levels) : resinfo; +void [[]] GetDimensions(out uint_only width, out $type1 elements) : resinfo_uint_o; +void [[]] GetDimensions(out float_like width, out $type1 elements) : resinfo_o; +$classT [[ro]] Load(in int<3> x) : tex1d_t_load_array; +$classT [[ro]] Load(in int<3> x, in int<1> o) : tex1d_t_load_array_o; +$classT [[]] Load(in int<3> x, in int<1> o, out uint_only status) : tex1d_t_load_array_o_s; +$classT [[ro]] Sample(in float<2> x) : tex1d_t_array; +$classT [[ro]] Sample(in float<2> x, in int<1> o) : tex1d_t_array_o; +$classT [[ro]] SampleBias(in float<2> x, in float bias) : tex1d_t_bias_array; +$classT [[ro]] SampleBias(in float<2> x, in float bias, in int<1> o) : tex1d_t_bias_array_o; +float_like [[ro]] SampleCmp(in float<2> x, in float compareValue) : tex1d_t_comp_array; +float_like [[ro]] SampleCmp(in float<2> x, in float compareValue, in int<1> o) : tex1d_t_comp_array_o; +float_like [[ro]] SampleCmpBias(in float<2> x, in float compareValue, in float bias) : tex1d_t_comp_bias_array; +float_like [[ro]] SampleCmpBias(in float<2> x, in float compareValue, in float bias, in int<1> o) : tex1d_t_comp_bias_array_o; +float_like [[ro]] SampleCmpGrad(in float<2> x, in float compareValue, in $match<2, 2> float<1> ddx, in $match<2, 2> float<1> ddy) : tex1d_t_comp_dd_array; +float_like [[ro]] SampleCmpGrad(in float<2> x, in float compareValue, in $match<2, 2> float<1> ddx, in $match<2, 2> float<1> ddy, in int<1> o) : tex1d_t_comp_dd_array_o; +float_like [[ro]] SampleCmpLevel(in float<2> x, in float compareValue, in float lod); +float_like [[ro]] SampleCmpLevel(in float<2> x, in float compareValue, in float lod, in int<1> o); +float_like [[ro]] SampleCmpLevelZero(in float<2> x, in float compareValue) : tex1d_t_comp_lz_array; +float_like [[ro]] SampleCmpLevelZero(in float<2> x, in float compareValue, in int<1> o) : tex1d_t_comp_lz_array_o; +$classT [[ro]] SampleGrad(in float<2> x, in $match<2, 2> float<1> ddx, in $match<2, 2> float<1> ddy) : tex1d_t_dd_array; +$classT [[ro]] SampleGrad(in float<2> x, in $match<2, 2> float<1> ddx, in $match<2, 2> float<1> ddy, in int<1> o) : tex1d_t_dd_array_o; +$classT [[ro]] SampleLevel(in float<2> x, in float lod) : tex1d_t_lod_array; +$classT [[ro]] SampleLevel(in float<2> x, in float lod, in int<1> o) : tex1d_t_lod_array_o; +$classT [[ro]] Sample(in float<2> x, in int<1> o, in float clamp) : tex1d_t_array_o_cl; +$classT [[]] Sample(in float<2> x, in int<1> o, in float clamp, out uint_only status) : tex1d_t_array_o_cl_s; +float_like [[ro]] SampleCmp(in float<2> x, in float compareValue, in int<1> o, in float clamp) : tex1d_t_comp_array_o_cl; +float_like [[]] SampleCmp(in float<2> x, in float compareValue, in int<1> o, in float clamp, out uint_only status) : tex1d_t_comp_array_o_cl_s; +float_like [[ro]] SampleCmpBias(in float<2> x, in float compareValue, in float bias, in int<1> o, in float clamp) : tex1d_t_comp_bias_array_o_cl; +float_like [[]] SampleCmpBias(in float<2> x, in float compareValue, in float bias, in int<1> o, in float clamp, out uint_only status) : tex1d_t_comp_bias_array_o_cl_s; +float_like [[ro]] SampleCmpGrad(in float<2> x, in float compareValue, in $match<2, 2> float<1> ddx, in $match<2, 2> float<1> ddy, in int<1> o, in float clamp) : tex1d_t_comp_dd_array_o_cl; +float_like [[]] SampleCmpGrad(in float<2> x, in float compareValue, in $match<2, 2> float<1> ddx, in $match<2, 2> float<1> ddy, in int<1> o, in float clamp, out uint_only status) : tex1d_t_comp_dd_array_o_cl_s; +float_like [[]] SampleCmpLevel(in float<2> x, in float compareValue, in float lod, in int<1> o, out uint_only status); +float_like [[]] SampleCmpLevelZero(in float<2> x, in float compareValue, in int<1> o, out uint_only status) : tex1d_t_comp_array_o_s; +$classT [[]] SampleLevel(in float<2> x, in float lod, in int<1> o, out uint_only status) : tex1d_t_lod_array_o_s; +$classT [[ro]] SampleBias(in float<2> x, in float bias, in int<1> o, in float clamp) : tex1d_t_bias_array_o_cl; +$classT [[]] SampleBias(in float<2> x, in float bias, in int<1> o, in float clamp, out uint_only status) : tex1d_t_bias_array_o_cl_s; +$classT [[ro]] SampleGrad(in float<2> x, in $match<2, 2> float<1> ddx, in $match<2, 2> float<1> ddy, in int<1> o, in float clamp) : tex1d_t_dd_array_o_cl; +$classT [[]] SampleGrad(in float<2> x, in $match<2, 2> float<1> ddx, in $match<2, 2> float<1> ddy, in int<1> o, in float clamp, out uint_only status) : tex1d_t_dd_array_o_cl_s; +} namespace namespace VkSampledTexture2DMethods { $classT [[ro]] Sample(in float<2> x) : tex2d_t; @@ -1423,7 +1513,6 @@ namespace VkSampledTexture2DMSMethods { $classT [[]] Load(in int<2> x, in int s, in int<2> o, out uint_only status) : texture2d_ms_o_s; } namespace - namespace VkSampledTexture2DMSArrayMethods { void [[]] GetDimensions(out uint_only width, out $type1 height, out $type1 elements, out $type1 samples) : resinfo_uint_o; void [[]] GetDimensions(out float_like width, out $type1 height, out $type1 elements, out $type1 samples) : resinfo_o; @@ -1431,4 +1520,6 @@ namespace VkSampledTexture2DMSArrayMethods { $classT [[ro]] Load(in int<3> x, in int s) : texture2darray_ms; $classT [[ro]] Load(in int<3> x, in int s, in int<2> o) : texture2darray_ms_o; $classT [[]] Load(in int<3> x, in int s, in int<2> o, out uint_only status) : texture2darray_ms_o_s; -} namespace \ No newline at end of file +} namespace + +// SPIRV Change Ends \ No newline at end of file diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index 71f035e059..40eb96d9b5 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -9651,7 +9651,7 @@ def load_intrinsics(self, intrinsic_defs): acceleration_struct | ray_desc | RayQuery | DxHitObject | Node\w* | RWNode\w* | EmptyNode\w* | AnyNodeOutput\w* | NodeOutputRecord\w* | GroupShared\w* | - VkBufferPointer | LinAlgMatrix | VkSampledTexture2D | VkSampledTexture2DArray + VkBufferPointer | LinAlgMatrix | VkSampledTexture1D | VkSampledTexture1DArray | VkSampledTexture2D | VkSampledTexture2DArray $)""", flags=re.VERBOSE, )