Implemented image creation for textures in the texture bank

This commit is contained in:
Kah Wei 2022-09-22 09:19:18 +08:00
parent 7acf25a770
commit 3d9abcf19c
9 changed files with 350 additions and 85 deletions

View File

@ -138,6 +138,7 @@ xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"</Command
<ClInclude Include="src\ECS_Base\UnitTesting\SHECSUnitTest.h" />
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestComponents.h" />
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestSystems.h" />
<ClInclude Include="src\Editor\SHEditor.h" />
<ClInclude Include="src\Engine\SHEngine.h" />
<ClInclude Include="src\Events\SHEvent.h" />
<ClInclude Include="src\Events\SHEventDefines.h" />
@ -167,13 +168,31 @@ xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"</Command
<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\MiddleEnd\Batching\SHBatch.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHBatcher.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHSuperBatch.h" />
<ClInclude Include="src\Graphics\MiddleEnd\GlobalData\SHGraphicsGlobalData.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHCamera.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsConstants.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterial.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterial.hpp" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.hpp" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMeshLibrary.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderable.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderer.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHViewport.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Meshes\SHMeshData.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Meshes\SHPrimitiveGenerator.h" />
<ClInclude Include="src\Graphics\MiddleEnd\PerFrame\SHPerFrameData.h" />
<ClInclude Include="src\Graphics\MiddleEnd\PerFrame\SHRenderContext.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Pipeline\SHPipelineLibrary.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderModuleLibrary.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderSourceLibrary.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderType.h" />
<ClInclude Include="src\Graphics\MiddleEnd\Textures\SHTextureLibrary.h" />
<ClInclude Include="src\Graphics\Pipeline\SHPipelineLayoutParams.h" />
<ClInclude Include="src\Graphics\Pipeline\SHPipelineState.h" />
<ClInclude Include="src\Graphics\Pipeline\SHPipelineType.h" />
@ -250,6 +269,7 @@ xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"</Command
<ClCompile Include="src\ECS_Base\System\SHFixedSystemRoutine.cpp" />
<ClCompile Include="src\ECS_Base\System\SHSystemRoutine.cpp" />
<ClCompile Include="src\ECS_Base\UnitTesting\SHECSUnitTest.cpp" />
<ClCompile Include="src\Editor\SHEditor.cpp" />
<ClCompile Include="src\Engine\SHEngine.cpp" />
<ClCompile Include="src\FRC\SHFramerateController.cpp" />
<ClCompile Include="src\Filesystem\SHFileSystem.cpp" />
@ -273,12 +293,26 @@ xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"</Command
<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\MiddleEnd\Batching\SHBatch.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHBatcher.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHSuperBatch.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\GlobalData\SHGraphicsGlobalData.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHCamera.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMaterial.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMeshLibrary.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderable.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderer.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHViewport.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Meshes\SHPrimitiveGenerator.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\PerFrame\SHPerFrameData.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\PerFrame\SHRenderContext.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Pipeline\SHPipelineLibrary.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Shaders\SHShaderModuleLibrary.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Shaders\SHShaderSourceLibrary.cpp" />
<ClCompile Include="src\Graphics\MiddleEnd\Textures\SHTextureLibrary.cpp" />
<ClCompile Include="src\Graphics\Pipeline\SHPipelineState.cpp" />
<ClCompile Include="src\Graphics\Pipeline\SHPushConstantInterface.cpp" />
<ClCompile Include="src\Graphics\Pipeline\SHVkPipeline.cpp" />

View File

