Skip to content

Commit 8030b4e

Browse files
committed
Implement optional arguments
1 parent 0143b0b commit 8030b4e

File tree

11 files changed

+152
-91
lines changed

11 files changed

+152
-91
lines changed

tools/clang/include/clang/AST/HlslTypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ DeclareVkBufferPointerType(clang::ASTContext &context,
409409

410410
clang::CXXRecordDecl *DeclareVkSampledTexture2DType(
411411
clang::ASTContext &context, clang::DeclContext *declContext,
412-
clang::QualType float2Type, clang::QualType defaultTextureType);
412+
clang::QualType float2Type, clang::QualType int2Type,
413+
clang::QualType float4Type);
413414

414415
clang::CXXRecordDecl *DeclareInlineSpirvType(clang::ASTContext &context,
415416
clang::DeclContext *declContext,
@@ -551,7 +552,6 @@ bool IsPatchConstantFunctionDecl(const clang::FunctionDecl *FD);
551552
bool IsVKBufferPointerType(clang::QualType type);
552553
clang::QualType GetVKBufferPointerBufferType(clang::QualType type);
553554
unsigned GetVKBufferPointerAlignment(clang::QualType type);
554-
bool IsVKSampledTexture2DType(clang::QualType type);
555555
#endif
556556

557557
/// <summary>Adds a constructor declaration to the specified class

tools/clang/include/clang/SPIRV/SpirvBuilder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ class SpirvBuilder {
286286
/// If compareVal is given a non-zero value, *Dref* variants of OpImageSample*
287287
/// will be generated.
288288
///
289+
/// If imageType is not a sampled image type, the OpSampledImage* instructions
290+
/// will be generated.
291+
///
289292
/// If lod or grad is given a non-zero value, *ExplicitLod variants of
290293
/// OpImageSample* will be generated; otherwise, *ImplicitLod variant will
291294
/// be generated.

tools/clang/lib/AST/ASTContextHLSL.cpp

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,13 +1369,15 @@ CXXRecordDecl *hlsl::DeclareNodeOrRecordType(
13691369
}
13701370

13711371
#ifdef ENABLE_SPIRV_CODEGEN
1372-
CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType(
1373-
ASTContext &context, DeclContext *declContext, QualType float2Type,
1374-
QualType defaultTextureType) {
1375-
// TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Later
1376-
// generalize these to all SampledTexture types.
1372+
CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType(ASTContext &context,
1373+
DeclContext *declContext,
1374+
QualType float2Type,
1375+
QualType int2Type,
1376+
QualType float4Type) {
13771377
BuiltinTypeDeclBuilder Builder(declContext, "SampledTexture2D",
13781378
TagDecl::TagKind::TTK_Struct);
1379+
1380+
QualType defaultTextureType = float4Type;
13791381
TemplateTypeParmDecl *TyParamDecl =
13801382
Builder.addTypeTemplateParam("SampledTextureType", defaultTextureType);
13811383

@@ -1384,8 +1386,10 @@ CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType(
13841386
QualType paramType = QualType(TyParamDecl->getTypeForDecl(), 0);
13851387
CXXRecordDecl *recordDecl = Builder.getRecordDecl();
13861388

1389+
QualType floatType = context.FloatTy;
1390+
QualType uintType = context.UnsignedIntTy;
13871391
// Add Sample method
1388-
// sampledtype Sample(float2 location)
1392+
// Sample(location)
13891393
CXXMethodDecl *sampleDecl = CreateObjectFunctionDeclarationWithParams(
13901394
context, recordDecl, paramType, ArrayRef<QualType>(float2Type),
13911395
ArrayRef<StringRef>(StringRef("location")),
@@ -1394,6 +1398,41 @@ CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType(
13941398
sampleDecl->addAttr(HLSLIntrinsicAttr::CreateImplicit(
13951399
context, "op", "",
13961400
static_cast<int>(hlsl::IntrinsicOp::MOP_Sample)));
1401+
sampleDecl->addAttr(HLSLCXXOverloadAttr::CreateImplicit(context));
1402+
1403+
// Sample(location, offset)
1404+
QualType params2[] = {float2Type, int2Type};
1405+
StringRef names2[] = {"location", "offset"};
1406+
CXXMethodDecl *sampleDecl2 = CreateObjectFunctionDeclarationWithParams(
1407+
context, recordDecl, paramType, params2, names2,
1408+
context.DeclarationNames.getIdentifier(&context.Idents.get("Sample")),
1409+
/*isConst*/ true);
1410+
sampleDecl2->addAttr(HLSLIntrinsicAttr::CreateImplicit(
1411+
context, "op", "", static_cast<int>(hlsl::IntrinsicOp::MOP_Sample)));
1412+
sampleDecl2->addAttr(HLSLCXXOverloadAttr::CreateImplicit(context));
1413+
1414+
// Sample(location, offset, clamp)
1415+
QualType params3[] = {float2Type, int2Type, floatType};
1416+
StringRef names3[] = {"location", "offset", "clamp"};
1417+
CXXMethodDecl *sampleDecl3 = CreateObjectFunctionDeclarationWithParams(
1418+
context, recordDecl, paramType, params3, names3,
1419+
context.DeclarationNames.getIdentifier(&context.Idents.get("Sample")),
1420+
/*isConst*/ true);
1421+
sampleDecl3->addAttr(HLSLIntrinsicAttr::CreateImplicit(
1422+
context, "op", "", static_cast<int>(hlsl::IntrinsicOp::MOP_Sample)));
1423+
sampleDecl3->addAttr(HLSLCXXOverloadAttr::CreateImplicit(context));
1424+
1425+
// Sample(location, offset, clamp, status)
1426+
QualType params4[] = {float2Type, int2Type, floatType,
1427+
context.getLValueReferenceType(uintType)};
1428+
StringRef names4[] = {"location", "offset", "clamp", "status"};
1429+
CXXMethodDecl *sampleDecl4 = CreateObjectFunctionDeclarationWithParams(
1430+
context, recordDecl, paramType, params4, names4,
1431+
context.DeclarationNames.getIdentifier(&context.Idents.get("Sample")),
1432+
/*isConst*/ true);
1433+
sampleDecl4->addAttr(HLSLIntrinsicAttr::CreateImplicit(
1434+
context, "op", "", static_cast<int>(hlsl::IntrinsicOp::MOP_Sample)));
1435+
sampleDecl4->addAttr(HLSLCXXOverloadAttr::CreateImplicit(context));
13971436

13981437
Builder.completeDefinition();
13991438
return recordDecl;

tools/clang/lib/AST/HlslTypes.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -817,15 +817,6 @@ unsigned GetVKBufferPointerAlignment(clang::QualType type) {
817817
"cannot get pointer alignment for type that is not a vk::BufferPointer");
818818
return bpParams.getValue().second;
819819
}
820-
821-
bool IsVKSampledTexture2DType(clang::QualType type) {
822-
return type ->isRecordType() &&
823-
type->getAs<RecordType>()
824-
->getDecl()
825-
->getName()
826-
.equals("SampledTexture2D");
827-
}
828-
829820
#endif
830821

831822
QualType GetHLSLResourceResultType(QualType type) {

tools/clang/lib/SPIRV/SpirvBuilder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,11 @@ SpirvInstruction *SpirvBuilder::createImageSample(
620620
assert(lod == nullptr || minLod == nullptr);
621621

622622
// An OpSampledImage is required to do the image sampling.
623-
// An OpSampledImage is required to do the image sampling.
623+
// Skip creating OpSampledImage if the imageType is a sampled texture.
624624
SpirvInstruction *sampledImage = nullptr;
625625
if (isSampledTexture(imageType)) {
626+
assert(!sampler &&
627+
"sampler must be null when sampling from a sampled texture");
626628
sampledImage = image;
627629
} else {
628630
sampledImage = createSampledImage(imageType, image, sampler, loc, range);

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5823,44 +5823,58 @@ SpirvEmitter::processTextureSampleGather(const CXXMemberCallExpr *expr,
58235823
const auto numArgs = expr->getNumArgs();
58245824
const auto loc = expr->getExprLoc();
58255825
const auto range = expr->getSourceRange();
5826-
const bool hasStatusArg =
5827-
expr->getArg(numArgs - 1)->getType()->isUnsignedIntegerType();
5828-
5829-
SpirvInstruction *clamp = nullptr;
5830-
if (numArgs > 2 && expr->getArg(2)->getType()->isFloatingType())
5831-
clamp = doExpr(expr->getArg(2));
5832-
else if (numArgs > 3 && expr->getArg(3)->getType()->isFloatingType())
5833-
clamp = doExpr(expr->getArg(3));
5834-
const bool hasClampArg = (clamp != 0);
5835-
const auto status =
5836-
hasStatusArg ? doExpr(expr->getArg(numArgs - 1)) : nullptr;
5837-
5838-
// Subtract 1 for status (if it exists), subtract 1 for clamp (if it exists),
5839-
// and subtract 2 for sampler_state and location.
5840-
const bool hasOffsetArg = numArgs - hasStatusArg - hasClampArg - 2 > 0;
58415826

58425827
const auto *imageExpr = expr->getImplicitObjectArgument();
58435828
const QualType imageType = imageExpr->getType();
58445829

58455830
if (isSampledTexture(imageType)) {
58465831
auto *sampledImage = loadIfGLValue(imageExpr);
58475832
auto *coordinate = doExpr(expr->getArg(0));
5833+
SpirvInstruction *constOffset = nullptr;
5834+
SpirvInstruction *varOffset = nullptr;
5835+
SpirvInstruction *clamp = nullptr;
5836+
SpirvInstruction *status = nullptr;
5837+
5838+
if (numArgs > 1) {
5839+
handleOffsetInMethodCall(expr, 1, &constOffset, &varOffset);
5840+
}
5841+
if (numArgs > 2) {
5842+
clamp = doExpr(expr->getArg(2));
5843+
}
5844+
if (numArgs > 3) {
5845+
status = doExpr(expr->getArg(3));
5846+
}
5847+
58485848
const auto retType = expr->getDirectCallee()->getReturnType();
5849-
return createImageSample(retType, imageType, sampledImage, /*sampler*/ nullptr,
5850-
coordinate,
5851-
/*compareVal*/ nullptr, /*bias*/ nullptr,
5852-
/*lod*/ nullptr, {nullptr, nullptr},
5853-
/*constOffset*/ nullptr, /*varOffset*/ nullptr,
5854-
/*constOffsets*/ nullptr, /*sample*/ nullptr,
5855-
/*minLod*/ nullptr, /*residencyCodeId*/ nullptr,
5856-
loc, range);
5849+
return createImageSample(
5850+
retType, imageType, sampledImage, /*sampler*/ nullptr, coordinate,
5851+
/*compareVal*/ nullptr, /*bias*/ nullptr,
5852+
/*lod*/ nullptr, {nullptr, nullptr}, constOffset, varOffset,
5853+
/*constOffsets*/ nullptr, /*sample*/ nullptr,
5854+
/*minLod*/ clamp, status, loc, range);
58575855
}
58585856

58595857
auto *image = loadIfGLValue(imageExpr);
58605858
auto *sampler = doExpr(expr->getArg(0));
58615859
auto *coordinate = doExpr(expr->getArg(1));
58625860
// .Sample()/.Gather() may have a third optional paramter for offset.
58635861
SpirvInstruction *constOffset = nullptr, *varOffset = nullptr;
5862+
5863+
const bool hasStatusArg =
5864+
expr->getArg(numArgs - 1)->getType()->isUnsignedIntegerType();
5865+
5866+
SpirvInstruction *clamp = nullptr;
5867+
if (numArgs > 2 && expr->getArg(2)->getType()->isFloatingType())
5868+
clamp = doExpr(expr->getArg(2));
5869+
else if (numArgs > 3 && expr->getArg(3)->getType()->isFloatingType())
5870+
clamp = doExpr(expr->getArg(3));
5871+
const bool hasClampArg = (clamp != 0);
5872+
const auto status =
5873+
hasStatusArg ? doExpr(expr->getArg(numArgs - 1)) : nullptr;
5874+
5875+
// Subtract 1 for status (if it exists), subtract 1 for clamp (if it exists),
5876+
// and subtract 2 for sampler_state and location.
5877+
const bool hasOffsetArg = numArgs - hasStatusArg - hasClampArg - 2 > 0;
58645878
if (hasOffsetArg)
58655879
handleOffsetInMethodCall(expr, 2, &constOffset, &varOffset);
58665880

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4016,14 +4016,14 @@ class HLSLExternalSource : public ExternalSemaSource {
40164016
} else if (kind == AR_OBJECT_VK_SAMPLED_TEXTURE2D) {
40174017
if (!m_vkNSDecl)
40184018
continue;
4019-
QualType float2Type =
4020-
LookupVectorType(HLSLScalarType::HLSLScalarType_float, 2);
4021-
QualType float4Type =
4022-
LookupVectorType(HLSLScalarType::HLSLScalarType_float, 4);
4023-
recordDecl = DeclareVkSampledTexture2DType(*m_context, m_vkNSDecl,
4024-
float2Type, float4Type);
4019+
recordDecl = DeclareVkSampledTexture2DType(
4020+
*m_context, m_vkNSDecl,
4021+
LookupVectorType(HLSLScalarType::HLSLScalarType_float, 2),
4022+
LookupVectorType(HLSLScalarType::HLSLScalarType_int, 2),
4023+
LookupVectorType(HLSLScalarType::HLSLScalarType_float, 4));
40254024
recordDecl->setImplicit(true);
4026-
m_vkSampledTexture2DTemplateDecl = recordDecl->getDescribedClassTemplate();
4025+
m_vkSampledTexture2DTemplateDecl =
4026+
recordDecl->getDescribedClassTemplate();
40274027
}
40284028
#endif
40294029
else if (templateArgCount == 0) {

tools/clang/test/CodeGenSPIRV/texture.array.sample.hlsl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ float4 main() : SV_Target {
4242
float4 val3 = t3.Sample(gSampler, float4(0.5, 0.25, 0.125, 1));
4343

4444
float clamp;
45-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
46-
// CHECK-NEXT: [[t1_0:%[0-9]+]] = OpLoad %type_1d_image_array %t1
45+
// CHECK: [[t1_0:%[0-9]+]] = OpLoad %type_1d_image_array %t1
4746
// CHECK-NEXT: [[gSampler_2:%[0-9]+]] = OpLoad %type_sampler %gSampler
47+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
4848
// CHECK-NEXT: [[sampledImg_2:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1_0]] [[gSampler_2]]
4949
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg_2]] [[v2fc]] ConstOffset|MinLod %int_1 [[clamp]]
5050
float4 val4 = t1.Sample(gSampler, float2(0.5, 1), 1, clamp);
@@ -56,10 +56,10 @@ float4 main() : SV_Target {
5656
float4 val5 = t3.Sample(gSampler, float4(0.5, 0.25, 0.125, 1), /*clamp*/ 1.5);
5757

5858
uint status;
59-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
60-
// CHECK-NEXT: [[t1_1:%[0-9]+]] = OpLoad %type_1d_image_array %t1
61-
// CHECK-NEXT: [[gSampler_4:%[0-9]+]] = OpLoad %type_sampler %gSampler
62-
// CHECK-NEXT: [[sampledImg_4:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1_1]] [[gSampler_4]]
59+
// CHECK: [[t1_1:%[0-9]+]] = OpLoad %type_1d_image_array %t1
60+
// CHECK-NEXT: [[gSampler_4:%[0-9]+]] = OpLoad %type_sampler %gSampler
61+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
62+
// CHECK-NEXT: [[sampledImg_4:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1_1]] [[gSampler_4]]
6363
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[sampledImg_4]] [[v2fc]] ConstOffset|MinLod %int_1 [[clamp_0]]
6464
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0
6565
// CHECK-NEXT: OpStore %status [[status]]

tools/clang/test/CodeGenSPIRV/texture.sample.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ float4 main(int2 offset: A) : SV_Target {
5151
float4 val4 = t4.Sample(gSampler, float3(0.5, 0.25, 0.3));
5252

5353
float clamp;
54-
// CHECK: [[clamp:%[0-9]+]] = OpLoad %float %clamp
55-
// CHECK-NEXT: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image %t2
54+
// CHECK: [[t2_0:%[0-9]+]] = OpLoad %type_2d_image %t2
5655
// CHECK-NEXT: [[gSampler_3:%[0-9]+]] = OpLoad %type_sampler %gSampler
56+
// CHECK-NEXT: [[clamp:%[0-9]+]] = OpLoad %float %clamp
5757
// CHECK-NEXT: [[sampledImg_3:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_0]] [[gSampler_3]]
5858
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg_3]] [[v2fc]] ConstOffset|MinLod [[v2ic]] [[clamp]]
5959
float4 val5 = t2.Sample(gSampler, float2(0.5, 0.25), int2(2, 3), clamp);
@@ -65,9 +65,9 @@ float4 main(int2 offset: A) : SV_Target {
6565
float4 val6 = t4.Sample(gSampler, float3(0.5, 0.25, 0.3), /*clamp*/ 2.0f);
6666

6767
uint status;
68-
// CHECK: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
69-
// CHECK-NEXT: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image %t2
68+
// CHECK: [[t2_1:%[0-9]+]] = OpLoad %type_2d_image %t2
7069
// CHECK-NEXT: [[gSampler_5:%[0-9]+]] = OpLoad %type_sampler %gSampler
70+
// CHECK-NEXT: [[clamp_0:%[0-9]+]] = OpLoad %float %clamp
7171
// CHECK-NEXT: [[sampledImg_5:%[0-9]+]] = OpSampledImage %type_sampled_image_0 [[t2_1]] [[gSampler_5]]
7272
// CHECK-NEXT: [[structResult:%[0-9]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[sampledImg_5]] [[v2fc]] ConstOffset|MinLod [[v2ic]] [[clamp_0]]
7373
// CHECK-NEXT: [[status:%[0-9]+]] = OpCompositeExtract %uint [[structResult]] 0
Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
1-
// RUN: %dxc -T ps_6_0 -E main %s -spirv | FileCheck %s
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
22

3-
// CHECK: [[type_2d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
4-
// CHECK: [[type_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image]]
5-
// CHECK: [[ptr_type:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image]]
3+
// CHECK: OpCapability MinLod
4+
// CHECK: OpCapability SparseResidency
65

7-
// CHECK: [[tex:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type]] UniformConstant
8-
// CHECK: [[in_var_TEXCOORD:%[a-zA-Z0-9_]+]] = OpVariable %_ptr_Input_v2float Input
9-
// CHECK: [[out_var_SV_Target:%[a-zA-Z0-9_]+]] = OpVariable %_ptr_Output_v4float Output
6+
// CHECK: [[v2fc:%[0-9]+]] = OpConstantComposite %v2float %float_0_5 %float_0_25
7+
// CHECK: [[v2ic:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_3
108

11-
vk::SampledTexture2D<float4> tex : register(t0);
9+
// CHECK: [[type_2d_image_1:%[a-zA-Z0-9_]+]] = OpTypeImage %float 2D 0 0 0 1 Unknown
10+
// CHECK: [[type_sampled_image_1:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_1]]
11+
// CHECK: [[ptr_type_1:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_1]]
1212

13-
float4 main(float2 uv : TEXCOORD) : SV_Target {
14-
// CHECK: [[tex_coord:%[a-zA-Z0-9_]+]] = OpLoad %v2float [[in_var_TEXCOORD]]
15-
// CHECK: [[tex_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image]] [[tex]]
16-
// CHECK: [[sampled_result:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex_load]] [[tex_coord]] None
17-
// CHECK: OpStore [[out_var_SV_Target]] [[sampled_result]]
18-
return tex.Sample(uv);
13+
// CHECK: [[type_2d_image_2:%[a-zA-Z0-9_]+]] = OpTypeImage %uint 2D 0 0 0 1 Unknown
14+
// CHECK: [[type_sampled_image_2:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_2d_image_2]]
15+
// CHECK: [[ptr_type_2:%[a-zA-Z0-9_]+]] = OpTypePointer UniformConstant [[type_sampled_image_2]]
16+
17+
// CHECK: [[tex1:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant
18+
// CHECK: [[tex2:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_1]] UniformConstant
19+
// CHECK: [[tex3:%[a-zA-Z0-9_]+]] = OpVariable [[ptr_type_2]] UniformConstant
20+
21+
vk::SampledTexture2D tex1 : register(t0);
22+
vk::SampledTexture2D<float4> tex2 : register(t1);
23+
vk::SampledTexture2D<uint> tex3 : register(t2);
24+
25+
float4 main() : SV_Target {
26+
// CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex1]]
27+
// CHECK: [[sampled_result1:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex1_load]] [[v2fc]] None
28+
float4 val1 = tex1.Sample(float2(0.5, 0.25));
29+
30+
// CHECK: [[tex2_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex2]]
31+
// CHECK: [[sampled_result2:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex2_load]] [[v2fc]] ConstOffset [[v2ic]]
32+
float4 val2 = tex2.Sample(float2(0.5, 0.25), int2(2, 3));
33+
34+
// CHECK: [[tex3_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex2]]
35+
// CHECK: [[sampled_result3:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4float [[tex3_load]] [[v2fc]] ConstOffset|MinLod [[v2ic]] %float_1
36+
float4 val3 = tex2.Sample(float2(0.5, 0.25), int2(2, 3), 1.0f);
37+
38+
// CHECK: [[tex4_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_1]] [[tex2]]
39+
// CHECK: [[sampled_result4:%[a-zA-Z0-9_]+]] = OpImageSparseSampleImplicitLod %SparseResidencyStruct [[tex4_load]] [[v2fc]] ConstOffset|MinLod [[v2ic]] %float_1
40+
// CHECK: [[status_0:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result4]] 0
41+
// CHECK: OpStore %status [[status_0]]
42+
uint status;
43+
float4 val4 = tex2.Sample(float2(0.5, 0.25), int2(2, 3), 1.0f, status);
44+
45+
// CHECK: [[tex5_load:%[a-zA-Z0-9_]+]] = OpLoad [[type_sampled_image_2]] [[tex3]]
46+
// CHECK: [[sampled_result5:%[a-zA-Z0-9_]+]] = OpImageSampleImplicitLod %v4uint [[tex5_load]] [[v2fc]] None
47+
// CHECK: [[val5:%[a-zA-Z0-9_]+]] = OpCompositeExtract %uint [[sampled_result5]] 0
48+
uint val5 = tex3.Sample(float2(0.5, 0.25));
49+
return 1.0;
1950
}

0 commit comments

Comments
 (0)