ADD: aspect ratio preserving part 1-add constants
This commit is contained in:
@@ -11,6 +11,7 @@ inline constexpr bool kUseValidationLayers = true;
|
|||||||
// - Default: disabled to avoid noise and I/O at shutdown.
|
// - Default: disabled to avoid noise and I/O at shutdown.
|
||||||
// - Enable at runtime by setting environment variable `VE_VMA_DEBUG=1`.
|
// - Enable at runtime by setting environment variable `VE_VMA_DEBUG=1`.
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstdint>
|
||||||
inline constexpr bool kEnableVmaDebugByDefault = false;
|
inline constexpr bool kEnableVmaDebugByDefault = false;
|
||||||
inline bool vmaDebugEnabled()
|
inline bool vmaDebugEnabled()
|
||||||
{
|
{
|
||||||
@@ -23,6 +24,12 @@ inline bool vmaDebugEnabled()
|
|||||||
return kEnableVmaDebugByDefault;
|
return kEnableVmaDebugByDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixed logical render resolution for letterboxed viewport.
|
||||||
|
// Internal rendering and camera aspect will target this size
|
||||||
|
// even when the window/swapchain size changes.
|
||||||
|
inline constexpr uint32_t kRenderWidth = 1920;
|
||||||
|
inline constexpr uint32_t kRenderHeight = 1080;
|
||||||
|
|
||||||
// Shadow mapping configuration
|
// Shadow mapping configuration
|
||||||
inline constexpr int kShadowCascadeCount = 4;
|
inline constexpr int kShadowCascadeCount = 4;
|
||||||
// Maximum shadow distance for CSM in view-space units
|
// Maximum shadow distance for CSM in view-space units
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
|
|
||||||
// Frequently used values
|
// Frequently used values
|
||||||
VkExtent2D drawExtent{};
|
VkExtent2D drawExtent{};
|
||||||
|
VkExtent2D logicalRenderExtent{};
|
||||||
|
|
||||||
// Optional convenience content pointers (moved to AssetManager for meshes)
|
// Optional convenience content pointers (moved to AssetManager for meshes)
|
||||||
|
|
||||||
@@ -95,6 +96,7 @@ public:
|
|||||||
const GPUSceneData& getSceneData() const;
|
const GPUSceneData& getSceneData() const;
|
||||||
const DrawContext& getMainDrawContext() const;
|
const DrawContext& getMainDrawContext() const;
|
||||||
VkExtent2D getDrawExtent() const { return drawExtent; }
|
VkExtent2D getDrawExtent() const { return drawExtent; }
|
||||||
|
VkExtent2D getLogicalRenderExtent() const { return logicalRenderExtent; }
|
||||||
AssetManager* getAssets() const { return assets; }
|
AssetManager* getAssets() const { return assets; }
|
||||||
// Convenience alias (singular) requested
|
// Convenience alias (singular) requested
|
||||||
AssetManager* getAsset() const { return assets; }
|
AssetManager* getAsset() const { return assets; }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <core/types.h>
|
#include <core/types.h>
|
||||||
|
#include <core/config.h>
|
||||||
|
|
||||||
class ResourceManager;
|
class ResourceManager;
|
||||||
class DeviceManager;
|
class DeviceManager;
|
||||||
@@ -42,7 +43,7 @@ private:
|
|||||||
VkSwapchainKHR _swapchain = nullptr;
|
VkSwapchainKHR _swapchain = nullptr;
|
||||||
VkFormat _swapchainImageFormat = {};
|
VkFormat _swapchainImageFormat = {};
|
||||||
VkExtent2D _swapchainExtent = {};
|
VkExtent2D _swapchainExtent = {};
|
||||||
VkExtent2D _windowExtent{1920, 1080};
|
VkExtent2D _windowExtent{kRenderWidth, kRenderHeight};
|
||||||
|
|
||||||
std::vector<VkImage> _swapchainImages;
|
std::vector<VkImage> _swapchainImages;
|
||||||
std::vector<VkImageView> _swapchainImageViews;
|
std::vector<VkImageView> _swapchainImageViews;
|
||||||
|
|||||||
@@ -145,6 +145,10 @@ void VulkanEngine::init()
|
|||||||
// We initialize SDL and create a window with it.
|
// We initialize SDL and create a window with it.
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
|
// Initialize fixed logical render resolution for the engine.
|
||||||
|
_logicalRenderExtent.width = kRenderWidth;
|
||||||
|
_logicalRenderExtent.height = kRenderHeight;
|
||||||
|
|
||||||
constexpr auto window_flags = static_cast<SDL_WindowFlags>(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
constexpr auto window_flags = static_cast<SDL_WindowFlags>(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
_swapchainManager = std::make_unique<SwapchainManager>();
|
_swapchainManager = std::make_unique<SwapchainManager>();
|
||||||
@@ -182,6 +186,7 @@ void VulkanEngine::init()
|
|||||||
};
|
};
|
||||||
_context->descriptors->init(_deviceManager->device(), 10, sizes);
|
_context->descriptors->init(_deviceManager->device(), 10, sizes);
|
||||||
}
|
}
|
||||||
|
_context->logicalRenderExtent = _logicalRenderExtent;
|
||||||
|
|
||||||
_swapchainManager->init(_deviceManager.get(), _resourceManager.get());
|
_swapchainManager->init(_deviceManager.get(), _resourceManager.get());
|
||||||
_swapchainManager->init_swapchain();
|
_swapchainManager->init_swapchain();
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ public:
|
|||||||
FrameResources &get_current_frame() { return _frames[_frameNumber % FRAME_OVERLAP]; };
|
FrameResources &get_current_frame() { return _frames[_frameNumber % FRAME_OVERLAP]; };
|
||||||
|
|
||||||
VkExtent2D _drawExtent;
|
VkExtent2D _drawExtent;
|
||||||
|
VkExtent2D _logicalRenderExtent{};
|
||||||
float renderScale = 1.f;
|
float renderScale = 1.f;
|
||||||
|
|
||||||
std::unique_ptr<DescriptorManager> _descriptorManager;
|
std::unique_ptr<DescriptorManager> _descriptorManager;
|
||||||
|
|||||||
Reference in New Issue
Block a user