@ -28,6 +28,9 @@
<Filter Include="ECS_Base\UnitTesting">
<UniqueIdentifier>{078AA1A3-F318-2B6D-9C37-3F6888A53B13}</UniqueIdentifier>
</Filter>
<Filter Include="Editor">
<UniqueIdentifier>{8C1A20B0-78BC-4A86-6177-5EDA4DB8D1D6}</UniqueIdentifier>
</Filter>
<Filter Include="Engine">
<UniqueIdentifier>{DBC7D3B0-C769-FE86-B024-12DB9C6585D7}</UniqueIdentifier>
</Filter>
@ -70,15 +73,30 @@
<Filter Include="Graphics\MiddleEnd">
<UniqueIdentifier>{4B204703-3704-0859-A064-02AC8C67F2DA}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Batching">
<UniqueIdentifier>{7A02D7B0-E60F-0597-6FF6-0082DB02D14D}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\GlobalData">
<UniqueIdentifier>{85EFB65D-F107-9E87-BAB4-2D21268C3221}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Interface">
<UniqueIdentifier>{EBA1D3FF-D75C-C3AB-8014-3CF66CAE0D3C}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Meshes">
<UniqueIdentifier>{1F603FFC-8B22-7386-D4D2-011340D44B64}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\PerFrame">
<UniqueIdentifier>{8CDBA7C9-F8E8-D5AF-81CF-D19AEDDBA166}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Pipeline">
<UniqueIdentifier>{D04C14FB-3C5A-42E1-C540-3ECC314D0E98}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Shaders">
<UniqueIdentifier>{2460C057-1070-6C28-7929-D14665585BC1}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\MiddleEnd\Textures">
<UniqueIdentifier>{7E76F08B-EA83-1E72-736A-1A5DDF76EA28}</UniqueIdentifier>
</Filter>
<Filter Include="Graphics\Pipeline">
<UniqueIdentifier>{FBD334F8-67EA-328E-B061-BEAF1CB70316}</UniqueIdentifier>
</Filter>
@ -121,6 +139,9 @@
<Filter Include="Math\Geometry">
<UniqueIdentifier>{EAD6C33D-5697-3F74-1FD2-88F18B518450}</UniqueIdentifier>
</Filter>
<Filter Include="Math\Transform">
<UniqueIdentifier>{3AB383AD-2681-77B3-0F15-E8D9FB815318}</UniqueIdentifier>
</Filter>
<Filter Include="Math\Vector">
<UniqueIdentifier>{F1B75745-5D6D-D03A-E661-CA115216C73E}</UniqueIdentifier>
</Filter>
@ -207,6 +228,9 @@
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestSystems.h">
<Filter>ECS_Base\UnitTesting</Filter>
</ClInclude>
<ClInclude Include="src\Editor\SHEditor.h">
<Filter>Editor</Filter>
</ClInclude>
<ClInclude Include="src\Engine\SHEngine.h">
<Filter>Engine</Filter>
</ClInclude>
@ -294,18 +318,69 @@
<ClInclude Include="src\Graphics\Instance\SHVkInstance.h">
<Filter>Graphics\Instance</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHBatch.h">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHBatcher.h">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Batching\SHSuperBatch.h">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\GlobalData\SHGraphicsGlobalData.h">
<Filter>Graphics\MiddleEnd\GlobalData</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHCamera.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsConstants.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterial.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterial.hpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.hpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHMeshLibrary.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderable.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHRenderer.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Interface\SHViewport.h">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Meshes\SHMeshData.h">
<Filter>Graphics\MiddleEnd\Meshes</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Meshes\SHPrimitiveGenerator.h">
<Filter>Graphics\MiddleEnd\Meshes</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\PerFrame\SHPerFrameData.h">
<Filter>Graphics\MiddleEnd\PerFrame</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\PerFrame\SHRenderContext.h">
<Filter>Graphics\MiddleEnd\PerFrame</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Pipeline\SHPipelineLibrary.h">
<Filter>Graphics\MiddleEnd\Pipeline</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderModuleLibrary.h">
<Filter>Graphics\MiddleEnd\Shaders</Filter>
</ClInclude>
@ -315,6 +390,9 @@
<ClInclude Include="src\Graphics\MiddleEnd\Shaders\SHShaderType.h">
<Filter>Graphics\MiddleEnd\Shaders</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\MiddleEnd\Textures\SHTextureLibrary.h">
<Filter>Graphics\MiddleEnd\Textures</Filter>
</ClInclude>
<ClInclude Include="src\Graphics\Pipeline\SHPipelineLayoutParams.h">
<Filter>Graphics\Pipeline</Filter>
</ClInclude>
@ -421,7 +499,13 @@
<Filter>Math</Filter>
</ClInclude>
<ClInclude Include="src\Math\Transform\SHTransform.h">
<Filter>Math</Filter>
<Filter>Math\Transform</Filter>
</ClInclude>
<ClInclude Include="src\Math\Transform\SHTransformComponent.h">
<Filter>Math\Transform</Filter>
</ClInclude>
<ClInclude Include="src\Math\Transform\SHTransformSystem.h">
<Filter>Math\Transform</Filter>
</ClInclude>
<ClInclude Include="src\Math\Vector\SHVec2.h">
<Filter>Math\Vector</Filter>
@ -498,8 +582,6 @@
<ClInclude Include="src\Tools\SHUtilities.hpp">
<Filter>Tools</Filter>
</ClInclude>
<ClInclude Include="src\Math\Transform\SHTransformComponent.h" />
<ClInclude Include="src\Math\Transform\SHTransformSystem.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\ECS_Base\Components\SHComponent.cpp">
@ -529,6 +611,9 @@
<ClCompile Include="src\ECS_Base\UnitTesting\SHECSUnitTest.cpp">
<Filter>ECS_Base\UnitTesting</Filter>
</ClCompile>
<ClCompile Include="src\Editor\SHEditor.cpp">
<Filter>Editor</Filter>
</ClCompile>
<ClCompile Include="src\Engine\SHEngine.cpp">
<Filter>Engine</Filter>
</ClCompile>
@ -598,24 +683,66 @@
<ClCompile Include="src\Graphics\Instance\SHVkInstance.cpp">
<Filter>Graphics\Instance</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHBatch.cpp">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHBatcher.cpp">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Batching\SHSuperBatch.cpp">
<Filter>Graphics\MiddleEnd\Batching</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\GlobalData\SHGraphicsGlobalData.cpp">
<Filter>Graphics\MiddleEnd\GlobalData</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHCamera.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHGraphicsSystem.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMaterial.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMaterialInstance.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHMeshLibrary.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderTarget.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderable.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHRenderer.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Interface\SHViewport.cpp">
<Filter>Graphics\MiddleEnd\Interface</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Meshes\SHPrimitiveGenerator.cpp">
<Filter>Graphics\MiddleEnd\Meshes</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\PerFrame\SHPerFrameData.cpp">
<Filter>Graphics\MiddleEnd\PerFrame</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\PerFrame\SHRenderContext.cpp">
<Filter>Graphics\MiddleEnd\PerFrame</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Pipeline\SHPipelineLibrary.cpp">
<Filter>Graphics\MiddleEnd\Pipeline</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Shaders\SHShaderModuleLibrary.cpp">
<Filter>Graphics\MiddleEnd\Shaders</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Shaders\SHShaderSourceLibrary.cpp">
<Filter>Graphics\MiddleEnd\Shaders</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\MiddleEnd\Textures\SHTextureLibrary.cpp">
<Filter>Graphics\MiddleEnd\Textures</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\Pipeline\SHPipelineState.cpp">
<Filter>Graphics\Pipeline</Filter>
</ClCompile>
@ -698,7 +825,13 @@
<Filter>Math</Filter>
</ClCompile>
<ClCompile Include="src\Math\Transform\SHTransform.cpp">
<Filter>Math</Filter>
<Filter>Math\Transform</Filter>
</ClCompile>
<ClCompile Include="src\Math\Transform\SHTransformComponent.cpp">
<Filter>Math\Transform</Filter>
</ClCompile>
<ClCompile Include="src\Math\Transform\SHTransformSystem.cpp">
<Filter>Math\Transform</Filter>
</ClCompile>
<ClCompile Include="src\Math\Vector\SHVec2.cpp">
<Filter>Math\Vector</Filter>
@ -740,7 +873,5 @@
<ClCompile Include="src\Tools\SHStringUtils.cpp">
<Filter>Tools</Filter>
</ClCompile>
<ClCompile Include="src\Math\Transform\SHTransformComponent.cpp" />
<ClCompile Include="src\Math\Transform\SHTransformSystem.cpp" />
</ItemGroup>
</Project>

