Refactored Graphics #297

Merged
Xenosas1337 merged 13 commits from SP3-1-Rendering into main 2023-01-01 12:35:09 +08:00
27 changed files with 405 additions and 287 deletions
Showing only changes of commit 8e2c32d110 - Show all commits

File diff suppressed because it is too large Load Diff

View File

@ -226,7 +226,7 @@ namespace SHADE
const SHMatrix& SHCameraComponent::GetPerspectiveMatrix() const noexcept const SHMatrix& SHCameraComponent::GetPerspectiveMatrix() const noexcept
{ {
return orthoProjMatrix; return perspProjMatrix;
} }
//void SHCameraComponent::SetMainCamera(size_t directorCameraIndex) noexcept //void SHCameraComponent::SetMainCamera(size_t directorCameraIndex) noexcept

View File

@ -201,7 +201,7 @@ namespace SHADE
// Get interface for the shader combination // Get interface for the shader combination
auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface
( (
mappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), mappings.at(SHPredefinedDescriptorTypes::MATERIALS),
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA
); );
if (!interface) if (!interface)

View File

@ -416,7 +416,7 @@ namespace SHADE
// - Material Properties Data // - Material Properties Data
const Handle<SHShaderBlockInterface> SHADER_INFO = pipeline->GetPipelineLayout()->GetShaderBlockInterface const Handle<SHShaderBlockInterface> SHADER_INFO = pipeline->GetPipelineLayout()->GetShaderBlockInterface
( (
descMappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), descMappings.at(SHPredefinedDescriptorTypes::MATERIALS),
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
vk::ShaderStageFlagBits::eFragment vk::ShaderStageFlagBits::eFragment
); );
@ -578,7 +578,7 @@ namespace SHADE
matPropsDescSet[frameIndex], matPropsDescSet[frameIndex],
SH_PIPELINE_TYPE::GRAPHICS, SH_PIPELINE_TYPE::GRAPHICS,
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, //SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
descMappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), descMappings.at(SHPredefinedDescriptorTypes::MATERIALS),
dynamicOffset dynamicOffset
); );
} }
@ -611,7 +611,7 @@ namespace SHADE
{ {
matPropsDescSet[frameIndex] = descPool->Allocate matPropsDescSet[frameIndex] = descPool->Allocate
( (
SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS), SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::MATERIALS),
{ 0 } { 0 }
); );
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -3,7 +3,7 @@
namespace SHADE namespace SHADE
{ {
void SHDescriptorMappings::AddMappings(std::initializer_list<std::pair<SHGraphicsConstants::DescriptorSetTypes, uint32_t>> inMappings) noexcept void SHDescriptorMappings::AddMappings(std::initializer_list<std::pair<SHPredefinedDescriptorTypes, uint32_t>> inMappings) noexcept
{ {
for (auto& map : inMappings) for (auto& map : inMappings)
mappings.emplace(map); mappings.emplace(map);

View File

@ -1,14 +1,14 @@
#pragma once #pragma once
#include <unordered_map> #include <unordered_map>
#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h" #include "Graphics/MiddleEnd/GlobalData/SHPredefinedDescriptorTypes.h"
namespace SHADE namespace SHADE
{ {
class SHDescriptorMappings class SHDescriptorMappings
{ {
public: public:
using MapType = std::unordered_map<SHGraphicsConstants::DescriptorSetTypes, uint32_t>; using MapType = std::unordered_map<SHPredefinedDescriptorTypes, uint32_t>;
private: private:
//! To map an enum value from descriptor set types to set indices //! To map an enum value from descriptor set types to set indices
@ -18,7 +18,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* PUBLIC MEMBER FUNCTIONS */ /* PUBLIC MEMBER FUNCTIONS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void AddMappings (std::initializer_list<std::pair<SHGraphicsConstants::DescriptorSetTypes, uint32_t>> inMappings) noexcept; void AddMappings (std::initializer_list<std::pair<SHPredefinedDescriptorTypes, uint32_t>> inMappings) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */

View File

@ -12,7 +12,7 @@ namespace SHADE
//void SHGlobalDescriptorSets::BindLightingData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t firstSet) noexcept //void SHGlobalDescriptorSets::BindLightingData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t firstSet) noexcept
//{ //{
// // Bind descriptor set for light data // // Bind descriptor set for light data
// cmdBuffer->BindDescriptorSet(SHGlobalDescriptorSets::GetLightDescriptorSet(), SH_PIPELINE_TYPE::COMPUTE, descMappings[SHGraphicsConstants::PredefinedDescSetLayoutTypes::LIGHTS], const std::span{ TEX_DYNAMIC_OFFSET.data(), 1 }); // cmdBuffer->BindDescriptorSet(SHGlobalDescriptorSets::GetLightDescriptorSet(), SH_PIPELINE_TYPE::COMPUTE, descMappings[SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::LIGHTS], const std::span{ TEX_DYNAMIC_OFFSET.data(), 1 });
//} //}
void SHGlobalDescriptorSets::BindLightingData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept void SHGlobalDescriptorSets::BindLightingData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept

View File

@ -24,25 +24,25 @@ namespace SHADE
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings
({ ({
{SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHPredefinedDescriptorTypes::STATIC_DATA, 0},
{SHGraphicsConstants::DescriptorSetTypes::CAMERA, 1}, {SHPredefinedDescriptorTypes::CAMERA, 1},
{SHGraphicsConstants::DescriptorSetTypes::MATERIALS, 2}, {SHPredefinedDescriptorTypes::MATERIALS, 2},
}); });
perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descMappings.AddMappings perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descMappings.AddMappings
({ ({
{SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHPredefinedDescriptorTypes::STATIC_DATA, 0},
{SHGraphicsConstants::DescriptorSetTypes::CAMERA, 1}, {SHPredefinedDescriptorTypes::CAMERA, 1},
{SHGraphicsConstants::DescriptorSetTypes::FONT, 2}, {SHPredefinedDescriptorTypes::FONT, 2},
}); });
perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descMappings.AddMappings perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descMappings.AddMappings
({ ({
{SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHPredefinedDescriptorTypes::STATIC_DATA, 0},
{SHGraphicsConstants::DescriptorSetTypes::LIGHTS, 1}, {SHPredefinedDescriptorTypes::LIGHTS, 1},
{SHGraphicsConstants::DescriptorSetTypes::CAMERA, 2}, {SHPredefinedDescriptorTypes::CAMERA, 2},
{SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE, 3}, {SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE, 3},
{SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE, 4}, {SHPredefinedDescriptorTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE, 4},
}); });
} }
@ -159,23 +159,23 @@ namespace SHADE
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descSetLayouts = GetPredefinedDescSetLayouts perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descSetLayouts = GetPredefinedDescSetLayouts
( (
SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA | SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA | SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::CAMERA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::MATERIALS
); );
perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descSetLayouts = GetPredefinedDescSetLayouts perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descSetLayouts = GetPredefinedDescSetLayouts
( (
SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA | SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA | SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::CAMERA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::FONT
); );
perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descSetLayouts = GetPredefinedDescSetLayouts perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descSetLayouts = GetPredefinedDescSetLayouts
( (
SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA | SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA | SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::CAMERA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::LIGHTS SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::LIGHTS
); );
} }
@ -198,10 +198,10 @@ namespace SHADE
InitDummyPipelineLayouts (logicalDevice); InitDummyPipelineLayouts (logicalDevice);
} }
std::vector<Handle<SHVkDescriptorSetLayout>> SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHEnumWrapper<SHGraphicsConstants::PredefinedDescSetLayoutTypes> types) noexcept std::vector<Handle<SHVkDescriptorSetLayout>> SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHEnumWrapper<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes> types) noexcept
{ {
std::vector<Handle<SHVkDescriptorSetLayout>> layoutsFound; std::vector<Handle<SHVkDescriptorSetLayout>> layoutsFound;
for (uint8_t i = 0; i < SHGraphicsConstants::numPredefinedDescSetLayoutTypes; ++i) for (uint8_t i = 0; i < numPredefinedDescSetLayoutTypes; ++i)
{ {
if (types & (static_cast<uint64_t>(1) << i)) if (types & (static_cast<uint64_t>(1) << i))
layoutsFound.push_back(predefinedLayouts[i]); layoutsFound.push_back(predefinedLayouts[i]);

View File

@ -18,6 +18,18 @@ namespace SHADE
class SH_API SHGraphicsPredefinedData class SH_API SHGraphicsPredefinedData
{ {
public: public:
static constexpr uint8_t numPredefinedDescSetLayoutTypes = 64;
// This enum is mainly to initialize a bit field to retrieve bit fields from SHPRedefinedData
enum class PredefinedDescSetLayoutTypes : uint64_t
{
STATIC_DATA = 0x01,
LIGHTS = 0x02,
CAMERA = 0x04,
MATERIALS = 0x08,
FONT = 0x10,
};
enum class SystemType enum class SystemType
{ {
BATCHING = 0, BATCHING = 0,
@ -76,7 +88,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
static std::vector<Handle<SHVkDescriptorSetLayout>> GetPredefinedDescSetLayouts (SHEnumWrapper<SHGraphicsConstants::PredefinedDescSetLayoutTypes> types) noexcept; static std::vector<Handle<SHVkDescriptorSetLayout>> GetPredefinedDescSetLayouts (SHEnumWrapper<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes> types) noexcept;
static SHVertexInputState const& GetDefaultViState (void) noexcept; static SHVertexInputState const& GetDefaultViState (void) noexcept;
static PerSystem const& GetSystemData (SystemType systemType) noexcept; static PerSystem const& GetSystemData (SystemType systemType) noexcept;
static SHDescriptorMappings::MapType const& GetMappings (SystemType systemType) noexcept; static SHDescriptorMappings::MapType const& GetMappings (SystemType systemType) noexcept;

View File

@ -0,0 +1,19 @@
#pragma once
namespace SHADE
{
// This enum is different from PredefinedDescSetLayoutTypes in that it is used to initialize a hash table to
// with the values here as keys and set indices as values. It is worth noting that some values here
// are not in the above table. This is because those values don't have predefined descriptor set layouts.
// Their layouts and set indices are instead created through introspection in the pipeline layout.
enum class SHPredefinedDescriptorTypes
{
STATIC_DATA,
LIGHTS,
CAMERA,
MATERIALS,
FONT,
RENDER_GRAPH_RESOURCE,
RENDER_GRAPH_NODE_COMPUTE_RESOURCE,
};
}

View File

@ -25,33 +25,6 @@ namespace SHADE
struct SHGraphicsConstants struct SHGraphicsConstants
{ {
public: public:
static constexpr uint8_t numPredefinedDescSetLayoutTypes = 64;
// This enum is mainly to initialize a bit field to retrieve bit fields from SHPRedefinedData
enum class PredefinedDescSetLayoutTypes : uint64_t
{
STATIC_DATA = 0x01,
LIGHTS = 0x02,
CAMERA = 0x04,
MATERIALS = 0x08,
FONT = 0x10,
};
// This enum is different from the one above in that it is used to initialize a hash table to
// with the values here as keys and set indices as values. It is worth noting that some values here
// are not in the above table. This is because those values don't have predefined descriptor set layouts.
// Their layouts and set indices are instead created through introspection in the pipeline layout.
enum class DescriptorSetTypes
{
STATIC_DATA,
LIGHTS,
CAMERA,
MATERIALS,
FONT,
RENDER_GRAPH_RESOURCE,
RENDER_GRAPH_NODE_COMPUTE_RESOURCE,
};
struct RenderGraphIndices struct RenderGraphIndices
{ {
static constexpr uint32_t WORLD = 0; static constexpr uint32_t WORLD = 0;

View File

@ -19,7 +19,6 @@ of DigiPen Institute of Technology is prohibited.
#include "Camera/SHCameraSystem.h" #include "Camera/SHCameraSystem.h"
#include "Editor/SHEditor.h" #include "Editor/SHEditor.h"
#include "ECS_Base/Managers/SHSystemManager.h" #include "ECS_Base/Managers/SHSystemManager.h"
//#include "SHRenderer.h"
#include "Graphics/Windowing/SHWindow.h" #include "Graphics/Windowing/SHWindow.h"
#include "Graphics/MiddleEnd/PerFrame/SHPerFrameData.h" #include "Graphics/MiddleEnd/PerFrame/SHPerFrameData.h"
#include "Graphics/MiddleEnd/Interface/SHViewport.h" #include "Graphics/MiddleEnd/Interface/SHViewport.h"
@ -125,25 +124,6 @@ namespace SHADE
SHFreetypeInstance::Init(); SHFreetypeInstance::Init();
SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDraw_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDraw_FS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDrawMesh_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/Normals_FS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/SSAOBlur_CS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_FS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_Tile_FS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_Tile_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/Text_FS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/ToSwapchain_FS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/ToSwapchain_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/UI_VS.glsl", false);
// Load Built In Shaders // Load Built In Shaders
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT); static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
static constexpr AssetID FS_DEFAULT = 46377769; defaultFragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(FS_DEFAULT); static constexpr AssetID FS_DEFAULT = 46377769; defaultFragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(FS_DEFAULT);
@ -173,16 +153,6 @@ namespace SHADE
auto windowDims = window->GetWindowSize(); auto windowDims = window->GetWindowSize();
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>(); auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
// Set Up Cameras
//screenCamera = resourceManager.Create<SHCamera>();
//screenCamera->SetLookAt(SHVec3(0.0f, 0.0f, -1.0f), SHVec3(0.0f, 0.0f, 1.0f), SHVec3(0.0f, 1.0f, 0.0f));
//screenCamera->SetOrthographic(static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.01f, 100.0f);
//worldCamera = resourceManager.Create<SHCamera>();
//worldCamera->SetLookAt(SHVec3(0.0f, 0.0f, 0.0f), SHVec3(0.0f, 0.0f, -2.0f), SHVec3(0.0f, 1.0f, 0.0f));
//worldCamera->SetPerspective(90.0f, static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.0f, 100.0f);
worldCameraDirector = cameraSystem->CreateDirector(); worldCameraDirector = cameraSystem->CreateDirector();
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
@ -343,42 +313,6 @@ namespace SHADE
// Generate render graph // Generate render graph
renderGraph->Generate(); renderGraph->Generate();
#if 0
/*-----------------------------------------------------------------------*/
/* SCREEN RENDER GRAPH */
/*-----------------------------------------------------------------------*/
// Initialize screen render graph
screenRenderGraph = resourceManager.Create<SHRenderGraph>();
screenRenderGraph->Init("Screen Render Graph", device, swapchain, &resourceManager);
screenRenderGraph->LinkNonOwningResource(worldRenderGraph, "Scene");
screenRenderGraph->LinkNonOwningResource(worldRenderGraph, "Entity ID");
screenRenderGraph->AddResource("Present", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT }, windowDims.first, windowDims.second);
auto screenSpaceNode = screenRenderGraph->AddNode("Screen Space Pass", { "Scene", "Entity ID"}, {});
auto uiSubpass = screenSpaceNode->AddSubpass("UI");
uiSubpass->AddColorOutput("Scene");
uiSubpass->AddColorOutput("Entity ID");
uiSubpass->AddExteriorDrawCalls([=](Handle<SHVkCommandBuffer>& cmdBuffer, uint32_t frameIndex)
{
textRenderingSubSystem->Render(cmdBuffer, frameIndex);
});
#ifdef SHEDITOR
{
// Dummy Node to transition scene render graph resource
auto dummyNode = screenRenderGraph->AddNode("Dummy Pass", { "Scene" }, { "Screen Space Pass" }); // no predecessors
auto dummySubpass = dummyNode->AddSubpass("Dummy Subpass");
dummySubpass->AddInput("Scene");
}
#else
screenRenderGraph->AddRenderToSwapchainNode("Scene", "Present", {"Screen Space Pass"}, {renderToSwapchainVS, renderToSwapchainFS});
#endif
screenRenderGraph->Generate();
#endif
// Create debug draw pipeline // Create debug draw pipeline
debugDrawPipeline = createDebugDrawPipeline(debugDrawNode->GetRenderpass(), debugDrawSubpass, false, false, false); debugDrawPipeline = createDebugDrawPipeline(debugDrawNode->GetRenderpass(), debugDrawSubpass, false, false, false);
SET_VK_OBJ_NAME(device, vk::ObjectType::ePipeline, debugDrawPipeline->GetVkPipeline(), "[Pipeline] Debug Draw"); SET_VK_OBJ_NAME(device, vk::ObjectType::ePipeline, debugDrawPipeline->GetVkPipeline(), "[Pipeline] Debug Draw");
@ -412,11 +346,6 @@ namespace SHADE
InitRenderGraph(); InitRenderGraph();
#if 0
#ifdef SHEDITOR
InitEditorRenderGraph();
#endif
#endif
// Create Semaphore // Create Semaphore
for (auto& semaHandle : graphSemaphores) for (auto& semaHandle : graphSemaphores)
@ -480,38 +409,6 @@ namespace SHADE
defaultMaterial->SetProperty("data.textureIndex", defaultTexture->TextureArrayIndex); defaultMaterial->SetProperty("data.textureIndex", defaultTexture->TextureArrayIndex);
} }
#if 0
#ifdef SHEDITOR
void SHGraphicsSystem::InitEditorRenderGraph(void) noexcept
{
auto windowDims = window->GetWindowSize();
// Create Default Viewport
editorViewport = AddViewport(vk::Viewport(0.0f, 0.0f, static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.0f, 1.0f));
// Get render graph from viewport editor renderer
editorRenderGraph = resourceManager.Create<SHRenderGraph>();
std::vector<Handle<SHVkCommandPool>> renderContextCmdPools{ swapchain->GetNumImages() };
for (uint32_t i = 0; i < renderContextCmdPools.size(); ++i)
renderContextCmdPools[i] = renderContext.GetFrameData(i).cmdPoolHdls[0];
editorRenderGraph->Init("Editor Render Graph", device, swapchain, &resourceManager);
editorRenderGraph->AddResource("Present", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT }, windowDims.first, windowDims.second);
auto imguiNode = editorRenderGraph->AddNode("ImGui Node", { "Present"}, {});
auto imguiSubpass = imguiNode->AddSubpass("ImGui Draw");
imguiSubpass->AddColorOutput("Present");
// Generate world render graph
editorRenderGraph->Generate();
// Add world renderer to default viewport
editorRenderer = AddRenderer(SHRenderer::PROJECTION_TYPE::PERSPECTIVE);
}
#endif
#endif
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Constructor/Destructors */ /* Constructor/Destructors */
@ -632,99 +529,15 @@ namespace SHADE
renderGraph->Execute(frameIndex, descPool); renderGraph->Execute(frameIndex, descPool);
renderGraph->End(frameIndex); renderGraph->End(frameIndex);
#if 0 graphicsQueue->SubmitCommandBuffer
// For every viewport (
for (int vpIndex = 0; vpIndex < static_cast<int>(viewports.size()); ++vpIndex) { renderGraph->GetCommandBuffer(frameIndex) },
{ { frameData.semRenderFinishHdl },
auto& renderers = viewports[vpIndex]->GetRenderers(); { frameData.semImgAvailableHdl },
{ vk::PipelineStageFlagBits::eColorAttachmentOutput },
{ frameData.fenceHdl }
);
// For every renderer
for (int renIndex = 0; renIndex < static_cast<int>(renderers.size()); ++renIndex)
{
/*-----------------------------------------------------------------------*/
/* Renderer start */
/*-----------------------------------------------------------------------*/
// get command buffer of the renderer in the current frame
auto currentCmdBuffer = renderers[renIndex]->GetCommandBuffer(frameIndex);
// Begin recording the command buffer
currentCmdBuffer->BeginRecording();
//// set viewport and scissor
//uint32_t w = static_cast<uint32_t>(viewports[vpIndex]->GetWidth());
//uint32_t h = static_cast<uint32_t>(viewports[vpIndex]->GetHeight());
//currentCmdBuffer->SetViewportScissor (static_cast<float>(w), static_cast<float>(h), w, h);
// Force set the pipeline layout
currentCmdBuffer->ForceSetPipelineLayout(SHPredefinedData::GetDummyPipelineLayout(), SH_PIPELINE_TYPE::GRAPHICS);
currentCmdBuffer->ForceSetPipelineLayout(SHPredefinedData::GetDummyPipelineLayout(), SH_PIPELINE_TYPE::COMPUTE);
// Bind all the buffers required for meshes
for (auto& [buffer, bindingPoint] : MESH_DATA)
{
if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eVertexBuffer)
currentCmdBuffer->BindVertexBuffer(bindingPoint, buffer, 0);
else if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eIndexBuffer)
currentCmdBuffer->BindIndexBuffer(buffer, 0);
}
lightingSubSystem->BindDescSet(currentCmdBuffer, frameIndex);
// Bind textures
auto textureDescSet = texLibrary.GetTextureDescriptorSetGroup();
if (textureDescSet)
{
std::array<uint32_t, 1> texDynamicOffset {0};
currentCmdBuffer->BindDescriptorSet
(
textureDescSet,
SH_PIPELINE_TYPE::GRAPHICS,
0,
texDynamicOffset
);
}
// bind camera data
//renderers[renIndex]->UpdateDataAndBind(currentCmdBuffer, frameIndex);
//#ifdef SHEDITOR
// if (renderers[renIndex] == worldRenderer)
// {
// auto editorSystem = SHSystemManager::GetSystem<SHEditor>();
// if (editorSystem->editorState != SHEditor::State::PLAY)
// worldRenderer->UpdateDataManual(currentCmdBuffer, frameIndex, cameraSystem->GetEditorCamera()->GetViewMatrix(), cameraSystem->GetEditorCamera()->GetProjMatrix(), cameraSystem->GetEditorCamera()->GetOrthoMatrix());
// else
// renderers[renIndex]->UpdateDataAndBind(currentCmdBuffer, frameIndex);
// }
// else
// renderers[renIndex]->UpdateDataAndBind(currentCmdBuffer, frameIndex);
//#else
// renderers[renIndex]->UpdateDataAndBind(currentCmdBuffer, frameIndex);
//#endif
// Draw the scene
renderers[renIndex]->Draw(frameIndex, descPool);
// End the command buffer recording
currentCmdBuffer->EndRecording();
/*-----------------------------------------------------------------------*/
/* Renderer end */
/*-----------------------------------------------------------------------*/
// submit a command buffer from the current render graph and make it wait for the previous render graph before submitting it to GPU.
graphicsQueue->SubmitCommandBuffer
(
{ currentCmdBuffer },
{ (vpIndex == viewports.size() - 1 && renIndex == renderers.size() - 1) ? frameData.semRenderFinishHdl : graphSemaphores[!semIndex] },
{ (vpIndex == 0 && renIndex == 0) ? frameData.semImgAvailableHdl : graphSemaphores[semIndex] },
{ vk::PipelineStageFlagBits::eColorAttachmentOutput },
{ (vpIndex == viewports.size() - 1 && renIndex == renderers.size() - 1) ? frameData.fenceHdl : Handle<SHVkFence>{} }
);
semIndex = !semIndex;
}
}
#endif
} }
@ -1023,7 +836,7 @@ namespace SHADE
void SHGraphicsSystem::BuildFonts(void) noexcept void SHGraphicsSystem::BuildFonts(void) noexcept
{ {
fontLibrary.BuildFonts(device, graphicsQueue, graphicsCmdPool, descPool, SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT)[0], resourceManager); fontLibrary.BuildFonts(device, graphicsQueue, graphicsCmdPool, descPool, SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::FONT)[0], resourceManager);
} }
#pragma endregion ADD_REMOVE #pragma endregion ADD_REMOVE
@ -1181,26 +994,18 @@ namespace SHADE
renderGraph->HandleResize(resizeWidth, resizeHeight); renderGraph->HandleResize(resizeWidth, resizeHeight);
#ifdef SHEDITOR #ifdef SHEDITOR
// NOTE: These 2 lines are actually not necessary because the editor viewport is not even used for // NOTE: These 2 lines are actually not necessary because the editor viewport is not even used for
// setting dynamic viewport or scissor state. ImGUI takes care of that for us. // setting dynamic viewport or scissor state. ImGUI takes care of that for us.
//editorViewport->SetWidth(windowDims.first); //editorViewport->SetWidth(windowDims.first);
//editorViewport->SetHeight(windowDims.second); //editorViewport->SetHeight(windowDims.second);
//editorRenderGraph->HandleResize(windowDims.first, windowDims.second);
#endif #endif
//screenRenderGraph->HandleResize(resizeWidth, resizeHeight);
mousePickSubSystem->HandleResize(); mousePickSubSystem->HandleResize();
postOffscreenRenderSubSystem->HandleResize(); postOffscreenRenderSubSystem->HandleResize();
worldViewport->SetWidth(static_cast<float>(resizeWidth)); worldViewport->SetWidth(static_cast<float>(resizeWidth));
worldViewport->SetHeight(static_cast<float>(resizeHeight)); worldViewport->SetHeight(static_cast<float>(resizeHeight));
//worldCamera->SetPerspective(90.0f, static_cast<float>(resizeWidth), static_cast<float>(resizeHeight), 0.0f, 100.0f);
//screenCamera->SetOrthographic(static_cast<float>(resizeWidth), static_cast<float>(resizeHeight), 0.01f, 100.0f);
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>(); auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
#ifdef SHEDITOR #ifdef SHEDITOR
cameraSystem->GetEditorCamera()->SetWidth(static_cast<float>(resizeWidth)); cameraSystem->GetEditorCamera()->SetWidth(static_cast<float>(resizeWidth));

