Skip to content
Open
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
12 changes: 7 additions & 5 deletions include/dxc/dxcapi.internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions tools/clang/lib/SPIRV/AstTypeProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,11 +929,7 @@ bool isTexture(QualType type) {
bool isSampledTexture(QualType type) {
if (const auto *rt = type->getAs<RecordType>()) {
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" ||
name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray")
return true;
return name.startswith("SampledTexture");
}
return false;
}
Expand All @@ -950,6 +946,9 @@ bool isTextureMS(QualType type) {
bool isSampledTextureMS(QualType type) {
if (const auto *rt = type->getAs<RecordType>()) {
const auto name = rt->getDecl()->getName();
if (!name.startswith("SampledTexture"))
return false;

if (name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the point here it to allow any SampledTexture, the 2 exact string match just after could be dropped no?

Copy link
Copy Markdown
Collaborator Author

@luciechoi luciechoi Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the util is checking whether it's a multi-sampling texture, so it's necessary we add this second check.

return true;
}
Expand Down
15 changes: 8 additions & 7 deletions tools/clang/lib/SPIRV/LowerTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,8 +850,7 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
assert(visitedTypeStack.size() == visitedTypeStackSize);
return pointerType;
}
if (name == "SampledTexture2D" || name == "SampledTexture2DArray" ||
name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") {
if (name.startswith("SampledTexture")) {
const auto sampledType = hlsl::GetHLSLResourceResultType(type);
auto loweredType = lowerType(getElementType(astContext, sampledType), rule,
/*isRowMajor*/ llvm::None, srcLoc);
Expand All @@ -862,13 +861,15 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
loweredType = spvContext.getUIntType(32);
}

const bool isArray =
(name == "SampledTexture2DArray" || name == "SampledTexture2DMSArray");
const bool isMS =
(name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray");
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;
const bool isArray = suffix.endswith("Array");
const bool isMS = suffix.find("MS") != StringRef::npos;

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);
}
Expand Down
2 changes: 2 additions & 0 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4413,6 +4413,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) ||
Expand Down
41 changes: 39 additions & 2 deletions tools/clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1854,6 +1869,8 @@ static const char *g_ArBasicTypeNames[] = {
"ext_type",
"ext_result_id",
"BufferPointer",
"SampledTexture1D",
"SampledTexture1DArray",
"SampledTexture2D",
"SampledTexture2DArray",
"SampledTexture2DMS",
Expand Down Expand Up @@ -2514,6 +2531,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);
Expand Down Expand Up @@ -4135,7 +4160,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) {
Expand Down Expand Up @@ -4969,7 +4996,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:
Expand Down Expand Up @@ -5074,6 +5103,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;
Expand All @@ -5083,6 +5115,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;
Expand Down Expand Up @@ -11690,7 +11725,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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown
// CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image

vk::SampledTexture1D<float4> tex1d;

struct S { int a; };

void main() {
// CHECK: OpStore %pos1 %uint_1
uint pos1 = 1;

// CHECK: [[pos1:%[a-zA-Z0-9_]+]] = OpLoad %uint %pos1
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
// CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_1d_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 = tex1d[pos1];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some amount of negative testing/implicit cast testing?
Make sure we get proper error if the dimension of the passed param is too narow/long, or if the template type of the texture doesn't match the return type?
Make sure we have no gap between what Clang overload resolution accepts and what our SPIR-V lowerering handles?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


#ifdef ERROR
S s = { 1 };
// CHECK-ERROR: error: no viable overloaded operator[]
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from 'S' to 'unsigned int' for 1st argument
float4 val2 = tex1d[s];

int2 i2 = int2(1, 2);
// CHECK-ERROR: error: no viable overloaded operator[]
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from '{{int2|vector<int, 2>}}' to 'unsigned int' for 1st argument
float4 val3 = tex1d[i2];

int3 i3 = int3(1, 2, 3);
// CHECK-ERROR: error: no viable overloaded operator[]
// CHECK-ERROR: note: candidate function {{.*}} no known conversion from '{{int3|vector<int, 3>}}' to 'unsigned int' for 1st argument
float4 val4 = tex1d[i3];
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %dxc -T ps_6_8 -E main -fcgl %s -spirv | FileCheck %s

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

vk::SampledTexture1D<float4> tex1d;

void main() {
// CHECK: OpStore %x %float_0_5
float x = 0.5;

// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
// CHECK: [[x:%[a-zA-Z0-9_]+]] = OpLoad %float %x
// CHECK: [[lod_query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[x]]
// CHECK: [[unclamped_lod:%[a-zA-Z0-9_]+]] = OpCompositeExtract %float [[lod_query]] 1
// CHECK: OpStore %lod1 [[unclamped_lod]]
float lod1 = tex1d.CalculateLevelOfDetailUnclamped(x);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s

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

vk::SampledTexture1D<float4> tex1d;

void main() {
// CHECK: OpStore %x %float_0_5
float x = 0.5;

// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d
// CHECK: [[x:%[a-zA-Z0-9_]+]] = OpLoad %float %x
// CHECK: [[lod_query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[x]]
// CHECK: [[lod:%[a-zA-Z0-9_]+]] = OpCompositeExtract %float [[lod_query]] 0
// CHECK: OpStore %lod [[lod]]
float lod = tex1d.CalculateLevelOfDetail(x);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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_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]]

vk::SampledTexture1D<float4> tex1d;

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

// CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
// CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_1d_image]] [[t1_load]]
// CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQuerySizeLod %uint [[image1]] %int_0
// CHECK-NEXT: OpStore %width [[query1]]
tex1d.GetDimensions(width);

// CHECK: [[t2_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
// CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_1d_image]] [[t2_load]]
// CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel
// CHECK-NEXT: [[query2:%[0-9]+]] = OpImageQuerySizeLod %uint [[image2]] [[mip]]
// CHECK-NEXT: OpStore %width [[query2]]
// CHECK-NEXT: [[query_level_2:%[0-9]+]] = OpImageQueryLevels %uint [[image2]]
// CHECK-NEXT: OpStore %numLevels [[query_level_2]]
tex1d.GetDimensions(mipLevel, width, numLevels);

float f_width, f_height, f_numLevels;
// CHECK: [[t3_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
// CHECK-NEXT: [[image3:%[0-9]+]] = OpImage [[type_1d_image]] [[t3_load]]
// CHECK-NEXT: [[query3:%[0-9]+]] = OpImageQuerySizeLod %uint [[image3]] %int_0
// CHECK-NEXT: [[f_query3:%[0-9]+]] = OpConvertUToF %float [[query3]]
// CHECK-NEXT: OpStore %f_width [[f_query3]]
tex1d.GetDimensions(f_width);

// CHECK: [[t4_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
// CHECK-NEXT: [[image4:%[0-9]+]] = OpImage [[type_1d_image]] [[t4_load]]
// CHECK-NEXT: [[mip4:%[0-9]+]] = OpLoad %uint %mipLevel
// CHECK-NEXT: [[query4:%[0-9]+]] = OpImageQuerySizeLod %uint [[image4]] [[mip4]]
// CHECK-NEXT: [[f_query4:%[0-9]+]] = OpConvertUToF %float [[query4]]
// CHECK-NEXT: OpStore %f_width [[f_query4]]
// 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]]
tex1d.GetDimensions(mipLevel, f_width, f_numLevels);

int i_width, i_height, i_numLevels;
// CHECK: [[t5_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
// CHECK-NEXT: [[image5:%[0-9]+]] = OpImage [[type_1d_image]] [[t5_load]]
// CHECK-NEXT: [[query5:%[0-9]+]] = OpImageQuerySizeLod %uint [[image5]] %int_0
// CHECK-NEXT: [[query5_i:%[0-9]+]] = OpBitcast %int [[query5]]
// CHECK-NEXT: OpStore %i_width [[query5_i]]
tex1d.GetDimensions(i_width);

// CHECK: [[t6_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d
// CHECK-NEXT: [[image6:%[0-9]+]] = OpImage [[type_1d_image]] [[t6_load]]
// CHECK-NEXT: [[mip6:%[0-9]+]] = OpLoad %uint %mipLevel
// CHECK-NEXT: [[query6:%[0-9]+]] = OpImageQuerySizeLod %uint [[image6]] [[mip6]]
// CHECK-NEXT: [[query6_i:%[0-9]+]] = OpBitcast %int [[query6]]
// CHECK-NEXT: OpStore %i_width [[query6_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]]
tex1d.GetDimensions(mipLevel, i_width, i_numLevels);

#ifdef ERROR
// ERROR: error: no matching member function for call to 'GetDimensions'
tex1d.GetDimensions(mipLevel, 0, height, numLevels);

// ERROR: error: no matching member function for call to 'GetDimensions'
tex1d.GetDimensions(width, 20);
#endif
}
Loading
Loading