refactor: move all caches to RenderResources object

This commit is contained in:
2026-06-29 04:08:57 +02:00
parent 3bc8ba02e1
commit aa5c497f29
27 changed files with 1187 additions and 692 deletions
+3 -3
View File
@@ -43,13 +43,13 @@ protected:
AppParams m_params{};
GfxDevice gfxDevice;
GameRenderer renderer;
RenderResources resources;
ImguiPass imguiPass;
Camera camera{glm::vec3(0.f, 0.f, -5.f), glm::vec3(0, 1, 0)};
MeshCache meshCache;
MaterialCache materialCache;
bool isRunning{false};
bool gamePaused{false};
@@ -10,15 +10,23 @@
class GfxDevice;
struct MaterialDefaultTextures {
ImageID white = NULL_IMAGE_ID;
ImageID normal = NULL_IMAGE_ID;
ImageID metallicRoughness = NULL_IMAGE_ID;
ImageID emissive = NULL_IMAGE_ID;
};
class MaterialCache {
friend class ResourcesInspector;
public:
void init(GfxDevice& gfxDevice);
void init(GfxDevice& gfxDevice, MaterialDefaultTextures defaults);
void cleanup(GfxDevice& gfxDevice);
MaterialID addMaterial(GfxDevice& gfxDevice, Material material);
MaterialID addSimpleTextureMaterial(GfxDevice& gfxDevice, ImageID textureID);
MaterialID addMaterial(Material material);
MaterialID addSimpleTextureMaterial(ImageID textureID);
[[nodiscard]] const Material& getMaterial(MaterialID id) const;
[[nodiscard]] MaterialID getFreeMaterialId() const;
@@ -29,7 +37,7 @@ public:
Material& getMaterialMutable(MaterialID id);
void updateMaterialGPU(GfxDevice& gfxDevice, MaterialID id);
void updateMaterialGPU(MaterialID id);
private:
std::vector<Material> materials;
@@ -37,10 +45,10 @@ private:
static constexpr auto MAX_MATERIALS = 1000;
GPUBuffer materialDataBuffer;
MaterialDefaultTextures defaultTextures;
// material which is used for meshes without materials
MaterialID placeholderMaterialId{NULL_MATERIAL_ID};
ImageID defaultNormalMapTextureID{NULL_IMAGE_ID};
};
@@ -3,13 +3,13 @@
#include <destrum/Graphics/Resources/Mesh.h>
#include "ids.h"
#include "../ids.h"
class GfxDevice;
class MeshCache {
public:
void cleanup(const GfxDevice& gfxDevice);
void cleanup(GfxDevice& gfxDevice);
MeshID addMesh(GfxDevice& gfxDevice, const CPUMesh& cpuMesh);
const GPUMesh& getMesh(MeshID id) const;
+135 -93
View File
@@ -1,153 +1,214 @@
#ifndef GFXDEVICE_H
#define GFXDEVICE_H
#include <VkBootstrap.h>
#include <vk_mem_alloc.h>
#include <array>
#include <cstdint>
#include <filesystem>
#include <functional>
#include <optional>
#include <string>
#include <SDL.h>
#include <destrum/Graphics/GPUImage.h>
#include <destrum/Graphics/Swapchain.h>
#include <destrum/Graphics/ImageCache.h>
#include <VkBootstrap.h>
#include <vk_mem_alloc.h>
#include <vulkan/vulkan.h>
#include <volk.h>
#include <VkBootstrap.h>
#include <vk_mem_alloc.h>
#include <filesystem>
#include <optional>
#include "ImmediateExecuter.h"
#include <glm/vec2.hpp>
#include <glm/vec4.hpp>
#include <destrum/Graphics/GPUImage.h>
#include <destrum/Graphics/Swapchain.h>
#include <destrum/Graphics/Resources/Buffer.h>
#include <destrum/Graphics/TextureIntent.h>
#include <destrum/Graphics/ids.h>
#include "ImmediateExecuter.h"
#include "Util.h"
class MeshCache;
class ImguiPass;
#if defined(TRACY_ENABLE)
namespace tracy { class VkCtx; }
namespace tracy
{
class VkCtx;
}
using DestrumTracyVkCtx = tracy::VkCtx*;
#else
using DestrumTracyVkCtx = void*;
#endif
using ImmediateExecuteFunction = std::function<void(VkCommandBuffer)>;
namespace {
using ImmediateExecuteFunction = std::function<void(VkCommandBuffer)>;
}
class GfxDevice {
class GfxDevice
{
public:
struct FrameData {
VkCommandPool commandPool;
VkCommandBuffer commandBuffer;
struct FrameData
{
VkCommandPool commandPool{VK_NULL_HANDLE};
VkCommandBuffer commandBuffer{VK_NULL_HANDLE};
};
struct EndFrameProps
{
VkClearColorValue clearColor{{0.f, 0.f, 0.f, 1.f}};
glm::ivec4 drawImageBlitRect{}; // where to blit draw image to
ImguiPass* imguiPass{nullptr};
};
public:
GfxDevice();
~GfxDevice() = default;
GfxDevice(const GfxDevice&) = delete;
GfxDevice& operator=(const GfxDevice&) = delete;
void init(SDL_Window* window, const std::string& appName, bool vSync);
void cleanup();
void recreateSwapchain(int width, int height);
VkCommandBuffer beginFrame();
[[nodiscard]] bool needsSwapchainRecreate() const { return swapchain.isDirty(); }
VulkanImmediateExecutor& GetImmediateExecuter();
struct EndFrameProps {
const VkClearColorValue clearColor{{0.f, 0.f, 0.f, 1.f}};
glm::ivec4 drawImageBlitRect{}; // where to blit draw image to
ImguiPass* imguiPass = nullptr;
};
void endFrame(VkCommandBuffer cmd, const GPUImage& drawImage, const EndFrameProps& props);
void cleanup();
void endFrame(
VkCommandBuffer cmd,
const GPUImage& drawImage,
const EndFrameProps& props);
void waitIdle();
BindlessSetManager& getBindlessSetManager();
VkDescriptorSetLayout getBindlessDescSetLayout() const;
const VkDescriptorSet& getBindlessDescSet() const;
void bindBindlessDescSet(VkCommandBuffer cmd, VkPipelineLayout layout) const;
[[nodiscard]] bool needsSwapchainRecreate() const
{
return swapchain.isDirty();
}
VulkanImmediateExecutor& GetImmediateExecuter();
void immediateSubmit(ImmediateExecuteFunction&& f) const;
vkb::Device getDevice() const { return device; }
std::uint32_t getCurrentFrameIndex() const {
[[nodiscard]] std::uint32_t getCurrentFrameIndex() const
{
return frameNumber % FRAMES_IN_FLIGHT;
}
FrameData& getCurrentFrame() {
[[nodiscard]] FrameData& getCurrentFrame()
{
return frames[getCurrentFrameIndex()];
}
VkExtent2D getSwapchainExtent() const { return swapchain.getExtent(); }
[[nodiscard]] const FrameData& getCurrentFrame() const
{
return frames[getCurrentFrameIndex()];
}
[[nodiscard]] VkExtent2D getSwapchainExtent() const
{
return swapchain.getExtent();
}
[[nodiscard]] GPUBuffer createBuffer(
std::size_t allocSize,
VkBufferUsageFlags usage,
VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_AUTO) const;
[[nodiscard]] VkDeviceAddress getBufferAddress(const GPUBuffer& buffer) const;
void destroyBuffer(const GPUBuffer& buffer) const;
VmaAllocator getAllocator() const { return allocator; }
[[nodiscard]] VkDeviceAddress getBufferAddress(const GPUBuffer& buffer) const;
vkb::Device getVkbDevice() const { return device; }
[[nodiscard]] GPUImage createImageRaw(
const vkutil::CreateImageInfo& createInfo,
std::optional<VmaAllocationCreateInfo> customAllocationCreateInfo = std::nullopt) const;
ImageID createImage(const vkutil::CreateImageInfo& createInfo, const std::string& debugName = "", void* pixelData = nullptr, ImageID imageId = NULL_IMAGE_ID);
ImageID createDrawImage(VkFormat format, glm::ivec2 size, const std::string& debugName = "", ImageID imageId = NULL_IMAGE_ID);
ImageID loadImageFromFile(const std::filesystem::path& path, VkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BIT, bool mipMap = false, TextureIntent intent = TextureIntent::ColorSrgb);
[[nodiscard]] std::optional<GPUImage> loadImageFromFileRaw(
const std::filesystem::path& path,
VkImageUsageFlags usage,
bool mipMap,
TextureIntent intent) const;
void uploadImageDataSized(
const GPUImage& image,
const void* pixelData,
std::size_t byteSize,
std::uint32_t layer) const;
ImageID addImageToCache(GPUImage image);
[[nodiscard]] const GPUImage& getImage(ImageID id) const;
// void uploadImageData(const GPUImage& image, void* pixelData, std::uint32_t layer = 0) const;
void uploadImageDataSized(const GPUImage& image, const void* pixelData, std::size_t byteSize, std::uint32_t layer) const;
[[nodiscard]] GPUImage createImageRaw(const vkutil::CreateImageInfo& createInfo, std::optional<VmaAllocationCreateInfo> customAllocationCreateInfo = std::nullopt) const;
GPUImage loadImageFromFileRaw(const std::filesystem::path& path, VkImageUsageFlags usage, bool mipMap, TextureIntent intent) const;
void destroyImage(const GPUImage& image) const;
[[nodiscard]] ImageID getWhiteTextureID() const { return whiteImageId; }
[[nodiscard]] vkb::Device getDevice() const
{
return device;
}
VkInstance getVkInstance() const { return instance; }
VkPhysicalDevice getVkPhysicalDevice() const { return physicalDevice; }
VkDevice getVkDevice() const { return device; }
[[nodiscard]] vkb::Device getVkbDevice() const
{
return device;
}
std::uint32_t getGraphicsQueueFamily() const { return graphicsQueueFamily; }
VkQueue getGraphicsQueue() const { return graphicsQueue; }
[[nodiscard]] VkInstance getVkInstance() const
{
return instance;
}
VkFormat getSwapchainFormat() const { return swapchainFormat; }
std::uint32_t getSwapchainImageCount() const { return swapchain.getImageCount(); }
VkImageView getSwapchainImageView(std::uint32_t imageIndex) const {
[[nodiscard]] VkPhysicalDevice getVkPhysicalDevice() const
{
return physicalDevice;
}
[[nodiscard]] VkDevice getVkDevice() const
{
return device;
}
[[nodiscard]] VmaAllocator getAllocator() const
{
return allocator;
}
[[nodiscard]] std::uint32_t getGraphicsQueueFamily() const
{
return graphicsQueueFamily;
}
[[nodiscard]] VkQueue getGraphicsQueue() const
{
return graphicsQueue;
}
[[nodiscard]] VkFormat getSwapchainFormat() const
{
return swapchainFormat;
}
[[nodiscard]] std::uint32_t getSwapchainImageCount() const
{
return swapchain.getImageCount();
}
[[nodiscard]] VkImageView getSwapchainImageView(std::uint32_t imageIndex) const
{
return swapchain.getImageView(imageIndex);
}
DestrumTracyVkCtx getTracyVkCtx() const { return tracyVkCtx; }
[[nodiscard]] DestrumTracyVkCtx getTracyVkCtx() const
{
return tracyVkCtx;
}
private:
vkb::Instance instance;
vkb::PhysicalDevice physicalDevice;
vkb::Device device;
VmaAllocator allocator;
VmaAllocator allocator{VK_NULL_HANDLE};
DestrumTracyVkCtx tracyVkCtx = nullptr;
DestrumTracyVkCtx tracyVkCtx{nullptr};
std::uint32_t graphicsQueueFamily;
VkQueue graphicsQueue;
std::uint32_t graphicsQueueFamily{0};
VkQueue graphicsQueue{VK_NULL_HANDLE};
VkSurfaceKHR surface;
VkFormat swapchainFormat;
VkSurfaceKHR surface{VK_NULL_HANDLE};
VkFormat swapchainFormat{VK_FORMAT_UNDEFINED};
Swapchain swapchain;
std::array<FrameData, FRAMES_IN_FLIGHT> frames{};
@@ -155,26 +216,7 @@ private:
VulkanImmediateExecutor executor;
ImageID whiteImageId{NULL_IMAGE_ID};
ImageID errorImageId{NULL_IMAGE_ID};
ImageCache imageCache;
bool m_vSync = false;
static uint32_t BytesPerTexel(VkFormat fmt) {
switch (fmt) {
case VK_FORMAT_R8_UNORM: return 1;
case VK_FORMAT_R8G8B8A8_UNORM: return 4;
case VK_FORMAT_B8G8R8A8_SRGB: return 4;
case VK_FORMAT_R16G16B16A16_SFLOAT: return 8;
case VK_FORMAT_R32G32B32A32_SFLOAT: return 16;
case VK_FORMAT_R8G8B8A8_SRGB: return 4;
default:
throw std::runtime_error("BytesPerTexel: unsupported format");
}
}
bool m_vSync{false};
};
#endif //GFXDEVICE_H
#endif // GFXDEVICE_H
@@ -7,6 +7,8 @@
#include <destrum/Graphics/Frustum.h>
#include <destrum/Graphics/Resources/Mesh.h>
struct MeshDrawCommand {
MeshID meshId;
@@ -1,27 +1,36 @@
#ifndef MESHPIPELINE_H
#define MESHPIPELINE_H
#include <vulkan/vulkan.h>
#include <cstdint>
#include <memory>
#include <destrum/Graphics/Pipeline.h>
#include <vector>
#include <destrum/Graphics/MeshCache.h>
#include <destrum/Graphics/MaterialCache.h>
#include <glm/mat4x4.hpp>
#include <vulkan/vulkan.h>
#include <destrum/Graphics/Pipeline.h>
#include <destrum/Graphics/Camera.h>
#include <destrum/Graphics/Resources/Buffer.h>
#include <destrum/Graphics/MeshDrawCommand.h>
class GfxDevice;
class RenderResources;
class MeshPipeline {
public:
MeshPipeline();
~MeshPipeline();
void init(GfxDevice& gfxDevice, VkFormat drawImageFormat, VkFormat depthImageFormat);
void draw(VkCommandBuffer cmd,
void init(
GfxDevice& gfxDevice,
RenderResources& resources,
VkFormat drawImageFormat,
VkFormat depthImageFormat);
void draw(
VkCommandBuffer cmd,
VkExtent2D renderExtent,
const GfxDevice& gfxDevice,
const MeshCache& meshCache,
const MaterialCache& materialCache,
const RenderResources& resources,
const Camera& camera,
const GPUBuffer& sceneDataBuffer,
const std::vector<MeshDrawCommand>& drawCommands,
@@ -33,14 +42,11 @@ public:
m_renderWireframe = wireframe;
}
bool getRenderWireframe(){ return m_renderWireframe; }
bool getRenderWireframe() const {
return m_renderWireframe;
}
private:
VkPipelineLayout m_pipelineLayout;
std::unique_ptr<Pipeline> m_pipeline;
struct PushConstants {
glm::mat4 transform;
VkDeviceAddress sceneDataBuffer;
@@ -49,8 +55,11 @@ private:
std::uint32_t padding;
};
bool m_renderWireframe{false};
private:
VkPipelineLayout m_pipelineLayout{VK_NULL_HANDLE};
std::unique_ptr<Pipeline> m_pipeline;
bool m_renderWireframe{false};
};
#endif //MESHPIPELINE_H
#endif // MESHPIPELINE_H
@@ -8,6 +8,8 @@
#include <destrum/Graphics/ids.h>
#include <destrum/Graphics/Pipeline.h>
#include <destrum/Graphics/Camera.h>
#include <destrum/Graphics/RenderResources.h>
class SkyboxPipeline final {
public:
@@ -15,14 +17,10 @@ public:
SkyboxPipeline();
~SkyboxPipeline();
void init(
GfxDevice& gfxDevice,
VkFormat drawImageFormat,
VkFormat depthImageFormat
);
void init(GfxDevice& gfxDevice, RenderResources& resources, VkFormat drawImageFormat, VkFormat depthImageFormat);
void cleanup(VkDevice device);
void draw(VkCommandBuffer cmd, GfxDevice& gfxDevice, const Camera& camera);
void draw(VkCommandBuffer cmd, RenderResources& resources, const Camera& camera);
void setSkyboxImage(const ImageID skyboxId);
@@ -0,0 +1,75 @@
#ifndef RENDER_RESOURCES_H
#define RENDER_RESOURCES_H
#include <destrum/Graphics/Caches/ImageCache.h>
#include <destrum/Graphics/Caches/MeshCache.h>
#include <destrum/Graphics/Caches/MaterialCache.h>
#include <destrum/Graphics/ids.h>
#include <destrum/Graphics/Util.h>
#include <filesystem>
#include <memory>
class GfxDevice;
class RenderResources {
public:
RenderResources();
RenderResources(const RenderResources&) = delete;
RenderResources& operator=(const RenderResources&) = delete;
void init(GfxDevice& gfxDevice);
void cleanup(GfxDevice& gfxDevice);
ImageID createImage(
GfxDevice& gfxDevice,
const vkutil::CreateImageInfo& createInfo,
const std::string& debugName = "",
void* pixelData = nullptr,
ImageID imageId = NULL_IMAGE_ID);
ImageID createDrawImage(
GfxDevice& gfxDevice,
VkFormat format,
glm::ivec2 size,
const std::string& debugName = "",
ImageID imageId = NULL_IMAGE_ID);
ImageID loadImageFromFile(
GfxDevice& gfxDevice,
const std::filesystem::path& path,
VkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BIT,
bool mipMap = false,
TextureIntent intent = TextureIntent::ColorSrgb);
ImageID addImageToCache(GPUImage image);
[[nodiscard]] const GPUImage& getImage(ImageID id) const;
[[nodiscard]] ImageID getWhiteTextureID() const { return whiteImageId; }
[[nodiscard]] ImageID getErrorTextureID() const { return errorImageId; }
BindlessSetManager& getBindlessSetManager();
VkDescriptorSetLayout getBindlessDescSetLayout() const;
const VkDescriptorSet& getBindlessDescSet() const;
void bindBindlessDescSet(VkCommandBuffer cmd, VkPipelineLayout layout) const;
MeshCache& meshes() { return *meshCache; }
const MeshCache& meshes() const { return *meshCache; }
MaterialCache& materials() { return *materialCache; }
const MaterialCache& materials() const { return *materialCache; }
private:
static uint32_t BytesPerTexel(VkFormat fmt);
std::unique_ptr<ImageCache> imageCache;
std::unique_ptr<MeshCache> meshCache;
std::unique_ptr<MaterialCache> materialCache;
ImageID whiteImageId{NULL_IMAGE_ID};
ImageID errorImageId{NULL_IMAGE_ID};
ImageID defaultNormalImageId{NULL_IMAGE_ID};
};
#endif
+14 -15
View File
@@ -5,15 +5,16 @@
#include <destrum/Graphics/Camera.h>
#include <destrum/Graphics/Pipelines/MeshPipeline.h>
#include <destrum/Graphics/MeshCache.h>
#include <destrum/Graphics/ids.h>
#include <destrum/Graphics/MeshDrawCommand.h>
#include <destrum/Graphics/Resources/NBuffer.h>
#include <destrum/Graphics/MaterialCache.h>
#include <destrum/Graphics/RenderResources.h>
#include <memory>
#include <destrum/Graphics/Pipelines/SkinningPipeline.h>
#include "Pipelines/SkyboxPipeline.h"
class GameRenderer {
@@ -26,9 +27,9 @@ public:
float fogDensity;
};
explicit GameRenderer(MeshCache& meshCache, MaterialCache& matCache);
explicit GameRenderer();
void init(GfxDevice& gfxDevice, const glm::ivec2& drawImageSize);
void init(GfxDevice& gfxDevice, RenderResources& _resources, glm::ivec2 drawImageSize);
void beginDrawing(GfxDevice& gfxDevice);
void endDrawing();
@@ -36,12 +37,8 @@ public:
void cleanup(GfxDevice& gfxDevice);
void drawMesh(MeshID id, const glm::mat4& transform, MaterialID materialId);
void drawSkinnedMesh(MeshID id,
const glm::mat4& transform,
MaterialID materialId,
SkinnedMesh* skinnedMesh,
std::size_t jointMatricesStartIndex);
const GPUImage& getDrawImage(const GfxDevice& gfx_device) const;
void drawSkinnedMesh(MeshID id, const glm::mat4& transform, MaterialID materialId, SkinnedMesh* skinnedMesh, std::size_t jointMatricesStartIndex);
const GPUImage& getDrawImage() const;
void resize(GfxDevice& gfxDevice, const glm::ivec2& newSize) {
createDrawImage(gfxDevice, newSize, false);
@@ -53,9 +50,6 @@ public:
void setSkyboxTexture(ImageID skyboxImageId);
void flushMaterialUpdates(GfxDevice& gfxDevice);
[[nodiscard]] MeshCache& GetMeshCache() const {
return meshCache;
}
[[nodiscard]] SkinningPipeline& getSkinningPipeline() const {
return *skinningPipeline;
@@ -69,11 +63,16 @@ public:
return meshPipeline->getRenderWireframe();
}
RenderResources* getResources()
{
return resources;
}
private:
void createDrawImage(GfxDevice& gfxDevice, const glm::ivec2& drawImageSize, bool firstCreate);
MeshCache& meshCache;
MaterialCache& materialCache;
RenderResources* resources = nullptr;
std::vector<MaterialID> pendingMaterialUploads;
@@ -2,65 +2,115 @@
#define CUBEMAP_H
#include <array>
#include <cstdint>
#include <filesystem>
#include <memory>
#include <string>
#include <glm/glm.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <vulkan/vulkan.h>
#include <destrum/Graphics/ids.h>
#include <destrum/Graphics/Pipeline.h>
#include "destrum/Graphics/Pipeline.h"
class GfxDevice;
class RenderResources;
class CubeMap {
public:
explicit CubeMap();
~CubeMap();
void LoadCubeMap(const std::filesystem::path &directoryPath);
void RenderToCubemap(ImageID inputImage, VkImage outputImage, std::array<VkImageView, 6> faceViews, uint32_t size);
CubeMap(const CubeMap&) = delete;
CubeMap& operator=(const CubeMap&) = delete;
void InitCubemapPipeline(const std::string& vertPath, const std::string& fragPath);
void CreateCubeMap();
ImageID GetCubeMapImageID();
void cleanup(GfxDevice& gfxDevice);
void LoadCubeMap(
GfxDevice& gfxDevice,
RenderResources& resources,
const std::filesystem::path& directoryPath);
void RenderToCubemap(
GfxDevice& gfxDevice,
RenderResources& resources,
ImageID inputImage,
VkImage outputImage,
std::array<VkImageView, 6> faceViews,
std::uint32_t size);
void InitCubemapPipeline(
GfxDevice& gfxDevice,
RenderResources& resources,
const std::string& vertPath,
const std::string& fragPath);
void CreateCubeMap(
GfxDevice& gfxDevice,
RenderResources& resources);
[[nodiscard]] ImageID GetCubeMapImageID() const;
private:
const std::array<glm::mat4, 6> viewMatrices = {
// POSITIVE_X
glm::lookAt(glm::vec3(0.0f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, -1.0f, 0.0f)),
glm::lookAt(
glm::vec3(0.0f),
glm::vec3(1.0f, 0.0f, 0.0f),
glm::vec3(0.0f, -1.0f, 0.0f)),
// NEGATIVE_X
glm::lookAt(glm::vec3(0.0f), glm::vec3(-1.0f, 0.0f, 0.0f), glm::vec3(0.0f, -1.0f, 0.0f)),
glm::lookAt(
glm::vec3(0.0f),
glm::vec3(-1.0f, 0.0f, 0.0f),
glm::vec3(0.0f, -1.0f, 0.0f)),
// POSITIVE_Y
glm::lookAt(glm::vec3(0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
glm::lookAt(
glm::vec3(0.0f),
glm::vec3(0.0f, 1.0f, 0.0f),
glm::vec3(0.0f, 0.0f, 1.0f)),
// NEGATIVE_Y
glm::lookAt(glm::vec3(0.0f), glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f)),
glm::lookAt(
glm::vec3(0.0f),
glm::vec3(0.0f, -1.0f, 0.0f),
glm::vec3(0.0f, 0.0f, -1.0f)),
// POSITIVE_Z
glm::lookAt(glm::vec3(0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, -1.0f, 0.0f)),
glm::lookAt(
glm::vec3(0.0f),
glm::vec3(0.0f, 0.0f, 1.0f),
glm::vec3(0.0f, -1.0f, 0.0f)),
// NEGATIVE_Z
glm::lookAt(glm::vec3(0.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, -1.0f, 0.0f))
glm::lookAt(
glm::vec3(0.0f),
glm::vec3(0.0f, 0.0f, -1.0f),
glm::vec3(0.0f, -1.0f, 0.0f))
};
struct alignas(16) PC {
glm::mat4 viewMtx; // 64
glm::mat4 projMtx; // 64
std::uint32_t inputImageId; // 4
glm::mat4 viewMtx;
glm::mat4 projMtx;
std::uint32_t inputImageId;
};
private:
glm::mat4 m_projection{};
ImageID m_hdrImage{};
ImageID m_hdrImage{NULL_IMAGE_ID};
ImageID m_cubemapImageID{NULL_IMAGE_ID};
uint32_t m_cubeMapSize = 1024; // Default size for cube map
VkImageView m_skyboxView;
std::uint32_t m_cubeMapSize{1024};
VkPipelineLayout m_cubemapPipelineLayout = VK_NULL_HANDLE;
VkPipelineLayout m_cubemapPipelineLayout{VK_NULL_HANDLE};
std::unique_ptr<Pipeline> m_cubemapPipeline;
std::string m_cubemapVert;
std::string m_cubemapFrag;
ImageID m_cubemapImageID;
};
#endif //CUBEMAP_H
#endif // CUBEMAP_H
+1
View File
@@ -32,6 +32,7 @@ public:
return *m_renderer;
}
private:
GfxDevice* m_gfxDevice{nullptr};
GameRenderer* m_renderer{nullptr};