Move mDevice from PipelineLayoutVk to PipelineLayoutBase

This commit is contained in:
Kai Ninomiya 2018-07-03 13:28:27 -07:00 committed by Kai Ninomiya
parent c5711ecd93
commit 11fc210487
4 changed files with 14 additions and 8 deletions

View File

@ -34,8 +34,9 @@ namespace backend {
// PipelineLayoutBase // PipelineLayoutBase
PipelineLayoutBase::PipelineLayoutBase(DeviceBase*, PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
const nxt::PipelineLayoutDescriptor* descriptor) { const nxt::PipelineLayoutDescriptor* descriptor)
: mDevice(device) {
ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups); ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups);
for (uint32_t group = 0; group < descriptor->numBindGroupLayouts; ++group) { for (uint32_t group = 0; group < descriptor->numBindGroupLayouts; ++group) {
mBindGroupLayouts[group] = mBindGroupLayouts[group] =
@ -67,4 +68,8 @@ namespace backend {
return kMaxBindGroups + 1; return kMaxBindGroups + 1;
} }
DeviceBase* PipelineLayoutBase::GetDevice() const {
return mDevice;
}
} // namespace backend } // namespace backend

View File

@ -47,7 +47,10 @@ namespace backend {
// [1, kMaxBindGroups + 1] // [1, kMaxBindGroups + 1]
uint32_t GroupsInheritUpTo(const PipelineLayoutBase* other) const; uint32_t GroupsInheritUpTo(const PipelineLayoutBase* other) const;
DeviceBase* GetDevice() const;
protected: protected:
DeviceBase* mDevice;
BindGroupLayoutArray mBindGroupLayouts; BindGroupLayoutArray mBindGroupLayouts;
std::bitset<kMaxBindGroups> mMask; std::bitset<kMaxBindGroups> mMask;
}; };

View File

@ -23,7 +23,7 @@
namespace backend { namespace vulkan { namespace backend { namespace vulkan {
PipelineLayout::PipelineLayout(Device* device, const nxt::PipelineLayoutDescriptor* descriptor) PipelineLayout::PipelineLayout(Device* device, const nxt::PipelineLayoutDescriptor* descriptor)
: PipelineLayoutBase(device, descriptor), mDevice(device) { : PipelineLayoutBase(device, descriptor) {
// Compute the array of VkDescriptorSetLayouts that will be chained in the create info. // Compute the array of VkDescriptorSetLayouts that will be chained in the create info.
// TODO(cwallez@chromium.org) Vulkan doesn't allow holes in this array, should we expose // TODO(cwallez@chromium.org) Vulkan doesn't allow holes in this array, should we expose
// this constraints at the NXT level? // this constraints at the NXT level?
@ -50,15 +50,15 @@ namespace backend { namespace vulkan {
createInfo.pushConstantRangeCount = 1; createInfo.pushConstantRangeCount = 1;
createInfo.pPushConstantRanges = &pushConstantRange; createInfo.pPushConstantRanges = &pushConstantRange;
if (mDevice->fn.CreatePipelineLayout(mDevice->GetVkDevice(), &createInfo, nullptr, if (device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr,
&mHandle) != VK_SUCCESS) { &mHandle) != VK_SUCCESS) {
ASSERT(false); ASSERT(false);
} }
} }
PipelineLayout::~PipelineLayout() { PipelineLayout::~PipelineLayout() {
if (mHandle != VK_NULL_HANDLE) { if (mHandle != VK_NULL_HANDLE) {
mDevice->GetFencedDeleter()->DeleteWhenUnused(mHandle); ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
mHandle = VK_NULL_HANDLE; mHandle = VK_NULL_HANDLE;
} }
} }

View File

@ -32,8 +32,6 @@ namespace backend { namespace vulkan {
private: private:
VkPipelineLayout mHandle = VK_NULL_HANDLE; VkPipelineLayout mHandle = VK_NULL_HANDLE;
Device* mDevice = nullptr;
}; };
}} // namespace backend::vulkan }} // namespace backend::vulkan