Added debug names for some SHVkBuffers
This commit is contained in:
parent
d8ee991213
commit
b5bc64456c
|
@ -269,7 +269,7 @@ namespace SHADE
|
|||
|
||||
*/
|
||||
/***************************************************************************/
|
||||
SHVkBuffer::SHVkBuffer(std::reference_wrapper<VmaAllocator const> allocator) noexcept
|
||||
SHVkBuffer::SHVkBuffer(Handle<SHVkLogicalDevice> logicalDevice, std::reference_wrapper<VmaAllocator const> allocator) noexcept
|
||||
: vkBuffer{}
|
||||
, stagingBuffer{}
|
||||
, sizeStored{ 0 }
|
||||
|
@ -277,19 +277,23 @@ namespace SHADE
|
|||
, alloc {nullptr}
|
||||
, randomAccessOptimized{false}
|
||||
, vmaAllocator{allocator}
|
||||
, device { logicalDevice }
|
||||
{}
|
||||
|
||||
SHVkBuffer::SHVkBuffer(
|
||||
Handle<SHVkLogicalDevice> logicalDevice,
|
||||
uint32_t inSize,
|
||||
void* data,
|
||||
uint32_t srcSize,
|
||||
std::reference_wrapper<VmaAllocator const> allocator,
|
||||
vk::BufferUsageFlags bufferUsage,
|
||||
const std::string& name,
|
||||
VmaMemoryUsage memUsage,
|
||||
VmaAllocationCreateFlags allocFlags
|
||||
) noexcept
|
||||
: SHVkBuffer(allocator)
|
||||
: SHVkBuffer(logicalDevice, allocator)
|
||||
{
|
||||
this->name = name;
|
||||
Init(inSize, data, srcSize, bufferUsage, memUsage, allocFlags);
|
||||
}
|
||||
|
||||
|
@ -304,6 +308,8 @@ namespace SHADE
|
|||
, bufferUsageFlags {rhs.bufferUsageFlags}
|
||||
, bufferCreateInfo { rhs.bufferCreateInfo }
|
||||
, allocCreateInfo { rhs.allocCreateInfo }
|
||||
, name { std::move(rhs.name) }
|
||||
, device { rhs.device }
|
||||
|
||||
{
|
||||
rhs.vkBuffer = VK_NULL_HANDLE;
|
||||
|
@ -325,6 +331,8 @@ namespace SHADE
|
|||
bufferCreateInfo = rhs.bufferCreateInfo;
|
||||
allocCreateInfo = rhs.allocCreateInfo;
|
||||
bufferUsageFlags = rhs.bufferUsageFlags;
|
||||
name = std::move(rhs.name);
|
||||
device = rhs.device;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -402,6 +410,7 @@ namespace SHADE
|
|||
|
||||
auto [tempBuffer, allocInfo] = createBuffer(sizeStored);
|
||||
vkBuffer = tempBuffer;
|
||||
SET_VK_OBJ_NAME(*device, vk::ObjectType::eBuffer, vkBuffer, name);
|
||||
|
||||
// This probably means that a HOST_CACHED memory type is used on allocation
|
||||
if (allocFlags & VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT)
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace SHADE
|
|||
//using SHVkBufferUsageBits = vk::BufferUsageFlagBits;
|
||||
|
||||
class SHVkCommandBuffer;
|
||||
class SHVkLogicalDevice;
|
||||
|
||||
class SHVkBuffer
|
||||
{
|
||||
|
@ -51,6 +52,11 @@ namespace SHADE
|
|||
//VmaAllocator const& vmaAllocator;
|
||||
std::reference_wrapper<VmaAllocator const> vmaAllocator;
|
||||
|
||||
//! Name of this buffer if any
|
||||
std::string name;
|
||||
//! Handle to the logical device that created this buffer
|
||||
Handle<SHVkLogicalDevice> device;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* PRIVATE MEMBER FUNCTIONS */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
@ -62,13 +68,15 @@ namespace SHADE
|
|||
/* CTORS AND DTORS */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
SHVkBuffer (void) noexcept = delete;
|
||||
SHVkBuffer (std::reference_wrapper<VmaAllocator const> allocator) noexcept;
|
||||
SHVkBuffer (Handle<SHVkLogicalDevice> logicalDevice, std::reference_wrapper<VmaAllocator const> allocator) noexcept;
|
||||
SHVkBuffer (
|
||||
Handle<SHVkLogicalDevice> logicalDevice,
|
||||
uint32_t inSize,
|
||||
void* data,
|
||||
uint32_t srcSize,
|
||||
std::reference_wrapper<VmaAllocator const> allocator,
|
||||
vk::BufferUsageFlags bufferUsage,
|
||||
vk::BufferUsageFlags bufferUsage,
|
||||
const std::string& name = "",
|
||||
VmaMemoryUsage memUsage = VMA_MEMORY_USAGE_AUTO,
|
||||
VmaAllocationCreateFlags allocFlags = {}
|
||||
) noexcept;
|
||||
|
@ -84,7 +92,7 @@ namespace SHADE
|
|||
uint32_t inSize,
|
||||
void* data,
|
||||
uint32_t srcSize,
|
||||
vk::BufferUsageFlags bufferUsage,
|
||||
vk::BufferUsageFlags bufferUsage,
|
||||
VmaMemoryUsage memUsage,
|
||||
VmaAllocationCreateFlags allocFlags
|
||||
) noexcept;
|
||||
|
|
|
@ -220,6 +220,7 @@ namespace SHADE
|
|||
else
|
||||
{
|
||||
SHVulkanDebugUtil::ReportVkSuccess("Successfully created a Logical Device. ");
|
||||
SET_VK_OBJ_NAME((*this), vk::ObjectType::eDevice, vkLogicalDevice, "Logical Device");
|
||||
}
|
||||
|
||||
InitializeVMA();
|
||||
|
@ -419,9 +420,9 @@ namespace SHADE
|
|||
|
||||
*/
|
||||
/***************************************************************************/
|
||||
Handle<SHVkBuffer> SHVkLogicalDevice::CreateBuffer(uint32_t inSize, void* data, uint32_t srcSize, vk::BufferUsageFlags bufferUsage, VmaMemoryUsage memUsage, VmaAllocationCreateFlags allocFlags) const noexcept
|
||||
Handle<SHVkBuffer> SHVkLogicalDevice::CreateBuffer(uint32_t inSize, void* data, uint32_t srcSize, vk::BufferUsageFlags bufferUsage, VmaMemoryUsage memUsage, VmaAllocationCreateFlags allocFlags, const std::string& name) const noexcept
|
||||
{
|
||||
return SHVkInstance::GetResourceManager().Create<SHVkBuffer>(inSize, data, srcSize, std::cref(vmaAllocator), bufferUsage, memUsage, allocFlags);
|
||||
return SHVkInstance::GetResourceManager().Create<SHVkBuffer>(GetHandle(), inSize, data, srcSize, std::cref(vmaAllocator), bufferUsage, name, memUsage, allocFlags);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef SH_LOGICAL_DEVICE_H
|
||||
#define SH_LOGICAL_DEVICE_H
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <array>
|
||||
|
@ -67,7 +66,6 @@ namespace SHADE
|
|||
class SHVkLogicalDevice : public ISelfHandle<SHVkLogicalDevice>
|
||||
{
|
||||
private:
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* PRIVATE MEMBER VARIABLES */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
@ -147,7 +145,8 @@ namespace SHADE
|
|||
uint32_t srcSize,
|
||||
vk::BufferUsageFlags bufferUsage,
|
||||
VmaMemoryUsage memUsage,
|
||||
VmaAllocationCreateFlags allocFlags
|
||||
VmaAllocationCreateFlags allocFlags,
|
||||
const std::string& name = ""
|
||||
) const noexcept;
|
||||
|
||||
Handle<SHVkImage> CreateImage (
|
||||
|
@ -202,7 +201,23 @@ namespace SHADE
|
|||
Handle<SHVkSemaphore> CreateSemaphore (void) const noexcept;
|
||||
|
||||
void UpdateDescriptorSets(std::vector<vk::WriteDescriptorSet> const& writeDescSets) noexcept;
|
||||
void UpdateDescriptorSet (vk::WriteDescriptorSet const& writeDescSet) noexcept;
|
||||
void UpdateDescriptorSet(vk::WriteDescriptorSet const& writeDescSet) noexcept;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Debug Tools */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
#ifdef _DEBUG
|
||||
/// <summary>
|
||||
/// Sets a Vulkan object's name for debugging purposes. This function will not be
|
||||
/// compiled outsied of Debug configurations. Hence, it is advised to use provided
|
||||
/// macro function SET_VK_OBJ_NAME() instead of using this function directly.
|
||||
/// </summary>
|
||||
/// <param name="objType">Type of the object.</param>
|
||||
/// <param name="objHandle">Handle to the Vulkan Object to name.</param>
|
||||
/// <param name="objName">Object's name.</param>
|
||||
template<typename T>
|
||||
inline void SetVulkanObjectName(vk::ObjectType objType, T objHandle, const std::string& objName);
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* SETTERS AND GETTERS */
|
||||
|
@ -220,4 +235,4 @@ namespace SHADE
|
|||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "SHVkLogicalDevice.hpp"
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/************************************************************************************//*!
|
||||
\file SHVkLogicalDevice.hpp
|
||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Nov 4, 2022
|
||||
\brief Contains implementation of inline and template functions of
|
||||
SHVkLogicalDevice.
|
||||
|
||||
Copyright (C) 2022 DigiPen Institute of Technology.
|
||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||
of DigiPen Institute of Technology is prohibited.
|
||||
*//*************************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "SHVkLogicalDevice.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Debug Tools */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#ifdef _DEBUG
|
||||
template<typename T>
|
||||
void SHVkLogicalDevice::SetVulkanObjectName(vk::ObjectType objType, T objHandle, const std::string& objName)
|
||||
{
|
||||
if (objName.empty())
|
||||
return;
|
||||
|
||||
vk::DebugUtilsObjectNameInfoEXT info;
|
||||
info.objectType = objType;
|
||||
info.objectHandle = (uint64_t) static_cast<typename T::NativeType>(objHandle);
|
||||
info.pObjectName = objName.data();
|
||||
vkLogicalDevice.setDebugUtilsObjectNameEXT(info);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
/* Macro Definitions */
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
#ifdef _DEBUG
|
||||
#define SET_VK_OBJ_NAME(DEVICE, OBJ_TYPE, OBJ_HDL, OBJ_NAME) \
|
||||
(DEVICE).SetVulkanObjectName(OBJ_TYPE, OBJ_HDL, OBJ_NAME);
|
||||
#else
|
||||
#define SET_VK_OBJ_NAME(DEVICE, OBJ_TYPE, OBJ_HDL, OBJ_NAME)
|
||||
#endif
|
|
@ -392,20 +392,23 @@ namespace SHADE
|
|||
SHVkUtil::EnsureBufferAndCopyHostVisibleData
|
||||
(
|
||||
device, drawDataBuffer[frameIndex], drawData.data(), DRAW_DATA_BYTES,
|
||||
BuffUsage::eIndirectBuffer
|
||||
BuffUsage::eIndirectBuffer,
|
||||
"Batch Draw Data Buffer"
|
||||
);
|
||||
// - Transform Buffer
|
||||
const uint32_t TF_DATA_BYTES = static_cast<uint32_t>(transformData.size() * sizeof(SHMatrix));
|
||||
SHVkUtil::EnsureBufferAndCopyHostVisibleData
|
||||
(
|
||||
device, transformDataBuffer[frameIndex], transformData.data(), TF_DATA_BYTES,
|
||||
BuffUsage::eVertexBuffer
|
||||
BuffUsage::eVertexBuffer,
|
||||
"Batch Transform Buffer"
|
||||
);
|
||||
const uint32_t EID_DATA_BYTES = static_cast<uint32_t>(instancedIntegerData.size() * sizeof(SHInstancedIntegerData));
|
||||
SHVkUtil::EnsureBufferAndCopyHostVisibleData
|
||||
(
|
||||
device, instancedIntegerBuffer[frameIndex], instancedIntegerData.data(), EID_DATA_BYTES,
|
||||
BuffUsage::eVertexBuffer
|
||||
BuffUsage::eVertexBuffer,
|
||||
"Batch Instance Data Buffer"
|
||||
);
|
||||
// - Material Properties Buffer
|
||||
rebuildMaterialBuffers(frameIndex, descPool);
|
||||
|
|
|
@ -141,7 +141,8 @@ namespace SHADE
|
|||
0,
|
||||
vk::BufferUsageFlagBits::eVertexBuffer,
|
||||
VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
|
||||
VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_MAPPED_BIT
|
||||
VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_MAPPED_BIT,
|
||||
"Debug Draw Non-Persistent Vertex Buffer"
|
||||
);
|
||||
}
|
||||
// - Persistent Draws
|
||||
|
@ -154,7 +155,8 @@ namespace SHADE
|
|||
0,
|
||||
vk::BufferUsageFlagBits::eVertexBuffer,
|
||||
VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
|
||||
VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_MAPPED_BIT
|
||||
VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_MAPPED_BIT,
|
||||
"Debug Draw Persistent Vertex Buffer"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace SHADE
|
|||
}
|
||||
}
|
||||
|
||||
void SHVkUtil::EnsureBufferAndCopyData(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkBuffer>& bufferHandle, void* src, uint32_t size, vk::BufferUsageFlagBits usage)
|
||||
void SHVkUtil::EnsureBufferAndCopyData(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkBuffer>& bufferHandle, void* src, uint32_t size, vk::BufferUsageFlagBits usage, const std::string& name)
|
||||
{
|
||||
if (bufferHandle)
|
||||
{
|
||||
|
@ -100,7 +100,8 @@ namespace SHADE
|
|||
size,
|
||||
usage | BuffUsage::eTransferDst,
|
||||
VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
|
||||
VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT
|
||||
VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
|
||||
name
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -108,7 +109,7 @@ namespace SHADE
|
|||
bufferHandle->TransferToDeviceResource(cmdBuffer);
|
||||
}
|
||||
|
||||
void SHVkUtil::EnsureBufferAndCopyHostVisibleData(Handle<SHVkLogicalDevice> device, Handle<SHVkBuffer>& bufferHandle, void* src, uint32_t size, vk::BufferUsageFlagBits usage)
|
||||
void SHVkUtil::EnsureBufferAndCopyHostVisibleData(Handle<SHVkLogicalDevice> device, Handle<SHVkBuffer>& bufferHandle, void* src, uint32_t size, vk::BufferUsageFlagBits usage, const std::string& name)
|
||||
{
|
||||
if (bufferHandle)
|
||||
{
|
||||
|
@ -126,7 +127,8 @@ namespace SHADE
|
|||
size,
|
||||
usage,
|
||||
VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
|
||||
VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_MAPPED_BIT
|
||||
VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VmaAllocationCreateFlagBits::VMA_ALLOCATION_CREATE_MAPPED_BIT,
|
||||
name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace SHADE
|
|||
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
static void EnsureBufferAndCopyData(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkBuffer>& bufferHandle, void* src, uint32_t size, vk::BufferUsageFlagBits usage);
|
||||
static void EnsureBufferAndCopyData(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkBuffer>& bufferHandle, void* src, uint32_t size, vk::BufferUsageFlagBits usage, const std::string& name = "");
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
|
@ -80,7 +80,7 @@ namespace SHADE
|
|||
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
static void EnsureBufferAndCopyHostVisibleData(Handle<SHVkLogicalDevice> device, Handle<SHVkBuffer>& bufferHandle, void* src, uint32_t size, vk::BufferUsageFlagBits usage);
|
||||
static void EnsureBufferAndCopyHostVisibleData(Handle<SHVkLogicalDevice> device, Handle<SHVkBuffer>& bufferHandle, void* src, uint32_t size, vk::BufferUsageFlagBits usage, const std::string& name = "");
|
||||
|
||||
static BindingAndSetHash GenBindingSetHash (uint32_t set, uint32_t binding) noexcept;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue