Merge branch 'SP3-4-editor' into SP3-1-Rendering

This commit is contained in:
Brandon Mak 2022-09-14 19:44:01 +08:00
commit 44e529f06f
32 changed files with 966 additions and 253 deletions

View File

@ -46,6 +46,7 @@
<IntDir>bin-int\Debug_x86_64\SHADE_Application\</IntDir> <IntDir>bin-int\Debug_x86_64\SHADE_Application\</IntDir>
<TargetName>SHADE_Application</TargetName> <TargetName>SHADE_Application</TargetName>
<TargetExt>.exe</TargetExt> <TargetExt>.exe</TargetExt>
<IncludePath>..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
@ -53,6 +54,7 @@
<IntDir>bin-int\Release_x86_64\SHADE_Application\</IntDir> <IntDir>bin-int\Release_x86_64\SHADE_Application\</IntDir>
<TargetName>SHADE_Application</TargetName> <TargetName>SHADE_Application</TargetName>
<TargetExt>.exe</TargetExt> <TargetExt>.exe</TargetExt>
<IncludePath>..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
@ -60,7 +62,7 @@
<PrecompiledHeaderFile>SBpch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>SBpch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NOMINMAX;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NOMINMAX;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
@ -80,7 +82,7 @@
<PrecompiledHeaderFile>SBpch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>SBpch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NOMINMAX;_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NOMINMAX;_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>

View File

@ -22,14 +22,20 @@ project "SHADE_Application"
includedirs includedirs
{ {
"%{IncludeDir.spdlog}/include",
"%{IncludeDir.VULKAN}/include",
"%{IncludeDir.VMA}/include",
"%{IncludeDir.VULKAN}/Source/SPIRV-Reflect",
"../SHADE_Engine/src", "../SHADE_Engine/src",
"src" "src"
} }
externalincludedirs
{
"%{IncludeDir.spdlog}/include",
"%{IncludeDir.VULKAN}/include",
"%{IncludeDir.VMA}/include",
"%{IncludeDir.VULKAN}/Source/SPIRV-Reflect"
}
externalwarnings "Off"
flags flags
{ {
"MultiProcessorCompile" "MultiProcessorCompile"

View File

@ -2,9 +2,10 @@
#include "SBApplication.h" #include "SBApplication.h"
#include "Engine/ECS_Base/System/SHSystemManager.h" #include "Engine/ECS_Base/System/SHSystemManager.h"
#define SHEDITOR
#ifdef SHEDITOR #ifdef SHEDITOR
#include "Editor/SHEditor.h" //#include "Editor/SHEditor.h"
#include "Scenes/SBEditorScene.h" //#include "Scenes/SBEditorScene.h"
#endif // SHEDITOR #endif // SHEDITOR
#include <chrono> #include <chrono>
@ -29,8 +30,8 @@ namespace Sandbox
graphicsSystem->SetWindow(&window); graphicsSystem->SetWindow(&window);
SHADE::SHSystemManager::Init(); SHADE::SHSystemManager::Init();
#ifdef SHEDITOR #ifdef SHEDITOR
//SHADE::SHEditor::Initialize(window.GetHWND());
#else #else
#endif #endif
@ -43,10 +44,15 @@ namespace Sandbox
//TODO: Change true to window is open //TODO: Change true to window is open
while (!window.WindowShouldClose()) while (!window.WindowShouldClose())
{ {
//#ifdef SHEDITOR
//SHADE::SHEditor::PreRender();
//#endif
graphicsSystem->BeginRender(); graphicsSystem->BeginRender();
#ifdef SHEDITOR //#ifdef SHEDITOR
#else //SHADE::SHEditor::PreRender();
#endif //SHADE::SHEditor::Update();
//SHADE::SHEditor::Render();
//#endif
graphicsSystem->EndRender(); graphicsSystem->EndRender();
} }
} }
@ -54,6 +60,7 @@ namespace Sandbox
void SBApplication::Exit(void) void SBApplication::Exit(void)
{ {
//SHADE::SHEditor::Exit();
SHADE::SHSystemManager::Exit(); SHADE::SHSystemManager::Exit();
#ifdef SHEDITOR #ifdef SHEDITOR

View File

@ -45,12 +45,14 @@
<IntDir>bin-int\Debug_x86_64\SHADE_Engine\</IntDir> <IntDir>bin-int\Debug_x86_64\SHADE_Engine\</IntDir>
<TargetName>SHADE_Engine</TargetName> <TargetName>SHADE_Engine</TargetName>
<TargetExt>.lib</TargetExt> <TargetExt>.lib</TargetExt>
<IncludePath>..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\ktx\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>bin\Release_x86_64\SHADE_Engine\</OutDir> <OutDir>bin\Release_x86_64\SHADE_Engine\</OutDir>
<IntDir>bin-int\Release_x86_64\SHADE_Engine\</IntDir> <IntDir>bin-int\Release_x86_64\SHADE_Engine\</IntDir>
<TargetName>SHADE_Engine</TargetName> <TargetName>SHADE_Engine</TargetName>
<TargetExt>.lib</TargetExt> <TargetExt>.lib</TargetExt>
<IncludePath>..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\ktx\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
@ -58,7 +60,7 @@
<PrecompiledHeaderFile>SHpch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>SHpch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>src;..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\ktx\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
@ -81,7 +83,7 @@
<PrecompiledHeaderFile>SHpch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>SHpch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>src;..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\ktx\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
@ -125,6 +127,7 @@
<ClInclude Include="src\Graphics\Debugging\SHVulkanDebugUtil.h" /> <ClInclude Include="src\Graphics\Debugging\SHVulkanDebugUtil.h" />
<ClInclude Include="src\Graphics\Descriptors\SHDescriptorPoolManager.h" /> <ClInclude Include="src\Graphics\Descriptors\SHDescriptorPoolManager.h" />
<ClInclude Include="src\Graphics\Descriptors\SHDescriptorPoolStorage.h" /> <ClInclude Include="src\Graphics\Descriptors\SHDescriptorPoolStorage.h" />
<ClInclude Include="src\Graphics\Descriptors\SHDescriptorSetUpdater.h" />
<ClInclude Include="src\Graphics\Descriptors\SHVkDescriptorPool.h" /> <ClInclude Include="src\Graphics\Descriptors\SHVkDescriptorPool.h" />
<ClInclude Include="src\Graphics\Descriptors\SHVkDescriptorSetGroup.h" /> <ClInclude Include="src\Graphics\Descriptors\SHVkDescriptorSetGroup.h" />
<ClInclude Include="src\Graphics\Descriptors\SHVkDescriptorSetLayout.h" /> <ClInclude Include="src\Graphics\Descriptors\SHVkDescriptorSetLayout.h" />
@ -135,6 +138,7 @@
<ClInclude Include="src\Graphics\Images\SHImageViewDetails.h" /> <ClInclude Include="src\Graphics\Images\SHImageViewDetails.h" />
<ClInclude Include="src\Graphics\Images\SHVkImage.h" /> <ClInclude Include="src\Graphics\Images\SHVkImage.h" />
<ClInclude Include="src\Graphics\Images\SHVkImageView.h" /> <ClInclude Include="src\Graphics\Images\SHVkImageView.h" />
<ClInclude Include="src\Graphics\Images\SHVkSampler.h" />
<ClInclude Include="src\Graphics\Instance\SHVkInstance.h" /> <ClInclude Include="src\Graphics\Instance\SHVkInstance.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.h" /> <ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.h" /> <ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.h" />
@ -201,6 +205,7 @@
<ClCompile Include="src\Graphics\Debugging\SHVulkanDebugUtil.cpp" /> <ClCompile Include="src\Graphics\Debugging\SHVulkanDebugUtil.cpp" />
<ClCompile Include="src\Graphics\Descriptors\SHDescriptorPoolManager.cpp" /> <ClCompile Include="src\Graphics\Descriptors\SHDescriptorPoolManager.cpp" />
<ClCompile Include="src\Graphics\Descriptors\SHDescriptorPoolStorage.cpp" /> <ClCompile Include="src\Graphics\Descriptors\SHDescriptorPoolStorage.cpp" />
<ClCompile Include="src\Graphics\Descriptors\SHDescriptorSetUpdater.cpp" />
<ClCompile Include="src\Graphics\Descriptors\SHVkDescriptorPool.cpp" /> <ClCompile Include="src\Graphics\Descriptors\SHVkDescriptorPool.cpp" />
<ClCompile Include="src\Graphics\Descriptors\SHVkDescriptorSetGroup.cpp" /> <ClCompile Include="src\Graphics\Descriptors\SHVkDescriptorSetGroup.cpp" />
<ClCompile Include="src\Graphics\Descriptors\SHVkDescriptorSetLayout.cpp" /> <ClCompile Include="src\Graphics\Descriptors\SHVkDescriptorSetLayout.cpp" />
@ -210,6 +215,7 @@
<ClCompile Include="src\Graphics\Framebuffer\SHVkFramebuffer.cpp" /> <ClCompile Include="src\Graphics\Framebuffer\SHVkFramebuffer.cpp" />
<ClCompile Include="src\Graphics\Images\SHVkImage.cpp" /> <ClCompile Include="src\Graphics\Images\SHVkImage.cpp" />
<ClCompile Include="src\Graphics\Images\SHVkImageView.cpp" /> <ClCompile Include="src\Graphics\Images\SHVkImageView.cpp" />
<ClCompile Include="src\Graphics\Images\SHVkSampler.cpp" />
<ClCompile Include="src\Graphics\Instance\SHVkInstance.cpp" /> <ClCompile Include="src\Graphics\Instance\SHVkInstance.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.cpp" /> <ClCompile Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.cpp" /> <ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.cpp" />

View File

@ -177,6 +177,9 @@
<ClInclude Include="src\Graphics\Descriptors\SHDescriptorPoolStorage.h"> <ClInclude Include="src\Graphics\Descriptors\SHDescriptorPoolStorage.h">
<Filter>Graphics\Descriptors</Filter> <Filter>Graphics\Descriptors</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Graphics\Descriptors\SHDescriptorSetUpdater.h">
<Filter>Graphics\Descriptors</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\Descriptors\SHVkDescriptorPool.h"> <ClInclude Include="src\Graphics\Descriptors\SHVkDescriptorPool.h">
<Filter>Graphics\Descriptors</Filter> <Filter>Graphics\Descriptors</Filter>
</ClInclude> </ClInclude>
@ -207,6 +210,9 @@
<ClInclude Include="src\Graphics\Images\SHVkImageView.h"> <ClInclude Include="src\Graphics\Images\SHVkImageView.h">
<Filter>Graphics\Images</Filter> <Filter>Graphics\Images</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Graphics\Images\SHVkSampler.h">
<Filter>Graphics\Images</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\Instance\SHVkInstance.h"> <ClInclude Include="src\Graphics\Instance\SHVkInstance.h">
<Filter>Graphics\Instance</Filter> <Filter>Graphics\Instance</Filter>
</ClInclude> </ClInclude>
@ -399,6 +405,9 @@
<ClCompile Include="src\Graphics\Descriptors\SHDescriptorPoolStorage.cpp"> <ClCompile Include="src\Graphics\Descriptors\SHDescriptorPoolStorage.cpp">
<Filter>Graphics\Descriptors</Filter> <Filter>Graphics\Descriptors</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Graphics\Descriptors\SHDescriptorSetUpdater.cpp">
<Filter>Graphics\Descriptors</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\Descriptors\SHVkDescriptorPool.cpp"> <ClCompile Include="src\Graphics\Descriptors\SHVkDescriptorPool.cpp">
<Filter>Graphics\Descriptors</Filter> <Filter>Graphics\Descriptors</Filter>
</ClCompile> </ClCompile>
@ -426,6 +435,9 @@
<ClCompile Include="src\Graphics\Images\SHVkImageView.cpp"> <ClCompile Include="src\Graphics\Images\SHVkImageView.cpp">
<Filter>Graphics\Images</Filter> <Filter>Graphics\Images</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Graphics\Images\SHVkSampler.cpp">
<Filter>Graphics\Images</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\Instance\SHVkInstance.cpp"> <ClCompile Include="src\Graphics\Instance\SHVkInstance.cpp">
<Filter>Graphics\Instance</Filter> <Filter>Graphics\Instance</Filter>
</ClCompile> </ClCompile>

View File

@ -21,7 +21,11 @@ project "SHADE_Engine"
includedirs includedirs
{ {
"%{prj.location}/src", "%{prj.location}/src",
"%{IncludeDir.assimp}/include", }
externalincludedirs
{
"%{IncludeDir.assimp}/include",
"%{IncludeDir.imgui}", "%{IncludeDir.imgui}",
"%{IncludeDir.imguizmo}", "%{IncludeDir.imguizmo}",
"%{IncludeDir.imnodes}", "%{IncludeDir.imnodes}",
@ -38,6 +42,8 @@ project "SHADE_Engine"
"%{IncludeDir.VULKAN}/Source/SPIRV-Reflect" "%{IncludeDir.VULKAN}/Source/SPIRV-Reflect"
} }
externalwarnings "Off"
libdirs libdirs
{ {
"%{prj.location}/libs", "%{prj.location}/libs",

View File

@ -33,6 +33,8 @@ namespace SHADE
}; };
cmdBufferHdl->GetVkCommandBuffer().copyBuffer(stagingBuffer, vkBuffer, 1, &copyRegion); cmdBufferHdl->GetVkCommandBuffer().copyBuffer(stagingBuffer, vkBuffer, 1, &copyRegion);
} }
// TODO: Need to destroy staging buffer. Obviously not here but after the command has finished executing.
} }
vk::Buffer SHVkBuffer::GetVkBuffer(void) const noexcept vk::Buffer SHVkBuffer::GetVkBuffer(void) const noexcept

