Slab-allocate frontend D3D12 bind groups
Bug: dawn:340 Change-Id: Ie613a1b8e445a385c10eb377983440ace9ad3f4a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16746 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
79230bf213
commit
ae96f04c0a
|
@ -24,6 +24,19 @@
|
|||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
// static
|
||||
BindGroup* BindGroup::Create(Device* device, const BindGroupDescriptor* descriptor) {
|
||||
return ToBackend(descriptor->layout)->AllocateBindGroup(device, descriptor);
|
||||
}
|
||||
|
||||
BindGroup::BindGroup(Device* device, const BindGroupDescriptor* descriptor)
|
||||
: BindGroupBase(this, device, descriptor) {
|
||||
}
|
||||
|
||||
BindGroup::~BindGroup() {
|
||||
ToBackend(GetLayout())->DeallocateBindGroup(this);
|
||||
}
|
||||
|
||||
ResultOrError<bool> BindGroup::Populate(ShaderVisibleDescriptorAllocator* allocator) {
|
||||
Device* device = ToBackend(GetDevice());
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef DAWNNATIVE_D3D12_BINDGROUPD3D12_H_
|
||||
#define DAWNNATIVE_D3D12_BINDGROUPD3D12_H_
|
||||
|
||||
#include "common/PlacementAllocated.h"
|
||||
#include "common/Serial.h"
|
||||
#include "dawn_native/BindGroup.h"
|
||||
#include "dawn_native/d3d12/d3d12_platform.h"
|
||||
|
@ -24,9 +25,12 @@ namespace dawn_native { namespace d3d12 {
|
|||
class Device;
|
||||
class ShaderVisibleDescriptorAllocator;
|
||||
|
||||
class BindGroup : public BindGroupBaseOwnBindingData {
|
||||
class BindGroup : public BindGroupBase, public PlacementAllocated {
|
||||
public:
|
||||
using BindGroupBaseOwnBindingData::BindGroupBaseOwnBindingData;
|
||||
static BindGroup* Create(Device* device, const BindGroupDescriptor* descriptor);
|
||||
|
||||
BindGroup(Device* device, const BindGroupDescriptor* descriptor);
|
||||
~BindGroup() override;
|
||||
|
||||
// Returns true if the BindGroup was successfully populated.
|
||||
ResultOrError<bool> Populate(ShaderVisibleDescriptorAllocator* allocator);
|
||||
|
|
|
@ -15,12 +15,15 @@
|
|||
#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
|
||||
|
||||
#include "common/BitSetIterator.h"
|
||||
#include "dawn_native/d3d12/BindGroupD3D12.h"
|
||||
#include "dawn_native/d3d12/DeviceD3D12.h"
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
BindGroupLayout::BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor)
|
||||
: BindGroupLayoutBase(device, descriptor), mDescriptorCounts{} {
|
||||
: BindGroupLayoutBase(device, descriptor),
|
||||
mDescriptorCounts{},
|
||||
mBindGroupAllocator(MakeFrontendBindGroupAllocator<BindGroup>(4096)) {
|
||||
const auto& groupInfo = GetBindingInfo();
|
||||
|
||||
for (uint32_t binding : IterateBitSet(groupInfo.mask)) {
|
||||
|
@ -143,6 +146,15 @@ namespace dawn_native { namespace d3d12 {
|
|||
}
|
||||
}
|
||||
|
||||
BindGroup* BindGroupLayout::AllocateBindGroup(Device* device,
|
||||
const BindGroupDescriptor* descriptor) {
|
||||
return mBindGroupAllocator.Allocate(device, descriptor);
|
||||
}
|
||||
|
||||
void BindGroupLayout::DeallocateBindGroup(BindGroup* bindGroup) {
|
||||
mBindGroupAllocator.Deallocate(bindGroup);
|
||||
}
|
||||
|
||||
const std::array<uint32_t, kMaxBindingsPerGroup>& BindGroupLayout::GetBindingOffsets() const {
|
||||
return mBindingOffsets;
|
||||
}
|
||||
|
|
|
@ -17,16 +17,21 @@
|
|||
|
||||
#include "dawn_native/BindGroupLayout.h"
|
||||
|
||||
#include "common/SlabAllocator.h"
|
||||
#include "dawn_native/d3d12/d3d12_platform.h"
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
class BindGroup;
|
||||
class Device;
|
||||
|
||||
class BindGroupLayout : public BindGroupLayoutBase {
|
||||
public:
|
||||
BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor);
|
||||
|
||||
BindGroup* AllocateBindGroup(Device* device, const BindGroupDescriptor* descriptor);
|
||||
void DeallocateBindGroup(BindGroup* bindGroup);
|
||||
|
||||
enum DescriptorType {
|
||||
CBV,
|
||||
UAV,
|
||||
|
@ -47,6 +52,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
std::array<uint32_t, kMaxBindingsPerGroup> mBindingOffsets;
|
||||
std::array<uint32_t, DescriptorType::Count> mDescriptorCounts;
|
||||
D3D12_DESCRIPTOR_RANGE mRanges[DescriptorType::Count];
|
||||
|
||||
SlabAllocator<BindGroup> mBindGroupAllocator;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
ResultOrError<BindGroupBase*> Device::CreateBindGroupImpl(
|
||||
const BindGroupDescriptor* descriptor) {
|
||||
return new BindGroup(this, descriptor);
|
||||
return BindGroup::Create(this, descriptor);
|
||||
}
|
||||
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
|
||||
const BindGroupLayoutDescriptor* descriptor) {
|
||||
|
|
Loading…
Reference in New Issue