Slab-allocate OpenGL bind groups

Now that all backends use slab-allocated bind groups, this patch also
moves the BindGroup implementation with owned-data into the Null backend.

Bug: dawn:340
Change-Id: I08a952075b382008fb82f1fbab3f779cc05bc2a3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16747
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Austin Eng
2020-03-13 23:51:50 +00:00
committed by Commit Bot service account
parent ae96f04c0a
commit 463c394905
12 changed files with 197 additions and 49 deletions

View File

@@ -252,6 +252,25 @@ namespace dawn_native { namespace null {
mLastSubmittedSerial++;
}
// BindGroupDataHolder
BindGroupDataHolder::BindGroupDataHolder(size_t size)
: mBindingDataAllocation(malloc(size)) // malloc is guaranteed to return a
// pointer aligned enough for the allocation
{
}
BindGroupDataHolder::~BindGroupDataHolder() {
free(mBindingDataAllocation);
}
// BindGroup
BindGroup::BindGroup(DeviceBase* device, const BindGroupDescriptor* descriptor)
: BindGroupDataHolder(descriptor->layout->GetBindingDataSize()),
BindGroupBase(device, descriptor, mBindingDataAllocation) {
}
// Buffer
struct BufferMapOperation : PendingOperation {

View File

@@ -38,7 +38,7 @@
namespace dawn_native { namespace null {
class Adapter;
using BindGroup = BindGroupBaseOwnBindingData;
class BindGroup;
using BindGroupLayout = BindGroupLayoutBase;
class Buffer;
class CommandBuffer;
@@ -157,6 +157,24 @@ namespace dawn_native { namespace null {
ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) override;
};
// Helper class so |BindGroup| can allocate memory for its binding data,
// before calling the BindGroupBase base class constructor.
class BindGroupDataHolder {
protected:
explicit BindGroupDataHolder(size_t size);
~BindGroupDataHolder();
void* mBindingDataAllocation;
};
// We don't have the complexity of placement-allocation of bind group data in
// the Null backend. This class, keeps the binding data in a separate allocation for simplicity.
class BindGroup : private BindGroupDataHolder, public BindGroupBase {
public:
BindGroup(DeviceBase* device, const BindGroupDescriptor* descriptor);
~BindGroup() override = default;
};
class Buffer : public BufferBase {
public:
Buffer(Device* device, const BufferDescriptor* descriptor);