Added labels for more buffers, images, imageviews, frames, semaphores and more
This commit is contained in:
parent
44ae6d0a8f
commit
d302d7e07d
|
@ -217,6 +217,7 @@ namespace SHADE
|
|||
&bufferInfo.operator VkBufferCreateInfo & (), // TODO: Verify if this works (can use RenderDoc to check buffer variables?)
|
||||
&allocCreateInfo,
|
||||
&tempBuffer, &stagingAlloc, &allocInfo);
|
||||
SET_VK_OBJ_NAME_VK(device, vk::ObjectType::eDeviceMemory, allocInfo.deviceMemory, "[Memory] Staging - " + name);
|
||||
|
||||
// then assign it to the hpp version
|
||||
stagingBuffer = tempBuffer;
|
||||
|
@ -253,6 +254,10 @@ namespace SHADE
|
|||
&bufferCreateInfo.operator VkBufferCreateInfo & (),
|
||||
&allocCreateInfo,
|
||||
&tempBuffer, &alloc, &allocInfo);
|
||||
#ifdef _DEBUG
|
||||
if (!name.empty())
|
||||
SET_VK_OBJ_NAME_VK(device, vk::ObjectType::eDeviceMemory, allocInfo.deviceMemory, "[Memory] " + name);
|
||||
#endif
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
SHVulkanDebugUtil::ReportVkError(vk::Result(result), "Failed to create vulkan buffer. ");
|
||||
|
|
|
@ -456,12 +456,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
|
||||
{
|
||||
return SHVkInstance::GetResourceManager().Create<SHVkImage>(&vmaAllocator, w, h, levels, format, usage, create);
|
||||
return SHVkInstance::GetResourceManager().Create<SHVkImage>(GetHandle(), &vmaAllocator, w, h, levels, format, usage, create);
|
||||
}
|
||||
|
||||
Handle<SHVkImage> SHVkLogicalDevice::CreateImage(SHImageCreateParams const& imageDetails, unsigned char* data, uint32_t dataSize, std::span<uint32_t> inMipOffsets, VmaMemoryUsage memUsage, VmaAllocationCreateFlags allocFlags) noexcept
|
||||
{
|
||||
return SHVkInstance::GetResourceManager().Create<SHVkImage>(&vmaAllocator, imageDetails, data, dataSize, inMipOffsets, memUsage, allocFlags);
|
||||
return SHVkInstance::GetResourceManager().Create<SHVkImage>(GetHandle(), &vmaAllocator, imageDetails, data, dataSize, inMipOffsets, memUsage, allocFlags);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -61,6 +61,7 @@ namespace SHADE
|
|||
&bufferInfo.operator VkBufferCreateInfo & (), // TODO: Verify if this works (can use renderdoc to check buffer variables?)
|
||||
&allocCreateInfo,
|
||||
&tempBuffer, &stagingAlloc, &allocInfo);
|
||||
SET_VK_OBJ_NAME_VK(device, vk::ObjectType::eDeviceMemory, allocInfo.deviceMemory, "[Memory] Staging Buffer for Image");
|
||||
|
||||
// then assign it to the hpp version
|
||||
stagingBuffer = tempBuffer;
|
||||
|
@ -107,6 +108,8 @@ namespace SHADE
|
|||
VkImage tempImage;
|
||||
auto result = vmaCreateImage(*vmaAllocator, &imageCreateInfo.operator VkImageCreateInfo & (), &allocCreateInfo, &tempImage, &alloc, &allocInfo);
|
||||
vkImage = tempImage;
|
||||
//SET_VK_OBJ_NAME_VK(device, vk::ObjectType::eImage, vkImage, "[Image] ");
|
||||
SET_VK_OBJ_NAME_VK(device, vk::ObjectType::eDeviceMemory, allocInfo.deviceMemory, "[Device Memory] Image Memory");
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
SHVulkanDebugUtil::ReportVkError(vk::Result(result), "Failed to create vulkan image. ");
|
||||
|
@ -115,6 +118,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
SHVkImage::SHVkImage(
|
||||
Handle<SHVkLogicalDevice> logicalDeviceHdl,
|
||||
VmaAllocator const* allocator,
|
||||
SHImageCreateParams const& imageDetails,
|
||||
const unsigned char* data,
|
||||
|
@ -137,6 +141,7 @@ namespace SHADE
|
|||
, boundToCoherent{false}
|
||||
, randomAccessOptimized {false}
|
||||
, mappedPtr{nullptr}
|
||||
, device { logicalDeviceHdl }
|
||||
{
|
||||
usageFlags = imageDetails.usageFlags;
|
||||
createFlags = imageDetails.createFlags;
|
||||
|
@ -176,6 +181,8 @@ namespace SHADE
|
|||
|
||||
VkImage tempImage;
|
||||
auto result = vmaCreateImage(*vmaAllocator, &imageCreateInfo.operator VkImageCreateInfo & (), &allocCreateInfo, &tempImage, &alloc, &allocInfo);
|
||||
//SET_VK_OBJ_NAME_VK(device, vk::ObjectType::eImage, vkImage, "[Image] ");
|
||||
SET_VK_OBJ_NAME_VK(device, vk::ObjectType::eDeviceMemory, allocInfo.deviceMemory, "[Device Memory] Image Memory");
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
SHVulkanDebugUtil::ReportVkError(vk::Result(result), "Failed to create vulkan image. ");
|
||||
|
@ -220,7 +227,7 @@ namespace SHADE
|
|||
//}
|
||||
}
|
||||
|
||||
SHVkImage::SHVkImage(VmaAllocator const* allocator, uint32_t w, uint32_t h, uint8_t levels, vk::Format format, vk::ImageUsageFlags usage, vk::ImageCreateFlags create) noexcept
|
||||
SHVkImage::SHVkImage(Handle<SHVkLogicalDevice> logicalDeviceHdl, VmaAllocator const* allocator, uint32_t w, uint32_t h, uint8_t levels, vk::Format format, vk::ImageUsageFlags usage, vk::ImageCreateFlags create) noexcept
|
||||
: width {w}
|
||||
, height{h}
|
||||
, depth {1}
|
||||
|
@ -230,11 +237,12 @@ namespace SHADE
|
|||
, usageFlags{usage}
|
||||
, createFlags {create}
|
||||
, vmaAllocator {allocator}
|
||||
, device { logicalDeviceHdl }
|
||||
{
|
||||
CreateFramebufferImage();
|
||||
}
|
||||
|
||||
Handle<SHVkImageView> SHVkImage::CreateImageView(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, Handle<SHVkImage> const& parent, SHImageViewDetails const& createParams) const noexcept
|
||||
Handle<SHVkImageView> SHVkImage::CreateImageView(Handle<SHVkLogicalDevice> inLogicalDeviceHdl, Handle<SHVkImage> const& parent, SHImageViewDetails const& createParams) const noexcept
|
||||
{
|
||||
return SHVkInstance::GetResourceManager().Create<SHVkImageView>(inLogicalDeviceHdl, parent, createParams);
|
||||
}
|
||||
|
|
|
@ -104,6 +104,9 @@ namespace SHADE
|
|||
//! Mipmap offsets for initializing the vk::BufferImageCopy during transfer to GPU resource
|
||||
std::span<uint32_t> mipOffsets;
|
||||
|
||||
//! Handle to the device that creates these images
|
||||
Handle<SHVkLogicalDevice> device;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* PRIVATE MEMBER FUNCTIONS */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
@ -117,6 +120,7 @@ namespace SHADE
|
|||
SHVkImage(void) noexcept = default;
|
||||
|
||||
SHVkImage(
|
||||
Handle<SHVkLogicalDevice> logicalDeviceHdl,
|
||||
VmaAllocator const* allocator,
|
||||
SHImageCreateParams const& imageDetails,
|
||||
const unsigned char* data,
|
||||
|
@ -126,7 +130,7 @@ namespace SHADE
|
|||
VmaAllocationCreateFlags allocFlags
|
||||
) 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(Handle<SHVkLogicalDevice> logicalDeviceHdl, VmaAllocator const* allocator, 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& operator=(SHVkImage && rhs) noexcept = default;
|
||||
|
@ -134,7 +138,7 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------*/
|
||||
/* PUBLIC MEMBER FUNCTIONS */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
Handle<SHVkImageView> CreateImageView (Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, Handle<SHVkImage> const& parent, SHImageViewDetails const& createParams) const noexcept;
|
||||
Handle<SHVkImageView> CreateImageView (Handle<SHVkLogicalDevice> inLogicalDeviceHdl, Handle<SHVkImage> const& parent, SHImageViewDetails const& createParams) const noexcept;
|
||||
void TransferToDeviceResource (Handle<SHVkCommandBuffer> cmdBufferHdl) noexcept;
|
||||
void PrepareImageTransitionInfo (vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::ImageMemoryBarrier& barrier) noexcept;
|
||||
void HandleResizeFramebufferImage(uint32_t newWidth, uint32_t newHeight) noexcept;
|
||||
|
|
|
@ -465,7 +465,8 @@ namespace SHADE
|
|||
SHVkUtil::EnsureBufferAndCopyHostVisibleData
|
||||
(
|
||||
device, matPropsBuffer[frameIndex], matPropsData.get(), static_cast<uint32_t>(matPropsDataSize),
|
||||
vk::BufferUsageFlagBits::eStorageBuffer
|
||||
vk::BufferUsageFlagBits::eStorageBuffer,
|
||||
"Batch Material Data"
|
||||
);
|
||||
|
||||
if (!matPropsDescSet[frameIndex])
|
||||
|
@ -475,6 +476,13 @@ namespace SHADE
|
|||
{ SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE] },
|
||||
{ 0 }
|
||||
);
|
||||
#ifdef _DEBUG
|
||||
const auto& DESC_SETS = matPropsDescSet[frameIndex]->GetVkHandle();
|
||||
for (auto descSet : DESC_SETS)
|
||||
{
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, descSet, "[Descriptor Set] Batch Material Data");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
std::array<Handle<SHVkBuffer>, 1> bufferList = { matPropsBuffer[frameIndex] };
|
||||
matPropsDescSet[frameIndex]->ModifyWriteDescBuffer
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace SHADE
|
|||
|
||||
// For global data (generic data and textures)
|
||||
Handle<SHVkDescriptorSetLayout> staticGlobalLayout = logicalDevice->CreateDescriptorSetLayout(SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS, { genericDataBinding, texturesBinding });
|
||||
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, staticGlobalLayout->GetVkHandle(), "[Descriptor Set Layout] Static Globals");
|
||||
|
||||
|
||||
std::vector<SHVkDescriptorSetLayout::Binding> lightBindings{};
|
||||
|
@ -70,11 +71,11 @@ namespace SHADE
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
// For Dynamic global data (lights)
|
||||
Handle<SHVkDescriptorSetLayout> dynamicGlobalLayout = logicalDevice->CreateDescriptorSetLayout(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, lightBindings);
|
||||
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, dynamicGlobalLayout->GetVkHandle(), "[Descriptor Set Layout] Dynamic Globals");
|
||||
|
||||
|
||||
// For High frequency global data (camera)
|
||||
SHVkDescriptorSetLayout::Binding cameraDataBinding
|
||||
{
|
||||
.Type = vk::DescriptorType::eUniformBufferDynamic,
|
||||
|
@ -82,10 +83,10 @@ namespace SHADE
|
|||
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::CAMERA_DATA,
|
||||
.DescriptorCount = 1,
|
||||
};
|
||||
|
||||
// For High frequency global data (camera)
|
||||
Handle<SHVkDescriptorSetLayout> cameraDataGlobalLayout = logicalDevice->CreateDescriptorSetLayout(SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS, { cameraDataBinding });
|
||||
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, cameraDataGlobalLayout->GetVkHandle(), "[Descriptor Set Layout] High Frequency Globals");
|
||||
|
||||
// For per instance data (transforms, materials, etc.)
|
||||
SHVkDescriptorSetLayout::Binding materialDataBinding
|
||||
{
|
||||
.Type = vk::DescriptorType::eStorageBufferDynamic,
|
||||
|
@ -93,9 +94,8 @@ namespace SHADE
|
|||
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
|
||||
.DescriptorCount = 1,
|
||||
};
|
||||
|
||||
// For High frequency global data (camera)
|
||||
Handle<SHVkDescriptorSetLayout> materialDataPerInstanceLayout = logicalDevice->CreateDescriptorSetLayout(SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, { materialDataBinding });
|
||||
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSetLayout, materialDataPerInstanceLayout->GetVkHandle(), "[Descriptor Set Layout] Material Globals");
|
||||
|
||||
globalDescSetLayouts.push_back(staticGlobalLayout);
|
||||
globalDescSetLayouts.push_back(dynamicGlobalLayout);
|
||||
|
|
|
@ -213,6 +213,7 @@ namespace SHADE
|
|||
ssaoStorage = resourceManager.Create<SHSSAO>();
|
||||
|
||||
ssaoTransferCmdBuffer = graphicsCmdPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::eCommandBuffer, ssaoTransferCmdBuffer->GetVkCommandBuffer(), "[Command Buffer] SSAO Pass (Graphics)");
|
||||
ssaoTransferCmdBuffer->BeginRecording();
|
||||
|
||||
ssaoStorage->Init(device, ssaoTransferCmdBuffer);
|
||||
|
@ -234,7 +235,7 @@ namespace SHADE
|
|||
|
||||
ssaoStorage->PrepareRotationVectorsVkData(device);
|
||||
|
||||
Handle<SHRenderGraphNodeCompute> ssaoPass = gBufferNode->AddNodeCompute(ssaoShader, {"Position", "Normals", "SSAO"});
|
||||
Handle<SHRenderGraphNodeCompute> ssaoPass = gBufferNode->AddNodeCompute("SSAO", ssaoShader, {"Position", "Normals", "SSAO"});
|
||||
auto ssaoDataBuffer = ssaoStorage->GetBuffer();
|
||||
ssaoPass->ModifyWriteDescBufferComputeResource(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_NODE_COMPUTE_RESOURCE, SHSSAO::DESC_SET_BUFFER_BINDING, { &ssaoDataBuffer, 1 }, 0, ssaoStorage->GetBuffer()->GetSizeStored());
|
||||
auto viewSamplerLayout = ssaoStorage->GetViewSamplerLayout();
|
||||
|
@ -242,12 +243,12 @@ namespace SHADE
|
|||
ssaoPass->ModifyWriteDescImageComputeResource(SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_NODE_COMPUTE_RESOURCE, SHSSAO::DESC_SET_IMAGE_BINDING, {&viewSamplerLayout, 1});
|
||||
|
||||
|
||||
Handle<SHRenderGraphNodeCompute> ssaoBlurPass = gBufferNode->AddNodeCompute(ssaoBlurShader, { "SSAO", "SSAO Blur"});
|
||||
Handle<SHRenderGraphNodeCompute> ssaoBlurPass = gBufferNode->AddNodeCompute("SSAO Blur Step", ssaoBlurShader, {"SSAO", "SSAO Blur"});
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* DEFERRED COMPOSITE SUBPASS INIT */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
gBufferNode->AddNodeCompute(deferredCompositeShader, { "Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Scene" });
|
||||
gBufferNode->AddNodeCompute("Deferred Composite", deferredCompositeShader, {"Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Scene"});
|
||||
|
||||
// Dummy Node
|
||||
auto dummyNode = worldRenderGraph->AddNode("Dummy Pass", { "Scene" }, { "Debug Draw" }); // no predecessors
|
||||
|
@ -271,7 +272,11 @@ namespace SHADE
|
|||
|
||||
// Create debug draw pipeline
|
||||
debugDrawPipeline = createDebugDrawPipeline(debugDrawNode->GetRenderpass(), debugDrawSubpass);
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::ePipeline, debugDrawPipeline->GetVkPipeline(), "[Pipeline] Debug Draw");
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::ePipelineLayout, debugDrawPipeline->GetPipelineLayout()->GetVkPipelineLayout(), "[Pipeline] Debug Draw Pipeline Layout");
|
||||
debugDrawDepthPipeline = createDebugDrawPipeline(debugDrawNodeDepth->GetRenderpass(), debugDrawDepthSubpass);
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::ePipeline, debugDrawDepthPipeline->GetVkPipeline(), "[Pipeline] Debug Draw with Depth Test");
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::ePipelineLayout, debugDrawDepthPipeline->GetPipelineLayout()->GetVkPipelineLayout(), "[Pipeline] Debug Draw with Depth Test Pipeline Layout");
|
||||
}
|
||||
|
||||
void SHGraphicsSystem::InitMiddleEnd(void) noexcept
|
||||
|
@ -677,6 +682,8 @@ namespace SHADE
|
|||
|
||||
auto renderGraphNode = subpass->GetParentNode();
|
||||
auto pipeline = renderGraphNode->GetOrCreatePipeline(std::make_pair(vertShader, fragShader), subpass);
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::ePipeline, pipeline->GetVkPipeline(), "[Pipeline] Custom Pipeline");
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::ePipelineLayout, pipeline->GetPipelineLayout()->GetVkPipelineLayout(), "[Pipeline] Custom Pipeline Layout");
|
||||
|
||||
mat->SetPipeline(pipeline);
|
||||
|
||||
|
@ -724,6 +731,7 @@ namespace SHADE
|
|||
void SHGraphicsSystem::BuildMeshBuffers()
|
||||
{
|
||||
transferCmdBuffer = graphicsCmdPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::eCommandBuffer, transferCmdBuffer->GetVkCommandBuffer(), "[Command Buffer] Mesh Buffer Building (Transfer)");
|
||||
device->WaitIdle();
|
||||
transferCmdBuffer->BeginRecording();
|
||||
meshLibrary.BuildBuffers(device, transferCmdBuffer);
|
||||
|
@ -768,6 +776,7 @@ namespace SHADE
|
|||
void SHGraphicsSystem::BuildTextures()
|
||||
{
|
||||
graphicsTexCmdBuffer = graphicsCmdPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::eCommandBuffer, graphicsTexCmdBuffer->GetVkCommandBuffer(), "[Command Buffer] Texture Building (Graphics)");
|
||||
device->WaitIdle();
|
||||
texLibrary.BuildTextures
|
||||
(
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace SHADE
|
|||
uint32_t bufferSize = entityIDAttachment->GetWidth() * entityIDAttachment->GetHeight() * SHVkUtil::GetBytesPerPixelFromFormat(entityIDAttachment->GetResourceFormat());
|
||||
|
||||
// Create the buffer
|
||||
imageDataDstBuffer = logicalDevice->CreateBuffer(bufferSize, nullptr, bufferSize, vk::BufferUsageFlagBits::eTransferDst, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
|
||||
imageDataDstBuffer = logicalDevice->CreateBuffer(bufferSize, nullptr, bufferSize, vk::BufferUsageFlagBits::eTransferDst, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Mouse Pick Image Data Destination");
|
||||
}
|
||||
|
||||
void SHMousePickSystem::SetViewportMousePos(SHVec2 vpMousePos) noexcept
|
||||
|
|
|
@ -39,9 +39,15 @@ namespace SHADE
|
|||
|
||||
cameraDescriptorSet = descriptorPool->Allocate({ cameraDescLayout }, { 1 });
|
||||
|
||||
#ifdef _DEBUG
|
||||
const auto& CAM_DESC_SETS = cameraDescriptorSet->GetVkHandle();
|
||||
for (int i = 0; i < static_cast<int>(CAM_DESC_SETS.size()); ++i)
|
||||
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSet, CAM_DESC_SETS[i], "[Descriptor Set] Camera Data Frame #" + std::to_string(i));
|
||||
#endif
|
||||
|
||||
cameraDataAlignedSize = logicalDevice->PadUBOSize(sizeof(SHShaderCameraData));
|
||||
|
||||
cameraBuffer = logicalDevice->CreateBuffer(cameraDataAlignedSize * numFrames, nullptr, cameraDataAlignedSize * numFrames, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
|
||||
cameraBuffer = logicalDevice->CreateBuffer(cameraDataAlignedSize * numFrames, nullptr, cameraDataAlignedSize * numFrames, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Camera Data");
|
||||
|
||||
std::array cameraBufferArray{cameraBuffer};
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace SHADE
|
|||
lightDataTotalAlignedSize = logicalDevice->PadSSBOSize(lightDataAlignedSize * maxLights);
|
||||
|
||||
// We want to initialize 3 times the amount of data required.
|
||||
dataBuffer = logicalDevice->CreateBuffer(lightDataTotalAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, lightDataTotalAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eStorageBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
|
||||
dataBuffer = logicalDevice->CreateBuffer(lightDataTotalAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, lightDataTotalAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eStorageBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Light Data");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -386,7 +386,11 @@ namespace SHADE
|
|||
|
||||
// Create the descriptor set
|
||||
lightingDataDescSet = descPool->Allocate({ SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS] }, variableSizes);
|
||||
|
||||
#ifdef _DEBUG
|
||||
const auto& CAM_DESC_SETS = lightingDataDescSet->GetVkHandle();
|
||||
for (int i = 0; i < static_cast<int>(CAM_DESC_SETS.size()); ++i)
|
||||
SET_VK_OBJ_NAME(logicalDevice, vk::ObjectType::eDescriptorSet, CAM_DESC_SETS[i], "[Descriptor Set] Light Data Frame #" + std::to_string(i));
|
||||
#endif
|
||||
|
||||
for (uint32_t i = 0; i < NUM_LIGHT_TYPES; ++i)
|
||||
{
|
||||
|
@ -402,7 +406,7 @@ namespace SHADE
|
|||
lightCountsAlignedSize = logicalDevice->PadUBOSize(lightCountsAlignedSize);
|
||||
|
||||
// Create the GPU buffer to hold light count
|
||||
lightCountsBuffer = logicalDevice->CreateBuffer(lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
|
||||
lightCountsBuffer = logicalDevice->CreateBuffer(lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, lightCountsAlignedSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Light Count Data");
|
||||
|
||||
lightingDataDescSet->ModifyWriteDescBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT, {&lightCountsBuffer, 1}, 0, sizeof (uint32_t) * NUM_LIGHT_TYPES);
|
||||
lightingDataDescSet->UpdateDescriptorSetBuffer(SHGraphicsConstants::DescriptorSetIndex::DYNAMIC_GLOBALS, SHGraphicsConstants::DescriptorSetBindings::LIGHTING_COUNT);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace SHADE
|
|||
|
||||
*/
|
||||
/***************************************************************************/
|
||||
void SHPerFrameData::Recreate(Handle<SHVkLogicalDevice> const& logicalDeviceHdl) noexcept
|
||||
void SHPerFrameData::Recreate(Handle<SHVkLogicalDevice> logicalDeviceHdl) noexcept
|
||||
{
|
||||
// Swapchain recreation means the images are just relinked to SHVkImages. Handles will remain the same. There is no need for this line.
|
||||
//swapchainImageHdl = params.swapchainHdl->GetSwapchainImage(frameIndex);
|
||||
|
@ -44,14 +44,17 @@ namespace SHADE
|
|||
|
||||
// Create image views for the swapchain
|
||||
swapchainImageViewHdl = swapchainImageHdl->CreateImageView(logicalDeviceHdl, swapchainImageHdl, viewDetails);
|
||||
SET_VK_OBJ_NAME(logicalDeviceHdl, vk::ObjectType::eImageView, swapchainImageViewHdl->GetImageView(), "[Image View] Swap Chain");
|
||||
|
||||
// Create a fence
|
||||
fenceHdl = logicalDeviceHdl->CreateFence();
|
||||
SET_VK_OBJ_NAME(logicalDeviceHdl, vk::ObjectType::eFence, fenceHdl->GetVkFence(), "[Fence] Swap Chain");
|
||||
|
||||
// scope makes it easier to navigate
|
||||
semImgAvailableHdl = logicalDeviceHdl->SHVkLogicalDevice::CreateSemaphore();
|
||||
SET_VK_OBJ_NAME(logicalDeviceHdl, vk::ObjectType::eSemaphore, semImgAvailableHdl->GetVkSem(), "[Semaphore] Swap Chain Image Available");
|
||||
semRenderFinishHdl = logicalDeviceHdl->SHVkLogicalDevice::CreateSemaphore();
|
||||
|
||||
SET_VK_OBJ_NAME(logicalDeviceHdl, vk::ObjectType::eSemaphore, semRenderFinishHdl->GetVkSem(), "[Semaphore] Swap Chain Render Finish");
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace SHADE
|
|||
/* PRIVATE MEMBER FUNCTIONS */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// These are made into functions (instead of ctor and dtor) because we want to call these functions again when we resize the window
|
||||
void Recreate (Handle<SHVkLogicalDevice> const& logicalDeviceHdl) noexcept;
|
||||
void Recreate (Handle<SHVkLogicalDevice> logicalDeviceHdl) noexcept;
|
||||
void Destroy (void);
|
||||
|
||||
friend class SHRenderContext;
|
||||
|
|
|
@ -50,7 +50,13 @@ namespace SHADE
|
|||
|
||||
for (uint32_t j = 0; j < params.numThreads; ++j)
|
||||
{
|
||||
frameData[i].cmdPoolHdls.push_back(logicalDeviceHdl->CreateCommandPool(params.cmdPoolQueueFamilyType, params.cmdPoolResetMode, params.cmdBufferTransient));
|
||||
auto cmdPool = logicalDeviceHdl->CreateCommandPool(params.cmdPoolQueueFamilyType, params.cmdPoolResetMode, params.cmdBufferTransient);
|
||||
SET_VK_OBJ_NAME
|
||||
(
|
||||
logicalDeviceHdl, vk::ObjectType::eCommandPool, cmdPool->GetVkCommandPool(),
|
||||
"[Command Pool] Render Context #" + std::to_string(i) + " Pool #" + std::to_string(j)
|
||||
);
|
||||
frameData[i].cmdPoolHdls.push_back(cmdPool);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ namespace SHADE
|
|||
{
|
||||
job.Image = resourceManager.Create<SHVkImage>
|
||||
(
|
||||
device,
|
||||
&device->GetVMAAllocator(),
|
||||
SHImageCreateParams
|
||||
{
|
||||
|
@ -143,6 +144,7 @@ namespace SHADE
|
|||
.layerCount = 1
|
||||
};
|
||||
job.TextureHandle->ImageView = job.Image->CreateImageView(device, job.Image, DETAILS);
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::eImageView, job.TextureHandle->ImageView->GetImageView(), "[Image View] Texture Library Texture #" + std::to_string(job.TextureHandle->TextureArrayIndex));
|
||||
}
|
||||
|
||||
// Add Textures
|
||||
|
@ -169,6 +171,10 @@ namespace SHADE
|
|||
{ SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS] },
|
||||
{ static_cast<uint32_t>(texOrder.size()) }
|
||||
);
|
||||
#ifdef _DEBUG
|
||||
for (auto set : texDescriptors->GetVkHandle())
|
||||
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals");
|
||||
#endif
|
||||
texDescriptors->ModifyWriteDescImage
|
||||
(
|
||||
SHGraphicsConstants::DescriptorSetIndex::STATIC_GLOBALS,
|
||||
|
|
|
@ -59,7 +59,8 @@ namespace SHADE
|
|||
format = renderGraphStorage->swapchain->GetSurfaceFormatKHR().format;
|
||||
}
|
||||
|
||||
renderGraphStorage->graphResources->try_emplace(resourceName, resourceManager->Create<SHRenderGraphResource>(renderGraphStorage, resourceName, typeFlags, format, w, h, levels, usageFlags, createFlags));
|
||||
auto resource = resourceManager->Create<SHRenderGraphResource>(renderGraphStorage, resourceName, typeFlags, format, w, h, levels, usageFlags, createFlags);
|
||||
renderGraphStorage->graphResources->try_emplace(resourceName, resource);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -58,6 +58,7 @@ namespace SHADE
|
|||
|
||||
|
||||
framebuffers[i] = graphStorage->logicalDevice->CreateFramebuffer(renderpass, imageViews, fbWidth, fbHeight);
|
||||
SET_VK_OBJ_NAME(graphStorage->logicalDevice, vk::ObjectType::eFramebuffer, framebuffers[i]->GetVkFramebuffer(), "[Framebuffer] " + name + std::to_string(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +267,7 @@ namespace SHADE
|
|||
return subpass;
|
||||
}
|
||||
|
||||
Handle<SHRenderGraphNodeCompute> SHRenderGraphNode::AddNodeCompute(Handle<SHVkShaderModule> computeShaderModule, std::initializer_list<std::string> resources, std::unordered_set<BindingAndSetHash>&& dynamicBufferBindings, float numWorkGroupScale/* = 1.0f*/) noexcept
|
||||
Handle<SHRenderGraphNodeCompute> SHRenderGraphNode::AddNodeCompute(std::string nodeName, Handle<SHVkShaderModule> computeShaderModule, std::initializer_list<std::string> resources, std::unordered_set<BindingAndSetHash>&& dynamicBufferBindings, float numWorkGroupScale/* = 1.0f*/) noexcept
|
||||
{
|
||||
// Look for the required resources in the graph
|
||||
std::vector<Handle<SHRenderGraphResource>> nodeComputeResources{};
|
||||
|
@ -279,7 +280,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
// Create the subpass compute with the resources
|
||||
auto nodeCompute = graphStorage->resourceManager->Create<SHRenderGraphNodeCompute>(graphStorage, computeShaderModule, std::move(nodeComputeResources), std::move (dynamicBufferBindings), nodeComputes.empty());
|
||||
auto nodeCompute = graphStorage->resourceManager->Create<SHRenderGraphNodeCompute>(std::move(nodeName), graphStorage, computeShaderModule, std::move(nodeComputeResources), std::move (dynamicBufferBindings), nodeComputes.empty());
|
||||
nodeComputes.push_back(nodeCompute);
|
||||
|
||||
return nodeCompute;
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace SHADE
|
|||
/* PUBLIC MEMBER FUNCTIONS */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
Handle<SHSubpass> AddSubpass(std::string subpassName) noexcept;
|
||||
Handle<SHRenderGraphNodeCompute> AddNodeCompute(Handle<SHVkShaderModule> computeShaderModule, std::initializer_list<std::string> resources, std::unordered_set<BindingAndSetHash>&& dynamicBufferBindings = {}, float numWorkGroupScale = 1.0f) noexcept;
|
||||
Handle<SHRenderGraphNodeCompute> AddNodeCompute(std::string nodeName, Handle<SHVkShaderModule> computeShaderModule, std::initializer_list<std::string> resources, std::unordered_set<BindingAndSetHash>&& dynamicBufferBindings = {}, float numWorkGroupScale = 1.0f) noexcept;
|
||||
void AddDummySubpassIfNeeded (void) noexcept;
|
||||
|
||||
// TODO: RemoveSubpass()
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace SHADE
|
||||
{
|
||||
SHRenderGraphNodeCompute::SHRenderGraphNodeCompute(Handle<SHRenderGraphStorage> graphStorage, Handle<SHVkShaderModule> computeShaderModule, std::vector<Handle<SHRenderGraphResource>>&& subpassComputeResources, std::unordered_set<BindingAndSetHash>&& dynamicBufferBindings, bool followingEndRP, float inNumWorkGroupScale/* = 1.0f*/) noexcept
|
||||
SHRenderGraphNodeCompute::SHRenderGraphNodeCompute(std::string nodeName, Handle<SHRenderGraphStorage> graphStorage, Handle<SHVkShaderModule> computeShaderModule, std::vector<Handle<SHRenderGraphResource>>&& subpassComputeResources, std::unordered_set<BindingAndSetHash>&& dynamicBufferBindings, bool followingEndRP, float inNumWorkGroupScale/* = 1.0f*/) noexcept
|
||||
: computePipeline{}
|
||||
, pipelineLayout{}
|
||||
, resources{}
|
||||
|
@ -22,6 +22,7 @@ namespace SHADE
|
|||
, followingEndRenderpass {followingEndRP}
|
||||
, numWorkGroupScale {std::clamp(inNumWorkGroupScale, 0.0f, 1.0f)}
|
||||
, computeResource{}
|
||||
, name { std::move(nodeName) }
|
||||
{
|
||||
SHPipelineLayoutParams pipelineLayoutParams
|
||||
{
|
||||
|
@ -50,6 +51,10 @@ namespace SHADE
|
|||
for (uint32_t i = 0; i < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++i)
|
||||
{
|
||||
graphResourceDescSets[i] = graphStorage->descriptorPool->Allocate({graphResourceLayout}, { 1 });
|
||||
#ifdef _DEBUG
|
||||
for (auto set : graphResourceDescSets[i]->GetVkHandle())
|
||||
SET_VK_OBJ_NAME(graphStorage->logicalDevice, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] " + name + " #" + std::to_string(i));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,6 +66,10 @@ namespace SHADE
|
|||
computeResource = graphStorage->resourceManager->Create<ComputeResource>();
|
||||
auto computeResourceLayout = layouts[SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_NODE_COMPUTE_RESOURCE];
|
||||
computeResource->descSet = graphStorage->descriptorPool->Allocate({ computeResourceLayout }, { 1 });
|
||||
#ifdef _DEBUG
|
||||
for (auto set : computeResource->descSet->GetVkHandle())
|
||||
SET_VK_OBJ_NAME(graphStorage->logicalDevice, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] " + name + " Resources");
|
||||
#endif
|
||||
|
||||
// Allocate for descriptor offsets
|
||||
for (uint32_t i = 0; i < SHGraphicsConstants::NUM_FRAME_BUFFERS; ++i)
|
||||
|
|
|
@ -65,8 +65,11 @@ namespace SHADE
|
|||
|
||||
std::array<std::vector<vk::ImageMemoryBarrier>, SHGraphicsConstants::NUM_FRAME_BUFFERS> memoryBarriers;
|
||||
|
||||
//! Name of this node
|
||||
std::string name;
|
||||
|
||||
public:
|
||||
SHRenderGraphNodeCompute(Handle<SHRenderGraphStorage> graphStorage, Handle<SHVkShaderModule> computeShaderModule, std::vector<Handle<SHRenderGraphResource>>&& subpassComputeResources, std::unordered_set<BindingAndSetHash>&& dynamicBufferBindings, bool followingEndRP, float inNumWorkGroupScale = 1.0f) noexcept;
|
||||
SHRenderGraphNodeCompute(std::string nodeName, Handle<SHRenderGraphStorage> graphStorage, Handle<SHVkShaderModule> computeShaderModule, std::vector<Handle<SHRenderGraphResource>>&& subpassComputeResources, std::unordered_set<BindingAndSetHash>&& dynamicBufferBindings, bool followingEndRP, float inNumWorkGroupScale = 1.0f) noexcept;
|
||||
|
||||
void Execute (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
|
||||
void HandleResize (void) noexcept;
|
||||
|
|
|
@ -82,6 +82,7 @@ namespace SHADE
|
|||
{
|
||||
images[i] = graphStorage->swapchain->GetSwapchainImage(i);
|
||||
imageViews[i] = images[i]->CreateImageView(graphStorage->logicalDevice, images[i], viewDetails);
|
||||
SET_VK_OBJ_NAME(graphStorage->logicalDevice, vk::ObjectType::eImageView, imageViews[i]->GetImageView(), "[Image View] " + resourceName + " #" + std::to_string(i));
|
||||
}
|
||||
}
|
||||
else // if swapchain image resource
|
||||
|
@ -129,7 +130,9 @@ namespace SHADE
|
|||
}
|
||||
|
||||
// The resource is not a swapchain image, just use the first slot of the vector
|
||||
images.push_back(graphStorage->logicalDevice->CreateImage(width, height, mipLevels, resourceFormat, usage, createFlags));
|
||||
auto image = graphStorage->logicalDevice->CreateImage(width, height, mipLevels, resourceFormat, usage, createFlags);
|
||||
SET_VK_OBJ_NAME(graphStorage->logicalDevice, vk::ObjectType::eImage, image->GetVkImage(), "[Image] " + resourceName);
|
||||
images.push_back(image);
|
||||
|
||||
// prepare image view details
|
||||
SHImageViewDetails viewDetails
|
||||
|
@ -144,7 +147,9 @@ namespace SHADE
|
|||
};
|
||||
|
||||
// just 1 image view created
|
||||
imageViews.push_back(images[0]->CreateImageView(graphStorage->logicalDevice, images[0], viewDetails));
|
||||
auto imageView = images[0]->CreateImageView(graphStorage->logicalDevice, images[0], viewDetails);
|
||||
imageViews.push_back(imageView);
|
||||
SET_VK_OBJ_NAME(graphStorage->logicalDevice, vk::ObjectType::eImageView, imageView->GetImageView(), "[Image View] " + resourceName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -302,6 +302,11 @@ namespace SHADE
|
|||
group.Free();
|
||||
|
||||
group = graphStorage->descriptorPool->Allocate({ inputDescriptorLayout }, variableCounts);
|
||||
#ifdef _DEBUG
|
||||
const auto& GROUP_HANDLES = group->GetVkHandle();
|
||||
for (int i = 0; i < static_cast<int>(GROUP_HANDLES.size()); ++i)
|
||||
SET_VK_OBJ_NAME(graphStorage->logicalDevice, vk::ObjectType::eDescriptorSet, GROUP_HANDLES[i], "[Descriptor Set] " + name + " #" + std::to_string(i));
|
||||
#endif
|
||||
|
||||
uint32_t i = 0;
|
||||
for (auto& binding : bindings)
|
||||
|
|
|
@ -14,8 +14,13 @@ public class RaccoonSpin : Script
|
|||
private Transform Transform;
|
||||
public RaccoonSpin(GameObject gameObj) : base(gameObj) { }
|
||||
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
testEvent = new CallbackEvent<int>();
|
||||
Action<int> action = (x) => Debug.Log($"{x}");
|
||||
testEvent.RegisterAction(action);
|
||||
|
||||
Transform = GetComponent<Transform>();
|
||||
if (Transform == null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue