mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
VideoBackends / VideoCommon: allow the ability to set debug names for shaders / textures. These names are visible in applications like RenderDoc
This commit is contained in:
@ -52,9 +52,10 @@ bool Renderer::IsHeadless() const
|
||||
return !m_swap_chain;
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractTexture> Renderer::CreateTexture(const TextureConfig& config)
|
||||
std::unique_ptr<AbstractTexture> Renderer::CreateTexture(const TextureConfig& config,
|
||||
std::string_view name)
|
||||
{
|
||||
return DXTexture::Create(config);
|
||||
return DXTexture::Create(config, name);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractStagingTexture> Renderer::CreateStagingTexture(StagingTextureType type,
|
||||
@ -70,20 +71,21 @@ std::unique_ptr<AbstractFramebuffer> Renderer::CreateFramebuffer(AbstractTexture
|
||||
static_cast<DXTexture*>(depth_attachment));
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractShader> Renderer::CreateShaderFromSource(ShaderStage stage,
|
||||
std::string_view source)
|
||||
std::unique_ptr<AbstractShader>
|
||||
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<AbstractShader> 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<AbstractPipeline> Renderer::CreatePipeline(const AbstractPipelineConfig& config,
|
||||
|
@ -24,13 +24,15 @@ public:
|
||||
|
||||
bool IsHeadless() const override;
|
||||
|
||||
std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config) override;
|
||||
std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config,
|
||||
std::string_view name) override;
|
||||
std::unique_ptr<AbstractStagingTexture>
|
||||
CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
|
||||
std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage,
|
||||
std::string_view source) override;
|
||||
std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage, std::string_view source,
|
||||
std::string_view name) override;
|
||||
std::unique_ptr<AbstractShader> CreateShaderFromBinary(ShaderStage stage, const void* data,
|
||||
size_t length) override;
|
||||
size_t length,
|
||||
std::string_view name) override;
|
||||
std::unique_ptr<NativeVertexFormat>
|
||||
CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override;
|
||||
std::unique_ptr<AbstractPipeline> CreatePipeline(const AbstractPipelineConfig& config,
|
||||
|
@ -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<UINT>(m_name.size()),
|
||||
m_name.data());
|
||||
}
|
||||
}
|
||||
|
||||
DXShader::~DXShader() = default;
|
||||
@ -38,7 +44,8 @@ ID3D11ComputeShader* DXShader::GetD3DComputeShader() const
|
||||
return static_cast<ID3D11ComputeShader*>(m_shader.Get());
|
||||
}
|
||||
|
||||
std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, BinaryData bytecode)
|
||||
std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, BinaryData bytecode,
|
||||
std::string_view name)
|
||||
{
|
||||
switch (stage)
|
||||
{
|
||||
@ -50,7 +57,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
return std::make_unique<DXShader>(ShaderStage::Vertex, std::move(bytecode), vs.Get());
|
||||
return std::make_unique<DXShader>(ShaderStage::Vertex, std::move(bytecode), vs.Get(), name);
|
||||
}
|
||||
|
||||
case ShaderStage::Geometry:
|
||||
@ -61,7 +68,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
return std::make_unique<DXShader>(ShaderStage::Geometry, std::move(bytecode), gs.Get());
|
||||
return std::make_unique<DXShader>(ShaderStage::Geometry, std::move(bytecode), gs.Get(), name);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -73,7 +80,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
return std::make_unique<DXShader>(ShaderStage::Pixel, std::move(bytecode), ps.Get());
|
||||
return std::make_unique<DXShader>(ShaderStage::Pixel, std::move(bytecode), ps.Get(), name);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -85,7 +92,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
return std::make_unique<DXShader>(ShaderStage::Compute, std::move(bytecode), cs.Get());
|
||||
return std::make_unique<DXShader>(ShaderStage::Compute, std::move(bytecode), cs.Get(), name);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2,7 +2,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#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<DXShader> CreateFromBytecode(ShaderStage stage, BinaryData bytecode);
|
||||
static std::unique_ptr<DXShader> CreateFromBytecode(ShaderStage stage, BinaryData bytecode,
|
||||
std::string_view name);
|
||||
|
||||
private:
|
||||
ComPtr<ID3D11DeviceChild> m_shader;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
} // namespace DX11
|
||||
|
@ -15,9 +15,15 @@
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
DXTexture::DXTexture(const TextureConfig& config, ComPtr<ID3D11Texture2D> texture)
|
||||
: AbstractTexture(config), m_texture(std::move(texture))
|
||||
DXTexture::DXTexture(const TextureConfig& config, ComPtr<ID3D11Texture2D> 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<UINT>(m_name.size()),
|
||||
m_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
DXTexture::~DXTexture()
|
||||
@ -26,7 +32,7 @@ DXTexture::~DXTexture()
|
||||
D3D::stateman->ApplyTextures();
|
||||
}
|
||||
|
||||
std::unique_ptr<DXTexture> DXTexture::Create(const TextureConfig& config)
|
||||
std::unique_ptr<DXTexture> 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> DXTexture::Create(const TextureConfig& config)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<DXTexture> tex(new DXTexture(config, std::move(d3d_texture)));
|
||||
std::unique_ptr<DXTexture> 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> DXTexture::CreateAdopted(ComPtr<ID3D11Texture2D> text
|
||||
if (desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS)
|
||||
config.flags |= AbstractTextureFlag_ComputeImage;
|
||||
|
||||
std::unique_ptr<DXTexture> tex(new DXTexture(config, std::move(texture)));
|
||||
std::unique_ptr<DXTexture> 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())
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "VideoCommon/AbstractFramebuffer.h"
|
||||
@ -18,7 +20,7 @@ class DXTexture final : public AbstractTexture
|
||||
public:
|
||||
~DXTexture();
|
||||
|
||||
static std::unique_ptr<DXTexture> Create(const TextureConfig& config);
|
||||
static std::unique_ptr<DXTexture> Create(const TextureConfig& config, std::string_view name);
|
||||
static std::unique_ptr<DXTexture> CreateAdopted(ComPtr<ID3D11Texture2D> texture);
|
||||
|
||||
void CopyRectangleFromTexture(const AbstractTexture* src,
|
||||
@ -35,7 +37,7 @@ public:
|
||||
ID3D11UnorderedAccessView* GetD3DUAV() const { return m_uav.Get(); }
|
||||
|
||||
private:
|
||||
DXTexture(const TextureConfig& config, ComPtr<ID3D11Texture2D> texture);
|
||||
DXTexture(const TextureConfig& config, ComPtr<ID3D11Texture2D> texture, std::string_view name);
|
||||
|
||||
bool CreateSRV();
|
||||
bool CreateUAV();
|
||||
@ -43,6 +45,7 @@ private:
|
||||
ComPtr<ID3D11Texture2D> m_texture;
|
||||
ComPtr<ID3D11ShaderResourceView> m_srv;
|
||||
ComPtr<ID3D11UnorderedAccessView> m_uav;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
class DXStagingTexture final : public AbstractStagingTexture
|
||||
|
Reference in New Issue
Block a user