View File

@ -51,7 +51,6 @@ namespace SHADE
class SHVkFramebuffer; class SHVkFramebuffer;
class SHVkCommandBuffer; class SHVkCommandBuffer;
class SHViewport; class SHViewport;
class SHCamera;
class SHVkShaderModule; class SHVkShaderModule;
class SHMaterial; class SHMaterial;
class SHMaterialInstance; class SHMaterialInstance;

View File

@ -100,7 +100,7 @@ namespace SHADE
auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
return pipeline->GetPipelineLayout()->GetShaderBlockInterface return pipeline->GetPipelineLayout()->GetShaderBlockInterface
( (
mappings.at (SHGraphicsConstants::DescriptorSetTypes::MATERIALS), mappings.at (SHPredefinedDescriptorTypes::MATERIALS),
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, //SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
vk::ShaderStageFlagBits::eFragment vk::ShaderStageFlagBits::eFragment

View File

@ -81,7 +81,7 @@ namespace SHADE
{ {
return baseMaterial->GetPipeline()->GetPipelineLayout()->GetShaderBlockInterface return baseMaterial->GetPipeline()->GetPipelineLayout()->GetShaderBlockInterface
( (
SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING).at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING).at(SHPredefinedDescriptorTypes::MATERIALS),
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, //SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
vk::ShaderStageFlagBits::eFragment vk::ShaderStageFlagBits::eFragment

View File

@ -36,7 +36,7 @@ namespace SHADE
//for (uint32_t i = 0; i < commandBuffers.size(); ++i) //for (uint32_t i = 0; i < commandBuffers.size(); ++i)
// commandBuffers[i] = cmdPools[i]->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY); // commandBuffers[i] = cmdPools[i]->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
cameraDescriptorSet = descriptorPool->Allocate(SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA), { 1 }); cameraDescriptorSet = descriptorPool->Allocate(SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::CAMERA), { 1 });
#ifdef _DEBUG #ifdef _DEBUG
const auto& CAM_DESC_SETS = cameraDescriptorSet->GetVkHandle(); const auto& CAM_DESC_SETS = cameraDescriptorSet->GetVkHandle();

View File

@ -386,7 +386,7 @@ namespace SHADE
std::fill (variableSizes.begin(), variableSizes.end(), 1); std::fill (variableSizes.begin(), variableSizes.end(), 1);
// Create the descriptor set // Create the descriptor set
lightingDataDescSet = descPool->Allocate({ SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::LIGHTS) }, variableSizes); lightingDataDescSet = descPool->Allocate({ SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::LIGHTS) }, variableSizes);
#ifdef _DEBUG #ifdef _DEBUG
const auto& CAM_DESC_SETS = lightingDataDescSet->GetVkHandle(); const auto& CAM_DESC_SETS = lightingDataDescSet->GetVkHandle();
for (int i = 0; i < static_cast<int>(CAM_DESC_SETS.size()); ++i) for (int i = 0; i < static_cast<int>(CAM_DESC_SETS.size()); ++i)

