Renderer: Implement and use debug names
This commit is contained in:
parent
54aafe05a1
commit
77642cf431
|
|
@ -83,6 +83,7 @@ namespace Nz
|
|||
|
||||
struct TextureData
|
||||
{
|
||||
std::string name;
|
||||
std::shared_ptr<Texture> texture;
|
||||
PixelFormat format;
|
||||
TextureUsageFlags usage;
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ namespace Nz
|
|||
|
||||
struct TextureData
|
||||
{
|
||||
std::string name;
|
||||
PixelFormat format;
|
||||
TextureUsageFlags usage;
|
||||
unsigned int width;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ namespace Nz
|
|||
void* Map(UInt64 offset, UInt64 size) override;
|
||||
bool Unmap() override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLBuffer& operator=(const OpenGLBuffer&) = delete;
|
||||
OpenGLBuffer& operator=(OpenGLBuffer&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace Nz
|
|||
inline void SetScissor(const Recti& scissorRegion);
|
||||
inline void SetViewport(const Recti& viewportRegion);
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLCommandBuffer& operator=(const OpenGLCommandBuffer&) = delete;
|
||||
OpenGLCommandBuffer& operator=(OpenGLCommandBuffer&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ namespace Nz
|
|||
|
||||
CommandBufferPtr BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLCommandPool& operator=(const OpenGLCommandPool&) = delete;
|
||||
OpenGLCommandPool& operator=(OpenGLCommandPool&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ namespace Nz
|
|||
|
||||
const Vector2ui& GetSize() const override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLFboFramebuffer& operator=(const OpenGLFboFramebuffer&) = delete;
|
||||
OpenGLFboFramebuffer& operator=(OpenGLFboFramebuffer&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ namespace Nz
|
|||
OpenGLRenderPass(OpenGLRenderPass&&) noexcept = default;
|
||||
~OpenGLRenderPass() = default;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLRenderPass& operator=(const OpenGLRenderPass&) = delete;
|
||||
OpenGLRenderPass& operator=(OpenGLRenderPass&&) noexcept = default;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ namespace Nz
|
|||
|
||||
inline const RenderPipelineInfo& GetPipelineInfo() const override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
private:
|
||||
RenderPipelineInfo m_pipelineInfo;
|
||||
GL::Program m_program;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ namespace Nz
|
|||
inline const nzsl::GlslWriter::BindingMapping& GetBindingMapping() const;
|
||||
inline const RenderPipelineLayoutInfo& GetLayoutInfo() const;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLRenderPipelineLayout& operator=(const OpenGLRenderPipelineLayout&) = delete;
|
||||
OpenGLRenderPipelineLayout& operator=(OpenGLRenderPipelineLayout&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ namespace Nz
|
|||
|
||||
void Update(const Binding* bindings, std::size_t bindingCount) override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLShaderBinding& operator=(const OpenGLShaderBinding&) = delete;
|
||||
OpenGLShaderBinding& operator=(OpenGLShaderBinding&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <Nazara/Renderer/ShaderModule.hpp>
|
||||
#include <NZSL/GlslWriter.hpp>
|
||||
#include <NZSL/Ast/Module.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -31,6 +32,8 @@ namespace Nz
|
|||
|
||||
inline const std::vector<ExplicitBinding>& GetExplicitBindings() const;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
struct ExplicitBinding
|
||||
{
|
||||
std::string name;
|
||||
|
|
@ -61,6 +64,7 @@ namespace Nz
|
|||
|
||||
OpenGLDevice& m_device;
|
||||
nzsl::ShaderWriter::States m_states;
|
||||
std::string m_debugName;
|
||||
std::vector<ExplicitBinding> m_explicitBindings;
|
||||
std::vector<Shader> m_shaders;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ namespace Nz
|
|||
using Texture::Update;
|
||||
bool Update(const void* ptr, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLTexture& operator=(const OpenGLTexture&) = delete;
|
||||
OpenGLTexture& operator=(OpenGLTexture&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ namespace Nz
|
|||
|
||||
inline const GL::Sampler& GetSampler(bool mipmaps) const;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLTextureSampler& operator=(const OpenGLTextureSampler&) = delete;
|
||||
OpenGLTextureSampler& operator=(OpenGLTextureSampler&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ namespace Nz
|
|||
|
||||
const Vector2ui& GetSize() const override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
OpenGLWindowFramebuffer& operator=(const OpenGLWindowFramebuffer&) = delete;
|
||||
OpenGLWindowFramebuffer& operator=(OpenGLWindowFramebuffer&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -28,6 +29,8 @@ namespace Nz
|
|||
CommandBuffer(CommandBuffer&&) = delete;
|
||||
virtual ~CommandBuffer();
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
CommandBuffer& operator=(const CommandBuffer&) = delete;
|
||||
CommandBuffer& operator=(CommandBuffer&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ namespace Nz
|
|||
|
||||
virtual CommandBufferPtr BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) = 0;
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
CommandPool& operator=(const CommandPool&) = delete;
|
||||
CommandPool& operator=(CommandPool&&) = default;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ namespace Nz
|
|||
|
||||
inline FramebufferType GetType() const;
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
Framebuffer& operator=(const Framebuffer&) = delete;
|
||||
Framebuffer& operator=(Framebuffer&&) noexcept = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ namespace Nz
|
|||
inline RenderDevice& GetRenderDevice();
|
||||
inline const RenderDevice& GetRenderDevice() const;
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
RenderBuffer& operator=(const RenderBuffer&) = delete;
|
||||
RenderBuffer& operator=(RenderBuffer&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ namespace Nz
|
|||
inline const std::vector<SubpassDescription>& GetSubpassDescriptions() const;
|
||||
inline const std::vector<SubpassDependency>& GetSubpassDependencies() const;
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
RenderPass& operator=(const RenderPass&) = delete;
|
||||
RenderPass& operator=(RenderPass&&) noexcept = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ namespace Nz
|
|||
|
||||
virtual const RenderPipelineInfo& GetPipelineInfo() const = 0;
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
protected:
|
||||
static void ValidatePipelineInfo(const RenderDevice& device, RenderPipelineInfo& pipelineInfo);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ namespace Nz
|
|||
virtual ~RenderPipelineLayout();
|
||||
|
||||
virtual ShaderBindingPtr AllocateShaderBinding(UInt32 setIndex) = 0;
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -37,6 +38,8 @@ namespace Nz
|
|||
virtual void Update(const Binding* bindings, std::size_t bindingCount) = 0;
|
||||
inline void Update(std::initializer_list<Binding> bindings);
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
ShaderBinding& operator=(const ShaderBinding&) = delete;
|
||||
ShaderBinding& operator=(ShaderBinding&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ namespace Nz
|
|||
public:
|
||||
ShaderModule() = default;
|
||||
virtual ~ShaderModule();
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,11 @@ namespace Nz
|
|||
virtual Vector3ui GetSize(UInt8 level = 0) const = 0;
|
||||
virtual ImageType GetType() const = 0;
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
Texture& operator=(const Texture&) = delete;
|
||||
Texture& operator=(Texture&&) = delete;
|
||||
|
||||
static inline unsigned int GetLevelSize(unsigned int size, unsigned int level);
|
||||
|
||||
static std::shared_ptr<Texture> CreateFromImage(const Image& image, const TextureParams& params);
|
||||
|
|
@ -79,9 +84,6 @@ namespace Nz
|
|||
static std::shared_ptr<Texture> LoadCubemapFromFile(const std::filesystem::path& filePath, const TextureParams& textureParams, const CubemapParams& cubemapParams = CubemapParams());
|
||||
static std::shared_ptr<Texture> LoadCubemapFromMemory(const void* data, std::size_t size, const TextureParams& textureParams, const CubemapParams& cubemapParams = CubemapParams());
|
||||
static std::shared_ptr<Texture> LoadCubemapFromStream(Stream& stream, const TextureParams& textureParams, const CubemapParams& cubemapParams = CubemapParams());
|
||||
|
||||
Texture& operator=(const Texture&) = delete;
|
||||
Texture& operator=(Texture&&) = delete;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ namespace Nz
|
|||
TextureSampler(TextureSampler&&) = delete;
|
||||
virtual ~TextureSampler();
|
||||
|
||||
virtual void UpdateDebugName(std::string_view name) = 0;
|
||||
|
||||
TextureSampler& operator=(const TextureSampler&) = delete;
|
||||
TextureSampler& operator=(TextureSampler&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ namespace Nz
|
|||
void* Map(UInt64 offset, UInt64 size) override;
|
||||
bool Unmap() override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
VulkanBuffer& operator=(const VulkanBuffer&) = delete;
|
||||
VulkanBuffer& operator=(VulkanBuffer&&) = delete; ///TODO
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ namespace Nz
|
|||
inline std::size_t GetPoolIndex() const;
|
||||
inline const VulkanCommandPool& GetOwner() const;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
VulkanCommandBuffer& operator=(const VulkanCommandBuffer&) = delete;
|
||||
VulkanCommandBuffer& operator=(VulkanCommandBuffer&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ namespace Nz
|
|||
|
||||
CommandBufferPtr BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
VulkanCommandPool& operator=(const VulkanCommandPool&) = delete;
|
||||
VulkanCommandPool& operator=(VulkanCommandPool&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ namespace Nz
|
|||
public:
|
||||
using Framebuffer::Framebuffer;
|
||||
|
||||
virtual Vk::Framebuffer& GetFramebuffer() = 0;
|
||||
virtual const Vk::Framebuffer& GetFramebuffer() const = 0;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ namespace Nz
|
|||
inline Vk::RenderPass& GetRenderPass();
|
||||
inline const Vk::RenderPass& GetRenderPass() const;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
VulkanRenderPass& operator=(const VulkanRenderPass&) = delete;
|
||||
VulkanRenderPass& operator=(VulkanRenderPass&&) noexcept = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <Nazara/VulkanRenderer/Wrapper/Device.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Pipeline.hpp>
|
||||
#include <Nazara/Utils/MovablePtr.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -35,6 +36,8 @@ namespace Nz
|
|||
|
||||
inline const RenderPipelineInfo& GetPipelineInfo() const override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
VulkanRenderPipeline& operator=(const VulkanRenderPipeline&) = delete;
|
||||
VulkanRenderPipeline& operator=(VulkanRenderPipeline&&) = delete;
|
||||
|
||||
|
|
@ -93,6 +96,7 @@ namespace Nz
|
|||
Vk::Pipeline pipeline;
|
||||
};
|
||||
|
||||
std::string m_debugName;
|
||||
mutable std::unordered_map<std::pair<VkRenderPass, std::size_t>, PipelineData, PipelineHasher> m_pipelines;
|
||||
MovablePtr<Vk::Device> m_device;
|
||||
mutable CreateInfo m_pipelineCreateInfo;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ namespace Nz
|
|||
|
||||
inline const Vk::PipelineLayout& GetPipelineLayout() const;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
private:
|
||||
struct DescriptorPool;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ namespace Nz
|
|||
|
||||
void Update(const Binding* bindings, std::size_t bindingCount) override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
VulkanShaderBinding& operator=(const VulkanShaderBinding&) = delete;
|
||||
VulkanShaderBinding& operator=(VulkanShaderBinding&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ namespace Nz
|
|||
inline const Vk::ShaderModule& GetHandle() const;
|
||||
inline const std::vector<Stage>& GetStages() const;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
struct Stage
|
||||
{
|
||||
nzsl::ShaderStageType stage;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ namespace Nz
|
|||
using Texture::Update;
|
||||
bool Update(const void* ptr, const Boxui& box, unsigned int srcWidth, unsigned int srcHeight, UInt8 level) override;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
VulkanTexture& operator=(const VulkanTexture&) = delete;
|
||||
VulkanTexture& operator=(VulkanTexture&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace Nz
|
|||
VulkanTextureFramebuffer(VulkanTextureFramebuffer&&) = delete;
|
||||
~VulkanTextureFramebuffer() = default;
|
||||
|
||||
inline Vk::Framebuffer& GetFramebuffer() override;
|
||||
inline const Vk::Framebuffer& GetFramebuffer() const override;
|
||||
|
||||
VulkanTextureFramebuffer& operator=(const VulkanTextureFramebuffer&) = delete;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
inline Vk::Framebuffer& VulkanTextureFramebuffer::GetFramebuffer()
|
||||
{
|
||||
return m_framebuffer;
|
||||
}
|
||||
|
||||
inline const Vk::Framebuffer& VulkanTextureFramebuffer::GetFramebuffer() const
|
||||
{
|
||||
return m_framebuffer;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ namespace Nz
|
|||
|
||||
inline VkSampler GetSampler() const;
|
||||
|
||||
void UpdateDebugName(std::string_view name) override;
|
||||
|
||||
VulkanTextureSampler& operator=(const VulkanTextureSampler&) = delete;
|
||||
VulkanTextureSampler& operator=(VulkanTextureSampler&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace Nz
|
|||
VulkanWindowFramebuffer(VulkanWindowFramebuffer&&) noexcept = default;
|
||||
~VulkanWindowFramebuffer() = default;
|
||||
|
||||
inline Vk::Framebuffer& GetFramebuffer() override;
|
||||
inline const Vk::Framebuffer& GetFramebuffer() const override;
|
||||
|
||||
VulkanWindowFramebuffer& operator=(const VulkanWindowFramebuffer&) = delete;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,12 @@ namespace Nz
|
|||
{
|
||||
}
|
||||
|
||||
inline const Vk::Framebuffer& Nz::VulkanWindowFramebuffer::GetFramebuffer() const
|
||||
inline Vk::Framebuffer& VulkanWindowFramebuffer::GetFramebuffer()
|
||||
{
|
||||
return m_framebuffer;
|
||||
}
|
||||
|
||||
inline const Vk::Framebuffer& VulkanWindowFramebuffer::GetFramebuffer() const
|
||||
{
|
||||
return m_framebuffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ namespace Nz
|
|||
|
||||
inline void Free();
|
||||
|
||||
inline VkResult GetLastErrorCode() const;
|
||||
inline CommandPool& GetPool();
|
||||
|
||||
inline void ImageBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout, VkImage image, VkImageAspectFlags aspectFlags);
|
||||
|
|
@ -104,8 +105,6 @@ namespace Nz
|
|||
inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout);
|
||||
inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange);
|
||||
|
||||
inline VkResult GetLastErrorCode() const;
|
||||
|
||||
CommandBuffer& operator=(const CommandBuffer&) = delete;
|
||||
CommandBuffer& operator=(CommandBuffer&& commandBuffer) noexcept;
|
||||
|
||||
|
|
|
|||
|
|
@ -345,6 +345,11 @@ namespace Nz
|
|||
}
|
||||
}
|
||||
|
||||
inline VkResult CommandBuffer::GetLastErrorCode() const
|
||||
{
|
||||
return m_lastErrorCode;
|
||||
}
|
||||
|
||||
inline CommandPool& CommandBuffer::GetPool()
|
||||
{
|
||||
return *m_pool;
|
||||
|
|
@ -586,11 +591,6 @@ namespace Nz
|
|||
return m_pool->GetDevice()->vkCmdSetViewport(m_handle, firstViewport, viewportCount, viewports);
|
||||
}
|
||||
|
||||
inline VkResult CommandBuffer::GetLastErrorCode() const
|
||||
{
|
||||
return m_lastErrorCode;
|
||||
}
|
||||
|
||||
inline CommandBuffer& CommandBuffer::operator=(CommandBuffer&& commandBuffer) noexcept
|
||||
{
|
||||
m_lastErrorCode = commandBuffer.m_lastErrorCode;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ namespace Nz
|
|||
inline bool IsExtensionLoaded(const std::string& extensionName);
|
||||
inline bool IsLayerLoaded(const std::string& layerName);
|
||||
|
||||
inline void SetDebugName(VkObjectType objectType, UInt64 objectHandle, const char* name);
|
||||
inline void SetDebugName(VkObjectType objectType, UInt64 objectHandle, std::string_view name);
|
||||
inline void SetDebugName(VkObjectType objectType, UInt64 objectHandle, const std::string& name);
|
||||
|
||||
inline bool WaitForIdle();
|
||||
|
||||
Device& operator=(const Device&) = delete;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <Nazara/VulkanRenderer/Wrapper/Device.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Utils/StackArray.hpp>
|
||||
#include <Nazara/VulkanRenderer/Utils.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Instance.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
|
@ -87,6 +88,40 @@ namespace Nz::Vk
|
|||
return m_loadedLayers.count(layerName) > 0;
|
||||
}
|
||||
|
||||
inline void Device::SetDebugName(VkObjectType objectType, UInt64 objectHandle, const char* name)
|
||||
{
|
||||
if (vkSetDebugUtilsObjectNameEXT)
|
||||
{
|
||||
VkDebugUtilsObjectNameInfoEXT debugName = {
|
||||
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
|
||||
nullptr,
|
||||
objectType,
|
||||
objectHandle,
|
||||
name
|
||||
};
|
||||
|
||||
vkSetDebugUtilsObjectNameEXT(m_device, &debugName);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Device::SetDebugName(VkObjectType objectType, UInt64 objectHandle, std::string_view name)
|
||||
{
|
||||
if (vkSetDebugUtilsObjectNameEXT)
|
||||
{
|
||||
// Ensure \0 at the end of string
|
||||
StackArray<char> nullTerminatedName = NazaraStackArrayNoInit(char, name.size() + 1);
|
||||
std::memcpy(nullTerminatedName.data(), name.data(), name.size());
|
||||
nullTerminatedName[name.size()] = '\0';
|
||||
|
||||
return SetDebugName(objectType, objectHandle, nullTerminatedName.data());
|
||||
}
|
||||
}
|
||||
|
||||
inline void Device::SetDebugName(VkObjectType objectType, UInt64 objectHandle, const std::string& name)
|
||||
{
|
||||
return SetDebugName(objectType, objectHandle, name.data());
|
||||
}
|
||||
|
||||
inline bool Device::WaitForIdle()
|
||||
{
|
||||
m_lastErrorCode = vkDeviceWaitIdle(m_device);
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ namespace Nz::Vk
|
|||
Device* GetDevice() const;
|
||||
VkResult GetLastErrorCode() const;
|
||||
|
||||
void SetDebugName(const char* name);
|
||||
void SetDebugName(const std::string& name);
|
||||
template<typename T> void SetDebugName(T&& name);
|
||||
|
||||
DeviceObject& operator=(const DeviceObject&) = delete;
|
||||
DeviceObject& operator=(DeviceObject&& object) noexcept;
|
||||
|
|
|
|||
|
|
@ -83,31 +83,16 @@ namespace Nz::Vk
|
|||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
void DeviceObject<C, VkType, CreateInfo, ObjectType>::SetDebugName(const char* name)
|
||||
template<typename T>
|
||||
void DeviceObject<C, VkType, CreateInfo, ObjectType>::SetDebugName(T&& name)
|
||||
{
|
||||
if (m_device->vkSetDebugUtilsObjectNameEXT)
|
||||
{
|
||||
VkDebugUtilsObjectNameInfoEXT debugName = {
|
||||
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
|
||||
nullptr,
|
||||
ObjectType,
|
||||
0,
|
||||
name
|
||||
};
|
||||
UInt64 objectHandle;
|
||||
if constexpr (std::is_pointer_v<VkType>)
|
||||
objectHandle = static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_handle));
|
||||
else
|
||||
objectHandle = static_cast<UInt64>(m_handle);
|
||||
|
||||
if constexpr (std::is_pointer_v<VkType>)
|
||||
debugName.objectHandle = static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_handle));
|
||||
else
|
||||
debugName.objectHandle = static_cast<UInt64>(m_handle);
|
||||
|
||||
m_device->vkSetDebugUtilsObjectNameEXT(*m_device, &debugName);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
void DeviceObject<C, VkType, CreateInfo, ObjectType>::SetDebugName(const std::string& name)
|
||||
{
|
||||
return SetDebugName(name.data());
|
||||
return m_device->SetDebugName(ObjectType, objectHandle, std::forward<T>(name));
|
||||
}
|
||||
|
||||
template<typename C, typename VkType, typename CreateInfo, VkObjectType ObjectType>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp>
|
||||
#include <string_view>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -29,6 +30,8 @@ namespace Nz
|
|||
inline Device& GetDevice() const;
|
||||
inline VkResult GetLastErrorCode() const;
|
||||
|
||||
inline void SetDebugName(std::string_view name);
|
||||
|
||||
Pipeline& operator=(const Pipeline&) = delete;
|
||||
Pipeline& operator=(Pipeline&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Pipeline.hpp>
|
||||
#include <Nazara/VulkanRenderer/Utils.hpp>
|
||||
#include <Nazara/Utils/StackArray.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -58,6 +59,11 @@ namespace Nz
|
|||
return m_lastErrorCode;
|
||||
}
|
||||
|
||||
inline void Pipeline::SetDebugName(std::string_view name)
|
||||
{
|
||||
return m_device->SetDebugName(VK_OBJECT_TYPE_PIPELINE, static_cast<UInt64>(reinterpret_cast<std::uintptr_t>(m_handle)), name);
|
||||
}
|
||||
|
||||
inline Pipeline::operator VkPipeline() const
|
||||
{
|
||||
return m_handle;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue