diff --git a/EvoEngine_Plugins/DigitalAgriculture/src/SorghumLayer.cpp b/EvoEngine_Plugins/DigitalAgriculture/src/SorghumLayer.cpp index aa01624..f7530d0 100644 --- a/EvoEngine_Plugins/DigitalAgriculture/src/SorghumLayer.cpp +++ b/EvoEngine_Plugins/DigitalAgriculture/src/SorghumLayer.cpp @@ -5,7 +5,7 @@ #endif #include #include "ClassRegistry.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "SkyIlluminance.hpp" #include "SorghumStateGenerator.hpp" #include "Times.hpp" diff --git a/EvoEngine_Plugins/EcoSysLab/include/Utilities/TreeVisualizer.hpp b/EvoEngine_Plugins/EcoSysLab/include/Utilities/TreeVisualizer.hpp index 573434b..b14cc84 100644 --- a/EvoEngine_Plugins/EcoSysLab/include/Utilities/TreeVisualizer.hpp +++ b/EvoEngine_Plugins/EcoSysLab/include/Utilities/TreeVisualizer.hpp @@ -2,7 +2,7 @@ #include "Application.hpp" #include "EditorLayer.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Jobs.hpp" #include "StrandModel.hpp" #include "TreeModel.hpp" diff --git a/EvoEngine_Plugins/EcoSysLab/src/ForestDescriptor.cpp b/EvoEngine_Plugins/EcoSysLab/src/ForestDescriptor.cpp index ac272d9..d78d18d 100644 --- a/EvoEngine_Plugins/EcoSysLab/src/ForestDescriptor.cpp +++ b/EvoEngine_Plugins/EcoSysLab/src/ForestDescriptor.cpp @@ -7,7 +7,7 @@ #include "Climate.hpp" #include "EcoSysLabLayer.hpp" #include "EditorLayer.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Tree.hpp" using namespace eco_sys_lab; diff --git a/EvoEngine_Plugins/EcoSysLab/src/RadialBoundingVolume.cpp b/EvoEngine_Plugins/EcoSysLab/src/RadialBoundingVolume.cpp index 1a1e70a..c1ac20a 100644 --- a/EvoEngine_Plugins/EcoSysLab/src/RadialBoundingVolume.cpp +++ b/EvoEngine_Plugins/EcoSysLab/src/RadialBoundingVolume.cpp @@ -2,7 +2,7 @@ #include -#include "Graphics.hpp" +#include "Platform.hpp" #include "PointCloud.hpp" #include "Tree.hpp" diff --git a/EvoEngine_Plugins/EcoSysLab/src/Soil.cpp b/EvoEngine_Plugins/EcoSysLab/src/Soil.cpp index f7d97c7..d0aba32 100644 --- a/EvoEngine_Plugins/EcoSysLab/src/Soil.cpp +++ b/EvoEngine_Plugins/EcoSysLab/src/Soil.cpp @@ -5,7 +5,7 @@ #include "EcoSysLabLayer.hpp" #include "EditorLayer.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "HeightField.hpp" using namespace eco_sys_lab; diff --git a/EvoEngine_Plugins/EcoSysLab/src/TreeStructor.cpp b/EvoEngine_Plugins/EcoSysLab/src/TreeStructor.cpp index 2e7029f..b2649ad 100644 --- a/EvoEngine_Plugins/EcoSysLab/src/TreeStructor.cpp +++ b/EvoEngine_Plugins/EcoSysLab/src/TreeStructor.cpp @@ -2,7 +2,7 @@ #include #include "EcoSysLabLayer.hpp" #include "FoliageDescriptor.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "rapidcsv.h" using namespace eco_sys_lab; diff --git a/EvoEngine_Plugins/Universe/src/StarClusterSystem.cpp b/EvoEngine_Plugins/Universe/src/StarClusterSystem.cpp index 5fb2d04..3b5a15c 100644 --- a/EvoEngine_Plugins/Universe/src/StarClusterSystem.cpp +++ b/EvoEngine_Plugins/Universe/src/StarClusterSystem.cpp @@ -4,7 +4,7 @@ #include "Serialization.hpp" #include "Resources.hpp" #include "ClassRegistry.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Jobs.hpp" #include "Particles.hpp" #include "Times.hpp" diff --git a/EvoEngine_SDK/include/Core/Input.hpp b/EvoEngine_SDK/include/Core/Input.hpp index 54bffbd..fee2dc6 100644 --- a/EvoEngine_SDK/include/Core/Input.hpp +++ b/EvoEngine_SDK/include/Core/Input.hpp @@ -14,7 +14,7 @@ class Input final { static glm::vec2 GetMousePosition(); private: - friend class Graphics; + friend class Platform; friend class Application; friend class EditorLayer; std::unordered_map pressed_keys_ = {}; diff --git a/EvoEngine_SDK/include/Layers/WindowLayer.hpp b/EvoEngine_SDK/include/Layers/WindowLayer.hpp index 717e523..fd3cefd 100644 --- a/EvoEngine_SDK/include/Layers/WindowLayer.hpp +++ b/EvoEngine_SDK/include/Layers/WindowLayer.hpp @@ -2,7 +2,7 @@ #include "ILayer.hpp" namespace evo_engine { class WindowLayer final : public ILayer { - friend class Graphics; + friend class Platform; friend class RenderLayer; #pragma region Presenters std::vector monitors_; diff --git a/EvoEngine_SDK/include/Rendering/Camera.hpp b/EvoEngine_SDK/include/Rendering/Camera.hpp index 89d6c11..a4cecc7 100644 --- a/EvoEngine_SDK/include/Rendering/Camera.hpp +++ b/EvoEngine_SDK/include/Rendering/Camera.hpp @@ -24,7 +24,7 @@ struct CameraInfoBlock { }; class Camera final : public IPrivateComponent { - friend class Graphics; + friend class Platform; friend class RenderLayer; friend class EditorLayer; friend struct CameraInfoBlock; diff --git a/EvoEngine_SDK/include/Rendering/Geometry/GeometryStorage.hpp b/EvoEngine_SDK/include/Rendering/Geometry/GeometryStorage.hpp index 2e622eb..4bf4be6 100644 --- a/EvoEngine_SDK/include/Rendering/Geometry/GeometryStorage.hpp +++ b/EvoEngine_SDK/include/Rendering/Geometry/GeometryStorage.hpp @@ -1,36 +1,36 @@ #pragma once -#include "Graphics.hpp" +#include "Platform.hpp" #include "GraphicsResources.hpp" #include "ISingleton.hpp" #include "Vertex.hpp" namespace evo_engine { struct VertexDataChunk { - Vertex vertex_data[Graphics::Constants::meshlet_max_vertices_size] = {}; + Vertex vertex_data[Platform::Constants::meshlet_max_vertices_size] = {}; }; struct Meshlet { - glm::u8vec3 triangles[Graphics::Constants::meshlet_max_triangles_size] = {}; // up to 126 triangles + glm::u8vec3 triangles[Platform::Constants::meshlet_max_triangles_size] = {}; // up to 126 triangles uint32_t vertices_size = 0; uint32_t triangle_size = 0; uint32_t vertex_chunk_index = 0; }; struct SkinnedVertexDataChunk { - SkinnedVertex skinned_vertex_data[Graphics::Constants::meshlet_max_vertices_size] = {}; + SkinnedVertex skinned_vertex_data[Platform::Constants::meshlet_max_vertices_size] = {}; }; struct SkinnedMeshlet { - glm::u8vec3 skinned_triangles[Graphics::Constants::meshlet_max_triangles_size] = {}; // up to 126 triangles + glm::u8vec3 skinned_triangles[Platform::Constants::meshlet_max_triangles_size] = {}; // up to 126 triangles uint32_t skinned_vertices_size = 0; uint32_t skinned_triangle_size = 0; uint32_t skinned_vertex_chunk_index = 0; }; struct StrandPointDataChunk { - StrandPoint strand_point_data[Graphics::Constants::meshlet_max_vertices_size] = {}; + StrandPoint strand_point_data[Platform::Constants::meshlet_max_vertices_size] = {}; }; struct StrandMeshlet { - glm::u8vec4 segments[Graphics::Constants::meshlet_max_triangles_size] = {}; // up to 126 triangles + glm::u8vec4 segments[Platform::Constants::meshlet_max_triangles_size] = {}; // up to 126 triangles uint32_t strand_points_size = 0; uint32_t segment_size = 0; uint32_t strand_point_chunk_index = 0; @@ -105,7 +105,7 @@ class GeometryStorage final { void UploadData(); friend class RenderLayer; friend class Resources; - friend class Graphics; + friend class Platform; static void DeviceSync(); static void Initialize(); diff --git a/EvoEngine_SDK/include/Rendering/Geometry/Mesh.hpp b/EvoEngine_SDK/include/Rendering/Geometry/Mesh.hpp index 4e020fd..5eb84b5 100644 --- a/EvoEngine_SDK/include/Rendering/Geometry/Mesh.hpp +++ b/EvoEngine_SDK/include/Rendering/Geometry/Mesh.hpp @@ -1,7 +1,7 @@ #pragma once #include "Bound.hpp" #include "GeometryStorage.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "GraphicsResources.hpp" #include "IAsset.hpp" #include "IGeometry.hpp" diff --git a/EvoEngine_SDK/include/Rendering/Geometry/SkinnedMesh.hpp b/EvoEngine_SDK/include/Rendering/Geometry/SkinnedMesh.hpp index 4e37907..340acd9 100644 --- a/EvoEngine_SDK/include/Rendering/Geometry/SkinnedMesh.hpp +++ b/EvoEngine_SDK/include/Rendering/Geometry/SkinnedMesh.hpp @@ -33,7 +33,7 @@ class SkinnedMesh : public IAsset, public IGeometry { Bound bound_; friend class SkinnedMeshRenderer; friend class Particles; - friend class Graphics; + friend class Platform; friend class RenderLayer; SkinnedVertexAttributes skinned_vertex_attributes_ = {}; std::vector skinned_vertices_; diff --git a/EvoEngine_SDK/include/Rendering/PBR/EnvironmentalMap.hpp b/EvoEngine_SDK/include/Rendering/PBR/EnvironmentalMap.hpp index 947ce61..97126bf 100644 --- a/EvoEngine_SDK/include/Rendering/PBR/EnvironmentalMap.hpp +++ b/EvoEngine_SDK/include/Rendering/PBR/EnvironmentalMap.hpp @@ -6,7 +6,7 @@ namespace evo_engine { class EnvironmentalMap final : public IAsset { - friend class Graphics; + friend class Platform; friend class Camera; friend class Environment; friend class RenderLayer; diff --git a/EvoEngine_SDK/include/Rendering/PBR/Material.hpp b/EvoEngine_SDK/include/Rendering/PBR/Material.hpp index 2397094..89af8b7 100644 --- a/EvoEngine_SDK/include/Rendering/PBR/Material.hpp +++ b/EvoEngine_SDK/include/Rendering/PBR/Material.hpp @@ -1,6 +1,6 @@ #pragma once #include "AssetRef.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "IAsset.hpp" #include "MaterialProperties.hpp" #include "Texture2D.hpp" diff --git a/EvoEngine_SDK/include/Rendering/Platform/ComputePipeline.hpp b/EvoEngine_SDK/include/Rendering/Platform/ComputePipeline.hpp index 9abb67d..723a5da 100644 --- a/EvoEngine_SDK/include/Rendering/Platform/ComputePipeline.hpp +++ b/EvoEngine_SDK/include/Rendering/Platform/ComputePipeline.hpp @@ -3,7 +3,7 @@ namespace evo_engine { class Shader; class ComputePipeline final : public IGraphicsResource{ - friend class Graphics; + friend class Platform; std::unique_ptr pipeline_layout_ = {}; diff --git a/EvoEngine_SDK/include/Rendering/Platform/GraphicsPipeline.hpp b/EvoEngine_SDK/include/Rendering/Platform/GraphicsPipeline.hpp index d7764a4..2bd8013 100644 --- a/EvoEngine_SDK/include/Rendering/Platform/GraphicsPipeline.hpp +++ b/EvoEngine_SDK/include/Rendering/Platform/GraphicsPipeline.hpp @@ -97,7 +97,7 @@ struct PipelineDynamicState { #pragma endregion class GraphicsPipeline final : public IGraphicsResource { - friend class Graphics; + friend class Platform; friend class RenderLayer; friend class GraphicsPipelineStates; diff --git a/EvoEngine_SDK/include/Rendering/Platform/GraphicsPipelineStates.hpp b/EvoEngine_SDK/include/Rendering/Platform/GraphicsPipelineStates.hpp index fb41808..3d3a5ad 100644 --- a/EvoEngine_SDK/include/Rendering/Platform/GraphicsPipelineStates.hpp +++ b/EvoEngine_SDK/include/Rendering/Platform/GraphicsPipelineStates.hpp @@ -3,7 +3,7 @@ namespace evo_engine { class GraphicsPipelineStates { - friend class Graphics; + friend class Platform; VkViewport view_port_applied_ = {}; VkRect2D scissor_applied_ = {}; diff --git a/EvoEngine_SDK/include/Rendering/Platform/GraphicsResources.hpp b/EvoEngine_SDK/include/Rendering/Platform/GraphicsResources.hpp index d1ec66e..14c400a 100644 --- a/EvoEngine_SDK/include/Rendering/Platform/GraphicsResources.hpp +++ b/EvoEngine_SDK/include/Rendering/Platform/GraphicsResources.hpp @@ -105,7 +105,7 @@ class ImageView final : public IGraphicsResource { VkComponentMapping components_; VkImageSubresourceRange subresource_range_; friend class Swapchain; - friend class Graphics; + friend class Platform; public: explicit ImageView(const VkImageViewCreateInfo& image_view_create_info); @@ -332,7 +332,7 @@ class ShaderExt final : public IGraphicsResource { enum class CommandBufferStatus { Ready, Recording, Recorded, Invalid }; class CommandBuffer final : public IGraphicsResource { - friend class Graphics; + friend class Platform; CommandBufferStatus status_ = CommandBufferStatus::Invalid; VkCommandBuffer vk_command_buffer_ = VK_NULL_HANDLE; @@ -358,7 +358,7 @@ class CommandBuffer final : public IGraphicsResource { }; class CommandQueue final : public IGraphicsResource { - friend class Graphics; + friend class Platform; VkQueue vk_queue_ = VK_NULL_HANDLE; public: diff --git a/EvoEngine_SDK/include/Rendering/Platform/Graphics.hpp b/EvoEngine_SDK/include/Rendering/Platform/Platform.hpp similarity index 95% rename from EvoEngine_SDK/include/Rendering/Platform/Graphics.hpp rename to EvoEngine_SDK/include/Rendering/Platform/Platform.hpp index a6205cc..77712d8 100644 --- a/EvoEngine_SDK/include/Rendering/Platform/Graphics.hpp +++ b/EvoEngine_SDK/include/Rendering/Platform/Platform.hpp @@ -19,8 +19,8 @@ struct SwapChainSupportDetails { std::vector present_modes; }; -class Graphics final { - EVOENGINE_SINGLETON_INSTANCE(Graphics) +class Platform final { + EVOENGINE_SINGLETON_INSTANCE(Platform) friend class Application; friend class Resources; friend class Lighting; @@ -56,8 +56,7 @@ class Graphics final { std::unique_ptr immediate_submit_queue_ {}; - std::unique_ptr graphics_queue_{}; - std::unique_ptr compute_queue_{}; + std::unique_ptr main_queue_{}; std::unique_ptr present_queue_{}; std::shared_ptr swapchain_ = {}; @@ -142,7 +141,7 @@ class Graphics final { std::vector>> command_buffer_pool_ = {}; std::shared_ptr immediate_submit_command_buffer; public: - static void RecordCommandsToMainGraphicsQueue(const std::function& action); + static void RecordCommandsMainQueue(const std::function& action); double cpu_wait_time = 0.0f; @@ -218,8 +217,7 @@ class Graphics final { static uint32_t GetCurrentFrameIndex(); static uint32_t GetNextImageIndex(); static VkCommandPool GetVkCommandPool(); - static const std::unique_ptr& GetGraphicsQueue(); - static const std::unique_ptr& GetComputeQueue(); + static const std::unique_ptr& GetMainQueue(); static const std::unique_ptr& GetImmediateSubmitQueue(); static const std::unique_ptr& GetPresentQueue(); static VmaAllocator GetVmaAllocator(); diff --git a/EvoEngine_SDK/include/Rendering/Renderer/SkinnedMeshRenderer.hpp b/EvoEngine_SDK/include/Rendering/Renderer/SkinnedMeshRenderer.hpp index face12f..5070b60 100644 --- a/EvoEngine_SDK/include/Rendering/Renderer/SkinnedMeshRenderer.hpp +++ b/EvoEngine_SDK/include/Rendering/Renderer/SkinnedMeshRenderer.hpp @@ -10,7 +10,7 @@ class SkinnedMeshRenderer : public IPrivateComponent { friend class Prefab; friend class RenderLayer; void RenderBound(const std::shared_ptr& editor_layer, glm::vec4& color); - friend class Graphics; + friend class Platform; bool rag_doll_ = false; std::vector rag_doll_transform_chain_; std::vector bound_entities_; diff --git a/EvoEngine_SDK/include/Rendering/Texture/Cubemap.hpp b/EvoEngine_SDK/include/Rendering/Texture/Cubemap.hpp index 8999c79..55342bf 100644 --- a/EvoEngine_SDK/include/Rendering/Texture/Cubemap.hpp +++ b/EvoEngine_SDK/include/Rendering/Texture/Cubemap.hpp @@ -1,5 +1,5 @@ #pragma once -#include "Graphics.hpp" +#include "Platform.hpp" #include "GraphicsResources.hpp" #include "IAsset.hpp" #include "Texture2D.hpp" diff --git a/EvoEngine_SDK/include/Rendering/Texture/RenderTexture.hpp b/EvoEngine_SDK/include/Rendering/Texture/RenderTexture.hpp index b4af1dc..2c97ca7 100644 --- a/EvoEngine_SDK/include/Rendering/Texture/RenderTexture.hpp +++ b/EvoEngine_SDK/include/Rendering/Texture/RenderTexture.hpp @@ -10,7 +10,7 @@ struct RenderTextureCreateInfo { }; class RenderTexture { - friend class Graphics; + friend class Platform; friend class RenderLayer; friend class Camera; std::shared_ptr color_image_ = {}; diff --git a/EvoEngine_SDK/include/Rendering/Texture/TextureStorage.hpp b/EvoEngine_SDK/include/Rendering/Texture/TextureStorage.hpp index 7cf5c18..8133df4 100644 --- a/EvoEngine_SDK/include/Rendering/Texture/TextureStorage.hpp +++ b/EvoEngine_SDK/include/Rendering/Texture/TextureStorage.hpp @@ -60,7 +60,7 @@ class TextureStorage final { std::vector cubemaps_; friend class RenderLayer; - friend class Graphics; + friend class Platform; friend class Resources; static void DeviceSync(); diff --git a/EvoEngine_SDK/src/Application.cpp b/EvoEngine_SDK/src/Application.cpp index 8b0a478..20d22a4 100644 --- a/EvoEngine_SDK/src/Application.cpp +++ b/EvoEngine_SDK/src/Application.cpp @@ -5,7 +5,7 @@ #include "Cubemap.hpp" #include "EditorLayer.hpp" #include "EnvironmentalMap.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Input.hpp" #include "Jobs.hpp" #include "Json.hpp" @@ -96,7 +96,7 @@ void Application::PreUpdateInternal() { application.application_execution_status_ = ApplicationExecutionStatus::PreUpdate; Input::PreUpdate(); - Graphics::PreUpdate(); + Platform::PreUpdate(); if (application.application_status_ == ApplicationStatus::NoProject) return; @@ -239,19 +239,19 @@ void Application::LateUpdateInternal() { } } - Graphics::RecordCommandsToMainGraphicsQueue([&](const VkCommandBuffer vk_command_buffer) { - Graphics::EverythingBarrier(vk_command_buffer); + Platform::RecordCommandsMainQueue([&](const VkCommandBuffer vk_command_buffer) { + Platform::EverythingBarrier(vk_command_buffer); constexpr VkClearValue clear_color = {{{0.0f, 0.0f, 0.0f, 1.0f}}}; VkRect2D render_area; render_area.offset = {0, 0}; - render_area.extent = Graphics::GetSwapchain()->GetImageExtent(); - Graphics::TransitImageLayout(vk_command_buffer, Graphics::GetSwapchain()->GetVkImage(), - Graphics::GetSwapchain()->GetImageFormat(), 1, VK_IMAGE_LAYOUT_UNDEFINED, + render_area.extent = Platform::GetSwapchain()->GetImageExtent(); + Platform::TransitImageLayout(vk_command_buffer, Platform::GetSwapchain()->GetVkImage(), + Platform::GetSwapchain()->GetImageFormat(), 1, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); VkRenderingAttachmentInfo color_attachment_info{}; color_attachment_info.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO; - color_attachment_info.imageView = Graphics::GetSwapchain()->GetVkImageView(); + color_attachment_info.imageView = Platform::GetSwapchain()->GetVkImageView(); color_attachment_info.imageLayout = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR; color_attachment_info.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; color_attachment_info.storeOp = VK_ATTACHMENT_STORE_OP_STORE; @@ -270,8 +270,8 @@ void Application::LateUpdateInternal() { ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), vk_command_buffer); vkCmdEndRendering(vk_command_buffer); - Graphics::TransitImageLayout(vk_command_buffer, Graphics::GetSwapchain()->GetVkImage(), - Graphics::GetSwapchain()->GetImageFormat(), 1, + Platform::TransitImageLayout(vk_command_buffer, Platform::GetSwapchain()->GetVkImage(), + Platform::GetSwapchain()->GetImageFormat(), 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); }); @@ -299,7 +299,7 @@ void Application::LateUpdateInternal() { if (application.application_status_ == ApplicationStatus::Step) application.application_status_ = ApplicationStatus::Pause; } - Graphics::LateUpdate(); + Platform::LateUpdate(); } const ApplicationInfo& Application::GetApplicationInfo() { @@ -346,9 +346,9 @@ void Application::Initialize(const ApplicationInfo& application_create_info) { Jobs::Initialize(default_thread_size - 2); Entities::Initialize(); TransformGraph::Initialize(); - Graphics::Initialize(); + Platform::Initialize(); Resources::Initialize(); - Graphics::PostResourceLoadingInitialization(); + Platform::PostResourceLoadingInitialization(); Resources::InitializeEnvironmentalMap(); for (const auto& layer : application.layers_) { diff --git a/EvoEngine_SDK/src/Camera.cpp b/EvoEngine_SDK/src/Camera.cpp index c0c8a0e..b861412 100644 --- a/EvoEngine_SDK/src/Camera.cpp +++ b/EvoEngine_SDK/src/Camera.cpp @@ -35,7 +35,7 @@ void Camera::UpdateGBuffer() { image_info.extent = render_texture_->GetExtent(); image_info.mipLevels = 1; image_info.arrayLayers = 1; - image_info.format = Graphics::Constants::g_buffer_color; + image_info.format = Platform::Constants::g_buffer_color; image_info.tiling = VK_IMAGE_TILING_OPTIMAL; image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | @@ -49,7 +49,7 @@ void Camera::UpdateGBuffer() { view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = g_buffer_normal_->GetVkImage(); view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - view_info.format = Graphics::Constants::g_buffer_color; + view_info.format = Platform::Constants::g_buffer_color; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; view_info.subresourceRange.baseMipLevel = 0; view_info.subresourceRange.levelCount = 1; @@ -66,7 +66,7 @@ void Camera::UpdateGBuffer() { sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; @@ -82,7 +82,7 @@ void Camera::UpdateGBuffer() { image_info.extent = render_texture_->GetExtent(); image_info.mipLevels = 1; image_info.arrayLayers = 1; - image_info.format = Graphics::Constants::g_buffer_color; + image_info.format = Platform::Constants::g_buffer_color; image_info.tiling = VK_IMAGE_TILING_OPTIMAL; image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | @@ -96,7 +96,7 @@ void Camera::UpdateGBuffer() { view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = g_buffer_material_->GetVkImage(); view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - view_info.format = Graphics::Constants::g_buffer_material; + view_info.format = Platform::Constants::g_buffer_material; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; view_info.subresourceRange.baseMipLevel = 0; view_info.subresourceRange.levelCount = 1; @@ -113,7 +113,7 @@ void Camera::UpdateGBuffer() { sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; @@ -122,7 +122,7 @@ void Camera::UpdateGBuffer() { g_buffer_material_sampler_ = std::make_unique(sampler_info); } - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { TransitGBufferImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); }); @@ -250,7 +250,7 @@ void Camera::OnCreate() { render_texture_create_info.extent.depth = 1; render_texture_ = std::make_unique(render_texture_create_info); - g_buffer_descriptor_set_ = std::make_shared(Graphics::GetDescriptorSetLayout("CAMERA_GBUFFER_LAYOUT")); + g_buffer_descriptor_set_ = std::make_shared(Platform::GetDescriptorSetLayout("CAMERA_GBUFFER_LAYOUT")); UpdateGBuffer(); } diff --git a/EvoEngine_SDK/src/ComputePipeline.cpp b/EvoEngine_SDK/src/ComputePipeline.cpp index 1977537..a8f2fd5 100644 --- a/EvoEngine_SDK/src/ComputePipeline.cpp +++ b/EvoEngine_SDK/src/ComputePipeline.cpp @@ -1,11 +1,11 @@ #include "ComputePipeline.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Shader.hpp" using namespace evo_engine; ComputePipeline::~ComputePipeline() { if (vk_compute_pipeline_ != VK_NULL_HANDLE) { - vkDestroyPipeline(Graphics::GetVkDevice(), vk_compute_pipeline_, nullptr); + vkDestroyPipeline(Platform::GetVkDevice(), vk_compute_pipeline_, nullptr); vk_compute_pipeline_ = nullptr; } } @@ -37,7 +37,7 @@ void ComputePipeline::Initialize() { pipeline_info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO; pipeline_info.layout = pipeline_layout_->GetVkPipelineLayout(); pipeline_info.stage = shader_stage_create_info; - Graphics::CheckVk(vkCreateComputePipelines(Graphics::GetVkDevice(), VK_NULL_HANDLE, 1, &pipeline_info, nullptr, + Platform::CheckVk(vkCreateComputePipelines(Platform::GetVkDevice(), VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &vk_compute_pipeline_)); } diff --git a/EvoEngine_SDK/src/Cubemap.cpp b/EvoEngine_SDK/src/Cubemap.cpp index 148ee15..4af6720 100644 --- a/EvoEngine_SDK/src/Cubemap.cpp +++ b/EvoEngine_SDK/src/Cubemap.cpp @@ -2,7 +2,7 @@ #include "Application.hpp" #include "Console.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "RenderLayer.hpp" #include "Resources.hpp" #include "TextureStorage.hpp" @@ -49,7 +49,7 @@ void Cubemap::ConvertFromEquirectangularTexture(const std::shared_ptr depth_image_info.extent.depth = 1; depth_image_info.mipLevels = 1; depth_image_info.arrayLayers = 1; - depth_image_info.format = Graphics::Constants::shadow_map; + depth_image_info.format = Platform::Constants::shadow_map; depth_image_info.tiling = VK_IMAGE_TILING_OPTIMAL; depth_image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; depth_image_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; @@ -57,7 +57,7 @@ void Cubemap::ConvertFromEquirectangularTexture(const std::shared_ptr depth_image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; const auto depth_image = std::make_shared(depth_image_info); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { depth_image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); }); @@ -65,7 +65,7 @@ void Cubemap::ConvertFromEquirectangularTexture(const std::shared_ptr depth_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; depth_view_info.image = depth_image->GetVkImage(); depth_view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - depth_view_info.format = Graphics::Constants::shadow_map; + depth_view_info.format = Platform::Constants::shadow_map; depth_view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; depth_view_info.subresourceRange.baseMipLevel = 0; depth_view_info.subresourceRange.levelCount = 1; @@ -75,7 +75,7 @@ void Cubemap::ConvertFromEquirectangularTexture(const std::shared_ptr #pragma endregion const std::unique_ptr temp_set = - std::make_unique(Graphics::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); + std::make_unique(Platform::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); VkDescriptorImageInfo descriptor_image_info{}; descriptor_image_info.imageView = target_texture->GetVkImageView(); descriptor_image_info.imageLayout = target_texture->GetLayout(); @@ -92,8 +92,8 @@ void Cubemap::ConvertFromEquirectangularTexture(const std::shared_ptr glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, -1.0f, 0.0f)), glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, -1.0f, 0.0f))}; - const auto equirectangular_to_cubemap = Graphics::GetGraphicsPipeline("EQUIRECTANGULAR_TO_CUBEMAP"); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + const auto equirectangular_to_cubemap = Platform::GetGraphicsPipeline("EQUIRECTANGULAR_TO_CUBEMAP"); + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { storage.image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); #pragma region Viewport and scissor VkRect2D render_area; @@ -164,7 +164,7 @@ void Cubemap::ConvertFromEquirectangularTexture(const std::shared_ptr vkCmdEndRendering(vk_command_buffer); #pragma endregion - Graphics::EverythingBarrier(vk_command_buffer); + Platform::EverythingBarrier(vk_command_buffer); } storage.image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); }); diff --git a/EvoEngine_SDK/src/DescriptorLayoutsRegistry.cpp b/EvoEngine_SDK/src/DescriptorLayoutsRegistry.cpp index 0d0fbe2..5cc377c 100644 --- a/EvoEngine_SDK/src/DescriptorLayoutsRegistry.cpp +++ b/EvoEngine_SDK/src/DescriptorLayoutsRegistry.cpp @@ -1,8 +1,8 @@ -#include "Graphics.hpp" +#include "Platform.hpp" #include "Utilities.hpp" using namespace evo_engine; -void Graphics::PrepareDescriptorSetLayouts() { +void Platform::PrepareDescriptorSetLayouts() { const auto render_texture_present = std::make_shared(); render_texture_present->PushDescriptorBinding(0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, 0); diff --git a/EvoEngine_SDK/src/EditorLayer.cpp b/EvoEngine_SDK/src/EditorLayer.cpp index 1f585ce..0a0d4a9 100644 --- a/EvoEngine_SDK/src/EditorLayer.cpp +++ b/EvoEngine_SDK/src/EditorLayer.cpp @@ -2,7 +2,7 @@ #include "Application.hpp" #include "Cubemap.hpp" #include "EnvironmentalMap.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "ILayer.hpp" #include "Material.hpp" #include "Mesh.hpp" @@ -109,7 +109,7 @@ void EditorLayer::OnCreate() { entity_index_read_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO; entity_index_read_buffer_create_info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT; entity_index_read_buffer_ = std::make_unique(entity_index_read_buffer, entity_index_read_buffer_create_info); - vmaMapMemory(Graphics::GetVmaAllocator(), entity_index_read_buffer_->GetVmaAllocation(), + vmaMapMemory(Platform::GetVmaAllocator(), entity_index_read_buffer_->GetVmaAllocation(), static_cast(static_cast(&mapped_entity_index_data_))); const auto scene_camera = Serialization::ProduceSerializable(); @@ -631,20 +631,20 @@ void EditorLayer::LateUpdate() { } } - Graphics::RecordCommandsToMainGraphicsQueue([&](const VkCommandBuffer vk_command_buffer) { - Graphics::EverythingBarrier(vk_command_buffer); - Graphics::TransitImageLayout(vk_command_buffer, Graphics::GetSwapchain()->GetVkImage(), - Graphics::GetSwapchain()->GetImageFormat(), 1, VK_IMAGE_LAYOUT_UNDEFINED, + Platform::RecordCommandsMainQueue([&](const VkCommandBuffer vk_command_buffer) { + Platform::EverythingBarrier(vk_command_buffer); + Platform::TransitImageLayout(vk_command_buffer, Platform::GetSwapchain()->GetVkImage(), + Platform::GetSwapchain()->GetImageFormat(), 1, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR); constexpr VkClearValue clear_color = {{{0.0f, 0.0f, 0.0f, 1.0f}}}; VkRect2D render_area; render_area.offset = {0, 0}; - render_area.extent = Graphics::GetSwapchain()->GetImageExtent(); + render_area.extent = Platform::GetSwapchain()->GetImageExtent(); VkRenderingAttachmentInfo color_attachment_info{}; color_attachment_info.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO; - color_attachment_info.imageView = Graphics::GetSwapchain()->GetVkImageView(); + color_attachment_info.imageView = Platform::GetSwapchain()->GetVkImageView(); color_attachment_info.imageLayout = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR; color_attachment_info.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; color_attachment_info.storeOp = VK_ATTACHMENT_STORE_OP_STORE; @@ -662,8 +662,8 @@ void EditorLayer::LateUpdate() { ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), vk_command_buffer); vkCmdEndRendering(vk_command_buffer); - Graphics::TransitImageLayout(vk_command_buffer, Graphics::GetSwapchain()->GetVkImage(), - Graphics::GetSwapchain()->GetImageFormat(), 1, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR, + Platform::TransitImageLayout(vk_command_buffer, Platform::GetSwapchain()->GetVkImage(), + Platform::GetSwapchain()->GetImageFormat(), 1, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); }); } @@ -757,7 +757,7 @@ void EditorLayer::InspectComponentData(const Entity entity, IDataComponent* data void EditorLayer::SceneCameraWindow() { const auto scene = GetScene(); auto window_layer = Application::GetLayer(); - const auto& graphics = Graphics::GetInstance(); + const auto& graphics = Platform::GetInstance(); auto& [sceneCameraRotation, sceneCameraPosition, sceneCamera] = editor_cameras_.at(scene_camera_handle_); #pragma region Scene Window ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{0, 0}); @@ -794,7 +794,7 @@ void EditorLayer::SceneCameraWindow() { ImGui::Text("Info & Settings"); ImGui::Text("%.1f FPS", ImGui::GetIO().Framerate); std::string draw_call_info = {}; - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); + const auto current_frame_index = Platform::GetCurrentFrameIndex(); if (graphics.triangles[current_frame_index] < 999) draw_call_info += std::to_string(graphics.triangles[current_frame_index]); else if (graphics.triangles[current_frame_index] < 999999) @@ -955,7 +955,7 @@ void EditorLayer::SceneCameraWindow() { void EditorLayer::MainCameraWindow() { if (const auto render_layer = Application::GetLayer(); !render_layer) return; - const auto& graphics = Graphics::GetInstance(); + const auto& graphics = Platform::GetInstance(); const auto scene = GetScene(); #pragma region Window ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{0, 0}); @@ -999,7 +999,7 @@ void EditorLayer::MainCameraWindow() { } ImGui::PopItemWidth(); std::string draw_call_info = {}; - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); + const auto current_frame_index = Platform::GetCurrentFrameIndex(); if (graphics.triangles[current_frame_index] < 999) draw_call_info += std::to_string(graphics.triangles[current_frame_index]); else if (graphics.triangles[current_frame_index] < 999999) diff --git a/EvoEngine_SDK/src/GeometryStorage.cpp b/EvoEngine_SDK/src/GeometryStorage.cpp index 1306249..0e17de1 100644 --- a/EvoEngine_SDK/src/GeometryStorage.cpp +++ b/EvoEngine_SDK/src/GeometryStorage.cpp @@ -170,20 +170,20 @@ void GeometryStorage::BindStrandPoints(const VkCommandBuffer vk_command_buffer) const Vertex& GeometryStorage::PeekVertex(const size_t vertex_index) { const auto& storage = GetInstance(); - return storage.vertex_data_chunks_[vertex_index / Graphics::Constants::meshlet_max_vertices_size] - .vertex_data[vertex_index % Graphics::Constants::meshlet_max_vertices_size]; + return storage.vertex_data_chunks_[vertex_index / Platform::Constants::meshlet_max_vertices_size] + .vertex_data[vertex_index % Platform::Constants::meshlet_max_vertices_size]; } const SkinnedVertex& GeometryStorage::PeekSkinnedVertex(const size_t skinned_vertex_index) { const auto& storage = GetInstance(); - return storage.skinned_vertex_data_chunks_[skinned_vertex_index / Graphics::Constants::meshlet_max_vertices_size] - .skinned_vertex_data[skinned_vertex_index % Graphics::Constants::meshlet_max_vertices_size]; + return storage.skinned_vertex_data_chunks_[skinned_vertex_index / Platform::Constants::meshlet_max_vertices_size] + .skinned_vertex_data[skinned_vertex_index % Platform::Constants::meshlet_max_vertices_size]; } const StrandPoint& GeometryStorage::PeekStrandPoint(const size_t strand_point_index) { const auto& storage = GetInstance(); - return storage.strand_point_data_chunks_[strand_point_index / Graphics::Constants::meshlet_max_vertices_size] - .strand_point_data[strand_point_index % Graphics::Constants::meshlet_max_vertices_size]; + return storage.strand_point_data_chunks_[strand_point_index / Platform::Constants::meshlet_max_vertices_size] + .strand_point_data[strand_point_index % Platform::Constants::meshlet_max_vertices_size]; } void GeometryStorage::AllocateMesh(const Handle& handle, const std::vector& vertices, @@ -210,15 +210,15 @@ void GeometryStorage::AllocateMesh(const Handle& handle, const std::vector meshlet_result_vertices; std::vector meshlet_result_triangles; const auto max_meshlets = - meshopt_buildMeshletsBound(triangles.size() * 3, Graphics::Constants::meshlet_max_vertices_size, - Graphics::Constants::meshlet_max_triangles_size); + meshopt_buildMeshletsBound(triangles.size() * 3, Platform::Constants::meshlet_max_vertices_size, + Platform::Constants::meshlet_max_triangles_size); meshlets_results.resize(max_meshlets); - meshlet_result_vertices.resize(max_meshlets * Graphics::Constants::meshlet_max_vertices_size); - meshlet_result_triangles.resize(max_meshlets * Graphics::Constants::meshlet_max_triangles_size * 3); + meshlet_result_vertices.resize(max_meshlets * Platform::Constants::meshlet_max_vertices_size); + meshlet_result_triangles.resize(max_meshlets * Platform::Constants::meshlet_max_triangles_size * 3); const auto meshlet_size = meshopt_buildMeshlets( meshlets_results.data(), meshlet_result_vertices.data(), meshlet_result_triangles.data(), &triangles.at(0).x, triangles.size() * 3, &vertices.at(0).position.x, vertices.size(), sizeof(Vertex), - Graphics::Constants::meshlet_max_vertices_size, Graphics::Constants::meshlet_max_triangles_size, 0); + Platform::Constants::meshlet_max_vertices_size, Platform::Constants::meshlet_max_triangles_size, 0); target_meshlet_range->range = meshlet_size; for (size_t meshlet_index = 0; meshlet_index < meshlet_size; meshlet_index++) { @@ -244,11 +244,11 @@ void GeometryStorage::AllocateMesh(const Handle& handle, const std::vectorrange += current_meshlet.triangle_size; } @@ -279,16 +279,16 @@ void GeometryStorage::AllocateSkinnedMesh(const Handle& handle, const std::vecto std::vector skinned_meshlet_result_vertices{}; std::vector skinned_meshlet_result_triangles{}; const auto max_meshlets = - meshopt_buildMeshletsBound(skinned_triangles.size() * 3, Graphics::Constants::meshlet_max_vertices_size, - Graphics::Constants::meshlet_max_triangles_size); + meshopt_buildMeshletsBound(skinned_triangles.size() * 3, Platform::Constants::meshlet_max_vertices_size, + Platform::Constants::meshlet_max_triangles_size); skinned_meshlets_results.resize(max_meshlets); - skinned_meshlet_result_vertices.resize(max_meshlets * Graphics::Constants::meshlet_max_vertices_size); - skinned_meshlet_result_triangles.resize(max_meshlets * Graphics::Constants::meshlet_max_triangles_size * 3); + skinned_meshlet_result_vertices.resize(max_meshlets * Platform::Constants::meshlet_max_vertices_size); + skinned_meshlet_result_triangles.resize(max_meshlets * Platform::Constants::meshlet_max_triangles_size * 3); const auto skinned_meshlet_size = meshopt_buildMeshlets( skinned_meshlets_results.data(), skinned_meshlet_result_vertices.data(), skinned_meshlet_result_triangles.data(), &skinned_triangles.at(0).x, skinned_triangles.size() * 3, &skinned_vertices.at(0).position.x, - skinned_vertices.size(), sizeof(SkinnedVertex), Graphics::Constants::meshlet_max_vertices_size, - Graphics::Constants::meshlet_max_triangles_size, 0); + skinned_vertices.size(), sizeof(SkinnedVertex), Platform::Constants::meshlet_max_vertices_size, + Platform::Constants::meshlet_max_triangles_size, 0); target_skinned_meshlet_range->range = skinned_meshlet_size; for (size_t skinned_meshlet_index = 0; skinned_meshlet_index < skinned_meshlet_size; skinned_meshlet_index++) { @@ -316,11 +316,11 @@ void GeometryStorage::AllocateSkinnedMesh(const Handle& handle, const std::vecto storage.skinned_triangles_.emplace_back(); auto& global_triangle = storage.skinned_triangles_.back(); global_triangle.x = current_meshlet_triangle.x + current_skinned_meshlet.skinned_vertex_chunk_index * - Graphics::Constants::meshlet_max_vertices_size; + Platform::Constants::meshlet_max_vertices_size; global_triangle.y = current_meshlet_triangle.y + current_skinned_meshlet.skinned_vertex_chunk_index * - Graphics::Constants::meshlet_max_vertices_size; + Platform::Constants::meshlet_max_vertices_size; global_triangle.z = current_meshlet_triangle.z + current_skinned_meshlet.skinned_vertex_chunk_index * - Graphics::Constants::meshlet_max_vertices_size; + Platform::Constants::meshlet_max_vertices_size; } target_skinned_triangle_range->range += current_skinned_meshlet.skinned_triangle_size; } @@ -361,7 +361,7 @@ void GeometryStorage::AllocateStrands(const Handle& handle, const std::vector assigned_strand_points{}; - while (current_strand_meshlet.segment_size < Graphics::Constants::meshlet_max_triangles_size && + while (current_strand_meshlet.segment_size < Platform::Constants::meshlet_max_triangles_size && current_segment_index < segments.size()) { const auto& current_segment = segments[current_segment_index]; uint32_t new_strand_points_amount = 0; @@ -382,7 +382,7 @@ void GeometryStorage::AllocateStrands(const Handle& handle, const std::vector - Graphics::Constants::meshlet_max_vertices_size) { + Platform::Constants::meshlet_max_vertices_size) { break; } auto& current_strand_meshlet_segment = current_strand_meshlet.segments[current_strand_meshlet.segment_size]; @@ -442,13 +442,13 @@ void GeometryStorage::AllocateStrands(const Handle& handle, const std::vectorrange++; } } @@ -506,9 +506,9 @@ void GeometryStorage::FreeMesh(const Handle& handle) { } for (uint32_t i = triangle_range_descriptor->offset; i < storage.triangles_.size(); i++) { - storage.triangles_[i].x -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; - storage.triangles_[i].y -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; - storage.triangles_[i].z -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; + storage.triangles_[i].x -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; + storage.triangles_[i].y -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; + storage.triangles_[i].z -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; } storage.triangle_range_descriptor_.erase(storage.triangle_range_descriptor_.begin() + triangle_range_descriptor_index); @@ -569,9 +569,9 @@ void GeometryStorage::FreeSkinnedMesh(const Handle& handle) { } for (uint32_t i = skinned_triangle_range_descriptor->offset; i < storage.skinned_triangles_.size(); i++) { - storage.skinned_triangles_[i].x -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; - storage.skinned_triangles_[i].y -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; - storage.skinned_triangles_[i].z -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; + storage.skinned_triangles_[i].x -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; + storage.skinned_triangles_[i].y -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; + storage.skinned_triangles_[i].z -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; } storage.skinned_triangle_range_descriptor_.erase(storage.skinned_triangle_range_descriptor_.begin() + @@ -631,10 +631,10 @@ void GeometryStorage::FreeStrands(const Handle& handle) { } for (uint32_t i = segment_range_descriptor->offset; i < storage.segments_.size(); i++) { - storage.segments_[i].x -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; - storage.segments_[i].y -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; - storage.segments_[i].z -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; - storage.segments_[i].w -= remove_chunk_size * Graphics::Constants::meshlet_max_vertices_size; + storage.segments_[i].x -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; + storage.segments_[i].y -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; + storage.segments_[i].z -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; + storage.segments_[i].w -= remove_chunk_size * Platform::Constants::meshlet_max_vertices_size; } storage.segment_range_descriptor_.erase(storage.segment_range_descriptor_.begin() + segment_range_descriptor_index); @@ -657,7 +657,7 @@ void GeometryStorage::AllocateParticleInfo(const Handle& handle, VmaAllocationCreateInfo buffer_vma_allocation_create_info{}; buffer_vma_allocation_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE; info_data.m_buffer = std::make_shared(buffer_create_info, buffer_vma_allocation_create_info); - info_data.descriptor_set = std::make_shared(Graphics::GetDescriptorSetLayout("INSTANCED_DATA_LAYOUT")); + info_data.descriptor_set = std::make_shared(Platform::GetDescriptorSetLayout("INSTANCED_DATA_LAYOUT")); info_data.m_status = ParticleInfoListDataStatus::UpdatePending; } diff --git a/EvoEngine_SDK/src/GraphicsPipeline.cpp b/EvoEngine_SDK/src/GraphicsPipeline.cpp index e7b6d20..d7feeba 100644 --- a/EvoEngine_SDK/src/GraphicsPipeline.cpp +++ b/EvoEngine_SDK/src/GraphicsPipeline.cpp @@ -2,7 +2,7 @@ #include "Application.hpp" #include "Console.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "RenderLayer.hpp" #include "Shader.hpp" #include "Utilities.hpp" @@ -208,7 +208,7 @@ void GraphicsPipeline::Initialize() { pipeline_info.layout = pipeline_layout_->GetVkPipelineLayout(); pipeline_info.pNext = &rendering_create_info; pipeline_info.basePipelineHandle = VK_NULL_HANDLE; - Graphics::CheckVk(vkCreateGraphicsPipelines(Graphics::GetVkDevice(), VK_NULL_HANDLE, 1, &pipeline_info, nullptr, + Platform::CheckVk(vkCreateGraphicsPipelines(Platform::GetVkDevice(), VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &vk_graphics_pipeline_)); states.ResetAllStates(1); } @@ -332,7 +332,7 @@ void PipelineDynamicState::Apply(const VkPipelineDynamicStateCreateInfo& vk_pipe GraphicsPipeline::~GraphicsPipeline() { if (vk_graphics_pipeline_ != VK_NULL_HANDLE) { - vkDestroyPipeline(Graphics::GetVkDevice(), vk_graphics_pipeline_, nullptr); + vkDestroyPipeline(Platform::GetVkDevice(), vk_graphics_pipeline_, nullptr); vk_graphics_pipeline_ = nullptr; } } diff --git a/EvoEngine_SDK/src/GraphicsPipelinesRegistry.cpp b/EvoEngine_SDK/src/GraphicsPipelinesRegistry.cpp index 5b452ed..64df51b 100644 --- a/EvoEngine_SDK/src/GraphicsPipelinesRegistry.cpp +++ b/EvoEngine_SDK/src/GraphicsPipelinesRegistry.cpp @@ -1,6 +1,6 @@ #include "Application.hpp" #include "EditorLayer.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "PostProcessingStack.hpp" #include "RenderLayer.hpp" #include "Resources.hpp" @@ -9,7 +9,7 @@ #include "WindowLayer.hpp" using namespace evo_engine; -void Graphics::CreateGraphicsPipelines() const { +void Platform::CreateGraphicsPipelines() const { auto per_frame_layout = GetDescriptorSetLayout("PER_FRAME_LAYOUT"); auto camera_g_buffer_layout = GetDescriptorSetLayout("CAMERA_GBUFFER_LAYOUT"); auto lighting_layout = GetDescriptorSetLayout("LIGHTING_LAYOUT"); diff --git a/EvoEngine_SDK/src/GraphicsResources.cpp b/EvoEngine_SDK/src/GraphicsResources.cpp index 1efb71c..85f18b9 100644 --- a/EvoEngine_SDK/src/GraphicsResources.cpp +++ b/EvoEngine_SDK/src/GraphicsResources.cpp @@ -2,19 +2,19 @@ #include "Application.hpp" #include "Console.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Utilities.hpp" using namespace evo_engine; Fence::Fence(const VkFenceCreateInfo& vk_fence_create_info) { - Graphics::CheckVk(vkCreateFence(Graphics::GetVkDevice(), &vk_fence_create_info, nullptr, &vk_fence_)); + Platform::CheckVk(vkCreateFence(Platform::GetVkDevice(), &vk_fence_create_info, nullptr, &vk_fence_)); flags_ = vk_fence_create_info.flags; } Fence::~Fence() { if (vk_fence_ != VK_NULL_HANDLE) { - vkDestroyFence(Graphics::GetVkDevice(), vk_fence_, nullptr); + vkDestroyFence(Platform::GetVkDevice(), vk_fence_, nullptr); vk_fence_ = nullptr; } } @@ -24,13 +24,13 @@ const VkFence& Fence::GetVkFence() const { } Semaphore::Semaphore(const VkSemaphoreCreateInfo& semaphore_create_info) { - Graphics::CheckVk(vkCreateSemaphore(Graphics::GetVkDevice(), &semaphore_create_info, nullptr, &vk_semaphore_)); + Platform::CheckVk(vkCreateSemaphore(Platform::GetVkDevice(), &semaphore_create_info, nullptr, &vk_semaphore_)); flags_ = semaphore_create_info.flags; } Semaphore::~Semaphore() { if (vk_semaphore_ != VK_NULL_HANDLE) { - vkDestroySemaphore(Graphics::GetVkDevice(), vk_semaphore_, nullptr); + vkDestroySemaphore(Platform::GetVkDevice(), vk_semaphore_, nullptr); vk_semaphore_ = VK_NULL_HANDLE; } } @@ -48,8 +48,8 @@ void* Semaphore::GetVkSemaphoreHandle(VkExternalSemaphoreHandleTypeFlagBitsKHR e vulkan_semaphore_get_win32_handle_info_khr.semaphore = vk_semaphore_; vulkan_semaphore_get_win32_handle_info_khr.handleType = external_semaphore_handle_type; auto func = - PFN_vkGetSemaphoreWin32HandleKHR(vkGetDeviceProcAddr(Graphics::GetVkDevice(), "vkGetSemaphoreWin32HandleKHR")); - func(Graphics::GetVkDevice(), &vulkan_semaphore_get_win32_handle_info_khr, &handle); + PFN_vkGetSemaphoreWin32HandleKHR(vkGetDeviceProcAddr(Platform::GetVkDevice(), "vkGetSemaphoreWin32HandleKHR")); + func(Platform::GetVkDevice(), &vulkan_semaphore_get_win32_handle_info_khr, &handle); return handle; } @@ -64,7 +64,7 @@ int Semaphore::GetVkSemaphoreHandle(VkExternalSemaphoreHandleTypeFlagBitsKHR ext vulkanSemaphoreGetFdInfoKHR.semaphore = vk_semaphore_; vulkanSemaphoreGetFdInfoKHR.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR; - vkGetSemaphoreFdKHR(Graphics::GetVkDevice(), &vulkanSemaphoreGetFdInfoKHR, &fd); + vkGetSemaphoreFdKHR(Platform::GetVkDevice(), &vulkanSemaphoreGetFdInfoKHR, &fd); return fd; } @@ -72,8 +72,8 @@ int Semaphore::GetVkSemaphoreHandle(VkExternalSemaphoreHandleTypeFlagBitsKHR ext } #endif Swapchain::Swapchain(const VkSwapchainCreateInfoKHR& swap_chain_create_info) { - const auto& device = Graphics::GetVkDevice(); - Graphics::CheckVk(vkCreateSwapchainKHR(Graphics::GetVkDevice(), &swap_chain_create_info, nullptr, &vk_swapchain_)); + const auto& device = Platform::GetVkDevice(); + Platform::CheckVk(vkCreateSwapchainKHR(Platform::GetVkDevice(), &swap_chain_create_info, nullptr, &vk_swapchain_)); uint32_t image_count = 0; vkGetSwapchainImagesKHR(device, vk_swapchain_, &image_count, nullptr); vk_images_.resize(image_count); @@ -117,7 +117,7 @@ Swapchain::Swapchain(const VkSwapchainCreateInfoKHR& swap_chain_create_info) { Swapchain::~Swapchain() { vk_image_views_.clear(); if (vk_swapchain_ != VK_NULL_HANDLE) { - vkDestroySwapchainKHR(Graphics::GetVkDevice(), vk_swapchain_, nullptr); + vkDestroySwapchainKHR(Platform::GetVkDevice(), vk_swapchain_, nullptr); vk_swapchain_ = VK_NULL_HANDLE; } } @@ -131,11 +131,11 @@ const std::vector& Swapchain::GetAllVkImages() const { } const VkImage& Swapchain::GetVkImage() const { - return vk_images_[Graphics::GetNextImageIndex()]; + return vk_images_[Platform::GetNextImageIndex()]; } const VkImageView& Swapchain::GetVkImageView() const { - return vk_image_views_[Graphics::GetNextImageIndex()]->vk_image_view_; + return vk_image_views_[Platform::GetNextImageIndex()]->vk_image_view_; } const std::vector>& Swapchain::GetAllImageViews() const { @@ -151,7 +151,7 @@ VkExtent2D Swapchain::GetImageExtent() const { } ImageView::ImageView(const VkImageViewCreateInfo& image_view_create_info) { - Graphics::CheckVk(vkCreateImageView(Graphics::GetVkDevice(), &image_view_create_info, nullptr, &vk_image_view_)); + Platform::CheckVk(vkCreateImageView(Platform::GetVkDevice(), &image_view_create_info, nullptr, &vk_image_view_)); image_ = nullptr; flags_ = image_view_create_info.flags; view_type_ = image_view_create_info.viewType; @@ -161,7 +161,7 @@ ImageView::ImageView(const VkImageViewCreateInfo& image_view_create_info) { } ImageView::ImageView(const VkImageViewCreateInfo& image_view_create_info, const std::shared_ptr& image) { - Graphics::CheckVk(vkCreateImageView(Graphics::GetVkDevice(), &image_view_create_info, nullptr, &vk_image_view_)); + Platform::CheckVk(vkCreateImageView(Platform::GetVkDevice(), &image_view_create_info, nullptr, &vk_image_view_)); image_ = image; flags_ = image_view_create_info.flags; view_type_ = image_view_create_info.viewType; @@ -172,7 +172,7 @@ ImageView::ImageView(const VkImageViewCreateInfo& image_view_create_info, const ImageView::~ImageView() { if (vk_image_view_ != VK_NULL_HANDLE) { - vkDestroyImageView(Graphics::GetVkDevice(), vk_image_view_, nullptr); + vkDestroyImageView(Platform::GetVkDevice(), vk_image_view_, nullptr); vk_image_view_ = VK_NULL_HANDLE; } } @@ -187,13 +187,13 @@ const std::shared_ptr& ImageView::GetImage() const { ShaderModule::~ShaderModule() { if (vk_shader_module_ != VK_NULL_HANDLE) { - vkDestroyShaderModule(Graphics::GetVkDevice(), vk_shader_module_, nullptr); + vkDestroyShaderModule(Platform::GetVkDevice(), vk_shader_module_, nullptr); vk_shader_module_ = VK_NULL_HANDLE; } } ShaderModule::ShaderModule(const VkShaderModuleCreateInfo& create_info) { - Graphics::CheckVk(vkCreateShaderModule(Graphics::GetVkDevice(), &create_info, nullptr, &vk_shader_module_)); + Platform::CheckVk(vkCreateShaderModule(Platform::GetVkDevice(), &create_info, nullptr, &vk_shader_module_)); } VkShaderModule ShaderModule::GetVkShaderModule() const { @@ -201,8 +201,8 @@ VkShaderModule ShaderModule::GetVkShaderModule() const { } PipelineLayout::PipelineLayout(const VkPipelineLayoutCreateInfo& pipeline_layout_create_info) { - Graphics::CheckVk( - vkCreatePipelineLayout(Graphics::GetVkDevice(), &pipeline_layout_create_info, nullptr, &vk_pipeline_layout_)); + Platform::CheckVk( + vkCreatePipelineLayout(Platform::GetVkDevice(), &pipeline_layout_create_info, nullptr, &vk_pipeline_layout_)); flags_ = pipeline_layout_create_info.flags; ApplyVector(set_layouts_, pipeline_layout_create_info.setLayoutCount, pipeline_layout_create_info.pSetLayouts); @@ -212,7 +212,7 @@ PipelineLayout::PipelineLayout(const VkPipelineLayoutCreateInfo& pipeline_layout PipelineLayout::~PipelineLayout() { if (vk_pipeline_layout_ != VK_NULL_HANDLE) { - vkDestroyPipelineLayout(Graphics::GetVkDevice(), vk_pipeline_layout_, nullptr); + vkDestroyPipelineLayout(Platform::GetVkDevice(), vk_pipeline_layout_, nullptr); vk_pipeline_layout_ = VK_NULL_HANDLE; } } @@ -222,13 +222,13 @@ VkPipelineLayout PipelineLayout::GetVkPipelineLayout() const { } CommandPool::CommandPool(const VkCommandPoolCreateInfo& command_pool_create_info) { - Graphics::CheckVk( - vkCreateCommandPool(Graphics::GetVkDevice(), &command_pool_create_info, nullptr, &vk_command_pool_)); + Platform::CheckVk( + vkCreateCommandPool(Platform::GetVkDevice(), &command_pool_create_info, nullptr, &vk_command_pool_)); } CommandPool::~CommandPool() { if (vk_command_pool_ != VK_NULL_HANDLE) { - vkDestroyCommandPool(Graphics::GetVkDevice(), vk_command_pool_, nullptr); + vkDestroyCommandPool(Platform::GetVkDevice(), vk_command_pool_, nullptr); vk_command_pool_ = VK_NULL_HANDLE; } } @@ -255,7 +255,7 @@ Image::Image(VkImageCreateInfo image_create_info) { VmaAllocationCreateInfo alloc_info = {}; alloc_info.usage = VMA_MEMORY_USAGE_AUTO; - if (vmaCreateImage(Graphics::GetVmaAllocator(), &image_create_info, &alloc_info, &vk_image_, &vma_allocation_, + if (vmaCreateImage(Platform::GetVmaAllocator(), &image_create_info, &alloc_info, &vk_image_, &vma_allocation_, &vma_allocation_info_)) { throw std::runtime_error("Failed to create image!"); } @@ -286,7 +286,7 @@ Image::Image(VkImageCreateInfo image_create_info, const VmaAllocationCreateInfo& image_create_info.pNext = &vk_external_mem_image_create_info; - if (vmaCreateImage(Graphics::GetVmaAllocator(), &image_create_info, &vma_allocation_create_info, &vk_image_, + if (vmaCreateImage(Platform::GetVmaAllocator(), &image_create_info, &vma_allocation_create_info, &vk_image_, &vma_allocation_, &vma_allocation_info_)) { throw std::runtime_error("Failed to create image!"); } @@ -411,7 +411,7 @@ VkImageLayout Image::GetLayout() const { Image::~Image() { if (vk_image_ != VK_NULL_HANDLE || vma_allocation_ != VK_NULL_HANDLE) { - vmaDestroyImage(Graphics::GetVmaAllocator(), vk_image_, vma_allocation_); + vmaDestroyImage(Platform::GetVmaAllocator(), vk_image_, vma_allocation_); vk_image_ = VK_NULL_HANDLE; vma_allocation_ = VK_NULL_HANDLE; vma_allocation_info_ = {}; @@ -420,7 +420,7 @@ Image::~Image() { void Image::TransitImageLayout(VkCommandBuffer vk_command_buffer, const VkImageLayout new_layout) { // if (newLayout == layout_) return; - Graphics::TransitImageLayout(vk_command_buffer, vk_image_, format_, array_layers_, layout_, new_layout, mip_levels_); + Platform::TransitImageLayout(vk_command_buffer, vk_image_, format_, array_layers_, layout_, new_layout, mip_levels_); layout_ = new_layout; } @@ -437,7 +437,7 @@ void* Image::GetVkImageMemHandle(VkExternalMemoryHandleTypeFlagsKHR external_mem vk_memory_get_win32_handle_info_khr.memory = vma_allocation_info_.deviceMemory; vk_memory_get_win32_handle_info_khr.handleType = static_cast(external_memory_handle_type); - vkGetMemoryWin32HandleKHR(Graphics::GetVkDevice(), &vk_memory_get_win32_handle_info_khr, &handle); + vkGetMemoryWin32HandleKHR(Platform::GetVkDevice(), &vk_memory_get_win32_handle_info_khr, &handle); return handle; } #else @@ -451,7 +451,7 @@ int Image::GetVkImageMemHandle(VkExternalMemoryHandleTypeFlagsKHR externalMemory vkMemoryGetFdInfoKHR.memory = vma_allocation_info_.deviceMemory; vkMemoryGetFdInfoKHR.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR; - vkGetMemoryFdKHR(Graphics::GetVkDevice(), &vkMemoryGetFdInfoKHR, &fd); + vkGetMemoryFdKHR(Platform::GetVkDevice(), &vkMemoryGetFdInfoKHR, &fd); return fd; } @@ -460,12 +460,12 @@ int Image::GetVkImageMemHandle(VkExternalMemoryHandleTypeFlagsKHR externalMemory #endif Sampler::Sampler(const VkSamplerCreateInfo& sampler_create_info) { - Graphics::CheckVk(vkCreateSampler(Graphics::GetVkDevice(), &sampler_create_info, nullptr, &vk_sampler_)); + Platform::CheckVk(vkCreateSampler(Platform::GetVkDevice(), &sampler_create_info, nullptr, &vk_sampler_)); } Sampler::~Sampler() { if (vk_sampler_ != VK_NULL_HANDLE) { - vkDestroySampler(Graphics::GetVkDevice(), vk_sampler_, nullptr); + vkDestroySampler(Platform::GetVkDevice(), vk_sampler_, nullptr); vk_sampler_ = VK_NULL_HANDLE; } } @@ -480,9 +480,9 @@ void Buffer::UploadData(const size_t size, const void* src) { if (vma_allocation_create_info_.flags & VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT || vma_allocation_create_info_.flags & VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT) { void* mapping; - vmaMapMemory(Graphics::GetVmaAllocator(), vma_allocation_, &mapping); + vmaMapMemory(Platform::GetVmaAllocator(), vma_allocation_, &mapping); memcpy(mapping, src, size); - vmaUnmapMemory(Graphics::GetVmaAllocator(), vma_allocation_); + vmaUnmapMemory(Platform::GetVmaAllocator(), vma_allocation_); } else { Buffer staging_buffer(size); staging_buffer.UploadData(size, src); @@ -496,9 +496,9 @@ void Buffer::DownloadData(const size_t size, void* dst) { if (vma_allocation_create_info_.flags & VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT || vma_allocation_create_info_.flags & VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT) { void* mapping; - vmaMapMemory(Graphics::GetVmaAllocator(), vma_allocation_, &mapping); + vmaMapMemory(Platform::GetVmaAllocator(), vma_allocation_, &mapping); memcpy(dst, mapping, size); - vmaUnmapMemory(Graphics::GetVmaAllocator(), vma_allocation_); + vmaUnmapMemory(Platform::GetVmaAllocator(), vma_allocation_); } else { Buffer staging_buffer(size); staging_buffer.CopyFromBuffer(*this, size, 0, 0); @@ -519,7 +519,7 @@ void Buffer::Allocate(VkBufferCreateInfo buffer_create_info, buffer_create_info.pNext = &vk_external_mem_buffer_create_info; - if (vmaCreateBuffer(Graphics::GetVmaAllocator(), &buffer_create_info, &vma_allocation_create_info, &vk_buffer_, + if (vmaCreateBuffer(Platform::GetVmaAllocator(), &buffer_create_info, &vma_allocation_create_info, &vk_buffer_, &vma_allocation_, &vma_allocation_info_)) { throw std::runtime_error("Failed to create buffer!"); } @@ -561,7 +561,7 @@ void Buffer::Resize(VkDeviceSize new_size) { if (new_size == size_) return; if (vk_buffer_ != VK_NULL_HANDLE || vma_allocation_ != VK_NULL_HANDLE) { - vmaDestroyBuffer(Graphics::GetVmaAllocator(), vk_buffer_, vma_allocation_); + vmaDestroyBuffer(Platform::GetVmaAllocator(), vk_buffer_, vma_allocation_); vk_buffer_ = VK_NULL_HANDLE; vma_allocation_ = VK_NULL_HANDLE; vma_allocation_info_ = {}; @@ -585,7 +585,7 @@ void Buffer::Resize(VkDeviceSize new_size) { #endif buffer_create_info.pNext = &vk_external_mem_buffer_create_info; - if (vmaCreateBuffer(Graphics::GetVmaAllocator(), &buffer_create_info, &vma_allocation_create_info_, &vk_buffer_, + if (vmaCreateBuffer(Platform::GetVmaAllocator(), &buffer_create_info, &vma_allocation_create_info_, &vk_buffer_, &vma_allocation_, &vma_allocation_info_)) { throw std::runtime_error("Failed to create buffer!"); } @@ -594,7 +594,7 @@ void Buffer::Resize(VkDeviceSize new_size) { Buffer::~Buffer() { if (vk_buffer_ != VK_NULL_HANDLE || vma_allocation_ != VK_NULL_HANDLE) { - vmaDestroyBuffer(Graphics::GetVmaAllocator(), vk_buffer_, vma_allocation_); + vmaDestroyBuffer(Platform::GetVmaAllocator(), vk_buffer_, vma_allocation_); vk_buffer_ = VK_NULL_HANDLE; vma_allocation_ = VK_NULL_HANDLE; vma_allocation_info_ = {}; @@ -604,7 +604,7 @@ Buffer::~Buffer() { void Buffer::CopyFromBuffer(const Buffer& src_buffer, const VkDeviceSize size, const VkDeviceSize src_offset, const VkDeviceSize dst_offset) { Resize(size); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { VkBufferCopy copy_region{}; copy_region.size = size; copy_region.srcOffset = src_offset; @@ -614,7 +614,7 @@ void Buffer::CopyFromBuffer(const Buffer& src_buffer, const VkDeviceSize size, c } void Buffer::CopyFromImage(Image& src_image, const VkBufferImageCopy& image_copy_info) const { - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { const auto prev_layout = src_image.GetLayout(); src_image.TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); vkCmdCopyImageToBuffer(vk_command_buffer, src_image.GetVkImage(), src_image.GetLayout(), vk_buffer_, 1, @@ -655,7 +655,7 @@ const VmaAllocationInfo& Buffer::GetVmaAllocationInfo() const { DescriptorSetLayout::~DescriptorSetLayout() { if (vk_descriptor_set_layout_ != VK_NULL_HANDLE) { - vkDestroyDescriptorSetLayout(Graphics::GetVkDevice(), vk_descriptor_set_layout_, nullptr); + vkDestroyDescriptorSetLayout(Platform::GetVkDevice(), vk_descriptor_set_layout_, nullptr); vk_descriptor_set_layout_ = VK_NULL_HANDLE; } } @@ -677,7 +677,7 @@ void DescriptorSetLayout::PushDescriptorBinding(uint32_t binding_index, VkDescri void DescriptorSetLayout::Initialize() { if (vk_descriptor_set_layout_ != VK_NULL_HANDLE) { - vkDestroyDescriptorSetLayout(Graphics::GetVkDevice(), vk_descriptor_set_layout_, nullptr); + vkDestroyDescriptorSetLayout(Platform::GetVkDevice(), vk_descriptor_set_layout_, nullptr); vk_descriptor_set_layout_ = VK_NULL_HANDLE; } @@ -698,7 +698,7 @@ void DescriptorSetLayout::Initialize() { descriptor_set_layout_create_info.bindingCount = static_cast(list_of_bindings.size()); descriptor_set_layout_create_info.pBindings = list_of_bindings.data(); descriptor_set_layout_create_info.pNext = &extended_info; - Graphics::CheckVk(vkCreateDescriptorSetLayout(Graphics::GetVkDevice(), &descriptor_set_layout_create_info, nullptr, + Platform::CheckVk(vkCreateDescriptorSetLayout(Platform::GetVkDevice(), &descriptor_set_layout_create_info, nullptr, &vk_descriptor_set_layout_)); } @@ -708,8 +708,8 @@ const VkDescriptorSet& DescriptorSet::GetVkDescriptorSet() const { DescriptorSet::~DescriptorSet() { if (descriptor_set_ != VK_NULL_HANDLE) { - Graphics::CheckVk(vkFreeDescriptorSets(Graphics::GetVkDevice(), - Graphics::GetDescriptorPool()->GetVkDescriptorPool(), 1, &descriptor_set_)); + Platform::CheckVk(vkFreeDescriptorSets(Platform::GetVkDevice(), + Platform::GetDescriptorPool()->GetVkDescriptorPool(), 1, &descriptor_set_)); descriptor_set_ = VK_NULL_HANDLE; } } @@ -717,11 +717,11 @@ DescriptorSet::~DescriptorSet() { DescriptorSet::DescriptorSet(const std::shared_ptr& target_layout) { VkDescriptorSetAllocateInfo alloc_info{}; alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; - alloc_info.descriptorPool = Graphics::GetDescriptorPool()->GetVkDescriptorPool(); + alloc_info.descriptorPool = Platform::GetDescriptorPool()->GetVkDescriptorPool(); alloc_info.descriptorSetCount = 1; alloc_info.pSetLayouts = &target_layout->GetVkDescriptorSetLayout(); - if (vkAllocateDescriptorSets(Graphics::GetVkDevice(), &alloc_info, &descriptor_set_) != VK_SUCCESS) { + if (vkAllocateDescriptorSets(Platform::GetVkDevice(), &alloc_info, &descriptor_set_) != VK_SUCCESS) { throw std::runtime_error("failed to allocate descriptor sets!"); } descriptor_set_layout_ = target_layout; @@ -738,7 +738,7 @@ void DescriptorSet::UpdateImageDescriptorBinding(const uint32_t binding_index, c write_info.descriptorType = descriptor_binding.binding.descriptorType; write_info.descriptorCount = 1; write_info.pImageInfo = &image_info; - vkUpdateDescriptorSets(Graphics::GetVkDevice(), 1, &write_info, 0, nullptr); + vkUpdateDescriptorSets(Platform::GetVkDevice(), 1, &write_info, 0, nullptr); } void DescriptorSet::UpdateBufferDescriptorBinding(const uint32_t binding_index, @@ -753,7 +753,7 @@ void DescriptorSet::UpdateBufferDescriptorBinding(const uint32_t binding_index, write_info.descriptorType = descriptor_binding.binding.descriptorType; write_info.descriptorCount = 1; write_info.pBufferInfo = &buffer_info; - vkUpdateDescriptorSets(Graphics::GetVkDevice(), 1, &write_info, 0, nullptr); + vkUpdateDescriptorSets(Platform::GetVkDevice(), 1, &write_info, 0, nullptr); } const VkDescriptorSetLayout& DescriptorSetLayout::GetVkDescriptorSetLayout() const { @@ -761,13 +761,13 @@ const VkDescriptorSetLayout& DescriptorSetLayout::GetVkDescriptorSetLayout() con } DescriptorPool::DescriptorPool(const VkDescriptorPoolCreateInfo& descriptor_pool_create_info) { - Graphics::CheckVk( - vkCreateDescriptorPool(Graphics::GetVkDevice(), &descriptor_pool_create_info, nullptr, &vk_descriptor_pool_)); + Platform::CheckVk( + vkCreateDescriptorPool(Platform::GetVkDevice(), &descriptor_pool_create_info, nullptr, &vk_descriptor_pool_)); } DescriptorPool::~DescriptorPool() { if (vk_descriptor_pool_ != VK_NULL_HANDLE) { - vkDestroyDescriptorPool(Graphics::GetVkDevice(), vk_descriptor_pool_, nullptr); + vkDestroyDescriptorPool(Platform::GetVkDevice(), vk_descriptor_pool_, nullptr); vk_descriptor_pool_ = VK_NULL_HANDLE; } } @@ -777,7 +777,7 @@ VkDescriptorPool DescriptorPool::GetVkDescriptorPool() const { } ShaderExt::ShaderExt(const VkShaderCreateInfoEXT& shader_create_info_ext) { - Graphics::CheckVk(vkCreateShadersEXT(Graphics::GetVkDevice(), 1, &shader_create_info_ext, nullptr, &shader_ext_)); + Platform::CheckVk(vkCreateShadersEXT(Platform::GetVkDevice(), 1, &shader_create_info_ext, nullptr, &shader_ext_)); flags_ = shader_create_info_ext.flags; stage_ = shader_create_info_ext.stage; next_stage_ = shader_create_info_ext.nextStage; @@ -792,7 +792,7 @@ ShaderExt::ShaderExt(const VkShaderCreateInfoEXT& shader_create_info_ext) { ShaderExt::~ShaderExt() { if (shader_ext_ != VK_NULL_HANDLE) { - vkDestroyShaderEXT(Graphics::GetVkDevice(), shader_ext_, nullptr); + vkDestroyShaderEXT(Platform::GetVkDevice(), shader_ext_, nullptr); shader_ext_ = VK_NULL_HANDLE; } } @@ -808,17 +808,17 @@ CommandBufferStatus CommandBuffer::GetStatus() const { CommandBuffer::CommandBuffer(const VkCommandBufferLevel& buffer_level) { VkCommandBufferAllocateInfo command_buffer_allocate_info = {}; command_buffer_allocate_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; - command_buffer_allocate_info.commandPool = Graphics::GetVkCommandPool(); + command_buffer_allocate_info.commandPool = Platform::GetVkCommandPool(); command_buffer_allocate_info.level = buffer_level; command_buffer_allocate_info.commandBufferCount = 1; - Graphics::CheckVk( - vkAllocateCommandBuffers(Graphics::GetVkDevice(), &command_buffer_allocate_info, &vk_command_buffer_)); + Platform::CheckVk( + vkAllocateCommandBuffers(Platform::GetVkDevice(), &command_buffer_allocate_info, &vk_command_buffer_)); status_ = CommandBufferStatus::Ready; } CommandBuffer::~CommandBuffer() { if (vk_command_buffer_ != VK_NULL_HANDLE) { - vkFreeCommandBuffers(Graphics::GetVkDevice(), Graphics::GetVkCommandPool(), 1, &vk_command_buffer_); + vkFreeCommandBuffers(Platform::GetVkDevice(), Platform::GetVkCommandPool(), 1, &vk_command_buffer_); vk_command_buffer_ = VK_NULL_HANDLE; } status_ = CommandBufferStatus::Invalid; @@ -840,7 +840,7 @@ void CommandBuffer::Begin(const VkCommandBufferUsageFlags& usage) { VkCommandBufferBeginInfo begin_info = {}; begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; begin_info.flags = usage; - Graphics::CheckVk(vkBeginCommandBuffer(vk_command_buffer_, &begin_info)); + Platform::CheckVk(vkBeginCommandBuffer(vk_command_buffer_, &begin_info)); status_ = CommandBufferStatus::Recording; } @@ -853,7 +853,7 @@ void CommandBuffer::End() { EVOENGINE_ERROR("Command buffer not recording!") return; } - Graphics::CheckVk(vkEndCommandBuffer(vk_command_buffer_)); + Platform::CheckVk(vkEndCommandBuffer(vk_command_buffer_)); status_ = CommandBufferStatus::Recorded; } @@ -868,7 +868,7 @@ void CommandBuffer::Reset() { EVOENGINE_ERROR("Command buffer invalid!"); return; } - Graphics::CheckVk(vkResetCommandBuffer(vk_command_buffer_, 0)); + Platform::CheckVk(vkResetCommandBuffer(vk_command_buffer_, 0)); status_ = CommandBufferStatus::Ready; } diff --git a/EvoEngine_SDK/src/LightProbe.cpp b/EvoEngine_SDK/src/LightProbe.cpp index 3a31cc9..e76da4b 100644 --- a/EvoEngine_SDK/src/LightProbe.cpp +++ b/EvoEngine_SDK/src/LightProbe.cpp @@ -8,7 +8,7 @@ using namespace evo_engine; void LightProbe::Initialize(const uint32_t resolution) { cubemap_ = ProjectManager::CreateTemporaryAsset(); cubemap_->Initialize(resolution); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { cubemap_->RefStorage().image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); }); } @@ -34,7 +34,7 @@ void LightProbe::ConstructFromCubemap(const std::shared_ptr& target_cub depth_image_info.extent.depth = 1; depth_image_info.mipLevels = 1; depth_image_info.arrayLayers = 1; - depth_image_info.format = Graphics::Constants::shadow_map; + depth_image_info.format = Platform::Constants::shadow_map; depth_image_info.tiling = VK_IMAGE_TILING_OPTIMAL; depth_image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; depth_image_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; @@ -42,7 +42,7 @@ void LightProbe::ConstructFromCubemap(const std::shared_ptr& target_cub depth_image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; const auto depth_image = std::make_shared(depth_image_info); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { depth_image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); }); @@ -50,7 +50,7 @@ void LightProbe::ConstructFromCubemap(const std::shared_ptr& target_cub depth_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; depth_view_info.image = depth_image->GetVkImage(); depth_view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - depth_view_info.format = Graphics::Constants::shadow_map; + depth_view_info.format = Platform::Constants::shadow_map; depth_view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; depth_view_info.subresourceRange.baseMipLevel = 0; depth_view_info.subresourceRange.levelCount = 1; @@ -60,7 +60,7 @@ void LightProbe::ConstructFromCubemap(const std::shared_ptr& target_cub #pragma endregion const std::unique_ptr temp_set = - std::make_unique(Graphics::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); + std::make_unique(Platform::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); VkDescriptorImageInfo descriptor_image_info{}; descriptor_image_info.imageView = target_cubemap->GetImageView()->GetVkImageView(); descriptor_image_info.imageLayout = target_cubemap->GetImage()->GetLayout(); @@ -77,8 +77,8 @@ void LightProbe::ConstructFromCubemap(const std::shared_ptr& target_cub glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, -1.0f, 0.0f)), glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, -1.0f, 0.0f))}; - const auto irradiance_construct = Graphics::GetGraphicsPipeline("IRRADIANCE_CONSTRUCT"); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + const auto irradiance_construct = Platform::GetGraphicsPipeline("IRRADIANCE_CONSTRUCT"); + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { cubemap_->RefStorage().image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); #pragma region Viewport and scissor VkRect2D render_area; @@ -149,7 +149,7 @@ void LightProbe::ConstructFromCubemap(const std::shared_ptr& target_cub vkCmdEndRendering(vk_command_buffer); #pragma endregion - Graphics::EverythingBarrier(vk_command_buffer); + Platform::EverythingBarrier(vk_command_buffer); } cubemap_->RefStorage().image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); }); diff --git a/EvoEngine_SDK/src/Lights.cpp b/EvoEngine_SDK/src/Lights.cpp index 75070f3..7194a13 100644 --- a/EvoEngine_SDK/src/Lights.cpp +++ b/EvoEngine_SDK/src/Lights.cpp @@ -1,7 +1,7 @@ #include "Lights.hpp" #include "Application.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "RenderLayer.hpp" #include "Serialization.hpp" using namespace evo_engine; @@ -204,7 +204,7 @@ void Lighting::AllocateAtlas(uint32_t size, uint32_t max_resolution, std::vector } Lighting::Lighting() { - lighting_descriptor_set = std::make_shared(Graphics::GetDescriptorSetLayout("LIGHTING_LAYOUT")); + lighting_descriptor_set = std::make_shared(Platform::GetDescriptorSetLayout("LIGHTING_LAYOUT")); } void Lighting::Initialize() { @@ -216,12 +216,12 @@ void Lighting::Initialize() { VkImageCreateInfo image_info{}; image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; image_info.imageType = VK_IMAGE_TYPE_2D; - image_info.extent.width = Graphics::Settings::directional_light_shadow_map_resolution; - image_info.extent.height = Graphics::Settings::directional_light_shadow_map_resolution; + image_info.extent.width = Platform::Settings::directional_light_shadow_map_resolution; + image_info.extent.height = Platform::Settings::directional_light_shadow_map_resolution; image_info.extent.depth = 1; image_info.mipLevels = 1; image_info.arrayLayers = 4; - image_info.format = Graphics::Constants::shadow_map; + image_info.format = Platform::Constants::shadow_map; image_info.tiling = VK_IMAGE_TILING_OPTIMAL; image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; @@ -234,7 +234,7 @@ void Lighting::Initialize() { view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = directional_light_shadow_map_->GetVkImage(); view_info.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; - view_info.format = Graphics::Constants::shadow_map; + view_info.format = Platform::Constants::shadow_map; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; view_info.subresourceRange.baseMipLevel = 0; view_info.subresourceRange.levelCount = 1; @@ -256,7 +256,7 @@ void Lighting::Initialize() { sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; @@ -275,12 +275,12 @@ void Lighting::Initialize() { VkImageCreateInfo image_info{}; image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; image_info.imageType = VK_IMAGE_TYPE_2D; - image_info.extent.width = Graphics::Settings::point_light_shadow_map_resolution; - image_info.extent.height = Graphics::Settings::point_light_shadow_map_resolution; + image_info.extent.width = Platform::Settings::point_light_shadow_map_resolution; + image_info.extent.height = Platform::Settings::point_light_shadow_map_resolution; image_info.extent.depth = 1; image_info.mipLevels = 1; image_info.arrayLayers = 6; - image_info.format = Graphics::Constants::shadow_map; + image_info.format = Platform::Constants::shadow_map; image_info.tiling = VK_IMAGE_TILING_OPTIMAL; image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; @@ -293,7 +293,7 @@ void Lighting::Initialize() { view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = point_light_shadow_map_->GetVkImage(); view_info.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; - view_info.format = Graphics::Constants::shadow_map; + view_info.format = Platform::Constants::shadow_map; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; view_info.subresourceRange.baseMipLevel = 0; view_info.subresourceRange.levelCount = 1; @@ -316,7 +316,7 @@ void Lighting::Initialize() { sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; @@ -334,12 +334,12 @@ void Lighting::Initialize() { VkImageCreateInfo image_info{}; image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; image_info.imageType = VK_IMAGE_TYPE_2D; - image_info.extent.width = Graphics::Settings::spot_light_shadow_map_resolution; - image_info.extent.height = Graphics::Settings::spot_light_shadow_map_resolution; + image_info.extent.width = Platform::Settings::spot_light_shadow_map_resolution; + image_info.extent.height = Platform::Settings::spot_light_shadow_map_resolution; image_info.extent.depth = 1; image_info.mipLevels = 1; image_info.arrayLayers = 1; - image_info.format = Graphics::Constants::shadow_map; + image_info.format = Platform::Constants::shadow_map; image_info.tiling = VK_IMAGE_TILING_OPTIMAL; image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; @@ -352,7 +352,7 @@ void Lighting::Initialize() { view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = spot_light_shadow_map_->GetVkImage(); view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - view_info.format = Graphics::Constants::shadow_map; + view_info.format = Platform::Constants::shadow_map; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; view_info.subresourceRange.baseMipLevel = 0; view_info.subresourceRange.levelCount = 1; @@ -369,7 +369,7 @@ void Lighting::Initialize() { sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; diff --git a/EvoEngine_SDK/src/Mesh.cpp b/EvoEngine_SDK/src/Mesh.cpp index 3f4af3c..21f036e 100644 --- a/EvoEngine_SDK/src/Mesh.cpp +++ b/EvoEngine_SDK/src/Mesh.cpp @@ -3,7 +3,7 @@ #include "ClassRegistry.hpp" #include "Console.hpp" #include "GeometryStorage.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Jobs.hpp" #include "Utilities.hpp" using namespace evo_engine; diff --git a/EvoEngine_SDK/src/Graphics.cpp b/EvoEngine_SDK/src/Platform.cpp similarity index 93% rename from EvoEngine_SDK/src/Graphics.cpp rename to EvoEngine_SDK/src/Platform.cpp index 3b86f25..fd113dc 100644 --- a/EvoEngine_SDK/src/Graphics.cpp +++ b/EvoEngine_SDK/src/Platform.cpp @@ -1,4 +1,4 @@ -#include "Graphics.hpp" +#include "Platform.hpp" #include "Application.hpp" #include "Console.hpp" #include "EditorLayer.hpp" @@ -12,7 +12,9 @@ #include "WindowLayer.hpp" #include "vk_mem_alloc.h" using namespace evo_engine; -#define GRAPHICS_VALIDATION + +//#define GRAPHICS_VALIDATION + VkBool32 DebugCallback(const VkDebugUtilsMessageSeverityFlagBitsEXT message_severity, const VkDebugUtilsMessageTypeFlagsEXT message_type, const VkDebugUtilsMessengerCallbackDataEXT* p_callback_data, void* p_user_data) { @@ -54,7 +56,7 @@ VkBool32 DebugCallback(const VkDebugUtilsMessageSeverityFlagBitsEXT message_seve return VK_FALSE; } -uint32_t Graphics::FindMemoryType(const uint32_t type_filter, const VkMemoryPropertyFlags properties) { +uint32_t Platform::FindMemoryType(const uint32_t type_filter, const VkMemoryPropertyFlags properties) { const auto& graphics = GetInstance(); VkPhysicalDeviceMemoryProperties mem_properties; vkGetPhysicalDeviceMemoryProperties(graphics.vk_physical_device_, &mem_properties); @@ -105,7 +107,7 @@ void SelectStageFlagsAccessMask(const VkImageLayout image_layout, VkAccessFlags& } } -void Graphics::RecordCommandsToMainGraphicsQueue(const std::function& action) { +void Platform::RecordCommandsMainQueue(const std::function& action) { auto& graphics = GetInstance(); const unsigned vk_command_buffer_index = graphics.used_command_buffer_size_; const auto current_frame_index = graphics.current_frame_index_; @@ -117,12 +119,12 @@ void Graphics::RecordCommandsToMainGraphicsQueue(const std::function& graphics_pipeline) { auto& graphics = GetInstance(); if (graphics.graphics_pipelines_.find(name) != graphics.graphics_pipelines_.end()) { @@ -132,7 +134,7 @@ void Graphics::RegisterGraphicsPipeline(const std::string& name, graphics.graphics_pipelines_[name] = graphics_pipeline; } -void Graphics::RegisterComputePipeline(const std::string& name, +void Platform::RegisterComputePipeline(const std::string& name, const std::shared_ptr& compute_pipeline) { auto& graphics = GetInstance(); if (graphics.compute_pipelines_.find(name) != graphics.compute_pipelines_.end()) { @@ -142,17 +144,17 @@ void Graphics::RegisterComputePipeline(const std::string& name, graphics.compute_pipelines_[name] = compute_pipeline; } -const std::shared_ptr& Graphics::GetGraphicsPipeline(const std::string& name) { +const std::shared_ptr& Platform::GetGraphicsPipeline(const std::string& name) { const auto& graphics = GetInstance(); return graphics.graphics_pipelines_.at(name); } -const std::shared_ptr& Graphics::GetDescriptorSetLayout(const std::string& name) { +const std::shared_ptr& Platform::GetDescriptorSetLayout(const std::string& name) { const auto& graphics = GetInstance(); return graphics.descriptor_set_layouts_.at(name); } -void Graphics::RegisterDescriptorSetLayout(const std::string& name, +void Platform::RegisterDescriptorSetLayout(const std::string& name, const std::shared_ptr& descriptor_set_layout) { auto& graphics = GetInstance(); if (graphics.descriptor_set_layouts_.find(name) != graphics.descriptor_set_layouts_.end()) { @@ -162,7 +164,7 @@ void Graphics::RegisterDescriptorSetLayout(const std::string& name, graphics.descriptor_set_layouts_[name] = descriptor_set_layout; } -void Graphics::TransitImageLayout(VkCommandBuffer vk_command_buffer, const VkImage target_image, +void Platform::TransitImageLayout(VkCommandBuffer vk_command_buffer, const VkImage target_image, const VkFormat image_format, const uint32_t layer_count, const VkImageLayout old_layout, const VkImageLayout new_layout, const uint32_t mip_levels) { @@ -200,17 +202,17 @@ void Graphics::TransitImageLayout(VkCommandBuffer vk_command_buffer, const VkIma vkCmdPipelineBarrier(vk_command_buffer, source_stage, destination_stage, 0, 0, nullptr, 0, nullptr, 1, &barrier); } -size_t Graphics::GetMaxBoneAmount() { +size_t Platform::GetMaxBoneAmount() { const auto& graphics = GetInstance(); return graphics.max_bone_amount_; } -size_t Graphics::GetMaxShadowCascadeAmount() { +size_t Platform::GetMaxShadowCascadeAmount() { const auto& graphics = GetInstance(); return graphics.max_shadow_cascade_amount_; } -void Graphics::ImmediateSubmit(const std::function& action) { +void Platform::ImmediateSubmit(const std::function& action) { const auto& graphics = GetInstance(); graphics.immediate_submit_command_buffer->Record(action); @@ -228,97 +230,92 @@ void Graphics::ImmediateSubmit(const std::functionReset(); } -QueueFamilyIndices Graphics::GetQueueFamilyIndices() { +QueueFamilyIndices Platform::GetQueueFamilyIndices() { const auto& graphics = GetInstance(); return graphics.queue_family_indices_; } -int Graphics::GetMaxFramesInFlight() { +int Platform::GetMaxFramesInFlight() { const auto& graphics = GetInstance(); return graphics.max_frame_in_flight_; } -void Graphics::NotifyRecreateSwapChain() { +void Platform::NotifyRecreateSwapChain() { auto& graphics = GetInstance(); graphics.recreate_swap_chain_ = true; } -VkInstance Graphics::GetVkInstance() { +VkInstance Platform::GetVkInstance() { const auto& graphics = GetInstance(); return graphics.vk_instance_; } -VkPhysicalDevice Graphics::GetVkPhysicalDevice() { +VkPhysicalDevice Platform::GetVkPhysicalDevice() { const auto& graphics = GetInstance(); return graphics.vk_physical_device_; } -VkDevice Graphics::GetVkDevice() { +VkDevice Platform::GetVkDevice() { const auto& graphics = GetInstance(); return graphics.vk_device_; } -uint32_t Graphics::GetCurrentFrameIndex() { +uint32_t Platform::GetCurrentFrameIndex() { const auto& graphics = GetInstance(); return graphics.current_frame_index_; } -uint32_t Graphics::GetNextImageIndex() { +uint32_t Platform::GetNextImageIndex() { const auto& graphics = GetInstance(); return graphics.next_image_index_; } -VkCommandPool Graphics::GetVkCommandPool() { +VkCommandPool Platform::GetVkCommandPool() { const auto& graphics = GetInstance(); return graphics.command_pool_->GetVkCommandPool(); } -const std::unique_ptr& Graphics::GetGraphicsQueue() { - const auto& graphics = GetInstance(); - return graphics.graphics_queue_; -} - -const std::unique_ptr& Graphics::GetComputeQueue() { +const std::unique_ptr& Platform::GetMainQueue() { const auto& graphics = GetInstance(); - return graphics.compute_queue_; + return graphics.main_queue_; } -const std::unique_ptr& Graphics::GetImmediateSubmitQueue() { +const std::unique_ptr& Platform::GetImmediateSubmitQueue() { const auto& graphics = GetInstance(); return graphics.immediate_submit_queue_; } -const std::unique_ptr& Graphics::GetPresentQueue() { +const std::unique_ptr& Platform::GetPresentQueue() { const auto& graphics = GetInstance(); return graphics.present_queue_; } -VmaAllocator Graphics::GetVmaAllocator() { +VmaAllocator Platform::GetVmaAllocator() { const auto& graphics = GetInstance(); return graphics.vma_allocator_; } -const std::shared_ptr& Graphics::GetSwapchain() { +const std::shared_ptr& Platform::GetSwapchain() { const auto& graphics = GetInstance(); return graphics.swapchain_; } -const std::unique_ptr& Graphics::GetDescriptorPool() { +const std::unique_ptr& Platform::GetDescriptorPool() { const auto& graphics = GetInstance(); return graphics.descriptor_pool_; } -unsigned Graphics::GetSwapchainVersion() { +unsigned Platform::GetSwapchainVersion() { const auto& graphics = GetInstance(); return graphics.swapchain_version_; } -VkSurfaceFormatKHR Graphics::GetVkSurfaceFormat() { +VkSurfaceFormatKHR Platform::GetVkSurfaceFormat() { const auto& graphics = GetInstance(); return graphics.vk_surface_format_; } -const VkPhysicalDeviceProperties& Graphics::GetVkPhysicalDeviceProperties() { +const VkPhysicalDeviceProperties& Platform::GetVkPhysicalDeviceProperties() { const auto& graphics = GetInstance(); return graphics.vk_physical_device_properties_; } @@ -379,7 +376,7 @@ bool CheckDeviceExtensionSupport(const VkPhysicalDevice physical_device, return required_extensions.empty(); } -QueueFamilyIndices Graphics::FindQueueFamilies(const VkPhysicalDevice physical_device) const { +QueueFamilyIndices Platform::FindQueueFamilies(const VkPhysicalDevice physical_device) const { const auto window_layer = Application::GetLayer(); QueueFamilyIndices indices; @@ -410,7 +407,7 @@ QueueFamilyIndices Graphics::FindQueueFamilies(const VkPhysicalDevice physical_d return indices; } -SwapChainSupportDetails Graphics::QuerySwapChainSupport(const VkPhysicalDevice physical_device) const { +SwapChainSupportDetails Platform::QuerySwapChainSupport(const VkPhysicalDevice physical_device) const { SwapChainSupportDetails details; vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, vk_surface_, &details.capabilities); @@ -435,7 +432,7 @@ SwapChainSupportDetails Graphics::QuerySwapChainSupport(const VkPhysicalDevice p return details; } -bool Graphics::IsDeviceSuitable(VkPhysicalDevice physical_device, +bool Platform::IsDeviceSuitable(VkPhysicalDevice physical_device, const std::vector& required_device_extensions) const { if (!CheckDeviceExtensionSupport(physical_device, required_device_extensions)) return false; @@ -451,7 +448,7 @@ bool Graphics::IsDeviceSuitable(VkPhysicalDevice physical_device, return true; } -void Graphics::CreateInstance() { +void Platform::CreateInstance() { auto application_info = Application::GetApplicationInfo(); const auto window_layer = Application::GetLayer(); const auto editor_layer = Application::GetLayer(); @@ -553,7 +550,7 @@ void Graphics::CreateInstance() { #pragma endregion } -void Graphics::CreateSurface() { +void Platform::CreateSurface() { const auto window_layer = Application::GetLayer(); #pragma region Surface if (window_layer) { @@ -564,7 +561,7 @@ void Graphics::CreateSurface() { #pragma endregion } -void Graphics::CreateDebugMessenger() { +void Platform::CreateDebugMessenger() { #pragma region Debug Messenger #ifdef GRAPHICS_VALIDATION VkDebugUtilsMessengerCreateInfoEXT debug_utils_messenger_create_info{}; @@ -600,7 +597,7 @@ int RateDeviceSuitability(const VkPhysicalDevice physical_device) { return score; } -void Graphics::SelectPhysicalDevice() { +void Platform::SelectPhysicalDevice() { if (const auto window_layer = Application::GetLayer()) { required_device_extensions_.emplace_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); } @@ -683,7 +680,7 @@ void Graphics::SelectPhysicalDevice() { } } -void Graphics::CreateLogicalDevice() { +void Platform::CreateLogicalDevice() { std::vector c_required_device_extensions; c_required_device_extensions.reserve(required_device_extensions_.size()); for (const auto& i : required_device_extensions_) @@ -794,10 +791,9 @@ void Graphics::CreateLogicalDevice() { unique_queue_families[queue_family_indices_.graphics_and_compute_family.value()] = std::make_pair(0, std::vector()); } - unique_queue_families[queue_family_indices_.graphics_and_compute_family.value()].first += 3; + unique_queue_families[queue_family_indices_.graphics_and_compute_family.value()].first += 2; unique_queue_families[queue_family_indices_.graphics_and_compute_family.value()].second.emplace_back(1.f); unique_queue_families[queue_family_indices_.graphics_and_compute_family.value()].second.emplace_back(0.f); - unique_queue_families[queue_family_indices_.graphics_and_compute_family.value()].second.emplace_back(0.f); } if (queue_family_indices_.present_family.has_value()) { @@ -834,28 +830,25 @@ void Graphics::CreateLogicalDevice() { throw std::runtime_error("Failed to create logical device!"); } if (queue_family_indices_.graphics_and_compute_family.has_value()) { - graphics_queue_ = std::make_unique(); - compute_queue_ = std::make_unique(); + main_queue_ = std::make_unique(); immediate_submit_queue_ = std::make_unique(); vkGetDeviceQueue(vk_device_, queue_family_indices_.graphics_and_compute_family.value(), 0, &immediate_submit_queue_->vk_queue_); vkGetDeviceQueue(vk_device_, queue_family_indices_.graphics_and_compute_family.value(), 1, - &compute_queue_->vk_queue_); - vkGetDeviceQueue(vk_device_, queue_family_indices_.graphics_and_compute_family.value(), 2, - &graphics_queue_->vk_queue_); + &main_queue_->vk_queue_); } if (queue_family_indices_.present_family.has_value()) { present_queue_ = std::make_unique(); if (queue_family_indices_.graphics_and_compute_family.value() != queue_family_indices_.present_family.value()) { vkGetDeviceQueue(vk_device_, queue_family_indices_.present_family.value(), 0, &present_queue_->vk_queue_); }else { - vkGetDeviceQueue(vk_device_, queue_family_indices_.present_family.value(), 3, &present_queue_->vk_queue_); + vkGetDeviceQueue(vk_device_, queue_family_indices_.present_family.value(), 2, &present_queue_->vk_queue_); } } #pragma endregion } -void Graphics::EverythingBarrier(VkCommandBuffer vk_command_buffer) { +void Platform::EverythingBarrier(const VkCommandBuffer vk_command_buffer) { VkMemoryBarrier2 memory_barrier{}; memory_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2; memory_barrier.srcStageMask = memory_barrier.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; @@ -868,7 +861,7 @@ void Graphics::EverythingBarrier(VkCommandBuffer vk_command_buffer) { vkCmdPipelineBarrier2(vk_command_buffer, &dependency_info); } -void Graphics::SetupVmaAllocator() { +void Platform::SetupVmaAllocator() { #pragma region VMA VmaVulkanFunctions vulkan_functions{}; vulkan_functions.vkGetInstanceProcAddr = vkGetInstanceProcAddr; @@ -898,7 +891,7 @@ void Graphics::SetupVmaAllocator() { #pragma endregion } -std::string Graphics::StringifyResultVk(const VkResult& result) { +std::string Platform::StringifyResultVk(const VkResult& result) { switch (result) { case VK_SUCCESS: return "Success"; @@ -953,7 +946,7 @@ std::string Graphics::StringifyResultVk(const VkResult& result) { } } -void Graphics::CheckVk(const VkResult& result) { +void Platform::CheckVk(const VkResult& result) { if (result >= 0) { return; } @@ -961,7 +954,7 @@ void Graphics::CheckVk(const VkResult& result) { throw std::runtime_error("Vulkan error: " + failure); } -void Graphics::CreateSwapChain() { +void Platform::CreateSwapChain() { auto application_info = Application::GetApplicationInfo(); auto window_layer = Application::GetLayer(); SwapChainSupportDetails swap_chain_support_details = QuerySwapChainSupport(vk_physical_device_); @@ -1069,7 +1062,7 @@ void Graphics::CreateSwapChain() { swapchain_version_++; } -void Graphics::CreateSwapChainSyncObjects() { +void Platform::CreateSwapChainSyncObjects() { VkSemaphoreCreateInfo semaphore_create_info{}; semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; VkFenceCreateInfo fence_create_info{}; @@ -1083,12 +1076,12 @@ void Graphics::CreateSwapChainSyncObjects() { } } -void Graphics::RecreateSwapChain() { +void Platform::RecreateSwapChain() { vkDeviceWaitIdle(vk_device_); CreateSwapChain(); } -void Graphics::OnDestroy() { +void Platform::OnDestroy() { const auto& window_layer = Application::GetLayer(); if (const auto& editor_layer = Application::GetLayer(); window_layer && editor_layer) { ImGui_ImplVulkan_Shutdown(); @@ -1120,7 +1113,7 @@ void Graphics::OnDestroy() { #pragma endregion } -void Graphics::SwapChainSwapImage() { +void Platform::SwapChainSwapImage() { if (const auto& window_layer = Application::GetLayer(); window_layer->window_size_.x == 0 || window_layer->window_size_.y == 0) return; @@ -1147,7 +1140,7 @@ void Graphics::SwapChainSwapImage() { vkResetFences(vk_device_, 1, in_flight_fences); } -void Graphics::SubmitPresent() { +void Platform::SubmitPresent() { if (const auto& window_layer = Application::GetLayer(); window_layer->window_size_.x == 0 || window_layer->window_size_.y == 0) return; @@ -1166,7 +1159,7 @@ void Graphics::SubmitPresent() { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); signal_semaphores.emplace_back(render_finished_semaphores_[current_frame_index_]); - graphics_queue_->Submit(command_buffers, wait_semaphores, signal_semaphores, in_flight_fences_[current_frame_index_]); + main_queue_->Submit(command_buffers, wait_semaphores, signal_semaphores, in_flight_fences_[current_frame_index_]); std::vector, uint32_t>> targets; targets.emplace_back(swapchain_, next_image_index_); @@ -1175,7 +1168,7 @@ void Graphics::SubmitPresent() { current_frame_index_ = (current_frame_index_ + 1) % max_frame_in_flight_; } -void Graphics::WaitForCommandsComplete() const { +void Platform::WaitForCommandsComplete() const { vkDeviceWaitIdle(vk_device_); GeometryStorage::DeviceSync(); TextureStorage::DeviceSync(); @@ -1184,17 +1177,17 @@ void Graphics::WaitForCommandsComplete() const { vkResetFences(vk_device_, 1, in_flight_fences); } -void Graphics::Submit() { +void Platform::Submit() { std::vector> command_buffers; command_buffers.reserve(used_command_buffer_size_); for (int i = 0; i < used_command_buffer_size_; i++) { command_buffers.emplace_back(command_buffer_pool_[current_frame_index_][i]); } - graphics_queue_->Submit(command_buffers, {}, {}, in_flight_fences_[current_frame_index_]); + main_queue_->Submit(command_buffers, {}, {}, in_flight_fences_[current_frame_index_]); current_frame_index_ = (current_frame_index_ + 1) % max_frame_in_flight_; } -void Graphics::ResetCommandBuffers() { +void Platform::ResetCommandBuffers() { used_command_buffer_size_ = 0; for (const auto& command_buffer : command_buffer_pool_[current_frame_index_]) { if (command_buffer->status_ == CommandBufferStatus::Recorded) @@ -1204,7 +1197,7 @@ void Graphics::ResetCommandBuffers() { #pragma endregion -void Graphics::Initialize() { +void Platform::Initialize() { auto& graphics = GetInstance(); #pragma region volk if (volkInitialize() != VK_SUCCESS) { @@ -1293,7 +1286,7 @@ void Graphics::Initialize() { init_info.PhysicalDevice = graphics.vk_physical_device_; init_info.Device = graphics.vk_device_; init_info.QueueFamily = graphics.queue_family_indices_.graphics_and_compute_family.value(); - init_info.Queue = graphics.graphics_queue_->vk_queue_; + init_info.Queue = graphics.main_queue_->vk_queue_; init_info.PipelineCache = VK_NULL_HANDLE; init_info.DescriptorPool = graphics.descriptor_pool_->GetVkDescriptorPool(); init_info.MinImageCount = graphics.swapchain_->GetAllImageViews().size(); @@ -1324,18 +1317,18 @@ void Graphics::Initialize() { graphics.strands_segments.resize(graphics.max_frame_in_flight_); } -void Graphics::PostResourceLoadingInitialization() { +void Platform::PostResourceLoadingInitialization() { const auto& graphics = GetInstance(); graphics.PrepareDescriptorSetLayouts(); graphics.CreateGraphicsPipelines(); } -void Graphics::Destroy() { +void Platform::Destroy() { auto& graphics = GetInstance(); graphics.OnDestroy(); } -void Graphics::PreUpdate() { +void Platform::PreUpdate() { auto& graphics = GetInstance(); const auto window_layer = Application::GetLayer(); const auto render_layer = Application::GetLayer(); @@ -1364,7 +1357,7 @@ void Graphics::PreUpdate() { } } -void Graphics::LateUpdate() { +void Platform::LateUpdate() { auto& graphics = GetInstance(); if (const auto window_layer = Application::GetLayer()) { if (Application::GetLayer() && !Application::GetLayer()) { @@ -1372,7 +1365,7 @@ void Graphics::LateUpdate() { if (const auto main_camera = scene->main_camera.Get(); main_camera->IsEnabled() && main_camera->rendered_) { const auto& render_texture_present = graphics.graphics_pipelines_["RENDER_TEXTURE_PRESENT"]; - RecordCommandsToMainGraphicsQueue([&](VkCommandBuffer vk_command_buffer) { + RecordCommandsMainQueue([&](VkCommandBuffer vk_command_buffer) { EverythingBarrier(vk_command_buffer); TransitImageLayout(vk_command_buffer, graphics.swapchain_->GetVkImage(), graphics.swapchain_->GetImageFormat(), 1, VK_IMAGE_LAYOUT_UNDEFINED, @@ -1444,7 +1437,7 @@ void Graphics::LateUpdate() { } } -bool Graphics::CheckExtensionSupport(const std::string& extension_name) { +bool Platform::CheckExtensionSupport(const std::string& extension_name) { const auto& graphics = GetInstance(); for (const auto& layer_properties : graphics.vk_layers_) { @@ -1455,7 +1448,7 @@ bool Graphics::CheckExtensionSupport(const std::string& extension_name) { return false; } -bool Graphics::CheckLayerSupport(const std::string& layer_name) { +bool Platform::CheckLayerSupport(const std::string& layer_name) { const auto& graphics = GetInstance(); for (const auto& layer_properties : graphics.vk_layers_) { if (strcmp(layer_name.c_str(), layer_properties.layerName) == 0) { diff --git a/EvoEngine_SDK/src/PostProcessingStack.cpp b/EvoEngine_SDK/src/PostProcessingStack.cpp index 54ffb39..980cded 100644 --- a/EvoEngine_SDK/src/PostProcessingStack.cpp +++ b/EvoEngine_SDK/src/PostProcessingStack.cpp @@ -3,7 +3,7 @@ #include "Application.hpp" #include "Camera.hpp" #include "GeometryStorage.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Mesh.hpp" #include "RenderLayer.hpp" #include "Resources.hpp" @@ -26,12 +26,12 @@ void PostProcessingStack::OnCreate() { render_texture1_ = std::make_unique(render_texture_create_info); render_texture2_ = std::make_unique(render_texture_create_info); - ssr_reflect_descriptor_set_ = std::make_shared(Graphics::GetDescriptorSetLayout("SSR_REFLECT_LAYOUT")); + ssr_reflect_descriptor_set_ = std::make_shared(Platform::GetDescriptorSetLayout("SSR_REFLECT_LAYOUT")); ssr_blur_horizontal_descriptor_set_ = - std::make_shared(Graphics::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); + std::make_shared(Platform::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); ssr_blur_vertical_descriptor_set_ = - std::make_shared(Graphics::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); - ssr_combine_descriptor_set_ = std::make_shared(Graphics::GetDescriptorSetLayout("SSR_COMBINE_LAYOUT")); + std::make_shared(Platform::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); + ssr_combine_descriptor_set_ = std::make_shared(Platform::GetDescriptorSetLayout("SSR_COMBINE_LAYOUT")); } bool PostProcessingStack::OnInspect(const std::shared_ptr& editor_layer) { @@ -55,7 +55,7 @@ void PostProcessingStack::Process(const std::shared_ptr& target_camera) render_texture0_->Resize({size.x, size.y, 1}); render_texture1_->Resize({size.x, size.y, 1}); render_texture2_->Resize({size.x, size.y, 1}); - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); + const auto current_frame_index = Platform::GetCurrentFrameIndex(); if (ssao) { } if (ssr) { @@ -100,7 +100,7 @@ void PostProcessingStack::Process(const std::shared_ptr& target_camera) ssr_combine_descriptor_set_->UpdateImageDescriptorBinding(1, image_info); } - Graphics::RecordCommandsToMainGraphicsQueue([&](const VkCommandBuffer vk_command_buffer) { + Platform::RecordCommandsMainQueue([&](const VkCommandBuffer vk_command_buffer) { #pragma region Viewport and scissor VkRect2D render_area; render_area.offset = {0, 0}; @@ -155,7 +155,7 @@ void PostProcessingStack::Process(const std::shared_ptr& target_camera) render_info2.pColorAttachments = color_attachment_infos.data(); { - const auto& ssr_reflect_pipeline = Graphics::GetGraphicsPipeline("SSR_REFLECT"); + const auto& ssr_reflect_pipeline = Platform::GetGraphicsPipeline("SSR_REFLECT"); vkCmdBeginRendering(vk_command_buffer, &render_info2); ssr_reflect_pipeline->states.depth_test = false; ssr_reflect_pipeline->states.color_blend_attachment_states.clear(); @@ -186,7 +186,7 @@ void PostProcessingStack::Process(const std::shared_ptr& target_camera) render_info2.colorAttachmentCount = color_attachment_infos.size(); render_info2.pColorAttachments = color_attachment_infos.data(); { - const auto& ssr_blur_pipeline = Graphics::GetGraphicsPipeline("SSR_BLUR"); + const auto& ssr_blur_pipeline = Platform::GetGraphicsPipeline("SSR_BLUR"); vkCmdBeginRendering(vk_command_buffer, &render_info2); ssr_blur_pipeline->states.depth_test = false; ssr_blur_pipeline->states.color_blend_attachment_states.clear(); @@ -216,7 +216,7 @@ void PostProcessingStack::Process(const std::shared_ptr& target_camera) render_info2.colorAttachmentCount = color_attachment_infos.size(); render_info2.pColorAttachments = color_attachment_infos.data(); { - const auto& ssr_blur_pipeline = Graphics::GetGraphicsPipeline("SSR_BLUR"); + const auto& ssr_blur_pipeline = Platform::GetGraphicsPipeline("SSR_BLUR"); vkCmdBeginRendering(vk_command_buffer, &render_info2); ssr_blur_pipeline->states.depth_test = false; ssr_blur_pipeline->states.color_blend_attachment_states.clear(); @@ -248,7 +248,7 @@ void PostProcessingStack::Process(const std::shared_ptr& target_camera) render_info2.colorAttachmentCount = color_attachment_infos.size(); render_info2.pColorAttachments = color_attachment_infos.data(); { - const auto& ssr_combine_pipeline = Graphics::GetGraphicsPipeline("SSR_COMBINE"); + const auto& ssr_combine_pipeline = Platform::GetGraphicsPipeline("SSR_COMBINE"); vkCmdBeginRendering(vk_command_buffer, &render_info2); ssr_combine_pipeline->states.depth_test = false; ssr_combine_pipeline->states.color_blend_attachment_states.clear(); diff --git a/EvoEngine_SDK/src/ReflectionProbe.cpp b/EvoEngine_SDK/src/ReflectionProbe.cpp index 3b2308e..69827de 100644 --- a/EvoEngine_SDK/src/ReflectionProbe.cpp +++ b/EvoEngine_SDK/src/ReflectionProbe.cpp @@ -15,7 +15,7 @@ void ReflectionProbe::Initialize(uint32_t resolution) { cubemap_->Initialize(resolution, mip_levels); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { cubemap_->RefStorage().image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); cubemap_->RefStorage().image->GenerateMipmaps(vk_command_buffer); cubemap_->RefStorage().image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); @@ -28,7 +28,7 @@ void ReflectionProbe::Initialize(uint32_t resolution) { view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = cubemap_->RefStorage().image->GetVkImage(); view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - view_info.format = Graphics::Constants::texture_2d; + view_info.format = Platform::Constants::texture_2d; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; view_info.subresourceRange.baseMipLevel = mip; view_info.subresourceRange.levelCount = 1; @@ -61,7 +61,7 @@ void ReflectionProbe::ConstructFromCubemap(const std::shared_ptr& targe depth_image_info.extent.depth = 1; depth_image_info.mipLevels = 1; depth_image_info.arrayLayers = 1; - depth_image_info.format = Graphics::Constants::shadow_map; + depth_image_info.format = Platform::Constants::shadow_map; depth_image_info.tiling = VK_IMAGE_TILING_OPTIMAL; depth_image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; depth_image_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; @@ -69,7 +69,7 @@ void ReflectionProbe::ConstructFromCubemap(const std::shared_ptr& targe depth_image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; const auto depth_image = std::make_shared(depth_image_info); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { depth_image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); }); @@ -77,7 +77,7 @@ void ReflectionProbe::ConstructFromCubemap(const std::shared_ptr& targe depth_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; depth_view_info.image = depth_image->GetVkImage(); depth_view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - depth_view_info.format = Graphics::Constants::shadow_map; + depth_view_info.format = Platform::Constants::shadow_map; depth_view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; depth_view_info.subresourceRange.baseMipLevel = 0; depth_view_info.subresourceRange.levelCount = 1; @@ -87,7 +87,7 @@ void ReflectionProbe::ConstructFromCubemap(const std::shared_ptr& targe #pragma endregion const std::unique_ptr temp_set = - std::make_unique(Graphics::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); + std::make_unique(Platform::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); VkDescriptorImageInfo descriptor_image_info; descriptor_image_info.imageView = target_cubemap->GetImageView()->GetVkImageView(); descriptor_image_info.imageLayout = target_cubemap->GetImage()->GetLayout(); @@ -105,8 +105,8 @@ void ReflectionProbe::ConstructFromCubemap(const std::shared_ptr& targe glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, -1.0f, 0.0f))}; const auto max_mip_levels = cubemap_->RefStorage().image->GetMipLevels(); - const auto prefilter_construct = Graphics::GetGraphicsPipeline("PREFILTER_CONSTRUCT"); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + const auto prefilter_construct = Platform::GetGraphicsPipeline("PREFILTER_CONSTRUCT"); + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { cubemap_->RefStorage().image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); for (uint32_t mip = 0; mip < max_mip_levels; ++mip) { @@ -182,7 +182,7 @@ void ReflectionProbe::ConstructFromCubemap(const std::shared_ptr& targe vkCmdEndRendering(vk_command_buffer); #pragma endregion - Graphics::EverythingBarrier(vk_command_buffer); + Platform::EverythingBarrier(vk_command_buffer); } } cubemap_->RefStorage().image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); diff --git a/EvoEngine_SDK/src/RenderLayer.cpp b/EvoEngine_SDK/src/RenderLayer.cpp index 7d6296d..057aec2 100644 --- a/EvoEngine_SDK/src/RenderLayer.cpp +++ b/EvoEngine_SDK/src/RenderLayer.cpp @@ -2,7 +2,7 @@ #include "Application.hpp" #include "EditorLayer.hpp" #include "GeometryStorage.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "GraphicsPipeline.hpp" #include "Jobs.hpp" #include "LODGroup.hpp" @@ -49,14 +49,14 @@ void RenderLayer::OnCreate() { CreatePerFrameDescriptorSets(); std::vector kernels; - for (uint32_t i = 0; i < Graphics::Constants::max_kernel_amount; i++) { + for (uint32_t i = 0; i < Platform::Constants::max_kernel_amount; i++) { kernels.emplace_back(glm::ballRand(1.0f), 1.0f); } - for (uint32_t i = 0; i < Graphics::Constants::max_kernel_amount; i++) { + for (uint32_t i = 0; i < Platform::Constants::max_kernel_amount; i++) { kernels.emplace_back(glm::gaussRand(0.0f, 1.0f), glm::gaussRand(0.0f, 1.0f), glm::gaussRand(0.0f, 1.0f), glm::gaussRand(0.0f, 1.0f)); } - for (int i = 0; i < Graphics::GetMaxFramesInFlight(); i++) { + for (int i = 0; i < Platform::GetMaxFramesInFlight(); i++) { kernel_descriptor_buffers_[i]->UploadVector(kernels); } @@ -80,7 +80,7 @@ void RenderLayer::ClearAllCameras() { std::vector>> cameras; CollectCameras(cameras); - Graphics::RecordCommandsToMainGraphicsQueue([&](VkCommandBuffer vk_command_buffer) { + Platform::RecordCommandsMainQueue([&](VkCommandBuffer vk_command_buffer) { for (const auto& i : cameras) { if (const auto render_texture = i.second->GetRenderTexture()) render_texture->Clear(vk_command_buffer); @@ -138,8 +138,8 @@ void RenderLayer::RenderAllCameras() { CollectPointLights(); CollectSpotLights(); - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); - auto& graphics = Graphics::GetInstance(); + const auto current_frame_index = Platform::GetCurrentFrameIndex(); + auto& graphics = Platform::GetInstance(); graphics.triangles[current_frame_index] = 0; graphics.strands_segments[current_frame_index] = 0; graphics.draw_call[current_frame_index] = 0; @@ -243,17 +243,17 @@ void RenderLayer::RenderAllCameras() { return; } if (i.editor_camera_component && i.editor_camera_component->IsEnabled()) { - Graphics::RecordCommandsToMainGraphicsQueue([&](VkCommandBuffer vk_command_buffer) { + Platform::RecordCommandsMainQueue([&](VkCommandBuffer vk_command_buffer) { std::shared_ptr gizmos_pipeline; switch (i.gizmo_settings.color_mode) { case GizmoSettings::ColorMode::Default: { - gizmos_pipeline = Graphics::GetGraphicsPipeline("GIZMOS"); + gizmos_pipeline = Platform::GetGraphicsPipeline("GIZMOS"); } break; case GizmoSettings::ColorMode::VertexColor: { - gizmos_pipeline = Graphics::GetGraphicsPipeline("GIZMOS_VERTEX_COLORED"); + gizmos_pipeline = Platform::GetGraphicsPipeline("GIZMOS_VERTEX_COLORED"); } break; case GizmoSettings::ColorMode::NormalColor: { - gizmos_pipeline = Graphics::GetGraphicsPipeline("GIZMOS_NORMAL_COLORED"); + gizmos_pipeline = Platform::GetGraphicsPipeline("GIZMOS_NORMAL_COLORED"); } break; } i.editor_camera_component->GetRenderTexture()->ApplyGraphicsPipelineStates(gizmos_pipeline->states); @@ -283,8 +283,8 @@ void RenderLayer::RenderAllCameras() { return; } if (i.editor_camera_component && i.editor_camera_component->IsEnabled()) { - Graphics::RecordCommandsToMainGraphicsQueue([&](VkCommandBuffer vk_command_buffer) { - const auto gizmos_pipeline = Graphics::GetGraphicsPipeline("GIZMOS_INSTANCED_COLORED"); + Platform::RecordCommandsMainQueue([&](VkCommandBuffer vk_command_buffer) { + const auto gizmos_pipeline = Platform::GetGraphicsPipeline("GIZMOS_INSTANCED_COLORED"); i.editor_camera_component->GetRenderTexture()->ApplyGraphicsPipelineStates(gizmos_pipeline->states); i.gizmo_settings.ApplySettings(gizmos_pipeline->states); @@ -315,17 +315,17 @@ void RenderLayer::RenderAllCameras() { return; } if (i.editor_camera_component && i.editor_camera_component->IsEnabled()) { - Graphics::RecordCommandsToMainGraphicsQueue([&](VkCommandBuffer vk_command_buffer) { + Platform::RecordCommandsMainQueue([&](VkCommandBuffer vk_command_buffer) { std::shared_ptr gizmos_pipeline; switch (i.gizmo_settings.color_mode) { case GizmoSettings::ColorMode::Default: { - gizmos_pipeline = Graphics::GetGraphicsPipeline("GIZMOS_STRANDS"); + gizmos_pipeline = Platform::GetGraphicsPipeline("GIZMOS_STRANDS"); } break; case GizmoSettings::ColorMode::VertexColor: { - gizmos_pipeline = Graphics::GetGraphicsPipeline("GIZMOS_STRANDS_VERTEX_COLORED"); + gizmos_pipeline = Platform::GetGraphicsPipeline("GIZMOS_STRANDS_VERTEX_COLORED"); } break; case GizmoSettings::ColorMode::NormalColor: { - gizmos_pipeline = Graphics::GetGraphicsPipeline("GIZMOS_STRANDS_NORMAL_COLORED"); + gizmos_pipeline = Platform::GetGraphicsPipeline("GIZMOS_STRANDS_NORMAL_COLORED"); } break; } i.editor_camera_component->GetRenderTexture()->ApplyGraphicsPipelineStates(gizmos_pipeline->states); @@ -385,11 +385,11 @@ void RenderLayer::OnInspect(const std::shared_ptr& editor_layer) { ImGui::Checkbox("Count dc for shadows", &count_shadow_rendering_draw_calls); ImGui::Checkbox("Wireframe", &wire_frame); - if (Graphics::Constants::enable_mesh_shader) - ImGui::Checkbox("Meshlet", &Graphics::Settings::use_mesh_shader); - if (!Graphics::Settings::use_mesh_shader) + if (Platform::Constants::enable_mesh_shader) + ImGui::Checkbox("Meshlet", &Platform::Settings::use_mesh_shader); + if (!Platform::Settings::use_mesh_shader) ImGui::Checkbox("Indirect Rendering", &enable_indirect_rendering); - if (Graphics::Constants::enable_mesh_shader && Graphics::Settings::use_mesh_shader) { + if (Platform::Constants::enable_mesh_shader && Platform::Settings::use_mesh_shader) { ImGui::Checkbox("Show meshlets", &enable_debug_visualization); } else { ImGui::Checkbox("Show meshes", &enable_debug_visualization); @@ -543,7 +543,7 @@ void RenderLayer::CollectDirectionalLights( scene->UnsafeGetPrivateComponentOwnersList(); render_info_block.directional_light_size = 0; if (directional_light_entities && !directional_light_entities->empty()) { - directional_light_info_blocks_.resize(Graphics::Settings::max_directional_light_size * cameras.size()); + directional_light_info_blocks_.resize(Platform::Settings::max_directional_light_size * cameras.size()); for (const auto& light_entity : *directional_light_entities) { if (!scene->IsEntityEnabled(light_entity)) continue; @@ -554,11 +554,11 @@ void RenderLayer::CollectDirectionalLights( } std::vector viewport_results; Lighting::AllocateAtlas(render_info_block.directional_light_size, - Graphics::Settings::directional_light_shadow_map_resolution, viewport_results); + Platform::Settings::directional_light_shadow_map_resolution, viewport_results); for (const auto& [cameraGlobalTransform, camera] : cameras) { auto camera_index = GetCameraIndex(camera->GetHandle()); for (int i = 0; i < render_info_block.directional_light_size; i++) { - const auto block_index = camera_index * Graphics::Settings::max_directional_light_size + i; + const auto block_index = camera_index * Platform::Settings::max_directional_light_size + i; auto& viewport = directional_light_info_blocks_[block_index].viewport; viewport.x = viewport_results[i].x; viewport.y = viewport_results[i].y; @@ -583,7 +583,7 @@ void RenderLayer::CollectDirectionalLights( float plane_distance = 0; glm::vec3 center; const auto block_index = - camera_index * Graphics::Settings::max_directional_light_size + directional_light_index; + camera_index * Platform::Settings::max_directional_light_size + directional_light_index; directional_light_info_blocks_[block_index].direction = glm::vec4(light_dir, 0.0f); directional_light_info_blocks_[block_index].diffuse = glm::vec4(dlc->diffuse * dlc->diffuse_brightness, dlc->cast_shadow); @@ -755,7 +755,7 @@ void RenderLayer::CollectPointLights() { render_info_block.point_light_size++; } std::vector view_port_results; - Lighting::AllocateAtlas(render_info_block.point_light_size, Graphics::Settings::point_light_shadow_map_resolution, + Lighting::AllocateAtlas(render_info_block.point_light_size, Platform::Settings::point_light_shadow_map_resolution, view_port_results); int allocation_index = 0; for (const auto& point_light_index : sorted_point_light_indices) { @@ -822,7 +822,7 @@ void RenderLayer::CollectSpotLights() { render_info_block.spot_light_size++; } std::vector view_port_results; - Lighting::AllocateAtlas(render_info_block.spot_light_size, Graphics::Settings::spot_light_shadow_map_resolution, + Lighting::AllocateAtlas(render_info_block.spot_light_size, Platform::Settings::spot_light_shadow_map_resolution, view_port_results); int allocation_index = 0; for (const auto& spot_light_index : sorted_spot_light_indices) { @@ -874,28 +874,28 @@ void RenderLayer::ApplyAnimator() const { void RenderLayer::PreparePointAndSpotLightShadowMap() const { const bool count_draw_calls = count_shadow_rendering_draw_calls; - const bool use_mesh_shader = Graphics::Constants::enable_mesh_shader && Graphics::Settings::use_mesh_shader; - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); + const bool use_mesh_shader = Platform::Constants::enable_mesh_shader && Platform::Settings::use_mesh_shader; + const auto current_frame_index = Platform::GetCurrentFrameIndex(); const auto& point_light_shadow_pipeline = use_mesh_shader - ? Graphics::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP_MESH") - : Graphics::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP"); - const auto& spot_light_shadow_pipeline = use_mesh_shader ? Graphics::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP_MESH") - : Graphics::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP"); + ? Platform::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP_MESH") + : Platform::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP"); + const auto& spot_light_shadow_pipeline = use_mesh_shader ? Platform::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP_MESH") + : Platform::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP"); - const auto& point_light_shadow_skinned_pipeline = Graphics::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP_SKINNED"); - const auto& spot_light_shadow_skinned_pipeline = Graphics::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP_SKINNED"); + const auto& point_light_shadow_skinned_pipeline = Platform::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP_SKINNED"); + const auto& spot_light_shadow_skinned_pipeline = Platform::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP_SKINNED"); - const auto& point_light_shadow_instanced_pipeline = Graphics::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP_INSTANCED"); - const auto& spot_light_shadow_instanced_pipeline = Graphics::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP_INSTANCED"); + const auto& point_light_shadow_instanced_pipeline = Platform::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP_INSTANCED"); + const auto& spot_light_shadow_instanced_pipeline = Platform::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP_INSTANCED"); - const auto& point_light_shadow_strands_pipeline = Graphics::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP_STRANDS"); - const auto& spot_light_shadow_strands_pipeline = Graphics::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP_STRANDS"); - auto& graphics = Graphics::GetInstance(); + const auto& point_light_shadow_strands_pipeline = Platform::GetGraphicsPipeline("POINT_LIGHT_SHADOW_MAP_STRANDS"); + const auto& spot_light_shadow_strands_pipeline = Platform::GetGraphicsPipeline("SPOT_LIGHT_SHADOW_MAP_STRANDS"); + auto& graphics = Platform::GetInstance(); const uint32_t task_work_group_invocations = graphics.mesh_shader_properties_ext_.maxPreferredTaskWorkGroupInvocations; - Graphics::RecordCommandsToMainGraphicsQueue([&](VkCommandBuffer vk_command_buffer) { + Platform::RecordCommandsMainQueue([&](VkCommandBuffer vk_command_buffer) { #pragma region Viewport and scissor VkRect2D render_area; render_area.offset = {0, 0}; @@ -937,7 +937,7 @@ void RenderLayer::PreparePointAndSpotLightShadowMap() const { vkCmdBeginRendering(vk_command_buffer, &render_info); point_light_shadow_pipeline->Bind(vk_command_buffer); point_light_shadow_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); for (int i = 0; i < point_light_info_blocks_.size(); i++) { const auto& point_light_info_block = point_light_info_blocks_[i]; viewport.x = point_light_info_block.viewport.x; @@ -1010,7 +1010,7 @@ void RenderLayer::PreparePointAndSpotLightShadowMap() const { vkCmdBeginRendering(vk_command_buffer, &render_info); point_light_shadow_instanced_pipeline->Bind(vk_command_buffer); point_light_shadow_instanced_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); for (int i = 0; i < point_light_info_blocks_.size(); i++) { const auto& point_light_info_block = point_light_info_blocks_[i]; viewport.x = point_light_info_block.viewport.x; @@ -1060,7 +1060,7 @@ void RenderLayer::PreparePointAndSpotLightShadowMap() const { vkCmdBeginRendering(vk_command_buffer, &render_info); point_light_shadow_skinned_pipeline->Bind(vk_command_buffer); point_light_shadow_skinned_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); for (int i = 0; i < point_light_info_blocks_.size(); i++) { const auto& point_light_info_block = point_light_info_blocks_[i]; viewport.x = point_light_info_block.viewport.x; @@ -1108,7 +1108,7 @@ void RenderLayer::PreparePointAndSpotLightShadowMap() const { vkCmdBeginRendering(vk_command_buffer, &render_info); point_light_shadow_strands_pipeline->Bind(vk_command_buffer); point_light_shadow_strands_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); for (int i = 0; i < point_light_info_blocks_.size(); i++) { const auto& point_light_info_block = point_light_info_blocks_[i]; viewport.x = point_light_info_block.viewport.x; @@ -1174,7 +1174,7 @@ void RenderLayer::PreparePointAndSpotLightShadowMap() const { vkCmdBeginRendering(vk_command_buffer, &render_info); spot_light_shadow_pipeline->Bind(vk_command_buffer); spot_light_shadow_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); for (int i = 0; i < spot_light_info_blocks_.size(); i++) { const auto& spot_light_info_block = spot_light_info_blocks_[i]; viewport.x = spot_light_info_block.viewport.x; @@ -1245,7 +1245,7 @@ void RenderLayer::PreparePointAndSpotLightShadowMap() const { vkCmdBeginRendering(vk_command_buffer, &render_info); spot_light_shadow_instanced_pipeline->Bind(vk_command_buffer); spot_light_shadow_instanced_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); for (int i = 0; i < spot_light_info_blocks_.size(); i++) { const auto& spot_light_info_block = spot_light_info_blocks_[i]; viewport.x = spot_light_info_block.viewport.x; @@ -1293,7 +1293,7 @@ void RenderLayer::PreparePointAndSpotLightShadowMap() const { vkCmdBeginRendering(vk_command_buffer, &render_info); spot_light_shadow_skinned_pipeline->Bind(vk_command_buffer); spot_light_shadow_skinned_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); for (int i = 0; i < spot_light_info_blocks_.size(); i++) { const auto& spot_light_info_block = spot_light_info_blocks_[i]; viewport.x = spot_light_info_block.viewport.x; @@ -1339,7 +1339,7 @@ void RenderLayer::PreparePointAndSpotLightShadowMap() const { vkCmdBeginRendering(vk_command_buffer, &render_info); spot_light_shadow_strands_pipeline->Bind(vk_command_buffer); spot_light_shadow_strands_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); for (int i = 0; i < spot_light_info_blocks_.size(); i++) { const auto& spot_light_info_block = spot_light_info_blocks_[i]; viewport.x = spot_light_info_block.viewport.x; @@ -1533,7 +1533,7 @@ void RenderLayer::CreateStandardDescriptorBuffers() { buffer_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; VmaAllocationCreateInfo buffer_vma_allocation_create_info{}; buffer_vma_allocation_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE; - const auto max_frame_in_flight = Graphics::GetMaxFramesInFlight(); + const auto max_frame_in_flight = Platform::GetMaxFramesInFlight(); for (size_t i = 0; i < max_frame_in_flight; i++) { buffer_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; buffer_create_info.size = sizeof(RenderInfoBlock); @@ -1543,37 +1543,37 @@ void RenderLayer::CreateStandardDescriptorBuffers() { environment_info_descriptor_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); buffer_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; - buffer_create_info.size = sizeof(CameraInfoBlock) * Graphics::Constants::initial_camera_size; + buffer_create_info.size = sizeof(CameraInfoBlock) * Platform::Constants::initial_camera_size; camera_info_descriptor_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); - buffer_create_info.size = sizeof(MaterialInfoBlock) * Graphics::Constants::initial_material_size; + buffer_create_info.size = sizeof(MaterialInfoBlock) * Platform::Constants::initial_material_size; material_info_descriptor_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); - buffer_create_info.size = sizeof(InstanceInfoBlock) * Graphics::Constants::initial_instance_size; + buffer_create_info.size = sizeof(InstanceInfoBlock) * Platform::Constants::initial_instance_size; instance_info_descriptor_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); buffer_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; - buffer_create_info.size = sizeof(glm::vec4) * Graphics::Constants::max_kernel_amount * 2; + buffer_create_info.size = sizeof(glm::vec4) * Platform::Constants::max_kernel_amount * 2; kernel_descriptor_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); buffer_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; - buffer_create_info.size = sizeof(DirectionalLightInfo) * Graphics::Settings::max_directional_light_size * - Graphics::Constants::initial_camera_size; + buffer_create_info.size = sizeof(DirectionalLightInfo) * Platform::Settings::max_directional_light_size * + Platform::Constants::initial_camera_size; directional_light_info_descriptor_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); - buffer_create_info.size = sizeof(PointLightInfo) * Graphics::Settings::max_point_light_size; + buffer_create_info.size = sizeof(PointLightInfo) * Platform::Settings::max_point_light_size; point_light_info_descriptor_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); - buffer_create_info.size = sizeof(SpotLightInfo) * Graphics::Settings::max_spot_light_size; + buffer_create_info.size = sizeof(SpotLightInfo) * Platform::Settings::max_spot_light_size; spot_light_info_descriptor_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); buffer_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; - buffer_create_info.size = sizeof(VkDrawMeshTasksIndirectCommandEXT) * Graphics::Constants::initial_render_task_size; + buffer_create_info.size = sizeof(VkDrawMeshTasksIndirectCommandEXT) * Platform::Constants::initial_render_task_size; mesh_draw_mesh_tasks_indirect_commands_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); - buffer_create_info.size = sizeof(VkDrawIndexedIndirectCommand) * Graphics::Constants::initial_render_task_size; + buffer_create_info.size = sizeof(VkDrawIndexedIndirectCommand) * Platform::Constants::initial_render_task_size; mesh_draw_indexed_indirect_commands_buffers_.emplace_back( std::make_unique(buffer_create_info, buffer_vma_allocation_create_info)); } @@ -1581,11 +1581,11 @@ void RenderLayer::CreateStandardDescriptorBuffers() { } void RenderLayer::CreatePerFrameDescriptorSets() { - const auto max_frames_in_flight = Graphics::GetMaxFramesInFlight(); + const auto max_frames_in_flight = Platform::GetMaxFramesInFlight(); per_frame_descriptor_sets_.clear(); for (size_t i = 0; i < max_frames_in_flight; i++) { - auto descriptor_set = std::make_shared(Graphics::GetDescriptorSetLayout("PER_FRAME_LAYOUT")); + auto descriptor_set = std::make_shared(Platform::GetDescriptorSetLayout("PER_FRAME_LAYOUT")); per_frame_descriptor_sets_.emplace_back(descriptor_set); } } @@ -1634,7 +1634,7 @@ void RenderLayer::PrepareEnvironmentalBrdfLut() { sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; @@ -1643,8 +1643,8 @@ void RenderLayer::PrepareEnvironmentalBrdfLut() { environmental_brdf_lut_texture_storage.sampler = std::make_unique(sampler_info); } - const auto environmental_brdf_pipeline = Graphics::GetGraphicsPipeline("ENVIRONMENTAL_MAP_BRDF"); - Graphics::ImmediateSubmit([&](VkCommandBuffer vk_command_buffer) { + const auto environmental_brdf_pipeline = Platform::GetGraphicsPipeline("ENVIRONMENTAL_MAP_BRDF"); + Platform::ImmediateSubmit([&](VkCommandBuffer vk_command_buffer) { environmental_brdf_lut_texture_storage.image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); #pragma region Viewport and scissor @@ -1708,24 +1708,24 @@ void RenderLayer::PrepareEnvironmentalBrdfLut() { void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, const std::shared_ptr& camera) { const bool count_draw_calls = count_shadow_rendering_draw_calls; - const bool use_mesh_shader = Graphics::Constants::enable_mesh_shader && Graphics::Settings::use_mesh_shader; - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); + const bool use_mesh_shader = Platform::Constants::enable_mesh_shader && Platform::Settings::use_mesh_shader; + const auto current_frame_index = Platform::GetCurrentFrameIndex(); const int camera_index = GetCameraIndex(camera->GetHandle()); const auto scene = Application::GetActiveScene(); #pragma region Directional Light Shadows const auto& directional_light_shadow_pipeline = - use_mesh_shader ? Graphics::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP_MESH") - : Graphics::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP"); + use_mesh_shader ? Platform::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP_MESH") + : Platform::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP"); const auto& directional_light_shadow_pipeline_skinned = - Graphics::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP_SKINNED"); + Platform::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP_SKINNED"); const auto& directional_light_shadow_pipeline_instanced = - Graphics::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP_INSTANCED"); + Platform::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP_INSTANCED"); const auto& directional_light_shadow_pipeline_strands = - Graphics::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP_STRANDS"); - auto& graphics = Graphics::GetInstance(); + Platform::GetGraphicsPipeline("DIRECTIONAL_LIGHT_SHADOW_MAP_STRANDS"); + auto& graphics = Platform::GetInstance(); const uint32_t task_work_group_invocations = graphics.mesh_shader_properties_ext_.maxPreferredTaskWorkGroupInvocations; - Graphics::RecordCommandsToMainGraphicsQueue([&](VkCommandBuffer vk_command_buffer) { + Platform::RecordCommandsMainQueue([&](VkCommandBuffer vk_command_buffer) { #pragma region Viewport and scissor VkRect2D render_area; render_area.offset = {0, 0}; @@ -1771,7 +1771,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, GeometryStorage::BindVertices(vk_command_buffer); for (int i = 0; i < render_info_block.directional_light_size; i++) { const auto& directional_light_info_block = - directional_light_info_blocks_[camera_index * Graphics::Settings::max_directional_light_size + i]; + directional_light_info_blocks_[camera_index * Platform::Settings::max_directional_light_size + i]; viewport.x = directional_light_info_block.viewport.x; viewport.y = directional_light_info_block.viewport.y; viewport.width = directional_light_info_block.viewport.z; @@ -1783,7 +1783,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, directional_light_shadow_pipeline->states.ApplyAllStates(vk_command_buffer); if (enable_indirect_rendering && !use_mesh_shader) { RenderInstancePushConstant push_constant; - push_constant.camera_index = camera_index * Graphics::Settings::max_directional_light_size + i; + push_constant.camera_index = camera_index * Platform::Settings::max_directional_light_size + i; push_constant.light_split_index = split; push_constant.instance_index = 0; directional_light_shadow_pipeline->PushConstant(vk_command_buffer, 0, push_constant); @@ -1800,7 +1800,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, if (!render_command.cast_shadow) return; RenderInstancePushConstant push_constant; - push_constant.camera_index = camera_index * Graphics::Settings::max_directional_light_size + i; + push_constant.camera_index = camera_index * Platform::Settings::max_directional_light_size + i; push_constant.light_split_index = split; push_constant.instance_index = render_command.instance_index; directional_light_shadow_pipeline->PushConstant(vk_command_buffer, 0, push_constant); @@ -1845,12 +1845,12 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, vkCmdBeginRendering(vk_command_buffer, &render_info); directional_light_shadow_pipeline_instanced->Bind(vk_command_buffer); directional_light_shadow_pipeline_instanced->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); directional_light_shadow_pipeline_instanced->states.cull_mode = VK_CULL_MODE_NONE; GeometryStorage::BindVertices(vk_command_buffer); for (int i = 0; i < render_info_block.directional_light_size; i++) { const auto& directional_light_info_block = - directional_light_info_blocks_[camera_index * Graphics::Settings::max_directional_light_size + i]; + directional_light_info_blocks_[camera_index * Platform::Settings::max_directional_light_size + i]; viewport.x = directional_light_info_block.viewport.x; viewport.y = directional_light_info_block.viewport.y; viewport.width = directional_light_info_block.viewport.z; @@ -1867,7 +1867,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, directional_light_shadow_pipeline_instanced->BindDescriptorSet( vk_command_buffer, 1, render_command.particle_infos->GetDescriptorSet()->GetVkDescriptorSet()); RenderInstancePushConstant push_constant; - push_constant.camera_index = camera_index * Graphics::Settings::max_directional_light_size + i; + push_constant.camera_index = camera_index * Platform::Settings::max_directional_light_size + i; push_constant.light_split_index = split; push_constant.instance_index = render_command.instance_index; directional_light_shadow_pipeline_instanced->PushConstant(vk_command_buffer, 0, push_constant); @@ -1902,11 +1902,11 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, vkCmdBeginRendering(vk_command_buffer, &render_info); directional_light_shadow_pipeline_skinned->Bind(vk_command_buffer); directional_light_shadow_pipeline_skinned->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); directional_light_shadow_pipeline_skinned->states.cull_mode = VK_CULL_MODE_NONE; for (int i = 0; i < render_info_block.directional_light_size; i++) { const auto& directional_light_info_block = - directional_light_info_blocks_[camera_index * Graphics::Settings::max_directional_light_size + i]; + directional_light_info_blocks_[camera_index * Platform::Settings::max_directional_light_size + i]; viewport.x = directional_light_info_block.viewport.x; viewport.y = directional_light_info_block.viewport.y; viewport.width = directional_light_info_block.viewport.z; @@ -1923,7 +1923,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, directional_light_shadow_pipeline_skinned->BindDescriptorSet( vk_command_buffer, 1, render_command.bone_matrices->GetDescriptorSet()->GetVkDescriptorSet()); RenderInstancePushConstant push_constant; - push_constant.camera_index = camera_index * Graphics::Settings::max_directional_light_size + i; + push_constant.camera_index = camera_index * Platform::Settings::max_directional_light_size + i; push_constant.light_split_index = split; push_constant.instance_index = render_command.instance_index; directional_light_shadow_pipeline_skinned->PushConstant(vk_command_buffer, 0, push_constant); @@ -1956,11 +1956,11 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, vkCmdBeginRendering(vk_command_buffer, &render_info); directional_light_shadow_pipeline_strands->Bind(vk_command_buffer); directional_light_shadow_pipeline_strands->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); directional_light_shadow_pipeline_strands->states.cull_mode = VK_CULL_MODE_NONE; for (int i = 0; i < render_info_block.directional_light_size; i++) { const auto& directional_light_info_block = - directional_light_info_blocks_[camera_index * Graphics::Settings::max_directional_light_size + i]; + directional_light_info_blocks_[camera_index * Platform::Settings::max_directional_light_size + i]; viewport.x = directional_light_info_block.viewport.x; viewport.y = directional_light_info_block.viewport.y; viewport.width = directional_light_info_block.viewport.z; @@ -1975,7 +1975,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, if (!render_command.cast_shadow) return; RenderInstancePushConstant push_constant; - push_constant.camera_index = camera_index * Graphics::Settings::max_directional_light_size + i; + push_constant.camera_index = camera_index * Platform::Settings::max_directional_light_size + i; push_constant.light_split_index = split; push_constant.instance_index = render_command.instance_index; directional_light_shadow_pipeline_strands->PushConstant(vk_command_buffer, 0, push_constant); @@ -2004,7 +2004,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, } #pragma region Deferred Rendering - Graphics::RecordCommandsToMainGraphicsQueue([&](VkCommandBuffer vk_command_buffer) { + Platform::RecordCommandsMainQueue([&](VkCommandBuffer vk_command_buffer) { #pragma region Viewport and scissor VkRect2D render_area; render_area.offset = {0, 0}; @@ -2044,8 +2044,8 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, render_info.pColorAttachments = color_attachment_infos.data(); const auto& deferred_prepass_pipeline = use_mesh_shader - ? Graphics::GetGraphicsPipeline("STANDARD_DEFERRED_PREPASS_MESH") - : Graphics::GetGraphicsPipeline("STANDARD_DEFERRED_PREPASS"); + ? Platform::GetGraphicsPipeline("STANDARD_DEFERRED_PREPASS_MESH") + : Platform::GetGraphicsPipeline("STANDARD_DEFERRED_PREPASS"); deferred_prepass_pipeline->states.ResetAllStates(color_attachment_infos.size()); deferred_prepass_pipeline->states.view_port = viewport; deferred_prepass_pipeline->states.scissor = scissor; @@ -2053,7 +2053,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, vkCmdBeginRendering(vk_command_buffer, &render_info); deferred_prepass_pipeline->Bind(vk_command_buffer); deferred_prepass_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); if (enable_indirect_rendering && !use_mesh_shader) { if (!deferred_render_instances_.render_commands.empty()) { RenderInstancePushConstant push_constant; @@ -2107,14 +2107,14 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, render_info.pColorAttachments = color_attachment_infos.data(); const auto& deferred_instanced_prepass_pipeline = - Graphics::GetGraphicsPipeline("STANDARD_INSTANCED_DEFERRED_PREPASS"); + Platform::GetGraphicsPipeline("STANDARD_INSTANCED_DEFERRED_PREPASS"); deferred_instanced_prepass_pipeline->states.ResetAllStates(color_attachment_infos.size()); deferred_instanced_prepass_pipeline->states.view_port = viewport; deferred_instanced_prepass_pipeline->states.scissor = scissor; vkCmdBeginRendering(vk_command_buffer, &render_info); deferred_instanced_prepass_pipeline->Bind(vk_command_buffer); deferred_instanced_prepass_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); deferred_instanced_render_instances_.Dispatch([&](const InstancedRenderInstance& render_command) { deferred_instanced_prepass_pipeline->BindDescriptorSet( vk_command_buffer, 1, render_command.particle_infos->GetDescriptorSet()->GetVkDescriptorSet()); @@ -2149,14 +2149,14 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, render_info.pColorAttachments = color_attachment_infos.data(); const auto& deferred_skinned_prepass_pipeline = - Graphics::GetGraphicsPipeline("STANDARD_SKINNED_DEFERRED_PREPASS"); + Platform::GetGraphicsPipeline("STANDARD_SKINNED_DEFERRED_PREPASS"); deferred_skinned_prepass_pipeline->states.ResetAllStates(color_attachment_infos.size()); deferred_skinned_prepass_pipeline->states.view_port = viewport; deferred_skinned_prepass_pipeline->states.scissor = scissor; vkCmdBeginRendering(vk_command_buffer, &render_info); deferred_skinned_prepass_pipeline->Bind(vk_command_buffer); deferred_skinned_prepass_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); deferred_skinned_render_instances_.Dispatch([&](const SkinnedRenderInstance& render_command) { deferred_skinned_prepass_pipeline->BindDescriptorSet( @@ -2190,7 +2190,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, render_info.pColorAttachments = color_attachment_infos.data(); const auto& deferred_strands_prepass_pipeline = - Graphics::GetGraphicsPipeline("STANDARD_STRANDS_DEFERRED_PREPASS"); + Platform::GetGraphicsPipeline("STANDARD_STRANDS_DEFERRED_PREPASS"); deferred_strands_prepass_pipeline->states.ResetAllStates(color_attachment_infos.size()); deferred_strands_prepass_pipeline->states.view_port = viewport; deferred_strands_prepass_pipeline->states.scissor = scissor; @@ -2198,7 +2198,7 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, vkCmdBeginRendering(vk_command_buffer, &render_info); deferred_strands_prepass_pipeline->Bind(vk_command_buffer); deferred_strands_prepass_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); deferred_strands_render_instances_.Dispatch([&](const StrandsRenderInstance& render_command) { RenderInstancePushConstant push_constant; push_constant.camera_index = camera_index; @@ -2237,15 +2237,15 @@ void RenderLayer::RenderToCamera(const GlobalTransform& camera_global_transform, lighting_->directional_light_shadow_map_->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); const auto& deferred_lighting_pipeline = - is_scene_camera ? Graphics::GetGraphicsPipeline("STANDARD_DEFERRED_LIGHTING_SCENE_CAMERA") - : Graphics::GetGraphicsPipeline("STANDARD_DEFERRED_LIGHTING"); + is_scene_camera ? Platform::GetGraphicsPipeline("STANDARD_DEFERRED_LIGHTING_SCENE_CAMERA") + : Platform::GetGraphicsPipeline("STANDARD_DEFERRED_LIGHTING"); vkCmdBeginRendering(vk_command_buffer, &render_info); deferred_lighting_pipeline->states.ResetAllStates(color_attachment_infos.size()); deferred_lighting_pipeline->states.depth_test = false; deferred_lighting_pipeline->Bind(vk_command_buffer); deferred_lighting_pipeline->BindDescriptorSet( - vk_command_buffer, 0, per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]->GetVkDescriptorSet()); + vk_command_buffer, 0, per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]->GetVkDescriptorSet()); deferred_lighting_pipeline->BindDescriptorSet(vk_command_buffer, 1, camera->g_buffer_descriptor_set_->GetVkDescriptorSet()); deferred_lighting_pipeline->BindDescriptorSet(vk_command_buffer, 2, @@ -2517,7 +2517,7 @@ void RenderLayer::DrawMesh(const std::shared_ptr& mesh, const std::shared_ } const std::shared_ptr& RenderLayer::GetPerFrameDescriptorSet() const { - return per_frame_descriptor_sets_[Graphics::GetCurrentFrameIndex()]; + return per_frame_descriptor_sets_[Platform::GetCurrentFrameIndex()]; } bool RenderLayer::TryRegisterRenderer(const std::shared_ptr& scene, const Entity& owner, diff --git a/EvoEngine_SDK/src/RenderTexture.cpp b/EvoEngine_SDK/src/RenderTexture.cpp index e320237..bc855a8 100644 --- a/EvoEngine_SDK/src/RenderTexture.cpp +++ b/EvoEngine_SDK/src/RenderTexture.cpp @@ -2,7 +2,7 @@ #include "Console.hpp" #include "EditorLayer.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" using namespace evo_engine; @@ -48,7 +48,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre image_info.extent = render_texture_create_info.extent; image_info.mipLevels = 1; image_info.arrayLayers = layer_count; - image_info.format = Graphics::Constants::render_texture_color; + image_info.format = Platform::Constants::render_texture_color; image_info.tiling = VK_IMAGE_TILING_OPTIMAL; image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | @@ -57,7 +57,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; color_image_ = std::make_shared(image_info); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { color_image_->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); }); @@ -65,7 +65,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = color_image_->GetVkImage(); view_info.viewType = render_texture_create_info.image_view_type; - view_info.format = Graphics::Constants::render_texture_color; + view_info.format = Platform::Constants::render_texture_color; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; view_info.subresourceRange.baseMipLevel = 0; view_info.subresourceRange.levelCount = 1; @@ -82,7 +82,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; @@ -102,7 +102,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre depth_info.extent = render_texture_create_info.extent; depth_info.mipLevels = 1; depth_info.arrayLayers = layer_count; - depth_info.format = Graphics::Constants::render_texture_depth; + depth_info.format = Platform::Constants::render_texture_depth; depth_info.tiling = VK_IMAGE_TILING_OPTIMAL; depth_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; depth_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | @@ -111,7 +111,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre depth_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; depth_image_ = std::make_shared(depth_info); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { depth_image_->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL); }); @@ -119,7 +119,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre depth_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; depth_view_info.image = depth_image_->GetVkImage(); depth_view_info.viewType = render_texture_create_info.image_view_type; - depth_view_info.format = Graphics::Constants::render_texture_depth; + depth_view_info.format = Platform::Constants::render_texture_depth; depth_view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; depth_view_info.subresourceRange.baseMipLevel = 0; depth_view_info.subresourceRange.levelCount = 1; @@ -136,7 +136,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre depth_sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; depth_sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; depth_sampler_info.anisotropyEnable = VK_TRUE; - depth_sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + depth_sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; depth_sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; depth_sampler_info.unnormalizedCoordinates = VK_FALSE; depth_sampler_info.compareEnable = VK_FALSE; @@ -150,7 +150,7 @@ void RenderTexture::Initialize(const RenderTextureCreateInfo& render_texture_cre if (color_) { descriptor_set_ = - std::make_shared(Graphics::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); + std::make_shared(Platform::GetDescriptorSetLayout("RENDER_TEXTURE_PRESENT_LAYOUT")); VkDescriptorImageInfo descriptor_image_info; descriptor_image_info.imageLayout = color_image_->GetLayout(); descriptor_image_info.imageView = color_image_view_->GetVkImageView(); diff --git a/EvoEngine_SDK/src/Resources.cpp b/EvoEngine_SDK/src/Resources.cpp index 04eb64d..f7a7b56 100644 --- a/EvoEngine_SDK/src/Resources.cpp +++ b/EvoEngine_SDK/src/Resources.cpp @@ -14,29 +14,29 @@ void Resources::LoadShaders() { #pragma region Shader Includes std::string add; uint32_t mesh_work_group_invocations = - Graphics::GetInstance().mesh_shader_properties_ext_.maxPreferredMeshWorkGroupInvocations; + Platform::GetInstance().mesh_shader_properties_ext_.maxPreferredMeshWorkGroupInvocations; uint32_t task_work_group_invocations = - Graphics::GetInstance().mesh_shader_properties_ext_.maxPreferredTaskWorkGroupInvocations; + Platform::GetInstance().mesh_shader_properties_ext_.maxPreferredTaskWorkGroupInvocations; - uint32_t mesh_subgroup_size = Graphics::GetInstance().vk_physical_device_vulkan11_properties_.subgroupSize; - uint32_t mesh_subgroup_count = (std::min(std::max(Graphics::Constants::meshlet_max_vertices_size, - Graphics::Constants::meshlet_max_triangles_size), + uint32_t mesh_subgroup_size = Platform::GetInstance().vk_physical_device_vulkan11_properties_.subgroupSize; + uint32_t mesh_subgroup_count = (std::min(std::max(Platform::Constants::meshlet_max_vertices_size, + Platform::Constants::meshlet_max_triangles_size), mesh_work_group_invocations) + mesh_subgroup_size - 1) / mesh_subgroup_size; - uint32_t task_subgroup_size = Graphics::GetInstance().vk_physical_device_vulkan11_properties_.subgroupSize; + uint32_t task_subgroup_size = Platform::GetInstance().vk_physical_device_vulkan11_properties_.subgroupSize; uint32_t task_subgroup_count = (task_work_group_invocations + task_subgroup_size - 1) / task_subgroup_size; task_subgroup_size = glm::max(task_subgroup_size, 1u); mesh_subgroup_size = glm::max(mesh_subgroup_size, 1u); task_subgroup_count = glm::max(task_subgroup_count, 1u); mesh_subgroup_count = glm::max(mesh_subgroup_count, 1u); - add += "\n#define MAX_DIRECTIONAL_LIGHT_SIZE " + std::to_string(Graphics::Settings::max_directional_light_size) + - "\n#define MAX_KERNEL_AMOUNT " + std::to_string(Graphics::Constants::max_kernel_amount) + - "\n#define MESHLET_MAX_VERTICES_SIZE " + std::to_string(Graphics::Constants::meshlet_max_vertices_size) + - "\n#define MESHLET_MAX_TRIANGLES_SIZE " + std::to_string(Graphics::Constants::meshlet_max_triangles_size) + - "\n#define MESHLET_MAX_INDICES_SIZE " + std::to_string(Graphics::Constants::meshlet_max_triangles_size * 3) + add += "\n#define MAX_DIRECTIONAL_LIGHT_SIZE " + std::to_string(Platform::Settings::max_directional_light_size) + + "\n#define MAX_KERNEL_AMOUNT " + std::to_string(Platform::Constants::max_kernel_amount) + + "\n#define MESHLET_MAX_VERTICES_SIZE " + std::to_string(Platform::Constants::meshlet_max_vertices_size) + + "\n#define MESHLET_MAX_TRIANGLES_SIZE " + std::to_string(Platform::Constants::meshlet_max_triangles_size) + + "\n#define MESHLET_MAX_INDICES_SIZE " + std::to_string(Platform::Constants::meshlet_max_triangles_size * 3) + "\n#define EXT_TASK_SUBGROUP_SIZE " + std::to_string(task_subgroup_size) + "\n#define EXT_MESH_SUBGROUP_SIZE " + std::to_string(mesh_subgroup_size) + @@ -47,17 +47,17 @@ void Resources::LoadShaders() { + "\n"; - Graphics::GetInstance().shader_basic_ = + Platform::GetInstance().shader_basic_ = add + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Include/Basic.glsl"); - Graphics::GetInstance().shader_basic_constants_ = + Platform::GetInstance().shader_basic_constants_ = add + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Include/BasicConstants.glsl"); - Graphics::GetInstance().shader_gizmos_constants_ = + Platform::GetInstance().shader_gizmos_constants_ = add + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Include/GizmosConstants.glsl"); - Graphics::GetInstance().shader_lighting_ = + Platform::GetInstance().shader_lighting_ = FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Include/Lighting.glsl"); - Graphics::GetInstance().shader_ssr_constants_ = + Platform::GetInstance().shader_ssr_constants_ = add + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Include/SSRConstants.glsl"); @@ -65,78 +65,78 @@ void Resources::LoadShaders() { #pragma region Standard Shader { - auto vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Standard/Standard.vert"); auto standard_vert = CreateResource("STANDARD_VERT"); standard_vert->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Standard/StandardSkinned.vert"); standard_vert = CreateResource("STANDARD_SKINNED_VERT"); standard_vert->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Standard/StandardInstanced.vert"); standard_vert = CreateResource("STANDARD_INSTANCED_VERT"); standard_vert->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Standard/StandardStrands.vert"); standard_vert = CreateResource("STANDARD_STRANDS_VERT"); standard_vert->Set(ShaderType::Vertex, vert_shader_code); - auto tesc_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto tesc_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/TessellationControl/Standard/StandardStrands.tesc"); auto standard_tesc = CreateResource("STANDARD_STRANDS_TESC"); standard_tesc->Set(ShaderType::TessellationControl, tesc_shader_code); - auto tese_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto tese_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/TessellationEvaluation/Standard/StandardStrands.tese"); auto standard_tese = CreateResource("STANDARD_STRANDS_TESE"); standard_tese->Set(ShaderType::TessellationEvaluation, tese_shader_code); - auto geom_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto geom_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Geometry/Standard/StandardStrands.geom"); auto standard_geom = CreateResource("STANDARD_STRANDS_GEOM"); standard_geom->Set(ShaderType::Geometry, geom_shader_code); - auto task_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto task_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Task/Standard/Standard.task"); auto standard_task = CreateResource("STANDARD_TASK"); standard_task->Set(ShaderType::Task, task_shader_code); - auto mesh_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto mesh_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Mesh/Standard/Standard.mesh"); auto standard_mesh = CreateResource("STANDARD_MESH"); standard_mesh->Set(ShaderType::Mesh, mesh_shader_code); - mesh_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + mesh_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Mesh/Standard/StandardMeshletColored.mesh"); standard_mesh = CreateResource("STANDARD_MESHLET_COLORED_MESH"); @@ -158,24 +158,24 @@ void Resources::LoadShaders() { #pragma region GBuffer { - auto frag_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + - Graphics::GetInstance().shader_basic_ + "\n" + "\n" + - Graphics::GetInstance().shader_lighting_ + "\n" + + auto frag_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + + Platform::GetInstance().shader_basic_ + "\n" + "\n" + + Platform::GetInstance().shader_lighting_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/Standard/StandardDeferredLighting.frag"); auto frag_shader = CreateResource("STANDARD_DEFERRED_LIGHTING_FRAG"); frag_shader->Set(ShaderType::Fragment, frag_shader_code); frag_shader_code = - std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + - Graphics::GetInstance().shader_basic_ + "\n" + "\n" + Graphics::GetInstance().shader_lighting_ + "\n" + + std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + + Platform::GetInstance().shader_basic_ + "\n" + "\n" + Platform::GetInstance().shader_lighting_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/Standard/StandardDeferredLightingSceneCamera.frag"); frag_shader = CreateResource("STANDARD_DEFERRED_LIGHTING_SCENE_CAMERA_FRAG"); frag_shader->Set(ShaderType::Fragment, frag_shader_code); - frag_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + frag_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/Standard/StandardDeferred.frag"); frag_shader = CreateResource("STANDARD_DEFERRED_FRAG"); @@ -185,20 +185,20 @@ void Resources::LoadShaders() { #pragma region PostProcessing { - auto frag_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_ssr_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto frag_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_ssr_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/PostProcessing/SSRReflect.frag"); auto frag_shader = CreateResource("SSR_REFLECT_FRAG"); frag_shader->Set(ShaderType::Fragment, frag_shader_code); - frag_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_ssr_constants_ + "\n" + + frag_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_ssr_constants_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/PostProcessing/SSRBlur.frag"); frag_shader = CreateResource("SSR_BLUR_FRAG"); frag_shader->Set(ShaderType::Fragment, frag_shader_code); - frag_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_ssr_constants_ + "\n" + + frag_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_ssr_constants_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/PostProcessing/SSRCombine.frag"); frag_shader = CreateResource("SSR_COMBINE_FRAG"); @@ -207,104 +207,104 @@ void Resources::LoadShaders() { #pragma endregion #pragma region Shadow Maps { - auto vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/DirectionalLightShadowMap.vert"); auto vert_shader = CreateResource("DIRECTIONAL_LIGHT_SHADOW_MAP_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/DirectionalLightShadowMapSkinned.vert"); vert_shader = CreateResource("DIRECTIONAL_LIGHT_SHADOW_MAP_SKINNED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/DirectionalLightShadowMapInstanced.vert"); vert_shader = CreateResource("DIRECTIONAL_LIGHT_SHADOW_MAP_INSTANCED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/DirectionalLightShadowMapStrands.vert"); vert_shader = CreateResource("DIRECTIONAL_LIGHT_SHADOW_MAP_STRANDS_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/PointLightShadowMap.vert"); vert_shader = CreateResource("POINT_LIGHT_SHADOW_MAP_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/PointLightShadowMapSkinned.vert"); vert_shader = CreateResource("POINT_LIGHT_SHADOW_MAP_SKINNED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/PointLightShadowMapInstanced.vert"); vert_shader = CreateResource("POINT_LIGHT_SHADOW_MAP_INSTANCED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/PointLightShadowMapStrands.vert"); vert_shader = CreateResource("POINT_LIGHT_SHADOW_MAP_STRANDS_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/SpotLightShadowMap.vert"); vert_shader = CreateResource("SPOT_LIGHT_SHADOW_MAP_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/SpotLightShadowMapSkinned.vert"); vert_shader = CreateResource("SPOT_LIGHT_SHADOW_MAP_SKINNED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/SpotLightShadowMapInstanced.vert"); vert_shader = CreateResource("SPOT_LIGHT_SHADOW_MAP_INSTANCED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Lighting/SpotLightShadowMapStrands.vert"); vert_shader = CreateResource("SPOT_LIGHT_SHADOW_MAP_STRANDS_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - auto tesc_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto tesc_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/TessellationControl/Lighting/ShadowMapStrands.tesc"); @@ -312,8 +312,8 @@ void Resources::LoadShaders() { tesc_shader->Set(ShaderType::TessellationControl, tesc_shader_code); auto tese_shader_code = - std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/TessellationEvaluation/Lighting/ShadowMapStrands.tese"); @@ -321,72 +321,72 @@ void Resources::LoadShaders() { tese_shader->Set(ShaderType::TessellationEvaluation, tese_shader_code); auto geom_shader_code = - std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Geometry/Lighting/DirectionalLightShadowMapStrands.geom"); auto geom_shader = CreateResource("DIRECTIONAL_LIGHT_SHADOW_MAP_STRANDS_GEOM"); geom_shader->Set(ShaderType::Geometry, geom_shader_code); - geom_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + geom_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Geometry/Lighting/PointLightShadowMapStrands.geom"); geom_shader = CreateResource("POINT_LIGHT_SHADOW_MAP_STRANDS_GEOM"); geom_shader->Set(ShaderType::Geometry, geom_shader_code); - geom_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + geom_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Geometry/Lighting/SpotLightShadowMapStrands.geom"); geom_shader = CreateResource("SPOT_LIGHT_SHADOW_MAP_STRANDS_GEOM"); geom_shader->Set(ShaderType::Geometry, geom_shader_code); - auto task_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto task_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Task/Lighting/DirectionalLightShadowMap.task"); auto task_shader = CreateResource("DIRECTIONAL_LIGHT_SHADOW_MAP_TASK"); task_shader->Set(ShaderType::Task, task_shader_code); - task_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + task_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Task/Lighting/PointLightShadowMap.task"); task_shader = CreateResource("POINT_LIGHT_SHADOW_MAP_TASK"); task_shader->Set(ShaderType::Task, task_shader_code); - task_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + task_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Task/Lighting/SpotLightShadowMap.task"); task_shader = CreateResource("SPOT_LIGHT_SHADOW_MAP_TASK"); task_shader->Set(ShaderType::Task, task_shader_code); - auto mesh_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto mesh_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Mesh/Lighting/DirectionalLightShadowMap.mesh"); auto mesh_shader = CreateResource("DIRECTIONAL_LIGHT_SHADOW_MAP_MESH"); mesh_shader->Set(ShaderType::Mesh, mesh_shader_code); - mesh_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + mesh_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Mesh/Lighting/PointLightShadowMap.mesh"); mesh_shader = CreateResource("POINT_LIGHT_SHADOW_MAP_MESH"); mesh_shader->Set(ShaderType::Mesh, mesh_shader_code); - mesh_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + mesh_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Mesh/Lighting/SpotLightShadowMap.mesh"); @@ -394,14 +394,14 @@ void Resources::LoadShaders() { mesh_shader->Set(ShaderType::Mesh, mesh_shader_code); auto frag_shader_code = - std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/Empty.frag"); auto frag_shader = CreateResource("EMPTY_FRAG"); frag_shader->Set(ShaderType::Fragment, frag_shader_code); - frag_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_basic_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + frag_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_basic_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/ShadowMapPassThrough.frag"); frag_shader = CreateResource("SHADOW_MAP_PASS_THROUGH_FRAG"); @@ -446,105 +446,105 @@ void Resources::LoadShaders() { #pragma region Gizmos { auto vert_shader_code = - std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Gizmos/Gizmos.vert"); auto vert_shader = CreateResource("GIZMOS_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Gizmos/GizmosStrands.vert"); vert_shader = CreateResource("GIZMOS_STRANDS_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Gizmos/GizmosInstancedColored.vert"); vert_shader = CreateResource("GIZMOS_INSTANCED_COLORED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Gizmos/GizmosNormalColored.vert"); vert_shader = CreateResource("GIZMOS_NORMAL_COLORED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Gizmos/GizmosStrandsNormalColored.vert"); vert_shader = CreateResource("GIZMOS_STRANDS_NORMAL_COLORED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Gizmos/GizmosVertexColored.vert"); vert_shader = CreateResource("GIZMOS_VERTEX_COLORED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - std::string tesc_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + - "\n" + Graphics::GetInstance().shader_basic_ + "\n" + + std::string tesc_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + + "\n" + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/TessellationControl/Gizmos/GizmosStrands.tesc"); auto tesc_shader = CreateResource("GIZMOS_STRANDS_TESC"); tesc_shader->Set(ShaderType::TessellationControl, tesc_shader_code); - tesc_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + tesc_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/TessellationControl/Gizmos/GizmosStrandsColored.tesc"); tesc_shader = CreateResource("GIZMOS_STRANDS_COLORED_TESC"); tesc_shader->Set(ShaderType::TessellationControl, tesc_shader_code); - auto tese_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto tese_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/TessellationEvaluation/Gizmos/GizmosStrands.tese"); auto tese_shader = CreateResource("GIZMOS_STRANDS_TESE"); tese_shader->Set(ShaderType::TessellationEvaluation, tese_shader_code); - tese_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + tese_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/TessellationEvaluation/Gizmos/GizmosStrandsColored.tese"); tese_shader = CreateResource("GIZMOS_STRANDS_COLORED_TESE"); tese_shader->Set(ShaderType::TessellationEvaluation, tese_shader_code); - auto geom_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto geom_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Geometry/Gizmos/GizmosStrands.geom"); auto geom_shader = CreateResource("GIZMOS_STRANDS_GEOM"); geom_shader->Set(ShaderType::Geometry, geom_shader_code); - geom_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + geom_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Geometry/Gizmos/GizmosStrandsColored.geom"); geom_shader = CreateResource("GIZMOS_STRANDS_COLORED_GEOM"); geom_shader->Set(ShaderType::Geometry, geom_shader_code); - vert_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + vert_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Vertex/Gizmos/GizmosStrandsVertexColored.vert"); vert_shader = CreateResource("GIZMOS_STRANDS_VERTEX_COLORED_VERT"); vert_shader->Set(ShaderType::Vertex, vert_shader_code); - auto frag_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + auto frag_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/Gizmos/Gizmos.frag"); auto frag_shader = CreateResource("GIZMOS_FRAG"); frag_shader->Set(ShaderType::Fragment, frag_shader_code); - frag_shader_code = std::string("#version 460\n") + Graphics::GetInstance().shader_gizmos_constants_ + "\n" + - Graphics::GetInstance().shader_basic_ + "\n" + + frag_shader_code = std::string("#version 460\n") + Platform::GetInstance().shader_gizmos_constants_ + "\n" + + Platform::GetInstance().shader_basic_ + "\n" + FileUtils::LoadFileAsString(std::filesystem::path("./DefaultResources") / "Shaders/Fragment/Gizmos/GizmosColored.frag"); frag_shader = CreateResource("GIZMOS_COLORED_FRAG"); diff --git a/EvoEngine_SDK/src/SkinnedMesh.cpp b/EvoEngine_SDK/src/SkinnedMesh.cpp index 0fe3b66..79f3bc1 100644 --- a/EvoEngine_SDK/src/SkinnedMesh.cpp +++ b/EvoEngine_SDK/src/SkinnedMesh.cpp @@ -23,7 +23,7 @@ void SkinnedVertexAttributes::Deserialize(const YAML::Node& in) { } const std::shared_ptr& BoneMatrices::GetDescriptorSet() const { - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); + const auto current_frame_index = Platform::GetCurrentFrameIndex(); return descriptor_set_[current_frame_index]; } @@ -35,11 +35,11 @@ BoneMatrices::BoneMatrices() { bone_matrices_crate_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; VmaAllocationCreateInfo allocation_create_info{}; allocation_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE; - const auto max_frames_in_flight = Graphics::GetMaxFramesInFlight(); + const auto max_frames_in_flight = Platform::GetMaxFramesInFlight(); for (int i = 0; i < max_frames_in_flight; i++) { bone_matrices_buffer_.emplace_back(std::make_unique(bone_matrices_crate_info, allocation_create_info)); descriptor_set_.emplace_back( - std::make_shared(Graphics::GetDescriptorSetLayout("BONE_MATRICES_LAYOUT"))); + std::make_shared(Platform::GetDescriptorSetLayout("BONE_MATRICES_LAYOUT"))); } } @@ -49,7 +49,7 @@ size_t& BoneMatrices::GetVersion() { void BoneMatrices::UploadData() { version_++; - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); + const auto current_frame_index = Platform::GetCurrentFrameIndex(); if (!value.empty()) bone_matrices_buffer_[current_frame_index]->UploadVector(value); VkDescriptorBufferInfo buffer_info; diff --git a/EvoEngine_SDK/src/Texture2D.cpp b/EvoEngine_SDK/src/Texture2D.cpp index 5fe39e7..10ab736 100644 --- a/EvoEngine_SDK/src/Texture2D.cpp +++ b/EvoEngine_SDK/src/Texture2D.cpp @@ -4,7 +4,7 @@ #include "ClassRegistry.hpp" #include "Console.hpp" #include "EditorLayer.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "Jobs.hpp" #include "TextureStorage.hpp" diff --git a/EvoEngine_SDK/src/TextureStorage.cpp b/EvoEngine_SDK/src/TextureStorage.cpp index f914c89..68edac2 100644 --- a/EvoEngine_SDK/src/TextureStorage.cpp +++ b/EvoEngine_SDK/src/TextureStorage.cpp @@ -15,7 +15,7 @@ void CubemapStorage::Initialize(uint32_t resolution, uint32_t mip_levels) { image_info.extent.depth = 1; image_info.mipLevels = mip_levels; image_info.arrayLayers = 6; - image_info.format = Graphics::Constants::texture_2d; + image_info.format = Platform::Constants::texture_2d; image_info.tiling = VK_IMAGE_TILING_OPTIMAL; image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | @@ -29,7 +29,7 @@ void CubemapStorage::Initialize(uint32_t resolution, uint32_t mip_levels) { view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = image->GetVkImage(); view_info.viewType = VK_IMAGE_VIEW_TYPE_CUBE; - view_info.format = Graphics::Constants::texture_2d; + view_info.format = Platform::Constants::texture_2d; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; view_info.subresourceRange.baseMipLevel = 0; view_info.subresourceRange.levelCount = mip_levels; @@ -46,7 +46,7 @@ void CubemapStorage::Initialize(uint32_t resolution, uint32_t mip_levels) { sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; @@ -58,7 +58,7 @@ void CubemapStorage::Initialize(uint32_t resolution, uint32_t mip_levels) { } sampler = std::make_shared(sampler_info); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); }); @@ -67,7 +67,7 @@ void CubemapStorage::Initialize(uint32_t resolution, uint32_t mip_levels) { face_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; face_view_info.image = image->GetVkImage(); face_view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - face_view_info.format = Graphics::Constants::texture_2d; + face_view_info.format = Platform::Constants::texture_2d; face_view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; face_view_info.subresourceRange.baseMipLevel = 0; face_view_info.subresourceRange.levelCount = 1; @@ -150,7 +150,7 @@ void Texture2DStorage::Initialize(const glm::uvec2& resolution) { image_info.extent.depth = 1; image_info.mipLevels = mip_levels; image_info.arrayLayers = 1; - image_info.format = Graphics::Constants::texture_2d; + image_info.format = Platform::Constants::texture_2d; image_info.tiling = VK_IMAGE_TILING_OPTIMAL; image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | @@ -163,7 +163,7 @@ void Texture2DStorage::Initialize(const glm::uvec2& resolution) { view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; view_info.image = image->GetVkImage(); view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; - view_info.format = Graphics::Constants::texture_2d; + view_info.format = Platform::Constants::texture_2d; view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; view_info.subresourceRange.baseMipLevel = 0; view_info.subresourceRange.levelCount = image_info.mipLevels; @@ -180,7 +180,7 @@ void Texture2DStorage::Initialize(const glm::uvec2& resolution) { sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT; sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT; sampler_info.anisotropyEnable = VK_TRUE; - sampler_info.maxAnisotropy = Graphics::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; + sampler_info.maxAnisotropy = Platform::GetVkPhysicalDeviceProperties().limits.maxSamplerAnisotropy; sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; sampler_info.unnormalizedCoordinates = VK_FALSE; sampler_info.compareEnable = VK_FALSE; @@ -212,11 +212,11 @@ void Texture2DStorage::UploadData(const std::vector& data, const glm: const Buffer staging_buffer{staging_buffer_create_info, staging_buffer_vma_allocation_create_info}; void* device_data = nullptr; - vmaMapMemory(Graphics::GetVmaAllocator(), staging_buffer.GetVmaAllocation(), &device_data); + vmaMapMemory(Platform::GetVmaAllocator(), staging_buffer.GetVmaAllocation(), &device_data); memcpy(device_data, data.data(), image_size); - vmaUnmapMemory(Graphics::GetVmaAllocator(), staging_buffer.GetVmaAllocation()); + vmaUnmapMemory(Platform::GetVmaAllocator(), staging_buffer.GetVmaAllocation()); - Graphics::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { + Platform::ImmediateSubmit([&](const VkCommandBuffer vk_command_buffer) { image->TransitImageLayout(vk_command_buffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); image->CopyFromBuffer(vk_command_buffer, staging_buffer.GetVkBuffer()); image->GenerateMipmaps(vk_command_buffer); @@ -260,7 +260,7 @@ void Texture2DStorage::UploadDataImmediately() { void TextureStorage::DeviceSync() { auto& storage = GetInstance(); - const auto current_frame_index = Graphics::GetCurrentFrameIndex(); + const auto current_frame_index = Platform::GetCurrentFrameIndex(); const auto render_layer = Application::GetLayer(); diff --git a/EvoEngine_SDK/src/WindowLayer.cpp b/EvoEngine_SDK/src/WindowLayer.cpp index 21d361d..ca42e0b 100644 --- a/EvoEngine_SDK/src/WindowLayer.cpp +++ b/EvoEngine_SDK/src/WindowLayer.cpp @@ -1,6 +1,6 @@ #include "WindowLayer.hpp" #include "Application.hpp" -#include "Graphics.hpp" +#include "Platform.hpp" #include "ProjectManager.hpp" using namespace evo_engine; @@ -9,7 +9,7 @@ void WindowLayer::FramebufferSizeCallback(GLFWwindow* window, int width, int hei if (const auto window_layer = Application::GetLayer(); window_layer->window_ == window) { window_layer->window_size_ = {width, height}; } - if (const auto& graphics_layer = Application::GetLayer()) { + if (const auto& graphics_layer = Application::GetLayer()) { graphics_layer->NotifyRecreateSwapChain(); } }