View File

@ -178,9 +178,9 @@ namespace SHADE
{ {
auto& textRendererComps = SHComponentManager::GetDense<SHTextRenderableComponent>(); auto& textRendererComps = SHComponentManager::GetDense<SHTextRenderableComponent>();
auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::TEXT_RENDERING); auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::TEXT_RENDERING);
uint32_t fontSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::FONT); uint32_t fontSetIndex = mappings.at(SHPredefinedDescriptorTypes::FONT);
uint32_t staticGlobalSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA); uint32_t staticGlobalSetIndex = mappings.at(SHPredefinedDescriptorTypes::STATIC_DATA);
uint32_t cameraSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA); uint32_t cameraSetIndex = mappings.at(SHPredefinedDescriptorTypes::CAMERA);
for (auto& comp : textRendererComps) for (auto& comp : textRendererComps)
{ {

View File

@ -168,7 +168,7 @@ namespace SHADE
} }
texDescriptors = descPool->Allocate texDescriptors = descPool->Allocate
( (
{ SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA) }, { SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA) },
{ static_cast<uint32_t>(texOrder.size()) } { static_cast<uint32_t>(texOrder.size()) }
); );
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -646,7 +646,7 @@ namespace SHADE
for (auto& node : nodes) for (auto& node : nodes)
{ {
// bind static global data // bind static global data
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA)); SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA));
node->Execute(cmdBuffer, descPool, frameIndex); node->Execute(cmdBuffer, descPool, frameIndex);
} }

