This commit is contained in:
Brandon Mak 2022-12-28 20:47:20 +08:00
parent 497889c050
commit 99e7dbfa01
67 changed files with 392 additions and 307 deletions

View File

@ -11,7 +11,7 @@ layout(location = 0) out struct
vec4 Color; vec4 Color;
} Out; } Out;
layout(set = 2, binding = 0) uniform CameraData layout(set = 1, binding = 0) uniform CameraData
{ {
vec4 position; vec4 position;
mat4 vpMat; mat4 vpMat;

View File

@ -10,7 +10,7 @@ layout(location = 0) out struct
vec4 vertColor; // location 0 vec4 vertColor; // location 0
} Out; } Out;
layout(set = 2, binding = 0) uniform CameraData layout(set = 1, binding = 0) uniform CameraData
{ {
vec4 position; vec4 position;
mat4 vpMat; mat4 vpMat;

View File

@ -17,12 +17,12 @@ struct AmbientLightStruct
}; };
layout(local_size_x = 16, local_size_y = 16) in; layout(local_size_x = 16, local_size_y = 16) in;
layout(set = 4, binding = 0, rgba32f) uniform image2D positions; layout(set = 3, binding = 0, rgba32f) uniform image2D positions;
layout(set = 4, binding = 1, rgba32f) uniform image2D normals; layout(set = 3, binding = 1, rgba32f) uniform image2D normals;
layout(set = 4, binding = 2, rgba8) uniform image2D albedo; layout(set = 3, binding = 2, rgba8) uniform image2D albedo;
layout(set = 4, binding = 3, r32ui) uniform uimage2D lightLayerData; layout(set = 3, binding = 3, r32ui) uniform uimage2D lightLayerData;
layout(set = 4, binding = 4, r8) uniform image2D ssaoBlurredImage; layout(set = 3, binding = 4, r8) uniform image2D ssaoBlurredImage;
layout(set = 4, binding = 5, rgba8) uniform image2D targetImage; layout(set = 3, binding = 5, rgba8) uniform image2D targetImage;
layout(set = 1, binding = 0) uniform LightCounts layout(set = 1, binding = 0) uniform LightCounts
{ {

View File

@ -50,8 +50,8 @@
#define NUM_MASKS 8 #define NUM_MASKS 8
layout(local_size_x = 16, local_size_y = 16) in; layout(local_size_x = 16, local_size_y = 16) in;
layout(set = 4, binding = 0, rgba8) uniform image2D inputImage; layout(set = 3, binding = 0, rgba8) uniform image2D inputImage;
layout(set = 4, binding = 1, rgba8) uniform image2D resultImage; layout(set = 3, binding = 1, rgba8) uniform image2D resultImage;
const float kirsch[8][3][3] = { const float kirsch[8][3][3] = {
{ {

View File

@ -28,7 +28,7 @@ layout(location = 3) flat in struct
} In2; } In2;
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
{ {
MatPropData data[]; MatPropData data[];
} MatProp; } MatProp;

Binary file not shown.

View File

@ -46,8 +46,8 @@
layout(local_size_x = 16, local_size_y = 16) in; layout(local_size_x = 16, local_size_y = 16) in;
layout(set = 4, binding = 0, rgba8) uniform image2D inputImage; layout(set = 3, binding = 0, rgba8) uniform image2D inputImage;
layout(set = 4, binding = 1, rgba8) uniform image2D targetImage; layout(set = 3, binding = 1, rgba8) uniform image2D targetImage;
void main() void main()

Binary file not shown.

View File

@ -5,8 +5,8 @@
#define SHM_WIDTH BLUR_WIDTH + 16 - 1 #define SHM_WIDTH BLUR_WIDTH + 16 - 1
layout(local_size_x = 16, local_size_y = 16) in; layout(local_size_x = 16, local_size_y = 16) in;
layout(set = 4, binding = 0, r8) uniform image2D ssaoImage; layout(set = 3, binding = 0, r8) uniform image2D ssaoImage;
layout(set = 4, binding = 1, r8) uniform image2D ssaoBlurImage; layout(set = 3, binding = 1, r8) uniform image2D ssaoBlurImage;
float GetSSAOValue(ivec2 uv, ivec2 imageSize) float GetSSAOValue(ivec2 uv, ivec2 imageSize)

Binary file not shown.

View File

@ -1,5 +1,7 @@
#version 450 #version 450
#pragma vscode_glsllint_stage : comp
const uint NUM_SAMPLES = 64; const uint NUM_SAMPLES = 64;
const uint NUM_ROTATIONS = 16; const uint NUM_ROTATIONS = 16;
const int ROTATION_KERNEL_W = 4; const int ROTATION_KERNEL_W = 4;
@ -10,19 +12,19 @@ const float RADIUS = 0.2f;
const float BIAS = 0.0025f; const float BIAS = 0.0025f;
layout(local_size_x = 16, local_size_y = 16) in; layout(local_size_x = 16, local_size_y = 16) in;
layout(set = 4, binding = 0, rgba32f) uniform image2D positions; layout(set = 3, binding = 0, rgba32f) uniform image2D positions;
layout(set = 4, binding = 1, rgba32f) uniform image2D normals; layout(set = 3, binding = 1, rgba32f) uniform image2D normals;
layout(set = 4, binding = 2, rgba32f) uniform image2D outputImage; layout(set = 3, binding = 2, rgba32f) uniform image2D outputImage;
// SSAO data // SSAO data
layout(std430, set = 5, binding = 0) buffer SSAOData layout(std430, set = 4, binding = 0) buffer SSAOData
{ {
vec4 samples[NUM_SAMPLES]; vec4 samples[NUM_SAMPLES];
} ssaoData; } ssaoData;
layout (set = 5, binding = 1) uniform sampler2D noiseTexture; layout (set = 4, binding = 1) uniform sampler2D noiseTexture;
layout(set = 2, binding = 0) uniform CameraData layout(set = 2, binding = 0) uniform CameraData
{ {

Binary file not shown.

View File

@ -28,7 +28,7 @@ layout(location = 3) flat in struct
} In2; } In2;
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
{ {
MatPropData data[]; MatPropData data[];
} MatProp; } MatProp;

Binary file not shown.

View File

@ -26,7 +26,7 @@ layout(location = 3) flat in struct
} In2; } In2;
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
{ {
MatPropData data[]; MatPropData data[];
} MatProp; } MatProp;

View File

@ -34,7 +34,7 @@ layout(location = 3) out struct
} Out2; } Out2;
layout(set = 2, binding = 0) uniform CameraData layout(set = 1, binding = 0) uniform CameraData
{ {
vec4 position; vec4 position;
mat4 vpMat; mat4 vpMat;
@ -42,7 +42,7 @@ layout(set = 2, binding = 0) uniform CameraData
mat4 projMat; mat4 projMat;
} cameraData; } cameraData;
layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
{ {
MatPropData data[]; MatPropData data[];
} MatProp; } MatProp;

View File

@ -29,7 +29,7 @@ layout(location = 3) out struct
} Out2; } Out2;
layout(set = 2, binding = 0) uniform CameraData layout(set = 1, binding = 0) uniform CameraData
{ {
vec4 position; vec4 position;
mat4 vpMat; mat4 vpMat;

Binary file not shown.

View File

@ -28,7 +28,7 @@ layout(location = 3) flat in struct
layout(set = 4, binding = 0) uniform sampler2D fontBitmap; layout(set = 2, binding = 0) uniform sampler2D fontBitmap;
layout(location = 0) out vec4 color; layout(location = 0) out vec4 color;
layout(location = 1) out uint outEntityID; layout(location = 1) out uint outEntityID;

Binary file not shown.

View File

@ -25,7 +25,7 @@ layout(location = 3) out struct
} Out2; } Out2;
// Camera data // Camera data
layout(set = 2, binding = 0) uniform CameraData layout(set = 1, binding = 0) uniform CameraData
{ {
vec4 position; vec4 position;
mat4 vpMat; mat4 vpMat;
@ -43,7 +43,7 @@ layout(std140, push_constant) uniform TestPushConstant
} testPushConstant; } testPushConstant;
// Descriptor sets // Descriptor sets
layout(std430, set = 4, binding = 1) buffer GlyphTransforms layout(std430, set = 2, binding = 1) buffer GlyphTransforms
{ {
mat4 matrices[]; mat4 matrices[];
} glyphTransforms; } glyphTransforms;

Binary file not shown.

View File

@ -3,7 +3,7 @@
#extension GL_ARB_shading_language_420pack : enable #extension GL_ARB_shading_language_420pack : enable
#extension GL_EXT_nonuniform_qualifier : require #extension GL_EXT_nonuniform_qualifier : require
layout (input_attachment_index = 0, set = 4, binding = 0) uniform subpassInput sceneTexture; layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput sceneTexture;
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;

View File

@ -28,7 +28,7 @@ layout(location = 3) flat in struct
} In2; } In2;
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
{ {
MatPropData data[]; MatPropData data[];
} MatProp; } MatProp;

Binary file not shown.

View File

