16using namespace RenderCore;
19 {RHIResourceFormat::R8G8B8A8Unorm, RHIColorSpace::SrgbNonLinear},
20 {RHIResourceFormat::B8G8R8A8Unrom, RHIColorSpace::SrgbNonLinear},
24 RHISwapchainPresentMode::Mailbox, RHISwapchainPresentMode::Tearing, RHISwapchainPresentMode::Fifo};
32 SDL_GetWindowSizeInPixels(window, &w, &h);
33 LOG(RenderApplication,
LogDebug,
"Creating swapchain ({}x{})", w, h);
41 CHECK_MSG(format.has_value(),
"No supported swapchain format found!");
42 LOG(RenderApplication,
LogDebug,
"Selected swapchain format: {} with color space: {}", format.value().format, format.value().colorSpace);
43 CHECK_MSG(present.has_value(),
"No supported presentation mode found!");
44 LOG(RenderApplication,
LogDebug,
"Selected swapchain present mode: {}", present.value());
46 .
format = format.value().format,
47 .colorSpace = format.value().colorSpace,
50 .presentMode = present.value(),
62 argh::parser cmdl(argc, argv, argh::parser::PREFER_PARAM_FOR_UNREG_OPTION);
63 if (cmdl[{
"-h",
"--help"}])
65 fmt::println(
"Usage: {} [options]", argv[0]);
66 fmt::println(
"Options:");
67 fmt::println(
"\t-h, --help\t\tShow this help message");
68 fmt::println(
"\t-g, --gpu <id>\t\tSpecify GPU device index");
69 fmt::println(
"\t-l, --list-gpus\t\tList available GPU devices");
72 if (cmdl[{
"-l",
"--list-gpus"}])
75 for (
auto const&
d :
app->EnumerateDevices())
88 return std::make_tuple(
renderer,
app, std::move(device), std::move(
swap));
156 static constexpr char kControlsText[] =
"Mouse Left: Rotate | Mouse Right: Pan | Mouse Wheel: Zoom";
169 pitch -=
event.motion.xrel * 1e-2f;
170 yaw -=
event.motion.yrel * 1e-2f;
#define GLOBAL_ALLOC
Definition Allocator.hpp:225
constexpr int Examples_SDLWindowFlagsVulkan
Definition Examples.hpp:55
constexpr RHISwapchainPresentMode kPresentModePreferenceList[]
Definition Examples.hpp:23
bool Examples_ShouldClose(SDL_Window *window, Renderer *renderer, RHIDeviceScopedHandle< RHISwapchain > &swap, SDL_Event *outEvent=nullptr)
Definition Examples.hpp:91
float Examples_GetTime()
Definition Examples.hpp:127
constexpr RHISurfaceFormat kFormatPreferenceList[]
Definition Examples.hpp:18
void Examples_NewFrame(Renderer *renderer)
Definition Examples.hpp:110
auto Examples_InitVulkan(SDL_Window *window, int argc, char **argv, RendererDesc const &desc={})
Definition Examples.hpp:60
auto Examples_DestroyVulkan(SDL_Window *window, Renderer *renderer, VulkanApplication *app, RHIApplicationScopedHandle< RHIDevice > &device, RHIDeviceScopedHandle< RHISwapchain > &swapchain)
Definition Examples.hpp:116
#define LOG(TAG, LEVEL, FORMAT,...)
Definition Logging.hpp:55
#define CHECK_MSG(expr, format_str,...)
Definition Logging.hpp:62
@ LogDebug
Definition Logging.hpp:6
Definition Device.hpp:245
virtual Span< RHISwapchainPresentMode const > GetSwapchainSupportedPresentModes() const =0
virtual Span< RHISurfaceFormat const > GetSwapchainSupportedFormats() const =0
virtual void WaitIdle() const =0
virtual RHIDeviceScopedHandle< RHISwapchain > CreateSwapchain(RHISwapchain::SwapchainDesc const &desc)=0
Scoped move-only RAII handle wrapper for RHI Objects.
Definition Details.hpp:86
void Reset()
Destructs the underlying RHIObject, and invalidates the scoped handle.
Definition Details.hpp:127
Definition Application.hpp:9
Renderer implementing a Frame Graph system with automatic resource tracking and synchronization.
Definition Renderer.hpp:89
constexpr Optional< range_value_t< T > > FirstOf(T &&range)
Returns the first element of a range, or an empty Optional if the range is empty.
Definition Container.hpp:231
void Destruct(Allocator *resource, T *obj)
Convenience destructor for objects allocated with Construct or ConstructBase.
Definition Allocator.hpp:160
void PathsInitFromDir(const char *exeDir)
Definition Paths.cpp:13
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:153
vec3 float3
Definition Math.hpp:26
mat4 infinitePerspectiveRHReverseZ(float fovY, float a, float zNear)
Definition ModelViewProjection.hpp:7
mat4 viewMatrixRHReverseZ(vec3 pos, quat rot)
Definition ModelViewProjection.hpp:26
RHISwapchainPresentMode
Definition Swapchain.hpp:11
glm::vec< 3, uint32_t > RHIExtent3D
Definition Common.hpp:11
Definition Allocator.hpp:5
Definition Examples.hpp:27
void CreateSwapchain(SDL_Window *window, RHIDevice *device, RHIDeviceScopedHandle< RHISwapchain > &outSwap)
Definition Examples.hpp:28
Definition Examples.hpp:134
size_t lastTick
Definition Examples.hpp:135
float fps
Definition Examples.hpp:137
float Update()
Definition Examples.hpp:138
size_t frames
Definition Examples.hpp:136
Definition Examples.hpp:155
float3 center
Definition Examples.hpp:158
float radius
Definition Examples.hpp:159
float yaw
Definition Examples.hpp:160
float zNear
Definition Examples.hpp:161
static constexpr char kControlsText[]
Definition Examples.hpp:156
float fovY
Definition Examples.hpp:161
float pitch
Definition Examples.hpp:160
mat4 view
Definition Examples.hpp:162
mat4 Update(SDL_Event const &event)
Definition Examples.hpp:163
mat4 proj
Definition Examples.hpp:162
float aspect
Definition Examples.hpp:161
Range predicate that checks if a value is contained within a given range.
Definition Container.hpp:219
Definition Swapchain.hpp:23
RHIResourceFormat format
Definition Swapchain.hpp:25
Parameters for Renderer creation.
Definition Renderer.hpp:17