View File

@ -48,7 +48,6 @@ namespace SHADE
vk::BufferUsageFlags bufferUsageFlags; vk::BufferUsageFlags bufferUsageFlags;
//! Reference to the allocator //! Reference to the allocator
//VmaAllocator const& vmaAllocator;
std::reference_wrapper<VmaAllocator const> vmaAllocator; std::reference_wrapper<VmaAllocator const> vmaAllocator;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/

View File

@ -202,6 +202,11 @@ namespace SHADE
vkCommandBuffer.endRenderPass(); vkCommandBuffer.endRenderPass();
} }
void SHVkCommandBuffer::NextSubpass(void) noexcept
{
vkCommandBuffer.nextSubpass(commandBufferType == SH_CMD_BUFFER_TYPE::PRIMARY ? vk::SubpassContents::eInline : vk::SubpassContents::eSecondaryCommandBuffers);
}
/***************************************************************************/ /***************************************************************************/
/*! /*!
@ -406,6 +411,31 @@ namespace SHADE
} }
void SHVkCommandBuffer::PipelineBarrier (
vk::PipelineStageFlags srcStage,
vk::PipelineStageFlags dstStage,
vk::DependencyFlags deps,
std::vector<vk::MemoryBarrier> const& memoryBarriers,
std::vector<vk::BufferMemoryBarrier> const& bufferMemoryBarriers,
std::vector<vk::ImageMemoryBarrier> const& imageMemoryBarriers
) const noexcept
{
vkCommandBuffer.pipelineBarrier (
srcStage,
dstStage,
deps,
memoryBarriers,
bufferMemoryBarriers,
imageMemoryBarriers
);
}
//void SHVkCommandBuffer::PipelineBarrier(vk::PipelineStageFlags ) const noexcept
//{
// //vkCommandBuffer.pipelineBarrier()
//}
/***************************************************************************/ /***************************************************************************/
/*! /*!

View File

@ -96,11 +96,12 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void Reset(void); void Reset(void);
// Begins and Ends // Begins, Ends and Nexts
void BeginRecording (void) noexcept; void BeginRecording (void) noexcept;
void EndRecording (void) noexcept; void EndRecording (void) noexcept;
void BeginRenderpass (Handle<SHVkRenderpass> const& renderpassHdl, Handle<SHVkFramebuffer> const& framebufferHdl, vk::Offset2D offset = {0, 0}, vk::Extent2D extent = {0, 0}) noexcept; void BeginRenderpass (Handle<SHVkRenderpass> const& renderpassHdl, Handle<SHVkFramebuffer> const& framebufferHdl, vk::Offset2D offset = {0, 0}, vk::Extent2D extent = {0, 0}) noexcept;
void EndRenderpass (void) noexcept; void EndRenderpass (void) noexcept;
void NextSubpass (void) noexcept;
// Dynamic State // Dynamic State
void SetviewportScissor (float vpWidth, float vpHeight, uint32_t sWidth, uint32_t sHeight, float vpX = 0.0f, float vpY = 0.0f, int32_t sX = 0.0f, int32_t sY = 0.0f, float vpMinDepth = 0.0f, float vpMaxDepth = 1.0f) noexcept; void SetviewportScissor (float vpWidth, float vpHeight, uint32_t sWidth, uint32_t sHeight, float vpX = 0.0f, float vpY = 0.0f, int32_t sX = 0.0f, int32_t sY = 0.0f, float vpMinDepth = 0.0f, float vpMaxDepth = 1.0f) noexcept;
@ -114,6 +115,17 @@ namespace SHADE
void DrawArrays (uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) const noexcept; void DrawArrays (uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) const noexcept;
void DrawIndexed (uint32_t indexCount, uint32_t firstIndex, uint32_t vertexOffset) const noexcept; void DrawIndexed (uint32_t indexCount, uint32_t firstIndex, uint32_t vertexOffset) const noexcept;
// memory barriers
void PipelineBarrier (
vk::PipelineStageFlags srcStage,
vk::PipelineStageFlags dstStage,
vk::DependencyFlags deps,
std::vector<vk::MemoryBarrier> const& memoryBarriers,
std::vector<vk::BufferMemoryBarrier> const& bufferMemoryBarriers,
std::vector<vk::ImageMemoryBarrier> const& imageMemoryBarriers
) const noexcept;
// Push Constant variable setting // Push Constant variable setting
template <typename T> template <typename T>
void SetPushConstantVariable(std::string variableName, T const& data) noexcept void SetPushConstantVariable(std::string variableName, T const& data) noexcept

View File

@ -59,7 +59,7 @@ namespace SHADE
*/ */
/***************************************************************************/ /***************************************************************************/
void SHVulkanDebugUtil::ReportVkWarning(vk::Result vkResult, std::string_view message, std::source_location const& location /*= std::source_location::current()*/) noexcept void SHVulkanDebugUtil::ReportVkWarning(vk::Result vkResult, std::string_view message) noexcept
{ {
//std::cout << location.file_name() << ": " << location.function_name() << "|" << location.line() << "|" << //std::cout << location.file_name() << ": " << location.function_name() << "|" << location.line() << "|" <<
// location.column() << "|: Warning: " << SHDebugUtil::VkResultToString(vkResult) << " | " << message << std::endl; // location.column() << "|: Warning: " << SHDebugUtil::VkResultToString(vkResult) << " | " << message << std::endl;
@ -88,7 +88,7 @@ namespace SHADE
*/ */
/***************************************************************************/ /***************************************************************************/
void SHVulkanDebugUtil::ReportVkError(vk::Result vkResult, std::string_view message, std::source_location const& location /*= std::source_location::current()*/) noexcept void SHVulkanDebugUtil::ReportVkError(vk::Result vkResult, std::string_view message) noexcept
{ {
std::string toLogger = "Vulkan Warning: " + std::string(SHVulkanDebugUtil::VkResultToString(vkResult)) + " | " + std::string(message); std::string toLogger = "Vulkan Warning: " + std::string(SHVulkanDebugUtil::VkResultToString(vkResult)) + " | " + std::string(message);
@ -96,7 +96,7 @@ namespace SHADE
} }
void SHVulkanDebugUtil::ReportVkSuccess(std::string_view message, std::source_location const& location /*= std::source_location::current()*/) noexcept void SHVulkanDebugUtil::ReportVkSuccess(std::string_view message) noexcept
{ {
SHLOGV_INFO(message); SHLOGV_INFO(message);
} }

View File

@ -15,9 +15,9 @@ namespace SHADE
public: public:
static VKAPI_ATTR VkBool32 VKAPI_CALL GenericDebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageSeverityFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData); static VKAPI_ATTR VkBool32 VKAPI_CALL GenericDebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageSeverityFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData);
static void ReportVkWarning(vk::Result vkResult, std::string_view message, std::source_location const& location = std::source_location::current()) noexcept; static void ReportVkWarning(vk::Result vkResult, std::string_view message) noexcept;
static void ReportVkError(vk::Result vkResult, std::string_view message, std::source_location const& location = std::source_location::current()) noexcept; static void ReportVkError(vk::Result vkResult, std::string_view message) noexcept;
static void ReportVkSuccess(std::string_view message, std::source_location const& location = std::source_location::current()) noexcept; static void ReportVkSuccess(std::string_view message) noexcept;
}; };

