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
2 changes: 2 additions & 0 deletions include/dxc/DXIL/DxilResourceProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace llvm {
class Constant;
class Type;
class Module;
} // namespace llvm

namespace hlsl {
Expand Down Expand Up @@ -89,6 +90,7 @@ struct DxilInst_AnnotateHandle;
namespace resource_helper {
llvm::Constant *getAsConstant(const DxilResourceProperties &, llvm::Type *Ty,
const ShaderModel &);
llvm::Type *GetResourcePropertiesType(llvm::Module &M);
DxilResourceProperties loadPropsFromConstant(const llvm::Constant &C);
DxilResourceProperties
loadPropsFromAnnotateHandle(DxilInst_AnnotateHandle &annotateHandle,
Expand Down
3 changes: 1 addition & 2 deletions lib/DXIL/DxilMetadataHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,8 +1345,7 @@ Metadata *DxilMDHelper::EmitDxilFieldAnnotation(const DxilFieldAnnotation &FA) {
MDVals.emplace_back(Uint32ToConstMD(kDxilFieldAnnotationResPropTag));
MDVals.emplace_back(ValueAsMetadata::get(resource_helper::getAsConstant(
FA.GetResourceProperties(),
m_pModule->GetDxilModule().GetOP()->GetResourcePropertiesType(),
*m_pSM)));
resource_helper::GetResourcePropertiesType(*m_pModule), *m_pSM)));
}
if (DXIL::CompareVersions(m_MinValMajor, m_MinValMinor, 1, 7) >= 0) {
if (FA.HasBitFields()) {
Expand Down
5 changes: 2 additions & 3 deletions lib/DXIL/DxilOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4118,9 +4118,8 @@ OP::OP(LLVMContext &Ctx, Module *pModule)
"dx.types.NodeHandle", pModule);
m_pNodeRecordHandleType = GetOrCreateStructType(
m_Ctx, Type::getInt8PtrTy(m_Ctx), "dx.types.NodeRecordHandle", pModule);
m_pResourcePropertiesType = GetOrCreateStructType(
m_Ctx, {Type::getInt32Ty(m_Ctx), Type::getInt32Ty(m_Ctx)},
"dx.types.ResourceProperties", pModule);
m_pResourcePropertiesType =
hlsl::resource_helper::GetResourcePropertiesType(*pModule);
m_pNodePropertiesType = GetOrCreateStructType(
m_Ctx, {Type::getInt32Ty(m_Ctx), Type::getInt32Ty(m_Ctx)},
"dx.types.NodeInfo", pModule);
Expand Down
12 changes: 12 additions & 0 deletions lib/DXIL/DxilResourceProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Module.h"

using namespace llvm;

Expand Down Expand Up @@ -104,6 +105,17 @@ Constant *getAsConstant(const DxilResourceProperties &RP, Type *Ty,
return nullptr;
}

llvm::Type *GetResourcePropertiesType(Module &M) {
LLVMContext &Ctx = M.getContext();
StringRef Name = "dx.types.ResourceProperties";
if (StructType *ST = M.getTypeByName(Name))
return ST;

Type *Int32Ty = Type::getInt32Ty(Ctx);
Type *Elements[] = {Int32Ty, Int32Ty};
return StructType::create(Ctx, Elements, Name);
}

DxilResourceProperties loadPropsFromConstant(const Constant &C) {
DxilResourceProperties RP;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// REQUIRES: dxil-1-8
// RUN: %dxc -T cs_6_8 -fcgl %s | FileCheck %s

// CHECK: %dx.types.ResourceProperties = type { i32, i32 }
// CHECK: !dx.typeAnnotations = !{![[TYPE_ANNOTATIONS:[0-9]+]]}
// CHECK: ![[TYPE_ANNOTATIONS]] = !{
// CHECK-SAME: void (%struct.RWByteAddressBuffer*)* @"\01?foo@@YAXURWByteAddressBuffer@@@Z", ![[FN_ANN:[0-9]+]]
// CHECK: ![[FN_ANN]] = !{!{{[0-9]+}}, ![[PARAM_ANN:[0-9]+]]}
// CHECK: ![[PARAM_ANN]] = !{i32 0, ![[FIELD_ANN:[0-9]+]], !{{[0-9]+}}}
// CHECK: ![[FIELD_ANN]] = !{
// CHECK-SAME: i32 10, %dx.types.ResourceProperties { i32 4107, i32 0 }

RWByteAddressBuffer OutBuff : register(u0);

void foo(RWByteAddressBuffer Buf) {
Buf.Store(0, 42);
}

[numthreads(8, 1, 1)]
void main() {
foo(OutBuff);
}
Loading