light/modules/renderer/private/frontend/renderer/renderer.cpp
light7734 61473c2758
Some checks failed
continuous-integration/drone/push Build is failing
test(renderer): overhaul tests & fix many bugs
2025-10-07 16:09:50 +03:30

38 lines
1.1 KiB
C++

#include <memory/scope.hpp>
#include <renderer/api.hpp>
#include <renderer/backend/vk/renderer/renderer.hpp>
#include <renderer/frontend/renderer/renderer.hpp>
namespace lt::renderer {
[[nodiscard]] /* static */ auto IRenderer::create(
Api target_api,
IDevice *device,
ISwapchain *swapchain,
uint32_t max_frames_in_flight
) -> memory::Scope<IRenderer>
{
ensure(device, "Failed to create renderer::IRenderer: null device");
ensure(swapchain, "Failed to create renderer::IRenderer: null swapchain");
ensure(
std::clamp(max_frames_in_flight, frames_in_flight_lower_limit, frames_in_flight_upper_limit)
== max_frames_in_flight,
"Failed to initialize renderer::System: max_frames_in_flight ({}) not within bounds ({} -> "
"{}) ",
max_frames_in_flight,
frames_in_flight_lower_limit,
frames_in_flight_upper_limit
);
switch (target_api)
{
case Api::vulkan:
return memory::create_scope<vk::Renderer>(device, swapchain, max_frames_in_flight);
case Api::none:
case Api::metal:
case Api::direct_x: throw std::runtime_error { "Invalid API" };
}
}
} // namespace lt::renderer