View File

@ -0,0 +1,84 @@
#include "SHpch.h"
#include "SHDescriptorSetUpdater.h"
namespace SHADE
{
SHDescriptorWriteInfo::SHDescriptorWriteInfo(SHDescriptorWriteInfo&& rhs) noexcept
: descImageInfos{ std::move(rhs.descImageInfos) }
, descBufferInfos{ std::move(rhs.descBufferInfos) }
, descTexelBufferInfos{std::move (rhs.descTexelBufferInfos)}
{
}
SHDescriptorWriteInfo::SHDescriptorWriteInfo(void) noexcept
: descImageInfos{}
, descBufferInfos{}
, descTexelBufferInfos{}
{
}
/***************************************************************************/
/*!
\brief
Links the write infos to the vulkan write descriptor sets.
*/
/***************************************************************************/
void SHDescriptorSetUpdater::LinkInfoToWriteDescSet(void) noexcept
{
for (uint32_t i = 0; i < writeInfos.size(); ++i)
{
writeDescSets[i].pImageInfo = writeInfos[i].descImageInfos.data();
writeDescSets[i].pBufferInfo = writeInfos[i].descBufferInfos.data();
writeDescSets[i].pTexelBufferView = writeInfos[i].descTexelBufferInfos.data();
}
}
SHDescriptorWriteInfo& SHDescriptorWriteInfo::operator=(SHDescriptorWriteInfo&& rhs) noexcept
{
if (&rhs == this)
return *this;
descImageInfos = std::move(rhs.descImageInfos);
descBufferInfos = std::move(rhs.descBufferInfos);
descTexelBufferInfos = std::move(rhs.descTexelBufferInfos);
return *this;
}
SHDescriptorSetUpdater::SHDescriptorSetUpdater(SHDescriptorSetUpdater&& rhs) noexcept
: writeInfos{ std::move(rhs.writeInfos) }
, writeHashMap {std::move (rhs.writeHashMap)}
{
}
SHDescriptorSetUpdater::SHDescriptorSetUpdater(void) noexcept
: writeInfos{}
, writeHashMap{}
{
}
std::vector<vk::WriteDescriptorSet> const& SHDescriptorSetUpdater::GetWriteDescriptorSets(void) const noexcept
{
return writeDescSets;
}
SHDescriptorSetUpdater& SHDescriptorSetUpdater::operator=(SHDescriptorSetUpdater&& rhs) noexcept
{
if (&rhs == this)
return *this;
writeInfos = std::move (rhs.writeInfos);
writeHashMap = std::move (rhs.writeHashMap);
return *this;
}
}

View File

@ -0,0 +1,60 @@
#pragma once
#include <vector>
#include <unordered_map>
#include "Graphics/SHVulkanIncludes.h"
#include "Graphics/Shaders/SHShaderReflected.h"
namespace SHADE
{
// Vulkan doesn't use all of the information when looking at a writeDescriptorSet. It all
// depends on the descriptor type. This struct plays it safe by having members that would
// accommodate all types of descriptors.
class SHDescriptorWriteInfo
{
//! When we want to update a descriptor that is an image, it goes in here
std::vector<vk::DescriptorImageInfo> descImageInfos;
//! When we want to update a descriptor that is a buffer, it goes in here
std::vector<vk::DescriptorBufferInfo> descBufferInfos;
//! When we want to update a descriptor that is an texel buffer, it goes in here
std::vector<vk::BufferView> descTexelBufferInfos;
public:
SHDescriptorWriteInfo (void) noexcept;
SHDescriptorWriteInfo (SHDescriptorWriteInfo&& rhs) noexcept;
SHDescriptorWriteInfo& operator= (SHDescriptorWriteInfo&& rhs) noexcept;
friend class SHVkDescriptorSetGroup;
friend class SHDescriptorSetUpdater;
};
class SHDescriptorSetUpdater
{
private:
//! When we want to update descriptor sets, this will get passed into vkUpdateDescriptorSets.
//! Each write will correspond to a binding from a set. If the binding is a variable
//! sized binding, pImageInfo (e.g.) will point to an array of vk::DescriptorImageInfo.
std::vector<SHDescriptorWriteInfo> writeInfos;
//! When we want to update a write, we need to use this to identify the index of the write.
std::unordered_map<BindingAndSetHash, uint32_t> writeHashMap;
//! We keep this here because we want this to be immediately passable to vkUpdateDescriptorSets
std::vector<vk::WriteDescriptorSet> writeDescSets;
void LinkInfoToWriteDescSet(void) noexcept;
public:
SHDescriptorSetUpdater (void) noexcept;
SHDescriptorSetUpdater(SHDescriptorSetUpdater&& rhs) noexcept;
SHDescriptorSetUpdater& operator= (SHDescriptorSetUpdater&& rhs) noexcept;
public:
std::vector<vk::WriteDescriptorSet> const& GetWriteDescriptorSets (void) const noexcept;
friend class SHVkDescriptorSetGroup;
};
}

View File

@ -42,9 +42,11 @@ namespace SHADE
{ {
// Create the layout for each concurrent frame // Create the layout for each concurrent frame
std::vector<vk::DescriptorSetLayout> vkLayouts{ layouts.size() }; std::vector<vk::DescriptorSetLayout> vkLayouts{ layouts.size() };
for (auto& layout : layouts)
//for (auto& layout : layouts)
for (uint32_t i = 0; i < layouts.size(); ++i)
{ {
vkLayouts.push_back(layout->GetVkHandle()); vkLayouts.push_back(layouts[i]->GetVkHandle());
} }
// Check for variable descriptor count // Check for variable descriptor count
@ -67,6 +69,66 @@ namespace SHADE
// allocate descriptor sets // allocate descriptor sets
descSets = device->GetVkLogicalDevice().allocateDescriptorSets(DESC_SET_LAYOUT_CREATE_INFO); descSets = device->GetVkLogicalDevice().allocateDescriptorSets(DESC_SET_LAYOUT_CREATE_INFO);
// Now we want to prepare the write descriptor sets for writing later.
for (uint32_t i = 0; i < layouts.size(); ++i)
{
auto const& bindings = layouts[i]->GetBindings();
for (auto& binding : bindings)
{
BindingAndSetHash writeHash = binding.BindPoint;
writeHash |= static_cast<uint64_t>(i) << 32;
// new write for the binding
updater.writeInfos.emplace_back();
updater.writeHashMap.try_emplace(writeHash, updater.writeInfos.size() - 1);
auto& writeInfo = updater.writeInfos.back();
updater.writeDescSets.emplace_back();
auto& writeDescSet = updater.writeDescSets.back();
// Initialize info for write
writeDescSet.descriptorType = binding.Type;
writeDescSet.dstArrayElement = 0;
writeDescSet.dstSet = descSets[i];
writeDescSet.dstBinding = binding.BindPoint;
// Descriptor count for the write descriptor set. Usually this is set to 1, but if binding is variable sized, set to info passed in
uint32_t descriptorCount = (binding.flags & vk::DescriptorBindingFlagBits::eVariableDescriptorCount) ? variableDescCounts[i] : 1;
writeDescSet.descriptorCount = descriptorCount;
switch (binding.Type)
{
//case vk::DescriptorType::eSampler:
//case vk::DescriptorType::eSampledImage:
case vk::DescriptorType::eCombinedImageSampler:
writeInfo.descImageInfos.resize(descriptorCount);
break;
//case vk::DescriptorType::eStorageImage:
// break;
case vk::DescriptorType::eUniformTexelBuffer:
case vk::DescriptorType::eStorageTexelBuffer:
case vk::DescriptorType::eUniformBuffer:
case vk::DescriptorType::eStorageBuffer:
writeInfo.descImageInfos.resize (descriptorCount);
break;
//case vk::DescriptorType::eUniformBufferDynamic:
// break;
//case vk::DescriptorType::eStorageBufferDynamic:
// break;
//case vk::DescriptorType::eInputAttachment:
// break;
//case vk::DescriptorType::eInlineUniformBlock:
// break;
default:
break;
}
}
}
// Link all the writeDescSet data for vkUpdateDescriptorSets to write to the linked descriptors
updater.LinkInfoToWriteDescSet();
} }
/***************************************************************************/ /***************************************************************************/
@ -82,4 +144,45 @@ namespace SHADE
if (!descSets.empty()) if (!descSets.empty())
device->GetVkLogicalDevice().freeDescriptorSets(descPool->GetVkHandle(), descSets); device->GetVkLogicalDevice().freeDescriptorSets(descPool->GetVkHandle(), descSets);
} }
/***************************************************************************/
/*!
\brief
Modifies a descriptor write info. #NoteToSelf: This function does NOT
need to modify the writeDescSets. Those are already linked before.
\param imageViewsAndSamplers
Image and view samplers
*/
/***************************************************************************/
void SHVkDescriptorSetGroup::ModifyWriteDescImage(uint32_t set, uint32_t binding, std::vector<std::pair<vk::ImageView, vk::Sampler>> const& imageViewsAndSamplers) noexcept
{
// Find the target writeDescSet
BindingAndSetHash writeHash = binding;
writeHash |= static_cast<uint64_t>(set) << 32;
auto& writeInfo = updater.writeInfos[updater.writeHashMap.at(writeHash)];
if (imageViewsAndSamplers.size() > writeInfo.descImageInfos.size())
{
SHLOG_ERROR("Attempting write too many descriptors into descriptor set. Failed to write to vk::WriteDescriptorSet. ");
}
for (uint32_t i = 0; i < imageViewsAndSamplers.size(); ++i)
{
// write sampler and image view
auto& ivs = imageViewsAndSamplers[i];
writeInfo.descImageInfos[i].imageView = ivs.first;
writeInfo.descImageInfos[i].sampler = ivs.second;
}
}
void SHVkDescriptorSetGroup::UpdateDescriptorSet(void) noexcept
{
device->UpdateDescriptorSets(updater.GetWriteDescriptorSets());
}
} }

View File

