Added UI functionality to the Graphics System #232

Merged
Xenosas1337 merged 40 commits from UI_Integration into main 2022-11-20 15:43:34 +08:00
15 changed files with 61 additions and 21 deletions
Showing only changes of commit d95ed3f067 - Show all commits

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Assets/Fonts/SegoeUI.ttf Normal file

Binary file not shown.

View File

@ -7,7 +7,6 @@
// vertex inputs
layout(location = 0) in vec4 positionalOffset;
layout(location = 1) in uint glyphIndex;
layout(location = 2) in uvec2 integerData;
// between shader stages
layout(location = 0) out struct
@ -37,6 +36,7 @@ layout(set = 2, binding = 0) uniform CameraData
layout(std140, push_constant) uniform TestPushConstant
{
mat4 worldTransform;
uint eid;
} testPushConstant;
@ -55,7 +55,7 @@ vec2 CreateQuad(in uint vertexID)
void main()
{
// write EID data to FS
Out2.eid = integerData[0];
Out2.eid = testPushConstats.eid;
// local variable for font index
uint fontIndex = glyphIndex;

View File

@ -6,7 +6,7 @@ echo ---------------------------------------------------
echo "SHADE DEPENDENCIES (Default - All in 10 Seconds)"
echo "A - All"
echo "B - VMA"
echo "C - msdf"
echo "C - FontCompiler"
echo "D - ModelCompiler"
echo "E - spdlog"
echo "F - reactphysics3d"
@ -28,7 +28,7 @@ set _e=%ERRORLEVEL%
if %_e%==1 goto VMA
if %_e%==2 goto VMA
if %_e%==3 goto MSDF
if %_e%==3 goto FontCompiler
if %_e%==4 goto ModelCompiler
if %_e%==5 goto spdlog
if %_e%==6 goto reactphysics3d
@ -47,12 +47,13 @@ if %_e%==16 goto fmod
echo -----------------------VMA----------------------------
rmdir "Dependencies/VMA" /S /Q
git clone https://github.com/SHADE-DP/VulkanMemoryAllocator.git "Dependencies/VMA"
if %_e%==2 (goto :done) else (goto :MSDF)
if %_e%==2 (goto :done) else (goto :FontCompiler)
:MSDF
echo -----------------------MSDF----------------------------
rmdir "Dependencies/msdf" /S /Q
git clone --recurse-submodules https://github.com/SHADE-DP/msdf-atlas-gen.git "Dependencies/msdf"
:FontCompiler
echo -----------------------FontCompiler----------------------------
rmdir "Dependencies/FontCompiler" /S /Q
git clone https://github.com/SHADE-DP/FontCompiler.git "Dependencies/FontCompiler"
git clone --recurse-submodules https://github.com/SHADE-DP/msdf-atlas-gen "Dependencies/FontCompiler/Dependencies/msdf"
if %_e%==3 (goto :done) else (goto :ModelCompiler)
:ModelCompiler

View File

@ -3,8 +3,9 @@ IncludeDir["ModelCompiler"] = "%{wks.location}\\Dependencies\\ModelCompiler"
IncludeDir["imgui"] = "%{wks.location}\\Dependencies\\imgui"
IncludeDir["imguizmo"] = "%{wks.location}\\Dependencies\\imguizmo"
IncludeDir["imnodes"] = "%{wks.location}\\Dependencies\\imnodes"
IncludeDir["msdf_atlas_gen"] = "%{wks.location}\\Dependencies\\msdf"
IncludeDir["msdfgen"] = "%{wks.location}\\Dependencies\\msdf\\msdfgen"
IncludeDir["FontCompiler"] = "%{wks.location}\\Dependencies\\FontCompiler"
IncludeDir["msdf_atlas_gen"] = "%{wks.location}\\Dependencies\\FontCompiler\\Dependencies\\msdf"
IncludeDir["msdfgen"] = "%{wks.location}\\Dependencies\\FontCompiler\\Dependencies\\msdf\\msdfgen"
IncludeDir["spdlog"] = "%{wks.location}\\Dependencies\\spdlog"
IncludeDir["tracy"] = "%{wks.location}\\Dependencies\\tracy"
IncludeDir["VMA"] = "%{wks.location}\\Dependencies\\VMA"

View File

@ -146,6 +146,8 @@ namespace Sandbox
SHFrameRateController::UpdateFRC();
//std::system("FontCompiler.exe ../../Assets/Fonts/SegoeUI.ttf");
// Link up SHDebugDraw
SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());
}

View File

