Fun menu :3

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-12-17 21:42:59 +02:00
parent b01a32194e
commit 4d9e1f03b0
3 changed files with 58 additions and 6 deletions

View File

@@ -9,6 +9,8 @@
#include <optional>
#include <print>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <SDL3/SDL_video.h>
#include <SDL3/SDL_vulkan.h>
@@ -526,6 +528,13 @@ auto VulkanRenderer::resize(uint32_t width, uint32_t height) -> void
}
auto VulkanRenderer::set_antialiasing(AntiAliasingKind kind) -> void
{
enqueue_render_command(RenderCommand {
RenderCommand::SetAntiAliasing { kind },
});
}
auto VulkanRenderer::apply_antialiasing(AntiAliasingKind kind) -> void
{
auto requested_samples = [&](AntiAliasingKind aa) {
switch (aa) {
@@ -616,6 +625,33 @@ auto VulkanRenderer::set_antialiasing(AntiAliasingKind kind) -> void
pipelines_init();
}
auto VulkanRenderer::enqueue_render_command(RenderCommand &&command) -> void
{
std::scoped_lock lock { m_command_mutex };
m_pending_render_commands.emplace_back(std::move(command));
}
auto VulkanRenderer::process_render_commands() -> void
{
std::vector<RenderCommand> commands;
{
std::scoped_lock lock { m_command_mutex };
commands.swap(m_pending_render_commands);
}
for (auto &command : commands) {
std::visit(
[&](auto &&payload) {
using Payload = std::decay_t<decltype(payload)>;
if constexpr (std::is_same_v<Payload,
RenderCommand::SetAntiAliasing>) {
apply_antialiasing(payload.kind);
}
},
command.payload);
}
}
auto VulkanRenderer::immediate_submit(
std::function<void(vk::CommandBuffer cmd)> &&function,
bool flush_frame_deletion_queue, bool clear_frame_descriptors) -> void
@@ -1155,6 +1191,8 @@ auto VulkanRenderer::render(std::function<void(GL &)> const &record) -> void
return;
}
process_render_commands();
auto &frame = m_vk.get_current_frame();
VK_CHECK(m_logger,
m_device.waitForFences(frame.render_fence.get(), true, 1'000'000'000));