Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/dxc/dxcapi.internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ enum LEGAL_INTRINSIC_COMPTYPES {
LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY = 60,
LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS = 61,
LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS_ARRAY = 62,
LICOMPTYPE_COUNT = 63
LICOMPTYPE_VK_SAMPLED_TEXTURE3D = 63,
LICOMPTYPE_COUNT = 64
#else
LICOMPTYPE_COUNT = 56
#endif
Expand Down
4 changes: 3 additions & 1 deletion tools/clang/lib/SPIRV/LowerTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,9 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
constexpr size_t sampledTexturePrefixLength = sizeof("SampledTexture") - 1;
StringRef suffix = name.drop_front(sampledTexturePrefixLength);
const spv::Dim dimension =
suffix.startswith("1D") ? spv::Dim::Dim1D : spv::Dim::Dim2D;
suffix.startswith("1D")
? spv::Dim::Dim1D
: (suffix.startswith("2D") ? spv::Dim::Dim2D : spv::Dim::Dim3D);
const bool isArray = suffix.endswith("Array");
const bool isMS = suffix.find("MS") != StringRef::npos;

Expand Down
1 change: 1 addition & 0 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4417,6 +4417,7 @@ SpirvEmitter::processBufferTextureGetDimensions(const CXXMemberCallExpr *expr) {
(typeName == "SampledTexture1DArray" && numArgs > 2) ||
(typeName == "SampledTexture2D" && numArgs > 2) ||
(typeName == "SampledTexture2DArray" && numArgs > 3) ||
(typeName == "SampledTexture3D" && numArgs > 3) ||
(typeName == "TextureCube" && numArgs > 2) ||
(typeName == "Texture3D" && numArgs > 3) ||
(typeName == "Texture1DArray" && numArgs > 2) ||
Expand Down
20 changes: 18 additions & 2 deletions tools/clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ enum ArBasicKind {
AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY,
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS,
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY,
AR_OBJECT_VK_SAMPLED_TEXTURE3D,
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends

Expand Down Expand Up @@ -572,6 +573,7 @@ const UINT g_uBasicKindProps[] = {
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
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SAMPLED_TEXTURE3D
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends

Expand Down Expand Up @@ -1292,6 +1294,8 @@ 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};
static const ArBasicKind g_VKSampledTexture3DCT[] = {
AR_OBJECT_VK_SAMPLED_TEXTURE3D, AR_BASIC_UNKNOWN};
#endif

// Basic kinds, indexed by a LEGAL_INTRINSIC_COMPTYPES value.
Expand Down Expand Up @@ -1361,6 +1365,7 @@ const ArBasicKind *g_LegalIntrinsicCompTypes[] = {
g_VKSampledTexture2DArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2D_ARRAY
g_VKSampledTexture2DMSCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS
g_VKSampledTexture2DMSArrayCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE2DMS_ARRAY
g_VKSampledTexture3DCT, // LICOMPTYPE_VK_SAMPLED_TEXTURE3D
#endif
};
static_assert(
Expand Down Expand Up @@ -1423,7 +1428,7 @@ static const ArBasicKind g_ArBasicKindsAsTypes[] = {
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,
AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY, AR_OBJECT_VK_SAMPLED_TEXTURE3D,
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends

Expand Down Expand Up @@ -1541,6 +1546,7 @@ static const uint8_t g_ArBasicKindsTemplateCount[] = {
1, // AR_OBJECT_VK_SAMPLED_TEXTURE2D_ARRAY
1, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS
1, // AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY
1, // AR_OBJECT_VK_SAMPLED_TEXTURE3D
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends

Expand Down Expand Up @@ -1700,6 +1706,7 @@ static const SubscriptOperatorRecord g_ArBasicKindsSubscripts[] = {
{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
{3, MipsTrue, SampleFalse}, // AR_OBJECT_VK_SAMPLED_TEXTURE3D
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends

Expand Down Expand Up @@ -1875,6 +1882,7 @@ static const char *g_ArBasicTypeNames[] = {
"SampledTexture2DArray",
"SampledTexture2DMS",
"SampledTexture2DMSArray",
"SampledTexture3D",
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends

Expand Down Expand Up @@ -2555,6 +2563,10 @@ static void GetIntrinsicMethods(ArBasicKind kind,
*intrinsics = g_VkSampledTexture2DMSArrayMethods;
*intrinsicCount = _countof(g_VkSampledTexture2DMSArrayMethods);
break;
case AR_OBJECT_VK_SAMPLED_TEXTURE3D:
*intrinsics = g_VkSampledTexture3DMethods;
*intrinsicCount = _countof(g_VkSampledTexture3DMethods);
break;
#endif
case AR_OBJECT_HIT_OBJECT:
*intrinsics = g_DxHitObjectMethods;
Expand Down Expand Up @@ -4165,7 +4177,8 @@ class HLSLExternalSource : public ExternalSemaSource {
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) {
kind == AR_OBJECT_VK_SAMPLED_TEXTURE2DMS_ARRAY ||
kind == AR_OBJECT_VK_SAMPLED_TEXTURE3D) {
if (!m_vkNSDecl)
continue;
QualType float4Type =
Expand Down Expand Up @@ -5153,6 +5166,9 @@ class HLSLExternalSource : public ExternalSemaSource {
ResClass = DXIL::ResourceClass::UAV;
return true;
case AR_OBJECT_TEXTURE3D:
#ifdef ENABLE_SPIRV_CODEGEN
case AR_OBJECT_VK_SAMPLED_TEXTURE3D:
#endif
ResKind = DXIL::ResourceKind::Texture3D;
ResClass = DXIL::ResourceClass::SRV;
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s
// RUN: not %dxc -T ps_6_7 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR

// CHECK: %type_3d_image = OpTypeImage %float 3D 0 0 0 1 Unknown
// CHECK: %type_sampled_image = OpTypeSampledImage %type_3d_image

vk::SampledTexture3D<float4> tex3d;

struct S { int a; };

void main() {
uint3 pos1 = uint3(1, 2, 3);

// CHECK: [[pos1:%[a-zA-Z0-9_]+]] = OpLoad %v3uint %pos1
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex3d
// CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_3d_image [[tex1_load]]
// CHECK: [[fetch_result:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image]] [[pos1]] Lod %uint_0
// CHECK: OpStore %a1 [[fetch_result]]
float4 a1 = tex3d[pos1];

#ifdef ERROR
S s = { 1 };
// CHECK-ERROR: error: no viable overloaded operator[]
float4 val2 = tex3d[s];

int2 i2 = int2(1, 2);
// CHECK-ERROR: error: no viable overloaded operator[]
float4 val3 = tex3d[i2];

int i1 = 1;
// CHECK-ERROR: error: no viable overloaded operator[]
float4 val4 = tex3d[i1];
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %dxc -T ps_6_8 -E main -fcgl %s -spirv | FileCheck %s

// CHECK: OpCapability ImageQuery

// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]

vk::SampledTexture3D<float4> tex3d;

void main() {
float3 xyz = float3(0.5, 0.5, 0.5);

// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[xyz_load:%[a-zA-Z0-9_]+]] = OpLoad %v3float %xyz
// CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[xyz_load]]
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query]] 1
float lod1 = tex3d.CalculateLevelOfDetailUnclamped(xyz);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s

// CHECK: OpCapability ImageQuery

// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]

vk::SampledTexture3D<float4> tex3d;

void main() {
float3 xyz = float3(0.5, 0.5, 0.5);

// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[xyz_load:%[a-zA-Z0-9_]+]] = OpLoad %v3float %xyz
// CHECK-NEXT: [[query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1]] [[xyz_load]]
// CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query]] 0
float lod = tex3d.CalculateLevelOfDetail(xyz);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
// RUN: not %dxc -T ps_6_0 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=ERROR

// CHECK: OpCapability ImageQuery

// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]

vk::SampledTexture3D<float4> tex3d;

void main() {
uint mipLevel = 1;
uint width, height, depth, numLevels;

// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_3d_image]] [[t1_load]]
// CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[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]]
// CHECK-NEXT: [[query1_2:%[0-9]+]] = OpCompositeExtract %uint [[query1]] 2
// CHECK-NEXT: OpStore %depth [[query1_2]]
tex3d.GetDimensions(width, height, depth);

// CHECK: [[t2_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_3d_image]] [[t2_load]]
// CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel
// CHECK-NEXT: [[query2:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image2]] [[mip]]
// CHECK-NEXT: [[query2_0:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 0
// CHECK-NEXT: OpStore %width [[query2_0]]
// CHECK-NEXT: [[query2_1:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 1
// CHECK-NEXT: OpStore %height [[query2_1]]
// CHECK-NEXT: [[query2_2:%[0-9]+]] = OpCompositeExtract %uint [[query2]] 2
// CHECK-NEXT: OpStore %depth [[query2_2]]
// CHECK-NEXT: [[query_level_2:%[0-9]+]] = OpImageQueryLevels %uint [[image2]]
// CHECK-NEXT: OpStore %numLevels [[query_level_2]]
tex3d.GetDimensions(mipLevel, width, height, depth, numLevels);

float f_width, f_height, f_depth, f_numLevels;
// CHECK: [[t3_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[image3:%[0-9]+]] = OpImage [[type_3d_image]] [[t3_load]]
// CHECK-NEXT: [[query3:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image3]] %int_0
// CHECK-NEXT: [[query3_0:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 0
// CHECK-NEXT: [[f_query3_0:%[0-9]+]] = OpConvertUToF %float [[query3_0]]
// CHECK-NEXT: OpStore %f_width [[f_query3_0]]
// CHECK-NEXT: [[query3_1:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 1
// CHECK-NEXT: [[f_query3_1:%[0-9]+]] = OpConvertUToF %float [[query3_1]]
// CHECK-NEXT: OpStore %f_height [[f_query3_1]]
// CHECK-NEXT: [[query3_2:%[0-9]+]] = OpCompositeExtract %uint [[query3]] 2
// CHECK-NEXT: [[f_query3_2:%[0-9]+]] = OpConvertUToF %float [[query3_2]]
// CHECK-NEXT: OpStore %f_depth [[f_query3_2]]
tex3d.GetDimensions(f_width, f_height, f_depth);

// CHECK: [[t4_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[image4:%[0-9]+]] = OpImage [[type_3d_image]] [[t4_load]]
// CHECK-NEXT: [[mip4:%[0-9]+]] = OpLoad %uint %mipLevel
// CHECK-NEXT: [[query4:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image4]] [[mip4]]
// CHECK-NEXT: [[query4_0:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 0
// CHECK-NEXT: [[f_query4_0:%[0-9]+]] = OpConvertUToF %float [[query4_0]]
// CHECK-NEXT: OpStore %f_width [[f_query4_0]]
// CHECK-NEXT: [[query4_1:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 1
// CHECK-NEXT: [[f_query4_1:%[0-9]+]] = OpConvertUToF %float [[query4_1]]
// CHECK-NEXT: OpStore %f_height [[f_query4_1]]
// CHECK-NEXT: [[query4_2:%[0-9]+]] = OpCompositeExtract %uint [[query4]] 2
// CHECK-NEXT: [[f_query4_2:%[0-9]+]] = OpConvertUToF %float [[query4_2]]
// CHECK-NEXT: OpStore %f_depth [[f_query4_2]]
// CHECK-NEXT: [[query_level_4:%[0-9]+]] = OpImageQueryLevels %uint [[image4]]
// CHECK-NEXT: [[f_query_level_4:%[0-9]+]] = OpConvertUToF %float [[query_level_4]]
// CHECK-NEXT: OpStore %f_numLevels [[f_query_level_4]]
tex3d.GetDimensions(mipLevel, f_width, f_height, f_depth, f_numLevels);

int i_width, i_height, i_depth, i_numLevels;
// CHECK: [[t5_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[image5:%[0-9]+]] = OpImage [[type_3d_image]] [[t5_load]]
// CHECK-NEXT: [[query5:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image5]] %int_0
// CHECK-NEXT: [[query5_0:%[0-9]+]] = OpCompositeExtract %uint [[query5]] 0
// CHECK-NEXT: [[query5_0_i:%[0-9]+]] = OpBitcast %int [[query5_0]]
// CHECK-NEXT: OpStore %i_width [[query5_0_i]]
// CHECK-NEXT: [[query5_1:%[0-9]+]] = OpCompositeExtract %uint [[query5]] 1
// CHECK-NEXT: [[query5_1_i:%[0-9]+]] = OpBitcast %int [[query5_1]]
// CHECK-NEXT: OpStore %i_height [[query5_1_i]]
// CHECK-NEXT: [[query5_2:%[0-9]+]] = OpCompositeExtract %uint [[query5]] 2
// CHECK-NEXT: [[query5_2_i:%[0-9]+]] = OpBitcast %int [[query5_2]]
// CHECK-NEXT: OpStore %i_depth [[query5_2_i]]
tex3d.GetDimensions(i_width, i_height, i_depth);

// CHECK: [[t6_load:%[0-9]+]] = OpLoad [[type_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[image6:%[0-9]+]] = OpImage [[type_3d_image]] [[t6_load]]
// CHECK-NEXT: [[mip6:%[0-9]+]] = OpLoad %uint %mipLevel
// CHECK-NEXT: [[query6:%[0-9]+]] = OpImageQuerySizeLod %v3uint [[image6]] [[mip6]]
// CHECK-NEXT: [[query6_0:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 0
// CHECK-NEXT: [[query6_0_i:%[0-9]+]] = OpBitcast %int [[query6_0]]
// CHECK-NEXT: OpStore %i_width [[query6_0_i]]
// CHECK-NEXT: [[query6_1:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 1
// CHECK-NEXT: [[query6_1_i:%[0-9]+]] = OpBitcast %int [[query6_1]]
// CHECK-NEXT: OpStore %i_height [[query6_1_i]]
// CHECK-NEXT: [[query6_2:%[0-9]+]] = OpCompositeExtract %uint [[query6]] 2
// CHECK-NEXT: [[query6_2_i:%[0-9]+]] = OpBitcast %int [[query6_2]]
// CHECK-NEXT: OpStore %i_depth [[query6_2_i]]
// CHECK-NEXT: [[query_level_6:%[0-9]+]] = OpImageQueryLevels %uint [[image6]]
// CHECK-NEXT: [[query_level_6_i:%[0-9]+]] = OpBitcast %int [[query_level_6]]
// CHECK-NEXT: OpStore %i_numLevels [[query_level_6_i]]
tex3d.GetDimensions(mipLevel, i_width, i_height, i_depth, i_numLevels);

#ifdef ERROR
// ERROR: error: Output argument must be an l-value
tex3d.GetDimensions(mipLevel, 0, height, depth, numLevels);

// ERROR: error: Output argument must be an l-value
tex3d.GetDimensions(width, 20, depth);
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s

// CHECK: [[v3ic:%[0-9]+]] = OpConstantComposite %v3int %int_1 %int_2 %int_3

// CHECK: [[type_3d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 3D 0 0 0 1 Unknown
// CHECK: [[type_3d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_3d_image]]

vk::SampledTexture3D<float4> tex3d;

float4 main(int4 location4: A) : SV_Target {
uint 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_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_3d_image]] [[tex]]
// CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod [[lod_0]]
float4 val1 = tex3d.Load(location4);

// 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_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_3d_image]] [[tex]]
// CHECK-NEXT: {{%[0-9]+}} = OpImageFetch %v4float [[tex_img]] [[coord_0]] Lod|ConstOffset [[lod_0]] [[v3ic]]
float4 val2 = tex3d.Load(location4, int3(1, 2, 3));

/////////////////////////////////
/// Using the Status argument ///
/////////////////////////////////

// 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_3d_sampled_image]] %tex3d
// CHECK-NEXT: [[tex_img:%[0-9]+]] = OpImage [[type_3d_image]] [[tex]]
// CHECK-NEXT:[[structResult:%[0-9]+]] = OpImageSparseFetch %SparseResidencyStruct [[tex_img]] [[coord_0]] Lod|ConstOffset [[lod_0]] [[v3ic]]
// 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 = tex3d.Load(location4, int3(1, 2, 3), status);

return 1.0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s

// CHECK: %type_3d_image = OpTypeImage %float 3D 0 0 0 1 Unknown
// CHECK: %type_sampled_image = OpTypeSampledImage %type_3d_image

vk::SampledTexture3D<float4> tex3d;

void main() {
uint3 pos1 = uint3(1, 2, 3);

// CHECK: [[pos1:%[a-zA-Z0-9_]+]] = OpLoad %v3uint %pos1
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex3d
// CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_3d_image [[tex1_load]]
// CHECK: [[fetch_result:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image]] [[pos1]] Lod %uint_2
// CHECK: OpStore %a1 [[fetch_result]]
float4 a1 = tex3d.mips[2][pos1];
}
Loading
Loading