@ -29,7 +29,7 @@ layout(location = 3) out struct
} Out2; } Out2;
layout(set = 2, binding = 0) uniform CameraData layout(set = 1, binding = 0) uniform CameraData
{ {
vec4 position; vec4 position;
mat4 vpMat; mat4 vpMat;

Binary file not shown.

View File

@ -196,10 +196,12 @@ namespace SHADE
if (!fragShader) if (!fragShader)
return; return;
auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
// Get interface for the shader combination // Get interface for the shader combination
auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface
( (
SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, mappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS),
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA
); );
if (!interface) if (!interface)

View File

@ -25,7 +25,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
#include "ECS_Base/Managers/SHComponentManager.h" #include "ECS_Base/Managers/SHComponentManager.h"
#include "Math/Transform/SHTransformComponent.h" #include "Math/Transform/SHTransformComponent.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Graphics/Descriptors/SHVkDescriptorPool.h" #include "Graphics/Descriptors/SHVkDescriptorPool.h"
#include "Scene/SHSceneManager.h" #include "Scene/SHSceneManager.h"
#include "UI/SHUIComponent.h" #include "UI/SHUIComponent.h"
@ -411,12 +411,12 @@ namespace SHADE
instancedIntegerData.reserve(numTotalElements); instancedIntegerData.reserve(numTotalElements);
instancedIntegerData.clear(); instancedIntegerData.clear();
auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
// - Material Properties Data // - Material Properties Data
const Handle<SHShaderBlockInterface> SHADER_INFO = pipeline->GetPipelineLayout()->GetShaderBlockInterface const Handle<SHShaderBlockInterface> SHADER_INFO = pipeline->GetPipelineLayout()->GetShaderBlockInterface
( (
descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), descMappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS),
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
vk::ShaderStageFlagBits::eFragment vk::ShaderStageFlagBits::eFragment
); );
@ -571,14 +571,14 @@ namespace SHADE
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::INTEGER_DATA, instancedIntegerBuffer[frameIndex], 0); cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::INTEGER_DATA, instancedIntegerBuffer[frameIndex], 0);
if (matPropsDescSet[frameIndex]) if (matPropsDescSet[frameIndex])
{ {
auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
cmdBuffer->BindDescriptorSet cmdBuffer->BindDescriptorSet
( (
matPropsDescSet[frameIndex], matPropsDescSet[frameIndex],
SH_PIPELINE_TYPE::GRAPHICS, SH_PIPELINE_TYPE::GRAPHICS,
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, //SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS), descMappings.at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS),
dynamicOffset dynamicOffset
); );
} }
@ -611,7 +611,7 @@ namespace SHADE
{ {
matPropsDescSet[frameIndex] = descPool->Allocate matPropsDescSet[frameIndex] = descPool->Allocate
( (
SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS), SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS),
{ 0 } { 0 }
); );
#ifdef _DEBUG #ifdef _DEBUG
@ -623,8 +623,7 @@ namespace SHADE
#endif #endif
} }
auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; static constexpr uint32_t MATERIAL_DESC_SET_INDEX = 0;
uint32_t const MATERIAL_DESC_SET_INDEX = descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS);
std::array<Handle<SHVkBuffer>, 1> bufferList = { matPropsBuffer[frameIndex] }; std::array<Handle<SHVkBuffer>, 1> bufferList = { matPropsBuffer[frameIndex] };
matPropsDescSet[frameIndex]->ModifyWriteDescBuffer matPropsDescSet[frameIndex]->ModifyWriteDescBuffer

View File

@ -23,8 +23,8 @@ namespace SHADE
void SHGlobalDescriptorSets::BindStaticGlobalData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept void SHGlobalDescriptorSets::BindStaticGlobalData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept
{ {
// Bind descriptor set for static global data // Bind descriptor set for static global data
static constexpr std::array<uint32_t, 1> TEX_DYNAMIC_OFFSET{ 0 }; static std::array<uint32_t, 1> TEX_DYNAMIC_OFFSET{ 0 };
cmdBuffer->BindDescriptorSet(staticGlobalDataDescriptorSet, pipelineType, setIndex, const std::span{ TEX_DYNAMIC_OFFSET.data(), 1 }); cmdBuffer->BindDescriptorSet(staticGlobalDataDescriptorSet, pipelineType, setIndex, std::span{ TEX_DYNAMIC_OFFSET.data(), 1 });
} }
/***************************************************************************/ /***************************************************************************/

View File

@ -1,5 +1,5 @@
#include "SHpch.h" #include "SHpch.h"
#include "SHPredefinedData.h" #include "SHGraphicsPredefinedData.h"
#include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Pipeline/SHPipelineState.h" #include "Graphics/Pipeline/SHPipelineState.h"
#include "Graphics/Pipeline/SHVkPipelineLayout.h" #include "Graphics/Pipeline/SHVkPipelineLayout.h"
@ -11,29 +11,32 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Static Definitions */ /* Static Definitions */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
std::vector<Handle<SHVkDescriptorSetLayout>> SHPredefinedData::predefinedLayouts; std::vector<Handle<SHVkDescriptorSetLayout>> SHGraphicsPredefinedData::predefinedLayouts;
SHVertexInputState SHPredefinedData::defaultVertexInputState; SHVertexInputState SHGraphicsPredefinedData::defaultVertexInputState;
SHPredefinedData::PerSystem SHPredefinedData::batchingSystemData; std::vector<SHGraphicsPredefinedData::PerSystem> SHGraphicsPredefinedData::perSystemData;
SHPredefinedData::PerSystem SHPredefinedData::textSystemData;
SHPredefinedData::PerSystem SHPredefinedData::renderGraphNodeComputeData;
void SHPredefinedData::InitDescMappings(void) noexcept //SHGraphicsPredefinedData::PerSystem SHGraphicsPredefinedData::batchingSystemData;
//SHGraphicsPredefinedData::PerSystem SHGraphicsPredefinedData::textSystemData;
//SHGraphicsPredefinedData::PerSystem SHGraphicsPredefinedData::renderGraphNodeComputeData;
void SHGraphicsPredefinedData::InitDescMappings(void) noexcept
{ {
batchingSystemData.descMappings.AddMappings
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings
({ ({
{SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0},
{SHGraphicsConstants::DescriptorSetTypes::CAMERA, 1}, {SHGraphicsConstants::DescriptorSetTypes::CAMERA, 1},
{SHGraphicsConstants::DescriptorSetTypes::MATERIALS, 2}, {SHGraphicsConstants::DescriptorSetTypes::MATERIALS, 2},
}); });
textSystemData.descMappings.AddMappings perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descMappings.AddMappings
({ ({
{SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0},
{SHGraphicsConstants::DescriptorSetTypes::CAMERA, 1}, {SHGraphicsConstants::DescriptorSetTypes::CAMERA, 1},
{SHGraphicsConstants::DescriptorSetTypes::FONT, 2}, {SHGraphicsConstants::DescriptorSetTypes::FONT, 2},
}); });
renderGraphNodeComputeData.descMappings.AddMappings perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descMappings.AddMappings
({ ({
{SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0}, {SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA, 0},
{SHGraphicsConstants::DescriptorSetTypes::LIGHTS, 1}, {SHGraphicsConstants::DescriptorSetTypes::LIGHTS, 1},
@ -43,16 +46,17 @@ namespace SHADE
}); });
} }
void SHPredefinedData::InitDummyPipelineLayouts(Handle<SHVkLogicalDevice> logicalDevice) noexcept void SHGraphicsPredefinedData::InitDummyPipelineLayouts(Handle<SHVkLogicalDevice> logicalDevice) noexcept
{ {
batchingSystemData.dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ batchingSystemData.descSetLayouts }); perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descSetLayouts });
textSystemData.dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ textSystemData.descSetLayouts }); perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descSetLayouts });
perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descSetLayouts });
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Function Definitions */ /* Function Definitions */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void SHPredefinedData::InitDescSetLayouts(Handle<SHVkLogicalDevice> logicalDevice) noexcept void SHGraphicsPredefinedData::InitDescSetLayouts(Handle<SHVkLogicalDevice> logicalDevice) noexcept
{ {
SHVkDescriptorSetLayout::Binding genericDataBinding SHVkDescriptorSetLayout::Binding genericDataBinding
{ {
@ -153,22 +157,29 @@ namespace SHADE
predefinedLayouts.push_back(materialDataPerInstanceLayout); predefinedLayouts.push_back(materialDataPerInstanceLayout);
predefinedLayouts.push_back(fontDataDescSetLayout); predefinedLayouts.push_back(fontDataDescSetLayout);
batchingSystemData.descSetLayouts = GetPredefinedDescSetLayouts perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descSetLayouts = GetPredefinedDescSetLayouts
( (
SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA | SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA | SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS SHGraphicsConstants::PredefinedDescSetLayoutTypes::MATERIALS
); );
textSystemData.descSetLayouts = GetPredefinedDescSetLayouts perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descSetLayouts = GetPredefinedDescSetLayouts
( (
SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA | SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA | SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT
); );
perSystemData[SHUtilities::ConvertEnum(SystemType::RENDER_GRAPH_NODE_COMPUTE)].descSetLayouts = GetPredefinedDescSetLayouts
(
SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA |
SHGraphicsConstants::PredefinedDescSetLayoutTypes::LIGHTS
);
} }
void SHPredefinedData::InitDefaultVertexInputState(void) noexcept void SHGraphicsPredefinedData::InitDefaultVertexInputState(void) noexcept
{ {
defaultVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_3D) }); // positions at binding 0 defaultVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_3D) }); // positions at binding 0
defaultVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_2D) }); // UVs at binding 1 defaultVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_2D) }); // UVs at binding 1
@ -178,15 +189,16 @@ namespace SHADE
defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::UINT32_2D) }); // Instanced integer data at index 8 defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::UINT32_2D) }); // Instanced integer data at index 8
} }
void SHPredefinedData::Init(Handle<SHVkLogicalDevice> logicalDevice) noexcept void SHGraphicsPredefinedData::Init(Handle<SHVkLogicalDevice> logicalDevice) noexcept
{ {
perSystemData.resize(SHUtilities::ConvertEnum(SystemType::NUM_TYPES));
InitDescSetLayouts(logicalDevice); InitDescSetLayouts(logicalDevice);
InitDefaultVertexInputState(); InitDefaultVertexInputState();
InitDescMappings(); InitDescMappings();
InitDummyPipelineLayouts (logicalDevice); InitDummyPipelineLayouts (logicalDevice);
} }
std::vector<Handle<SHVkDescriptorSetLayout>> SHPredefinedData::GetPredefinedDescSetLayouts(SHEnumWrapper<SHGraphicsConstants::PredefinedDescSetLayoutTypes> types) noexcept std::vector<Handle<SHVkDescriptorSetLayout>> SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHEnumWrapper<SHGraphicsConstants::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 < SHGraphicsConstants::numPredefinedDescSetLayoutTypes; ++i)
@ -198,26 +210,35 @@ namespace SHADE
return layoutsFound; return layoutsFound;
} }
SHVertexInputState const& SHGraphicsPredefinedData::GetDefaultViState(void) noexcept
SHVertexInputState const& SHPredefinedData::GetDefaultViState(void) noexcept
{ {
return defaultVertexInputState; return defaultVertexInputState;
} }
SHPredefinedData::PerSystem const& SHPredefinedData::GetBatchingSystemData(void) noexcept SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetSystemData(SystemType systemType) noexcept
{ {
return batchingSystemData; return perSystemData[static_cast<uint32_t>(systemType)];
} }
SHPredefinedData::PerSystem const& SHPredefinedData::GetTextSystemData(void) noexcept SHDescriptorMappings::MapType const& SHGraphicsPredefinedData::GetMappings(SystemType systemType) noexcept
{ {
return textSystemData; return perSystemData[static_cast<uint32_t>(systemType)].descMappings.GetMappings();
} }
SHPredefinedData::PerSystem const& SHPredefinedData::GetRenderGraphNodeComputeData(void) noexcept //SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetBatchingSystemData(void) noexcept
{ //{
return renderGraphNodeComputeData; // return batchingSystemData;
} //}
//SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetTextSystemData(void) noexcept
//{
// return textSystemData;
//}
//SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetRenderGraphNodeComputeData(void) noexcept
//{
// return renderGraphNodeComputeData;
//}
} }