View File

@ -359,10 +359,10 @@ namespace SHADE
commandBuffer->ForceSetPipelineLayout(SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE); commandBuffer->ForceSetPipelineLayout(SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE);
// bind static global data // bind static global data
SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA)); SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA));
// bind lighting data // bind lighting data
SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::LIGHTS), frameIndex); SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::LIGHTS), frameIndex);
} }
// Execute all subpass computes // Execute all subpass computes

View File

@ -53,7 +53,7 @@ namespace SHADE
//Get the descriptor set layouts required to allocate. We only want the ones for allocate because //Get the descriptor set layouts required to allocate. We only want the ones for allocate because
//global descriptors are already bound in the main system. //global descriptors are already bound in the main system.
auto const& graphResourceLayout = layouts[descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE)]; auto const& graphResourceLayout = layouts[descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE)];
// Allocate descriptor sets to hold the images for reading (STORAGE_IMAGE) // Allocate descriptor sets to hold the images for reading (STORAGE_IMAGE)
for (uint32_t i = 0; i < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++i) for (uint32_t i = 0; i < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++i)
@ -66,11 +66,11 @@ namespace SHADE
} }
// check if all layouts are there // check if all layouts are there
if (layouts.size() == descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE) + 1) if (layouts.size() == descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE) + 1)
{ {
// create compute resources // create compute resources
computeResource = graphStorage->resourceHub->Create<ComputeResource>(); computeResource = graphStorage->resourceHub->Create<ComputeResource>();
auto computeResourceLayout = layouts[descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE)]; auto computeResourceLayout = layouts[descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE)];
computeResource->descSet = graphStorage->descriptorPool->Allocate({ computeResourceLayout }, { 1 }); computeResource->descSet = graphStorage->descriptorPool->Allocate({ computeResourceLayout }, { 1 });
#ifdef _DEBUG #ifdef _DEBUG
for (auto set : computeResource->descSet->GetVkHandle()) for (auto set : computeResource->descSet->GetVkHandle())
@ -98,17 +98,17 @@ namespace SHADE
// bind render graph resource // bind render graph resource
cmdBuffer->BindDescriptorSet(graphResourceDescSets[frameIndex], SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE), {}); cmdBuffer->BindDescriptorSet(graphResourceDescSets[frameIndex], SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE), {});
// bind compute resource // bind compute resource
if (computeResource) if (computeResource)
{ {
cmdBuffer->BindDescriptorSet(computeResource->descSet, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE), computeResource->dynamicOffsets[frameIndex]); cmdBuffer->BindDescriptorSet(computeResource->descSet, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE), computeResource->dynamicOffsets[frameIndex]);
} }
// bind camera data // bind camera data
if (renderer) if (renderer)
renderer->BindDescriptorSet (cmdBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex); renderer->BindDescriptorSet (cmdBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::CAMERA), frameIndex);
// dispatch compute // dispatch compute
cmdBuffer->ComputeDispatch(groupSizeX, groupSizeY, 1); cmdBuffer->ComputeDispatch(groupSizeX, groupSizeY, 1);
@ -121,7 +121,7 @@ namespace SHADE
void SHRenderGraphNodeCompute::HandleResize(void) noexcept void SHRenderGraphNodeCompute::HandleResize(void) noexcept
{ {
// We need to get from mappings because we want the introspected layout from the vector of layouts (of which the first few are predefined) // We need to get from mappings because we want the introspected layout from the vector of layouts (of which the first few are predefined)
uint32_t RENDER_GRAPH_RESOURCE_SET_INDEX = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).at (SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE); uint32_t RENDER_GRAPH_RESOURCE_SET_INDEX = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).at (SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE);
// Since the descriptor set is standalone, the index we want to use is not the one in the shaders, it should always be 0. // Since the descriptor set is standalone, the index we want to use is not the one in the shaders, it should always be 0.
uint32_t RENDER_GRAPH_RESOURCE_UPDATE_SET_INDEX = 0; uint32_t RENDER_GRAPH_RESOURCE_UPDATE_SET_INDEX = 0;

