mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-05 20:55:58 +00:00
D3D12: Remove increment during bindgroup population.
Simplifies descriptor heap allocations by removing increment which is no longer required by Populate(). BUG=dawn:155 Change-Id: I1d9cd2c607691dc1bcffddd82aa46a10c2bf6fd3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/20048 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
This commit is contained in:
parent
f204cf2c4f
commit
c133cab158
@ -180,10 +180,10 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
d3d12Device->CopyDescriptorsSimple(
|
d3d12Device->CopyDescriptorsSimple(
|
||||||
viewDescriptorCount, viewDescriptorHeapAllocation.GetCPUHandle(0),
|
viewDescriptorCount, viewDescriptorHeapAllocation.GetBaseCPUDescriptor(),
|
||||||
mCPUViewAllocation.OffsetFrom(0, 0), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
mCPUViewAllocation.GetBaseDescriptor(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||||
|
|
||||||
mBaseViewDescriptor = viewDescriptorHeapAllocation.GetGPUHandle(0);
|
mBaseViewDescriptor = viewDescriptorHeapAllocation.GetBaseGPUDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t samplerDescriptorCount = bgl->GetSamplerDescriptorCount();
|
const uint32_t samplerDescriptorCount = bgl->GetSamplerDescriptorCount();
|
||||||
@ -197,10 +197,10 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
d3d12Device->CopyDescriptorsSimple(
|
d3d12Device->CopyDescriptorsSimple(
|
||||||
samplerDescriptorCount, samplerDescriptorHeapAllocation.GetCPUHandle(0),
|
samplerDescriptorCount, samplerDescriptorHeapAllocation.GetBaseCPUDescriptor(),
|
||||||
mCPUSamplerAllocation.OffsetFrom(0, 0), D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
|
mCPUSamplerAllocation.GetBaseDescriptor(), D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
|
||||||
|
|
||||||
mBaseSamplerDescriptor = samplerDescriptorHeapAllocation.GetGPUHandle(0);
|
mBaseSamplerDescriptor = samplerDescriptorHeapAllocation.GetBaseGPUDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record both the device and heap serials to determine later if the allocations are still
|
// Record both the device and heap serials to determine later if the allocations are still
|
||||||
|
@ -23,6 +23,11 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
: mBaseDescriptor(baseDescriptor), mHeapIndex(heapIndex) {
|
: mBaseDescriptor(baseDescriptor), mHeapIndex(heapIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHeapAllocation::GetBaseDescriptor() const {
|
||||||
|
ASSERT(IsValid());
|
||||||
|
return mBaseDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHeapAllocation::OffsetFrom(
|
D3D12_CPU_DESCRIPTOR_HANDLE CPUDescriptorHeapAllocation::OffsetFrom(
|
||||||
uint32_t sizeIncrementInBytes,
|
uint32_t sizeIncrementInBytes,
|
||||||
uint32_t offsetInDescriptorCount) const {
|
uint32_t offsetInDescriptorCount) const {
|
||||||
|
@ -27,6 +27,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
CPUDescriptorHeapAllocation() = default;
|
CPUDescriptorHeapAllocation() = default;
|
||||||
CPUDescriptorHeapAllocation(D3D12_CPU_DESCRIPTOR_HANDLE baseDescriptor, uint32_t heapIndex);
|
CPUDescriptorHeapAllocation(D3D12_CPU_DESCRIPTOR_HANDLE baseDescriptor, uint32_t heapIndex);
|
||||||
|
|
||||||
|
D3D12_CPU_DESCRIPTOR_HANDLE GetBaseDescriptor() const;
|
||||||
|
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE OffsetFrom(uint32_t sizeIncrementInBytes,
|
D3D12_CPU_DESCRIPTOR_HANDLE OffsetFrom(uint32_t sizeIncrementInBytes,
|
||||||
uint32_t offsetInDescriptorCount) const;
|
uint32_t offsetInDescriptorCount) const;
|
||||||
uint32_t GetHeapIndex() const;
|
uint32_t GetHeapIndex() const;
|
||||||
|
@ -17,30 +17,21 @@
|
|||||||
|
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
DescriptorHeapAllocation::DescriptorHeapAllocation() : mSizeIncrement(0) {
|
|
||||||
}
|
|
||||||
|
|
||||||
DescriptorHeapAllocation::DescriptorHeapAllocation(
|
DescriptorHeapAllocation::DescriptorHeapAllocation(
|
||||||
uint32_t sizeIncrement,
|
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptorHandle,
|
D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptorHandle,
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE baseGPUDescriptorHandle)
|
D3D12_GPU_DESCRIPTOR_HANDLE baseGPUDescriptorHandle)
|
||||||
: mSizeIncrement(sizeIncrement),
|
: mBaseCPUDescriptorHandle(baseCPUDescriptorHandle),
|
||||||
mBaseCPUDescriptorHandle(baseCPUDescriptorHandle),
|
|
||||||
mBaseGPUDescriptorHandle(baseGPUDescriptorHandle) {
|
mBaseGPUDescriptorHandle(baseGPUDescriptorHandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE DescriptorHeapAllocation::GetCPUHandle(uint32_t offset) const {
|
D3D12_GPU_DESCRIPTOR_HANDLE DescriptorHeapAllocation::GetBaseGPUDescriptor() const {
|
||||||
ASSERT(!IsInvalid());
|
ASSERT(!IsInvalid());
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = mBaseCPUDescriptorHandle;
|
return mBaseGPUDescriptorHandle;
|
||||||
cpuHandle.ptr += mSizeIncrement * offset;
|
|
||||||
return cpuHandle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE DescriptorHeapAllocation::GetGPUHandle(uint32_t offset) const {
|
D3D12_CPU_DESCRIPTOR_HANDLE DescriptorHeapAllocation::GetBaseCPUDescriptor() const {
|
||||||
ASSERT(!IsInvalid());
|
ASSERT(!IsInvalid());
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = mBaseGPUDescriptorHandle;
|
return mBaseCPUDescriptorHandle;
|
||||||
gpuHandle.ptr += mSizeIncrement * offset;
|
|
||||||
return gpuHandle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DescriptorHeapAllocation::IsInvalid() const {
|
bool DescriptorHeapAllocation::IsInvalid() const {
|
||||||
|
@ -21,23 +21,20 @@
|
|||||||
|
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
// Wrapper for a handle into a descriptor heap.
|
// Wrapper for a handle into a GPU-only descriptor heap.
|
||||||
class DescriptorHeapAllocation {
|
class DescriptorHeapAllocation {
|
||||||
public:
|
public:
|
||||||
DescriptorHeapAllocation();
|
DescriptorHeapAllocation() = default;
|
||||||
DescriptorHeapAllocation(uint32_t sizeIncrement,
|
DescriptorHeapAllocation(D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptorHandle,
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptorHandle,
|
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE baseGPUDescriptorHandle);
|
D3D12_GPU_DESCRIPTOR_HANDLE baseGPUDescriptorHandle);
|
||||||
~DescriptorHeapAllocation() = default;
|
~DescriptorHeapAllocation() = default;
|
||||||
|
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE GetCPUHandle(uint32_t offset) const;
|
D3D12_GPU_DESCRIPTOR_HANDLE GetBaseGPUDescriptor() const;
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE GetGPUHandle(uint32_t offset) const;
|
D3D12_CPU_DESCRIPTOR_HANDLE GetBaseCPUDescriptor() const;
|
||||||
|
|
||||||
bool IsInvalid() const;
|
bool IsInvalid() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t mSizeIncrement;
|
|
||||||
|
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE mBaseCPUDescriptorHandle = {0};
|
D3D12_CPU_DESCRIPTOR_HANDLE mBaseCPUDescriptorHandle = {0};
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE mBaseGPUDescriptorHandle = {0};
|
D3D12_GPU_DESCRIPTOR_HANDLE mBaseGPUDescriptorHandle = {0};
|
||||||
};
|
};
|
||||||
|
@ -101,16 +101,20 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
ID3D12DescriptorHeap* descriptorHeap = mShaderVisibleBuffers[heapType].heap.Get();
|
ID3D12DescriptorHeap* descriptorHeap = mShaderVisibleBuffers[heapType].heap.Get();
|
||||||
|
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptor =
|
const uint64_t heapOffset = mSizeIncrements[heapType] * startOffset;
|
||||||
descriptorHeap->GetCPUDescriptorHandleForHeapStart();
|
|
||||||
baseCPUDescriptor.ptr += mSizeIncrements[heapType] * startOffset;
|
|
||||||
|
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE baseGPUDescriptor =
|
// Check for 32-bit overflow since CPU heap start handle uses size_t.
|
||||||
descriptorHeap->GetGPUDescriptorHandleForHeapStart();
|
const size_t cpuHeapStartPtr = descriptorHeap->GetCPUDescriptorHandleForHeapStart().ptr;
|
||||||
baseGPUDescriptor.ptr += mSizeIncrements[heapType] * startOffset;
|
|
||||||
|
|
||||||
return DescriptorHeapAllocation{mSizeIncrements[heapType], baseCPUDescriptor,
|
ASSERT(heapOffset <= std::numeric_limits<size_t>::max() - cpuHeapStartPtr);
|
||||||
baseGPUDescriptor};
|
|
||||||
|
const D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptor = {cpuHeapStartPtr +
|
||||||
|
static_cast<size_t>(heapOffset)};
|
||||||
|
|
||||||
|
const D3D12_GPU_DESCRIPTOR_HANDLE baseGPUDescriptor = {
|
||||||
|
descriptorHeap->GetGPUDescriptorHandleForHeapStart().ptr + heapOffset};
|
||||||
|
|
||||||
|
return DescriptorHeapAllocation{baseCPUDescriptor, baseGPUDescriptor};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<ID3D12DescriptorHeap*, 2> ShaderVisibleDescriptorAllocator::GetShaderVisibleHeaps()
|
std::array<ID3D12DescriptorHeap*, 2> ShaderVisibleDescriptorAllocator::GetShaderVisibleHeaps()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user