@ -1,71 +1,89 @@
#pragma once #pragma once
// Project Includes // Project Includes
#include "Graphics/SHVulkanIncludes.h" #include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h" #include "Resource/Handle.h"
#include "Graphics/Shaders/SHShaderReflected.h"
#include "SHDescriptorSetUpdater.h"
namespace SHADE namespace SHADE
{ {
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Forward Declarations */ /* Forward Declarations */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
class SHVkLogicalDevice; class SHVkLogicalDevice;
class SHVkDescriptorPool; class SHVkDescriptorPool;
class SHVkDescriptorSetLayout; class SHVkDescriptorSetLayout;
/*---------------------------------------------------------------------------------*/
/* Type Definitions */ /*---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/ /* Type Definitions */
/*---------------------------------------------------------------------------------*/
/// <summary>
///
/// </summary>
class SHVkDescriptorSetGroup
{
public:
/*-----------------------------------------------------------------------------*/
/* Constructor/Destructors */
/*-----------------------------------------------------------------------------*/
/// <summary> /// <summary>
/// /// Constructs a Descriptor Set with the specified layout using the specified
/// pool meant for use with the specified surface. This Set will be created with
/// multiple Vulkan Descriptor Set objects based on the max number of concurrent
/// frames for the specified surface.
/// </summary> /// </summary>
class SHVkDescriptorSetGroup /// <param name="device">Vulkan logical device used to create the Set.</param>
{ /// <param name="pool">Descriptor Pool used to create the Set.</param>
public: /// <param name="layout">Descriptor Set Layout to create the Set with.</param>
/*-----------------------------------------------------------------------------*/ SHVkDescriptorSetGroup(Handle<SHVkLogicalDevice> deviceHdl, Handle<SHVkDescriptorPool> pool,
/* Constructor/Destructors */ std::vector<Handle<SHVkDescriptorSetLayout>> const& layouts,
/*-----------------------------------------------------------------------------*/ std::vector<uint32_t> const& variableDescCounts);
/// <summary> SHVkDescriptorSetGroup(const SHVkDescriptorSetGroup&) = delete;
/// Constructs a Descriptor Set with the specified layout using the specified SHVkDescriptorSetGroup(SHVkDescriptorSetGroup&& rhs) noexcept = default;
/// pool meant for use with the specified surface. This Set will be created with /// <summary>
/// multiple Vulkan Descriptor Set objects based on the max number of concurrent /// Destructor which will unload and deallocate all resources for this Descriptor Set.
/// frames for the specified surface. /// </summary>
/// </summary> ~SHVkDescriptorSetGroup() noexcept;
/// <param name="device">Vulkan logical device used to create the Set.</param>
/// <param name="pool">Descriptor Pool used to create the Set.</param>
/// <param name="layout">Descriptor Set Layout to create the Set with.</param>
SHVkDescriptorSetGroup(Handle<SHVkLogicalDevice> deviceHdl, Handle<SHVkDescriptorPool> pool,
std::vector<Handle<SHVkDescriptorSetLayout>> const& layouts,
std::vector<uint32_t> const& variableDescCounts);
SHVkDescriptorSetGroup(const SHVkDescriptorSetGroup&) = delete;
SHVkDescriptorSetGroup(SHVkDescriptorSetGroup&& rhs) noexcept = default;
/// <summary>
/// Destructor which will unload and deallocate all resources for this Descriptor Set.
/// </summary>
~SHVkDescriptorSetGroup() noexcept;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Overloaded Operators */ /* Overloaded Operators */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
SHVkDescriptorSetGroup& operator=(const SHVkDescriptorSetGroup&) = delete; SHVkDescriptorSetGroup& operator=(const SHVkDescriptorSetGroup&) = delete;
SHVkDescriptorSetGroup& operator=(SHVkDescriptorSetGroup&& rhs) noexcept = default; SHVkDescriptorSetGroup& operator=(SHVkDescriptorSetGroup&& rhs) noexcept = default;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Getter Functions */ /* Descriptor set writing */
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/// <summary> void ModifyWriteDescImage (uint32_t set, uint32_t binding, std::vector<std::pair<vk::ImageView, vk::Sampler>> const& imageViewsAndSamplers) noexcept;
/// Retrieves the handle to the Vulkan Descriptor Set handle. void UpdateDescriptorSet (void) noexcept;
/// </summary>
/// <returns>Handle to the Vulkan Descriptor Set.</returns>
[[nodiscard]]
inline const std::vector<vk::DescriptorSet>& GetVkHandle() { return descSets; }
private: /*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/ /* Getter Functions */
/* Data Members */ /*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/ /// <summary>
Handle<SHVkLogicalDevice> device; /// Retrieves the handle to the Vulkan Descriptor Set handle.
Handle<SHVkDescriptorPool> descPool; /// </summary>
std::vector<vk::DescriptorSet> descSets; /// <returns>Handle to the Vulkan Descriptor Set.</returns>
}; [[nodiscard]]
inline const std::vector<vk::DescriptorSet>& GetVkHandle() { return descSets; }
private:
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
//! Device required to allocate descriptor sets
Handle<SHVkLogicalDevice> device;
//! Descriptor pool to allocate descriptor sets
Handle<SHVkDescriptorPool> descPool;
//! Descriptor sets
std::vector<vk::DescriptorSet> descSets;
//! for updating descriptor sets. We want to cache this so that we don't create the
//! write structs at runtime.
SHDescriptorSetUpdater updater;
};
} }

View File

@ -85,6 +85,11 @@ namespace SHADE
device->GetVkLogicalDevice().destroyDescriptorSetLayout(setLayout); device->GetVkLogicalDevice().destroyDescriptorSetLayout(setLayout);
} }
std::vector<SHVkDescriptorSetLayout::Binding> const& SHVkDescriptorSetLayout::GetBindings(void) const noexcept
{
return layoutDesc;
}
SHVkDescriptorSetLayout& SHVkDescriptorSetLayout::operator=(SHVkDescriptorSetLayout&& rhs) noexcept SHVkDescriptorSetLayout& SHVkDescriptorSetLayout::operator=(SHVkDescriptorSetLayout&& rhs) noexcept
{ {
if (&rhs == this) if (&rhs == this)

View File

@ -96,6 +96,7 @@ namespace SHADE
/// </summary> /// </summary>
/// <returns>Handle to the Vulkan Descriptor Set Layout handle.</returns> /// <returns>Handle to the Vulkan Descriptor Set Layout handle.</returns>
inline const vk::DescriptorSetLayout& GetVkHandle() const { return setLayout; } inline const vk::DescriptorSetLayout& GetVkHandle() const { return setLayout; }
std::vector<Binding> const& GetBindings (void) const noexcept;
private: private:
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/

View File

@ -418,7 +418,12 @@ namespace SHADE
/***************************************************************************/ /***************************************************************************/
Handle<SHVkImage> SHVkLogicalDevice::CreateImage(uint32_t w, uint32_t h, uint8_t levels, vk::Format format, vk::ImageUsageFlags usage, vk::ImageCreateFlags create) const noexcept Handle<SHVkImage> SHVkLogicalDevice::CreateImage(uint32_t w, uint32_t h, uint8_t levels, vk::Format format, vk::ImageUsageFlags usage, vk::ImageCreateFlags create) const noexcept
{ {
return SHVkInstance::GetResourceManager().Create<SHVkImage>(std::cref(vmaAllocator), w, h, levels, format, usage, create); return SHVkInstance::GetResourceManager().Create<SHVkImage>(&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
{
return SHVkInstance::GetResourceManager().Create<SHVkImage>(&vmaAllocator, imageDetails, data, dataSize, inMipOffsets, memUsage, allocFlags);
} }
/***************************************************************************/ /***************************************************************************/
@ -547,6 +552,22 @@ namespace SHADE
return SHVkInstance::GetResourceManager().Create<SHVkSemaphore>(GetHandle()); return SHVkInstance::GetResourceManager().Create<SHVkSemaphore>(GetHandle());
} }
/***************************************************************************/
/*!
\brief
Writes to descriptor sets.
\param writeDescSets
Descriptor sets to write to.
*/
/***************************************************************************/
void SHVkLogicalDevice::UpdateDescriptorSets(std::vector<vk::WriteDescriptorSet> const& writeDescSets) noexcept
{
vkLogicalDevice.updateDescriptorSets(writeDescSets, {});
}
/***************************************************************************/ /***************************************************************************/
/*! /*!

View File

@ -19,6 +19,7 @@
#include "vk_mem_alloc.h" #include "vk_mem_alloc.h"
#include "Graphics/Descriptors/SHVkDescriptorPool.h" #include "Graphics/Descriptors/SHVkDescriptorPool.h"
#include "Graphics/Descriptors/SHVkDescriptorSetLayout.h" #include "Graphics/Descriptors/SHVkDescriptorSetLayout.h"
#include "Graphics/Images/SHVkImage.h"
namespace SHADE namespace SHADE
{ {
@ -29,7 +30,6 @@ namespace SHADE
class SHVkSurface; class SHVkSurface;
class SHVkSwapchain; class SHVkSwapchain;
class SHVkBuffer; class SHVkBuffer;
class SHVkImage;
class SHVkFence; class SHVkFence;
class SHVkSemaphore; class SHVkSemaphore;
class SHVkShaderModule; class SHVkShaderModule;
@ -38,6 +38,7 @@ namespace SHADE
class SHVkFramebuffer; class SHVkFramebuffer;
class SHVkImageView; class SHVkImageView;
class SHShaderBlockInterface; class SHShaderBlockInterface;
class SHVkDescriptorSetGroup;
/***************************************************************************/ /***************************************************************************/
/*! /*!
@ -138,14 +139,23 @@ namespace SHADE
) const noexcept; ) const noexcept;
Handle<SHVkImage> CreateImage ( Handle<SHVkImage> CreateImage (
uint32_t w, uint32_t w,
uint32_t h, uint32_t h,
uint8_t levels, uint8_t levels,
vk::Format format, vk::Format format,
vk::ImageUsageFlags usage, vk::ImageUsageFlags usage,
vk::ImageCreateFlags create vk::ImageCreateFlags create
) const noexcept; ) const noexcept;
Handle<SHVkImage> CreateImage (
SHImageCreateParams const& imageDetails,
unsigned char* data,
uint32_t dataSize,
std::span<uint32_t> inMipOffsets,
VmaMemoryUsage memUsage,
VmaAllocationCreateFlags allocFlags
) noexcept;
Handle<SHVkShaderModule> CreateShaderModule ( Handle<SHVkShaderModule> CreateShaderModule (
std::vector<uint32_t> const& binaryData, std::vector<uint32_t> const& binaryData,
std::string entryPoint, std::string entryPoint,
@ -170,6 +180,8 @@ namespace SHADE
Handle<SHVkFence> CreateFence (void) const noexcept; Handle<SHVkFence> CreateFence (void) const noexcept;
Handle<SHVkSemaphore> CreateSemaphore (void) const noexcept; Handle<SHVkSemaphore> CreateSemaphore (void) const noexcept;
void UpdateDescriptorSets (std::vector<vk::WriteDescriptorSet> const& writeDescSets) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/

View File

@ -5,14 +5,88 @@
#include "Tools/SHLogger.h" #include "Tools/SHLogger.h"
#include "SHVkImageView.h" #include "SHVkImageView.h"
#include "Graphics/Instance/SHVkInstance.h" #include "Graphics/Instance/SHVkInstance.h"
#include "Graphics/Buffers/SHVkBuffer.h"
namespace SHADE namespace SHADE
{ {
/***************************************************************************/
/*!
\brief
If an image is a GPU only resource, we need to prep a staging buffer
to use for transferring data to the GPU. #NoteToSelf: I don't really
like this because its duplicate code. Should try to find a way to utilize
the logical device for this.
\param data
Data to transfer.
\param srcSize
Size in bytes of the data.
*/
/***************************************************************************/
void SHVkImage::PrepStagingBuffer(void* data, uint32_t srcSize) noexcept
{
// For creation of buffer
vk::BufferCreateInfo bufferInfo{};
// size stored same as GPU buffer
bufferInfo.size = srcSize;
// We just want to set the transfer bit
bufferInfo.usage = vk::BufferUsageFlagBits::eTransferSrc;
// sharing mode exclusive
bufferInfo.sharingMode = vk::SharingMode::eExclusive;
// Set to auto detect bits
VmaAllocationCreateInfo allocCreateInfo{};
allocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
// We want to just write all at once. Using random access bit could make this slow
allocCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
// parameters of a vmaAllocation retrieved via vmaGetAllocationInfo
VmaAllocationInfo allocInfo;
// results of allocation
VmaAllocation stagingAlloc;
// To get around VMA's usage for C version of vulkan, create a temp first...,
VkBuffer tempBuffer{};
// Create the buffer...
vmaCreateBuffer(*vmaAllocator,
&bufferInfo.operator VkBufferCreateInfo & (), // TODO: Verify if this works (can use renderdoc to check buffer variables?)
&allocCreateInfo,
&tempBuffer, &stagingAlloc, &allocInfo);
// then assign it to the hpp version
stagingBuffer = tempBuffer;
// Just map, copy then unmap
void* stagingBufferMappedPtr = nullptr;
vmaMapMemory(*vmaAllocator, stagingAlloc, &stagingBufferMappedPtr);
if (stagingBufferMappedPtr)
std::memcpy(static_cast<uint8_t*>(stagingBufferMappedPtr), static_cast<uint8_t*>(data), srcSize);
const VkDeviceSize offsets = 0;
const VkDeviceSize sizes = srcSize;
vmaFlushAllocations(*vmaAllocator, 1, &stagingAlloc, &offsets, &sizes);
vmaUnmapMemory(*vmaAllocator, stagingAlloc);
}
SHVkImage::SHVkImage( SHVkImage::SHVkImage(
VmaAllocator const& vmaAllocator, VmaAllocator const* allocator,
SHImageCreateParams const& imageDetails, SHImageCreateParams const& imageDetails,
VmaMemoryUsage memUsage, unsigned char* data,
VmaAllocationCreateFlags allocFlags uint32_t dataSize,
std::span<uint32_t> inMipOffsets,
VmaMemoryUsage memUsage,
VmaAllocationCreateFlags allocFlags
) noexcept ) noexcept
: imageType { imageDetails.imageType } : imageType { imageDetails.imageType }
, width{ imageDetails.width } , width{ imageDetails.width }
@ -23,12 +97,14 @@ namespace SHADE
, imageFormat{ imageDetails.imageFormat } , imageFormat{ imageDetails.imageFormat }
, usageFlags{} , usageFlags{}
, createFlags{} , createFlags{}
, vmaAllocator{allocator}
, mipOffsets { inMipOffsets }
, boundToCoherent{false}
, randomAccessOptimized {false}
, mappedPtr{nullptr}
{ {
for (auto& bit : imageDetails.usageBits) usageFlags = imageDetails.usageFlags;
usageFlags |= bit; createFlags = imageDetails.createFlags;
for (auto& bit : imageDetails.createBits)
createFlags |= bit;
// If marked as 2D array compatible, image type MUST be 3D // If marked as 2D array compatible, image type MUST be 3D
if (createFlags & vk::ImageCreateFlagBits::e2DArrayCompatible) if (createFlags & vk::ImageCreateFlagBits::e2DArrayCompatible)
@ -64,58 +140,52 @@ namespace SHADE
VmaAllocationInfo allocInfo{}; VmaAllocationInfo allocInfo{};
VkImage tempImage; VkImage tempImage;
vmaCreateImage(vmaAllocator, &imageCreateInfo.operator VkImageCreateInfo&(), &allocCreateInfo, &tempImage, &alloc, &allocInfo); auto result = vmaCreateImage(*vmaAllocator, &imageCreateInfo.operator VkImageCreateInfo&(), &allocCreateInfo, &tempImage, &alloc, &allocInfo);
if (result != VK_SUCCESS)
SHVulkanDebugUtil::ReportVkError(vk::Result(result), "Failed to create vulkan image. ");
else
SHVulkanDebugUtil::ReportVkSuccess("Successfully created image. ");
vkImage = tempImage; vkImage = tempImage;
//if (allocFlags & ) // At this point the image and device memory have been created.
if (allocFlags & VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT)
randomAccessOptimized = true;
// TODO: This constructor can only create a GPU only resource for now. Due to time constraint, I was trying to create a ctor
// fast to finish up the ImGUI backend. In the future, there definitely needs to be more versatility to the constructor.
// Get the memory property flags
VkMemoryPropertyFlags memPropFlags;
vmaGetAllocationMemoryProperties(*vmaAllocator, alloc, &memPropFlags);
// mainly host visible. Can be cached (need to flush/invalidate), uncached (always coherent) and coherent (virtual).
//if (memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
//{
// // If memory is marked to be coherent between CPU and GPU (no need flush/invalidate) (TODO: Verify if VMA_ALLOCATION_CREATE_MAPPED_BIT is used when VMA_MEMORY_USAGE_AUTO is set)
// // TODO: also verify that coherent bit = pointer is already mapped
// if (memPropFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
// {
// boundToCoherent = true;
// mappedPtr = allocInfo.pMappedData;
// }
// else
// mappedPtr = nullptr;
// if (data)
// MapWriteUnmap(data, srcSize, 0, 0);
//}
//else
//{
// We can prep first so that we can do transfers later via 1 cmd buffer recording
PrepStagingBuffer(data, dataSize);
//}
} }
/***************************************************************************/ SHVkImage::SHVkImage(VmaAllocator const* allocator, uint32_t w, uint32_t h, uint8_t levels, vk::Format format, vk::ImageUsageFlags usage, vk::ImageCreateFlags create) noexcept
/*!
\brief
This is mainly used for images that aren't created internally because
they cannot be created in the traditional way (e.g. swapchain images).
\param inVkImage
Image already created outside
\param width
Width of the image
\param height
Height of the image
\param depth
Depth of the image
\param levels
Number of levels in the image
\param arrayLayers
if the image is an array, this value will be > 1.
\param imageFormat
Format of the image
*/
/***************************************************************************/
SHVkImage::SHVkImage(vk::Image inVkImage, vk::ImageType type, uint32_t inWidth, uint32_t inHeight, uint32_t inDepth, uint32_t arrayLayers, uint8_t levels, vk::Format format, vk::ImageUsageFlags flags) noexcept
: vkImage (inVkImage)
, width{ inWidth }
, height{ inHeight }
, depth{ inDepth }
, mipLevelCount{ levels }
, layerCount{ arrayLayers }
, imageFormat{ format }
, usageFlags{flags}
, alloc{}
, imageType{type}
, createFlags{}
{
}
SHVkImage::SHVkImage(VmaAllocator const& vmaAllocator, uint32_t w, uint32_t h, uint8_t levels, vk::Format format, vk::ImageUsageFlags usage, vk::ImageCreateFlags create) noexcept
: width {w} : width {w}
, height{h} , height{h}
, depth {1} , depth {1}
@ -124,6 +194,7 @@ namespace SHADE
, imageFormat{format} , imageFormat{format}
, usageFlags{usage} , usageFlags{usage}
, createFlags {create} , createFlags {create}
, vmaAllocator {allocator}
{ {
vk::ImageCreateInfo imageCreateInfo{}; vk::ImageCreateInfo imageCreateInfo{};
imageCreateInfo.imageType = vk::ImageType::e2D; imageCreateInfo.imageType = vk::ImageType::e2D;
@ -149,7 +220,7 @@ namespace SHADE
VmaAllocationInfo allocInfo{}; VmaAllocationInfo allocInfo{};
VkImage tempImage; VkImage tempImage;
auto result = vmaCreateImage(vmaAllocator, &imageCreateInfo.operator VkImageCreateInfo & (), &allocCreateInfo, &tempImage, &alloc, &allocInfo); auto result = vmaCreateImage(*vmaAllocator, &imageCreateInfo.operator VkImageCreateInfo & (), &allocCreateInfo, &tempImage, &alloc, &allocInfo);
vkImage = tempImage; vkImage = tempImage;
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
@ -163,6 +234,86 @@ namespace SHADE
return SHVkInstance::GetResourceManager().Create<SHVkImageView>(inLogicalDeviceHdl, parent, createParams); return SHVkInstance::GetResourceManager().Create<SHVkImageView>(inLogicalDeviceHdl, parent, createParams);
} }
void SHVkImage::TransferToDeviceResource(Handle<SHVkCommandBuffer> const& cmdBufferHdl) noexcept
{
// prepare copy regions
std::vector<vk::BufferImageCopy> copyRegions{mipOffsets.size()};
for (uint32_t i = 0; i < mipOffsets.size(); ++i)
{
copyRegions[i].bufferOffset = mipOffsets[i];
copyRegions[i].bufferRowLength = 0; // for padding
copyRegions[i].bufferImageHeight = 0; // for padding
copyRegions[i].imageSubresource.aspectMask = vk::ImageAspectFlagBits::eColor; // TODO: Need to change this to base it off image format.
copyRegions[i].imageSubresource.mipLevel = i;
copyRegions[i].imageSubresource.baseArrayLayer = 0; // TODO: Array textures not supported yet
copyRegions[i].imageSubresource.layerCount = layerCount;
copyRegions[i].imageOffset = vk::Offset3D{ 0,0,0 };
copyRegions[i].imageExtent = vk::Extent3D{ width >> i, height >> i, 1 };
}
}
/***************************************************************************/
/*!
\brief
Does not perform any image transitions but prepares a barrier for image
transitioning. Pipeline barrier will be issued outside this call after
this preparation function, or at least, it should be.
\param oldLayout
Old layout of the image.
\param newLayout
new layout of the image to transition to.
\param barrier
Barrier to modify to prepare the image for transitioning.
*/
/***************************************************************************/
void SHVkImage::PrepareImageTransition(vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::ImageMemoryBarrier& barrier) noexcept
{
barrier.oldLayout = oldLayout;
barrier.newLayout = newLayout;
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.image = vkImage;
barrier.subresourceRange.aspectMask = vk::ImageAspectFlagBits::eColor; // TODO: Need to change this to base it off image format.
barrier.subresourceRange.baseMipLevel = 0;
barrier.subresourceRange.levelCount = mipLevelCount;
barrier.subresourceRange.baseArrayLayer = 0;
barrier.subresourceRange.layerCount = layerCount;
vk::PipelineStageFlagBits srcStage = vk::PipelineStageFlagBits::eTopOfPipe;
vk::PipelineStageFlagBits dstStage = vk::PipelineStageFlagBits::eTopOfPipe;
if (oldLayout == vk::ImageLayout::eUndefined && newLayout == vk::ImageLayout::eTransferDstOptimal)
{
srcStage = vk::PipelineStageFlagBits::eTopOfPipe;
dstStage = vk::PipelineStageFlagBits::eTransfer;
barrier.srcAccessMask = vk::AccessFlagBits::eNone;
barrier.dstAccessMask = vk::AccessFlagBits::eTransferWrite;
}
else if (oldLayout == vk::ImageLayout::eTransferDstOptimal && newLayout == vk::ImageLayout::eShaderReadOnlyOptimal)
{
srcStage = vk::PipelineStageFlagBits::eTransfer;
// TODO, what if we want to access in compute shader
dstStage = vk::PipelineStageFlagBits::eFragmentShader;
barrier.srcAccessMask = vk::AccessFlagBits::eTransferWrite;
barrier.dstAccessMask = vk::AccessFlagBits::eShaderRead;
}
else
{
SHLOG_ERROR("Image layouts are invalid. ");
}
}
void SHVkImage::LinkWithExteriorImage(vk::Image inVkImage, vk::ImageType type, uint32_t inWidth, uint32_t inHeight, uint32_t inDepth, uint32_t layers, uint8_t levels, vk::Format format, vk::ImageUsageFlags flags) noexcept void SHVkImage::LinkWithExteriorImage(vk::Image inVkImage, vk::ImageType type, uint32_t inWidth, uint32_t inHeight, uint32_t inDepth, uint32_t layers, uint8_t levels, vk::Format format, vk::ImageUsageFlags flags) noexcept
{ {
vkImage = inVkImage; vkImage = inVkImage;

View File

@ -10,6 +10,7 @@ namespace SHADE
{ {
class SHVkLogicalDevice; class SHVkLogicalDevice;
class SHVkImageView; class SHVkImageView;
class SHVkCommandBuffer;
struct SHImageCreateParams struct SHImageCreateParams
{ {
@ -35,10 +36,10 @@ namespace SHADE
vk::Format imageFormat; vk::Format imageFormat;
//! Image usage bits //! Image usage bits
std::span<vk::ImageUsageFlagBits> usageBits; vk::ImageUsageFlags usageFlags;
//! Image create flags //! Image create flags
std::span<vk::ImageCreateFlagBits> createBits; vk::ImageCreateFlags createFlags;
}; };
class SHVkImage class SHVkImage
@ -47,6 +48,12 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* PRIVATE MEMBER VARIABLES */ /* PRIVATE MEMBER VARIABLES */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
//! Pointer to the vma allocator. #NoteToSelf: Not super proud of this being a pointer.
//! The only reason why this is a pointer is because a reference_wrapper cannot be default constructed.
//! And the reason why we want a default constructor is because sometimes we don't want to create images
//! but merely link them from outside (swapchain images)
VmaAllocator const* vmaAllocator;
//! 1D, 2D or 3D //! 1D, 2D or 3D
vk::ImageType imageType = vk::ImageType::e2D; vk::ImageType imageType = vk::ImageType::e2D;
@ -80,22 +87,46 @@ namespace SHADE
//! allocation object containing details of an allocation //! allocation object containing details of an allocation
VmaAllocation alloc{}; VmaAllocation alloc{};
//! Whether or not this image is HOST_VISIBLE and random access optimized
bool randomAccessOptimized;
//! Whether or not the memory the image is bound to is memory coherent (updates on CPU can be seen on GPU without flushing cache)
bool boundToCoherent;
//! Persistently mapped pointer if applicable (will be void if image is
//! not created with the correct flags). Note that this is only used for
//! persistent mapping. One time updates do not use this pointer.
void* mappedPtr;
//! Staging buffer for images purely in the GPU
vk::Buffer stagingBuffer;
//! Mipmap offsets for initializing the vk::BufferImageCopy during transfer to GPU resource
std::span<uint32_t> mipOffsets;
/*-----------------------------------------------------------------------*/
/* PRIVATE MEMBER FUNCTIONS */
/*-----------------------------------------------------------------------*/
void PrepStagingBuffer(void* data, uint32_t srcSize) noexcept;
public: public:
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* CTOR AND DTOR */ /* CTOR AND DTOR */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
SHVkImage(void) noexcept = default; SHVkImage(void) noexcept = default;
// TODO: Might need to add flags to parameters
SHVkImage( SHVkImage(
VmaAllocator const& vmaAllocator, VmaAllocator const* allocator,
SHImageCreateParams const& imageDetails, SHImageCreateParams const& imageDetails,
VmaMemoryUsage memUsage, unsigned char* data,
VmaAllocationCreateFlags allocFlags uint32_t dataSize,
std::span<uint32_t> inMipOffsets,
VmaMemoryUsage memUsage,
VmaAllocationCreateFlags allocFlags
) noexcept; ) noexcept;
SHVkImage(vk::Image inVkImage, vk::ImageType type, uint32_t inWidth, uint32_t inHeight, uint32_t inDepth, uint32_t arrayLayers, uint8_t levels, vk::Format format, vk::ImageUsageFlags flags) noexcept; SHVkImage(VmaAllocator const* allocator, uint32_t w, uint32_t h, uint8_t levels, vk::Format format, vk::ImageUsageFlags usage, vk::ImageCreateFlags create) noexcept;
SHVkImage(VmaAllocator const& vmaAllocator, uint32_t w, uint32_t h, uint8_t levels, vk::Format format, vk::ImageUsageFlags usage, vk::ImageCreateFlags create) noexcept;
SHVkImage(SHVkImage&& rhs) noexcept = default; SHVkImage(SHVkImage&& rhs) noexcept = default;
SHVkImage& operator=(SHVkImage && rhs) noexcept = default; SHVkImage& operator=(SHVkImage && rhs) noexcept = default;
@ -103,7 +134,9 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* PUBLIC MEMBER FUNCTIONS */ /* PUBLIC MEMBER FUNCTIONS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
Handle<SHVkImageView> CreateImageView(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, Handle<SHVkImage> const& parent, SHImageViewDetails const& createParams) const noexcept; Handle<SHVkImageView> CreateImageView (Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, Handle<SHVkImage> const& parent, SHImageViewDetails const& createParams) const noexcept;
void TransferToDeviceResource (Handle<SHVkCommandBuffer> const& cmdBufferHdl) noexcept;
void PrepareImageTransition (vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::ImageMemoryBarrier& barrier) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* GETTERS AND SETTERS */ /* GETTERS AND SETTERS */

View File

@ -0,0 +1,7 @@
#include "SHpch.h"
#include "SHVkSampler.h"
namespace SHADE
{
}

View File

@ -0,0 +1,27 @@
#pragma once
#include "Graphics/SHVulkanIncludes.h"
namespace SHADE
{
struct SHVkSamplerParams
{
vk::Filter minFilter;
vk::Filter maxFilter;
//vk::Filter maxFilter;
};
class SHVkSampler
{
private:
//! The vulkan sampler handler
vk::Sampler vkSampler;
public:
SHVkSampler () noexcept;
SHVkSampler (SHVkSampler&& rhs) noexcept;
SHVkSampler&& operator=(SHVkSampler&& rhs) noexcept;
};
}

View File

@ -84,8 +84,6 @@ namespace SHADE
//commandBuffers[i] = commandPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY); // works //commandBuffers[i] = commandPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY); // works
} }
descPool = device->CreateDescriptorPools(); descPool = device->CreateDescriptorPools();

View File

@ -117,7 +117,7 @@ namespace SHADE
dirty = isDirty; dirty = isDirty;
} }
std::tuple<uint32_t, uint32_t, vk::Format> SHVertexInputState::GetInfoFromAttribFormat(SHAttribFormat attribFormat) const noexcept std::tuple<SHVertexInputState::numAttribSlots, SHVertexInputState::bytesRequired, vk::Format> SHVertexInputState::GetInfoFromAttribFormat(SHAttribFormat attribFormat) const noexcept
{ {
switch (attribFormat) switch (attribFormat)
{ {
@ -138,6 +138,9 @@ namespace SHADE
case SHAttribFormat::MAT_4D: case SHAttribFormat::MAT_4D:
return std::make_tuple(4, 16, vk::Format::eR32G32B32A32Sfloat); return std::make_tuple(4, 16, vk::Format::eR32G32B32A32Sfloat);
break; break;
case SHAttribFormat::UINT32_1D:
return std::make_tuple(1, 4, vk::Format::eR32Uint);
} }
return std::make_tuple(0, 0, vk::Format::eR32Sfloat); return std::make_tuple(0, 0, vk::Format::eR32Sfloat);
} }

View File

@ -182,12 +182,12 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Destructor for resource. Destructor for resource.
*/ */
/***************************************************************************/ /***************************************************************************/
SHRenderGraphResource::~SHRenderGraphResource(void) noexcept SHRenderGraphResource::~SHRenderGraphResource(void) noexcept
{ {
@ -195,37 +195,38 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Subpass non-default constructor. Simply initializes variables. Subpass non-default constructor. Simply initializes variables.
\param mapping \param mapping
Mapping from a resource handle to an attachment reference referencing Mapping from a resource handle to an attachment reference referencing
the resource. the resource.
\param resources \param resources
A mapping from string to render graph resource. A mapping from string to render graph resource.
*/ */
/***************************************************************************/ /***************************************************************************/
SHRenderGraphNode::SHSubpass::SHSubpass(std::unordered_map<uint64_t, uint32_t> const* mapping, std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* resources) noexcept SHRenderGraphNode::SHSubpass::SHSubpass(Handle<SHRenderGraphNode> const& parent, std::unordered_map<uint64_t, uint32_t> const* mapping, std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* resources) noexcept
: resourceAttachmentMapping{ mapping } : resourceAttachmentMapping{ mapping }
, ptrToResources{ resources } , ptrToResources{ resources }
, parentNode{ parent }
{ {
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Move constructor for subpass. Move constructor for subpass.
\param rhs \param rhs
The subpass the move from. The subpass the move from.
*/ */
/***************************************************************************/ /***************************************************************************/
SHRenderGraphNode::SHSubpass::SHSubpass(SHSubpass&& rhs) noexcept SHRenderGraphNode::SHSubpass::SHSubpass(SHSubpass&& rhs) noexcept
: colorReferences{ std::move(rhs.colorReferences) } : colorReferences{ std::move(rhs.colorReferences) }
@ -238,15 +239,15 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Move assignment operator for subpass. Move assignment operator for subpass.
\param rhs \param rhs
subpass to move from. subpass to move from.
*/ */
/***************************************************************************/ /***************************************************************************/
SHRenderGraphNode::SHSubpass& SHRenderGraphNode::SHSubpass::operator=(SHSubpass&& rhs) noexcept SHRenderGraphNode::SHSubpass& SHRenderGraphNode::SHSubpass::operator=(SHSubpass&& rhs) noexcept
{ {
@ -263,16 +264,16 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Adds a color output to a subpass. Takes in a string and finds the Adds a color output to a subpass. Takes in a string and finds the
attachment index to create the vk::SubpassReference. attachment index to create the vk::SubpassReference.
\param resourceToReference \param resourceToReference
Resource name to find resource to attach. Resource name to find resource to attach.
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraphNode::SHSubpass::AddColorOutput(std::string resourceToReference) noexcept void SHRenderGraphNode::SHSubpass::AddColorOutput(std::string resourceToReference) noexcept
{ {
@ -280,8 +281,8 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Adds a depth output to a subpass. Takes in a string and finds the Adds a depth output to a subpass. Takes in a string and finds the
attachment index to create the vk::SubpassReference. attachment index to create the vk::SubpassReference.
@ -292,8 +293,8 @@ namespace SHADE
\param attachmentDescriptionType \param attachmentDescriptionType
Depending on the type of the resource, initialize the image layout Depending on the type of the resource, initialize the image layout
appropriately. appropriately.
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraphNode::SHSubpass::AddDepthOutput(std::string resourceToReference, SH_ATT_DESC_TYPE attachmentDescriptionType) noexcept void SHRenderGraphNode::SHSubpass::AddDepthOutput(std::string resourceToReference, SH_ATT_DESC_TYPE attachmentDescriptionType) noexcept
{ {
@ -317,8 +318,8 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Adds a input output to a subpass. Takes in a string and finds the Adds a input output to a subpass. Takes in a string and finds the
attachment index to create the vk::SubpassReference. attachment index to create the vk::SubpassReference.
@ -326,21 +327,53 @@ namespace SHADE
\param resourceToReference \param resourceToReference
Resource name to find resource to attach. Resource name to find resource to attach.
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraphNode::SHSubpass::AddInput(std::string resourceToReference) noexcept void SHRenderGraphNode::SHSubpass::AddInput(std::string resourceToReference) noexcept
{ {
inputReferences.push_back({ resourceAttachmentMapping->at(ptrToResources->at(resourceToReference).GetId().Raw), vk::ImageLayout::eShaderReadOnlyOptimal }); inputReferences.push_back({ resourceAttachmentMapping->at(ptrToResources->at(resourceToReference).GetId().Raw), vk::ImageLayout::eShaderReadOnlyOptimal });
} }
void SHRenderGraphNode::SHSubpass::Execute(Handle<SHVkCommandBuffer>& commandBuffer) noexcept
{
// Draw all the batches
// Draw all the exterior draw calls
for (auto& drawCall : exteriorDrawCalls)
{
drawCall(commandBuffer);
}
}
void SHRenderGraphNode::SHSubpass::AddExteriorDrawCalls(std::function<void(Handle<SHVkCommandBuffer>&)> const& newDrawCall) noexcept
{
exteriorDrawCalls.push_back(newDrawCall);
}
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Creates a renderpass for the node. Uses subpass and attachment Getter for parent renderpass.
\return
Returns the parent renderpass the subpass belongs to.
*/
/***************************************************************************/
Handle<SHRenderGraphNode> const& SHRenderGraphNode::SHSubpass::GetParentNode(void) const noexcept
{
return parentNode;
}
/***************************************************************************/
/*!
\brief
Creates a renderpass for the node. Uses subpass and attachment
descriptions already configured beforehand in the render graph. descriptions already configured beforehand in the render graph.
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraphNode::CreateRenderpass(void) noexcept void SHRenderGraphNode::CreateRenderpass(void) noexcept
{ {
@ -348,12 +381,12 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Creates a framebuffer from the images used in the renderpass. Creates a framebuffer from the images used in the renderpass.
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraphNode::CreateFramebuffer(void) noexcept void SHRenderGraphNode::CreateFramebuffer(void) noexcept
{ {
@ -489,18 +522,18 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Add subpasses to the renderpass and returns a reference to it. Add subpasses to the renderpass and returns a reference to it.
\param subpassName \param subpassName
Name of the subpass. Name of the subpass.
\return \return
Handle to the new subpass. Handle to the new subpass.
*/ */
/***************************************************************************/ /***************************************************************************/
Handle<SHRenderGraphNode::SHSubpass> SHRenderGraphNode::AddSubpass(std::string subpassName) noexcept Handle<SHRenderGraphNode::SHSubpass> SHRenderGraphNode::AddSubpass(std::string subpassName) noexcept
{ {
@ -512,20 +545,35 @@ namespace SHADE
} }
// Add subpass to container and create mapping for it // Add subpass to container and create mapping for it
subpasses.emplace_back(resourceManager.Create<SHSubpass>(&resourceAttachmentMapping, ptrToResources)); subpasses.emplace_back(resourceManager.Create<SHSubpass>(GetHandle(), &resourceAttachmentMapping, ptrToResources));
subpassIndexing.try_emplace(subpassName, subpasses.size() - 1); subpassIndexing.try_emplace(subpassName, static_cast<uint32_t>(subpasses.size()) - 1u);
return subpasses.at(subpassIndexing[subpassName]); return subpasses.at(subpassIndexing[subpassName]);
} }
void SHRenderGraphNode::Execute(Handle<SHVkCommandBuffer>& commandBuffer, uint32_t frameIndex) noexcept
{
commandBuffer->BeginRenderpass(renderpass, framebuffers[frameIndex]);
for (auto& subpass : subpasses)
{
subpass->Execute(commandBuffer);
// Go to next subpass
commandBuffer->NextSubpass();
}
commandBuffer->EndRenderpass();
}
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Get the renderpass from the node. Get the renderpass from the node.
\return \return
Handle to the renderpass. Handle to the renderpass.
*/ */
/***************************************************************************/ /***************************************************************************/
Handle<SHVkRenderpass> SHRenderGraphNode::GetRenderpass(void) const noexcept Handle<SHVkRenderpass> SHRenderGraphNode::GetRenderpass(void) const noexcept
@ -560,7 +608,7 @@ namespace SHADE
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraph::AddResource(std::string resourceName, SH_ATT_DESC_TYPE type, uint32_t w /*= static_cast<uint32_t>(-1)*/, uint32_t h /*= static_cast<uint32_t>(-1)*/, vk::Format format/* = vk::Format::eB8G8R8A8Unorm*/, uint32_t levels /*= 1*/, vk::ImageCreateFlagBits createFlags /*= {}*/) void SHRenderGraph::AddResource(std::string resourceName, SH_ATT_DESC_TYPE type, uint32_t w /*= static_cast<uint32_t>(-1)*/, uint32_t h /*= static_cast<uint32_t>(-1)*/, vk::Format format/* = vk::Format::eB8G8R8A8Unorm*/, uint8_t levels /*= 1*/, vk::ImageCreateFlagBits createFlags /*= {}*/)
{ {
// If we set to // If we set to
if (w == static_cast<uint32_t>(-1) && h == static_cast<uint32_t>(-1)) if (w == static_cast<uint32_t>(-1) && h == static_cast<uint32_t>(-1))
@ -663,16 +711,16 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Configures the supasses; mainly the subpass descriptions and the Configures the supasses; mainly the subpass descriptions and the
subpass dependencies involved between subpasses. subpass dependencies involved between subpasses.
\return \return
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraph::ConfigureSubpasses(void) noexcept void SHRenderGraph::ConfigureSubpasses(void) noexcept
{ {
@ -801,12 +849,12 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Simply loops through all nodes and create renderpasses. Simply loops through all nodes and create renderpasses.
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraph::ConfigureRenderpasses(void) noexcept void SHRenderGraph::ConfigureRenderpasses(void) noexcept
{ {
@ -817,12 +865,12 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Simply loops through all nodes and create framebuffers. Simply loops through all nodes and create framebuffers.
*/ */
/***************************************************************************/ /***************************************************************************/
void SHRenderGraph::ConfigureFramebuffers(void) noexcept void SHRenderGraph::ConfigureFramebuffers(void) noexcept
{ {
@ -836,7 +884,21 @@ namespace SHADE
/*! /*!
\brief \brief
Init function. Doesn't do much except initialize device and swapchain Configures command pools and command buffers.
*/
/***************************************************************************/
void SHRenderGraph::ConfigureCommands(void) noexcept
{
commandPool = logicalDeviceHdl->CreateCommandPool(SH_QUEUE_FAMILY_ARRAY_INDEX::GRAPHICS, SH_CMD_POOL_RESET::POOL_BASED, true);
commandBuffers.resize(static_cast<std::size_t>(swapchainHdl->GetNumImages()));
}
/***************************************************************************/
/*!
\brief
Init function. Doesn't do much except initialize device and swapchain
handle. Graph should start out empty. handle. Graph should start out empty.
\param swapchain \param swapchain
@ -854,15 +916,15 @@ namespace SHADE
} }
/***************************************************************************/ /***************************************************************************/
/*! /*!
\brief \brief
Default ctor, doesn't do much. Default ctor, doesn't do much.
\return \return
*/ */
/***************************************************************************/ /***************************************************************************/
SHRenderGraph::SHRenderGraph(void) noexcept SHRenderGraph::SHRenderGraph(void) noexcept
: logicalDeviceHdl{ } : logicalDeviceHdl{ }
@ -929,7 +991,7 @@ namespace SHADE
} }
nodes.emplace_back(resourceManager.Create<SHRenderGraphNode>(resourceManager, logicalDeviceHdl, swapchainHdl, std::move(resources), std::move(predecessors), &graphResources)); nodes.emplace_back(resourceManager.Create<SHRenderGraphNode>(resourceManager, logicalDeviceHdl, swapchainHdl, std::move(resources), std::move(predecessors), &graphResources));
nodeIndexing.emplace(nodeName, nodes.size() - 1); nodeIndexing.emplace(nodeName, static_cast<uint32_t>(nodes.size()) - 1u);
return nodes.at(nodeIndexing[nodeName]); return nodes.at(nodeIndexing[nodeName]);
} }
@ -952,14 +1014,20 @@ namespace SHADE
ConfigureSubpasses(); ConfigureSubpasses();
ConfigureRenderpasses(); ConfigureRenderpasses();
ConfigureFramebuffers(); ConfigureFramebuffers();
ConfigureCommands();
} }
void SHRenderGraph::Execute(void) noexcept void SHRenderGraph::Execute(uint32_t frameIndex) noexcept
{ {
auto& cmdBuffer = commandBuffers[frameIndex];
cmdBuffer->BeginRecording();
for (auto& node : nodes) for (auto& node : nodes)
{ {
node->Execute(commandBuffers[frameIndex], frameIndex);
} }
cmdBuffer->EndRenderpass();
} }
Handle<SHRenderGraphNode> SHRenderGraph::GetNode(std::string const& nodeName) const noexcept Handle<SHRenderGraphNode> SHRenderGraph::GetNode(std::string const& nodeName) const noexcept

View File

@ -15,6 +15,8 @@ namespace SHADE
class SHVkImage; class SHVkImage;
class SHVkImageView; class SHVkImageView;
class SHVkFramebuffer; class SHVkFramebuffer;
class SHVkCommandPool;
class SHVkCommandBuffer;
// Used for attachment description creation for renderpass node // Used for attachment description creation for renderpass node
enum class SH_ATT_DESC_TYPE enum class SH_ATT_DESC_TYPE
@ -72,25 +74,44 @@ namespace SHADE
friend class SHRenderGraph; friend class SHRenderGraph;
}; };
class SHRenderGraphNode class SHRenderGraphNode : public ISelfHandle<SHRenderGraphNode>
{ {
public: public:
class SHSubpass class SHSubpass
{ {
public: public:
SHSubpass(std::unordered_map<uint64_t, uint32_t> const* mapping, std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* ptrToResources) noexcept; /*-----------------------------------------------------------------------*/
/* CTORS AND DTORS */
/*-----------------------------------------------------------------------*/
SHSubpass(Handle<SHRenderGraphNode> const& parent, std::unordered_map<uint64_t, uint32_t> const* mapping, std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* ptrToResources) noexcept;
SHSubpass(SHSubpass&& rhs) noexcept; SHSubpass(SHSubpass&& rhs) noexcept;
SHSubpass& operator=(SHSubpass&& rhs) noexcept; SHSubpass& operator=(SHSubpass&& rhs) noexcept;
/*-----------------------------------------------------------------------*/
/* PUBLIC MEMBER FUNCTIONS */
/*-----------------------------------------------------------------------*/
// Preparation functions
void AddColorOutput (std::string resourceToReference) noexcept; void AddColorOutput (std::string resourceToReference) noexcept;
void AddDepthOutput (std::string resourceToReference, SH_ATT_DESC_TYPE attachmentDescriptionType = SH_ATT_DESC_TYPE::DEPTH_STENCIL) noexcept; void AddDepthOutput (std::string resourceToReference, SH_ATT_DESC_TYPE attachmentDescriptionType = SH_ATT_DESC_TYPE::DEPTH_STENCIL) noexcept;
void AddInput (std::string resourceToReference) noexcept; void AddInput (std::string resourceToReference) noexcept;
// Runtime functions
void Execute (Handle<SHVkCommandBuffer>& commandBuffer) noexcept;
void AddExteriorDrawCalls (std::function<void(Handle<SHVkCommandBuffer>&)> const& newDrawCall) noexcept;
/*-----------------------------------------------------------------------*/
/* GETTERS AND SETTERS */
/*-----------------------------------------------------------------------*/
Handle<SHRenderGraphNode> const& GetParentNode (void) const noexcept;
private: private:
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
/* PRIVATE MEMBER VARIABLES */ /* PRIVATE MEMBER VARIABLES */
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
//! The parent renderpass that this subpass belongs to
Handle<SHRenderGraphNode> parentNode;
//! Color attachments //! Color attachments
std::vector<vk::AttachmentReference> colorReferences; std::vector<vk::AttachmentReference> colorReferences;
@ -106,6 +127,14 @@ namespace SHADE
//! Pointer to resources in the render graph (for getting handle IDs) //! Pointer to resources in the render graph (for getting handle IDs)
std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* ptrToResources; std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* ptrToResources;
//! Sometimes there exists entities that we want to render onto a render target
//! but don't want it to come from the batching system. An example would be ImGUI.
//! For these entities we want to link a function from the outside and draw them
//! 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
//! COMPLEX.
std::vector<std::function<void(Handle<SHVkCommandBuffer>&)>> exteriorDrawCalls;
friend class SHRenderGraphNode; friend class SHRenderGraphNode;
friend class SHRenderGraph; friend class SHRenderGraph;
}; };
@ -179,6 +208,7 @@ namespace SHADE
/* PUBLIC MEMBER FUNCTIONS */ /* PUBLIC MEMBER FUNCTIONS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
Handle<SHSubpass> AddSubpass (std::string subpassName) noexcept; Handle<SHSubpass> AddSubpass (std::string subpassName) noexcept;
void Execute (Handle<SHVkCommandBuffer>& commandBuffer, uint32_t frameIndex) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */
@ -198,6 +228,7 @@ namespace SHADE
void ConfigureSubpasses (void) noexcept; void ConfigureSubpasses (void) noexcept;
void ConfigureRenderpasses (void) noexcept; void ConfigureRenderpasses (void) noexcept;
void ConfigureFramebuffers (void) noexcept; void ConfigureFramebuffers (void) noexcept;
void ConfigureCommands (void) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* PRIVATE MEMBER VARIABLES */ /* PRIVATE MEMBER VARIABLES */
@ -219,6 +250,13 @@ namespace SHADE
//! Resource library for graph handles //! Resource library for graph handles
ResourceManager resourceManager; ResourceManager resourceManager;
//! Command pool for the render graph
Handle<SHVkCommandPool> commandPool;
//! Command buffers for the render graph
std::vector<Handle<SHVkCommandBuffer>> commandBuffers;
public: public:
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* CTORS AND DTORS */ /* CTORS AND DTORS */
@ -229,10 +267,10 @@ namespace SHADE
/* PUBLIC MEMBER FUNCTIONS */ /* PUBLIC MEMBER FUNCTIONS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void Init (Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain) noexcept; void Init (Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain) noexcept;
void AddResource (std::string resourceName, SH_ATT_DESC_TYPE type, uint32_t w = static_cast<uint32_t>(-1), uint32_t h = static_cast<uint32_t>(-1), vk::Format format = vk::Format::eB8G8R8A8Unorm, uint32_t levels = 1, vk::ImageCreateFlagBits createFlags = {}); void AddResource (std::string resourceName, SH_ATT_DESC_TYPE type, uint32_t w = static_cast<uint32_t>(-1), uint32_t h = static_cast<uint32_t>(-1), vk::Format format = vk::Format::eB8G8R8A8Unorm, uint8_t levels = 1, vk::ImageCreateFlagBits createFlags = {});
Handle<SHRenderGraphNode> AddNode (std::string nodeName, std::initializer_list<std::string> resourceNames, std::initializer_list<std::string> predecessorNodes) noexcept; Handle<SHRenderGraphNode> AddNode (std::string nodeName, std::initializer_list<std::string> resourceNames, std::initializer_list<std::string> predecessorNodes) noexcept;
void Generate (void) noexcept; void Generate (void) noexcept;
void Execute (void) noexcept; void Execute (uint32_t frameIndex) noexcept;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */

View File

@ -189,7 +189,7 @@ namespace SHADE
Handle<SHShaderBlockInterface> SHShaderDescriptorBindingInfo::GetShaderBlockInterface(uint32_t set, uint32_t binding) const noexcept Handle<SHShaderBlockInterface> SHShaderDescriptorBindingInfo::GetShaderBlockInterface(uint32_t set, uint32_t binding) const noexcept
{ {
SHShaderDescriptorBindingInfo::BindingAndSetHash hash = binding; BindingAndSetHash hash = binding;
hash |= static_cast<uint64_t>(set) << 32; hash |= static_cast<uint64_t>(set) << 32;
if (blockInterfaces.contains(hash)) if (blockInterfaces.contains(hash))
return blockInterfaces.at(hash); return blockInterfaces.at(hash);

View File

@ -9,11 +9,10 @@
namespace SHADE namespace SHADE
{ {
using BindingAndSetHash = uint64_t;
struct SHShaderDescriptorBindingInfo struct SHShaderDescriptorBindingInfo
{ {
public:
using BindingAndSetHash = uint64_t;
private: private:
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* PRIVATE MEMBER VARIABLES */ /* PRIVATE MEMBER VARIABLES */

View File

@ -18,7 +18,10 @@ namespace SHADE
// that a mat2 can be interpreted as (x, y, x, y), (o, o, o, o) instead of (x, y, o, o), (o, o, o, o)? // that a mat2 can be interpreted as (x, y, x, y), (o, o, o, o) instead of (x, y, o, o), (o, o, o, o)?
MAT_2D, MAT_2D,
MAT_3D, MAT_3D,
MAT_4D MAT_4D,
// integer formats
UINT32_1D,
}; };
struct SHVertexAttribute struct SHVertexAttribute

View File

@ -222,7 +222,7 @@ namespace SHADE
return true; return true;
{ {
MSG Message; MSG Message;
while (PeekMessageW(&Message, NULL, 0, 0, PM_REMOVE)) while (PeekMessageW(&Message, wndHWND, 0, 0, PM_REMOVE))
{ {
if (WM_QUIT == Message.message) if (WM_QUIT == Message.message)
{ {