Merge branch 'FontIntegration' into SP3-1-Rendering

This commit is contained in:
Brandon Mak 2022-11-18 16:36:10 +08:00
commit b5f37195a9
46 changed files with 299 additions and 149 deletions

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: SegoeUI
ID: 176667660
Type: 10

View File

@ -23,16 +23,12 @@ layout(location = 0) in struct
layout(location = 3) flat in struct layout(location = 3) flat in struct
{ {
uint eid; uint eid;
vec3 textColor;
} In2; } In2;
// push constants
layout(std140, push_constant) uniform TestPushConstant
{
vec3 textColor;
} testPushConstant;
layout(set = 6, binding = 0) uniform sampler2D fontBitmap; layout(set = 4, 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;
@ -56,7 +52,7 @@ void main()
fragColor = vec4(0.0f, 1.0f, 1.0f, 1.0f); fragColor = vec4(0.0f, 1.0f, 1.0f, 1.0f);
} }
fragColor = mix(vec4(0.0f), vec4(testPushConstant.textColor, 1.0f), min (opacity, 1.0f)); fragColor = mix(vec4(0.0f), vec4(In2.textColor, 1.0f), min (opacity, 1.0f));
color = fragColor; color = fragColor;

Binary file not shown.

View File

@ -21,6 +21,7 @@ layout(location = 0) out struct
layout(location = 3) out struct layout(location = 3) out struct
{ {
uint eid; uint eid;
vec3 textColor;
} Out2; } Out2;
// Camera data // Camera data
@ -37,11 +38,12 @@ layout(std140, push_constant) uniform TestPushConstant
{ {
mat4 worldTransform; mat4 worldTransform;
uint eid; uint eid;
vec3 textColor;
} testPushConstant; } testPushConstant;
// Descriptor sets // Descriptor sets
layout(std430, set = 6, binding = 1) buffer GlyphTransforms layout(std430, set = 4, binding = 1) buffer GlyphTransforms
{ {
mat4 matrices[]; mat4 matrices[];
} glyphTransforms; } glyphTransforms;
@ -92,6 +94,8 @@ void main()
// Transform the vertices to font space // Transform the vertices to font space
vertexPos = toFontSpace * vertexPos; vertexPos = toFontSpace * vertexPos;
Out2.textColor = testPushConstant.textColor;
// transform the vertex position to font space // transform the vertex position to font space
gl_Position = PVMatrix * localModel * vec4(vertexPos, 1.0f); gl_Position = PVMatrix * localModel * vec4(vertexPos, 1.0f);
} }

Binary file not shown.

View File

@ -78,6 +78,7 @@ namespace Sandbox
SHSystemManager::CreateSystem<SHAudioSystem>(); SHSystemManager::CreateSystem<SHAudioSystem>();
SHSystemManager::CreateSystem<SHCameraSystem>(); SHSystemManager::CreateSystem<SHCameraSystem>();
std::system("FontCompiler.exe ../../Assets/Fonts/SegoeUI.ttf");
SHSystemManager::CreateSystem<SHGraphicsSystem>(); SHSystemManager::CreateSystem<SHGraphicsSystem>();
SHGraphicsSystem* graphicsSystem = static_cast<SHGraphicsSystem*>(SHSystemManager::GetSystem<SHGraphicsSystem>()); SHGraphicsSystem* graphicsSystem = static_cast<SHGraphicsSystem*>(SHSystemManager::GetSystem<SHGraphicsSystem>());
@ -135,7 +136,7 @@ namespace Sandbox
//SHComponentManager::CreateComponentSparseSet<SHCameraComponent>(); //SHComponentManager::CreateComponentSparseSet<SHCameraComponent>();
SHAssetManager::Load(); SHAssetManager::Load();
auto font = SHAssetManager::GetData<SHFontAsset>(176667660);
SHSystemManager::RegisterRoutine<SHAudioSystem, SHAudioSystem::AudioRoutine>(); SHSystemManager::RegisterRoutine<SHAudioSystem, SHAudioSystem::AudioRoutine>();
@ -148,8 +149,6 @@ namespace Sandbox
SHFrameRateController::UpdateFRC(); SHFrameRateController::UpdateFRC();
//std::system("FontCompiler.exe ../../Assets/Fonts/SegoeUI.ttf");
// Link up SHDebugDraw // Link up SHDebugDraw
SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>()); SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());
} }

View File

@ -13,6 +13,7 @@
#include "Physics/Interface/SHRigidBodyComponent.h" #include "Physics/Interface/SHRigidBodyComponent.h"
#include "Physics/Interface/SHColliderComponent.h" #include "Physics/Interface/SHColliderComponent.h"
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h" #include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
#include "Graphics/MiddleEnd/TextRendering/SHTextRendererComponent.h"
#include "Assets/SHAssetManager.h" #include "Assets/SHAssetManager.h"
#include "Camera/SHCameraComponent.h" #include "Camera/SHCameraComponent.h"
@ -41,6 +42,19 @@ namespace Sandbox
void SBMainScene::Init() void SBMainScene::Init()
{ {
sceneName = SHSerialization::DeserializeSceneFromFile(sceneAssetID); sceneName = SHSerialization::DeserializeSceneFromFile(sceneAssetID);
/*-----------------------------------------------------------------------*/
/* TESTING CODE */
/*-----------------------------------------------------------------------*/
//testText = SHEntityManager::CreateEntity<SHTransformComponent, SHTextRendererComponent>(MAX_EID, "Test Text");
//auto gfxSystem =SHSystemManager::GetSystem<SHGraphicsSystem>();
//auto textComp = SHComponentManager::GetComponent<SHTextRendererComponent>(testText);
//textComp->SetFont(gfxSystem->GetFontLibrary().GetFonts()[0]);
/*-----------------------------------------------------------------------*/
/* TESTING CODE */
/*-----------------------------------------------------------------------*/
} }
void SBMainScene::Update(float dt) void SBMainScene::Update(float dt)

View File

@ -12,6 +12,8 @@ namespace Sandbox
EntityID testObj; EntityID testObj;
std::vector<EntityID> stressTestObjects; std::vector<EntityID> stressTestObjects;
EntityID testText;
public: public:
virtual void Load(); virtual void Load();
virtual void Init(); virtual void Init();

View File

@ -48,15 +48,17 @@ namespace SHADE
// read the height // read the height
file.read(reinterpret_cast<char*>(&newFontAsset->bitmapHeight), sizeof(SHFontAsset::bitmapHeight)); file.read(reinterpret_cast<char*>(&newFontAsset->bitmapHeight), sizeof(SHFontAsset::bitmapHeight));
uint32_t bytesRequired = newFontAsset->bitmapWidth * newFontAsset->bitmapHeight * SHFontAsset::BYTES_PER_CHANNEL * SHFontAsset::NUM_CHANNELS; uint32_t bytesRequired = 0;
file.read(reinterpret_cast<char*>(&bytesRequired), sizeof(uint32_t));
// Read the bitmap // Read the bitmap
newFontAsset->bitmapData.resize(bytesRequired); newFontAsset->bitmapData.resize(bytesRequired);
file.read (reinterpret_cast<char*>(newFontAsset->bitmapData.data()), bytesRequired); file.read(reinterpret_cast<char*>(newFontAsset->bitmapData.data()), bytesRequired);
file.close(); file.close();
return nullptr; return newFontAsset;
} }
void SHFontLoader::Write(SHAssetData const* data, AssetPath path) void SHFontLoader::Write(SHAssetData const* data, AssetPath path)

View File

@ -67,8 +67,9 @@ constexpr std::string_view ASSET_ROOT {"../../Assets"};
constexpr std::string_view BUILT_IN_ASSET_ROOT{ "../../Built_In" }; constexpr std::string_view BUILT_IN_ASSET_ROOT{ "../../Built_In" };
#endif #endif
// COMPILER PATHS // COMPILER EXE
constexpr std::string_view MODEL_COMPILER_EXE{ "ModelCompiler.exe" }; constexpr std::string_view MODEL_COMPILER_EXE{ "ModelCompiler.exe" };
constexpr std::string_view FONT_COMPILER_EXE{ "FontCompiler.exe" };
// INTERNAL ASSET PATHS // INTERNAL ASSET PATHS
constexpr std::string_view SCENE_FOLDER{ "/Scenes/" }; constexpr std::string_view SCENE_FOLDER{ "/Scenes/" };

View File