View File

@ -5,6 +5,8 @@
#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h" #include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h"
#include "Graphics/MiddleEnd/GlobalData/SHDescriptorMappings.h" #include "Graphics/MiddleEnd/GlobalData/SHDescriptorMappings.h"
#include "Tools/Utilities/SHUtilities.h" #include "Tools/Utilities/SHUtilities.h"
#include "Tools/SHEnumWrapper.h"
#include <unordered_map>
namespace SHADE namespace SHADE
{ {
@ -13,17 +15,24 @@ namespace SHADE
class SHVkDescriptorSetGroup; class SHVkDescriptorSetGroup;
class SHVkPipelineLayout; class SHVkPipelineLayout;
class SH_API SHGraphicsPredefinedData
class SH_API SHPredefinedData
{ {
public: public:
enum class SystemType
{
BATCHING = 0,
TEXT_RENDERING,
RENDER_GRAPH_NODE_COMPUTE,
NUM_TYPES
};
struct PerSystem struct PerSystem
{ {
//! vector of descriptor set layouts used by a system //! vector of descriptor set layouts used by a system
std::vector<Handle<SHVkDescriptorSetLayout>> descSetLayouts; std::vector<Handle<SHVkDescriptorSetLayout>> descSetLayouts;
//! pipeline layout used for binding descriptor sets in the system //! pipeline layout used for binding descriptor sets in the system
static Handle<SHVkPipelineLayout> dummyPipelineLayout; Handle<SHVkPipelineLayout> dummyPipelineLayout;
//! Descriptor type mappings for the system //! Descriptor type mappings for the system
SHDescriptorMappings descMappings; SHDescriptorMappings descMappings;
@ -36,14 +45,17 @@ namespace SHADE
//! Default vertex input state (used by everything). //! Default vertex input state (used by everything).
static SHVertexInputState defaultVertexInputState; static SHVertexInputState defaultVertexInputState;
//! predefined data for the batching system //! Predefined data for each type of system
static PerSystem batchingSystemData; static std::vector<PerSystem> perSystemData;
//! predefined data for the text system ////! predefined data for the batching system
static PerSystem textSystemData; //static PerSystem batchingSystemData;
//! predefined data for the render graph node computes ////! predefined data for the text system
static PerSystem renderGraphNodeComputeData; //static PerSystem textSystemData;
////! predefined data for the render graph node computes
//static PerSystem renderGraphNodeComputeData;
static void InitDescMappings (void) noexcept; static void InitDescMappings (void) noexcept;
static void InitDummyPipelineLayouts (Handle<SHVkLogicalDevice> logicalDevice) noexcept; static void InitDummyPipelineLayouts (Handle<SHVkLogicalDevice> logicalDevice) noexcept;
@ -54,7 +66,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Constructors */ /* Constructors */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
SHPredefinedData() = delete; SHGraphicsPredefinedData() = delete;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* PUBLIC MEMBER FUNCTIONS */ /* PUBLIC MEMBER FUNCTIONS */
@ -66,8 +78,10 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
static std::vector<Handle<SHVkDescriptorSetLayout>> GetPredefinedDescSetLayouts (SHEnumWrapper<SHGraphicsConstants::PredefinedDescSetLayoutTypes> types) noexcept; static std::vector<Handle<SHVkDescriptorSetLayout>> GetPredefinedDescSetLayouts (SHEnumWrapper<SHGraphicsConstants::PredefinedDescSetLayoutTypes> types) noexcept;
static SHVertexInputState const& GetDefaultViState (void) noexcept; static SHVertexInputState const& GetDefaultViState (void) noexcept;
static PerSystem const& GetBatchingSystemData(void) noexcept; static PerSystem const& GetSystemData (SystemType systemType) noexcept;
static PerSystem const& GetTextSystemData(void) noexcept; static SHDescriptorMappings::MapType const& GetMappings (SystemType systemType) noexcept;
static PerSystem const& GetRenderGraphNodeComputeData(void) noexcept; //static PerSystem const& GetBatchingSystemData(void) noexcept;
//static PerSystem const& GetTextSystemData(void) noexcept;
//static PerSystem const& GetRenderGraphNodeComputeData(void) noexcept;
}; };
} }

View File

@ -58,68 +58,68 @@ namespace SHADE
static constexpr uint32_t EDITOR = 0; static constexpr uint32_t EDITOR = 0;
}; };
struct DescriptorSetIndex //struct DescriptorSetIndex
{ //{
/***************************************************************************/ // /***************************************************************************/
/*! // /*!
\brief // \brief
DescriptorSet Index for static global values like generic data, and // DescriptorSet Index for static global values like generic data, and
texture samplers // texture samplers
*/ // */
/***************************************************************************/ // /***************************************************************************/
static constexpr uint32_t STATIC_GLOBALS = 0; // static constexpr uint32_t STATIC_GLOBALS = 0;
/***************************************************************************/ // /***************************************************************************/
/*! // /*!
\brief // \brief
DescriptorSet Index for dynamic global values like lights. // DescriptorSet Index for dynamic global values like lights.
*/ // */
/***************************************************************************/ // /***************************************************************************/
static constexpr uint32_t DYNAMIC_GLOBALS = 1; // static constexpr uint32_t DYNAMIC_GLOBALS = 1;
/***************************************************************************/ // /***************************************************************************/
/*! // /*!
\brief // \brief
DescriptorSet Index for high frequency changing global values like // DescriptorSet Index for high frequency changing global values like
camera matrices. // camera matrices.
*/ // */
/***************************************************************************/ // /***************************************************************************/
static constexpr uint32_t HIGH_FREQUENCY_GLOBALS = 2; // static constexpr uint32_t HIGH_FREQUENCY_GLOBALS = 2;
/***************************************************************************/ // /***************************************************************************/
/*! // /*!
\brief // \brief
DescriptorSet Index for per-instance/material changing values. // DescriptorSet Index for per-instance/material changing values.
*/ // */
/***************************************************************************/ // /***************************************************************************/
static constexpr uint32_t PER_INSTANCE = 3; // static constexpr uint32_t PER_INSTANCE = 3;
/***************************************************************************/ // /***************************************************************************/
/*! // /*!
\brief // \brief
DescriptorSet Index for render graph resources. Unlike the sets from // DescriptorSet Index for render graph resources. Unlike the sets from
1 to 3 and 6, this set index does not have hard coded bindings and is // 1 to 3 and 6, this set index does not have hard coded bindings and is
NOT part of the layouts included in the global data. // NOT part of the layouts included in the global data.
*/ // */
/***************************************************************************/ // /***************************************************************************/
static constexpr uint32_t RENDERGRAPH_RESOURCE = 4; // static constexpr uint32_t RENDERGRAPH_RESOURCE = 4;
/***************************************************************************/ // /***************************************************************************/
/*! // /*!
\brief // \brief
DescriptorSet Index for render graph node compute resources. For data // DescriptorSet Index for render graph node compute resources. For data
that we wish to pass to compute shaders in the render graph, this is // that we wish to pass to compute shaders in the render graph, this is
the set to use. Unlike the sets from 1 to 3 and 6, this set index does not have // the set to use. Unlike the sets from 1 to 3 and 6, this set index does not have
hard coded bindings and is NOT part of the layouts included in the global // hard coded bindings and is NOT part of the layouts included in the global
data. // data.
*/ // */
/***************************************************************************/ // /***************************************************************************/
static constexpr uint32_t RENDERGRAPH_NODE_COMPUTE_RESOURCE = 5; // static constexpr uint32_t RENDERGRAPH_NODE_COMPUTE_RESOURCE = 5;
/***************************************************************************/ // /***************************************************************************/
/*! // /*!
\brief // \brief
To store font data. // To store font data.
//
*/ // */
/***************************************************************************/ // /***************************************************************************/
static constexpr uint32_t FONT_DATA = 4; // static constexpr uint32_t FONT_DATA = 4;
}; //};
struct DescriptorSetBindings struct DescriptorSetBindings
{ {

View File

@ -31,7 +31,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/MiddleEnd/Interface/SHRenderable.h" #include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Graphics/MiddleEnd/Batching/SHSuperBatch.h" #include "Graphics/MiddleEnd/Batching/SHSuperBatch.h"
#include "SHGraphicsConstants.h" #include "SHGraphicsConstants.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/Images/SHVkSampler.h" #include "Graphics/Images/SHVkSampler.h"
#include "Assets/Asset Types/SHTextureAsset.h" #include "Assets/Asset Types/SHTextureAsset.h"
@ -127,6 +127,22 @@ namespace SHADE
SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDraw_VS.glsl", false); SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDraw_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/DebugDraw_FS.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);
@ -207,7 +223,7 @@ namespace SHADE
renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, windowDims.first, windowDims.second); renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, windowDims.first, windowDims.second);
renderGraph->AddResource("SSAO", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR8Unorm); renderGraph->AddResource("SSAO", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR8Unorm);
renderGraph->AddResource("SSAO Blur", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR8Unorm); renderGraph->AddResource("SSAO Blur", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR8Unorm);
renderGraph->AddResource("Present", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT }, windowDims.first, windowDims.second, vk::Format::eR8Unorm); renderGraph->AddResource("Present", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT }, windowDims.first, windowDims.second);
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
@ -261,10 +277,10 @@ namespace SHADE
// Add the pass to generate an image with just SSAO data // Add the pass to generate an image with just SSAO data
Handle<SHRenderGraphNodeCompute> ssaoPass = gBufferNode->AddNodeCompute("SSAO", ssaoShader, { "Position", "Normals", "SSAO" }); Handle<SHRenderGraphNodeCompute> ssaoPass = gBufferNode->AddNodeCompute("SSAO", ssaoShader, { "Position", "Normals", "SSAO" });
auto ssaoDataBuffer = ssaoStorage->GetBuffer(); auto ssaoDataBuffer = ssaoStorage->GetBuffer();
ssaoPass->ModifyWriteDescBufferComputeResource(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_NODE_COMPUTE_RESOURCE, SHSSAO::DESC_SET_BUFFER_BINDING, { &ssaoDataBuffer, 1 }, 0, ssaoStorage->GetBuffer()->GetSizeStored()); ssaoPass->ModifyWriteDescBufferComputeResource(SHSSAO::DESC_SET_BUFFER_BINDING, { &ssaoDataBuffer, 1 }, 0, ssaoStorage->GetBuffer()->GetSizeStored());
auto viewSamplerLayout = ssaoStorage->GetViewSamplerLayout(); auto viewSamplerLayout = ssaoStorage->GetViewSamplerLayout();
ssaoPass->ModifyWriteDescImageComputeResource(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_NODE_COMPUTE_RESOURCE, SHSSAO::DESC_SET_IMAGE_BINDING, { &viewSamplerLayout, 1 }); ssaoPass->ModifyWriteDescImageComputeResource(SHSSAO::DESC_SET_IMAGE_BINDING, { &viewSamplerLayout, 1 });
ssaoPass->SetRenderer (worldRenderer); ssaoPass->SetRenderer (worldRenderer);
// Add another pass to blur SSAO // Add another pass to blur SSAO
@ -392,7 +408,7 @@ namespace SHADE
void SHGraphicsSystem::InitMiddleEnd(void) noexcept void SHGraphicsSystem::InitMiddleEnd(void) noexcept
{ {
SHPredefinedData::Init(device); SHGraphicsPredefinedData::Init(device);
InitRenderGraph(); InitRenderGraph();
@ -435,7 +451,6 @@ namespace SHADE
auto uiNode = renderGraph->GetNode("Screen Space Pass"); auto uiNode = renderGraph->GetNode("Screen Space Pass");
textRenderingSubSystem->Init(device, uiNode->GetRenderpass(), uiNode->GetSubpass("UI"), descPool, textVS, textFS); textRenderingSubSystem->Init(device, uiNode->GetRenderpass(), uiNode->GetSubpass("UI"), descPool, textVS, textFS);
SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup());
SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem); SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem);
} }
@ -844,7 +859,7 @@ namespace SHADE
} }
// Create the renderer // Create the renderer
auto renderer = resourceManager.Create<SHRenderer>(device, swapchain->GetNumImages(), renderContextCmdPools, descPool); auto renderer = resourceManager.Create<SHRenderer>(device, swapchain->GetNumImages(), descPool, projectionType);
// Store // Store
renderers.emplace_back(renderer); renderers.emplace_back(renderer);
@ -989,6 +1004,8 @@ namespace SHADE
); );
device->WaitIdle(); device->WaitIdle();
graphicsTexCmdBuffer.Free(); graphicsTexCmdBuffer = {}; graphicsTexCmdBuffer.Free(); graphicsTexCmdBuffer = {};
SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup());
} }
Handle<SHTexture> SHGraphicsSystem::GetTextureHandle(SHTexture::Index textureId) const Handle<SHTexture> SHGraphicsSystem::GetTextureHandle(SHTexture::Index textureId) const
@ -1006,7 +1023,7 @@ namespace SHADE
void SHGraphicsSystem::BuildFonts(void) noexcept void SHGraphicsSystem::BuildFonts(void) noexcept
{ {
fontLibrary.BuildFonts(device, graphicsQueue, graphicsCmdPool, descPool, SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT)[0], resourceManager); fontLibrary.BuildFonts(device, graphicsQueue, graphicsCmdPool, descPool, SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::FONT)[0], resourceManager);
} }
#pragma endregion ADD_REMOVE #pragma endregion ADD_REMOVE
@ -1245,7 +1262,7 @@ namespace SHADE
device, SHPipelineLayoutParams device, SHPipelineLayoutParams
{ {
.shaderModules = { (instanced ? debugMeshVertShader : debugVertShader) , debugFragShader }, .shaderModules = { (instanced ? debugMeshVertShader : debugVertShader) , debugFragShader },
.predefinedDescSetLayouts = SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA) .predefinedDescSetLayouts = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING).descSetLayouts
} }
); );
auto pipeline = resourceManager.Create<SHVkPipeline>(device, pipelineLayout, nullptr, renderPass, subpass); auto pipeline = resourceManager.Create<SHVkPipeline>(device, pipelineLayout, nullptr, renderPass, subpass);

