[llvm] 59e91d4 - [DXIL][Analysis] Make the DXILResource binding optional. NFC
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 25 12:28:01 PDT 2024
Author: Justin Bogner
Date: 2024-07-25T12:27:57-07:00
New Revision: 59e91d4c5094641ffa0763c17599b1d0d7c6fbb0
URL: https://github.com/llvm/llvm-project/commit/59e91d4c5094641ffa0763c17599b1d0d7c6fbb0
DIFF: https://github.com/llvm/llvm-project/commit/59e91d4c5094641ffa0763c17599b1d0d7c6fbb0.diff
LOG: [DXIL][Analysis] Make the DXILResource binding optional. NFC
This makes the binding structure in a DXILResource default to empty
and need a separate call to set up, and also moves the unique ID into
it since bindings are the only place where those are actually used.
This will put us in a better position when dealing with resource
handles in libraries.
Pull Request: https://github.com/llvm/llvm-project/pull/100623
Added:
Modified:
llvm/include/llvm/Analysis/DXILResource.h
llvm/lib/Analysis/DXILResource.cpp
llvm/unittests/Analysis/DXILResourceTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index cca5e0f0bd759..d4006ae10837c 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -17,19 +17,22 @@ class MDTuple;
namespace dxil {
-struct ResourceBinding {
- uint32_t Space;
- uint32_t LowerBound;
- uint32_t Size;
-
- bool operator==(const ResourceBinding &RHS) const {
- return std::tie(Space, LowerBound, Size) ==
- std::tie(RHS.Space, RHS.LowerBound, RHS.Size);
- }
- bool operator!=(const ResourceBinding &RHS) const { return !(*this == RHS); }
-};
-
class ResourceInfo {
+ struct ResourceBinding {
+ uint32_t UniqueID;
+ uint32_t Space;
+ uint32_t LowerBound;
+ uint32_t Size;
+
+ bool operator==(const ResourceBinding &RHS) const {
+ return std::tie(UniqueID, Space, LowerBound, Size) ==
+ std::tie(RHS.UniqueID, RHS.Space, RHS.LowerBound, RHS.Size);
+ }
+ bool operator!=(const ResourceBinding &RHS) const {
+ return !(*this == RHS);
+ }
+ };
+
struct UAVInfo {
bool GloballyCoherent;
bool HasCounter;
@@ -81,12 +84,11 @@ class ResourceInfo {
Value *Symbol;
StringRef Name;
- ResourceBinding Binding;
- uint32_t UniqueID;
-
dxil::ResourceClass RC;
dxil::ResourceKind Kind;
+ ResourceBinding Binding = {};
+
// Resource class dependent properties.
// CBuffer, Sampler, and RawBuffer end here.
union {
@@ -114,70 +116,62 @@ class ResourceInfo {
bool isMultiSample() const;
ResourceInfo(dxil::ResourceClass RC, dxil::ResourceKind Kind, Value *Symbol,
- StringRef Name, ResourceBinding Binding, uint32_t UniqueID)
- : Symbol(Symbol), Name(Name), Binding(Binding), UniqueID(UniqueID),
- RC(RC), Kind(Kind) {}
+ StringRef Name)
+ : Symbol(Symbol), Name(Name), RC(RC), Kind(Kind) {}
public:
static ResourceInfo SRV(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
dxil::ElementType ElementTy, uint32_t ElementCount,
dxil::ResourceKind Kind);
- static ResourceInfo RawBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID);
+ static ResourceInfo RawBuffer(Value *Symbol, StringRef Name);
static ResourceInfo StructuredBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID, uint32_t Stride,
- Align Alignment);
+ uint32_t Stride, Align Alignment);
static ResourceInfo Texture2DMS(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
dxil::ElementType ElementTy,
uint32_t ElementCount, uint32_t SampleCount);
- static ResourceInfo
- Texture2DMSArray(Value *Symbol, StringRef Name, ResourceBinding Binding,
- uint32_t UniqueID, dxil::ElementType ElementTy,
- uint32_t ElementCount, uint32_t SampleCount);
+ static ResourceInfo Texture2DMSArray(Value *Symbol, StringRef Name,
+ dxil::ElementType ElementTy,
+ uint32_t ElementCount,
+ uint32_t SampleCount);
static ResourceInfo UAV(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
dxil::ElementType ElementTy, uint32_t ElementCount,
bool GloballyCoherent, bool IsROV,
dxil::ResourceKind Kind);
static ResourceInfo RWRawBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
bool GloballyCoherent, bool IsROV);
static ResourceInfo RWStructuredBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID, uint32_t Stride,
+ uint32_t Stride,
Align Alignment, bool GloballyCoherent,
bool IsROV, bool HasCounter);
static ResourceInfo RWTexture2DMS(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
dxil::ElementType ElementTy,
uint32_t ElementCount, uint32_t SampleCount,
bool GloballyCoherent);
- static ResourceInfo
- RWTexture2DMSArray(Value *Symbol, StringRef Name, ResourceBinding Binding,
- uint32_t UniqueID, dxil::ElementType ElementTy,
- uint32_t ElementCount, uint32_t SampleCount,
- bool GloballyCoherent);
+ static ResourceInfo RWTexture2DMSArray(Value *Symbol, StringRef Name,
+ dxil::ElementType ElementTy,
+ uint32_t ElementCount,
+ uint32_t SampleCount,
+ bool GloballyCoherent);
static ResourceInfo FeedbackTexture2D(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID,
dxil::SamplerFeedbackType FeedbackTy);
static ResourceInfo
- FeedbackTexture2DArray(Value *Symbol, StringRef Name, ResourceBinding Binding,
- uint32_t UniqueID,
+ FeedbackTexture2DArray(Value *Symbol, StringRef Name,
dxil::SamplerFeedbackType FeedbackTy);
- static ResourceInfo CBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
- uint32_t Size);
+ static ResourceInfo CBuffer(Value *Symbol, StringRef Name, uint32_t Size);
static ResourceInfo Sampler(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
dxil::SamplerType SamplerTy);
+ void bind(uint32_t UniqueID, uint32_t Space, uint32_t LowerBound,
+ uint32_t Size) {
+ Binding.UniqueID = UniqueID;
+ Binding.Space = Space;
+ Binding.LowerBound = LowerBound;
+ Binding.Size = Size;
+ }
+
bool operator==(const ResourceInfo &RHS) const;
MDTuple *getAsMetadata(LLVMContext &Ctx) const;
diff --git a/llvm/lib/Analysis/DXILResource.cpp b/llvm/lib/Analysis/DXILResource.cpp
index d47a73c05a3e5..72cba9d4373bb 100644
--- a/llvm/lib/Analysis/DXILResource.cpp
+++ b/llvm/lib/Analysis/DXILResource.cpp
@@ -64,10 +64,9 @@ bool ResourceInfo::isMultiSample() const {
}
ResourceInfo ResourceInfo::SRV(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
ElementType ElementTy, uint32_t ElementCount,
ResourceKind Kind) {
- ResourceInfo RI(ResourceClass::SRV, Kind, Symbol, Name, Binding, UniqueID);
+ ResourceInfo RI(ResourceClass::SRV, Kind, Symbol, Name);
assert(RI.isTyped() && !(RI.isStruct() || RI.isMultiSample()) &&
"Invalid ResourceKind for SRV constructor.");
RI.Typed.ElementTy = ElementTy;
@@ -75,43 +74,37 @@ ResourceInfo ResourceInfo::SRV(Value *Symbol, StringRef Name,
return RI;
}
-ResourceInfo ResourceInfo::RawBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID) {
- ResourceInfo RI(ResourceClass::SRV, ResourceKind::RawBuffer, Symbol, Name,
- Binding, UniqueID);
+ResourceInfo ResourceInfo::RawBuffer(Value *Symbol, StringRef Name) {
+ ResourceInfo RI(ResourceClass::SRV, ResourceKind::RawBuffer, Symbol, Name);
return RI;
}
ResourceInfo ResourceInfo::StructuredBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID, uint32_t Stride,
- Align Alignment) {
+ uint32_t Stride, Align Alignment) {
ResourceInfo RI(ResourceClass::SRV, ResourceKind::StructuredBuffer, Symbol,
- Name, Binding, UniqueID);
+ Name);
RI.Struct.Stride = Stride;
RI.Struct.Alignment = Alignment;
return RI;
}
ResourceInfo ResourceInfo::Texture2DMS(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID, ElementType ElementTy,
+ ElementType ElementTy,
uint32_t ElementCount,
uint32_t SampleCount) {
- ResourceInfo RI(ResourceClass::SRV, ResourceKind::Texture2DMS, Symbol, Name,
- Binding, UniqueID);
+ ResourceInfo RI(ResourceClass::SRV, ResourceKind::Texture2DMS, Symbol, Name);
RI.Typed.ElementTy = ElementTy;
RI.Typed.ElementCount = ElementCount;
RI.MultiSample.Count = SampleCount;
return RI;
}
-ResourceInfo ResourceInfo::Texture2DMSArray(
- Value *Symbol, StringRef Name, ResourceBinding Binding, uint32_t UniqueID,
- ElementType ElementTy, uint32_t ElementCount, uint32_t SampleCount) {
+ResourceInfo ResourceInfo::Texture2DMSArray(Value *Symbol, StringRef Name,
+ ElementType ElementTy,
+ uint32_t ElementCount,
+ uint32_t SampleCount) {
ResourceInfo RI(ResourceClass::SRV, ResourceKind::Texture2DMSArray, Symbol,
- Name, Binding, UniqueID);
+ Name);
RI.Typed.ElementTy = ElementTy;
RI.Typed.ElementCount = ElementCount;
RI.MultiSample.Count = SampleCount;
@@ -119,11 +112,10 @@ ResourceInfo ResourceInfo::Texture2DMSArray(
}
ResourceInfo ResourceInfo::UAV(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
ElementType ElementTy, uint32_t ElementCount,
bool GloballyCoherent, bool IsROV,
ResourceKind Kind) {
- ResourceInfo RI(ResourceClass::UAV, Kind, Symbol, Name, Binding, UniqueID);
+ ResourceInfo RI(ResourceClass::UAV, Kind, Symbol, Name);
assert(RI.isTyped() && !(RI.isStruct() || RI.isMultiSample()) &&
"Invalid ResourceKind for UAV constructor.");
RI.Typed.ElementTy = ElementTy;
@@ -135,11 +127,8 @@ ResourceInfo ResourceInfo::UAV(Value *Symbol, StringRef Name,
}
ResourceInfo ResourceInfo::RWRawBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID, bool GloballyCoherent,
- bool IsROV) {
- ResourceInfo RI(ResourceClass::UAV, ResourceKind::RawBuffer, Symbol, Name,
- Binding, UniqueID);
+ bool GloballyCoherent, bool IsROV) {
+ ResourceInfo RI(ResourceClass::UAV, ResourceKind::RawBuffer, Symbol, Name);
RI.UAVFlags.GloballyCoherent = GloballyCoherent;
RI.UAVFlags.IsROV = IsROV;
RI.UAVFlags.HasCounter = false;
@@ -147,13 +136,11 @@ ResourceInfo ResourceInfo::RWRawBuffer(Value *Symbol, StringRef Name,
}
ResourceInfo ResourceInfo::RWStructuredBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID,
uint32_t Stride, Align Alignment,
bool GloballyCoherent, bool IsROV,
bool HasCounter) {
ResourceInfo RI(ResourceClass::UAV, ResourceKind::StructuredBuffer, Symbol,
- Name, Binding, UniqueID);
+ Name);
RI.Struct.Stride = Stride;
RI.Struct.Alignment = Alignment;
RI.UAVFlags.GloballyCoherent = GloballyCoherent;
@@ -162,13 +149,12 @@ ResourceInfo ResourceInfo::RWStructuredBuffer(Value *Symbol, StringRef Name,
return RI;
}
-ResourceInfo
-ResourceInfo::RWTexture2DMS(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
- ElementType ElementTy, uint32_t ElementCount,
- uint32_t SampleCount, bool GloballyCoherent) {
- ResourceInfo RI(ResourceClass::UAV, ResourceKind::Texture2DMS, Symbol, Name,
- Binding, UniqueID);
+ResourceInfo ResourceInfo::RWTexture2DMS(Value *Symbol, StringRef Name,
+ ElementType ElementTy,
+ uint32_t ElementCount,
+ uint32_t SampleCount,
+ bool GloballyCoherent) {
+ ResourceInfo RI(ResourceClass::UAV, ResourceKind::Texture2DMS, Symbol, Name);
RI.Typed.ElementTy = ElementTy;
RI.Typed.ElementCount = ElementCount;
RI.UAVFlags.GloballyCoherent = GloballyCoherent;
@@ -178,13 +164,13 @@ ResourceInfo::RWTexture2DMS(Value *Symbol, StringRef Name,
return RI;
}
-ResourceInfo
-ResourceInfo::RWTexture2DMSArray(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
- ElementType ElementTy, uint32_t ElementCount,
- uint32_t SampleCount, bool GloballyCoherent) {
+ResourceInfo ResourceInfo::RWTexture2DMSArray(Value *Symbol, StringRef Name,
+ ElementType ElementTy,
+ uint32_t ElementCount,
+ uint32_t SampleCount,
+ bool GloballyCoherent) {
ResourceInfo RI(ResourceClass::UAV, ResourceKind::Texture2DMSArray, Symbol,
- Name, Binding, UniqueID);
+ Name);
RI.Typed.ElementTy = ElementTy;
RI.Typed.ElementCount = ElementCount;
RI.UAVFlags.GloballyCoherent = GloballyCoherent;
@@ -195,11 +181,9 @@ ResourceInfo::RWTexture2DMSArray(Value *Symbol, StringRef Name,
}
ResourceInfo ResourceInfo::FeedbackTexture2D(Value *Symbol, StringRef Name,
- ResourceBinding Binding,
- uint32_t UniqueID,
SamplerFeedbackType FeedbackTy) {
ResourceInfo RI(ResourceClass::UAV, ResourceKind::FeedbackTexture2D, Symbol,
- Name, Binding, UniqueID);
+ Name);
RI.UAVFlags.GloballyCoherent = false;
RI.UAVFlags.IsROV = false;
RI.UAVFlags.HasCounter = false;
@@ -209,10 +193,9 @@ ResourceInfo ResourceInfo::FeedbackTexture2D(Value *Symbol, StringRef Name,
ResourceInfo
ResourceInfo::FeedbackTexture2DArray(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
SamplerFeedbackType FeedbackTy) {
ResourceInfo RI(ResourceClass::UAV, ResourceKind::FeedbackTexture2DArray,
- Symbol, Name, Binding, UniqueID);
+ Symbol, Name);
RI.UAVFlags.GloballyCoherent = false;
RI.UAVFlags.IsROV = false;
RI.UAVFlags.HasCounter = false;
@@ -221,27 +204,22 @@ ResourceInfo::FeedbackTexture2DArray(Value *Symbol, StringRef Name,
}
ResourceInfo ResourceInfo::CBuffer(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
uint32_t Size) {
- ResourceInfo RI(ResourceClass::CBuffer, ResourceKind::CBuffer, Symbol, Name,
- Binding, UniqueID);
+ ResourceInfo RI(ResourceClass::CBuffer, ResourceKind::CBuffer, Symbol, Name);
RI.CBufferSize = Size;
return RI;
}
ResourceInfo ResourceInfo::Sampler(Value *Symbol, StringRef Name,
- ResourceBinding Binding, uint32_t UniqueID,
SamplerType SamplerTy) {
- ResourceInfo RI(ResourceClass::Sampler, ResourceKind::Sampler, Symbol, Name,
- Binding, UniqueID);
+ ResourceInfo RI(ResourceClass::Sampler, ResourceKind::Sampler, Symbol, Name);
RI.SamplerTy = SamplerTy;
return RI;
}
bool ResourceInfo::operator==(const ResourceInfo &RHS) const {
- if (std::tie(Symbol, Name, Binding, UniqueID, RC, Kind) !=
- std::tie(RHS.Symbol, RHS.Name, RHS.Binding, RHS.UniqueID, RHS.RC,
- RHS.Kind))
+ if (std::tie(Symbol, Name, Binding, RC, Kind) !=
+ std::tie(RHS.Symbol, RHS.Name, RHS.Binding, RHS.RC, RHS.Kind))
return false;
if (isCBuffer())
return CBufferSize == RHS.CBufferSize;
@@ -278,7 +256,7 @@ MDTuple *ResourceInfo::getAsMetadata(LLVMContext &Ctx) const {
Constant::getIntegerValue(I1Ty, APInt(1, V)));
};
- MDVals.push_back(getIntMD(UniqueID));
+ MDVals.push_back(getIntMD(Binding.UniqueID));
MDVals.push_back(ValueAsMetadata::get(Symbol));
MDVals.push_back(MDString::get(Ctx, Name));
MDVals.push_back(getIntMD(Binding.Space));
diff --git a/llvm/unittests/Analysis/DXILResourceTest.cpp b/llvm/unittests/Analysis/DXILResourceTest.cpp
index 036ba40f275d0..554cbd0d8ded7 100644
--- a/llvm/unittests/Analysis/DXILResourceTest.cpp
+++ b/llvm/unittests/Analysis/DXILResourceTest.cpp
@@ -113,9 +113,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
// ByteAddressBuffer Buffer0;
Value *Symbol = UndefValue::get(
StructType::create(Context, {Int32Ty}, "struct.ByteAddressBuffer"));
- ResourceInfo Resource =
- ResourceInfo::RawBuffer(Symbol, "Buffer0", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0);
+ ResourceInfo Resource = ResourceInfo::RawBuffer(Symbol, "Buffer0");
+ Resource.bind(0, 0, 0, 1);
std::pair<uint32_t, uint32_t> Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x0000000bU);
EXPECT_EQ(Props.second, 0U);
@@ -125,9 +124,10 @@ TEST(DXILResource, AnnotationsAndMetadata) {
// RWByteAddressBuffer BufferOut : register(u3, space2);
Symbol = UndefValue::get(
StructType::create(Context, {Int32Ty}, "struct.RWByteAddressBuffer"));
- Resource = ResourceInfo::RWRawBuffer(
- Symbol, "BufferOut", ResourceBinding{2, 3, 1}, /*UniqueID=*/1,
- /*GloballyCoherent=*/false, /*IsROV=*/false);
+ Resource =
+ ResourceInfo::RWRawBuffer(Symbol, "BufferOut",
+ /*GloballyCoherent=*/false, /*IsROV=*/false);
+ Resource.bind(1, 2, 3, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x0000100bU);
EXPECT_EQ(Props.second, 0U);
@@ -141,9 +141,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
StructType::create(Context, {Int32Ty, FloatTy, DoubleTy}, "BufType0");
Symbol = UndefValue::get(StructType::create(
Context, {BufType0}, "class.StructuredBuffer<BufType>"));
- Resource = ResourceInfo::StructuredBuffer(
- Symbol, "Buffer0", ResourceBinding{0, 0, 1}, /*UniqueID=*/0,
- /*Stride=*/16, Align(8));
+ Resource = ResourceInfo::StructuredBuffer(Symbol, "Buffer0",
+ /*Stride=*/16, Align(8));
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x0000030cU);
EXPECT_EQ(Props.second, 0x00000010U);
@@ -155,9 +155,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
Symbol = UndefValue::get(StructType::create(
Context, {Floatx4Ty}, "class.Texture2D<vector<float, 4> >"));
Resource =
- ResourceInfo::SRV(Symbol, "ColorMapTexture", ResourceBinding{0, 2, 1},
- /*UniqueID=*/2, dxil::ElementType::F32,
+ ResourceInfo::SRV(Symbol, "ColorMapTexture", dxil::ElementType::F32,
/*ElementCount=*/4, dxil::ResourceKind::Texture2D);
+ Resource.bind(2, 0, 2, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x00000002U);
EXPECT_EQ(Props.second, 0x00000409U);
@@ -169,9 +169,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
Symbol = UndefValue::get(
StructType::create(Context, {FloatTy}, "class.Texture2DMS<float, 8>"));
Resource =
- ResourceInfo::Texture2DMS(Symbol, "DepthBuffer", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0, dxil::ElementType::F32,
+ ResourceInfo::Texture2DMS(Symbol, "DepthBuffer", dxil::ElementType::F32,
/*ElementCount=*/1, /*SampleCount=*/8);
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x00000003U);
EXPECT_EQ(Props.second, 0x00080109U);
@@ -182,9 +182,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
// FeedbackTexture2D<SAMPLER_FEEDBACK_MIN_MIP> feedbackMinMip;
Symbol = UndefValue::get(
StructType::create(Context, {Int32Ty}, "class.FeedbackTexture2D<0>"));
- Resource = ResourceInfo::FeedbackTexture2D(
- Symbol, "feedbackMinMip", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0, SamplerFeedbackType::MinMip);
+ Resource = ResourceInfo::FeedbackTexture2D(Symbol, "feedbackMinMip",
+ SamplerFeedbackType::MinMip);
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x00001011U);
EXPECT_EQ(Props.second, 0U);
@@ -196,8 +196,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
Symbol = UndefValue::get(StructType::create(
Context, {Int32Ty}, "class.FeedbackTexture2DArray<1>"));
Resource = ResourceInfo::FeedbackTexture2DArray(
- Symbol, "feedbackMipRegion", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0, SamplerFeedbackType::MipRegionUsed);
+ Symbol, "feedbackMipRegion", SamplerFeedbackType::MipRegionUsed);
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x00001012U);
EXPECT_EQ(Props.second, 0x00000001U);
@@ -208,11 +208,10 @@ TEST(DXILResource, AnnotationsAndMetadata) {
// globallycoherent RWTexture2D<int2> OutputTexture : register(u0, space2);
Symbol = UndefValue::get(StructType::create(
Context, {Int32x2Ty}, "class.RWTexture2D<vector<int, 2> >"));
- Resource =
- ResourceInfo::UAV(Symbol, "OutputTexture", ResourceBinding{2, 0, 1},
- /*UniqueID=*/0, dxil::ElementType::I32,
- /*ElementCount=*/2, /*GloballyCoherent=*/1, /*IsROV=*/0,
- dxil::ResourceKind::Texture2D);
+ Resource = ResourceInfo::UAV(Symbol, "OutputTexture", dxil::ElementType::I32,
+ /*ElementCount=*/2, /*GloballyCoherent=*/1,
+ /*IsROV=*/0, dxil::ResourceKind::Texture2D);
+ Resource.bind(0, 2, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x00005002U);
EXPECT_EQ(Props.second, 0x00000204U);
@@ -224,10 +223,10 @@ TEST(DXILResource, AnnotationsAndMetadata) {
Symbol = UndefValue::get(
StructType::create(Context, {Floatx4Ty},
"class.RasterizerOrderedBuffer<vector<float, 4> >"));
- Resource = ResourceInfo::UAV(Symbol, "ROB", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0, dxil::ElementType::F32,
+ Resource = ResourceInfo::UAV(Symbol, "ROB", dxil::ElementType::F32,
/*ElementCount=*/4, /*GloballyCoherent=*/0,
/*IsROV=*/1, dxil::ResourceKind::TypedBuffer);
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x0000300aU);
EXPECT_EQ(Props.second, 0x00000409U);
@@ -240,10 +239,11 @@ TEST(DXILResource, AnnotationsAndMetadata) {
Context, {Floatx3Ty, FloatTy, Int32Ty}, "ParticleMotion");
Symbol = UndefValue::get(StructType::create(
Context, {BufType1}, "class.StructuredBuffer<ParticleMotion>"));
- Resource = ResourceInfo::RWStructuredBuffer(
- Symbol, "g_OutputBuffer", ResourceBinding{0, 2, 1},
- /*UniqueID=*/0, /*Stride=*/20, Align(4), /*GloballyCoherent=*/false,
- /*IsROV=*/false, /*HasCounter=*/true);
+ Resource =
+ ResourceInfo::RWStructuredBuffer(Symbol, "g_OutputBuffer", /*Stride=*/20,
+ Align(4), /*GloballyCoherent=*/false,
+ /*IsROV=*/false, /*HasCounter=*/true);
+ Resource.bind(0, 0, 2, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x0000920cU);
EXPECT_EQ(Props.second, 0x00000014U);
@@ -255,9 +255,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
Symbol = UndefValue::get(StructType::create(
Context, {Int32Ty}, "class.RWTexture2DMSArray<unsigned int, 8>"));
Resource = ResourceInfo::RWTexture2DMSArray(
- Symbol, "g_rw_t2dmsa", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0, dxil::ElementType::U32, /*ElementCount=*/1,
+ Symbol, "g_rw_t2dmsa", dxil::ElementType::U32, /*ElementCount=*/1,
/*SampleCount=*/8, /*GloballyCoherent=*/false);
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x00001008U);
EXPECT_EQ(Props.second, 0x00080105U);
@@ -268,8 +268,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
// cbuffer cb0 { float4 g_X; float4 g_Y; }
Symbol = UndefValue::get(
StructType::create(Context, {Floatx4Ty, Floatx4Ty}, "cb0"));
- Resource = ResourceInfo::CBuffer(Symbol, "cb0", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0, /*Size=*/32);
+ Resource = ResourceInfo::CBuffer(Symbol, "cb0", /*Size=*/32);
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x0000000dU);
EXPECT_EQ(Props.second, 0x00000020U);
@@ -279,9 +279,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
// SamplerState ColorMapSampler : register(s0);
Symbol = UndefValue::get(
StructType::create(Context, {Int32Ty}, "struct.SamplerState"));
- Resource =
- ResourceInfo::Sampler(Symbol, "ColorMapSampler", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0, dxil::SamplerType::Default);
+ Resource = ResourceInfo::Sampler(Symbol, "ColorMapSampler",
+ dxil::SamplerType::Default);
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x0000000eU);
EXPECT_EQ(Props.second, 0U);
@@ -290,9 +290,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
TestMD.get(0, Symbol, "ColorMapSampler", 0, 0, 1, 0, nullptr));
// SamplerComparisonState ShadowSampler {...};
- Resource =
- ResourceInfo::Sampler(Symbol, "CmpSampler", ResourceBinding{0, 0, 1},
- /*UniqueID=*/0, dxil::SamplerType::Comparison);
+ Resource = ResourceInfo::Sampler(Symbol, "CmpSampler",
+ dxil::SamplerType::Comparison);
+ Resource.bind(0, 0, 0, 1);
Props = Resource.getAnnotateProps();
EXPECT_EQ(Props.first, 0x0000800eU);
EXPECT_EQ(Props.second, 0U);
More information about the llvm-commits
mailing list