filamentapp: fix vulkan dependency (#6987)

Fixes #6983
This commit is contained in:
Powei Feng
2023-07-24 16:50:51 -07:00
committed by GitHub
parent ad03fc4118
commit 5fce0f9ecf
2 changed files with 17 additions and 5 deletions

View File

@@ -49,10 +49,12 @@ class ImGuiHelper;
class IBL;
class MeshAssimp;
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)
// For customizing the vulkan backend
namespace filament::backend {
class VulkanPlatform;
}
#endif
class FilamentApp {
public:
@@ -250,7 +252,9 @@ private:
float mCameraNear = 0.1f;
float mCameraFar = 100.0f;
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)
filament::backend::VulkanPlatform* mVulkanPlatform = nullptr;
#endif
};
#endif // TNT_FILAMENT_SAMPLE_FILAMENTAPP_H

View File

@@ -44,7 +44,9 @@
#include <filament/DebugRegistry.h>
#endif
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)
#include <backend/platforms/VulkanPlatform.h>
#endif
#include <filagui/ImGuiHelper.h>
@@ -64,6 +66,7 @@ namespace {
using namespace filament::backend;
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)
class FilamentAppVulkanPlatform : public VulkanPlatform {
public:
FilamentAppVulkanPlatform(std::string const& gpuHint) {
@@ -85,6 +88,7 @@ public:
private:
VulkanPlatform::GPUPreference mPreference;
};
#endif
} // anonymous namespace
@@ -473,9 +477,11 @@ void FilamentApp::run(const Config& config, SetupCallback setupCallback,
Engine::destroy(&mEngine);
mEngine = nullptr;
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)
if (mVulkanPlatform) {
delete mVulkanPlatform;
}
#endif
}
// RELATIVE_ASSET_PATH is set inside samples/CMakeLists.txt and used to support multi-configuration
@@ -584,11 +590,13 @@ FilamentApp::Window::Window(FilamentApp* filamentApp,
#endif
if (backend == Engine::Backend::VULKAN) {
mFilamentApp->mVulkanPlatform = new FilamentAppVulkanPlatform(config.vulkanGPUHint);
return Engine::Builder()
.backend(backend)
.platform(mFilamentApp->mVulkanPlatform)
.build();
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)
mFilamentApp->mVulkanPlatform = new FilamentAppVulkanPlatform(config.vulkanGPUHint);
return Engine::Builder()
.backend(backend)
.platform(mFilamentApp->mVulkanPlatform)
.build();
#endif
}
return Engine::Builder().backend(backend).build();
};