View File

@ -9,6 +9,8 @@
#include "ECS_Base/Managers/SHSystemManager.h" #include "ECS_Base/Managers/SHSystemManager.h"
#include "SHGraphicsSystem.h" #include "SHGraphicsSystem.h"
#include "SHMaterialInstance.h" #include "SHMaterialInstance.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
namespace SHADE namespace SHADE
{ {
@ -95,9 +97,11 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
Handle<SHShaderBlockInterface> SHMaterial::GetShaderBlockInterface() const noexcept Handle<SHShaderBlockInterface> SHMaterial::GetShaderBlockInterface() const noexcept
{ {
auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
return pipeline->GetPipelineLayout()->GetShaderBlockInterface return pipeline->GetPipelineLayout()->GetShaderBlockInterface
( (
SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, mappings.at (SHGraphicsConstants::DescriptorSetTypes::MATERIALS),
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
vk::ShaderStageFlagBits::eFragment vk::ShaderStageFlagBits::eFragment
); );

View File

@ -16,6 +16,7 @@ of DigiPen Institute of Technology is prohibited.
#include "SHMaterial.h" #include "SHMaterial.h"
#include "Graphics/Pipeline/SHVkPipeline.h" #include "Graphics/Pipeline/SHVkPipeline.h"
#include "Tools/Logger/SHLogger.h" #include "Tools/Logger/SHLogger.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
namespace SHADE namespace SHADE
{ {
@ -80,7 +81,8 @@ namespace SHADE
{ {
return baseMaterial->GetPipeline()->GetPipelineLayout()->GetShaderBlockInterface return baseMaterial->GetPipeline()->GetPipelineLayout()->GetShaderBlockInterface
( (
SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING).at(SHGraphicsConstants::DescriptorSetTypes::MATERIALS),
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
vk::ShaderStageFlagBits::eFragment vk::ShaderStageFlagBits::eFragment
); );

View File

@ -56,7 +56,7 @@ namespace SHADE
}; };
// Create descriptor set layout // Create descriptor set layout
offscreenRenderDescSetLayout = logicalDevice->CreateDescriptorSetLayout(0, { imageBinding }, false); offscreenRenderDescSetLayout = logicalDevice->CreateDescriptorSetLayout({ imageBinding }, false);
// Create descriptor set // Create descriptor set
offscreenRenderDescSet = descriptorPool->Allocate({ offscreenRenderDescSetLayout }, { 1 }); offscreenRenderDescSet = descriptorPool->Allocate({ offscreenRenderDescSetLayout }, { 1 });

View File

@ -21,7 +21,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
#include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Buffers/SHVkBuffer.h"
#include "Camera/SHCameraDirector.h" #include "Camera/SHCameraDirector.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
namespace SHADE namespace SHADE
{ {
@ -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(SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA), { 1 }); cameraDescriptorSet = descriptorPool->Allocate(SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::CAMERA), { 1 });
#ifdef _DEBUG #ifdef _DEBUG
const auto& CAM_DESC_SETS = cameraDescriptorSet->GetVkHandle(); const auto& CAM_DESC_SETS = cameraDescriptorSet->GetVkHandle();

View File

@ -36,7 +36,7 @@ namespace SHADE
class SHVkCommandBuffer; class SHVkCommandBuffer;
class SHCamera; class SHCamera;
class SHVkDescriptorSetGroup; class SHVkDescriptorSetGroup;
class SHPredefinedData; class SHGraphicsPredefinedData;
class SHVkDescriptorPool; class SHVkDescriptorPool;
class SHVkBuffer; class SHVkBuffer;
class SHCameraDirector; class SHCameraDirector;

View File

@ -1,6 +1,6 @@
#include "SHpch.h" #include "SHpch.h"
#include "SHLightingSubSystem.h" #include "SHLightingSubSystem.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Tools/Utilities/SHUtilities.h" #include "Tools/Utilities/SHUtilities.h"
#include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Buffers/SHVkBuffer.h"
@ -320,15 +320,16 @@ namespace SHADE
void SHLightingSubSystem::UpdateDescSet(uint32_t binding) noexcept void SHLightingSubSystem::UpdateDescSet(uint32_t binding) noexcept
{ {
auto buffer = perTypeData[binding].GetDataBuffer(); auto buffer = perTypeData[binding].GetDataBuffer();
static constexpr uint32_t LIGHTING_DATA_SET_INDEX = 0;
// We bind the buffer with the correct desc set binding // We bind the buffer with the correct desc set binding
lightingDataDescSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, lightingDataDescSet->ModifyWriteDescBuffer(LIGHTING_DATA_SET_INDEX,
binding + 1, // we want to +1 here because the first binding is reserved for count binding + 1, // we want to +1 here because the first binding is reserved for count
{ &buffer, 1 }, { &buffer, 1 },
0, 0,
perTypeData[binding].GetDataSize() * perTypeData[binding].GetMaxLights()); perTypeData[binding].GetDataSize() * perTypeData[binding].GetMaxLights());
lightingDataDescSet->UpdateDescriptorSetBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, binding + 1); // +1 here, same reason. see above lightingDataDescSet->UpdateDescriptorSetBuffer(LIGHTING_DATA_SET_INDEX, binding + 1); // +1 here, same reason. see above
} }
/***************************************************************************/ /***************************************************************************/
@ -385,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({ SHPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::LIGHTS) }, variableSizes); lightingDataDescSet = descPool->Allocate({ SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::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)
@ -408,8 +409,9 @@ namespace SHADE
// Create the GPU buffer to hold light count // Create the GPU buffer to hold light count
lightCountsBuffer = logicalDevice->CreateBuffer(lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Light Count Data"); lightCountsBuffer = logicalDevice->CreateBuffer(lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Light Count Data");
lightingDataDescSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT, {&lightCountsBuffer, 1}, 0, sizeof (uint32_t) * NUM_LIGHT_TYPES); static constexpr uint32_t LIGHTING_DATA_SET_INDEX = 0;
lightingDataDescSet->UpdateDescriptorSetBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT); lightingDataDescSet->ModifyWriteDescBuffer(LIGHTING_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT, { &lightCountsBuffer, 1 }, 0, sizeof(uint32_t) * NUM_LIGHT_TYPES);
lightingDataDescSet->UpdateDescriptorSetBuffer(LIGHTING_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT);
for (uint32_t i = 0; i < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++i) for (uint32_t i = 0; i < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++i)
{ {

View File

@ -1,7 +1,7 @@
#include "SHpch.h" #include "SHpch.h"
#include "SHPipelineLibrary.h" #include "SHPipelineLibrary.h"
#include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Graphics/RenderGraph/SHSubpass.h" #include "Graphics/RenderGraph/SHSubpass.h"
#include "Graphics/SHVkUtil.h" #include "Graphics/SHVkUtil.h"
@ -13,7 +13,7 @@ namespace SHADE
SHPipelineLayoutParams params SHPipelineLayoutParams params
{ {
.shaderModules = {vsFsPair.first, vsFsPair.second}, .shaderModules = {vsFsPair.first, vsFsPair.second},
.globalDescSetLayouts = SHPredefinedData::GetBatchingSystemData().descSetLayouts .predefinedDescSetLayouts = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING).descSetLayouts
}; };
// Create the pipeline layout // Create the pipeline layout
@ -21,7 +21,7 @@ namespace SHADE
// Create the pipeline and configure the default vertex input state // Create the pipeline and configure the default vertex input state
auto newPipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderpass, subpass); auto newPipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderpass, subpass);
newPipeline->GetPipelineState().SetVertexInputState(SHPredefinedData::GetDefaultViState()); newPipeline->GetPipelineState().SetVertexInputState(SHGraphicsPredefinedData::GetDefaultViState());
SHColorBlendState colorBlendState{}; SHColorBlendState colorBlendState{};
colorBlendState.logic_op_enable = VK_FALSE; colorBlendState.logic_op_enable = VK_FALSE;