@ -118,6 +118,7 @@ project "SHADE_Engine"
{
"xcopy /r /y /q \"%{IncludeDir.ModelCompiler}\\bin\\Debug\\assimp-vc142-mtd.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.ModelCompiler}\\bin\\Debug\\ModelCompiler.exe\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.FontCompiler}\\bin\\Debug\\FontCompiler.exe\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodL.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudioL.dll\" \"$(OutDir)\""
}
@ -127,6 +128,7 @@ project "SHADE_Engine"
{
"xcopy /r /y /q \"%{IncludeDir.ModelCompiler}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.ModelCompiler}\\bin\\Release\\ModelCompiler.exe\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.FontCompiler}\\bin\\Release\\FontCompiler.exe\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmod.dll\" \"$(OutDir)\"",
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\""
}

View File

@ -203,6 +203,10 @@ namespace SHADE
/***************************************************************************/
static constexpr uint32_t INTEGER_DATA = 5;
static constexpr uint32_t CALCULATED_GLYPH_POSITION = 0;
static constexpr uint32_t GLYPH_INDEX = 1;
};
/*******************************************************************************/

View File

@ -154,4 +154,9 @@ namespace SHADE
return matrixDataBuffer;
}
Handle<SHVkDescriptorSetGroup> SHFont::GetDescriptorSet(void) const noexcept
{
return descSet;
}
}

View File

@ -61,7 +61,8 @@ namespace SHADE
std::unordered_map<msdfgen::unicode_t, uint32_t> GetUnicodeIndexing (void) const noexcept;
SHFontAsset const& GetFontAsset (void) const noexcept;
Handle<SHVkImage> GetImage (void) const noexcept;
Handle<SHVkBuffer> GetMatrixBuffer (void) const noexcept;
Handle<SHVkBuffer> GetMatrixBuffer (void) const noexcept;
Handle<SHVkDescriptorSetGroup> GetDescriptorSet (void) const noexcept;
};
}

View File

@ -7,6 +7,7 @@
#include "Graphics/MiddleEnd/TextRendering/SHFont.h"
#include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h"
#include "Graphics/Pipeline/SHVkPipeline.h"
namespace SHADE
{
@ -102,6 +103,19 @@ namespace SHADE
// Create pipeline
pipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, compatibleRenderpass, subpass);
// vertex input state of the pipeline
SHVertexInputState vertexInputState;
// Configure vertex attributes
vertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_4D) }); // location = 0 (character position data)
vertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::UINT32_1D) }); // location = 1 (glyph index to index matrices)
// Set vertex state for new pipeline
pipeline->GetPipelineState().SetVertexInputState(vertexInputState);
// Construct pipeline
pipeline->ConstructPipeline();
}
void SHTextRenderingSubSystem::Run(uint32_t frameIndex) noexcept
@ -120,19 +134,27 @@ namespace SHADE
}
}
void SHTextRenderingSubSystem::Render(void) noexcept
void SHTextRenderingSubSystem::Render(Handle<SHVkCommandBuffer> cmdBuffer) noexcept
{
auto& textRendererComps = SHComponentManager::GetDense<SHTextRendererComponent>();
for (auto& comp : textRendererComps)
{
// draw the component
Handle<SHFont> fontHandle = comp.fontHandle;
if (fontHandle)
{
// bind the pipeline
cmdBuffer->BindPipeline(pipeline);
// bind the pipeline
// bind the pipeline layout
// bind VBO (position and indices)
// bind descriptors for font (matrices)
// bind VBO (position and indices)
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0);
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::GLYPH_INDEX, comp.indexingDataBuffer, 0);
// call draw call
// bind descriptors for font (matrices)
cmdBuffer->BindDescriptorSet(fontHandle->GetDescriptorSet(), SH_PIPELINE_TYPE::GRAPHICS, SHGraphicsConstants::DescriptorSetIndex::FONT_DATA, {});
// call draw call
}
}
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "Resource/SHHandle.h"
#include "Graphics/Pipeline/SHPipelineState.h"
namespace SHADE
{
@ -37,7 +38,7 @@ namespace SHADE
public:
void Init(Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkDescriptorPool> descPool, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS) noexcept;
void Run(uint32_t frameIndex) noexcept;
void Render (void) noexcept;
void Render (Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
void Exit(void) noexcept;

View File

@ -25,10 +25,11 @@ workspace "SHADE"
include "SHADE_CSharp"
group "Dependencies"
include "Dependencies/msdf"
include "Dependencies/FontCompiler/Dependencies/msdf"
include "Dependencies/imgui"
--include "Dependencies/tracy"
include "Dependencies/yamlcpp"
include "Dependencies/reactphysics3d"
include "Dependencies/ModelCompiler"
include "Dependencies/FontCompiler"
group ""