View File

@ -8,6 +8,7 @@
#include "Graphics/Framebuffer/SHVkFramebuffer.h"
#include "Graphics/Pipeline/SHVkPipeline.h"
#include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/Images/SHVkImage.h"
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
@ -422,8 +423,41 @@ namespace SHADE
}
/***************************************************************************/
/*!
void SHVkCommandBuffer::PipelineBarrier (
\brief
Issues a multi indirect draw call.
\param indirectDrawData
SHVkBuffer containing the data for the multi indirect draw call.
\param drawCount
Number of multi indirect draw sub-calls stored in indirectDrawData.
*/
/***************************************************************************/
void SHVkCommandBuffer::DrawMultiIndirect(Handle<SHVkBuffer> indirectDrawData, uint32_t drawCount)
{
if (cmdBufferState != SH_CMD_BUFFER_STATE::RECORDING)
{
SHLOG_ERROR("Command buffer must have started recording before a pipeline can be bound.");
return;
}
vkCommandBuffer.drawIndexedIndirect(indirectDrawData->GetVkBuffer(), 0, drawCount, sizeof(vk::DrawIndexedIndirectCommand));
}
void SHVkCommandBuffer::CopyBufferToImage(const vk::Buffer& src, const vk::Image& dst, const std::vector<vk::BufferImageCopy>& copyInfo)
{
vkCommandBuffer.copyBufferToImage
(
src, dst, vk::ImageLayout::eTransferDstOptimal,
static_cast<uint32_t>(copyInfo.size()), copyInfo.data()
);
}
void SHVkCommandBuffer::PipelineBarrier(
vk::PipelineStageFlags srcStage,
vk::PipelineStageFlags dstStage,
vk::DependencyFlags deps,
@ -457,33 +491,6 @@ namespace SHADE
// //vkCommandBuffer.pipelineBarrier()
//}
/***************************************************************************/
/*!
\brief
Issues a multi indirect draw call.
\param indirectDrawData
SHVkBuffer containing the data for the multi indirect draw call.
\param drawCount
Number of multi indirect draw sub-calls stored in indirectDrawData.
*/
/***************************************************************************/
void SHVkCommandBuffer::DrawMultiIndirect(Handle<SHVkBuffer> indirectDrawData, uint32_t drawCount)
{
if (cmdBufferState != SH_CMD_BUFFER_STATE::RECORDING)
{
SHLOG_ERROR("Command buffer must have started recording before a pipeline can be bound.");
return;
}
vkCommandBuffer.drawIndexedIndirect(indirectDrawData->GetVkBuffer(), 0, drawCount, sizeof(vk::DrawIndexedIndirectCommand));
}
/***************************************************************************/
/*!

View File

@ -15,6 +15,7 @@ namespace SHADE
class SHVkFramebuffer;
class SHVkPipeline;
class SHVkBuffer;
class SHVkImage;
class SHVkDescriptorSetGroup;
enum class SH_CMD_BUFFER_TYPE
@ -116,6 +117,10 @@ namespace SHADE
// Draw Commands
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 DrawMultiIndirect (Handle<SHVkBuffer> indirectDrawData, uint32_t drawCount);
// Buffer Copy
void CopyBufferToImage (const vk::Buffer& src, const vk::Image& dst, const std::vector<vk::BufferImageCopy>& copyInfo);
// memory barriers
void PipelineBarrier (
@ -129,7 +134,6 @@ namespace SHADE
bool IsReadyToSubmit (void) const noexcept;
void HandlePostSubmit (void) noexcept;
void DrawMultiIndirect (Handle<SHVkBuffer> indirectDrawData, uint32_t drawCount);
// Push Constant variable setting
template <typename T>

View File

@ -234,7 +234,7 @@ namespace SHADE
return SHVkInstance::GetResourceManager().Create<SHVkImageView>(inLogicalDeviceHdl, parent, createParams);
}
void SHVkImage::TransferToDeviceResource(void) noexcept
void SHVkImage::TransferToDeviceResource(Handle<SHVkCommandBuffer> cmdBufferHdl) noexcept
{
// prepare copy regions
std::vector<vk::BufferImageCopy> copyRegions{mipOffsets.size()};
@ -252,7 +252,7 @@ namespace SHADE
copyRegions[i].imageExtent = vk::Extent3D{ width >> i, height >> i, 1 };
}
//PrepareImageTransition();
cmdBufferHdl->CopyBufferToImage(stagingBuffer, vkImage, copyRegions);
}
/***************************************************************************/
@ -274,7 +274,7 @@ namespace SHADE
*/
/***************************************************************************/
void SHVkImage::PrepareImageTransition(vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::ImageMemoryBarrier& barrier) noexcept
void SHVkImage::PrepareImageTransitionInfo(vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::ImageMemoryBarrier& barrier) noexcept
{
barrier.oldLayout = oldLayout;
barrier.newLayout = newLayout;
@ -286,33 +286,6 @@ namespace SHADE
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

View File

@ -135,8 +135,8 @@ namespace SHADE
/* PUBLIC MEMBER FUNCTIONS */
/*-----------------------------------------------------------------------*/
Handle<SHVkImageView> CreateImageView (Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, Handle<SHVkImage> const& parent, SHImageViewDetails const& createParams) const noexcept;
void TransferToDeviceResource (void) noexcept;
void PrepareImageTransition (vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::ImageMemoryBarrier& barrier) noexcept;
void TransferToDeviceResource (Handle<SHVkCommandBuffer> cmdBufferHdl) noexcept;
void PrepareImageTransitionInfo (vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::ImageMemoryBarrier& barrier) noexcept;
/*-----------------------------------------------------------------------*/
/* GETTERS AND SETTERS */

View File

@ -13,29 +13,130 @@ of DigiPen Institute of Technology is prohibited.
#include "SHpch.h"
#include "SHTextureLibrary.h"
#include "Graphics/SHVulkanIncludes.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/Commands/SHVkCommandBuffer.h"
#include "Graphics/SHVkUtil.h"
#include "Tools/SHLogger.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------*/
/* Usage Functions */
/*-----------------------------------------------------------------------------*/
Handle<SHTexture> SHTextureLibrary::Add(uint32_t pixelCount, const SHTexture::PixelChannel* const pixelData)
/*---------------------------------------------------------------------------------*/
/* Usage Functions */
/*---------------------------------------------------------------------------------*/
Handle<SHTexture> SHTextureLibrary::Add(uint32_t pixelCount, const SHTexture::PixelChannel* const pixelData, SHTexture::TextureFormat format, int mipLevels)
{
return {};
isDirty = true;
auto handle = resourceManager.Create<SHTexture>();
addJobs.emplace_back(AddJob { pixelCount, pixelData, format, mipLevels });
return handle;
}
void SHTextureLibrary::Remove(Handle<SHTexture> mesh)
void SHTextureLibrary::Remove(Handle<SHTexture> texture)
{
if (!texture)
throw std::invalid_argument("Attempted to remove a Texture that did not belong to the Texture Library!");
removeJobs.emplace_back(texture);
isDirty = true;
}
void SHTextureLibrary::BuildBuffers(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer)
void SHTextureLibrary::BuildImages(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorPool> descPool, Handle<SHVkDescriptorSetLayout> descLayout)
{
/* Remove Textures */
std::vector<vk::ImageMemoryBarrier> pipelineBarriers(addJobs.size());
/* Add Textures */
// Transition
for (int i = 0; auto& job : addJobs)
{
job.Image = resourceManager.Create<SHVkImage>();
job.Image->PrepareImageTransitionInfo(vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, pipelineBarriers[i]);
++i;
}
vk::PipelineStageFlagBits srcStage = vk::PipelineStageFlagBits::eTopOfPipe;
vk::PipelineStageFlagBits dstStage = vk::PipelineStageFlagBits::eTopOfPipe;
preparePipelineBarriers(vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, srcStage, dstStage, pipelineBarriers);
cmdBuffer->PipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eTransfer, {}, {}, {}, pipelineBarriers);
// Copy
for (auto& job : addJobs)
{
job.Image->TransferToDeviceResource(cmdBuffer);
}
// Transition
for (int i = 0; auto & job : addJobs)
{
// Transition
job.Image->PrepareImageTransitionInfo(vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal, pipelineBarriers[i]);
}
preparePipelineBarriers(vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal, srcStage, dstStage, pipelineBarriers);
cmdBuffer->PipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eTransfer, {}, {}, {}, pipelineBarriers);
// Execute Commands
graphicsQueue->SubmitCommandBuffer({ cmdBuffer });
device->WaitIdle();
// Create Image View
for (auto& job : addJobs)
{
const SHImageViewDetails DETAILS
{
.viewType = vk::ImageViewType::e2D,
.format = job.TextureFormat,
.imageAspectFlags = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0,
.mipLevelCount = job.MipLevels,
.baseArrayLayer = 0,
.layerCount = 0
};
job.Handle->ImageView = job.Image->CreateImageView(device, job.Image, DETAILS);
}
// Build Descriptor
Handle<SHVkDescriptorSetGroup> descSetGroup = descPool->Allocate({ descLayout }, { 1 }).front();
isDirty = false;
}
/*---------------------------------------------------------------------------------*/
/* Usage Functions */
/*---------------------------------------------------------------------------------*/
void SHTextureLibrary::preparePipelineBarriers(vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::PipelineStageFlagBits& srcStage, vk::PipelineStageFlagBits& dstStage, std::vector<vk::ImageMemoryBarrier>& barriers)
{
if (oldLayout == vk::ImageLayout::eUndefined && newLayout == vk::ImageLayout::eTransferDstOptimal)
{
srcStage = vk::PipelineStageFlagBits::eTopOfPipe;
dstStage = vk::PipelineStageFlagBits::eTransfer;
for (auto& barrier : barriers)
{
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;
for (auto& barrier : barriers)
{
barrier.srcAccessMask = vk::AccessFlagBits::eTransferWrite;
barrier.dstAccessMask = vk::AccessFlagBits::eShaderRead;
}
}
else
{
SHLOG_ERROR("Image layouts are invalid. ");
}
}
}