View File

@ -10,7 +10,7 @@ namespace SHADE
class SHVkDescriptorSetLayouts; class SHVkDescriptorSetLayouts;
class SHVkPipeline; class SHVkPipeline;
class SHSubpass; class SHSubpass;
class SHPredefinedData; class SHGraphicsPredefinedData;
// Pipeline library is a PURELY MIDDLE END SYSTEM. It is responsible for only creating pipelines from shaders and caching // Pipeline library is a PURELY MIDDLE END SYSTEM. It is responsible for only creating pipelines from shaders and caching
// them so that they don't need to be recreated again. // them so that they don't need to be recreated again.

View File

@ -1,7 +1,7 @@
#include "SHpch.h" #include "SHpch.h"
#include "SHFont.h" #include "SHFont.h"
#include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
#include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/Images/SHVkSampler.h" #include "Graphics/Images/SHVkSampler.h"
@ -121,14 +121,15 @@ namespace SHADE
descSet = descPool->Allocate({ layout }, { 1 }); descSet = descPool->Allocate({ layout }, { 1 });
auto viewLayoutSampler = std::make_tuple(bitmapDataImageView, sampler, vk::ImageLayout::eShaderReadOnlyOptimal); auto viewLayoutSampler = std::make_tuple(bitmapDataImageView, sampler, vk::ImageLayout::eShaderReadOnlyOptimal);
descSet->ModifyWriteDescImage(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA, {&viewLayoutSampler, 1}); static constexpr uint32_t FONT_DATA_SET_INDEX = 0;
descSet->ModifyWriteDescImage(FONT_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA, {&viewLayoutSampler, 1});
descSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, descSet->ModifyWriteDescBuffer(FONT_DATA_SET_INDEX,
SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA, { &matrixDataBuffer, 1 }, 0, fontAsset.glyphTransformations.size() * sizeof(SHMatrix)); SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA, { &matrixDataBuffer, 1 }, 0, fontAsset.glyphTransformations.size() * sizeof(SHMatrix));
// Bind image and buffer to desc set. // Bind image and buffer to desc set.
descSet->UpdateDescriptorSetImages(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA); descSet->UpdateDescriptorSetImages(FONT_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA);
descSet->UpdateDescriptorSetBuffer(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA); descSet->UpdateDescriptorSetBuffer(FONT_DATA_SET_INDEX, SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA);
} }

View File