@ -20,6 +20,7 @@
#include "Libraries/Loaders/SHTextureLoader.h" #include "Libraries/Loaders/SHTextureLoader.h"
#include "Libraries/Loaders/SHShaderSourceLoader.h" #include "Libraries/Loaders/SHShaderSourceLoader.h"
#include "Libraries/Loaders/SHTextBasedLoader.h" #include "Libraries/Loaders/SHTextBasedLoader.h"
#include "Libraries/Loaders/SHFontLoader.h"
//#include "Libraries/Compilers/SHMeshCompiler.h" //#include "Libraries/Compilers/SHMeshCompiler.h"
#include "Libraries/Compilers/SHTextureCompiler.h" #include "Libraries/Compilers/SHTextureCompiler.h"
@ -398,6 +399,16 @@ namespace SHADE
} }
newPath = pathGen.value(); newPath = pathGen.value();
} }
else if (ext == TTF_EXTENSION.data())
{
std::string command = FONT_COMPILER_EXE.data();
command += " " + path.string();
std::system(command.c_str());
std::string fontPath = path.string().substr(0, path.string().find_last_of('.'));
fontPath += FONT_EXTENSION;
newPath = fontPath;
}
else else
{ {
SHLOG_WARNING("File Type compilation not yet Implemented: {}", path.string()); SHLOG_WARNING("File Type compilation not yet Implemented: {}", path.string());
@ -450,6 +461,8 @@ namespace SHADE
loaders[static_cast<size_t>(AssetType::PREFAB)] = loaders[static_cast<size_t>(AssetType::SCENE)]; loaders[static_cast<size_t>(AssetType::PREFAB)] = loaders[static_cast<size_t>(AssetType::SCENE)];
loaders[static_cast<size_t>(AssetType::MATERIAL)] = loaders[static_cast<size_t>(AssetType::SCENE)]; loaders[static_cast<size_t>(AssetType::MATERIAL)] = loaders[static_cast<size_t>(AssetType::SCENE)];
loaders[static_cast<size_t>(AssetType::MESH)] = nullptr; loaders[static_cast<size_t>(AssetType::MESH)] = nullptr;
loaders[static_cast<size_t>(AssetType::SCRIPT)] = nullptr;
loaders[static_cast<size_t>(AssetType::FONT)] = dynamic_cast<SHAssetLoader*>(new SHFontLoader());
} }
/**************************************************************************** /****************************************************************************

View File

@ -345,10 +345,18 @@ namespace SHADE
void SHHierarchyPanel::ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) const noexcept void SHHierarchyPanel::ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) const noexcept
{ {
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
std::vector<EntityID> entitiesToParent{};
std::ranges::copy_if(entities, std::back_inserter(entitiesToParent), [&sceneGraph](EntityID const& eid)
{
if (sceneGraph.GetParent(eid)->GetEntityID() == MAX_EID)
return true;
return false;
});
//auto const editor = SHSystemManager::GetSystem<SHEditor>(); //auto const editor = SHSystemManager::GetSystem<SHEditor>();
SHEntityParentCommand::EntityParentData entityParentData; SHEntityParentCommand::EntityParentData entityParentData;
std::vector<EntityID> parentedEIDS; std::vector<EntityID> parentedEIDS;
for (auto const& eid : entities) for (auto const& eid : entitiesToParent)
{ {
if(eid == parentEID) if(eid == parentEID)
continue; continue;

View File

@ -68,10 +68,10 @@ namespace SHADE
{ {
if (!component) if (!component)
return; return;
const auto componentType = rttr::type::get<T>(); const auto componentType = rttr::type::get<T>();
ImGui::PushID(SHFamilyID<SHComponent>::GetID<T>()); ImGui::PushID(SHFamilyID<SHComponent>::GetID<T>());
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::PopID();
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data())) if (ImGui::CollapsingHeader(componentType.get_name().data()))
{ {
@ -216,6 +216,8 @@ namespace SHADE
} }
} }
else DrawContextMenu(component); else DrawContextMenu(component);
ImGui::PopID();
} }
template<> template<>
@ -223,7 +225,8 @@ namespace SHADE
{ {
if (!component) if (!component)
return; return;
ImGui::PushID(component); ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHColliderComponent>());
const auto componentType = rttr::type::get(*component); const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
@ -330,6 +333,7 @@ namespace SHADE
{ {
if (!component) if (!component)
return; return;
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHLightComponent>());
const auto componentType = rttr::type::get(*component); const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
@ -353,6 +357,7 @@ namespace SHADE
{ {
DrawContextMenu(component); DrawContextMenu(component);
} }
ImGui::PopID();
} }
template<> template<>
@ -360,6 +365,7 @@ namespace SHADE
{ {
if (!component) if (!component)
return; return;
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHRenderable>());
const auto componentType = rttr::type::get(*component); const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine(); ImGui::SameLine();
@ -397,5 +403,6 @@ namespace SHADE
{ {
DrawContextMenu(component); DrawContextMenu(component);
} }
ImGui::PopID();
} }
} }

View File

@ -35,7 +35,7 @@ namespace SHADE
constexpr ImGuiWindowFlags dockspaceFlags = ImGuiDockNodeFlags_PassthruCentralNode; constexpr ImGuiWindowFlags dockspaceFlags = ImGuiDockNodeFlags_PassthruCentralNode;
//#==============================================================# //#==============================================================#
//|| Public Member Functions || //|| Public Member Functions ||
//#==============================================================# //#==============================================================#
SHEditorMenuBar::SHEditorMenuBar() SHEditorMenuBar::SHEditorMenuBar()
@ -221,13 +221,20 @@ namespace SHADE
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PLAY); ImGui::BeginDisabled(editor->editorState == SHEditor::State::PLAY);
if(ImGui::SmallButton(ICON_MD_PLAY_ARROW)) if(ImGui::SmallButton(ICON_MD_PLAY_ARROW))
{ {
if(editor->SaveScene()) if(editor->editorState == SHEditor::State::STOP)
{
if (editor->SaveScene())
{
editor->Play();
}
}
else
{ {
editor->Play(); editor->Play();
} }
} }
ImGui::EndDisabled(); ImGui::EndDisabled();
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PAUSE); ImGui::BeginDisabled(editor->editorState == SHEditor::State::STOP || editor->editorState == SHEditor::State::PAUSE);
if(ImGui::SmallButton(ICON_MD_PAUSE)) if(ImGui::SmallButton(ICON_MD_PAUSE))
{ {
editor->Pause(); editor->Pause();

View File

@ -85,7 +85,7 @@ namespace SHADE
shouldUpdateCamArm = ImGui::IsWindowHovered() && ImGui::IsKeyDown(ImGuiKey_LeftAlt) && ImGui::IsMouseDown(ImGuiMouseButton_Left); shouldUpdateCamArm = ImGui::IsWindowHovered() && ImGui::IsKeyDown(ImGuiKey_LeftAlt) && ImGui::IsMouseDown(ImGuiMouseButton_Left);
if (editor->editorState != SHEditor::State::PLAY && ImGui::IsWindowFocused() && !ImGui::IsMouseDown(ImGuiMouseButton_Right)) if (editor->editorState != SHEditor::State::PLAY && !ImGui::IsAnyItemActive() && !ImGui::IsMouseDown(ImGuiMouseButton_Right))
{ {
if (ImGui::IsKeyReleased(ImGuiKey_W)) if (ImGui::IsKeyReleased(ImGuiKey_W))
{ {
@ -151,7 +151,7 @@ namespace SHADE
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
{ {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::Text("Translate [Q]"); ImGui::Text("Translate [W]");
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
if (isTranslate) if (isTranslate)
@ -169,7 +169,7 @@ namespace SHADE
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
{ {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::Text("Rotate [W]"); ImGui::Text("Rotate [E]");
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
if (isRotate) if (isRotate)
@ -187,7 +187,7 @@ namespace SHADE
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
{ {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::Text("Scale [E]"); ImGui::Text("Scale [R]");
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
if (isScale) if (isScale)

View File

@ -516,7 +516,7 @@ namespace SHADE
ImGui_ImplVulkan_DestroyFontUploadObjects(); ImGui_ImplVulkan_DestroyFontUploadObjects();
renderGraph->GetNode("ImGui Node")->GetSubpass("ImGui Draw")->AddExteriorDrawCalls([](Handle<SHVkCommandBuffer>& cmd) renderGraph->GetNode("ImGui Node")->GetSubpass("ImGui Draw")->AddExteriorDrawCalls([](Handle<SHVkCommandBuffer>& cmd, uint32_t frameIndex)
{ {
cmd->BeginLabeledSegment("ImGui Draw"); cmd->BeginLabeledSegment("ImGui Draw");
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmd->GetVkCommandBuffer()); ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmd->GetVkCommandBuffer());

View File

@ -459,7 +459,7 @@ namespace SHADE
return SHVkInstance::GetResourceManager().Create<SHVkImage>(GetHandle(), &vmaAllocator, w, h, levels, format, usage, create); return SHVkInstance::GetResourceManager().Create<SHVkImage>(GetHandle(), &vmaAllocator, w, h, levels, format, usage, create);
} }
Handle<SHVkImage> SHVkLogicalDevice::CreateImage(SHImageCreateParams const& imageDetails, unsigned char* data, uint32_t dataSize, std::span<uint32_t> inMipOffsets, VmaMemoryUsage memUsage, VmaAllocationCreateFlags allocFlags) noexcept Handle<SHVkImage> SHVkLogicalDevice::CreateImage(SHImageCreateParams const& imageDetails, unsigned char* data, uint32_t dataSize, std::vector<uint32_t> const& inMipOffsets, VmaMemoryUsage memUsage, VmaAllocationCreateFlags allocFlags) noexcept
{ {
return SHVkInstance::GetResourceManager().Create<SHVkImage>(GetHandle(), &vmaAllocator, imageDetails, data, dataSize, inMipOffsets, memUsage, allocFlags); return SHVkInstance::GetResourceManager().Create<SHVkImage>(GetHandle(), &vmaAllocator, imageDetails, data, dataSize, inMipOffsets, memUsage, allocFlags);
} }

View File

@ -162,7 +162,7 @@ namespace SHADE
SHImageCreateParams const& imageDetails, SHImageCreateParams const& imageDetails,
unsigned char* data, unsigned char* data,
uint32_t dataSize, uint32_t dataSize,
std::span<uint32_t> inMipOffsets, std::vector<uint32_t> const& inMipOffsets,
VmaMemoryUsage memUsage, VmaMemoryUsage memUsage,
VmaAllocationCreateFlags allocFlags VmaAllocationCreateFlags allocFlags
) noexcept; ) noexcept;

View File

@ -123,7 +123,7 @@ namespace SHADE
SHImageCreateParams const& imageDetails, SHImageCreateParams const& imageDetails,
const unsigned char* data, const unsigned char* data,
uint32_t dataSize, uint32_t dataSize,
std::span<uint32_t> inMipOffsets, std::vector<uint32_t> const& inMipOffsets,
VmaMemoryUsage memUsage, VmaMemoryUsage memUsage,
VmaAllocationCreateFlags allocFlags VmaAllocationCreateFlags allocFlags
) noexcept ) noexcept

View File

@ -102,7 +102,7 @@ namespace SHADE
vk::Buffer stagingBuffer; vk::Buffer stagingBuffer;
//! Mipmap offsets for initializing the vk::BufferImageCopy during transfer to GPU resource //! Mipmap offsets for initializing the vk::BufferImageCopy during transfer to GPU resource
std::span<uint32_t> mipOffsets; std::vector<uint32_t> mipOffsets;
//! Handle to the device that creates these images //! Handle to the device that creates these images
Handle<SHVkLogicalDevice> device; Handle<SHVkLogicalDevice> device;
@ -125,7 +125,7 @@ namespace SHADE
SHImageCreateParams const& imageDetails, SHImageCreateParams const& imageDetails,
const unsigned char* data, const unsigned char* data,
uint32_t dataSize, uint32_t dataSize,
std::span<uint32_t> inMipOffsets, std::vector<uint32_t> const& inMipOffsets,
VmaMemoryUsage memUsage, VmaMemoryUsage memUsage,
VmaAllocationCreateFlags allocFlags VmaAllocationCreateFlags allocFlags
) noexcept; ) noexcept;

View File

@ -97,23 +97,6 @@ namespace SHADE
Handle<SHVkDescriptorSetLayout> materialDataPerInstanceLayout = logicalDevice->CreateDescriptorSetLayout(SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, { materialDataBinding }); Handle<SHVkDescriptorSetLayout> materialDataPerInstanceLayout = logicalDevice->CreateDescriptorSetLayout(SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, { materialDataBinding });
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, materialDataPerInstanceLayout->GetVkHandle(), "[Descriptor Set Layout] Material Globals"); SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, materialDataPerInstanceLayout->GetVkHandle(), "[Descriptor Set Layout] Material Globals");
SHVkDescriptorSetLayout::Binding fontBitmapBinding
{
.Type = vk::DescriptorType::eCombinedImageSampler,
.Stage = vk::ShaderStageFlagBits::eFragment,
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA,
.DescriptorCount = 1,
};
SHVkDescriptorSetLayout::Binding fontMatrixBinding
{
.Type = vk::DescriptorType::eStorageBuffer,
.Stage = vk::ShaderStageFlagBits::eVertex,
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA,
.DescriptorCount = 1,
};
Handle<SHVkDescriptorSetLayout> fontDataLayout = logicalDevice->CreateDescriptorSetLayout(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, { fontBitmapBinding, fontMatrixBinding });
globalDescSetLayouts.push_back(staticGlobalLayout); globalDescSetLayouts.push_back(staticGlobalLayout);

View File

@ -90,7 +90,7 @@ namespace SHADE
auto const& RENDERERS = GFX_SYSTEM->GetDefaultViewport()->GetRenderers(); auto const& RENDERERS = GFX_SYSTEM->GetDefaultViewport()->GetRenderers();
auto renderGraph = RENDERERS[SHGraphicsConstants::RenderGraphIndices::WORLD]->GetRenderGraph(); auto renderGraph = RENDERERS[SHGraphicsConstants::RenderGraphIndices::WORLD]->GetRenderGraph();
auto subPass = renderGraph->GetNode("Debug Draw")->GetSubpass("Debug Draw"); auto subPass = renderGraph->GetNode("Debug Draw")->GetSubpass("Debug Draw");
subPass->AddExteriorDrawCalls([this, GFX_SYSTEM](Handle<SHVkCommandBuffer>& cmdBuffer) subPass->AddExteriorDrawCalls([this, GFX_SYSTEM](Handle<SHVkCommandBuffer>& cmdBuffer, uint32_t frameIndex)
{ {
// Get Current frame index // Get Current frame index
const uint32_t FRAME_IDX = GFX_SYSTEM->GetCurrentFrameIndex(); const uint32_t FRAME_IDX = GFX_SYSTEM->GetCurrentFrameIndex();
@ -106,7 +106,7 @@ namespace SHADE
} }
}); });
auto subPassWithDepth = renderGraph->GetNode("Debug Draw with Depth")->GetSubpass("Debug Draw with Depth"); auto subPassWithDepth = renderGraph->GetNode("Debug Draw with Depth")->GetSubpass("Debug Draw with Depth");
subPassWithDepth->AddExteriorDrawCalls([this, GFX_SYSTEM](Handle<SHVkCommandBuffer>& cmdBuffer) subPassWithDepth->AddExteriorDrawCalls([this, GFX_SYSTEM](Handle<SHVkCommandBuffer>& cmdBuffer, uint32_t frameIndex)
{ {
// Get Current frame index // Get Current frame index
const uint32_t FRAME_IDX = GFX_SYSTEM->GetCurrentFrameIndex(); const uint32_t FRAME_IDX = GFX_SYSTEM->GetCurrentFrameIndex();

View File

@ -66,7 +66,9 @@ namespace SHADE
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
DescriptorSet Index for render graph resources. 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
NOT part of the layouts included in the global data.
*/ */
/***************************************************************************/ /***************************************************************************/
static constexpr uint32_t RENDERGRAPH_RESOURCE = 4; static constexpr uint32_t RENDERGRAPH_RESOURCE = 4;
@ -75,7 +77,7 @@ namespace SHADE
\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, 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.
*/ */
@ -89,7 +91,7 @@ namespace SHADE
*/ */
/***************************************************************************/ /***************************************************************************/
static constexpr uint32_t FONT_DATA = 6; static constexpr uint32_t FONT_DATA = 4;
}; };
struct DescriptorSetBindings struct DescriptorSetBindings

View File

@ -121,15 +121,16 @@ namespace SHADE
SHAssetManager::CompileAsset("../../Assets/Shaders/Text_FS.glsl", false); SHAssetManager::CompileAsset("../../Assets/Shaders/Text_FS.glsl", false);
// Load Built In Shaders // Load Built In Shaders
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT); static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
static constexpr AssetID FS_DEFAULT = 46377769; defaultFragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(FS_DEFAULT); static constexpr AssetID FS_DEFAULT = 46377769; defaultFragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(FS_DEFAULT);
static constexpr AssetID VS_DEBUG = 48002439; debugVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEBUG); static constexpr AssetID VS_DEBUG = 48002439; debugVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEBUG);
static constexpr AssetID FS_DEBUG = 36671027; debugFragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(FS_DEBUG); static constexpr AssetID FS_DEBUG = 36671027; debugFragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(FS_DEBUG);
static constexpr AssetID CS_COMPOSITE = 45072428; deferredCompositeShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(CS_COMPOSITE); static constexpr AssetID CS_COMPOSITE = 45072428; deferredCompositeShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(CS_COMPOSITE);
static constexpr AssetID SSAO = 38430899; ssaoShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(SSAO); static constexpr AssetID SSAO = 38430899; ssaoShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(SSAO);
static constexpr AssetID SSAO_BLUR = 39760835; ssaoBlurShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(SSAO_BLUR); static constexpr AssetID SSAO_BLUR = 39760835; ssaoBlurShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(SSAO_BLUR);
static constexpr AssetID TEXT_VS = 39816727; textVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_VS); static constexpr AssetID TEXT_VS = 39816727; textVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_VS);
static constexpr AssetID TEXT_FS = 38024754; textFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_FS); static constexpr AssetID TEXT_FS = 38024754; textFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_FS);
static constexpr AssetID SEGOE_UI_FONT = 176667660; testFont = SHResourceManager::LoadOrGet<SHFont>(SEGOE_UI_FONT);
} }
void SHGraphicsSystem::InitSceneRenderGraph(void) noexcept void SHGraphicsSystem::InitSceneRenderGraph(void) noexcept
@ -281,10 +282,16 @@ namespace SHADE
screenRenderGraph = resourceManager.Create<SHRenderGraph>(); screenRenderGraph = resourceManager.Create<SHRenderGraph>();
screenRenderGraph->Init("Scene Render Graph", device, swapchain, &resourceManager); screenRenderGraph->Init("Scene Render Graph", device, swapchain, &resourceManager);
screenRenderGraph->LinkNonOwningResource(worldRenderGraph, "Scene"); screenRenderGraph->LinkNonOwningResource(worldRenderGraph, "Scene");
screenRenderGraph->LinkNonOwningResource(worldRenderGraph, "Entity ID");
auto screenSpaceNode = screenRenderGraph->AddNode("Screen Space Pass", { "Scene" }, {}); auto screenSpaceNode = screenRenderGraph->AddNode("Screen Space Pass", { "Scene", "Entity ID"}, {});
auto uiSubpass = screenSpaceNode->AddSubpass("UI"); auto uiSubpass = screenSpaceNode->AddSubpass("UI");
uiSubpass->AddColorOutput("Scene"); uiSubpass->AddColorOutput("Scene");
uiSubpass->AddColorOutput("Entity ID");
uiSubpass->AddExteriorDrawCalls([=](Handle<SHVkCommandBuffer>& cmdBuffer, uint32_t frameIndex)
{
textRenderingSubSystem->Render(cmdBuffer, frameIndex);
});
{ {
// Dummy Node to transition scene render graph resource // Dummy Node to transition scene render graph resource
@ -359,8 +366,11 @@ namespace SHADE
textRenderingSubSystem = resourceManager.Create<SHTextRenderingSubSystem>(); textRenderingSubSystem = resourceManager.Create<SHTextRenderingSubSystem>();
// initialize the text renderer // initialize the text renderer
//auto uiNode = screenRenderGraph->GetNode("Screen Space Pass"); auto uiNode = screenRenderGraph->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, [=](Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex)
{
screenRenderer->BindDescSet(cmdBuffer, frameIndex);
});
SHFreetypeInstance::Init(); SHFreetypeInstance::Init();
} }
@ -503,6 +513,8 @@ namespace SHADE
#endif #endif
} }
textRenderingSubSystem->Run(frameIndex);
// For every viewport // For every viewport
for (int vpIndex = 0; vpIndex < static_cast<int>(viewports.size()); ++vpIndex) for (int vpIndex = 0; vpIndex < static_cast<int>(viewports.size()); ++vpIndex)
{ {
@ -807,7 +819,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
Handle<SHTexture> SHGraphicsSystem::AddTexture(const SHTextureAsset& texAsset) Handle<SHTexture> SHGraphicsSystem::AddTexture(const SHTextureAsset& texAsset)
{ {
const int MIPS = texAsset.mipOffsets.size(); const int MIPS = static_cast<int> (texAsset.mipOffsets.size());
auto sampler = samplerCache.GetSampler(device, SHVkSamplerParams { .maxLod = static_cast<float>(MIPS) }); auto sampler = samplerCache.GetSampler(device, SHVkSamplerParams { .maxLod = static_cast<float>(MIPS) });
SET_VK_OBJ_NAME(device, vk::ObjectType::eSampler, sampler->GetVkSampler(), "[Sampler] Mips " + std::to_string(MIPS)); SET_VK_OBJ_NAME(device, vk::ObjectType::eSampler, sampler->GetVkSampler(), "[Sampler] Mips " + std::to_string(MIPS));
return texLibrary.Add(texAsset, sampler); return texLibrary.Add(texAsset, sampler);
@ -815,7 +827,7 @@ namespace SHADE
SHADE::Handle<SHADE::SHTexture> SHGraphicsSystem::AddTexture(uint32_t pixelCount, const SHTexture::PixelChannel* const pixelData, uint32_t width, uint32_t height, SHTexture::TextureFormat format, std::vector<uint32_t> mipOffsets) SHADE::Handle<SHADE::SHTexture> SHGraphicsSystem::AddTexture(uint32_t pixelCount, const SHTexture::PixelChannel* const pixelData, uint32_t width, uint32_t height, SHTexture::TextureFormat format, std::vector<uint32_t> mipOffsets)
{ {
const int MIPS = mipOffsets.size(); const int MIPS = static_cast<int> (mipOffsets.size());
auto sampler = samplerCache.GetSampler(device, SHVkSamplerParams{ .maxLod = static_cast<float>(MIPS) }); auto sampler = samplerCache.GetSampler(device, SHVkSamplerParams{ .maxLod = static_cast<float>(MIPS) });
SET_VK_OBJ_NAME(device, vk::ObjectType::eSampler, sampler->GetVkSampler(), "[Sampler] Mips " + std::to_string(MIPS)); SET_VK_OBJ_NAME(device, vk::ObjectType::eSampler, sampler->GetVkSampler(), "[Sampler] Mips " + std::to_string(MIPS));
return texLibrary.Add(pixelCount, pixelData, width, height, format, mipOffsets, sampler); return texLibrary.Add(pixelCount, pixelData, width, height, format, mipOffsets, sampler);
@ -854,7 +866,7 @@ namespace SHADE
void SHGraphicsSystem::BuildFonts(void) noexcept void SHGraphicsSystem::BuildFonts(void) noexcept
{ {
fontLibrary.BuildFonts(device, graphicsQueue, graphicsCmdPool, descPool, resourceManager); fontLibrary.BuildFonts(device, graphicsQueue, graphicsCmdPool, descPool, textRenderingSubSystem->GetFontDataDescSetLayout(), resourceManager);
} }
#pragma endregion ADD_REMOVE #pragma endregion ADD_REMOVE
@ -1005,6 +1017,11 @@ namespace SHADE
return worldRenderGraph->GetNode(G_BUFFER_RENDER_GRAPH_NODE_NAME.data()); return worldRenderGraph->GetNode(G_BUFFER_RENDER_GRAPH_NODE_NAME.data());
} }
SHADE::SHFontLibrary const& SHGraphicsSystem::GetFontLibrary(void) const noexcept
{
return fontLibrary;
}
Handle<SHVkPipeline> SHGraphicsSystem::createDebugDrawPipeline(Handle<SHVkRenderpass> renderPass, Handle<SHSubpass> subpass) Handle<SHVkPipeline> SHGraphicsSystem::createDebugDrawPipeline(Handle<SHVkRenderpass> renderPass, Handle<SHSubpass> subpass)
{ {
auto pipelineLayout = resourceManager.Create<SHVkPipelineLayout> auto pipelineLayout = resourceManager.Create<SHVkPipelineLayout>

View File

@ -367,6 +367,7 @@ namespace SHADE
Handle<SHVkPipeline> GetDebugDrawPipeline(void) const noexcept { return debugDrawPipeline; } Handle<SHVkPipeline> GetDebugDrawPipeline(void) const noexcept { return debugDrawPipeline; }
Handle<SHVkPipeline> GetDebugDrawDepthPipeline(void) const noexcept { return debugDrawDepthPipeline; } Handle<SHVkPipeline> GetDebugDrawDepthPipeline(void) const noexcept { return debugDrawDepthPipeline; }
uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); } uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); }
SHFontLibrary const& GetFontLibrary (void) const noexcept;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Getters */ /* Getters */
@ -437,6 +438,8 @@ namespace SHADE
Handle<SHVkShaderModule> textVS; Handle<SHVkShaderModule> textVS;
Handle<SHVkShaderModule> textFS; Handle<SHVkShaderModule> textFS;
// Fonts
Handle<SHFont> testFont;
// Built-In Materials // Built-In Materials
Handle<SHMaterial> defaultMaterial; Handle<SHMaterial> defaultMaterial;

View File

@ -101,6 +101,11 @@ namespace SHADE
//cpuCameraData.viewProjectionMatrix = camera->GetViewProjectionMatrix(); //cpuCameraData.viewProjectionMatrix = camera->GetViewProjectionMatrix();
cameraBuffer->WriteToMemory(&cpuCameraData, sizeof(SHShaderCameraData), 0, cameraDataAlignedSize * frameIndex); cameraBuffer->WriteToMemory(&cpuCameraData, sizeof(SHShaderCameraData), 0, cameraDataAlignedSize * frameIndex);
BindDescSet(cmdBuffer, frameIndex);
}
void SHRenderer::BindDescSet(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept
{
std::array<uint32_t, 1> dynamicOffsets{ frameIndex * cameraDataAlignedSize }; std::array<uint32_t, 1> dynamicOffsets{ frameIndex * cameraDataAlignedSize };
cmdBuffer->BindDescriptorSet(cameraDescriptorSet, SH_PIPELINE_TYPE::GRAPHICS, SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS, std::span{ dynamicOffsets.data(), 1 }); cmdBuffer->BindDescriptorSet(cameraDescriptorSet, SH_PIPELINE_TYPE::GRAPHICS, SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS, std::span{ dynamicOffsets.data(), 1 });

View File

@ -63,6 +63,7 @@ namespace SHADE
/***********************************************************************************/ /***********************************************************************************/
class SHRenderer class SHRenderer
{ {
public: public:
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Constructor/Destructors */ /* Constructor/Destructors */
@ -82,6 +83,7 @@ namespace SHADE
void Draw(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool) noexcept; void Draw(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool) noexcept;
void UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept; void UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
void UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex, SHMatrix const& viewMatrix, SHMatrix const& projMatrix) noexcept; void UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex, SHMatrix const& viewMatrix, SHMatrix const& projMatrix) noexcept;
void BindDescSet (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
void UpdateCameraDataToBuffer (void) noexcept; void UpdateCameraDataToBuffer (void) noexcept;
void SetViewProjectionMatrix (SHMatrix const& viewMatrix, SHMatrix const& projMatrix) noexcept; void SetViewProjectionMatrix (SHMatrix const& viewMatrix, SHMatrix const& projMatrix) noexcept;

View File

@ -423,9 +423,8 @@ namespace SHADE
/*! /*!
\brief \brief
Loops through every single light component and checks for dirty light Loops through every single light component and writes light data to CPU
data. If light data is dirty, rewrite to the CPU container. We also want then GPU.
to bind the descriptor set for the light data.
*/ */
/***************************************************************************/ /***************************************************************************/

View File

@ -76,7 +76,7 @@ namespace SHADE
}; };
uint32_t mipOffset = 0; uint32_t mipOffset = 0;
rotationVectorsImage = logicalDevice->CreateImage(imageDetails, reinterpret_cast<unsigned char*>( rotationVectors.data()), static_cast<uint32_t>(sizeof(rotationVectors)), {&mipOffset, 1}, VMA_MEMORY_USAGE_AUTO, {}); rotationVectorsImage = logicalDevice->CreateImage(imageDetails, reinterpret_cast<unsigned char*>(rotationVectors.data()), static_cast<uint32_t>(sizeof(rotationVectors)), { mipOffset }, VMA_MEMORY_USAGE_AUTO, {});
vk::ImageMemoryBarrier transferBarrier{}; vk::ImageMemoryBarrier transferBarrier{};
rotationVectorsImage->PrepareImageTransitionInfo(vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, transferBarrier); rotationVectorsImage->PrepareImageTransitionInfo(vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, transferBarrier);

View File

@ -4,6 +4,7 @@
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.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"
namespace SHADE namespace SHADE
{ {
@ -42,16 +43,18 @@ namespace SHADE
.depth = 1, .depth = 1,
.levels = 1, .levels = 1,
.arrayLayers = 1, .arrayLayers = 1,
.imageFormat = vk::Format::eR32G32B32Sfloat, .imageFormat = vk::Format::eR8G8B8A8Unorm,
//.imageFormat = vk::Format::eR32Sfloat,
//.imageFormat = vk::Format::eR32G32B32Sfloat,
.usageFlags = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst, .usageFlags = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst,
.createFlags = {} .createFlags = {}
}; };
uint32_t bytesRequired = fontAsset.bitmapWidth * fontAsset.bitmapHeight * SHFontAsset::BYTES_PER_CHANNEL * SHFontAsset::NUM_CHANNELS; uint32_t bytesRequired = asset.bitmapData.size();
uint32_t mipOffset = 0; uint32_t mipOffset = 0;
// Create the image // Create the image
bitmapDataImage = logicalDevice->CreateImage(imageParams, fontAsset.bitmapData.data(), bytesRequired, { &mipOffset, 1 }, VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO, {}); bitmapDataImage = logicalDevice->CreateImage(imageParams, fontAsset.bitmapData.data(), bytesRequired, { mipOffset }, VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO, {});
// Amount of data required to hold matrices for all glyphs // Amount of data required to hold matrices for all glyphs
uint32_t glyphDataSize = fontAsset.glyphTransformations.size() * sizeof (SHMatrix); uint32_t glyphDataSize = fontAsset.glyphTransformations.size() * sizeof (SHMatrix);
@ -63,9 +66,7 @@ namespace SHADE
// allocate GPU buffer for matrices // allocate GPU buffer for matrices
matrixDataBuffer = logicalDevice->CreateBuffer(glyphDataSize, fontAsset.glyphTransformations.data(), glyphDataSize, vk::BufferUsageFlagBits::eTransferDst | vk::BufferUsageFlagBits::eStorageBuffer, VMA_MEMORY_USAGE_AUTO, {}); matrixDataBuffer = logicalDevice->CreateBuffer(glyphDataSize, fontAsset.glyphTransformations.data(), glyphDataSize, vk::BufferUsageFlagBits::eTransferDst | vk::BufferUsageFlagBits::eStorageBuffer, VMA_MEMORY_USAGE_AUTO, {});
//// Prepare pre and post transfer barrier sampler = logicalDevice->CreateSampler(SHVkSamplerParams{});
//bitmapDataImage->PrepareImageTransitionInfo(vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, preTransferBarrier);
//bitmapDataImage->PrepareImageTransitionInfo(vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal, postTransferBarrier);
} }
@ -95,7 +96,7 @@ namespace SHADE
matrixDataBuffer->TransferToDeviceResource(commandBuffer); matrixDataBuffer->TransferToDeviceResource(commandBuffer);
} }
void SHFont::DoPostTransfer(Handle<SHVkDescriptorPool> descPool) noexcept void SHFont::DoPostTransfer(Handle<SHVkDescriptorPool> descPool, Handle<SHVkDescriptorSetLayout> layout) noexcept
{ {
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* CREATE IMAGE VIEW */ /* CREATE IMAGE VIEW */
@ -104,7 +105,7 @@ namespace SHADE
SHImageViewDetails viewDetails SHImageViewDetails viewDetails
{ {
.viewType = vk::ImageViewType::e2D, .viewType = vk::ImageViewType::e2D,
.format = vk::Format::eR32G32B32Sfloat, .format = bitmapDataImage->GetImageFormat(),
.imageAspectFlags = vk::ImageAspectFlagBits::eColor, .imageAspectFlags = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0, .baseMipLevel = 0,
.mipLevelCount = 1, .mipLevelCount = 1,
@ -116,14 +117,11 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* DESCRIPTORS */ /* DESCRIPTORS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
// Font data desc set layout
auto fontDataLayout = SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA];
// allocate desc set for the bitmap and matrix data // allocate desc set for the bitmap and matrix data
descSet = descPool->Allocate({ fontDataLayout }, { 1, 1 }); descSet = descPool->Allocate({ layout }, { 1 });
//auto viewLayoutSampler = std::make_tuple() auto viewLayoutSampler = std::make_tuple(bitmapDataImageView, sampler, vk::ImageLayout::eShaderReadOnlyOptimal);
descSet->ModifyWriteDescImage(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA, {}); descSet->ModifyWriteDescImage(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA, {&viewLayoutSampler, 1});
descSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, descSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA,
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));

View File

@ -9,12 +9,14 @@ namespace SHADE
class SHVkLogicalDevice; class SHVkLogicalDevice;
class SHVkDescriptorPool; class SHVkDescriptorPool;
class SHVkDescriptorSetGroup; class SHVkDescriptorSetGroup;
class SHVkDescriptorSetLayout;
class SHVkCommandBuffer; class SHVkCommandBuffer;
class SHVkCommandPool; class SHVkCommandPool;
class SHVkImage; class SHVkImage;
class SHVkImageView; class SHVkImageView;
class SHVkBuffer; class SHVkBuffer;
class SHVkQueue; class SHVkQueue;
class SHVkSampler;
class SHFont class SHFont
{ {
@ -37,6 +39,8 @@ namespace SHADE
//! Descriptor set required to store the bitmap AND matrix data for the UV and quad transformation //! Descriptor set required to store the bitmap AND matrix data for the UV and quad transformation
Handle<SHVkDescriptorSetGroup> descSet; Handle<SHVkDescriptorSetGroup> descSet;
Handle<SHVkSampler> sampler;
//! Used for getting the correct indices into the matrix data buffer //! Used for getting the correct indices into the matrix data buffer
std::unordered_map<msdfgen::unicode_t, uint32_t> unicodeIndexing; std::unordered_map<msdfgen::unicode_t, uint32_t> unicodeIndexing;
@ -52,7 +56,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
SHFont (Handle<SHVkLogicalDevice> inLogicalDeviceHdl, SHFontAsset const& asset) noexcept; SHFont (Handle<SHVkLogicalDevice> inLogicalDeviceHdl, SHFontAsset const& asset) noexcept;
void TransferToGPU (Handle<SHVkCommandBuffer> commandBuffer) noexcept; void TransferToGPU (Handle<SHVkCommandBuffer> commandBuffer) noexcept;
void DoPostTransfer (Handle<SHVkDescriptorPool> descPool) noexcept; void DoPostTransfer (Handle<SHVkDescriptorPool> descPool, Handle<SHVkDescriptorSetLayout> layout) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/

View File

@ -50,11 +50,11 @@ namespace SHADE
*/ */
/***************************************************************************/ /***************************************************************************/
void SHFontLibrary::BuildFonts(Handle<SHVkLogicalDevice> logicalDevice, Handle<SHVkQueue> queue, Handle<SHVkCommandPool> cmdPool, Handle<SHVkDescriptorPool> descPool, SHResourceHub& resourceHub) noexcept void SHFontLibrary::BuildFonts(Handle<SHVkLogicalDevice> logicalDevice, Handle<SHVkQueue> queue, Handle<SHVkCommandPool> cmdPool, Handle<SHVkDescriptorPool> descPool, Handle<SHVkDescriptorSetLayout> layout, SHResourceHub& resourceHub) noexcept
{ {
// create fence to wait on after transfer // create fence to wait on after transfer
Handle<SHVkFence> finishCopyFence = resourceHub.Create<SHVkFence>(logicalDevice); Handle<SHVkFence> finishCopyFence = resourceHub.Create<SHVkFence>(logicalDevice);
finishCopyFence->Reset();
// allocate new command buffer // allocate new command buffer
Handle<SHVkCommandBuffer> transferCommandBuffer = cmdPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY); Handle<SHVkCommandBuffer> transferCommandBuffer = cmdPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
@ -84,10 +84,10 @@ namespace SHADE
// Prepare image views and desc sets // Prepare image views and desc sets
for (auto& font : unpreparedFonts) for (auto& font : unpreparedFonts)
font->DoPostTransfer(descPool); font->DoPostTransfer(descPool, layout);
// Free the command buffer and fence // Free the command buffer and fence
resourceHub.Free(transferCommandBuffer); transferCommandBuffer.Free();
resourceHub.Free(finishCopyFence); resourceHub.Free(finishCopyFence);
// Once unprepared fonts are now ready for use, push them into container // Once unprepared fonts are now ready for use, push them into container
@ -100,4 +100,9 @@ namespace SHADE
postTransferBarriers.clear(); postTransferBarriers.clear();
} }
std::vector<Handle<SHFont>> const& SHFontLibrary::GetFonts(void) const noexcept
{
return fonts;
}
} }

View File

@ -11,8 +11,9 @@ namespace SHADE
class SHVkCommandPool; class SHVkCommandPool;
class SHVkCommandBuffer; class SHVkCommandBuffer;
class SHVkQueue; class SHVkQueue;
class SHVkDescriptorSetLayout;
class SHFontLibrary class SH_API SHFontLibrary
{ {
private: private:
//! Handles to all the fonts usable in SHTextRendererComponents //! Handles to all the fonts usable in SHTextRendererComponents
@ -29,6 +30,7 @@ namespace SHADE
public: public:
Handle<SHFont> AddFont (Handle<SHVkLogicalDevice> logicalDevice, SHResourceHub& resourceHub, SHFontAsset const& asset) noexcept; Handle<SHFont> AddFont (Handle<SHVkLogicalDevice> logicalDevice, SHResourceHub& resourceHub, SHFontAsset const& asset) noexcept;
void BuildFonts (Handle<SHVkLogicalDevice> logicalDevice, Handle<SHVkQueue> queue, Handle<SHVkCommandPool> cmdPool, Handle<SHVkDescriptorPool> descPool, SHResourceHub& resourceHub) noexcept; void BuildFonts (Handle<SHVkLogicalDevice> logicalDevice, Handle<SHVkQueue> queue, Handle<SHVkCommandPool> cmdPool, Handle<SHVkDescriptorPool> descPool, Handle<SHVkDescriptorSetLayout> layout, SHResourceHub& resourceHub) noexcept;
std::vector<Handle<SHFont>> const& GetFonts (void) const noexcept;
}; };
} }

