Renderer: Implement and use debug names
This commit is contained in:
@@ -157,6 +157,8 @@ namespace Nz
|
||||
textureCreationParams.pixelFormat = textureData.format;
|
||||
|
||||
textureData.texture = renderDevice->InstantiateTexture(textureCreationParams);
|
||||
if (!textureData.name.empty())
|
||||
textureData.texture->UpdateDebugName(textureData.name);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Texture>> textures;
|
||||
@@ -181,6 +183,9 @@ namespace Nz
|
||||
passData.renderRect.Set(0, 0, int(framebufferWidth), int(framebufferHeight));
|
||||
|
||||
passData.framebuffer = renderDevice->InstantiateFramebuffer(framebufferWidth, framebufferHeight, passData.renderPass, textures);
|
||||
if (!passData.name.empty())
|
||||
passData.framebuffer->UpdateDebugName(passData.name);
|
||||
|
||||
passData.forceCommandBufferRegeneration = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ namespace Nz
|
||||
for (auto& texture : m_pending.textures)
|
||||
{
|
||||
auto& bakedTexture = bakedTextures.emplace_back();
|
||||
bakedTexture.name = std::move(texture.name);
|
||||
bakedTexture.format = texture.format;
|
||||
bakedTexture.height = texture.height;
|
||||
bakedTexture.usage = texture.usage;
|
||||
@@ -161,7 +162,7 @@ namespace Nz
|
||||
if (currentPass.name.empty())
|
||||
currentPass.name = pass.GetName();
|
||||
else
|
||||
currentPass.name += " + " + pass.GetName();
|
||||
currentPass.name += " / " + pass.GetName();
|
||||
|
||||
auto& subpass = currentPass.passes.emplace_back();
|
||||
subpass.passIndex = *it;
|
||||
@@ -957,6 +958,9 @@ namespace Nz
|
||||
m_pending.texturePool.erase(it);
|
||||
m_pending.attachmentToTextures.emplace(attachmentIndex, textureId);
|
||||
|
||||
if (!attachmentData.name.empty() && data.name != attachmentData.name)
|
||||
data.name += " / " + attachmentData.name;
|
||||
|
||||
return textureId;
|
||||
}
|
||||
|
||||
@@ -964,6 +968,7 @@ namespace Nz
|
||||
m_pending.attachmentToTextures.emplace(attachmentIndex, textureId);
|
||||
|
||||
TextureData& data = m_pending.textures.emplace_back();
|
||||
data.name = attachmentData.name;
|
||||
data.format = attachmentData.format;
|
||||
data.width = attachmentData.width;
|
||||
data.height = attachmentData.height;
|
||||
|
||||
@@ -62,4 +62,9 @@ namespace Nz
|
||||
{
|
||||
return m_buffer.Unmap();
|
||||
}
|
||||
|
||||
void OpenGLBuffer::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_buffer.SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +321,11 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCommandBuffer::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
// No OpenGL object to name
|
||||
}
|
||||
|
||||
void OpenGLCommandBuffer::ApplyStates(const GL::Context& context, const DrawStates& states)
|
||||
{
|
||||
states.pipeline->Apply(context, states.shouldFlipY);
|
||||
|
||||
@@ -36,6 +36,11 @@ namespace Nz
|
||||
return commandBuffer;
|
||||
}
|
||||
|
||||
void OpenGLCommandPool::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
// No OpenGL object to name
|
||||
}
|
||||
|
||||
auto OpenGLCommandPool::AllocatePool() -> CommandPool&
|
||||
{
|
||||
constexpr UInt32 MaxSet = 128;
|
||||
|
||||
@@ -103,4 +103,9 @@ namespace Nz
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void OpenGLFboFramebuffer::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_framebuffer.SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,8 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void OpenGLRenderPass::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
// No OpenGL object to name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,4 +103,9 @@ namespace Nz
|
||||
m_isViewportFlipped = flipViewport;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLRenderPipeline::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_program.SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace Nz
|
||||
return bindingPtr;
|
||||
}
|
||||
|
||||
void OpenGLRenderPipelineLayout::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
// No OpenGL object to name
|
||||
}
|
||||
|
||||
auto OpenGLRenderPipelineLayout::AllocatePool() -> DescriptorPool&
|
||||
{
|
||||
constexpr UInt32 MaxSet = 128;
|
||||
|
||||
@@ -132,6 +132,11 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLShaderBinding::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
// No OpenGL object to name
|
||||
}
|
||||
|
||||
void OpenGLShaderBinding::Release()
|
||||
{
|
||||
m_owner.Release(*this);
|
||||
|
||||
@@ -113,6 +113,9 @@ namespace Nz
|
||||
if (!shader.Create(m_device, ToOpenGL(shaderEntry.stage)))
|
||||
throw std::runtime_error("failed to create shader"); //< TODO: Handle error message
|
||||
|
||||
if (!m_debugName.empty())
|
||||
shader.SetDebugName(m_debugName);
|
||||
|
||||
std::visit([&](auto&& arg)
|
||||
{
|
||||
using T = std::decay_t<decltype(arg)>;
|
||||
@@ -161,6 +164,11 @@ namespace Nz
|
||||
return stageFlags;
|
||||
}
|
||||
|
||||
void OpenGLShaderModule::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_debugName = name;
|
||||
}
|
||||
|
||||
void OpenGLShaderModule::Create(OpenGLDevice& /*device*/, nzsl::ShaderStageTypeFlags shaderStages, const nzsl::Ast::Module& shaderModule, const nzsl::ShaderWriter::States& states)
|
||||
{
|
||||
m_states = states;
|
||||
|
||||
@@ -145,4 +145,9 @@ namespace Nz
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenGLTexture::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_texture.SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,10 @@ namespace Nz
|
||||
if (samplerInfo.anisotropyLevel > 1.f)
|
||||
sampler.SetParameterf(GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerInfo.anisotropyLevel);
|
||||
}
|
||||
|
||||
void OpenGLTextureSampler::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_samplerWithMipmaps.SetDebugName(name);
|
||||
m_samplerWithoutMipmaps.SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,9 @@ namespace Nz
|
||||
{
|
||||
return m_renderWindow.GetSize();
|
||||
}
|
||||
|
||||
void OpenGLWindowFramebuffer::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
// No OpenGL object to name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ namespace Nz
|
||||
}
|
||||
|
||||
texture->SetFilePath(image.GetFilePath());
|
||||
if (std::string debugName = image.GetFilePath().generic_u8string(); !debugName.empty())
|
||||
texture->UpdateDebugName(debugName);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
@@ -136,6 +136,11 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanBuffer::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
return m_device.SetDebugName(VK_OBJECT_TYPE_BUFFER, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_buffer)), name);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void VulkanCommandBuffer::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
return m_owner.m_device->SetDebugName(VK_OBJECT_TYPE_COMMAND_BUFFER, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(static_cast<VkCommandBuffer>(m_commandBuffer))), name);
|
||||
}
|
||||
|
||||
void VulkanCommandBuffer::Release()
|
||||
{
|
||||
m_owner.Release(*this);
|
||||
|
||||
@@ -38,7 +38,12 @@ namespace Nz
|
||||
|
||||
return AllocateFromPool(newPoolIndex, std::move(commandBuffer));
|
||||
}
|
||||
|
||||
|
||||
void VulkanCommandPool::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_commandPool.SetDebugName(name);
|
||||
}
|
||||
|
||||
auto VulkanCommandPool::AllocatePool() -> CommandPool&
|
||||
{
|
||||
constexpr UInt32 MaxSet = 128;
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void VulkanFramebuffer::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
GetFramebuffer().SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
||||
@@ -133,6 +133,11 @@ namespace Nz
|
||||
{
|
||||
OnRenderPassRelease(this);
|
||||
}
|
||||
|
||||
void VulkanRenderPass::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
return m_renderPass.SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
||||
@@ -51,10 +51,18 @@ namespace Nz
|
||||
if (!pipelineData.pipeline.CreateGraphics(*m_device, pipelineCreateInfo))
|
||||
return VK_NULL_HANDLE;
|
||||
|
||||
if (!m_debugName.empty())
|
||||
pipelineData.pipeline.SetDebugName(m_debugName);
|
||||
|
||||
auto it = m_pipelines.emplace(key, std::move(pipelineData)).first;
|
||||
return it->second.pipeline;
|
||||
}
|
||||
|
||||
void VulkanRenderPipeline::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_debugName = name;
|
||||
}
|
||||
|
||||
std::vector<VkPipelineColorBlendAttachmentState> VulkanRenderPipeline::BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo)
|
||||
{
|
||||
std::vector<VkPipelineColorBlendAttachmentState> colorBlendStates;
|
||||
|
||||
@@ -87,6 +87,11 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
void VulkanRenderPipelineLayout::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_pipelineLayout.SetDebugName(name);
|
||||
}
|
||||
|
||||
auto VulkanRenderPipelineLayout::AllocatePool() -> DescriptorPool&
|
||||
{
|
||||
StackVector<VkDescriptorPoolSize> poolSizes = NazaraStackVector(VkDescriptorPoolSize, m_layoutInfo.bindings.size());
|
||||
|
||||
@@ -81,6 +81,11 @@ namespace Nz
|
||||
m_owner.GetDevice()->vkUpdateDescriptorSets(*m_owner.GetDevice(), UInt32(writeOps.size()), writeOps.data(), 0U, nullptr);
|
||||
}
|
||||
|
||||
void VulkanShaderBinding::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
return m_owner.m_device->SetDebugName(VK_OBJECT_TYPE_DESCRIPTOR_SET, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(static_cast<VkDescriptorSet>(m_descriptorSet))), name);
|
||||
}
|
||||
|
||||
void VulkanShaderBinding::Release()
|
||||
{
|
||||
m_owner.Release(*this);
|
||||
|
||||
@@ -146,6 +146,11 @@ namespace Nz
|
||||
NazaraError("this language is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
void VulkanShaderModule::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
m_shaderModule.SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
||||
@@ -339,6 +339,11 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
void VulkanTexture::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
return m_device.SetDebugName(VK_OBJECT_TYPE_IMAGE, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_image)), name);
|
||||
}
|
||||
|
||||
void VulkanTexture::InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView)
|
||||
{
|
||||
createImageView.components = {
|
||||
|
||||
@@ -32,6 +32,11 @@ namespace Nz
|
||||
if (!m_sampler.Create(device, createInfo))
|
||||
throw std::runtime_error("Failed to create sampler: " + TranslateVulkanError(m_sampler.GetLastErrorCode()));
|
||||
}
|
||||
|
||||
void VulkanTextureSampler::UpdateDebugName(std::string_view name)
|
||||
{
|
||||
return m_sampler.SetDebugName(name);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
|
||||
Reference in New Issue
Block a user