@ -3,6 +3,7 @@
#include "Resource/SHHandle.h" #include "Resource/SHHandle.h"
#include "msdf-atlas-gen/msdf-atlas-gen.h" #include "msdf-atlas-gen/msdf-atlas-gen.h"
#include "Assets/Asset Types/SHFontAsset.h" #include "Assets/Asset Types/SHFontAsset.h"
#include "Graphics/Pipeline/SHPipelineType.h"
namespace SHADE namespace SHADE
{ {

View File

@ -6,7 +6,7 @@
#include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/MiddleEnd/TextRendering/SHFont.h" #include "Graphics/MiddleEnd/TextRendering/SHFont.h"
#include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Graphics/Pipeline/SHVkPipeline.h" #include "Graphics/Pipeline/SHVkPipeline.h"
#include "Graphics/SHVkUtil.h" #include "Graphics/SHVkUtil.h"
#include "Graphics/RenderGraph/SHSubpass.h" #include "Graphics/RenderGraph/SHSubpass.h"
@ -103,7 +103,7 @@ namespace SHADE
SHPipelineLayoutParams plParams SHPipelineLayoutParams plParams
{ {
.shaderModules = {textVS, textFS}, .shaderModules = {textVS, textFS},
.predefinedDescSetLayouts = SHPredefinedData::GetTextSystemData().descSetLayouts .predefinedDescSetLayouts = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::TEXT_RENDERING).descSetLayouts
}; };
pipelineLayout = logicalDevice->CreatePipelineLayout(plParams); pipelineLayout = logicalDevice->CreatePipelineLayout(plParams);
@ -177,10 +177,10 @@ namespace SHADE
void SHTextRenderingSubSystem::Render(Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex) noexcept void SHTextRenderingSubSystem::Render(Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex) noexcept
{ {
auto& textRendererComps = SHComponentManager::GetDense<SHTextRenderableComponent>(); auto& textRendererComps = SHComponentManager::GetDense<SHTextRenderableComponent>();
auto const& mappings = SHPredefinedData::GetTextSystemData().descMappings; auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::TEXT_RENDERING);
uint32_t fontSetIndex = mappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::FONT); uint32_t fontSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::FONT);
uint32_t staticGlobalSetIndex = mappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA); uint32_t staticGlobalSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA);
uint32_t cameraSetIndex = mappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::CAMERA); uint32_t cameraSetIndex = mappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA);
for (auto& comp : textRendererComps) for (auto& comp : textRendererComps)
{ {

View File

@ -20,6 +20,7 @@ namespace SHADE
class SHVkRenderpass; class SHVkRenderpass;
class SHSubpass; class SHSubpass;
class SHVkShaderModule; class SHVkShaderModule;
class SHRenderer;
class SHTextRenderingSubSystem class SHTextRenderingSubSystem
{ {

View File

@ -24,7 +24,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
#include "Graphics/Images/SHVkImage.h" #include "Graphics/Images/SHVkImage.h"
#include "Graphics/Images/SHVkImageView.h" #include "Graphics/Images/SHVkImageView.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Assets/Asset Types/SHTextureAsset.h" #include "Assets/Asset Types/SHTextureAsset.h"
namespace SHADE namespace SHADE
@ -168,22 +168,23 @@ namespace SHADE
} }
texDescriptors = descPool->Allocate texDescriptors = descPool->Allocate
( (
{ SHPredefinedData::GetPredefinedDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS] }, { SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsConstants::PredefinedDescSetLayoutTypes::STATIC_DATA) },
{ static_cast<uint32_t>(texOrder.size()) } { static_cast<uint32_t>(texOrder.size()) }
); );
#ifdef _DEBUG #ifdef _DEBUG
for (auto set : texDescriptors->GetVkHandle()) for (auto set : texDescriptors->GetVkHandle())
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals"); SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals");
#endif #endif
static constexpr uint32_t TEX_DESCRIPTOR_SET_INDEX = 0;
texDescriptors->ModifyWriteDescImage texDescriptors->ModifyWriteDescImage
( (
SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS, TEX_DESCRIPTOR_SET_INDEX,
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA, SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA,
combinedImageSamplers combinedImageSamplers
); );
texDescriptors->UpdateDescriptorSetImages texDescriptors->UpdateDescriptorSetImages
( (
SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS, TEX_DESCRIPTOR_SET_INDEX,
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA
); );
} }

View File

@ -220,7 +220,7 @@ namespace SHADE
// 1 descriptor set layout for every descriptor set detected. // 1 descriptor set layout for every descriptor set detected.
for (auto const& set : setsWithBindings) for (auto const& set : setsWithBindings)
{ {
auto newDescriptorSetLayout = logicalDeviceHdl->CreateDescriptorSetLayout(set.first, set.second); auto newDescriptorSetLayout = logicalDeviceHdl->CreateDescriptorSetLayout(set.second);
descriptorSetLayoutsAllocate.push_back(newDescriptorSetLayout); descriptorSetLayoutsAllocate.push_back(newDescriptorSetLayout);
} }
@ -317,7 +317,7 @@ namespace SHADE
, logicalDeviceHdl {inLogicalDeviceHdl} , logicalDeviceHdl {inLogicalDeviceHdl}
, pushConstantInterface{} , pushConstantInterface{}
, vkPcRanges{} , vkPcRanges{}
, descriptorSetLayoutsGlobal{pipelineLayoutParams.globalDescSetLayouts } // do a copy, some other pipeline layout might need this , descriptorSetLayoutsGlobal{pipelineLayoutParams.predefinedDescSetLayouts } // do a copy, some other pipeline layout might need this
, descriptorSetLayoutsAllocate{} , descriptorSetLayoutsAllocate{}
, vkDescriptorSetLayoutsAllocate{} , vkDescriptorSetLayoutsAllocate{}
, descriptorSetLayoutsPipeline{} , descriptorSetLayoutsPipeline{}

View File

@ -12,7 +12,7 @@
#include "SHRenderGraphStorage.h" #include "SHRenderGraphStorage.h"
#include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h" #include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h"
#include "Tools/Utilities/SHUtilities.h" #include "Tools/Utilities/SHUtilities.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Graphics/RenderGraph/SHRenderToSwapchainImageSystem.h" #include "Graphics/RenderGraph/SHRenderToSwapchainImageSystem.h"
#include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h" #include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h"
@ -578,7 +578,8 @@ namespace SHADE
uint32_t h = static_cast<uint32_t>(resource->GetHeight()); uint32_t h = static_cast<uint32_t>(resource->GetHeight());
cmdBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h); cmdBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h);
newSubpass->BindDescriptorInputDescriptorSets (cmdBuffer, frameIndex); static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0;
newSubpass->BindInputDescriptorSets (cmdBuffer, INPUT_IMAGE_SET_INDEX, frameIndex);
// draw a quad. // draw a quad.
cmdBuffer->DrawArrays(4, 1, 0, 0); cmdBuffer->DrawArrays(4, 1, 0, 0);
@ -634,16 +635,18 @@ namespace SHADE
auto cmdBuffer = commandBuffers[frameIndex]; auto cmdBuffer = commandBuffers[frameIndex];
cmdBuffer->BeginLabeledSegment(name); cmdBuffer->BeginLabeledSegment(name);
// Force bind pipeline layout auto batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING);
cmdBuffer->ForceSetPipelineLayout(SHPredefinedData::GetBatchingSystemData().dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS);
cmdBuffer->ForceSetPipelineLayout(SHPredefinedData::GetBatchingSystemData().dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE);
auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; // Force bind pipeline layout
cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS);
cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE);
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
for (auto& node : nodes) for (auto& node : nodes)
{ {
// bind static global data // bind static global data
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA)); SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA));
node->Execute(cmdBuffer, descPool, frameIndex); node->Execute(cmdBuffer, descPool, frameIndex);
} }

View File

@ -29,7 +29,7 @@ namespace SHADE
class SHVkCommandPool; class SHVkCommandPool;
class SHVkCommandBuffer; class SHVkCommandBuffer;
class SHRenderGraphNode; class SHRenderGraphNode;
class SHPredefinedData; class SHGraphicsPredefinedData;
class SHVkDescriptorPool; class SHVkDescriptorPool;
class SHRenderGraphStorage; class SHRenderGraphStorage;
class SHRenderToSwapchainImageSystem; class SHRenderToSwapchainImageSystem;

View File

@ -10,7 +10,7 @@
#include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h" #include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h"
#include "Graphics/SHVkUtil.h" #include "Graphics/SHVkUtil.h"
#include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h" #include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
namespace SHADE namespace SHADE
{ {
@ -351,16 +351,18 @@ namespace SHADE
commandBuffer->EndRenderpass(); commandBuffer->EndRenderpass();
auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE);
// We bind these 2 descriptor sets here because they apply to all node computes // We bind these 2 descriptor sets here because they apply to all node computes
if (!nodeComputes.empty()) if (!nodeComputes.empty())
{ {
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.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA)); SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::STATIC_DATA));
// bind lighting data // bind lighting data
SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::LIGHTS), frameIndex); SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::LIGHTS), frameIndex);
} }
// Execute all subpass computes // Execute all subpass computes

View File

@ -19,7 +19,7 @@ namespace SHADE
class SHVkLogicalDevice; class SHVkLogicalDevice;
class SHVkRenderpass; class SHVkRenderpass;
class SHVkDescriptorPool; class SHVkDescriptorPool;
class SHPredefinedData; class SHGraphicsPredefinedData;
class SHRenderGraphStorage; class SHRenderGraphStorage;
class SHRenderGraphNodeCompute; class SHRenderGraphNodeCompute;
class SHRenderer; class SHRenderer;

View File

