25#include <utility/system_io/android_system_io.hpp>
26#include <utility/system_io/default_system_io.hpp>
30#include <glm/gtc/matrix_transform.hpp>
31#include <glm/gtx/hash.hpp>
41const bool enableValidationLayers =
false;
43const bool enableValidationLayers =
true;
54const std::vector<const char *> validationLayers = {
55 "VK_LAYER_KHRONOS_validation"
66const int MAX_FRAMES_IN_FLIGHT = 2;
76const int MAX_SWAPCHAINS = 8;
85constexpr uint32_t MAX_MULTIVIEW_VIEWS = 2;
93enum class MultiviewMode {
107inline MultiviewMode multiviewMode()
109 static const MultiviewMode mode = [] {
110 const char *value = std::getenv(
"EVAN_MULTIVIEW");
111 if (value ==
nullptr || value[0] ==
'\0') {
112 return MultiviewMode::Auto;
114 if (std::strcmp(value,
"1") == 0 || std::strcmp(value,
"on") == 0
115 || std::strcmp(value,
"true") == 0
116 || std::strcmp(value,
"yes") == 0) {
117 return MultiviewMode::On;
119 if (std::strcmp(value,
"0") == 0 || std::strcmp(value,
"off") == 0
120 || std::strcmp(value,
"false") == 0
121 || std::strcmp(value,
"no") == 0) {
122 return MultiviewMode::Off;
124 return MultiviewMode::Auto;
139inline bool statsFlagEnabled(
const char *value)
141 return value !=
nullptr && value[0] !=
'\0' && value[0] !=
'0';
154inline unsigned statsIntervalFromValue(
const char *value)
156 constexpr unsigned defaultInterval = 120u;
157 constexpr unsigned long maxInterval = 1000000ul;
159 if (value ==
nullptr || value[0] ==
'\0') {
160 return defaultInterval;
164 const unsigned long parsed = std::strtoul(value, &end, 10);
165 if (end == value || parsed == 0 || parsed > maxInterval) {
166 return defaultInterval;
168 return static_cast<unsigned>(parsed);
180inline bool statsEnabled()
182 static const bool enabled = statsFlagEnabled(std::getenv(
"EVAN_STATS"));
194inline unsigned statsLogInterval()
196 static const unsigned interval =
197 statsIntervalFromValue(std::getenv(
"EVAN_STATS_INTERVAL"));
210inline bool statsGpuEnabled()
212 static const bool enabled = [] {
213 const char *value = std::getenv(
"EVAN_STATS_GPU");
214 if (value ==
nullptr || value[0] ==
'\0') {
217 return value[0] !=
'0';
232constexpr uint32_t multiviewViewMask(std::size_t viewCount)
235 || viewCount >
static_cast<std::size_t
>(MAX_MULTIVIEW_VIEWS)) {
238 return (1u << viewCount) - 1u;
259constexpr std::size_t frameSlotCount(std::size_t viewCount,
260 std::size_t swapchainCount)
262 const std::size_t requested =
263 viewCount > swapchainCount ? viewCount : swapchainCount;
265 if (requested == 0) {
268 return requested >
static_cast<std::size_t
>(MAX_SWAPCHAINS)
269 ?
static_cast<std::size_t
>(MAX_SWAPCHAINS)
282const int MAX_INSTANCES_PER_VIEW = 1024;
297constexpr std::size_t nextInstanceCapacity(std::size_t required,
300 const std::size_t minimum =
301 static_cast<std::size_t
>(MAX_INSTANCES_PER_VIEW);
302 std::size_t capacity = current > minimum ? current : minimum;
304 while (capacity < required) {
306 if (capacity > std::numeric_limits<std::size_t>::max() / 2) {
321const int MAX_INDIRECT_COMMANDS_PER_VIEW = 4096;
324#if defined(__GLFW__) || defined(__OPENXR__)
325 #include <vulkan/vulkan.h>
328#include <vulkan/vulkan.h>
331 #include <vulkan/vulkan.hpp>
332 #define GLFW_INCLUDE_VULKAN
333 #include <GLFW/glfw3.h>
334 #include <GLFW/glfw3native.h>
342 #include <openxr/openxr.h>
346 #include <openxr/openxr_platform.h>
363typedef VkBool32 debugCallback_t(VkDebugUtilsMessageSeverityFlagBitsEXT,
364 VkDebugUtilsMessageTypeFlagsEXT,
365 const VkDebugUtilsMessengerCallbackDataEXT *,
bool enabled() noexcept
Whether the global counters currently record.