View File

@ -24,13 +24,18 @@ namespace SHADE
/***************************************************************************/ /***************************************************************************/
void SHTextRendererComponent::OnCreate(void) void SHTextRendererComponent::OnCreate(void)
{ {
text = ""; text = "Text";
requiresRecompute = true; requiresRecompute = true;
// Default white color. // Default white color.
color = SHColour::WHITE; color = SHColour::WHITE;
} }
void SHTextRendererComponent::OnDestroy(void)
{
}
/***************************************************************************/ /***************************************************************************/
/*! /*!
@ -50,6 +55,11 @@ namespace SHADE
MakeDirty(); MakeDirty();
} }
void SHTextRendererComponent::SetFont(Handle<SHFont> font) noexcept
{
fontHandle = font;
}
/***************************************************************************/ /***************************************************************************/
/*! /*!

View File

@ -12,7 +12,7 @@ namespace SHADE
class SHVkDescriptorSetGroup; class SHVkDescriptorSetGroup;
class SHVkBuffer; class SHVkBuffer;
class SHTextRendererComponent final : public SHComponent class SH_API SHTextRendererComponent final : public SHComponent
{ {
public: public:
static constexpr uint32_t MAX_CHARACTERS = 500; static constexpr uint32_t MAX_CHARACTERS = 500;
@ -44,11 +44,14 @@ namespace SHADE
public: public:
void OnCreate(void) override final; void OnCreate(void) override final;
void OnDestroy(void) override final;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void SetText (std::string_view newText) noexcept; void SetText (std::string_view newText) noexcept;
void SetFont (Handle<SHFont> font) noexcept;
std::string const& GetText (void) const noexcept; std::string const& GetText (void) const noexcept;
friend class SHTextRenderingSubSystem; friend class SHTextRenderingSubSystem;

View File

@ -8,6 +8,9 @@
#include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h"
#include "Graphics/Pipeline/SHVkPipeline.h" #include "Graphics/Pipeline/SHVkPipeline.h"
#include "Graphics/SHVkUtil.h"
#include "Graphics/RenderGraph/SHSubpass.h"
#include "Math/Transform/SHTransformComponent.h"
namespace SHADE namespace SHADE
{ {
@ -80,16 +83,20 @@ namespace SHADE
//} //}
} }
textComp.indexingDataBuffer->WriteToMemory(indexingData.data(), indexingData.size() * sizeof (SHTextRendererComponent::TextIndexingType),0, 0); textComp.indexingDataBuffer->WriteToMemory(indexingData.data(), static_cast<uint32_t>(indexingData.size()) * sizeof (SHTextRendererComponent::TextIndexingType),0, 0);
textComp.charPositionDataBuffer->WriteToMemory(charPositionData.data(), charPositionData.size() * sizeof (SHVec4), 0, 0); textComp.charPositionDataBuffer->WriteToMemory(charPositionData.data(), static_cast<uint32_t>(charPositionData.size()) * sizeof (SHVec4), 0, 0);
indexingData.clear(); indexingData.clear();
charPositionData.clear(); charPositionData.clear();
} }
void SHTextRenderingSubSystem::Init(Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkDescriptorPool> descPool, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS) noexcept void SHTextRenderingSubSystem::Init(Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkDescriptorPool> descPool, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS, std::function<void(Handle<SHVkCommandBuffer>, uint32_t)> const& bindFunction) noexcept
{ {
SHComponentManager::CreateComponentSparseSet<SHTextRendererComponent>();
cameraDescSetBind = bindFunction;
logicalDevice = device; logicalDevice = device;
// prepare pipeline layout params // prepare pipeline layout params
@ -114,8 +121,53 @@ namespace SHADE
// Set vertex state for new pipeline // Set vertex state for new pipeline
pipeline->GetPipelineState().SetVertexInputState(vertexInputState); pipeline->GetPipelineState().SetVertexInputState(vertexInputState);
SHColorBlendState colorBlendState{};
colorBlendState.logic_op_enable = VK_FALSE;
colorBlendState.logic_op = vk::LogicOp::eCopy;
auto const& subpassColorReferences = subpass->GetColorAttachmentReferences();
colorBlendState.attachments.reserve(static_cast<uint32_t>(subpassColorReferences.size()));
for (auto& att : subpassColorReferences)
{
colorBlendState.attachments.push_back(vk::PipelineColorBlendAttachmentState
{
.blendEnable = SHVkUtil::IsBlendCompatible(subpass->GetFormatFromAttachmentReference(att.attachment)) ? true : false,
.srcColorBlendFactor = vk::BlendFactor::eSrcAlpha,
.dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha,
.colorBlendOp = vk::BlendOp::eAdd,
.srcAlphaBlendFactor = vk::BlendFactor::eOne,
.dstAlphaBlendFactor = vk::BlendFactor::eZero,
.alphaBlendOp = vk::BlendOp::eAdd,
.colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA,
}
);
}
pipeline->GetPipelineState().SetColorBlenState(colorBlendState);
// Construct pipeline // Construct pipeline
pipeline->ConstructPipeline(); pipeline->ConstructPipeline();
SHVkDescriptorSetLayout::Binding fontBitmapBinding
{
.Type = vk::DescriptorType::eCombinedImageSampler,
.Stage = vk::ShaderStageFlagBits::eFragment,
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::FONT_BITMAP_DATA,
.DescriptorCount = 1,
};
SHVkDescriptorSetLayout::Binding fontMatrixBinding
{
.Type = vk::DescriptorType::eStorageBuffer,
.Stage = vk::ShaderStageFlagBits::eVertex,
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::FONT_MATRIX_DATA,
.DescriptorCount = 1,
};
fontDataDescSetLayout = logicalDevice->CreateDescriptorSetLayout(SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, { fontBitmapBinding, fontMatrixBinding });
} }
void SHTextRenderingSubSystem::Run(uint32_t frameIndex) noexcept void SHTextRenderingSubSystem::Run(uint32_t frameIndex) noexcept
@ -130,17 +182,18 @@ namespace SHADE
RecomputePositions(comp); RecomputePositions(comp);
comp.Clean(); comp.Clean();
} }
} }
} }
void SHTextRenderingSubSystem::Render(Handle<SHVkCommandBuffer> cmdBuffer) noexcept void SHTextRenderingSubSystem::Render(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept
{ {
auto& textRendererComps = SHComponentManager::GetDense<SHTextRendererComponent>(); auto& textRendererComps = SHComponentManager::GetDense<SHTextRendererComponent>();
for (auto& comp : textRendererComps) for (auto& comp : textRendererComps)
{ {
auto* transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID());
Handle<SHFont> fontHandle = comp.fontHandle; Handle<SHFont> fontHandle = comp.fontHandle;
if (fontHandle) if (fontHandle && transform)
{ {
// bind the pipeline // bind the pipeline
cmdBuffer->BindPipeline(pipeline); cmdBuffer->BindPipeline(pipeline);
@ -149,10 +202,20 @@ namespace SHADE
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0); cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0);
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::GLYPH_INDEX, comp.indexingDataBuffer, 0); cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::GLYPH_INDEX, comp.indexingDataBuffer, 0);
cameraDescSetBind(cmdBuffer, frameIndex);
// bind descriptors for font (matrices) // bind descriptors for font (matrices)
cmdBuffer->BindDescriptorSet(fontHandle->GetDescriptorSet(), SH_PIPELINE_TYPE::GRAPHICS, SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, {}); cmdBuffer->BindDescriptorSet(fontHandle->GetDescriptorSet(), SH_PIPELINE_TYPE::GRAPHICS, SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, {});
cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS);
cmdBuffer->SetPushConstantVariable("TestPushConstant.eid", comp.GetEID(), SH_PIPELINE_TYPE::GRAPHICS);
cmdBuffer->SetPushConstantVariable("TestPushConstant.textColor", SHVec3 (1.0f, 1.0f, 1.0f), SH_PIPELINE_TYPE::GRAPHICS);
cmdBuffer->SubmitPushConstants(SH_PIPELINE_TYPE::GRAPHICS);
// call draw call // call draw call
cmdBuffer->DrawArrays(4, comp.text.size(), 0, 0);
//glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, static_cast<GLsizei>(textComp.lastRenderedCharacterIndex) + 1);
} }
@ -164,4 +227,9 @@ namespace SHADE
} }
Handle<SHVkDescriptorSetLayout> SHTextRenderingSubSystem::GetFontDataDescSetLayout(void) const noexcept
{
return fontDataDescSetLayout;
}
} }

View File

@ -2,6 +2,8 @@
#include "Resource/SHHandle.h" #include "Resource/SHHandle.h"
#include "Graphics/Pipeline/SHPipelineState.h" #include "Graphics/Pipeline/SHPipelineState.h"
#include "Math/SHMatrix.h"
#include "Math/Vector/SHVec3.h"
namespace SHADE namespace SHADE
{ {
@ -22,6 +24,12 @@ namespace SHADE
class SHTextRenderingSubSystem class SHTextRenderingSubSystem
{ {
private: private:
struct ShaderPushConstantData
{
SHMatrix worldTransform;
uint32_t eid;
SHVec3 textColor;
};
//! Logical device for creation and destruction //! Logical device for creation and destruction
Handle<SHVkLogicalDevice> logicalDevice; Handle<SHVkLogicalDevice> logicalDevice;
@ -32,15 +40,26 @@ namespace SHADE
//! Pipeline layout for the pipeline //! Pipeline layout for the pipeline
Handle<SHVkPipelineLayout> pipelineLayout; Handle<SHVkPipelineLayout> pipelineLayout;
//! Descriptor set for font data access in shaders
Handle<SHVkDescriptorSetLayout> fontDataDescSetLayout;
//! Super temporary. Global descriptor set needs to be revamped along with
//! entire graphics system.
std::function<void(Handle<SHVkCommandBuffer>, uint32_t)> cameraDescSetBind;
private: private:
void RecomputePositions(SHTextRendererComponent& textComp) noexcept; void RecomputePositions(SHTextRendererComponent& textComp) noexcept;
public: public:
void Init(Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkDescriptorPool> descPool, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS) noexcept; void Init(Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkDescriptorPool> descPool, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS, std::function<void(Handle<SHVkCommandBuffer>, uint32_t)> const& bindFunction) noexcept;
void Run(uint32_t frameIndex) noexcept; void Run(uint32_t frameIndex) noexcept;
void Render (Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
void Render (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
void Exit(void) noexcept; void Exit(void) noexcept;
Handle<SHVkDescriptorSetLayout> GetFontDataDescSetLayout (void) const noexcept;
}; };
} }

View File

@ -79,9 +79,9 @@ namespace SHADE
startOffset += pcInfo.size; startOffset += pcInfo.size;
} }
stageFlags |= shaderModule->GetShaderStageFlagBits();
} }
stageFlags |= shaderModule->GetShaderStageFlagBits();
} }
// After all the sizes of the push constant blocks have been added, record the size in the interface // After all the sizes of the push constant blocks have been added, record the size in the interface

View File

@ -211,7 +211,7 @@ namespace SHADE
// Draw all the exterior draw calls // Draw all the exterior draw calls
for (auto& drawCall : exteriorDrawCalls) for (auto& drawCall : exteriorDrawCalls)
{ {
drawCall(commandBuffer); drawCall(commandBuffer, frameIndex);
} }
commandBuffer->EndLabeledSegment(); commandBuffer->EndLabeledSegment();
} }
@ -221,7 +221,7 @@ namespace SHADE
UpdateWriteDescriptors(); UpdateWriteDescriptors();
} }
void SHSubpass::AddExteriorDrawCalls(std::function<void(Handle<SHVkCommandBuffer>&)> const& newDrawCall) noexcept void SHSubpass::AddExteriorDrawCalls(std::function<void(Handle<SHVkCommandBuffer>&, uint32_t)> const& newDrawCall) noexcept
{ {
exteriorDrawCalls.push_back(newDrawCall); exteriorDrawCalls.push_back(newDrawCall);
} }

View File

@ -76,7 +76,7 @@ namespace SHADE
//! after we draw everything from the batch. Because of this, these draw calls //! after we draw everything from the batch. Because of this, these draw calls
//! are always the last things drawn, so DO NOT USE THIS FUNCTIONALITY FOR ANYTHING //! are always the last things drawn, so DO NOT USE THIS FUNCTIONALITY FOR ANYTHING
//! COMPLEX. //! COMPLEX.
std::vector<std::function<void(Handle<SHVkCommandBuffer>&)>> exteriorDrawCalls; std::vector<std::function<void(Handle<SHVkCommandBuffer>&, uint32_t)>> exteriorDrawCalls;
/// For identifying subpasses /// For identifying subpasses
std::string name; std::string name;
@ -99,7 +99,7 @@ namespace SHADE
void AddGeneralDepthOutput(std::string resourceToReference) noexcept; void AddGeneralDepthOutput(std::string resourceToReference) noexcept;
void AddInput(std::string resourceToReference) noexcept; void AddInput(std::string resourceToReference) noexcept;
void AddGeneralInput (std::string resourceToReference) noexcept; void AddGeneralInput (std::string resourceToReference) noexcept;
void AddExteriorDrawCalls(std::function<void(Handle<SHVkCommandBuffer>&)> const& newDrawCall) noexcept; void AddExteriorDrawCalls(std::function<void(Handle<SHVkCommandBuffer>&, uint32_t)> const& newDrawCall) noexcept;
// 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;

View File

@ -316,10 +316,10 @@ namespace SHADE
return matHandle; return matHandle;
} }
else if constexpr (std::is_same_v<ResourceType, SHFontAsset>) else if constexpr (std::is_same_v<ResourceType, SHFont>)
{ {
loadedAssetData.emplace_back(assetId); loadedAssetData.emplace_back(assetId);
textureChanged = true; fontChanged = true;
return gfxSystem->AddFont(assetData); return gfxSystem->AddFont(assetData);
} }

View File

@ -179,7 +179,9 @@ namespace SHADE
{ {
if (ComponentType* component = SHComponentManager::GetComponent_s<ComponentType>(eid)) if (ComponentType* component = SHComponentManager::GetComponent_s<ComponentType>(eid))
{ {
componentsNode[rttr::type::get<ComponentType>().get_name().data()] = YAML::convert<ComponentType>::encode(*component); auto componentNode = YAML::convert<ComponentType>::encode(*component);
componentNode[IsActive.data()] = component->isActive;
componentsNode[rttr::type::get<ComponentType>().get_name().data()] = componentNode;
} }
} }

View File

@ -14,6 +14,8 @@
namespace SHADE namespace SHADE
{ {
static constexpr std::string_view IsActive = "IsActive";
using AssetQueue = std::unordered_map<AssetID, AssetType>; using AssetQueue = std::unordered_map<AssetID, AssetType>;
struct SHSerializationHelper struct SHSerializationHelper
{ {
@ -118,9 +120,9 @@ namespace SHADE
YAML::Node node{}; YAML::Node node{};
if (!component) if (!component)
return node; return node;
auto componentType = rttr::type::get<ComponentType>(); auto componentType = rttr::type::get<ComponentType>();
node = RTTRToNode(*component); node = RTTRToNode(*component);
node[IsActive.data()] = component->isActive;
return node; return node;
} }
@ -198,6 +200,9 @@ namespace SHADE
auto componentNode = componentsNode[rttrType.get_name().data()]; auto componentNode = componentsNode[rttrType.get_name().data()];
if (!componentNode.IsDefined()) if (!componentNode.IsDefined())
return; return;
if(componentNode[IsActive.data()].IsDefined())
component->isActive = componentNode[IsActive.data()].as<bool>();
auto properties = rttrType.get_properties(); auto properties = rttrType.get_properties();
for (auto const& prop : properties) for (auto const& prop : properties)
{ {
@ -227,8 +232,10 @@ namespace SHADE
auto component = SHComponentManager::GetComponent_s<ComponentType>(eid); auto component = SHComponentManager::GetComponent_s<ComponentType>(eid);
if (componentsNode.IsNull() && !component) if (componentsNode.IsNull() && !component)
return; return;
auto componentNode = GetComponentNode<ComponentType>(componentsNode, eid);
YAML::convert<ComponentType>::decode(GetComponentNode<ComponentType>(componentsNode, eid), *component); if (componentNode[IsActive.data()].IsDefined())
component->isActive = componentNode[IsActive.data()].as<bool>();
YAML::convert<ComponentType>::decode(componentNode, *component);
} }
template <typename ComponentType, std::enable_if_t<std::is_base_of_v<SHComponent, ComponentType>, bool> = true> template <typename ComponentType, std::enable_if_t<std::is_base_of_v<SHComponent, ComponentType>, bool> = true>

View File

@ -44,13 +44,6 @@ namespace SHADE
SHLOG_FLOOR() SHLOG_FLOOR()
} }
#ifdef _DEBUG
void SHLog::Trace(const std::string& msg) noexcept
{
SHLOG_TRACE(msg)
}
#endif
void SHLog_Info(const char* msg) noexcept void SHLog_Info(const char* msg) noexcept
{ {
SHLOG_INFO(msg) SHLOG_INFO(msg)

View File

@ -323,34 +323,6 @@ namespace SHADE
SHLOG_FLOOR() SHLOG_FLOOR()
} }
#ifdef _DEBUG
void SHLogger::LogTrace(const std::string& msg) noexcept
{
SHLOG_TRACE(msg)
}
void SHLogger::LogVerboseTrace(const std::string& msg, const std::source_location& src) noexcept
{
const bool SHOW_SRC_FILE = configFlags & (1U << 3);
const bool SHOW_SRC_LINE = configFlags & (1U << 4);
std::stringstream ss;
ss << "[";
if (SHOW_SRC_FILE)
{
ss << std::filesystem::path(src.file_name()).filename().string() << ", ";
if (SHOW_SRC_LINE)
{
ss << src.line() << ", ";
}
}
ss << src.function_name() << "] " << msg;
SHLOG_TRACE(ss.str())
}
#endif
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Private Function Member Definitions */ /* Private Function Member Definitions */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/