View File

@ -262,11 +262,13 @@ namespace SHADE
void SHRenderGraphResource::HandleResize(uint32_t newWidth, uint32_t newHeight) noexcept void SHRenderGraphResource::HandleResize(uint32_t newWidth, uint32_t newHeight) noexcept
{ {
width = newWidth;
height = newHeight;
if ((resourceTypeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) == 0) if ((resourceTypeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) == 0)
{ {
width = newWidth;
height = newHeight;
// prepare image view details // prepare image view details
SHImageViewDetails viewDetails SHImageViewDetails viewDetails
{ {
@ -287,6 +289,9 @@ namespace SHADE
} }
else else
{ {
width = graphStorage->swapchain->GetWidth();
height = graphStorage->swapchain->GetHeight();
// Prepare image view details // Prepare image view details
SHImageViewDetails viewDetails SHImageViewDetails viewDetails
{ {

View File

@ -227,7 +227,7 @@ namespace SHADE
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
if (renderer) if (renderer)
renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex); renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::CAMERA), frameIndex);
// Draw all the batches // Draw all the batches
superBatch->Draw(commandBuffer, frameIndex); superBatch->Draw(commandBuffer, frameIndex);

View File

@ -347,4 +347,14 @@ namespace SHADE
return vkDepthFormat; return vkDepthFormat;
} }
uint32_t SHVkSwapchain::GetWidth(void) const noexcept
{
return width;
}
uint32_t SHVkSwapchain::GetHeight(void) const noexcept
{
return height;
}
} }

View File

@ -101,6 +101,8 @@ namespace SHADE
vk::SwapchainKHR const& GetVkSwapchain (void) const noexcept; vk::SwapchainKHR const& GetVkSwapchain (void) const noexcept;
vk::SurfaceFormatKHR GetSurfaceFormatKHR (void) const noexcept; vk::SurfaceFormatKHR GetSurfaceFormatKHR (void) const noexcept;
vk::Format GetDepthFormat (void) const noexcept; vk::Format GetDepthFormat (void) const noexcept;
uint32_t GetWidth (void) const noexcept;
uint32_t GetHeight (void) const noexcept;
}; };
} }

View File

@ -266,7 +266,7 @@ namespace SHADE
{ {
auto fragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(spec.fragShader); auto fragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(spec.fragShader);
auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface(mappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA); auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface(mappings.at(SHPredefinedDescriptorTypes::MATERIALS), SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA);
int const varCount = static_cast<int>(interface->GetVariableCount()); int const varCount = static_cast<int>(interface->GetVariableCount());
for (int i = 0; i < varCount; ++i) for (int i = 0; i < varCount; ++i)