Skip to content

Commit 7def3cc

Browse files
committed
Also check FB size after the swapchain creation. Only throw on mismatch in benchmark mode.
1 parent cdb5594 commit 7def3cc

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/RayTracer.cpp

+21-13
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,7 @@ RayTracer::RayTracer(const UserSettings& userSettings, const Vulkan::WindowConfi
2727
Application(windowConfig, vsync, EnableValidationLayers),
2828
userSettings_(userSettings)
2929
{
30-
// Check the framebuffer size when requesting a fullscreen window, as it's not guaranteed to match.
31-
const auto fbSize = Window().FramebufferSize();
32-
33-
if (windowConfig.Fullscreen && (fbSize.width != windowConfig.Width || fbSize.height != windowConfig.Height))
34-
{
35-
std::ostringstream out;
36-
out << "framebuffer fullscreen size mismatch (requested: ";
37-
out << windowConfig.Width << "x" << windowConfig.Height;
38-
out << ", got: ";
39-
out << fbSize.width << "x" << fbSize.height << ")";
40-
41-
Throw(std::runtime_error(out.str()));
42-
}
30+
CheckFramebufferSize();
4331
}
4432

4533
RayTracer::~RayTracer()
@@ -90,6 +78,8 @@ void RayTracer::CreateSwapChain()
9078

9179
userInterface_.reset(new UserInterface(CommandPool(), SwapChain(), DepthBuffer(), userSettings_));
9280
resetAccumulation_ = true;
81+
82+
CheckFramebufferSize();
9383
}
9484

9585
void RayTracer::DeleteSwapChain()
@@ -318,3 +308,21 @@ void RayTracer::CheckAndUpdateBenchmarkState(double prevTime)
318308
}
319309
}
320310
}
311+
312+
void RayTracer::CheckFramebufferSize() const
313+
{
314+
// Check the framebuffer size when requesting a fullscreen window, as it's not guaranteed to match.
315+
const auto& cfg = Window().Config();
316+
const auto fbSize = Window().FramebufferSize();
317+
318+
if (userSettings_.Benchmark && cfg.Fullscreen && (fbSize.width != cfg.Width || fbSize.height != cfg.Height))
319+
{
320+
std::ostringstream out;
321+
out << "framebuffer fullscreen size mismatch (requested: ";
322+
out << cfg.Width << "x" << cfg.Height;
323+
out << ", got: ";
324+
out << fbSize.width << "x" << fbSize.height << ")";
325+
326+
Throw(std::runtime_error(out.str()));
327+
}
328+
}

src/RayTracer.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class RayTracer final : public Vulkan::RayTracing::Application
3232

3333
void LoadScene(uint32_t sceneIndex);
3434
void CheckAndUpdateBenchmarkState(double prevTime);
35+
void CheckFramebufferSize() const;
3536

3637
uint32_t sceneIndex_{};
3738
UserSettings userSettings_{};

0 commit comments

Comments
 (0)