Skip to content

Commit

Permalink
vulkan: clean-up includes and simplify destruct
Browse files Browse the repository at this point in the history
  • Loading branch information
poweifeng committed Aug 9, 2023
1 parent 96cccc8 commit c409382
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
2 changes: 2 additions & 0 deletions filament/backend/src/vulkan/VulkanBlitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

#include "VulkanBlitter.h"
#include "VulkanContext.h"
#include "VulkanFboCache.h"
#include "VulkanHandles.h"
#include "VulkanSamplerCache.h"

#include <utils/FixedCapacityVector.h>
#include <utils/Panic.h>
Expand Down
1 change: 0 additions & 1 deletion filament/backend/src/vulkan/VulkanCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "VulkanConstants.h"
#include "VulkanContext.h"
#include "VulkanDriver.h"

#include <utils/Log.h>
#include <utils/Panic.h>
Expand Down
2 changes: 2 additions & 0 deletions filament/backend/src/vulkan/VulkanCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <bluevk/BlueVK.h>

#include "DriverBase.h"

#include "VulkanConstants.h"

#include <utils/Condition.h>
Expand Down
4 changes: 2 additions & 2 deletions filament/backend/src/vulkan/VulkanDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void VulkanDriver::createIndexBufferR(Handle<HwIndexBuffer> ibh, ElementType ele
auto indexBuffer = construct<VulkanIndexBuffer>(ibh, mAllocator, mCommands.get(), mStagePool,
elementSize, indexCount);
mDisposer.createDisposable(indexBuffer,
[this, ibh]() { destructBuffer<VulkanIndexBuffer>(ibh); });
[this, ibh]() { destruct<VulkanIndexBuffer>(ibh); });
}

void VulkanDriver::destroyIndexBuffer(Handle<HwIndexBuffer> ibh) {
Expand All @@ -355,7 +355,7 @@ void VulkanDriver::createBufferObjectR(Handle<HwBufferObject> boh, uint32_t byte
auto bufferObject = construct<VulkanBufferObject>(boh, mAllocator, mCommands.get(), mStagePool,
byteCount, bindingType, usage);
mDisposer.createDisposable(bufferObject,
[this, boh]() { destructBuffer<VulkanBufferObject>(boh); });
[this, boh]() { destruct<VulkanBufferObject>(boh); });
}

void VulkanDriver::destroyBufferObject(Handle<HwBufferObject> boh) {
Expand Down
15 changes: 6 additions & 9 deletions filament/backend/src/vulkan/VulkanDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "VulkanConstants.h"
#include "VulkanContext.h"
#include "VulkanFboCache.h"
#include "VulkanHandles.h"
#include "VulkanReadPixels.h"
#include "VulkanSamplerCache.h"
#include "VulkanStagePool.h"
Expand Down Expand Up @@ -118,18 +119,14 @@ class VulkanDriver final : public DriverBase {

template<typename D, typename B>
void destruct(Handle<B> handle) noexcept {
if constexpr (std::is_base_of_v<VulkanIndexBuffer, D> ||
std::is_base_of_v<VulkanBufferObject, D>) {
auto ptr = handle_cast<D*>(handle);
ptr->terminate();
}
destruct(handle, handle_cast<D const*>(handle));
}

// This version of destruct takes a VulkanContext and calls a terminate(VulkanContext&)
// on the handle before calling the dtor
template<typename Dp, typename B>
void destructBuffer(Handle<B> handle) noexcept {
auto ptr = handle_cast<Dp*>(handle);
ptr->terminate();
mHandleAllocator.deallocate(handle, ptr);
}

inline void setRenderPrimitiveBuffer(Handle<HwRenderPrimitive> rph,
Handle<HwVertexBuffer> vbh, Handle<HwIndexBuffer> ibh);

Expand Down
10 changes: 6 additions & 4 deletions filament/backend/src/vulkan/VulkanHandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
* limitations under the License.
*/

#ifndef TNT_FILAMENT_BACKEND_VULKANHANDLES_H
#define TNT_FILAMENT_BACKEND_VULKANHANDLES_H
#ifndef TNT_FILAMENT_BACKEND_VULKANHANDLES_H
#define TNT_FILAMENT_BACKEND_VULKANHANDLES_H

// This needs to be at the top
#include "DriverBase.h"

#include "VulkanDriver.h"
#include "VulkanPipelineCache.h"
#include "VulkanBuffer.h"
#include "VulkanSwapChain.h"
Expand All @@ -26,7 +28,7 @@

#include "private/backend/SamplerGroup.h"

#include "utils/Mutex.h"
#include <utils/Mutex.h>

namespace filament::backend {

Expand Down
3 changes: 2 additions & 1 deletion filament/backend/src/vulkan/VulkanSwapChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
#ifndef TNT_FILAMENT_BACKEND_VULKANSWAPCHAIN_H
#define TNT_FILAMENT_BACKEND_VULKANSWAPCHAIN_H

#include "DriverBase.h"

#include "VulkanContext.h"
#include "VulkanDriver.h"

#include <backend/platforms/VulkanPlatform.h>

Expand Down
3 changes: 2 additions & 1 deletion filament/backend/src/vulkan/VulkanTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#ifndef TNT_FILAMENT_BACKEND_VULKANTEXTURE_H
#define TNT_FILAMENT_BACKEND_VULKANTEXTURE_H

#include "VulkanDriver.h"
#include "DriverBase.h"

#include "VulkanBuffer.h"
#include "VulkanImageUtility.h"

Expand Down

0 comments on commit c409382

Please sign in to comment.