diff --git a/src/RayTracer.cpp b/src/RayTracer.cpp index 9f53226f..062efb0d 100644 --- a/src/RayTracer.cpp +++ b/src/RayTracer.cpp @@ -27,19 +27,7 @@ RayTracer::RayTracer(const UserSettings& userSettings, const Vulkan::WindowConfi Application(windowConfig, vsync, EnableValidationLayers), userSettings_(userSettings) { - // Check the framebuffer size when requesting a fullscreen window, as it's not guaranteed to match. - const auto fbSize = Window().FramebufferSize(); - - if (windowConfig.Fullscreen && (fbSize.width != windowConfig.Width || fbSize.height != windowConfig.Height)) - { - std::ostringstream out; - out << "framebuffer fullscreen size mismatch (requested: "; - out << windowConfig.Width << "x" << windowConfig.Height; - out << ", got: "; - out << fbSize.width << "x" << fbSize.height << ")"; - - Throw(std::runtime_error(out.str())); - } + CheckFramebufferSize(); } RayTracer::~RayTracer() @@ -90,6 +78,8 @@ void RayTracer::CreateSwapChain() userInterface_.reset(new UserInterface(CommandPool(), SwapChain(), DepthBuffer(), userSettings_)); resetAccumulation_ = true; + + CheckFramebufferSize(); } void RayTracer::DeleteSwapChain() @@ -318,3 +308,21 @@ void RayTracer::CheckAndUpdateBenchmarkState(double prevTime) } } } + +void RayTracer::CheckFramebufferSize() const +{ + // Check the framebuffer size when requesting a fullscreen window, as it's not guaranteed to match. + const auto& cfg = Window().Config(); + const auto fbSize = Window().FramebufferSize(); + + if (userSettings_.Benchmark && cfg.Fullscreen && (fbSize.width != cfg.Width || fbSize.height != cfg.Height)) + { + std::ostringstream out; + out << "framebuffer fullscreen size mismatch (requested: "; + out << cfg.Width << "x" << cfg.Height; + out << ", got: "; + out << fbSize.width << "x" << fbSize.height << ")"; + + Throw(std::runtime_error(out.str())); + } +} diff --git a/src/RayTracer.hpp b/src/RayTracer.hpp index df3dc3b1..939e10e5 100644 --- a/src/RayTracer.hpp +++ b/src/RayTracer.hpp @@ -32,6 +32,7 @@ class RayTracer final : public Vulkan::RayTracing::Application void LoadScene(uint32_t sceneIndex); void CheckAndUpdateBenchmarkState(double prevTime); + void CheckFramebufferSize() const; uint32_t sceneIndex_{}; UserSettings userSettings_{};