@ -6,7 +6,7 @@
#include "Graphics/Descriptors/SHVkDescriptorSetLayout.h" #include "Graphics/Descriptors/SHVkDescriptorSetLayout.h"
#include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Pipeline/SHVkPipelineLayout.h" #include "Graphics/Pipeline/SHVkPipelineLayout.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "SHRenderGraphStorage.h" #include "SHRenderGraphStorage.h"
#include "SHRenderGraphResource.h" #include "SHRenderGraphResource.h"
#include "Graphics/Commands/SHVkCommandBuffer.h" #include "Graphics/Commands/SHVkCommandBuffer.h"
@ -29,7 +29,7 @@ namespace SHADE
SHPipelineLayoutParams pipelineLayoutParams SHPipelineLayoutParams pipelineLayoutParams
{ {
.shaderModules = {computeShaderModule}, .shaderModules = {computeShaderModule},
.predefinedDescSetLayouts = SHPredefinedData::GetRenderGraphNodeComputeData().descSetLayouts, .predefinedDescSetLayouts = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).descSetLayouts,
.dynamicBufferBindings = std::move(dynamicBufferBindings), .dynamicBufferBindings = std::move(dynamicBufferBindings),
}; };
@ -47,13 +47,13 @@ namespace SHADE
// save the resources // save the resources
resources = std::move (subpassComputeResources); resources = std::move (subpassComputeResources);
auto const& descMappings = SHPredefinedData::GetRenderGraphNodeComputeData().descMappings; auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE);
auto const& layouts = computePipeline->GetPipelineLayout()->GetDescriptorSetLayoutsPipeline(); auto const& layouts = computePipeline->GetPipelineLayout()->GetDescriptorSetLayoutsPipeline();
//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.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE)]; auto const& graphResourceLayout = layouts[descMappings.at(SHGraphicsConstants::DescriptorSetTypes::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.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE) + 1) if (layouts.size() == descMappings.at(SHGraphicsConstants::DescriptorSetTypes::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.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE)]; auto computeResourceLayout = layouts[descMappings.at(SHGraphicsConstants::DescriptorSetTypes::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())
@ -94,21 +94,21 @@ namespace SHADE
// bind the compute pipeline // bind the compute pipeline
cmdBuffer->BindPipeline(computePipeline); cmdBuffer->BindPipeline(computePipeline);
auto const& descMappings = SHPredefinedData::GetRenderGraphNodeComputeData().descMappings; auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE);
// bind render graph resource // bind render graph resource
cmdBuffer->BindDescriptorSet(graphResourceDescSets[frameIndex], SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE), {}); cmdBuffer->BindDescriptorSet(graphResourceDescSets[frameIndex], SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE), {});
// bind compute resource // bind compute resource
if (computeResource) if (computeResource)
{ {
cmdBuffer->BindDescriptorSet(computeResource->descSet, SH_PIPELINE_TYPE::COMPUTE, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_NODE_COMPUTE_RESOURCE), computeResource->dynamicOffsets[frameIndex]); cmdBuffer->BindDescriptorSet(computeResource->descSet, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::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.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex); renderer->BindDescriptorSet (cmdBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex);
// dispatch compute // dispatch compute
cmdBuffer->ComputeDispatch(groupSizeX, groupSizeY, 1); cmdBuffer->ComputeDispatch(groupSizeX, groupSizeY, 1);
@ -120,11 +120,14 @@ namespace SHADE
void SHRenderGraphNodeCompute::HandleResize(void) noexcept void SHRenderGraphNodeCompute::HandleResize(void) noexcept
{ {
auto const& descMappings = SHPredefinedData::GetRenderGraphNodeComputeData().descMappings; // 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 renderGraphResourceSetIndex = descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::RENDER_GRAPH_RESOURCE); uint32_t RENDER_GRAPH_RESOURCE_SET_INDEX = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).at (SHGraphicsConstants::DescriptorSetTypes::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.
uint32_t RENDER_GRAPH_RESOURCE_UPDATE_SET_INDEX = 0;
// Get the layout for the render graph resource. We can index it this way because the container returned is a container of layouts that includes the global ones // Get the layout for the render graph resource. We can index it this way because the container returned is a container of layouts that includes the global ones
auto pipelineDescSetLayouts = computePipeline->GetPipelineLayout()->GetDescriptorSetLayoutsPipeline()[renderGraphResourceSetIndex]; auto pipelineDescSetLayouts = computePipeline->GetPipelineLayout()->GetDescriptorSetLayoutsPipeline()[RENDER_GRAPH_RESOURCE_SET_INDEX];
// everything below here needs resizing // everything below here needs resizing
for (uint32_t frameIndex = 0; frameIndex < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++frameIndex) for (uint32_t frameIndex = 0; frameIndex < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++frameIndex)
@ -137,8 +140,8 @@ namespace SHADE
uint32_t imageIndex = (resources[i]->resourceTypeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) ? frameIndex : 0; uint32_t imageIndex = (resources[i]->resourceTypeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) ? frameIndex : 0;
SHVkDescriptorSetGroup::viewSamplerLayout vsl = std::make_tuple(resources[i]->GetImageView(imageIndex), Handle<SHVkSampler>{}, vk::ImageLayout::eGeneral); SHVkDescriptorSetGroup::viewSamplerLayout vsl = std::make_tuple(resources[i]->GetImageView(imageIndex), Handle<SHVkSampler>{}, vk::ImageLayout::eGeneral);
graphResourceDescSets[frameIndex]->ModifyWriteDescImage(renderGraphResourceSetIndex, binding.BindPoint, { &vsl, 1 }); graphResourceDescSets[frameIndex]->ModifyWriteDescImage(RENDER_GRAPH_RESOURCE_UPDATE_SET_INDEX, binding.BindPoint, { &vsl, 1 });
graphResourceDescSets[frameIndex]->UpdateDescriptorSetImages(renderGraphResourceSetIndex, binding.BindPoint); graphResourceDescSets[frameIndex]->UpdateDescriptorSetImages(RENDER_GRAPH_RESOURCE_UPDATE_SET_INDEX, binding.BindPoint);
++i; ++i;
} }
} }
@ -200,16 +203,19 @@ namespace SHADE
renderer = inRenderer; renderer = inRenderer;
} }
void SHRenderGraphNodeCompute::ModifyWriteDescBufferComputeResource(uint32_t set, uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers, uint32_t offset, uint32_t range) noexcept void SHRenderGraphNodeCompute::ModifyWriteDescBufferComputeResource(uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers, uint32_t offset, uint32_t range) noexcept
{ {
computeResource->descSet->ModifyWriteDescBuffer(set, binding, buffers, offset, range); static constexpr uint32_t COMPUTE_RESOURCE_SET_INDEX = 0;
computeResource->descSet->UpdateDescriptorSetBuffer(set, binding);
computeResource->descSet->ModifyWriteDescBuffer(COMPUTE_RESOURCE_SET_INDEX, binding, buffers, offset, range);
computeResource->descSet->UpdateDescriptorSetBuffer(COMPUTE_RESOURCE_SET_INDEX, binding);
} }
void SHRenderGraphNodeCompute::ModifyWriteDescImageComputeResource(uint32_t set, uint32_t binding, std::span<SHVkDescriptorSetGroup::viewSamplerLayout> const& viewSamplerLayouts) noexcept void SHRenderGraphNodeCompute::ModifyWriteDescImageComputeResource(uint32_t binding, std::span<SHVkDescriptorSetGroup::viewSamplerLayout> const& viewSamplerLayouts) noexcept
{ {
computeResource->descSet->ModifyWriteDescImage(set, binding, viewSamplerLayouts); static constexpr uint32_t COMPUTE_RESOURCE_SET_INDEX = 0;
computeResource->descSet->UpdateDescriptorSetImages(set, binding); computeResource->descSet->ModifyWriteDescImage(COMPUTE_RESOURCE_SET_INDEX, binding, viewSamplerLayouts);
computeResource->descSet->UpdateDescriptorSetImages(COMPUTE_RESOURCE_SET_INDEX, binding);
} }

View File

@ -82,8 +82,8 @@ namespace SHADE
void SetDynamicOffsets (std::span<uint32_t> perFrameSizes) noexcept; void SetDynamicOffsets (std::span<uint32_t> perFrameSizes) noexcept;
void SetRenderer (Handle<SHRenderer> inRenderer) noexcept; void SetRenderer (Handle<SHRenderer> inRenderer) noexcept;
void ModifyWriteDescBufferComputeResource (uint32_t set, uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers, uint32_t offset, uint32_t range) noexcept; void ModifyWriteDescBufferComputeResource (uint32_t binding, std::span<Handle<SHVkBuffer>> const& buffers, uint32_t offset, uint32_t range) noexcept;
void ModifyWriteDescImageComputeResource(uint32_t set, uint32_t binding, std::span<SHVkDescriptorSetGroup::viewSamplerLayout> const& viewSamplerLayouts) noexcept; void ModifyWriteDescImageComputeResource(uint32_t binding, std::span<SHVkDescriptorSetGroup::viewSamplerLayout> const& viewSamplerLayouts) noexcept;
friend class SHRenderGraph; friend class SHRenderGraph;

View File

