From 11fc210487b4a5e391f21e3e1e9551b0d7b05c6b Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Tue, 3 Jul 2018 13:28:27 -0700 Subject: [PATCH] Move mDevice from PipelineLayoutVk to PipelineLayoutBase --- src/backend/PipelineLayout.cpp | 9 +++++++-- src/backend/PipelineLayout.h | 3 +++ src/backend/vulkan/PipelineLayoutVk.cpp | 8 ++++---- src/backend/vulkan/PipelineLayoutVk.h | 2 -- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/backend/PipelineLayout.cpp b/src/backend/PipelineLayout.cpp index 141b3ec1ba..8bd1259f4f 100644 --- a/src/backend/PipelineLayout.cpp +++ b/src/backend/PipelineLayout.cpp @@ -34,8 +34,9 @@ namespace backend { // PipelineLayoutBase - PipelineLayoutBase::PipelineLayoutBase(DeviceBase*, - const nxt::PipelineLayoutDescriptor* descriptor) { + PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device, + const nxt::PipelineLayoutDescriptor* descriptor) + : mDevice(device) { ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups); for (uint32_t group = 0; group < descriptor->numBindGroupLayouts; ++group) { mBindGroupLayouts[group] = @@ -67,4 +68,8 @@ namespace backend { return kMaxBindGroups + 1; } + DeviceBase* PipelineLayoutBase::GetDevice() const { + return mDevice; + } + } // namespace backend diff --git a/src/backend/PipelineLayout.h b/src/backend/PipelineLayout.h index 446b232c62..c33d9def96 100644 --- a/src/backend/PipelineLayout.h +++ b/src/backend/PipelineLayout.h @@ -47,7 +47,10 @@ namespace backend { // [1, kMaxBindGroups + 1] uint32_t GroupsInheritUpTo(const PipelineLayoutBase* other) const; + DeviceBase* GetDevice() const; + protected: + DeviceBase* mDevice; BindGroupLayoutArray mBindGroupLayouts; std::bitset mMask; }; diff --git a/src/backend/vulkan/PipelineLayoutVk.cpp b/src/backend/vulkan/PipelineLayoutVk.cpp index 465ec22634..b60d6103a9 100644 --- a/src/backend/vulkan/PipelineLayoutVk.cpp +++ b/src/backend/vulkan/PipelineLayoutVk.cpp @@ -23,7 +23,7 @@ namespace backend { namespace vulkan { 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. // TODO(cwallez@chromium.org) Vulkan doesn't allow holes in this array, should we expose // this constraints at the NXT level? @@ -50,15 +50,15 @@ namespace backend { namespace vulkan { createInfo.pushConstantRangeCount = 1; createInfo.pPushConstantRanges = &pushConstantRange; - if (mDevice->fn.CreatePipelineLayout(mDevice->GetVkDevice(), &createInfo, nullptr, - &mHandle) != VK_SUCCESS) { + if (device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr, + &mHandle) != VK_SUCCESS) { ASSERT(false); } } PipelineLayout::~PipelineLayout() { if (mHandle != VK_NULL_HANDLE) { - mDevice->GetFencedDeleter()->DeleteWhenUnused(mHandle); + ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle); mHandle = VK_NULL_HANDLE; } } diff --git a/src/backend/vulkan/PipelineLayoutVk.h b/src/backend/vulkan/PipelineLayoutVk.h index a6ab0c4f15..2cb97e31f7 100644 --- a/src/backend/vulkan/PipelineLayoutVk.h +++ b/src/backend/vulkan/PipelineLayoutVk.h @@ -32,8 +32,6 @@ namespace backend { namespace vulkan { private: VkPipelineLayout mHandle = VK_NULL_HANDLE; - - Device* mDevice = nullptr; }; }} // namespace backend::vulkan