Added debug names and markers to vulkan

This commit is contained in:
antopilo
2025-04-26 23:07:41 -04:00
parent 60819fe1d3
commit 958287f6b1
13 changed files with 195 additions and 16 deletions

View File

@@ -20,10 +20,42 @@ namespace Nuake
Cmd(VkCommandBuffer cmdBuffer) : CmdBuffer(cmdBuffer) {}
VkCommandBuffer GetCmdBuffer() { return CmdBuffer; }
class DebugMarkerScope
{
private:
VkCommandBuffer cmd;
public:
DebugMarkerScope(VkCommandBuffer inCmd, const std::string& name, Color color = Color(1, 0, 0, 1)) :
cmd(inCmd)
{
VkDebugUtilsLabelEXT labelInfo{};
labelInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
labelInfo.pLabelName = name.c_str();
labelInfo.color[0] = color.r; // Red
labelInfo.color[1] = color.g;
labelInfo.color[2] = color.b;
labelInfo.color[3] = color.a; // Alpha
vkCmdBeginDebugUtilsLabelEXT(cmd, &labelInfo);
}
~DebugMarkerScope()
{
vkCmdEndDebugUtilsLabelEXT(cmd);
}
};
public:
void BeginRendering(VkRenderingInfo renderInfo);
void EndRendering();
DebugMarkerScope DebugScope(const std::string& name, Color color = Color(1, 0, 0, 1))
{
return DebugMarkerScope(CmdBuffer, name, color);
}
void DebugMarker(const std::string& name, Color color = Color(1, 0, 0, 1));
void BindPipeline(VkPipeline pipeline) const;
void SetViewport(const Vector2& size) const;
void SetScissor(const Vector2& size) const;

View File

