[llvm-branch-commits] [DirectX] Implement metadata lowering for resources (PR #104447)

Xiang Li via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 20 06:58:27 PDT 2024


================
@@ -13,27 +13,52 @@
 #include "DXILShaderFlags.h"
 #include "DirectX.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/Analysis/DXILResource.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
 #include "llvm/TargetParser/Triple.h"
 
 using namespace llvm;
 using namespace llvm::dxil;
 
-static void emitResourceMetadata(Module &M,
+static void emitResourceMetadata(Module &M, const DXILResourceMap &DRM,
                                  const dxil::Resources &MDResources) {
-  Metadata *SRVMD = nullptr, *UAVMD = nullptr, *CBufMD = nullptr,
-           *SmpMD = nullptr;
-  bool HasResources = false;
+  LLVMContext &Context = M.getContext();
+
+  SmallVector<Metadata *> SRVs, UAVs, CBufs, Smps;
+  for (auto [_, RI] : DRM) {
+    switch (RI.getResourceClass()) {
----------------
python3kgae wrote:

For a resource array like `Buffer<float4> B[10]` which used `B[2]` and `B[5]`. Will `B[2]` and `B[5]` both in DRM and get same RI?

https://github.com/llvm/llvm-project/pull/104447


More information about the llvm-branch-commits mailing list