Skip to content

Commit 18ae17b

Browse files
committed
SampledTextureCube, SampledTextureCubeArray
1 parent 7d4ff86 commit 18ae17b

25 files changed

+468
-15
lines changed

include/dxc/dxcapi.internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ enum LEGAL_INTRINSIC_COMPTYPES {
146146
LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY = 60,
147147
LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS = 61,
148148
LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS_ARRAY = 62,
149-
LICOMPTYPE_COUNT = 63
149+
LICOMPTYPE_VK_SAMPLED_TEXTURECUBE = 63,
150+
LICOMPTYPE_VK_SAMPLED_TEXTURECUBE_ARRAY = 64,
151+
LICOMPTYPE_COUNT = 65
150152
#else
151153
LICOMPTYPE_COUNT = 56
152154
#endif

tools/clang/lib/SPIRV/AstTypeProbe.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,12 +929,11 @@ bool isTexture(QualType type) {
929929
bool isSampledTexture(QualType type) {
930930
if (const auto *rt = type->getAs<RecordType>()) {
931931
const auto name = rt->getDecl()->getName();
932-
// TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Add
933-
// other sampled texture types as needed.
934932

935933
if (name == "SampledTexture1D" || name == "SampledTexture1DArray" ||
936934
name == "SampledTexture2D" || name == "SampledTexture2DArray" ||
937-
name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray")
935+
name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray" ||
936+
name == "SampledTextureCUBE" || name == "SampledTextureCUBEArray")
938937
return true;
939938
}
940939
return false;

tools/clang/lib/SPIRV/LowerTypeVisitor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,8 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
851851
}
852852
if (name == "SampledTexture1D" || name == "SampledTexture1DArray" ||
853853
name == "SampledTexture2D" || name == "SampledTexture2DArray" ||
854-
name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") {
854+
name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray" ||
855+
name == "SampledTextureCUBE" || name == "SampledTextureCUBEArray") {
855856
const auto sampledType = hlsl::GetHLSLResourceResultType(type);
856857
auto loweredType = lowerType(getElementType(astContext, sampledType), rule,
857858
/*isRowMajor*/ llvm::None, srcLoc);
@@ -863,7 +864,9 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
863864
}
864865

865866
const spv::Dim dimension =
866-
name.count("1D") > 0 ? spv::Dim::Dim1D : spv::Dim::Dim2D;
867+
name.count("1D") > 0
868+
? spv::Dim::Dim1D
869+
: (name.count("CUBE") > 0 ? spv::Dim::Cube : spv::Dim::Dim2D);
867870
const bool isArray = name.count("Array") > 0;
868871
const bool isMS = name.count("MS") > 0;
869872

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4409,6 +4409,8 @@ SpirvEmitter::processBufferTextureGetDimensions(const CXXMemberCallExpr *expr) {
44094409
(typeName == "SampledTexture1DArray" && numArgs > 2) ||
44104410
(typeName == "SampledTexture2D" && numArgs > 2) ||
44114411
(typeName == "SampledTexture2DArray" && numArgs > 3) ||
4412+
(typeName == "SampledTextureCUBE" && numArgs > 2) ||
4413+
(typeName == "SampledTextureCUBEArray" && numArgs > 3) ||
44124414
(typeName == "TextureCube" && numArgs > 2) ||
44134415
(typeName == "Texture3D" && numArgs > 3) ||
44144416
(typeName == "Texture1DArray" && numArgs > 2) ||

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ enum ArBasicKind {
206206
AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY,
207207
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS,
208208
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY,
209+
AR_OBJECT_VK_SAMPLED_TEXTURECUBE,
210+
AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY,
209211
#endif // ENABLE_SPIRV_CODEGEN
210212
// SPIRV change ends
211213

@@ -572,6 +574,8 @@ const UINT g_uBasicKindProps[] = {
572574
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY
573575
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS
574576
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY
577+
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURECUBE
578+
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY
575579
#endif // ENABLE_SPIRV_CODEGEN
576580
// SPIRV change ends
577581

@@ -1292,6 +1296,10 @@ static const ArBasicKind g_VKSampledTexture2DMSCT[] = {
12921296
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS, AR_BASIC_UNKNOWN};
12931297
static const ArBasicKind g_VKSampledTexture2DMSArrayCT[] = {
12941298
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY, AR_BASIC_UNKNOWN};
1299+
static const ArBasicKind g_VKSampledTextureCUBECT[] = {
1300+
AR_OBJECT_VK_SAMPLED_TEXTURECUBE, AR_BASIC_UNKNOWN};
1301+
static const ArBasicKind g_VKSampledTextureCUBEArrayCT[] = {
1302+
AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY, AR_BASIC_UNKNOWN};
12951303
#endif
12961304

12971305
// Basic kinds, indexed by a LEGAL_INTRINSIC_COMPTYPES value.
@@ -1361,6 +1369,8 @@ const ArBasicKind *g_LegalIntrinsicCompTypes[] = {
13611369
g_VKSampledTexture2DArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY
13621370
g_VKSampledTexture2DMSCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS
13631371
g_VKSampledTexture2DMSArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS_ARRAY
1372+
g_VKSampledTextureCUBECT, // LICOMPTYPE_VK_SAMPLED_TEXTURECUBE
1373+
g_VKSampledTextureCUBEArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURECUBE_ARRAY
13641374
#endif
13651375
};
13661376
static_assert(
@@ -1423,7 +1433,8 @@ static const ArBasicKind g_ArBasicKindsAsTypes[] = {
14231433
AR_OBJECT_VK_BUFFER_POINTER, AR_OBJECT_VK_SAMPLED_TEXTURE1D,
14241434
AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURE2D,
14251435
AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURE2DMS,
1426-
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY,
1436+
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURECUBE,
1437+
AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY,
14271438
#endif // ENABLE_SPIRV_CODEGEN
14281439
// SPIRV change ends
14291440

@@ -1541,6 +1552,8 @@ static const uint8_t g_ArBasicKindsTemplateCount[] = {
15411552
1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY
15421553
1, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS
15431554
1, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY
1555+
1, // AR_OBJECT_VK_SAMPLED_TEXTURECUBE
1556+
1, // AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY
15441557
#endif // ENABLE_SPIRV_CODEGEN
15451558
// SPIRV change ends
15461559

@@ -1700,6 +1713,8 @@ static const SubscriptOperatorRecord g_ArBasicKindsSubscripts[] = {
17001713
{3, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY
17011714
{2, MipsFalse, SampleTrue}, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS
17021715
{3, MipsFalse, SampleTrue}, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY
1716+
{0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURECUBE
1717+
{0, MipsFalse, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY
17031718
#endif // ENABLE_SPIRV_CODEGEN
17041719
// SPIRV change ends
17051720

@@ -1875,6 +1890,8 @@ static const char *g_ArBasicTypeNames[] = {
18751890
"SampledTexture2DArray",
18761891
"SampledTexture2DMS",
18771892
"SampledTexture2DMSArray",
1893+
"SampledTextureCUBE",
1894+
"SampledTextureCUBEArray",
18781895
#endif // ENABLE_SPIRV_CODEGEN
18791896
// SPIRV change ends
18801897

@@ -2552,6 +2569,14 @@ static void GetIntrinsicMethods(ArBasicKind kind,
25522569
*intrinsics = g_VkSampledTexture2DMSArrayMethods;
25532570
*intrinsicCount = _countof(g_VkSampledTexture2DMSArrayMethods);
25542571
break;
2572+
case AR_OBJECT_VK_SAMPLED_TEXTURECUBE:
2573+
*intrinsics = g_VkSampledTextureCUBEMethods;
2574+
*intrinsicCount = _countof(g_VkSampledTextureCUBEMethods);
2575+
break;
2576+
case AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY:
2577+
*intrinsics = g_VkSampledTextureCUBEArrayMethods;
2578+
*intrinsicCount = _countof(g_VkSampledTextureCUBEArrayMethods);
2579+
break;
25552580
#endif
25562581
case AR_OBJECT_HIT_OBJECT:
25572582
*intrinsics = g_DxHitObjectMethods;
@@ -4162,7 +4187,9 @@ class HLSLExternalSource : public ExternalSemaSource {
41624187
kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D ||
41634188
kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY ||
41644189
kind == AR_OBJECT_VK_SAMPLED_TEXTURE2DMS ||
4165-
kind == AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY) {
4190+
kind == AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY ||
4191+
kind == AR_OBJECT_VK_SAMPLED_TEXTURECUBE ||
4192+
kind == AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY) {
41664193
if (!m_vkNSDecl)
41674194
continue;
41684195
QualType float4Type =
@@ -4997,12 +5024,18 @@ class HLSLExternalSource : public ExternalSemaSource {
49975024
case AR_OBJECT_TEXTURE1D_ARRAY:
49985025
case AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY:
49995026
case AR_OBJECT_TEXTURE2D:
5027+
case AR_OBJECT_VK_SAMPLED_TEXTURE2D:
50005028
case AR_OBJECT_TEXTURE2D_ARRAY:
5029+
case AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY:
50015030
case AR_OBJECT_TEXTURE3D:
50025031
case AR_OBJECT_TEXTURECUBE:
5032+
case AR_OBJECT_VK_SAMPLED_TEXTURECUBE:
50035033
case AR_OBJECT_TEXTURECUBE_ARRAY:
5034+
case AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY:
50045035
case AR_OBJECT_TEXTURE2DMS:
5036+
case AR_OBJECT_VK_SAMPLED_TEXTURE2DMS:
50055037
case AR_OBJECT_TEXTURE2DMS_ARRAY:
5038+
case AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY:
50065039

50075040
case AR_OBJECT_SAMPLER:
50085041
case AR_OBJECT_SAMPLERCOMPARISON:
@@ -5149,10 +5182,12 @@ class HLSLExternalSource : public ExternalSemaSource {
51495182
ResClass = DXIL::ResourceClass::UAV;
51505183
return true;
51515184
case AR_OBJECT_TEXTURECUBE:
5185+
case AR_OBJECT_VK_SAMPLED_TEXTURECUBE:
51525186
ResKind = DXIL::ResourceKind::TextureCube;
51535187
ResClass = DXIL::ResourceClass::SRV;
51545188
return true;
51555189
case AR_OBJECT_TEXTURECUBE_ARRAY:
5190+
case AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY:
51565191
ResKind = DXIL::ResourceKind::TextureCubeArray;
51575192
ResClass = DXIL::ResourceClass::SRV;
51585193
return true;
@@ -6229,13 +6264,13 @@ class HLSLExternalSource : public ExternalSemaSource {
62296264
// Remove this when update intrinsic table not affect other things.
62306265
// Change vector<float,1> into float for bias.
62316266
const unsigned biasOperandID = 3; // return type, sampler, coord, bias.
6232-
DXASSERT(parameterTypeCount > biasOperandID,
6233-
"else operation was misrecognized");
6234-
if (const ExtVectorType *VecTy =
6235-
hlsl::ConvertHLSLVecMatTypeToExtVectorType(
6236-
*m_context, parameterTypes[biasOperandID])) {
6237-
if (VecTy->getNumElements() == 1)
6238-
parameterTypes[biasOperandID] = VecTy->getElementType();
6267+
if (parameterTypeCount > biasOperandID) {
6268+
if (const ExtVectorType *VecTy =
6269+
hlsl::ConvertHLSLVecMatTypeToExtVectorType(
6270+
*m_context, parameterTypes[biasOperandID])) {
6271+
if (VecTy->getNumElements() == 1)
6272+
parameterTypes[biasOperandID] = VecTy->getElementType();
6273+
}
62396274
}
62406275
}
62416276

@@ -11696,12 +11731,18 @@ void hlsl::DiagnoseRegisterType(clang::Sema *self, clang::SourceLocation loc,
1169611731
case AR_OBJECT_TEXTURE1D_ARRAY:
1169711732
case AR_OBJECT_VK_SAMPLED_TEXTURE1D_ARRAY:
1169811733
case AR_OBJECT_TEXTURE2D:
11734+
case AR_OBJECT_VK_SAMPLED_TEXTURE2D:
1169911735
case AR_OBJECT_TEXTURE2D_ARRAY:
11736+
case AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY:
1170011737
case AR_OBJECT_TEXTURE3D:
1170111738
case AR_OBJECT_TEXTURECUBE:
11739+
case AR_OBJECT_VK_SAMPLED_TEXTURECUBE:
1170211740
case AR_OBJECT_TEXTURECUBE_ARRAY:
11741+
case AR_OBJECT_VK_SAMPLED_TEXTURECUBE_ARRAY:
1170311742
case AR_OBJECT_TEXTURE2DMS:
11743+
case AR_OBJECT_VK_SAMPLED_TEXTURE2DMS:
1170411744
case AR_OBJECT_TEXTURE2DMS_ARRAY:
11745+
case AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY:
1170511746
expected = "'t' or 's'";
1170611747
isValid = registerType == 't' || registerType == 's';
1170711748
break;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010
// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
1111
// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown
1212
// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]]
13+
// CHECK: [[type_cube_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float Cube 0 0 0 1 Unknown
14+
// CHECK: [[type_cube_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_cube_image]]
15+
// CHECK: [[type_cube_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float Cube 0 1 0 1 Unknown
16+
// CHECK: [[type_cube_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_cube_image_array]]
1317

1418
vk::SampledTexture1D<float4> tex1d;
1519
vk::SampledTexture1DArray<float4> tex1dArray;
1620
vk::SampledTexture2D<float4> tex2d;
1721
vk::SampledTexture2DArray<float4> tex2dArray;
22+
vk::SampledTextureCUBE<float4> texCube;
23+
vk::SampledTextureCUBEArray<float4> texCubeArray;
1824

1925
void main() {
2026
float2 xy = float2(0.5, 0.5);
@@ -40,4 +46,14 @@ void main() {
4046
// CHECK-NEXT: [[query1da:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1da_load]] %float_0_5
4147
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1da]] 1
4248
float lod4 = tex1dArray.CalculateLevelOfDetailUnclamped(0.5);
49+
50+
// CHECK: [[texCube_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_cube_sampled_image]] %texCube
51+
// CHECK-NEXT: [[query_cube:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[texCube_load]] {{%[0-9]+}}
52+
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query_cube]] 1
53+
float lod5 = texCube.CalculateLevelOfDetailUnclamped(float3(0.5, 0.25, 0.125));
54+
55+
// CHECK: [[texCubeArr_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_cube_sampled_image_array]] %texCubeArray
56+
// CHECK-NEXT: [[query_cube_arr:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[texCubeArr_load]] {{%[0-9]+}}
57+
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query_cube_arr]] 1
58+
float lod6 = texCubeArray.CalculateLevelOfDetailUnclamped(float3(0.5, 0.25, 0.125));
4359
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010
// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
1111
// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown
1212
// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]]
13+
// CHECK: [[type_cube_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float Cube 0 0 0 1 Unknown
14+
// CHECK: [[type_cube_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_cube_image]]
15+
// CHECK: [[type_cube_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float Cube 0 1 0 1 Unknown
16+
// CHECK: [[type_cube_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_cube_image_array]]
1317

1418
vk::SampledTexture1D<float4> tex1d;
1519
vk::SampledTexture1DArray<float4> tex1dArray;
1620
vk::SampledTexture2D<float4> tex2d;
1721
vk::SampledTexture2DArray<float4> tex2dArray;
22+
vk::SampledTextureCUBE<float4> texCube;
23+
vk::SampledTextureCUBEArray<float4> texCubeArray;
1824

1925
void main() {
2026
float2 xy = float2(0.5, 0.5);
@@ -40,4 +46,14 @@ void main() {
4046
// CHECK-NEXT: [[query1da:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1da_load]] %float_0_5
4147
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1da]] 0
4248
float lod4 = tex1dArray.CalculateLevelOfDetail(0.5);
49+
50+
// CHECK: [[texCube_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_cube_sampled_image]] %texCube
51+
// CHECK-NEXT: [[query_cube:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[texCube_load]] {{%[0-9]+}}
52+
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query_cube]] 0
53+
float lod5 = texCube.CalculateLevelOfDetail(float3(0.5, 0.25, 0.125));
54+
55+
// CHECK: [[texCubeArr_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_cube_sampled_image_array]] %texCubeArray
56+
// CHECK-NEXT: [[query_cube_arr:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[texCubeArr_load]] {{%[0-9]+}}
57+
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query_cube_arr]] 0
58+
float lod6 = texCubeArray.CalculateLevelOfDetail(float3(0.5, 0.25, 0.125));
4359
}

tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-alpha.hlsl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@
55
// CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25
66
// CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3
77
// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0
8+
// CHECK: [[v4fc:%[0-9]+]] = OpConstantComposite %v4float %float_0_5 %float_0_25 %float_0 %float_0
89

910
// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
1011
// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
1112
// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown
1213
// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]]
14+
// CHECK: [[type_cube_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float Cube 0 0 0 1 Unknown
15+
// CHECK: [[type_cube_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_cube_image]]
16+
// CHECK: [[type_cube_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float Cube 0 1 0 1 Unknown
17+
// CHECK: [[type_cube_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_cube_image_array]]
1318

1419
vk::SampledTexture2D<float4> tex2d;
1520
vk::SampledTexture2DArray<float4> tex2dArray;
21+
vk::SampledTextureCUBE<float4> texCube;
22+
vk::SampledTextureCUBEArray<float4> texCubeArray;
1623

1724
float4 main() : SV_Target {
1825
uint status;
@@ -53,5 +60,13 @@ float4 main() : SV_Target {
5360
// CHECK: [[val_alpha_array:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex2_load]] [[v3fc]] %int_3 None
5461
val = tex2dArray.GatherAlpha(float3(0.5, 0.25, 0));
5562

63+
// CHECK: [[cube_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_cube_sampled_image]] %texCube
64+
// CHECK: [[val_alpha_cube:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[cube_load]] [[v3fc]] %int_3 None
65+
val = texCube.GatherAlpha(float3(0.5, 0.25, 0));
66+
67+
// CHECK: [[cube_arr_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_cube_sampled_image_array]] %texCubeArray
68+
// CHECK: [[val_alpha_cube_arr:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[cube_arr_load]] [[v4fc]] %int_3 None
69+
val = texCubeArray.GatherAlpha(float4(0.5, 0.25, 0, 0));
70+
5671
return val;
5772
}

tools/clang/test/CodeGenSPIRV/vk.sampledtexture.gather-blue.hlsl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@
55
// CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25
66
// CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3
77
// CHECK: [[v3fc:%[0-9]+]] = OpConstantComposite %v3float %float_0_5 %float_0_25 %float_0
8+
// CHECK: [[v4fc:%[0-9]+]] = OpConstantComposite %v4float %float_0_5 %float_0_25 %float_0 %float_0
89

910
// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
1011
// CHECK: [[type_2d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
1112
// CHECK: [[type_2d_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 1 0 1 Unknown
1213
// CHECK: [[type_2d_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_array]]
14+
// CHECK: [[type_cube_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float Cube 0 0 0 1 Unknown
15+
// CHECK: [[type_cube_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_cube_image]]
16+
// CHECK: [[type_cube_image_array:%[a-zA-Z0-9_]+]] = OpTypeImage %float Cube 0 1 0 1 Unknown
17+
// CHECK: [[type_cube_sampled_image_array:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_cube_image_array]]
1318

1419
vk::SampledTexture2D<float4> tex2d;
1520
vk::SampledTexture2DArray<float4> tex2dArray;
21+
vk::SampledTextureCUBE<float4> texCube;
22+
vk::SampledTextureCUBEArray<float4> texCubeArray;
1623

1724

1825
float4 main() : SV_Target {
@@ -54,5 +61,13 @@ float4 main() : SV_Target {
5461
// CHECK: [[val_blue_array:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[tex2_load]] [[v3fc]] %int_2 None
5562
val = tex2dArray.GatherBlue(float3(0.5, 0.25, 0));
5663

64+
// CHECK: [[cube_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_cube_sampled_image]] %texCube
65+
// CHECK: [[val_blue_cube:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[cube_load]] [[v3fc]] %int_2 None
66+
val = texCube.GatherBlue(float3(0.5, 0.25, 0));
67+
68+
// CHECK: [[cube_arr_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_cube_sampled_image_array]] %texCubeArray
69+
// CHECK: [[val_blue_cube_arr:%[a-zA-Z0-9_]+]] = OpImageGather %v4float [[cube_arr_load]] [[v4fc]] %int_2 None
70+
val = texCubeArray.GatherBlue(float4(0.5, 0.25, 0, 0));
71+
5772
return val;
5873
}

0 commit comments

Comments
 (0)