View File

@ -37,11 +37,15 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------*/
using PixelChannel = uint8_t;
using PixelChannel = void;
using TextureFormat = vk::Format; // TODO: Change
using Index = uint32_t;
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
Handle<SHVkImageView> ImageView;
Index TextureArrayIndex = std::numeric_limits<Index>::max();
};
/***********************************************************************************/
/*!
@ -61,7 +65,7 @@ namespace SHADE
\brief
Adds a texture to the Texture Library. But this does not mean that the
textures have been added yet. A call to "BuildBuffers()" is required to
textures have been added yet. A call to "BuildImages()" is required to
transfer all textures into the GPU.
\param pixelCount
@ -69,20 +73,22 @@ namespace SHADE
\param positions
Pointer to the first in a contiguous array of SHMathVec3s that define vertex
positions.
\param format
Format of the texture loaded in.
\return
Handle to the created Texture. This is not valid to be used until a call to
BuildBuffers().
BuildImages().
*/
/*******************************************************************************/
Handle<SHTexture> Add(uint32_t pixelCount, const SHTexture::PixelChannel* const pixelData);
Handle<SHTexture> Add(uint32_t pixelCount, const SHTexture::PixelChannel* const pixelData, SHTexture::TextureFormat format, int mipLevels);
/*******************************************************************************/
/*!
\brief
Removes a mesh from the Texture Library. But this does not mean that the
textures have been removed yet. A call to "BuildBuffers()" is required to
textures have been removed yet. A call to "BuildImages()" is required to
finalise all changes.
\param mesh
@ -106,7 +112,7 @@ namespace SHADE
queue.
*/
/***************************************************************************/
void BuildBuffers(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer);
void BuildImages(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue);
/*-----------------------------------------------------------------------------*/
/* Getter Functions */
@ -119,10 +125,14 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
struct AddJob
{
uint32_t PixelCount = 0;
const SHTexture::PixelChannel* PixelData = nullptr;
Handle<SHTexture> Handle;
uint32_t PixelCount = 0;
const SHTexture::PixelChannel* PixelData = nullptr;
SHTexture::TextureFormat TextureFormat = {};
int MipLevels = 0;
Handle<SHVkImage> Image;
Handle<SHTexture> Handle;
};
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
@ -130,7 +140,7 @@ namespace SHADE
std::vector<AddJob> addJobs;
std::vector<Handle<SHTexture>> removeJobs;
// Tracking
ResourceLibrary<SHTexture> textures{};
ResourceManager resourceManager;
std::vector<Handle<SHTexture>> texOrder;
// CPU Storage
std::vector<SHTexture::PixelChannel> texStorage;
@ -138,5 +148,10 @@ namespace SHADE
Handle<SHVkBuffer> texStorageBuffer{};
// Flags
bool isDirty = true;
/*-----------------------------------------------------------------------------*/
/* Helper Functions */
/*-----------------------------------------------------------------------------*/
void preparePipelineBarriers(vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::PipelineStageFlagBits& srcStage, vk::PipelineStageFlagBits& dstStage, std::vector<vk::ImageMemoryBarrier>& barriers);
};
}

View File

@ -9,4 +9,4 @@
#include "SHQuaternion.h"
#include "SHMatrix.h"
#include "SHTransform.h"
#include "Transform/SHTransform.h"