diff --git a/Source/Core/VideoBackends/D3D/D3DRender.cpp b/Source/Core/VideoBackends/D3D/D3DRender.cpp index f3db6d815a..129465c114 100644 --- a/Source/Core/VideoBackends/D3D/D3DRender.cpp +++ b/Source/Core/VideoBackends/D3D/D3DRender.cpp @@ -52,9 +52,10 @@ bool Renderer::IsHeadless() const return !m_swap_chain; } -std::unique_ptr Renderer::CreateTexture(const TextureConfig& config) +std::unique_ptr Renderer::CreateTexture(const TextureConfig& config, + std::string_view name) { - return DXTexture::Create(config); + return DXTexture::Create(config, name); } std::unique_ptr Renderer::CreateStagingTexture(StagingTextureType type, @@ -70,20 +71,21 @@ std::unique_ptr Renderer::CreateFramebuffer(AbstractTexture static_cast(depth_attachment)); } -std::unique_ptr Renderer::CreateShaderFromSource(ShaderStage stage, - std::string_view source) +std::unique_ptr +Renderer::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::string_view name) { auto bytecode = DXShader::CompileShader(D3D::feature_level, stage, source); if (!bytecode) return nullptr; - return DXShader::CreateFromBytecode(stage, std::move(*bytecode)); + return DXShader::CreateFromBytecode(stage, std::move(*bytecode), name); } std::unique_ptr Renderer::CreateShaderFromBinary(ShaderStage stage, - const void* data, size_t length) + const void* data, size_t length, + std::string_view name) { - return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length)); + return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name); } std::unique_ptr Renderer::CreatePipeline(const AbstractPipelineConfig& config, diff --git a/Source/Core/VideoBackends/D3D/D3DRender.h b/Source/Core/VideoBackends/D3D/D3DRender.h index b4f34a2b53..0d76fea819 100644 --- a/Source/Core/VideoBackends/D3D/D3DRender.h +++ b/Source/Core/VideoBackends/D3D/D3DRender.h @@ -24,13 +24,15 @@ public: bool IsHeadless() const override; - std::unique_ptr CreateTexture(const TextureConfig& config) override; + std::unique_ptr CreateTexture(const TextureConfig& config, + std::string_view name) override; std::unique_ptr CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; - std::unique_ptr CreateShaderFromSource(ShaderStage stage, - std::string_view source) override; + std::unique_ptr CreateShaderFromSource(ShaderStage stage, std::string_view source, + std::string_view name) override; std::unique_ptr CreateShaderFromBinary(ShaderStage stage, const void* data, - size_t length) override; + size_t length, + std::string_view name) override; std::unique_ptr CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, diff --git a/Source/Core/VideoBackends/D3D/DXShader.cpp b/Source/Core/VideoBackends/D3D/DXShader.cpp index 569cc65946..58d2ed6bf8 100644 --- a/Source/Core/VideoBackends/D3D/DXShader.cpp +++ b/Source/Core/VideoBackends/D3D/DXShader.cpp @@ -7,9 +7,15 @@ namespace DX11 { -DXShader::DXShader(ShaderStage stage, BinaryData bytecode, ID3D11DeviceChild* shader) - : D3DCommon::Shader(stage, std::move(bytecode)), m_shader(shader) +DXShader::DXShader(ShaderStage stage, BinaryData bytecode, ID3D11DeviceChild* shader, + std::string_view name) + : D3DCommon::Shader(stage, std::move(bytecode)), m_shader(shader), m_name(name) { + if (!m_name.empty()) + { + m_shader->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(m_name.size()), + m_name.data()); + } } DXShader::~DXShader() = default; @@ -38,7 +44,8 @@ ID3D11ComputeShader* DXShader::GetD3DComputeShader() const return static_cast(m_shader.Get()); } -std::unique_ptr DXShader::CreateFromBytecode(ShaderStage stage, BinaryData bytecode) +std::unique_ptr DXShader::CreateFromBytecode(ShaderStage stage, BinaryData bytecode, + std::string_view name) { switch (stage) { @@ -50,7 +57,7 @@ std::unique_ptr DXShader::CreateFromBytecode(ShaderStage stage, Binary if (FAILED(hr)) return nullptr; - return std::make_unique(ShaderStage::Vertex, std::move(bytecode), vs.Get()); + return std::make_unique(ShaderStage::Vertex, std::move(bytecode), vs.Get(), name); } case ShaderStage::Geometry: @@ -61,7 +68,7 @@ std::unique_ptr DXShader::CreateFromBytecode(ShaderStage stage, Binary if (FAILED(hr)) return nullptr; - return std::make_unique(ShaderStage::Geometry, std::move(bytecode), gs.Get()); + return std::make_unique(ShaderStage::Geometry, std::move(bytecode), gs.Get(), name); } break; @@ -73,7 +80,7 @@ std::unique_ptr DXShader::CreateFromBytecode(ShaderStage stage, Binary if (FAILED(hr)) return nullptr; - return std::make_unique(ShaderStage::Pixel, std::move(bytecode), ps.Get()); + return std::make_unique(ShaderStage::Pixel, std::move(bytecode), ps.Get(), name); } break; @@ -85,7 +92,7 @@ std::unique_ptr DXShader::CreateFromBytecode(ShaderStage stage, Binary if (FAILED(hr)) return nullptr; - return std::make_unique(ShaderStage::Compute, std::move(bytecode), cs.Get()); + return std::make_unique(ShaderStage::Compute, std::move(bytecode), cs.Get(), name); } break; diff --git a/Source/Core/VideoBackends/D3D/DXShader.h b/Source/Core/VideoBackends/D3D/DXShader.h index dbb9bc701e..69164bd2f2 100644 --- a/Source/Core/VideoBackends/D3D/DXShader.h +++ b/Source/Core/VideoBackends/D3D/DXShader.h @@ -2,7 +2,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once + #include +#include +#include #include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3DCommon/Shader.h" @@ -12,7 +15,8 @@ namespace DX11 class DXShader final : public D3DCommon::Shader { public: - DXShader(ShaderStage stage, BinaryData bytecode, ID3D11DeviceChild* shader); + DXShader(ShaderStage stage, BinaryData bytecode, ID3D11DeviceChild* shader, + std::string_view name); ~DXShader() override; ID3D11VertexShader* GetD3DVertexShader() const; @@ -20,10 +24,12 @@ public: ID3D11PixelShader* GetD3DPixelShader() const; ID3D11ComputeShader* GetD3DComputeShader() const; - static std::unique_ptr CreateFromBytecode(ShaderStage stage, BinaryData bytecode); + static std::unique_ptr CreateFromBytecode(ShaderStage stage, BinaryData bytecode, + std::string_view name); private: ComPtr m_shader; + std::string m_name; }; } // namespace DX11 diff --git a/Source/Core/VideoBackends/D3D/DXTexture.cpp b/Source/Core/VideoBackends/D3D/DXTexture.cpp index 72fe7958c2..1247b32fc7 100644 --- a/Source/Core/VideoBackends/D3D/DXTexture.cpp +++ b/Source/Core/VideoBackends/D3D/DXTexture.cpp @@ -15,9 +15,15 @@ namespace DX11 { -DXTexture::DXTexture(const TextureConfig& config, ComPtr texture) - : AbstractTexture(config), m_texture(std::move(texture)) +DXTexture::DXTexture(const TextureConfig& config, ComPtr texture, + std::string_view name) + : AbstractTexture(config), m_texture(std::move(texture)), m_name(name) { + if (!m_name.empty()) + { + m_texture->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(m_name.size()), + m_name.c_str()); + } } DXTexture::~DXTexture() @@ -26,7 +32,7 @@ DXTexture::~DXTexture() D3D::stateman->ApplyTextures(); } -std::unique_ptr DXTexture::Create(const TextureConfig& config) +std::unique_ptr DXTexture::Create(const TextureConfig& config, std::string_view name) { // Use typeless to create the texture when it's a render target, so we can alias it with an // integer format (for EFB). @@ -49,7 +55,7 @@ std::unique_ptr DXTexture::Create(const TextureConfig& config) return nullptr; } - std::unique_ptr tex(new DXTexture(config, std::move(d3d_texture))); + std::unique_ptr tex(new DXTexture(config, std::move(d3d_texture), name)); if (!tex->CreateSRV() || (config.IsComputeImage() && !tex->CreateUAV())) return nullptr; @@ -70,7 +76,7 @@ std::unique_ptr DXTexture::CreateAdopted(ComPtr text if (desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS) config.flags |= AbstractTextureFlag_ComputeImage; - std::unique_ptr tex(new DXTexture(config, std::move(texture))); + std::unique_ptr tex(new DXTexture(config, std::move(texture), "")); if (desc.BindFlags & D3D11_BIND_SHADER_RESOURCE && !tex->CreateSRV()) return nullptr; if (desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS && !tex->CreateUAV()) diff --git a/Source/Core/VideoBackends/D3D/DXTexture.h b/Source/Core/VideoBackends/D3D/DXTexture.h index a899f0664f..a49b4902e4 100644 --- a/Source/Core/VideoBackends/D3D/DXTexture.h +++ b/Source/Core/VideoBackends/D3D/DXTexture.h @@ -5,6 +5,8 @@ #include #include +#include +#include #include "Common/CommonTypes.h" #include "VideoCommon/AbstractFramebuffer.h" @@ -18,7 +20,7 @@ class DXTexture final : public AbstractTexture public: ~DXTexture(); - static std::unique_ptr Create(const TextureConfig& config); + static std::unique_ptr Create(const TextureConfig& config, std::string_view name); static std::unique_ptr CreateAdopted(ComPtr texture); void CopyRectangleFromTexture(const AbstractTexture* src, @@ -35,7 +37,7 @@ public: ID3D11UnorderedAccessView* GetD3DUAV() const { return m_uav.Get(); } private: - DXTexture(const TextureConfig& config, ComPtr texture); + DXTexture(const TextureConfig& config, ComPtr texture, std::string_view name); bool CreateSRV(); bool CreateUAV(); @@ -43,6 +45,7 @@ private: ComPtr m_texture; ComPtr m_srv; ComPtr m_uav; + std::string m_name; }; class DXStagingTexture final : public AbstractStagingTexture diff --git a/Source/Core/VideoBackends/D3D12/D3D12Renderer.cpp b/Source/Core/VideoBackends/D3D12/D3D12Renderer.cpp index bcc994a376..ceb21e7376 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12Renderer.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12Renderer.cpp @@ -62,9 +62,10 @@ void Renderer::Shutdown() ::Renderer::Shutdown(); } -std::unique_ptr Renderer::CreateTexture(const TextureConfig& config) +std::unique_ptr Renderer::CreateTexture(const TextureConfig& config, + std::string_view name) { - return DXTexture::Create(config); + return DXTexture::Create(config, name); } std::unique_ptr Renderer::CreateStagingTexture(StagingTextureType type, @@ -80,16 +81,17 @@ std::unique_ptr Renderer::CreateFramebuffer(AbstractTexture static_cast(depth_attachment)); } -std::unique_ptr Renderer::CreateShaderFromSource(ShaderStage stage, - std::string_view source) +std::unique_ptr +Renderer::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::string_view name) { - return DXShader::CreateFromSource(stage, source); + return DXShader::CreateFromSource(stage, source, name); } std::unique_ptr Renderer::CreateShaderFromBinary(ShaderStage stage, - const void* data, size_t length) + const void* data, size_t length, + std::string_view name) { - return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length)); + return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name); } std::unique_ptr diff --git a/Source/Core/VideoBackends/D3D12/D3D12Renderer.h b/Source/Core/VideoBackends/D3D12/D3D12Renderer.h index d931e115f9..7073cac1a3 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12Renderer.h +++ b/Source/Core/VideoBackends/D3D12/D3D12Renderer.h @@ -30,16 +30,18 @@ public: bool Initialize() override; void Shutdown() override; - std::unique_ptr CreateTexture(const TextureConfig& config) override; + std::unique_ptr CreateTexture(const TextureConfig& config, + std::string_view name) override; std::unique_ptr CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; std::unique_ptr CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override; - std::unique_ptr CreateShaderFromSource(ShaderStage stage, - std::string_view source) override; + std::unique_ptr CreateShaderFromSource(ShaderStage stage, std::string_view source, + std::string_view name) override; std::unique_ptr CreateShaderFromBinary(ShaderStage stage, const void* data, - size_t length) override; + size_t length, + std::string_view name) override; std::unique_ptr CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, diff --git a/Source/Core/VideoBackends/D3D12/DX12Shader.cpp b/Source/Core/VideoBackends/D3D12/DX12Shader.cpp index b6369585d2..39589b6b24 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Shader.cpp +++ b/Source/Core/VideoBackends/D3D12/DX12Shader.cpp @@ -2,34 +2,43 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "VideoBackends/D3D12/DX12Shader.h" + +#include "Common/StringUtil.h" + #include "VideoBackends/D3D12/Common.h" #include "VideoBackends/D3D12/DX12Context.h" namespace DX12 { -DXShader::DXShader(ShaderStage stage, BinaryData bytecode) - : D3DCommon::Shader(stage, std::move(bytecode)) +DXShader::DXShader(ShaderStage stage, BinaryData bytecode, std::string_view name) + : D3DCommon::Shader(stage, std::move(bytecode)), m_name(UTF8ToWString(name)) { + if (!m_name.empty()) + { + m_compute_pipeline->SetName(m_name.c_str()); + } } DXShader::~DXShader() = default; -std::unique_ptr DXShader::CreateFromBytecode(ShaderStage stage, BinaryData bytecode) +std::unique_ptr DXShader::CreateFromBytecode(ShaderStage stage, BinaryData bytecode, + std::string_view name) { - std::unique_ptr shader(new DXShader(stage, std::move(bytecode))); + std::unique_ptr shader(new DXShader(stage, std::move(bytecode), name)); if (stage == ShaderStage::Compute && !shader->CreateComputePipeline()) return nullptr; return shader; } -std::unique_ptr DXShader::CreateFromSource(ShaderStage stage, std::string_view source) +std::unique_ptr DXShader::CreateFromSource(ShaderStage stage, std::string_view source, + std::string_view name) { auto bytecode = CompileShader(g_dx_context->GetFeatureLevel(), stage, source); if (!bytecode) return nullptr; - return CreateFromBytecode(stage, std::move(*bytecode)); + return CreateFromBytecode(stage, std::move(*bytecode), name); } D3D12_SHADER_BYTECODE DXShader::GetD3DByteCode() const diff --git a/Source/Core/VideoBackends/D3D12/DX12Shader.h b/Source/Core/VideoBackends/D3D12/DX12Shader.h index b788015c9f..ab6329d424 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Shader.h +++ b/Source/Core/VideoBackends/D3D12/DX12Shader.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include "VideoBackends/D3D12/Common.h" #include "VideoBackends/D3DCommon/Shader.h" @@ -18,15 +19,19 @@ public: ID3D12PipelineState* GetComputePipeline() const { return m_compute_pipeline.Get(); } D3D12_SHADER_BYTECODE GetD3DByteCode() const; - static std::unique_ptr CreateFromBytecode(ShaderStage stage, BinaryData bytecode); - static std::unique_ptr CreateFromSource(ShaderStage stage, std::string_view source); + static std::unique_ptr CreateFromBytecode(ShaderStage stage, BinaryData bytecode, + std::string_view name); + static std::unique_ptr CreateFromSource(ShaderStage stage, std::string_view source, + std::string_view name); private: - DXShader(ShaderStage stage, BinaryData bytecode); + DXShader(ShaderStage stage, BinaryData bytecode, std::string_view name); bool CreateComputePipeline(); ComPtr m_compute_pipeline; + + std::wstring m_name; }; } // namespace DX12 diff --git a/Source/Core/VideoBackends/D3D12/DX12Texture.cpp b/Source/Core/VideoBackends/D3D12/DX12Texture.cpp index f217fdabb6..34d0670a1f 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Texture.cpp +++ b/Source/Core/VideoBackends/D3D12/DX12Texture.cpp @@ -4,6 +4,7 @@ #include "VideoBackends/D3D12/DX12Texture.h" #include "Common/Align.h" #include "Common/Assert.h" +#include "Common/StringUtil.h" #include "VideoBackends/D3D12/Common.h" #include "VideoBackends/D3D12/D3D12Renderer.h" #include "VideoBackends/D3D12/D3D12StreamBuffer.h" @@ -41,9 +42,13 @@ static ComPtr CreateTextureUploadBuffer(u32 buffer_size) } DXTexture::DXTexture(const TextureConfig& config, ID3D12Resource* resource, - D3D12_RESOURCE_STATES state) - : AbstractTexture(config), m_resource(resource), m_state(state) + D3D12_RESOURCE_STATES state, std::string_view name) + : AbstractTexture(config), m_resource(resource), m_state(state), m_name(UTF8ToWString(name)) { + if (!m_name.empty()) + { + resource->SetName(m_name.c_str()); + } } DXTexture::~DXTexture() @@ -63,7 +68,7 @@ DXTexture::~DXTexture() g_dx_context->DeferResourceDestruction(m_resource.Get()); } -std::unique_ptr DXTexture::Create(const TextureConfig& config) +std::unique_ptr DXTexture::Create(const TextureConfig& config, std::string_view name) { constexpr D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_DEFAULT}; D3D12_RESOURCE_STATES resource_state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; @@ -113,7 +118,8 @@ std::unique_ptr DXTexture::Create(const TextureConfig& config) if (FAILED(hr)) return nullptr; - auto tex = std::unique_ptr(new DXTexture(config, resource.Get(), resource_state)); + auto tex = + std::unique_ptr(new DXTexture(config, resource.Get(), resource_state, name)); if (!tex->CreateSRVDescriptor() || (config.IsComputeImage() && !tex->CreateUAVDescriptor())) return nullptr; @@ -142,7 +148,7 @@ std::unique_ptr DXTexture::CreateAdopted(ID3D12Resource* resource) config.flags |= AbstractTextureFlag_ComputeImage; auto tex = - std::unique_ptr(new DXTexture(config, resource, D3D12_RESOURCE_STATE_COMMON)); + std::unique_ptr(new DXTexture(config, resource, D3D12_RESOURCE_STATE_COMMON, "")); if (!tex->CreateSRVDescriptor()) return nullptr; diff --git a/Source/Core/VideoBackends/D3D12/DX12Texture.h b/Source/Core/VideoBackends/D3D12/DX12Texture.h index 4d3c3ab08c..c3b2a8b710 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Texture.h +++ b/Source/Core/VideoBackends/D3D12/DX12Texture.h @@ -4,6 +4,8 @@ #pragma once #include +#include +#include #include "Common/CommonTypes.h" #include "VideoBackends/D3D12/Common.h" #include "VideoBackends/D3D12/DescriptorHeapManager.h" @@ -18,7 +20,7 @@ class DXTexture final : public AbstractTexture public: ~DXTexture(); - static std::unique_ptr Create(const TextureConfig& config); + static std::unique_ptr Create(const TextureConfig& config, std::string_view name); static std::unique_ptr CreateAdopted(ID3D12Resource* resource); void Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer, @@ -43,7 +45,8 @@ public: void DestroyResource(); private: - DXTexture(const TextureConfig& config, ID3D12Resource* resource, D3D12_RESOURCE_STATES state); + DXTexture(const TextureConfig& config, ID3D12Resource* resource, D3D12_RESOURCE_STATES state, + std::string_view name); bool CreateSRVDescriptor(); bool CreateUAVDescriptor(); @@ -52,6 +55,8 @@ private: DescriptorHandle m_srv_descriptor = {}; DescriptorHandle m_uav_descriptor = {}; + std::wstring m_name; + mutable D3D12_RESOURCE_STATES m_state; }; diff --git a/Source/Core/VideoBackends/Null/NullRender.cpp b/Source/Core/VideoBackends/Null/NullRender.cpp index 0fe65aef0b..9c87ed8529 100644 --- a/Source/Core/VideoBackends/Null/NullRender.cpp +++ b/Source/Core/VideoBackends/Null/NullRender.cpp @@ -28,7 +28,8 @@ bool Renderer::IsHeadless() const return true; } -std::unique_ptr Renderer::CreateTexture(const TextureConfig& config) +std::unique_ptr Renderer::CreateTexture(const TextureConfig& config, + [[maybe_unused]] std::string_view name) { return std::make_unique(config); } @@ -46,13 +47,15 @@ public: }; std::unique_ptr -Renderer::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source) +Renderer::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source, + [[maybe_unused]] std::string_view name) { return std::make_unique(stage); } -std::unique_ptr Renderer::CreateShaderFromBinary(ShaderStage stage, - const void* data, size_t length) +std::unique_ptr +Renderer::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length, + [[maybe_unused]] std::string_view name) { return std::make_unique(stage); } diff --git a/Source/Core/VideoBackends/Null/NullRender.h b/Source/Core/VideoBackends/Null/NullRender.h index f0d78bf543..f14484d3bc 100644 --- a/Source/Core/VideoBackends/Null/NullRender.h +++ b/Source/Core/VideoBackends/Null/NullRender.h @@ -15,16 +15,18 @@ public: bool IsHeadless() const override; - std::unique_ptr CreateTexture(const TextureConfig& config) override; + std::unique_ptr CreateTexture(const TextureConfig& config, + std::string_view name) override; std::unique_ptr CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; std::unique_ptr CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override; - std::unique_ptr CreateShaderFromSource(ShaderStage stage, - std::string_view source) override; + std::unique_ptr CreateShaderFromSource(ShaderStage stage, std::string_view source, + std::string_view name) override; std::unique_ptr CreateShaderFromBinary(ShaderStage stage, const void* data, - size_t length) override; + size_t length, + std::string_view name) override; std::unique_ptr CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, diff --git a/Source/Core/VideoBackends/OGL/OGLRender.cpp b/Source/Core/VideoBackends/OGL/OGLRender.cpp index 26cd912ec1..5b4f4f53eb 100644 --- a/Source/Core/VideoBackends/OGL/OGLRender.cpp +++ b/Source/Core/VideoBackends/OGL/OGLRender.cpp @@ -807,9 +807,10 @@ void Renderer::Shutdown() glDeleteFramebuffers(1, &m_shared_read_framebuffer); } -std::unique_ptr Renderer::CreateTexture(const TextureConfig& config) +std::unique_ptr Renderer::CreateTexture(const TextureConfig& config, + std::string_view name) { - return std::make_unique(config); + return std::make_unique(config, name); } std::unique_ptr Renderer::CreateStagingTexture(StagingTextureType type, @@ -825,14 +826,15 @@ std::unique_ptr Renderer::CreateFramebuffer(AbstractTexture static_cast(depth_attachment)); } -std::unique_ptr Renderer::CreateShaderFromSource(ShaderStage stage, - std::string_view source) +std::unique_ptr +Renderer::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::string_view name) { - return OGLShader::CreateFromSource(stage, source); + return OGLShader::CreateFromSource(stage, source, name); } -std::unique_ptr Renderer::CreateShaderFromBinary(ShaderStage stage, - const void* data, size_t length) +std::unique_ptr +Renderer::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length, + [[maybe_unused]] std::string_view name) { return nullptr; } diff --git a/Source/Core/VideoBackends/OGL/OGLRender.h b/Source/Core/VideoBackends/OGL/OGLRender.h index c533a4e646..371b6902a4 100644 --- a/Source/Core/VideoBackends/OGL/OGLRender.h +++ b/Source/Core/VideoBackends/OGL/OGLRender.h @@ -5,6 +5,7 @@ #include #include +#include #include "Common/GL/GLContext.h" #include "Common/GL/GLExtensions/GLExtensions.h" @@ -91,13 +92,15 @@ public: bool Initialize() override; void Shutdown() override; - std::unique_ptr CreateTexture(const TextureConfig& config) override; + std::unique_ptr CreateTexture(const TextureConfig& config, + std::string_view name) override; std::unique_ptr CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; - std::unique_ptr CreateShaderFromSource(ShaderStage stage, - std::string_view source) override; + std::unique_ptr CreateShaderFromSource(ShaderStage stage, std::string_view source, + std::string_view name) override; std::unique_ptr CreateShaderFromBinary(ShaderStage stage, const void* data, - size_t length) override; + size_t length, + std::string_view name) override; std::unique_ptr CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, diff --git a/Source/Core/VideoBackends/OGL/OGLShader.cpp b/Source/Core/VideoBackends/OGL/OGLShader.cpp index 9a4db8b856..11914f0355 100644 --- a/Source/Core/VideoBackends/OGL/OGLShader.cpp +++ b/Source/Core/VideoBackends/OGL/OGLShader.cpp @@ -23,17 +23,26 @@ static GLenum GetGLShaderTypeForStage(ShaderStage stage) } } -OGLShader::OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id, std::string source) +OGLShader::OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id, std::string source, + std::string name) : AbstractShader(stage), m_id(ProgramShaderCache::GenerateShaderID()), m_type(gl_type), - m_gl_id(gl_id), m_source(std::move(source)) + m_gl_id(gl_id), m_source(std::move(source)), m_name(std::move(name)) { + if (!m_name.empty()) + { + glObjectLabel(GetGLShaderTypeForStage(stage), m_gl_id, -1, m_name.c_str()); + } } -OGLShader::OGLShader(GLuint gl_compute_program_id, std::string source) +OGLShader::OGLShader(GLuint gl_compute_program_id, std::string source, std::string name) : AbstractShader(ShaderStage::Compute), m_id(ProgramShaderCache::GenerateShaderID()), m_type(GL_COMPUTE_SHADER), m_gl_compute_program_id(gl_compute_program_id), - m_source(std::move(source)) + m_source(std::move(source)), m_name(std::move(name)) { + if (!m_name.empty()) + { + glObjectLabel(GL_COMPUTE_SHADER, m_gl_compute_program_id, -1, m_name.c_str()); + } } OGLShader::~OGLShader() @@ -44,9 +53,11 @@ OGLShader::~OGLShader() glDeleteProgram(m_gl_compute_program_id); } -std::unique_ptr OGLShader::CreateFromSource(ShaderStage stage, std::string_view source) +std::unique_ptr OGLShader::CreateFromSource(ShaderStage stage, std::string_view source, + std::string_view name) { std::string source_str(source); + std::string name_str(name); if (stage != ShaderStage::Compute) { GLenum shader_type = GetGLShaderTypeForStage(stage); @@ -54,14 +65,15 @@ std::unique_ptr OGLShader::CreateFromSource(ShaderStage stage, std::s if (!shader_id) return nullptr; - return std::make_unique(stage, shader_type, shader_id, std::move(source_str)); + return std::make_unique(stage, shader_type, shader_id, std::move(source_str), + std::move(name_str)); } // Compute shaders. SHADER prog; if (!ProgramShaderCache::CompileComputeShader(prog, source_str)) return nullptr; - return std::make_unique(prog.glprogid, std::move(source_str)); + return std::make_unique(prog.glprogid, std::move(source_str), std::move(name_str)); } } // namespace OGL diff --git a/Source/Core/VideoBackends/OGL/OGLShader.h b/Source/Core/VideoBackends/OGL/OGLShader.h index 0494ff5b24..06b9449ac6 100644 --- a/Source/Core/VideoBackends/OGL/OGLShader.h +++ b/Source/Core/VideoBackends/OGL/OGLShader.h @@ -5,6 +5,7 @@ #include #include +#include #include #include "Common/CommonTypes.h" @@ -16,8 +17,9 @@ namespace OGL class OGLShader final : public AbstractShader { public: - explicit OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id, std::string source); - explicit OGLShader(GLuint gl_compute_program_id, std::string source); + explicit OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id, std::string source, + std::string name); + explicit OGLShader(GLuint gl_compute_program_id, std::string source, std::string name); ~OGLShader() override; u64 GetID() const { return m_id; } @@ -26,7 +28,8 @@ public: GLuint GetGLComputeProgramID() const { return m_gl_compute_program_id; } const std::string& GetSource() const { return m_source; } - static std::unique_ptr CreateFromSource(ShaderStage stage, std::string_view source); + static std::unique_ptr CreateFromSource(ShaderStage stage, std::string_view source, + std::string_view name); private: u64 m_id; @@ -34,6 +37,7 @@ private: GLuint m_gl_id = 0; GLuint m_gl_compute_program_id = 0; std::string m_source; + std::string m_name; }; } // namespace OGL diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.cpp b/Source/Core/VideoBackends/OGL/OGLTexture.cpp index 7023a254d9..83c1d1b419 100644 --- a/Source/Core/VideoBackends/OGL/OGLTexture.cpp +++ b/Source/Core/VideoBackends/OGL/OGLTexture.cpp @@ -104,7 +104,8 @@ bool UsePersistentStagingBuffers() } } // Anonymous namespace -OGLTexture::OGLTexture(const TextureConfig& tex_config) : AbstractTexture(tex_config) +OGLTexture::OGLTexture(const TextureConfig& tex_config, std::string_view name) + : AbstractTexture(tex_config), m_name(name) { DEBUG_ASSERT_MSG(VIDEO, !tex_config.IsMultisampled() || tex_config.levels == 1, "OpenGL does not support multisampled textures with mip levels"); @@ -114,6 +115,11 @@ OGLTexture::OGLTexture(const TextureConfig& tex_config) : AbstractTexture(tex_co glActiveTexture(GL_MUTABLE_TEXTURE_INDEX); glBindTexture(target, m_texId); + if (!m_name.empty()) + { + glObjectLabel(GL_TEXTURE, m_texId, -1, m_name.c_str()); + } + glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, m_config.levels - 1); GLenum gl_internal_format = GetGLInternalFormatForTextureFormat(m_config.format, true); diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.h b/Source/Core/VideoBackends/OGL/OGLTexture.h index 03b430b60a..4900801523 100644 --- a/Source/Core/VideoBackends/OGL/OGLTexture.h +++ b/Source/Core/VideoBackends/OGL/OGLTexture.h @@ -4,6 +4,8 @@ #pragma once #include +#include +#include #include #include "Common/GL/GLUtil.h" @@ -17,7 +19,7 @@ namespace OGL class OGLTexture final : public AbstractTexture { public: - explicit OGLTexture(const TextureConfig& tex_config); + explicit OGLTexture(const TextureConfig& tex_config, std::string_view name); ~OGLTexture(); void CopyRectangleFromTexture(const AbstractTexture* src, @@ -42,6 +44,7 @@ private: u32 dst_layer, u32 dst_level); GLuint m_texId; + std::string m_name; }; class OGLStagingTexture final : public AbstractStagingTexture diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index 2089db924c..d66609ad3a 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -38,7 +38,8 @@ bool SWRenderer::IsHeadless() const return m_window->IsHeadless(); } -std::unique_ptr SWRenderer::CreateTexture(const TextureConfig& config) +std::unique_ptr SWRenderer::CreateTexture(const TextureConfig& config, + [[maybe_unused]] std::string_view name) { return std::make_unique(config); } @@ -78,13 +79,15 @@ public: }; std::unique_ptr -SWRenderer::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source) +SWRenderer::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source, + [[maybe_unused]] std::string_view name) { return std::make_unique(stage); } -std::unique_ptr SWRenderer::CreateShaderFromBinary(ShaderStage stage, - const void* data, size_t length) +std::unique_ptr +SWRenderer::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length, + [[maybe_unused]] std::string_view name) { return std::make_unique(stage); } diff --git a/Source/Core/VideoBackends/Software/SWRenderer.h b/Source/Core/VideoBackends/Software/SWRenderer.h index 0c40afcd1a..b3c624b0d0 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.h +++ b/Source/Core/VideoBackends/Software/SWRenderer.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include "Common/CommonTypes.h" @@ -20,7 +21,8 @@ public: bool IsHeadless() const override; - std::unique_ptr CreateTexture(const TextureConfig& config) override; + std::unique_ptr CreateTexture(const TextureConfig& config, + std::string_view name) override; std::unique_ptr CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; std::unique_ptr @@ -28,10 +30,11 @@ public: void BindBackbuffer(const ClearColor& clear_color = {}) override; - std::unique_ptr CreateShaderFromSource(ShaderStage stage, - std::string_view source) override; + std::unique_ptr CreateShaderFromSource(ShaderStage stage, std::string_view source, + std::string_view name) override; std::unique_ptr CreateShaderFromBinary(ShaderStage stage, const void* data, - size_t length) override; + size_t length, + std::string_view name) override; std::unique_ptr CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp index cde48e1965..db59b16398 100644 --- a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp +++ b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp @@ -58,7 +58,7 @@ bool StateTracker::Initialize() { // Create a dummy texture which can be used in place of a real binding. m_dummy_texture = - VKTexture::Create(TextureConfig(1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, 0)); + VKTexture::Create(TextureConfig(1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, 0), ""); if (!m_dummy_texture) return false; m_dummy_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentInitCommandBuffer(), diff --git a/Source/Core/VideoBackends/Vulkan/VKRenderer.cpp b/Source/Core/VideoBackends/Vulkan/VKRenderer.cpp index df10b3d2d7..4623094776 100644 --- a/Source/Core/VideoBackends/Vulkan/VKRenderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKRenderer.cpp @@ -82,9 +82,10 @@ void Renderer::Shutdown() m_swap_chain.reset(); } -std::unique_ptr Renderer::CreateTexture(const TextureConfig& config) +std::unique_ptr Renderer::CreateTexture(const TextureConfig& config, + std::string_view name) { - return VKTexture::Create(config); + return VKTexture::Create(config, name); } std::unique_ptr Renderer::CreateStagingTexture(StagingTextureType type, @@ -93,16 +94,17 @@ std::unique_ptr Renderer::CreateStagingTexture(StagingTe return VKStagingTexture::Create(type, config); } -std::unique_ptr Renderer::CreateShaderFromSource(ShaderStage stage, - std::string_view source) +std::unique_ptr +Renderer::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::string_view name) { - return VKShader::CreateFromSource(stage, source); + return VKShader::CreateFromSource(stage, source, name); } std::unique_ptr Renderer::CreateShaderFromBinary(ShaderStage stage, - const void* data, size_t length) + const void* data, size_t length, + std::string_view name) { - return VKShader::CreateFromBinary(stage, data, length); + return VKShader::CreateFromBinary(stage, data, length, name); } std::unique_ptr diff --git a/Source/Core/VideoBackends/Vulkan/VKRenderer.h b/Source/Core/VideoBackends/Vulkan/VKRenderer.h index fc447c77b4..d44776a0eb 100644 --- a/Source/Core/VideoBackends/Vulkan/VKRenderer.h +++ b/Source/Core/VideoBackends/Vulkan/VKRenderer.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "Common/CommonTypes.h" #include "VideoBackends/Vulkan/Constants.h" @@ -35,16 +36,18 @@ public: bool Initialize() override; void Shutdown() override; - std::unique_ptr CreateTexture(const TextureConfig& config) override; + std::unique_ptr CreateTexture(const TextureConfig& config, + std::string_view name) override; std::unique_ptr CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; std::unique_ptr CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override; - std::unique_ptr CreateShaderFromSource(ShaderStage stage, - std::string_view source) override; + std::unique_ptr CreateShaderFromSource(ShaderStage stage, std::string_view source, + std::string_view name) override; std::unique_ptr CreateShaderFromBinary(ShaderStage stage, const void* data, - size_t length) override; + size_t length, + std::string_view name) override; std::unique_ptr CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, diff --git a/Source/Core/VideoBackends/Vulkan/VKShader.cpp b/Source/Core/VideoBackends/Vulkan/VKShader.cpp index e17c2c6569..cd910b898a 100644 --- a/Source/Core/VideoBackends/Vulkan/VKShader.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKShader.cpp @@ -11,16 +11,35 @@ namespace Vulkan { -VKShader::VKShader(ShaderStage stage, std::vector spv, VkShaderModule mod) +VKShader::VKShader(ShaderStage stage, std::vector spv, VkShaderModule mod, + std::string_view name) : AbstractShader(stage), m_spv(std::move(spv)), m_module(mod), - m_compute_pipeline(VK_NULL_HANDLE) + m_compute_pipeline(VK_NULL_HANDLE), m_name(name) { + if (!m_name.empty()) + { + VkDebugUtilsObjectNameInfoEXT name_info = {}; + name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; + name_info.objectType = VK_OBJECT_TYPE_SHADER_MODULE; + name_info.objectHandle = reinterpret_cast(m_module); + name_info.pObjectName = m_name.data(); + vkSetDebugUtilsObjectNameEXT(g_vulkan_context->GetDevice(), &name_info); + } } -VKShader::VKShader(std::vector spv, VkPipeline compute_pipeline) +VKShader::VKShader(std::vector spv, VkPipeline compute_pipeline, std::string_view name) : AbstractShader(ShaderStage::Compute), m_spv(std::move(spv)), m_module(VK_NULL_HANDLE), - m_compute_pipeline(compute_pipeline) + m_compute_pipeline(compute_pipeline), m_name(name) { + if (!m_name.empty()) + { + VkDebugUtilsObjectNameInfoEXT name_info = {}; + name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; + name_info.objectType = VK_OBJECT_TYPE_PIPELINE; + name_info.objectHandle = reinterpret_cast(m_compute_pipeline); + name_info.pObjectName = m_name.data(); + vkSetDebugUtilsObjectNameEXT(g_vulkan_context->GetDevice(), &name_info); + } } VKShader::~VKShader() @@ -38,8 +57,8 @@ AbstractShader::BinaryData VKShader::GetBinary() const return ret; } -static std::unique_ptr CreateShaderObject(ShaderStage stage, - ShaderCompiler::SPIRVCodeVector spv) +static std::unique_ptr +CreateShaderObject(ShaderStage stage, ShaderCompiler::SPIRVCodeVector spv, std::string_view name) { VkShaderModuleCreateInfo info = {}; info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; @@ -56,7 +75,7 @@ static std::unique_ptr CreateShaderObject(ShaderStage stage, // If it's a graphics shader, we defer pipeline creation. if (stage != ShaderStage::Compute) - return std::make_unique(stage, std::move(spv), mod); + return std::make_unique(stage, std::move(spv), mod, name); // If it's a compute shader, we create the pipeline straight away. const VkComputePipelineCreateInfo pipeline_info = { @@ -82,10 +101,11 @@ static std::unique_ptr CreateShaderObject(ShaderStage stage, return nullptr; } - return std::make_unique(std::move(spv), pipeline); + return std::make_unique(std::move(spv), pipeline, name); } -std::unique_ptr VKShader::CreateFromSource(ShaderStage stage, std::string_view source) +std::unique_ptr VKShader::CreateFromSource(ShaderStage stage, std::string_view source, + std::string_view name) { std::optional spv; switch (stage) @@ -109,11 +129,11 @@ std::unique_ptr VKShader::CreateFromSource(ShaderStage stage, std::str if (!spv) return nullptr; - return CreateShaderObject(stage, std::move(*spv)); + return CreateShaderObject(stage, std::move(*spv), name); } std::unique_ptr VKShader::CreateFromBinary(ShaderStage stage, const void* data, - size_t length) + size_t length, std::string_view name) { const size_t size_in_words = Common::AlignUp(length, sizeof(ShaderCompiler::SPIRVCodeType)) / sizeof(ShaderCompiler::SPIRVCodeType); @@ -121,7 +141,7 @@ std::unique_ptr VKShader::CreateFromBinary(ShaderStage stage, const vo if (length > 0) std::memcpy(spv.data(), data, length); - return CreateShaderObject(stage, std::move(spv)); + return CreateShaderObject(stage, std::move(spv), name); } } // namespace Vulkan diff --git a/Source/Core/VideoBackends/Vulkan/VKShader.h b/Source/Core/VideoBackends/Vulkan/VKShader.h index 0efb2e6ccd..8414983aaa 100644 --- a/Source/Core/VideoBackends/Vulkan/VKShader.h +++ b/Source/Core/VideoBackends/Vulkan/VKShader.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -17,22 +18,24 @@ namespace Vulkan class VKShader final : public AbstractShader { public: - VKShader(ShaderStage stage, std::vector spv, VkShaderModule mod); - VKShader(std::vector spv, VkPipeline compute_pipeline); + VKShader(ShaderStage stage, std::vector spv, VkShaderModule mod, std::string_view name); + VKShader(std::vector spv, VkPipeline compute_pipeline, std::string_view name); ~VKShader() override; VkShaderModule GetShaderModule() const { return m_module; } VkPipeline GetComputePipeline() const { return m_compute_pipeline; } BinaryData GetBinary() const override; - static std::unique_ptr CreateFromSource(ShaderStage stage, std::string_view source); + static std::unique_ptr CreateFromSource(ShaderStage stage, std::string_view source, + std::string_view name); static std::unique_ptr CreateFromBinary(ShaderStage stage, const void* data, - size_t length); + size_t length, std::string_view name); private: std::vector m_spv; VkShaderModule m_module; VkPipeline m_compute_pipeline; + std::string m_name; }; } // namespace Vulkan diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp index 2d826c0ca6..f744eb2e79 100644 --- a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp @@ -23,11 +23,20 @@ namespace Vulkan { VKTexture::VKTexture(const TextureConfig& tex_config, VkDeviceMemory device_memory, VkImage image, - VkImageLayout layout /* = VK_IMAGE_LAYOUT_UNDEFINED */, + std::string_view name, VkImageLayout layout /* = VK_IMAGE_LAYOUT_UNDEFINED */, ComputeImageLayout compute_layout /* = ComputeImageLayout::Undefined */) : AbstractTexture(tex_config), m_device_memory(device_memory), m_image(image), m_layout(layout), - m_compute_layout(compute_layout) + m_compute_layout(compute_layout), m_name(name) { + if (!m_name.empty()) + { + VkDebugUtilsObjectNameInfoEXT name_info = {}; + name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; + name_info.objectType = VK_OBJECT_TYPE_IMAGE; + name_info.objectHandle = reinterpret_cast(image); + name_info.pObjectName = m_name.c_str(); + vkSetDebugUtilsObjectNameEXT(g_vulkan_context->GetDevice(), &name_info); + } } VKTexture::~VKTexture() @@ -43,7 +52,7 @@ VKTexture::~VKTexture() } } -std::unique_ptr VKTexture::Create(const TextureConfig& tex_config) +std::unique_ptr VKTexture::Create(const TextureConfig& tex_config, std::string_view name) { // Determine image usage, we need to flag as an attachment if it can be used as a rendertarget. VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | @@ -109,8 +118,9 @@ std::unique_ptr VKTexture::Create(const TextureConfig& tex_config) return nullptr; } - std::unique_ptr texture = std::make_unique( - tex_config, device_memory, image, VK_IMAGE_LAYOUT_UNDEFINED, ComputeImageLayout::Undefined); + std::unique_ptr texture = + std::make_unique(tex_config, device_memory, image, name, VK_IMAGE_LAYOUT_UNDEFINED, + ComputeImageLayout::Undefined); if (!texture->CreateView(VK_IMAGE_VIEW_TYPE_2D_ARRAY)) return nullptr; @@ -121,7 +131,7 @@ std::unique_ptr VKTexture::CreateAdopted(const TextureConfig& tex_con VkImageViewType view_type, VkImageLayout layout) { std::unique_ptr texture = std::make_unique( - tex_config, VkDeviceMemory(VK_NULL_HANDLE), image, layout, ComputeImageLayout::Undefined); + tex_config, VkDeviceMemory(VK_NULL_HANDLE), image, "", layout, ComputeImageLayout::Undefined); if (!texture->CreateView(view_type)) return nullptr; diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.h b/Source/Core/VideoBackends/Vulkan/VKTexture.h index 283e8169df..ce25fec74f 100644 --- a/Source/Core/VideoBackends/Vulkan/VKTexture.h +++ b/Source/Core/VideoBackends/Vulkan/VKTexture.h @@ -4,6 +4,8 @@ #pragma once #include +#include +#include #include "VideoBackends/Vulkan/VulkanLoader.h" #include "VideoCommon/AbstractFramebuffer.h" @@ -29,7 +31,7 @@ public: VKTexture() = delete; VKTexture(const TextureConfig& tex_config, VkDeviceMemory device_memory, VkImage image, - VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED, + std::string_view name, VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED, ComputeImageLayout compute_layout = ComputeImageLayout::Undefined); ~VKTexture(); @@ -55,7 +57,7 @@ public: VkFormat GetVkFormat() const { return GetVkFormatForHostTextureFormat(m_config.format); } bool IsAdopted() const { return m_device_memory != VkDeviceMemory(VK_NULL_HANDLE); } - static std::unique_ptr Create(const TextureConfig& tex_config); + static std::unique_ptr Create(const TextureConfig& tex_config, std::string_view name); static std::unique_ptr CreateAdopted(const TextureConfig& tex_config, VkImage image, VkImageViewType view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY, @@ -77,6 +79,7 @@ private: VkImageView m_view = VK_NULL_HANDLE; mutable VkImageLayout m_layout = VK_IMAGE_LAYOUT_UNDEFINED; mutable ComputeImageLayout m_compute_layout = ComputeImageLayout::Undefined; + std::string m_name; }; class VKStagingTexture final : public AbstractStagingTexture diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp index b0941ae856..63ad23e7ed 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp @@ -223,6 +223,7 @@ bool VulkanContext::SelectInstanceExtensions(std::vector* extension AddExtension(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, false); AddExtension(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, false); + AddExtension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, false); return true; } diff --git a/Source/Core/VideoBackends/Vulkan/VulkanEntryPoints.inl b/Source/Core/VideoBackends/Vulkan/VulkanEntryPoints.inl index 9006baf91a..6233ceb9f6 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanEntryPoints.inl +++ b/Source/Core/VideoBackends/Vulkan/VulkanEntryPoints.inl @@ -197,4 +197,6 @@ VULKAN_DEVICE_ENTRY_POINT(vkAcquireFullScreenExclusiveModeEXT, false) VULKAN_DEVICE_ENTRY_POINT(vkReleaseFullScreenExclusiveModeEXT, false) #endif +VULKAN_DEVICE_ENTRY_POINT(vkSetDebugUtilsObjectNameEXT, false) + #endif // VULKAN_DEVICE_ENTRY_POINT diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 19cb5fc6ac..ddc86cd3b3 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -93,7 +93,8 @@ public: virtual bool IsFullscreen() const { return false; } virtual void BeginUtilityDrawing(); virtual void EndUtilityDrawing(); - virtual std::unique_ptr CreateTexture(const TextureConfig& config) = 0; + virtual std::unique_ptr CreateTexture(const TextureConfig& config, + std::string_view name = "") = 0; virtual std::unique_ptr CreateStagingTexture(StagingTextureType type, const TextureConfig& config) = 0; virtual std::unique_ptr @@ -125,9 +126,11 @@ public: // Shader modules/objects. virtual std::unique_ptr CreateShaderFromSource(ShaderStage stage, - std::string_view source) = 0; - virtual std::unique_ptr - CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length) = 0; + std::string_view source, + std::string_view name = "") = 0; + virtual std::unique_ptr CreateShaderFromBinary(ShaderStage stage, + const void* data, size_t length, + std::string_view name = "") = 0; virtual std::unique_ptr CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) = 0; virtual std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config,