Skip to content

Commit

Permalink
Also check FB size after the swapchain creation. Only throw on mismat…
Browse files Browse the repository at this point in the history
…ch in benchmark mode.
  • Loading branch information
GPSnoopy committed Oct 20, 2019
1 parent cdb5594 commit 7def3cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/RayTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -90,6 +78,8 @@ void RayTracer::CreateSwapChain()

userInterface_.reset(new UserInterface(CommandPool(), SwapChain(), DepthBuffer(), userSettings_));
resetAccumulation_ = true;

CheckFramebufferSize();
}

void RayTracer::DeleteSwapChain()
Expand Down Expand Up @@ -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()));
}
}
1 change: 1 addition & 0 deletions src/RayTracer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_{};
Expand Down

0 comments on commit 7def3cc

Please sign in to comment.