@@ -70,6 +70,8 @@ void RenderPass::Execute(PassRenderContext& ctx, PassAttachments& inputs)
void RenderPass::ClearAttachments(PassRenderContext& ctx, PassAttachments& inputs)
{
auto marker = ctx.commandBuffer.DebugScope("Clear Attachments");
// Clear all color attachments
int attachmentIndex = 0;
for (int i = 0; i < std::size(inputs); i++)
@@ -96,6 +98,7 @@ void RenderPass::ClearAttachments(PassRenderContext& ctx, PassAttachments& input
void RenderPass::TransitionAttachments(PassRenderContext& ctx, PassAttachments& inputs)
{
auto marker = ctx.commandBuffer.DebugScope("Transition Attachments");
// Transition all color attachments
for (auto& attachment : inputs)
{
@@ -108,6 +111,8 @@ void RenderPass::TransitionAttachments(PassRenderContext& ctx, PassAttachments&
void RenderPass::UntransitionAttachments(PassRenderContext& ctx, PassAttachments& inputs)
{
auto marker = ctx.commandBuffer.DebugScope("Detransition Attachments");
for (auto& attachment : inputs)
{
// Transform from color attachment to transfer src for next pass
@@ -122,6 +127,7 @@ void RenderPass::Render(PassRenderContext& ctx, PassAttachments& inputs)
if (PreRender)
{
auto marker = ctx.commandBuffer.DebugScope("Pre Render");
PreRender(ctx);
}
@@ -162,6 +168,7 @@ void RenderPass::Render(PassRenderContext& ctx, PassAttachments& inputs)
if (RenderCb)
{
auto marker = ctx.commandBuffer.DebugScope("Render");
RenderCb(ctx);
}
}
@@ -169,6 +176,7 @@ void RenderPass::Render(PassRenderContext& ctx, PassAttachments& inputs)
if (PostRender)
{
auto marker = ctx.commandBuffer.DebugScope("Post Render");
PostRender(ctx);
}
}
@@ -278,6 +286,7 @@ void RenderPass::Build()
VK_CALL(vkCreatePipelineLayout(VkRenderer::Get().GetDevice(), &pipeline_layout_info, nullptr, &PipelineLayout));
VulkanUtil::SetDebugName(PipelineLayout, Name + "PipelineLayout");
// Create pipeline
const size_t attachmentCount = Attachments.size();
@@ -314,7 +323,7 @@ void RenderPass::Build()
}
Pipeline = pipelineBuilder.BuildPipeline(VkRenderer::Get().GetDevice());
VulkanUtil::SetDebugName(Pipeline, Name + "Pipeline");
IsBuilt = true;
}
@@ -381,6 +390,7 @@ void RenderPipeline::Execute(PassRenderContext& ctx, PipelineAttachments& inputs
int passIndex = 0;
for (auto& pass : RenderPasses)
{
auto marker = ctx.commandBuffer.DebugScope(pass.GetName() + " Execute");
pass.Execute(ctx, inputs[passIndex]);
passIndex++;

View File

@@ -145,6 +145,8 @@ SceneRenderPipeline::SceneRenderPipeline()
memcpy(mappedData, ssaoKernelSamples.data(), buffer->GetSize());
VkRenderer::Get().ImmediateSubmit([&](VkCommandBuffer cmd)
{
auto command = Cmd(cmd);
command.DebugScope("SSAO Kernel CopyBuffer");
VkBufferCopy copy{ 0 };
copy.dstOffset = 0;
copy.srcOffset = 0;
@@ -316,7 +318,10 @@ void SceneRenderPipeline::Render(PassRenderContext& ctx)
{ LineCombineOutput },
};
GBufferPipeline.Execute(ctx, pipelineInputs);
{
auto marker = ctx.commandBuffer.DebugScope("GBufferPipeline Execute");
GBufferPipeline.Execute(ctx, pipelineInputs);
}
// Mouse Picking requests
if (!mousePickingRequests.empty())
@@ -334,6 +339,7 @@ void SceneRenderPipeline::Render(PassRenderContext& ctx)
VkRenderer::Get().ImmediateSubmit([&](VkCommandBuffer cmd)
{
Cmd command(cmd);
command.DebugScope("Mouse picking GPU to CPU copy");
command.TransitionImageLayout(GBufferEntityID, VkImageLayout::VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
command.CopyImageToBuffer(GBufferEntityID, stagingBuffer, request.mousePosition);
command.TransitionImageLayout(GBufferEntityID, VkImageLayout::VK_IMAGE_LAYOUT_GENERAL);

View File

@@ -29,18 +29,18 @@ bool Viewport::Resize()
viewportSize = queuedResize;
auto newRenderTarget = CreateRef<VulkanImage>(ImageFormat::RGBA16F, viewportSize);
VkRenderer::Get().ImmediateSubmit([&](VkCommandBuffer cmd)
VkRenderer::Get().ImmediateSubmit([&, newRenderTarget](VkCommandBuffer cmd)
{
Cmd command(cmd);
command.DebugScope("Viewport Resize GPGPU copy");
command.TransitionImageLayout(renderTarget, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
command.TransitionImageLayout(newRenderTarget, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
command.CopyImageToImage(renderTarget, newRenderTarget);
command.TransitionImageLayout(renderTarget, VK_IMAGE_LAYOUT_GENERAL);
command.TransitionImageLayout(newRenderTarget, VK_IMAGE_LAYOUT_GENERAL);
renderTarget = newRenderTarget;
});
renderTarget = newRenderTarget;
return true;
}

View File

@@ -14,6 +14,7 @@ namespace Nuake
class Viewport
{
private:
std::string Name;
bool Active;
UUID id;
Vector2 queuedResize;
@@ -33,6 +34,8 @@ namespace Nuake
void SetActive(bool isActive) { Active = isActive; }
bool IsActive() const { return Active; }
void SetDebugName(const std::string& name) { Name = name; }
const std::string& GetDebugName() const { return Name; }
UUID GetID() const { return id; }
UUID GetViewID() const { return viewId; }
void SetViewID(UUID inViewID) { this->viewId = inViewID; }

View File

@@ -3,6 +3,7 @@
#include "VulkanRenderer.h"
#include "VulkanAllocator.h"
#include "VulkanInit.h"
using namespace Nuake;
@@ -36,6 +37,8 @@ void VkMesh::UploadToGPU(const std::vector<Vertex>& vertices, const std::vector<
memcpy((char*)mappedData + VertexBuffer->GetSize(), indices.data(), IndexBuffer->GetSize());
VkRenderer::Get().ImmediateSubmit([&](VkCommandBuffer cmd) {
auto command = Cmd(cmd);
command.DebugScope("VkMesh UploadToGPU");
VkBufferCopy vertexCopy{ 0 };
vertexCopy.dstOffset = 0;
vertexCopy.srcOffset = 0;
@@ -65,6 +68,9 @@ void VkMesh::CreateDescriptorSet()
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
DescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
DescriptorSet = vk.GetDescriptorAllocator().Allocate(device, DescriptorLayout);
VulkanUtil::SetDebugName(DescriptorLayout, "VkMesh " + std::to_string(ID) + " DescriptorLayout");
VulkanUtil::SetDebugName(DescriptorSet, "VkMesh " + std::to_string(ID) + " DescriptorSet");
}
VkDescriptorBufferInfo bufferInfo{};

View File

@@ -91,7 +91,7 @@ namespace Nuake
constexpr uint32_t MAX_MODEL_MATRIX = 3000;
constexpr uint32_t MAX_MATERIAL = 3000;
constexpr uint32_t MAX_TEXTURES = 1000;
constexpr uint32_t MAX_TEXTURES = 3000;
constexpr uint32_t MAX_CAMERAS = 1000;
constexpr uint32_t MAX_LIGHTS = 100;

View File

@@ -5,6 +5,7 @@
#include "VulkanRenderer.h"
#include "vk_mem_alloc.h"
#include "VulkanInit.h"
#include "VkResources.h"
using namespace Nuake;
@@ -33,6 +34,8 @@ AllocatedBuffer::AllocatedBuffer(const std::string& name, size_t inSize, BufferU
AllocatedBuffer::AllocatedBuffer(inSize, inFlags, inUsage)
{
Name = name.empty() ? std::to_string(ID) : name; // Default name is just ID
VulkanUtil::SetDebugName(Buffer, "Name");
}
AllocatedBuffer::~AllocatedBuffer()

View File

@@ -62,13 +62,19 @@ VulkanImage::VulkanImage(const std::string & path) :
vmaCreateImage(VulkanAllocator::Get().GetAllocator(), &imgCreateInfo, &imgAllocInfo, &Image, &Allocation, nullptr);
VulkanUtil::SetDebugName(Image, path + "Image");
VkImageViewCreateInfo imageViewCreateInfo = VulkanInit::ImageviewCreateInfo(static_cast<VkFormat>(Format), Image, VK_IMAGE_ASPECT_COLOR_BIT);
VK_CALL(vkCreateImageView(VkRenderer::Get().GetDevice(), &imageViewCreateInfo, nullptr, &ImageView));
VulkanUtil::SetDebugName(ImageView, path + "ImageView");
// Transition image and copy data to GPU
VkRenderer::Get().ImmediateSubmit([&](VkCommandBuffer cmd)
{
Cmd command(cmd);
command.DebugScope("Image CPU to GPU Copy");
TransitionLayout(cmd, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
//VulkanUtil::TransitionImage(cmd, Image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
@@ -225,6 +231,7 @@ VulkanImage::VulkanImage(void* inData, ImageFormat inFormat, Vector2 inSize) : V
Layout = VK_IMAGE_LAYOUT_UNDEFINED;
VkRenderer::Get().ImmediateSubmit([&](VkCommandBuffer cmd)
{
TransitionLayout(cmd, VK_IMAGE_LAYOUT_GENERAL);
TransitionLayout(cmd, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
VkBufferImageCopy copyRegion = {};
@@ -296,7 +303,6 @@ VulkanImage::VulkanImage(void* inData, size_t inSize) :
vmaCreateImage(VulkanAllocator::Get().GetAllocator(), &imgCreateInfo, &imgAllocInfo, &Image, &Allocation, nullptr);
VkImageViewCreateInfo imageViewCreateInfo = VulkanInit::ImageviewCreateInfo(static_cast<VkFormat>(Format), Image, VK_IMAGE_ASPECT_COLOR_BIT);
VK_CALL(vkCreateImageView(VkRenderer::Get().GetDevice(), &imageViewCreateInfo, nullptr, &ImageView));
@@ -336,7 +342,8 @@ VulkanImage::~VulkanImage()
void VulkanImage::SetDebugName(const std::string& name)
{
GPUManaged::SetDebugName(name);
VulkanUtil::SetDebugName(Image, name);
VulkanUtil::SetDebugName(ImageView, name);
vmaSetAllocationName(VulkanAllocator::Get().GetAllocator(), Allocation, GetDebugName().data());
}
@@ -401,6 +408,7 @@ VkDescriptorSet& VulkanImage::GetImGuiDescriptorSet()
ImGuiDescriptorSetGenerated = true;
struct cleanUpData
{
VkDescriptorSet descriptorSet;
@@ -413,6 +421,8 @@ VkDescriptorSet& VulkanImage::GetImGuiDescriptorSet()
Sampler
};
AddGPUCleanUpFunc([=]() {
cleanUpData data = dataToCleanUp;
ImGui_ImplVulkan_RemoveTexture(data.descriptorSet);

View File

@@ -2,7 +2,9 @@
#include <volk/volk.h>
#include "Nuake/Core/Maths.h"
#include "Nuake/Rendering/Vulkan/VulkanRenderer.h"
#include <string>
#include <vector>
namespace Nuake
@@ -46,5 +48,80 @@ namespace Nuake
static void TransitionImage(VkCommandBuffer cmd, VkImage image, VkImageLayout currentLayout, VkImageLayout newLayout, bool isDepth = false);
static void CopyImageToImage(VkCommandBuffer cmd, VkImage source, VkImage destination, Vector2 srcSize, Vector2 dstSize);
template<typename VulkanHandleType>
static constexpr VkObjectType GetVkObjectType()
{
if constexpr (std::is_same_v<VulkanHandleType, VkBuffer>) {
return VK_OBJECT_TYPE_BUFFER;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkImage>) {
return VK_OBJECT_TYPE_IMAGE;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkShaderModule>) {
return VK_OBJECT_TYPE_SHADER_MODULE;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkPipeline>) {
return VK_OBJECT_TYPE_PIPELINE;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkDescriptorSet>) {
return VK_OBJECT_TYPE_DESCRIPTOR_SET;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkPipelineLayout>) {
return VK_OBJECT_TYPE_PIPELINE_LAYOUT;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkRenderPass>) {
return VK_OBJECT_TYPE_RENDER_PASS;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkFramebuffer>) {
return VK_OBJECT_TYPE_FRAMEBUFFER;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkDescriptorSetLayout>) {
return VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkBufferView>) {
return VK_OBJECT_TYPE_BUFFER_VIEW;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkImageView>) {
return VK_OBJECT_TYPE_IMAGE_VIEW;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkSampler>) {
return VK_OBJECT_TYPE_SAMPLER;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkSamplerYcbcrConversion>) {
return VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkPipelineCache>) {
return VK_OBJECT_TYPE_PIPELINE_CACHE;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkQueryPool>) {
return VK_OBJECT_TYPE_QUERY_POOL;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkEvent>) {
return VK_OBJECT_TYPE_EVENT;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkFence>) {
return VK_OBJECT_TYPE_FENCE;
}
else if constexpr (std::is_same_v<VulkanHandleType, VkSemaphore>) {
return VK_OBJECT_TYPE_SEMAPHORE;
}
else {
static_assert(false, "Unknown Vulkan object type.");
return VK_OBJECT_TYPE_UNKNOWN;
}
}
template<typename VulkanHandleType>
static void SetDebugName(VulkanHandleType object, const std::string& name)
{
VkDebugUtilsObjectNameInfoEXT info{};
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
info.objectType = GetVkObjectType<VulkanHandleType>();
info.objectHandle = reinterpret_cast<uint64_t>(object);
info.pObjectName = name.c_str();
vkSetDebugUtilsObjectNameEXT(VkRenderer::Get().GetDevice(), &info);
}
};
}

View File

@@ -179,6 +179,7 @@ void VkRenderer::GetInstance()
//make the vulkan instance, with basic debug features
auto instRet = builder.set_app_name("Nuake Engine")
.request_validation_layers(NKUseValidationLayer)
.enable_extension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
.use_default_debug_messenger()
.require_api_version(1, 3, 0)
.build();
@@ -209,7 +210,7 @@ void VkRenderer::SelectGPU()
{
VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
VK_KHR_LINE_RASTERIZATION_EXTENSION_NAME,
VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME
VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME,
};
auto systemInfoRet = vkb::SystemInfo::get_system_info();
@@ -219,9 +220,9 @@ void VkRenderer::SelectGPU()
{
if (!systemInfo.is_extension_available(extension))
{
std::string errMessage = "No GPU found who supports the required Vulkan extension: " + std::string(extension);
errMessage += "\nConsider updating drivers.";
Logger::Log(errMessage, "vulkan", CRITICAL);
//std::string errMessage = "No GPU found who supports the required Vulkan extension: " + std::string(extension);
//errMessage += "\nConsider updating drivers.";
//Logger::Log(errMessage, "vulkan", CRITICAL);
//OS::ShowMessageBox("Vulkan Error", errMessage);
}
}
@@ -233,7 +234,7 @@ void VkRenderer::SelectGPU()
.set_required_features_12(features12)
.set_required_features(VkPhysicalDeviceFeatures{
.fillModeNonSolid = VK_TRUE,
.wideLines = VK_TRUE
.wideLines = VK_TRUE,
})
.set_surface(Surface)
.add_required_extensions(requiredExtensions)
@@ -451,6 +452,11 @@ void VkRenderer::DrawScenes()
ctx.SelectedEntityID = viewport->GetSelectedEntityID();
SceneRenderers[view]->DrawSceneView(ctx);
Stats.ViewRenderers++;
}
else
{
Stats.ViewRenderSkipped++;
}
}
}
@@ -737,6 +743,8 @@ void VkRenderer::BeginScene(const UUID& camera)
bool VkRenderer::Draw()
{
Stats = {};
VK_CALL(vkWaitForFences(Device, 1, &GetCurrentFrame().RenderFence, true, 1000000000));
if (SurfaceSize != Window::Get()->GetSize())
@@ -798,7 +806,6 @@ bool VkRenderer::Draw()
std::mutex queueMutex;
void VkRenderer::EndDraw()
{
std::lock_guard<std::mutex> lock(queueMutex);
if (FrameSkipped)
{
@@ -894,7 +901,9 @@ void VkRenderer::ImmediateSubmit(std::function<void(VkCommandBuffer cmd)>&& func
VK_CALL(vkResetCommandBuffer(ImguiCommandBuffer, 0));
VkCommandBuffer cmd = ImguiCommandBuffer;
Cmd command(cmd);
command.DebugScope("Immediate Submit", Color(1, 1, 0, 1));
VkCommandBufferBeginInfo cmdBeginInfo = VulkanInit::CommandBufferBeginInfo(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
VK_CALL(vkBeginCommandBuffer(cmd, &cmdBeginInfo));
@@ -927,8 +936,6 @@ void DescriptorAllocator::InitPool(VkDevice device, uint32_t maxSets, std::span<
);
}
VkDescriptorPoolCreateInfo pool_info = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO };
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
pool_info.maxSets = maxSets;

View File

@@ -134,6 +134,13 @@ namespace Nuake
class Viewport;
struct RendererStats
{
int ViewRenderers = 0;
int ViewRenderSkipped = 0;
int DrawCalls = 0;
};
class VkRenderer
{
private:
@@ -165,6 +172,7 @@ namespace Nuake
DescriptorAllocator GlobalDescriptorAllocator;
public:
RendererStats Stats;
uint32_t FrameNumber = 0;
VkDescriptorSet DrawImageDescriptors;
VkDescriptorSetLayout DrawImageDescriptorLayout;

View File

@@ -3,6 +3,7 @@
#include "VulkanAllocator.h"
#include "GPUManaged.h"
#include "VulkanInit.h"
using namespace Nuake;
@@ -228,6 +229,7 @@ void GPUResources::CreateBindlessLayout()
DescriptorLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
ModelDescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
VulkanUtil::SetDebugName(ModelDescriptorLayout, "ModelDescriptorLayout");
}
// Triangles
@@ -235,6 +237,7 @@ void GPUResources::CreateBindlessLayout()
DescriptorLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
TriangleBufferDescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
VulkanUtil::SetDebugName(TriangleBufferDescriptorLayout, "TriangleBufferDescriptorLayout");
}
// SSAO kernel
@@ -242,6 +245,7 @@ void GPUResources::CreateBindlessLayout()
DescriptorLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
SSAOKernelDescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
VulkanUtil::SetDebugName(SSAOKernelDescriptorLayout, "SSAOKernelDescriptorLayout");
}
// Samplers
@@ -249,6 +253,7 @@ void GPUResources::CreateBindlessLayout()
DescriptorLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_SAMPLER, 2);
SamplerDescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
VulkanUtil::SetDebugName(SamplerDescriptorLayout, "SamplerDescriptorLayout");
}
// Material
@@ -256,6 +261,7 @@ void GPUResources::CreateBindlessLayout()
DescriptorLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
MaterialDescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
VulkanUtil::SetDebugName(MaterialDescriptorLayout, "MaterialDescriptorLayout");
}
// Textures
@@ -263,6 +269,7 @@ void GPUResources::CreateBindlessLayout()
DescriptorLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, MAX_TEXTURES);
TexturesDescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
VulkanUtil::SetDebugName(TexturesDescriptorLayout, "TexturesDescriptorLayout");
}
// bindless lights
@@ -270,6 +277,7 @@ void GPUResources::CreateBindlessLayout()
DescriptorLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
LightsDescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
VulkanUtil::SetDebugName(LightsDescriptorLayout, "LightsDescriptorLayout");
}
// bindless cameras
@@ -277,6 +285,7 @@ void GPUResources::CreateBindlessLayout()
DescriptorLayoutBuilder builder;
builder.AddBinding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
CamerasDescriptorLayout = builder.Build(device, VK_SHADER_STAGE_ALL_GRAPHICS);
VulkanUtil::SetDebugName(CamerasDescriptorLayout, "CamerasDescriptorLayout");
}
auto allocator = vk.GetDescriptorAllocator();
@@ -289,6 +298,14 @@ void GPUResources::CreateBindlessLayout()
MaterialDescriptor = allocator.Allocate(device, MaterialDescriptorLayout);
SSAOKernelDescriptor = allocator.Allocate(device, SSAOKernelDescriptorLayout);
VulkanUtil::SetDebugName(TexturesDescriptor, "TextureDescriptor");
VulkanUtil::SetDebugName(CamerasDescriptor, "CamerasDescriptor");
VulkanUtil::SetDebugName(TriangleBufferDescriptor, "TriangleBufferDescriptor");
VulkanUtil::SetDebugName(ModelDescriptor, "ModelDescriptor");
VulkanUtil::SetDebugName(LightsDescriptor, "LightsDescriptor");
VulkanUtil::SetDebugName(MaterialDescriptor, "MaterialDescriptor");
VulkanUtil::SetDebugName(SSAOKernelDescriptor, "SSAOKernelDescriptor");
// Samplers
VkPhysicalDeviceProperties properties{};
vkGetPhysicalDeviceProperties(VkRenderer::Get().GetPhysicalDevice(), &properties);