Animation WIP merge #321

Merged
XiaoQiDigipen merged 76 commits from SP3-17-animation-system into main 2023-01-30 17:35:57 +08:00
12 changed files with 185 additions and 124 deletions
Showing only changes of commit 7da89def50 - Show all commits

View File

@ -10,7 +10,8 @@ layout(location = 2) in vec3 aNormal;
layout(location = 3) in vec3 aTangent;
layout(location = 4) in mat4 worldTransform;
layout(location = 8) in uvec2 integerData;
layout(location = 9) in uvec4 aBoneIndices;
layout(location = 10) in vec4 aBoneWeights;
layout(location = 0) out struct
{

Binary file not shown.

View File

@ -202,7 +202,7 @@ namespace SHADE
auto interface = fragShader->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface
(
mappings.at(SHPredefinedDescriptorTypes::MATERIALS),
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA
SHGraphicsConstants::DescriptorSetBindings::PER_INST_MATERIAL_DATA
);
if (!interface)
return;

View File

@ -65,13 +65,13 @@ namespace SHADE
, transformDataBuffer { rhs.transformDataBuffer }
, instancedIntegerBuffer { rhs.instancedIntegerBuffer }
, matPropsBuffer { rhs.matPropsBuffer }
, matPropsDescSet { rhs.matPropsDescSet }
, instanceDataDescSet { rhs.instanceDataDescSet }
{
rhs.drawDataBuffer = {};
rhs.transformDataBuffer = {};
rhs.instancedIntegerBuffer = {};
rhs.matPropsBuffer = {};
rhs.matPropsDescSet = {};
rhs.instanceDataDescSet = {};
}
SHBatch& SHBatch::operator=(SHBatch&& rhs)
@ -97,14 +97,14 @@ namespace SHADE
transformDataBuffer = rhs.transformDataBuffer ;
instancedIntegerBuffer = rhs.instancedIntegerBuffer ;
matPropsBuffer = rhs.matPropsBuffer ;
matPropsDescSet = rhs.matPropsDescSet ;
instanceDataDescSet = rhs.instanceDataDescSet ;
// Unset values
rhs.drawDataBuffer = {};
rhs.transformDataBuffer = {};
rhs.instancedIntegerBuffer = {};
rhs.matPropsBuffer = {};
rhs.matPropsDescSet = {};
rhs.instanceDataDescSet = {};
return *this;
}
@ -122,8 +122,8 @@ namespace SHADE
instancedIntegerBuffer[i].Free();
if (matPropsBuffer[i])
matPropsBuffer[i].Free();
if (matPropsDescSet[i])
matPropsDescSet[i].Free();
if (instanceDataDescSet[i])
instanceDataDescSet[i].Free();
}
}
@ -289,7 +289,7 @@ namespace SHADE
}
// Transfer to GPU
rebuildMaterialBuffers(frameIndex, descPool);
rebuildDescriptorSetBuffers(frameIndex, descPool);
// This frame is updated
matBufferDirty[frameIndex] = false;
@ -421,7 +421,7 @@ namespace SHADE
const Handle<SHShaderBlockInterface> SHADER_INFO = pipeline->GetPipelineLayout()->GetShaderBlockInterface
(
descMappings.at(SHPredefinedDescriptorTypes::MATERIALS),
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
SHGraphicsConstants::DescriptorSetBindings::PER_INST_MATERIAL_DATA,
vk::ShaderStageFlagBits::eFragment
);
const bool EMPTY_MAT_PROPS = !SHADER_INFO;
@ -557,10 +557,8 @@ namespace SHADE
BuffUsage::eVertexBuffer,
"Batch Instance Data Buffer"
);
// - Material Properties Buffer
rebuildMaterialBuffers(frameIndex, descPool);
// - Bone Buffers
rebuildBoneBuffers(frameIndex, descPool);
// - Material and bone buffers/descriptor sets
rebuildDescriptorSetBuffers(frameIndex, descPool);
}
// Mark this frame as no longer dirty
@ -588,15 +586,14 @@ namespace SHADE
cmdBuffer->BindPipeline(pipeline);
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::TRANSFORM, transformDataBuffer[frameIndex], 0);
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::INTEGER_DATA, instancedIntegerBuffer[frameIndex], 0);
if (matPropsDescSet[frameIndex])
{
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
if (instanceDataDescSet[frameIndex])
{
cmdBuffer->BindDescriptorSet
(
matPropsDescSet[frameIndex],
instanceDataDescSet[frameIndex],
SH_PIPELINE_TYPE::GRAPHICS,
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
descMappings.at(SHPredefinedDescriptorTypes::MATERIALS),
dynamicOffset
);
@ -604,13 +601,6 @@ namespace SHADE
if (boneMatrixBuffer[frameIndex] && boneFirstIndexBuffer[frameIndex])
{
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::BONE_INDICES, boneFirstIndexBuffer[frameIndex], 0);
cmdBuffer->BindDescriptorSet
(
boneMatricesDescSet[frameIndex],
SH_PIPELINE_TYPE::GRAPHICS,
SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
dynamicOffset
);
}
cmdBuffer->DrawMultiIndirect(drawDataBuffer[frameIndex], static_cast<uint32_t>(drawData.size()));
cmdBuffer->EndLabeledSegment();
@ -651,107 +641,109 @@ namespace SHADE
isCPUBuffersDirty = true;
}
void SHBatch::rebuildMaterialBuffers(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool)
void SHBatch::rebuildDescriptorSetBuffers(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool)
{
if (matPropsData && !drawData.empty())
{
SHVkUtil::EnsureBufferAndCopyHostVisibleData
(
device, matPropsBuffer[frameIndex], matPropsData.get(), static_cast<uint32_t>(matPropsDataSize),
vk::BufferUsageFlagBits::eStorageBuffer,
"Batch Material Data"
);
// Using Declarations and constants
using BuffUsage = vk::BufferUsageFlagBits;
using PreDefDescLayoutType = SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes;
static constexpr uint32_t MATERIAL_DESC_SET_INDEX = 0;
if (!matPropsDescSet[frameIndex])
// Flags
bool descSetUpdateRequired = false;
/* Create Descriptor Sets if Needed */
PreDefDescLayoutType layoutTypes = {};
if (matPropsData)
layoutTypes |= PreDefDescLayoutType::MATERIALS;
if (!boneMatrixData.empty())
layoutTypes |= PreDefDescLayoutType::BONES;
if (matPropsData || !boneMatrixData.empty())
{
// Make sure that we have a descriptor set if we don't already have one
if (!instanceDataDescSet[frameIndex])
{
matPropsDescSet[frameIndex] = descPool->Allocate
instanceDataDescSet[frameIndex] = descPool->Allocate
(
SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::MATERIALS),
SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(layoutTypes),
{ 0 }
);
#ifdef _DEBUG
const auto& DESC_SETS = matPropsDescSet[frameIndex]->GetVkHandle();
const auto& DESC_SETS = instanceDataDescSet[frameIndex]->GetVkHandle();
for (auto descSet : DESC_SETS)
{
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, descSet, "[Descriptor Set] Batch Material Data");
}
#endif
}
}
static constexpr uint32_t MATERIAL_DESC_SET_INDEX = 0;
/* Material Data */
if (matPropsData && !drawData.empty())
{
// Update GPU buffer
SHVkUtil::EnsureBufferAndCopyHostVisibleData
(
device, matPropsBuffer[frameIndex], matPropsData.get(), static_cast<uint32_t>(matPropsDataSize),
BuffUsage::eStorageBuffer,
"Batch Material Data"
);
// Update descriptor set buffer
std::array<Handle<SHVkBuffer>, 1> bufferList = { matPropsBuffer[frameIndex] };
matPropsDescSet[frameIndex]->ModifyWriteDescBuffer
instanceDataDescSet[frameIndex]->ModifyWriteDescBuffer
(
MATERIAL_DESC_SET_INDEX,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
SHGraphicsConstants::DescriptorSetBindings::PER_INST_MATERIAL_DATA,
bufferList,
0, static_cast<uint32_t>(matPropsDataSize)
);
matPropsDescSet[frameIndex]->UpdateDescriptorSetBuffer
descSetUpdateRequired = true;
}
/* Animation Bone Data */
if (!boneMatrixData.empty())
{
// Update GPU Buffers
const uint32_t BONE_IDX_DATA_BYTES = static_cast<uint32_t>(boneMatrixIndices.size() * sizeof(uint32_t));
SHVkUtil::EnsureBufferAndCopyHostVisibleData
(
device, boneFirstIndexBuffer[frameIndex], boneMatrixIndices.data(), BONE_IDX_DATA_BYTES,
BuffUsage::eVertexBuffer,
"Batch Bone Indices Buffer"
);
const uint32_t BONE_MTX_DATA_BYTES = static_cast<uint32_t>(boneMatrixData.size() * sizeof(uint32_t));
SHVkUtil::EnsureBufferAndCopyHostVisibleData
(
device, boneMatrixBuffer[frameIndex], boneMatrixData.data(), BONE_MTX_DATA_BYTES,
BuffUsage::eStorageBuffer,
"Batch Bone Matrix Buffer"
);
// Update descriptor set buffer
std::array<Handle<SHVkBuffer>, 1> bufferList = { boneMatrixBuffer[frameIndex] };
instanceDataDescSet[frameIndex]->ModifyWriteDescBuffer
(
MATERIAL_DESC_SET_INDEX,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA
SHGraphicsConstants::DescriptorSetBindings::PER_INST_BONE_DATA,
bufferList,
static_cast<uint32_t>(matPropsDataSize),
static_cast<uint32_t>(boneMatrixData.size() * sizeof(SHMatrix))
);
descSetUpdateRequired = true;
}
}
void SHBatch::rebuildBoneBuffers(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool)
{
// Using Declarations
using BuffUsage = vk::BufferUsageFlagBits;
// Nothing to rebuild
if (boneMatrixData.empty())
return;
// Update GPU Buffers
const uint32_t BONE_IDX_DATA_BYTES = static_cast<uint32_t>(boneMatrixIndices.size() * sizeof(uint32_t));
SHVkUtil::EnsureBufferAndCopyHostVisibleData
(
device, boneFirstIndexBuffer[frameIndex], boneMatrixIndices.data(), BONE_IDX_DATA_BYTES,
BuffUsage::eVertexBuffer,
"Batch Bone Index Buffer"
);
const uint32_t BONE_MTX_DATA_BYTES = static_cast<uint32_t>(boneMatrixData.size() * sizeof(uint32_t));
SHVkUtil::EnsureBufferAndCopyHostVisibleData
(
device, boneMatrixBuffer[frameIndex], boneMatrixData.data(), BONE_MTX_DATA_BYTES,
BuffUsage::eStorageBuffer,
"Batch Bone Matrix Buffer"
);
// Update descriptor set buffer
if (!boneMatricesDescSet[frameIndex])
{
boneMatricesDescSet[frameIndex] = descPool->Allocate
// Build and prepare the descriptor set if necessary
if (descSetUpdateRequired)
{
// Update the descriptor set buffer
instanceDataDescSet[frameIndex]->UpdateDescriptorSetBuffer
(
{ SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE] },
{ 0 }
MATERIAL_DESC_SET_INDEX,
SHGraphicsConstants::DescriptorSetBindings::PER_INST_MATERIAL_DATA
);
#ifdef _DEBUG
const auto& DESC_SETS = boneMatricesDescSet[frameIndex]->GetVkHandle();
for (auto descSet : DESC_SETS)
{
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, descSet, "[Descriptor Set] Batch Bone Data");
}
#endif
}
std::array<Handle<SHVkBuffer>, 1> bufferList = { boneMatrixBuffer[frameIndex] };
boneMatricesDescSet[frameIndex]->ModifyWriteDescBuffer
(
SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
bufferList,
0, static_cast<uint32_t>(boneMatrixData.size() * sizeof(SHMatrix))
);
boneMatricesDescSet[frameIndex]->UpdateDescriptorSetBuffer
(
SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA
);
// TODO: Need to merge this with the material one
}
}

View File

@ -133,15 +133,14 @@ namespace SHADE
TripleBuffer transformDataBuffer;
TripleBuffer instancedIntegerBuffer;
TripleBuffer matPropsBuffer;
TripleDescSet matPropsDescSet;
TripleBuffer boneMatrixBuffer;
TripleBuffer boneFirstIndexBuffer;
TripleDescSet boneMatricesDescSet;
TripleDescSet instanceDataDescSet;
/*-----------------------------------------------------------------------------*/
/* Helper Functions */
/*-----------------------------------------------------------------------------*/
void setAllDirtyFlags();
void rebuildMaterialBuffers(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool);
void rebuildBoneBuffers(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool);
void rebuildDescriptorSetBuffers(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool);
};
}

View File

@ -20,14 +20,21 @@ namespace SHADE
//SHGraphicsPredefinedData::PerSystem SHGraphicsPredefinedData::renderGraphNodeComputeData;
void SHGraphicsPredefinedData::InitDescMappings(void) noexcept
{
{
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings
({
{SHPredefinedDescriptorTypes::STATIC_DATA, 0},
{SHPredefinedDescriptorTypes::CAMERA, 1},
{SHPredefinedDescriptorTypes::MATERIALS, 2},
});
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING_ANIM)].descMappings.AddMappings
({
{SHPredefinedDescriptorTypes::STATIC_DATA, 0},
{SHPredefinedDescriptorTypes::CAMERA, 1},
{SHPredefinedDescriptorTypes::MATERIALS, 2},
{SHPredefinedDescriptorTypes::BONES, 3},
});
perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descMappings.AddMappings
({
@ -48,9 +55,13 @@ namespace SHADE
void SHGraphicsPredefinedData::InitDummyPipelineLayouts(Handle<SHVkLogicalDevice> logicalDevice) noexcept
{
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy(SHPipelineLayoutParamsDummy{ perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].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 });
for (int i = 0; i < SYSTEM_TYPE_COUNT; ++i)
{
perSystemData[i].dummyPipelineLayout = logicalDevice->CreatePipelineLayoutDummy
(
SHPipelineLayoutParamsDummy { perSystemData[i].descSetLayouts }
);
}
}
/*-----------------------------------------------------------------------------------*/
@ -122,8 +133,8 @@ namespace SHADE
SHVkDescriptorSetLayout::Binding materialDataBinding
{
.Type = vk::DescriptorType::eStorageBufferDynamic,
.Stage = vk::ShaderStageFlagBits::eFragment | vk::ShaderStageFlagBits::eVertex,
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
.Stage = vk::ShaderStageFlagBits::eFragment,
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::PER_INST_MATERIAL_DATA,
.DescriptorCount = 1,
};
Handle<SHVkDescriptorSetLayout> materialDataPerInstanceLayout = logicalDevice->CreateDescriptorSetLayout({ materialDataBinding });
@ -150,12 +161,25 @@ namespace SHADE
Handle<SHVkDescriptorSetLayout> fontDataDescSetLayout = logicalDevice->CreateDescriptorSetLayout({ fontBitmapBinding, fontMatrixBinding });
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, fontDataDescSetLayout->GetVkHandle(), "[Descriptor Set Layout] Font Data");
// Bone matrix data
SHVkDescriptorSetLayout::Binding boneMatrixBinding
{
.Type = vk::DescriptorType::eStorageBuffer,
.Stage = vk::ShaderStageFlagBits::eVertex,
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::BONE_MATRIX_DATA,
.DescriptorCount = 1,
};
Handle<SHVkDescriptorSetLayout> boneMatricesDescSetLayout = logicalDevice->CreateDescriptorSetLayout({ boneMatrixBinding });
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, boneMatricesDescSetLayout->GetVkHandle(), "[Descriptor Set Layout] Bone Matrix Data");
predefinedLayouts.push_back(staticGlobalLayout);
predefinedLayouts.push_back(lightDataDescSetLayout);
predefinedLayouts.push_back(cameraDataGlobalLayout);
predefinedLayouts.push_back(materialDataPerInstanceLayout);
predefinedLayouts.push_back(fontDataDescSetLayout);
predefinedLayouts.push_back({});
predefinedLayouts.push_back(boneMatricesDescSetLayout);
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descSetLayouts = GetPredefinedDescSetLayouts
(
@ -164,6 +188,14 @@ namespace SHADE
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::MATERIALS
);
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING_ANIM)].descSetLayouts = GetPredefinedDescSetLayouts
(
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA |
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::CAMERA |
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::MATERIALS |
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::BONES
);
perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descSetLayouts = GetPredefinedDescSetLayouts
(
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA |
@ -181,12 +213,14 @@ namespace SHADE
void SHGraphicsPredefinedData::InitDefaultVertexInputState(void) noexcept
{
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_3D) }); // Normals at binding 2
defaultVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_3D) }); // Tangents at binding 3
defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::MAT_4D) }); // Transform at binding 4 - 7 (4 slots)
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_3D) }); // Normals at binding 2
defaultVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_3D) }); // Tangents at binding 3
defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::MAT_4D) }); // Transform at binding 4 - 7 (4 slots)
defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::UINT32_2D) }); // Instanced integer data at index 8
defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::UINT32_4D) }); // Instanced bone indices at index 9
defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::FLOAT_4D) }); // Instanced bone weights at index 10
}
void SHGraphicsPredefinedData::Init(Handle<SHVkLogicalDevice> logicalDevice) noexcept
@ -232,12 +266,24 @@ namespace SHADE
return static_cast<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes>(static_cast<uint64_t>(lhs) | static_cast<uint64_t>(rhs));
}
SHADE::SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes& operator|=(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes& lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept
{
lhs = lhs | rhs;
return lhs;
}
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator&(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept
{
return static_cast<SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes>(static_cast<uint64_t>(lhs) & static_cast<uint64_t>(rhs));
}
SHADE::SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes& operator&=(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes& lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept
{
lhs = lhs & rhs;
return lhs;
}
//SHGraphicsPredefinedData::PerSystem const& SHGraphicsPredefinedData::GetBatchingSystemData(void) noexcept
//{
// return batchingSystemData;

View File

@ -23,20 +23,24 @@ namespace SHADE
// 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,
STATIC_DATA = 0b0000001,
LIGHTS = 0b0000010,
CAMERA = 0b0000100,
MATERIALS = 0b0001000,
FONT = 0b0010000,
SHADOW = 0b0100000,
BONES = 0b1000000,
};
enum class SystemType
{
BATCHING = 0,
BATCHING_ANIM,
TEXT_RENDERING,
RENDER_GRAPH_NODE_COMPUTE,
NUM_TYPES
};
static constexpr int SYSTEM_TYPE_COUNT = static_cast<int>(SystemType::NUM_TYPES);
struct PerSystem
{
@ -98,5 +102,7 @@ namespace SHADE
};
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator| (SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept;
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes& operator|=(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes& lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept;
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes operator& (SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept;
SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes& operator&=(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes& lhs, SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes rhs) noexcept;
}

View File

@ -12,6 +12,7 @@ namespace SHADE
LIGHTS,
CAMERA,
MATERIALS,
BONES,
FONT,
RENDER_GRAPH_RESOURCE,
RENDER_GRAPH_NODE_COMPUTE_RESOURCE,

View File

@ -138,7 +138,15 @@ namespace SHADE
DescriptorSet binding for per instance material values.
*/
/***************************************************************************/
static constexpr uint32_t BATCHED_PER_INST_DATA = 0;
static constexpr uint32_t PER_INST_MATERIAL_DATA = 0;
/***************************************************************************/
/*!
\brief
DescriptorSet binding for per instance bone values.
*/
/***************************************************************************/
static constexpr uint32_t PER_INST_BONE_DATA = 1;
/***************************************************************************/
/*!
@ -158,6 +166,14 @@ namespace SHADE
/***************************************************************************/
static constexpr uint32_t FONT_MATRIX_DATA = 1;
/***************************************************************************/
/*!
\brief
Descriptor set binding for bone matrix data.
*/
/***************************************************************************/
static constexpr uint32_t BONE_MATRIX_DATA = 0;
};
struct VertexBufferBindings

View File

@ -102,7 +102,7 @@ namespace SHADE
(
mappings.at (SHPredefinedDescriptorTypes::MATERIALS),
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
SHGraphicsConstants::DescriptorSetBindings::PER_INST_MATERIAL_DATA,
vk::ShaderStageFlagBits::eFragment
);
}

View File

@ -83,7 +83,7 @@ namespace SHADE
(
SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING).at(SHPredefinedDescriptorTypes::MATERIALS),
//SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE,
SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
SHGraphicsConstants::DescriptorSetBindings::PER_INST_MATERIAL_DATA,
vk::ShaderStageFlagBits::eFragment
);
}

View File

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