Skip to content
Merged
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
8 changes: 7 additions & 1 deletion llvm/lib/Target/DirectX/DXContainerGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "llvm/Support/MD5.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <cstdint>
#include <optional>

using namespace llvm;
Expand Down Expand Up @@ -193,7 +194,12 @@ void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
dxbc::PSV::v2::ResourceBindInfo BindInfo;
BindInfo.Type = Type;
BindInfo.LowerBound = Binding.LowerBound;
BindInfo.UpperBound = Binding.LowerBound + Binding.Size - 1;
assert(Binding.Size == UINT32_MAX ||
(uint64_t)Binding.LowerBound + Binding.Size - 1 <= UINT32_MAX &&
"Resource range is too large");
BindInfo.UpperBound = (Binding.Size == UINT32_MAX)
? UINT32_MAX
: Binding.LowerBound + Binding.Size - 1;
BindInfo.Space = Binding.Space;
BindInfo.Kind = static_cast<dxbc::PSV::ResourceKind>(Kind);
BindInfo.Flags = Flags;
Expand Down
12 changes: 12 additions & 0 deletions llvm/test/CodeGen/DirectX/ContainerData/PSVResources.ll
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ define void @main() #0 {
%uav2_2 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
@llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_1_0(
i32 4, i32 0, i32 10, i32 5, ptr null)

; RWBuffer<float4> UnboundedArray[] : register(u10, space5)
; CHECK: - Type: UAVTyped
; CHECK: Space: 5
; CHECK: LowerBound: 10
; CHECK: UpperBound: 4294967295
; CHECK: Kind: TypedBuffer
; CHECK: Flags:
; CHECK: UsedByAtomic64: false
; RWBuffer<float4> Buf = BufferArray[100];
%uav3 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
@llvm.dx.resource.handlefrombinding(i32 5, i32 10, i32 -1, i32 100, ptr null)
ret void
}

Expand Down
Loading