@ -7,7 +7,7 @@ namespace SHADE
{ {
class SHVkLogicalDevice; class SHVkLogicalDevice;
class SHVkSwapchain; class SHVkSwapchain;
class SHPredefinedData; class SHGraphicsPredefinedData;
class SHVkDescriptorPool; class SHVkDescriptorPool;
class SHRenderGraphResource; class SHRenderGraphResource;

View File

@ -1,7 +1,7 @@
#include "SHpch.h" #include "SHpch.h"
#include "SHRenderToSwapchainImageSystem.h" #include "SHRenderToSwapchainImageSystem.h"
#include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
#include "Graphics/RenderGraph/SHRenderGraphNode.h" #include "Graphics/RenderGraph/SHRenderGraphNode.h"
#include "Graphics/RenderGraph/SHSubpass.h" #include "Graphics/RenderGraph/SHSubpass.h"
#include "Graphics/SHVkUtil.h" #include "Graphics/SHVkUtil.h"
@ -24,7 +24,7 @@ namespace SHADE
auto pipelineLayout = logicalDevice->CreatePipelineLayout(SHPipelineLayoutParams auto pipelineLayout = logicalDevice->CreatePipelineLayout(SHPipelineLayoutParams
{ {
.shaderModules = {shaderModules.first, shaderModules.second}, .shaderModules = {shaderModules.first, shaderModules.second},
.predefinedDescSetLayouts = SHPredefinedData::GetBatchingSystemData().descSetLayouts .predefinedDescSetLayouts = {}
}); });
pipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderGraphNode->GetRenderpass(), subpass); pipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderGraphNode->GetRenderpass(), subpass);

View File

@ -13,7 +13,7 @@
#include "SHRenderGraphResource.h" #include "SHRenderGraphResource.h"
#include "Graphics/MiddleEnd/Interface/SHViewport.h" #include "Graphics/MiddleEnd/Interface/SHViewport.h"
#include "Graphics/MiddleEnd/Interface/SHRenderer.h" #include "Graphics/MiddleEnd/Interface/SHRenderer.h"
#include "Graphics/MiddleEnd/GlobalData/SHPredefinedData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
namespace SHADE namespace SHADE
{ {
@ -224,10 +224,10 @@ namespace SHADE
commandBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h); commandBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h);
} }
auto const& descMappings = SHPredefinedData::GetBatchingSystemData().descMappings; auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
if (renderer) if (renderer)
renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.GetMappings().at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex); renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHGraphicsConstants::DescriptorSetTypes::CAMERA), frameIndex);
// Draw all the batches // Draw all the batches
superBatch->Draw(commandBuffer, frameIndex); superBatch->Draw(commandBuffer, frameIndex);
@ -245,11 +245,11 @@ namespace SHADE
UpdateWriteDescriptors(); UpdateWriteDescriptors();
} }
void SHSubpass::BindDescriptorInputDescriptorSets(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) const noexcept void SHSubpass::BindInputDescriptorSets(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t setIndex, uint32_t frameIndex) const noexcept
{ {
if (!inputImageDescriptorSets.empty()) if (!inputImageDescriptorSets.empty())
{ {
cmdBuffer->BindDescriptorSet(inputImageDescriptorSets[frameIndex], SH_PIPELINE_TYPE::GRAPHICS, SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_RESOURCE, { }); cmdBuffer->BindDescriptorSet(inputImageDescriptorSets[frameIndex], SH_PIPELINE_TYPE::GRAPHICS, setIndex, { });
} }
} }
@ -356,8 +356,13 @@ namespace SHADE
// Update descriptor sets // Update descriptor sets
auto args = std::make_tuple(resource->GetImageView(viewIndex), inputSamplers[i], descriptorLayout); auto args = std::make_tuple(resource->GetImageView(viewIndex), inputSamplers[i], descriptorLayout);
group->ModifyWriteDescImage(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_RESOURCE, binding.BindPoint, std::span{&args, 1});
group->UpdateDescriptorSetImages(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_RESOURCE, binding.BindPoint);
// 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_SET_INDEX = 0;
group->ModifyWriteDescImage(RENDER_GRAPH_RESOURCE_SET_INDEX, binding.BindPoint, std::span{&args, 1});
group->UpdateDescriptorSetImages(RENDER_GRAPH_RESOURCE_SET_INDEX, binding.BindPoint);
} }
++i; ++i;

View File

@ -121,7 +121,7 @@ namespace SHADE
// Runtime functions // Runtime functions
void Execute(Handle<SHVkCommandBuffer> commandBuffer, Handle<SHVkDescriptorPool> descPool, uint32_t frameIndex) noexcept; void Execute(Handle<SHVkCommandBuffer> commandBuffer, Handle<SHVkDescriptorPool> descPool, uint32_t frameIndex) noexcept;
void HandleResize (void) noexcept; void HandleResize (void) noexcept;
void BindDescriptorInputDescriptorSets (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) const noexcept; void BindInputDescriptorSets (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t setIndex, uint32_t frameIndex) const noexcept;
void Init(SHResourceHub& resourceManager) noexcept; void Init(SHResourceHub& resourceManager) noexcept;

View File

@ -10,6 +10,7 @@
#include "ECS_Base/Managers/SHComponentManager.h" #include "ECS_Base/Managers/SHComponentManager.h"
#include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h" #include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h"
#include "Tools/Logger/SHLog.h" #include "Tools/Logger/SHLog.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.h"
namespace SHADE namespace SHADE
@ -264,7 +265,8 @@ namespace SHADE
if(spec.properties.IsDefined()) if(spec.properties.IsDefined())
{ {
auto fragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(spec.fragShader); auto fragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(spec.fragShader);
auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface(SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA); 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);
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)

View File

@ -0,0 +1,67 @@
#pragma once
#include <iostream>
namespace SHADE
{
template<typename BitType>
class SHEnumWrapper
{
public:
using UnderlyingType = typename std::underlying_type_t<BitType>;
private:
UnderlyingType mask;
public:
constexpr SHEnumWrapper(void) noexcept
: mask{ 0 }
{
};
constexpr SHEnumWrapper(BitType bit) noexcept
: mask{ static_cast<UnderlyingType>(bit) }
{
};
constexpr SHEnumWrapper(SHEnumWrapper<BitType> const& rhs) noexcept = default;
constexpr SHEnumWrapper& operator= (SHEnumWrapper<BitType> const& rhs) noexcept = default;
constexpr explicit SHEnumWrapper(UnderlyingType flags) noexcept
: mask{ flags }
{
};
constexpr SHEnumWrapper<BitType> operator| (SHEnumWrapper<BitType> const& rhs) const noexcept
{
return static_cast<SHEnumWrapper<BitType>> (mask | rhs.mask);
};
constexpr SHEnumWrapper<BitType> operator& (SHEnumWrapper<BitType> const& rhs) const noexcept
{
return static_cast<SHEnumWrapper<BitType>> (mask & rhs.mask);
};
constexpr operator UnderlyingType() const noexcept
{
return mask;
};
};
template<typename BitType, typename = std::enable_if_t<std::is_enum_v<BitType>>>
inline BitType operator|(const BitType& left, const BitType& right)
{
return static_cast<BitType>(static_cast<int>(left) | static_cast<int>(right));
}
template<typename BitType, typename = std::enable_if_t<std::is_enum_v<BitType>>>
inline BitType operator&(const BitType& left, const BitType& right)
{
return static_cast<BitType>(static_cast<int>(left) & static_cast<int>(right));
}
}

View File

@ -43,73 +43,6 @@ namespace SHADE
static constexpr OutputType ConvertEnum(InputType enumClassMember) noexcept; static constexpr OutputType ConvertEnum(InputType enumClassMember) noexcept;
}; };
template<typename BitType>
class SHEnumWrapper
{
public:
using UnderlyingType = typename std::underlying_type_t<BitType>;
private:
UnderlyingType mask;
public:
constexpr SHEnumWrapper(void) noexcept
: mask{ 0 }
{
};
constexpr SHEnumWrapper(BitType bit) noexcept
: mask{ static_cast<UnderlyingType>(bit) }
{
};
constexpr SHEnumWrapper(SHEnumWrapper<BitType> const& rhs) noexcept = default;
constexpr SHEnumWrapper& operator= (SHEnumWrapper<BitType> const& rhs) noexcept = default;
constexpr explicit SHEnumWrapper(UnderlyingType flags) noexcept
: mask{ flags }
{
};
constexpr SHEnumWrapper<BitType> operator| (SHEnumWrapper<BitType> const& rhs) const noexcept
{
return static_cast<SHEnumWrapper<BitType>> (mask | rhs.mask);
};
constexpr SHEnumWrapper<BitType> operator& (SHEnumWrapper<BitType> const& rhs) const noexcept
{
return static_cast<SHEnumWrapper<BitType>> (mask & rhs.mask);
};
constexpr operator UnderlyingType() const noexcept
{
return mask;
};
};
template<typename BitType, typename = std::enable_if_t<std::is_enum_v<BitType>>>
inline BitType operator|(const BitType& left, const BitType& right)
{
return static_cast<BitType>(static_cast<int>(left) | static_cast<int>(right));
}
template<typename BitType, typename = std::enable_if_t<std::is_enum_v<BitType>>>
inline BitType operator&(const BitType& left, const BitType& right)
{
return static_cast<BitType>(static_cast<int>(left) & static_cast<int>(right));
}
template <typename EnumType>
std::ostream& operator<<(std::ostream& os, EnumType const& type)
{
os << static_cast<EnumType::UnderlyingType>(type);
return os;
}
} // namespace SHADE } // namespace SHADE
#include "SHUtilities.hpp" #include "SHUtilities.hpp"