GPUDevice: Put debug messages/scopes behind conditions
And completely compile them out in Release builds. Gets Devel close to Release in terms of performance.
This commit is contained in:
parent
0faa9cf650
commit
9df59713da
|
@ -32,7 +32,7 @@ static constexpr GPUTexture::Format s_swap_chain_format = GPUTexture::Format::RG
|
||||||
|
|
||||||
void SetD3DDebugObjectName(ID3D11DeviceChild* obj, std::string_view name)
|
void SetD3DDebugObjectName(ID3D11DeviceChild* obj, std::string_view name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
// WKPDID_D3DDebugObjectName
|
// WKPDID_D3DDebugObjectName
|
||||||
static constexpr GUID guid = {0x429b8c22, 0x9188, 0x4b0c, {0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00}};
|
static constexpr GUID guid = {0x429b8c22, 0x9188, 0x4b0c, {0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00}};
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ bool D3D11Device::CreateDeviceAndMainSwapChain(std::string_view adapter, Feature
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
if (m_debug_device)
|
if (m_debug_device)
|
||||||
m_context.As(&m_annotation);
|
m_context.As(&m_annotation);
|
||||||
#endif
|
#endif
|
||||||
|
@ -832,36 +832,34 @@ float D3D11Device::GetAndResetAccumulatedGPUTime()
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D11Device::PushDebugGroup(const char* name)
|
void D3D11Device::PushDebugGroup(const char* name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!m_annotation)
|
if (!m_annotation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_annotation->BeginEvent(StringUtil::UTF8StringToWideString(name).c_str());
|
m_annotation->BeginEvent(StringUtil::UTF8StringToWideString(name).c_str());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D11Device::PopDebugGroup()
|
void D3D11Device::PopDebugGroup()
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!m_annotation)
|
if (!m_annotation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_annotation->EndEvent();
|
m_annotation->EndEvent();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D11Device::InsertDebugMessage(const char* msg)
|
void D3D11Device::InsertDebugMessage(const char* msg)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!m_annotation)
|
if (!m_annotation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_annotation->SetMarker(StringUtil::UTF8StringToWideString(msg).c_str());
|
m_annotation->SetMarker(StringUtil::UTF8StringToWideString(msg).c_str());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void D3D11Device::MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
void D3D11Device::MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
||||||
u32* map_base_vertex)
|
u32* map_base_vertex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,9 +80,11 @@ public:
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void PushDebugGroup(const char* name) override;
|
void PushDebugGroup(const char* name) override;
|
||||||
void PopDebugGroup() override;
|
void PopDebugGroup() override;
|
||||||
void InsertDebugMessage(const char* msg) override;
|
void InsertDebugMessage(const char* msg) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
||||||
u32* map_base_vertex) override;
|
u32* map_base_vertex) override;
|
||||||
|
|
|
@ -47,11 +47,15 @@ ID3D11ComputeShader* D3D11Shader::GetComputeShader() const
|
||||||
return static_cast<ID3D11ComputeShader*>(m_shader.Get());
|
return static_cast<ID3D11ComputeShader*>(m_shader.Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D11Shader::SetDebugName(std::string_view name)
|
void D3D11Shader::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
SetD3DDebugObjectName(m_shader.Get(), name);
|
SetD3DDebugObjectName(m_shader.Get(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data,
|
std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data,
|
||||||
Error* error)
|
Error* error)
|
||||||
{
|
{
|
||||||
|
@ -135,11 +139,15 @@ D3D11Pipeline::~D3D11Pipeline()
|
||||||
D3D11Device::GetInstance().UnbindPipeline(this);
|
D3D11Device::GetInstance().UnbindPipeline(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D11Pipeline::SetDebugName(std::string_view name)
|
void D3D11Pipeline::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
// can't label this directly
|
// can't label this directly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
D3D11Device::ComPtr<ID3D11RasterizerState> D3D11Device::GetRasterizationState(const GPUPipeline::RasterizationState& rs,
|
D3D11Device::ComPtr<ID3D11RasterizerState> D3D11Device::GetRasterizationState(const GPUPipeline::RasterizationState& rs,
|
||||||
Error* error)
|
Error* error)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,9 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE const std::vector<u8>& GetBytecode() const { return m_bytecode; }
|
ALWAYS_INLINE const std::vector<u8>& GetBytecode() const { return m_bytecode; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D11Shader(GPUShaderStage stage, Microsoft::WRL::ComPtr<ID3D11DeviceChild> shader, std::vector<u8> bytecode);
|
D3D11Shader(GPUShaderStage stage, Microsoft::WRL::ComPtr<ID3D11DeviceChild> shader, std::vector<u8> bytecode);
|
||||||
|
@ -49,7 +51,9 @@ class D3D11Pipeline final : public GPUPipeline
|
||||||
public:
|
public:
|
||||||
~D3D11Pipeline() override;
|
~D3D11Pipeline() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
ALWAYS_INLINE bool IsComputePipeline() const { return !m_vs; }
|
ALWAYS_INLINE bool IsComputePipeline() const { return !m_vs; }
|
||||||
ALWAYS_INLINE ID3D11RasterizerState* GetRasterizerState() const { return m_rs.Get(); }
|
ALWAYS_INLINE ID3D11RasterizerState* GetRasterizerState() const { return m_rs.Get(); }
|
||||||
|
|
|
@ -42,11 +42,15 @@ D3D11Sampler::D3D11Sampler(ComPtr<ID3D11SamplerState> ss) : m_ss(std::move(ss))
|
||||||
|
|
||||||
D3D11Sampler::~D3D11Sampler() = default;
|
D3D11Sampler::~D3D11Sampler() = default;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D11Sampler::SetDebugName(std::string_view name)
|
void D3D11Sampler::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
SetD3DDebugObjectName(m_ss.Get(), name);
|
SetD3DDebugObjectName(m_ss.Get(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUSampler> D3D11Device::CreateSampler(const GPUSampler::Config& config, Error* error)
|
std::unique_ptr<GPUSampler> D3D11Device::CreateSampler(const GPUSampler::Config& config, Error* error)
|
||||||
{
|
{
|
||||||
static constexpr std::array<D3D11_TEXTURE_ADDRESS_MODE, static_cast<u8>(GPUSampler::AddressMode::MaxCount)> ta = {{
|
static constexpr std::array<D3D11_TEXTURE_ADDRESS_MODE, static_cast<u8>(GPUSampler::AddressMode::MaxCount)> ta = {{
|
||||||
|
@ -200,8 +204,7 @@ bool D3D11Texture::Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32
|
||||||
|
|
||||||
if (IsCompressedFormat(m_format))
|
if (IsCompressedFormat(m_format))
|
||||||
{
|
{
|
||||||
*map = static_cast<u8*>(sr.pData) + ((y / GetBlockSize()) * sr.RowPitch) +
|
*map = static_cast<u8*>(sr.pData) + ((y / GetBlockSize()) * sr.RowPitch) + ((x / GetBlockSize()) * GetPixelSize());
|
||||||
((x / GetBlockSize()) * GetPixelSize());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -225,11 +228,15 @@ void D3D11Texture::GenerateMipmaps()
|
||||||
D3D11Device::GetD3DContext()->GenerateMips(m_srv.Get());
|
D3D11Device::GetD3DContext()->GenerateMips(m_srv.Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D11Texture::SetDebugName(std::string_view name)
|
void D3D11Texture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
SetD3DDebugObjectName(m_texture.Get(), name);
|
SetD3DDebugObjectName(m_texture.Get(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
DXGI_FORMAT D3D11Texture::GetDXGIFormat() const
|
DXGI_FORMAT D3D11Texture::GetDXGIFormat() const
|
||||||
{
|
{
|
||||||
return D3DCommon::GetFormatMapping(m_format).resource_format;
|
return D3DCommon::GetFormatMapping(m_format).resource_format;
|
||||||
|
@ -419,11 +426,15 @@ void D3D11TextureBuffer::Unmap(u32 used_elements)
|
||||||
m_buffer.Unmap(D3D11Device::GetD3DContext(), size);
|
m_buffer.Unmap(D3D11Device::GetD3DContext(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D11TextureBuffer::SetDebugName(std::string_view name)
|
void D3D11TextureBuffer::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
SetD3DDebugObjectName(m_buffer.GetD3DBuffer(), name);
|
SetD3DDebugObjectName(m_buffer.GetD3DBuffer(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUTextureBuffer> D3D11Device::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
std::unique_ptr<GPUTextureBuffer> D3D11Device::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
||||||
u32 size_in_elements, Error* error /* = nullptr */)
|
u32 size_in_elements, Error* error /* = nullptr */)
|
||||||
{
|
{
|
||||||
|
@ -543,6 +554,8 @@ void D3D11DownloadTexture::Flush()
|
||||||
// Handled when mapped.
|
// Handled when mapped.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D11DownloadTexture::SetDebugName(std::string_view name)
|
void D3D11DownloadTexture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
|
@ -551,6 +564,8 @@ void D3D11DownloadTexture::SetDebugName(std::string_view name)
|
||||||
SetD3DDebugObjectName(m_texture.Get(), name);
|
SetD3DDebugObjectName(m_texture.Get(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUDownloadTexture> D3D11Device::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format,
|
std::unique_ptr<GPUDownloadTexture> D3D11Device::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format,
|
||||||
Error* error /* = nullptr */)
|
Error* error /* = nullptr */)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,9 @@ public:
|
||||||
ALWAYS_INLINE ID3D11SamplerState* GetSamplerState() const { return m_ss.Get(); }
|
ALWAYS_INLINE ID3D11SamplerState* GetSamplerState() const { return m_ss.Get(); }
|
||||||
ALWAYS_INLINE ID3D11SamplerState* const* GetSamplerStateArray() const { return m_ss.GetAddressOf(); }
|
ALWAYS_INLINE ID3D11SamplerState* const* GetSamplerStateArray() const { return m_ss.GetAddressOf(); }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D11Sampler(ComPtr<ID3D11SamplerState> ss);
|
D3D11Sampler(ComPtr<ID3D11SamplerState> ss);
|
||||||
|
@ -88,7 +90,9 @@ public:
|
||||||
void Unmap() override;
|
void Unmap() override;
|
||||||
void GenerateMipmaps() override;
|
void GenerateMipmaps() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D11Texture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, Format format, Flags flags,
|
D3D11Texture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, Format format, Flags flags,
|
||||||
|
@ -118,7 +122,9 @@ public:
|
||||||
void* Map(u32 required_elements) override;
|
void* Map(u32 required_elements) override;
|
||||||
void Unmap(u32 used_elements) override;
|
void Unmap(u32 used_elements) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D11StreamBuffer m_buffer;
|
D3D11StreamBuffer m_buffer;
|
||||||
|
@ -140,7 +146,9 @@ public:
|
||||||
|
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D11DownloadTexture(Microsoft::WRL::ComPtr<ID3D11Texture2D> tex, u32 width, u32 height, GPUTexture::Format format);
|
D3D11DownloadTexture(Microsoft::WRL::ComPtr<ID3D11Texture2D> tex, u32 width, u32 height, GPUTexture::Format format);
|
||||||
|
|
|
@ -310,7 +310,7 @@ u32 D3D12::RootSignatureBuilder::AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D12::SetObjectName(ID3D12Object* object, std::string_view name)
|
void D3D12::SetObjectName(ID3D12Object* object, std::string_view name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "common/windows_headers.h"
|
#include "common/windows_headers.h"
|
||||||
|
|
||||||
|
#include "gpu_device.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <d3d12.h>
|
#include <d3d12.h>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
@ -122,7 +124,7 @@ private:
|
||||||
D3D12_COMPUTE_PIPELINE_STATE_DESC m_desc;
|
D3D12_COMPUTE_PIPELINE_STATE_DESC m_desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetObjectName(ID3D12Object* object, std::string_view name);
|
void SetObjectName(ID3D12Object* object, std::string_view name);
|
||||||
#else
|
#else
|
||||||
static inline void SetObjectName(ID3D12Object* object, std::string_view name)
|
static inline void SetObjectName(ID3D12Object* object, std::string_view name)
|
||||||
|
|
|
@ -59,7 +59,7 @@ static constexpr GPUTexture::Format s_swap_chain_format = GPUTexture::Format::RG
|
||||||
// We just need to keep this alive, never reference it.
|
// We just need to keep this alive, never reference it.
|
||||||
static DynamicHeapArray<u8> s_pipeline_cache_data;
|
static DynamicHeapArray<u8> s_pipeline_cache_data;
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
#include "WinPixEventRuntime/pix3.h"
|
#include "WinPixEventRuntime/pix3.h"
|
||||||
static u32 s_debug_scope_depth = 0;
|
static u32 s_debug_scope_depth = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -117,7 +117,7 @@ D3D12Device::D3D12Device()
|
||||||
{
|
{
|
||||||
m_render_api = RenderAPI::D3D12;
|
m_render_api = RenderAPI::D3D12;
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
s_debug_scope_depth = 0;
|
s_debug_scope_depth = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1273,7 +1273,8 @@ void D3D12Device::SubmitPresent(GPUSwapChain* swap_chain)
|
||||||
SC->GetSwapChain()->Present(sync_interval, flags);
|
SC->GetSwapChain()->Present(sync_interval, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
static UINT64 Palette(float phase, const std::array<float, 3>& a, const std::array<float, 3>& b,
|
static UINT64 Palette(float phase, const std::array<float, 3>& a, const std::array<float, 3>& b,
|
||||||
const std::array<float, 3>& c, const std::array<float, 3>& d)
|
const std::array<float, 3>& c, const std::array<float, 3>& d)
|
||||||
{
|
{
|
||||||
|
@ -1286,41 +1287,36 @@ static UINT64 Palette(float phase, const std::array<float, 3>& a, const std::arr
|
||||||
static_cast<BYTE>(std::clamp(result[1] * 255.0f, 0.0f, 255.0f)),
|
static_cast<BYTE>(std::clamp(result[1] * 255.0f, 0.0f, 255.0f)),
|
||||||
static_cast<BYTE>(std::clamp(result[2] * 255.0f, 0.0f, 255.0f)));
|
static_cast<BYTE>(std::clamp(result[2] * 255.0f, 0.0f, 255.0f)));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void D3D12Device::PushDebugGroup(const char* name)
|
void D3D12Device::PushDebugGroup(const char* name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!m_debug_device)
|
if (!m_debug_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const UINT64 color = Palette(static_cast<float>(++s_debug_scope_depth), {0.5f, 0.5f, 0.5f}, {0.5f, 0.5f, 0.5f},
|
const UINT64 color = Palette(static_cast<float>(++s_debug_scope_depth), {0.5f, 0.5f, 0.5f}, {0.5f, 0.5f, 0.5f},
|
||||||
{1.0f, 1.0f, 0.5f}, {0.8f, 0.90f, 0.30f});
|
{1.0f, 1.0f, 0.5f}, {0.8f, 0.90f, 0.30f});
|
||||||
PIXBeginEvent(GetCommandList(), color, "%s", name);
|
PIXBeginEvent(GetCommandList(), color, "%s", name);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D12Device::PopDebugGroup()
|
void D3D12Device::PopDebugGroup()
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!m_debug_device)
|
if (!m_debug_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_debug_scope_depth = (s_debug_scope_depth == 0) ? 0 : (s_debug_scope_depth - 1u);
|
s_debug_scope_depth = (s_debug_scope_depth == 0) ? 0 : (s_debug_scope_depth - 1u);
|
||||||
PIXEndEvent(GetCommandList());
|
PIXEndEvent(GetCommandList());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D12Device::InsertDebugMessage(const char* msg)
|
void D3D12Device::InsertDebugMessage(const char* msg)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!m_debug_device)
|
if (!m_debug_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PIXSetMarker(GetCommandList(), PIX_COLOR(0, 0, 0), "%s", msg);
|
PIXSetMarker(GetCommandList(), PIX_COLOR(0, 0, 0), "%s", msg);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void D3D12Device::SetFeatures(D3D_FEATURE_LEVEL feature_level, FeatureMask disabled_features)
|
void D3D12Device::SetFeatures(D3D_FEATURE_LEVEL feature_level, FeatureMask disabled_features)
|
||||||
{
|
{
|
||||||
m_render_api_version = D3DCommon::GetRenderAPIVersionForFeatureLevel(feature_level);
|
m_render_api_version = D3DCommon::GetRenderAPIVersionForFeatureLevel(feature_level);
|
||||||
|
|
|
@ -101,9 +101,11 @@ public:
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void PushDebugGroup(const char* name) override;
|
void PushDebugGroup(const char* name) override;
|
||||||
void PopDebugGroup() override;
|
void PopDebugGroup() override;
|
||||||
void InsertDebugMessage(const char* msg) override;
|
void InsertDebugMessage(const char* msg) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
||||||
u32* map_base_vertex) override;
|
u32* map_base_vertex) override;
|
||||||
|
|
|
@ -22,10 +22,14 @@ D3D12Shader::D3D12Shader(GPUShaderStage stage, Bytecode bytecode) : GPUShader(st
|
||||||
|
|
||||||
D3D12Shader::~D3D12Shader() = default;
|
D3D12Shader::~D3D12Shader() = default;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D12Shader::SetDebugName(std::string_view name)
|
void D3D12Shader::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data,
|
std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data,
|
||||||
Error* error)
|
Error* error)
|
||||||
{
|
{
|
||||||
|
@ -72,11 +76,15 @@ D3D12Pipeline::~D3D12Pipeline()
|
||||||
D3D12Device::GetInstance().DeferObjectDestruction(std::move(m_pipeline));
|
D3D12Device::GetInstance().DeferObjectDestruction(std::move(m_pipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D12Pipeline::SetDebugName(std::string_view name)
|
void D3D12Pipeline::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
D3D12::SetObjectName(m_pipeline.Get(), name);
|
D3D12::SetObjectName(m_pipeline.Get(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string D3D12Pipeline::GetPipelineName(const GraphicsConfig& config)
|
std::string D3D12Pipeline::GetPipelineName(const GraphicsConfig& config)
|
||||||
{
|
{
|
||||||
SHA1Digest hash;
|
SHA1Digest hash;
|
||||||
|
|
|
@ -25,7 +25,9 @@ public:
|
||||||
ALWAYS_INLINE const u8* GetBytecodeData() const { return m_bytecode.data(); }
|
ALWAYS_INLINE const u8* GetBytecodeData() const { return m_bytecode.data(); }
|
||||||
ALWAYS_INLINE u32 GetBytecodeSize() const { return static_cast<u32>(m_bytecode.size()); }
|
ALWAYS_INLINE u32 GetBytecodeSize() const { return static_cast<u32>(m_bytecode.size()); }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D12Shader(GPUShaderStage stage, Bytecode bytecode);
|
D3D12Shader(GPUShaderStage stage, Bytecode bytecode);
|
||||||
|
@ -48,7 +50,9 @@ public:
|
||||||
ALWAYS_INLINE const std::array<float, 4>& GetBlendConstantsF() const { return m_blend_constants_f; }
|
ALWAYS_INLINE const std::array<float, 4>& GetBlendConstantsF() const { return m_blend_constants_f; }
|
||||||
ALWAYS_INLINE bool HasVertexStride() const { return (m_vertex_stride > 0); }
|
ALWAYS_INLINE bool HasVertexStride() const { return (m_vertex_stride > 0); }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
static std::string GetPipelineName(const GraphicsConfig& config);
|
static std::string GetPipelineName(const GraphicsConfig& config);
|
||||||
static std::string GetPipelineName(const ComputeConfig& config);
|
static std::string GetPipelineName(const ComputeConfig& config);
|
||||||
|
|
|
@ -616,11 +616,15 @@ void D3D12Texture::ActuallyCommitClear(ID3D12GraphicsCommandList* cmdlist)
|
||||||
SetState(State::Dirty);
|
SetState(State::Dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D12Texture::SetDebugName(std::string_view name)
|
void D3D12Texture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
D3D12::SetObjectName(m_resource.Get(), name);
|
D3D12::SetObjectName(m_resource.Get(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
u32 D3D12Texture::CalculateSubresource(u32 layer, u32 level, u32 num_levels)
|
u32 D3D12Texture::CalculateSubresource(u32 layer, u32 level, u32 num_levels)
|
||||||
{
|
{
|
||||||
// D3D11CalcSubresource
|
// D3D11CalcSubresource
|
||||||
|
@ -698,10 +702,14 @@ D3D12Sampler::~D3D12Sampler()
|
||||||
// Cleaned up by main class.
|
// Cleaned up by main class.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D12Sampler::SetDebugName(std::string_view name)
|
void D3D12Sampler::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
D3D12DescriptorHandle D3D12Device::GetSampler(const GPUSampler::Config& config, Error* error)
|
D3D12DescriptorHandle D3D12Device::GetSampler(const GPUSampler::Config& config, Error* error)
|
||||||
{
|
{
|
||||||
const auto it = m_sampler_map.find(config.key);
|
const auto it = m_sampler_map.find(config.key);
|
||||||
|
@ -843,11 +851,15 @@ void D3D12TextureBuffer::Unmap(u32 used_elements)
|
||||||
m_buffer.CommitMemory(size);
|
m_buffer.CommitMemory(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D12TextureBuffer::SetDebugName(std::string_view name)
|
void D3D12TextureBuffer::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
D3D12::SetObjectName(m_buffer.GetBuffer(), name);
|
D3D12::SetObjectName(m_buffer.GetBuffer(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUTextureBuffer> D3D12Device::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
std::unique_ptr<GPUTextureBuffer> D3D12Device::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
||||||
u32 size_in_elements, Error* error /* = nullptr */)
|
u32 size_in_elements, Error* error /* = nullptr */)
|
||||||
{
|
{
|
||||||
|
@ -1026,6 +1038,8 @@ void D3D12DownloadTexture::Flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void D3D12DownloadTexture::SetDebugName(std::string_view name)
|
void D3D12DownloadTexture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
|
@ -1034,6 +1048,8 @@ void D3D12DownloadTexture::SetDebugName(std::string_view name)
|
||||||
D3D12::SetObjectName(m_buffer.Get(), name);
|
D3D12::SetObjectName(m_buffer.Get(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUDownloadTexture> D3D12Device::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format,
|
std::unique_ptr<GPUDownloadTexture> D3D12Device::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format,
|
||||||
Error* error /* = nullptr */)
|
Error* error /* = nullptr */)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,9 @@ public:
|
||||||
void GenerateMipmaps() override;
|
void GenerateMipmaps() override;
|
||||||
void MakeReadyForSampling() override;
|
void MakeReadyForSampling() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
void TransitionToState(D3D12_RESOURCE_STATES state);
|
void TransitionToState(D3D12_RESOURCE_STATES state);
|
||||||
void CommitClear();
|
void CommitClear();
|
||||||
|
@ -115,7 +117,9 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE const D3D12DescriptorHandle& GetDescriptor() const { return m_descriptor; }
|
ALWAYS_INLINE const D3D12DescriptorHandle& GetDescriptor() const { return m_descriptor; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D12Sampler(D3D12DescriptorHandle descriptor);
|
D3D12Sampler(D3D12DescriptorHandle descriptor);
|
||||||
|
@ -140,7 +144,9 @@ public:
|
||||||
void* Map(u32 required_elements) override;
|
void* Map(u32 required_elements) override;
|
||||||
void Unmap(u32 used_elements) override;
|
void Unmap(u32 used_elements) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D12StreamBuffer m_buffer;
|
D3D12StreamBuffer m_buffer;
|
||||||
|
@ -165,7 +171,9 @@ public:
|
||||||
|
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D12DownloadTexture(u32 width, u32 height, GPUTexture::Format format, ComPtr<D3D12MA::Allocation> allocation,
|
D3D12DownloadTexture(u32 width, u32 height, GPUTexture::Format format, ComPtr<D3D12MA::Allocation> allocation,
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include "common/small_string.h"
|
#include "common/small_string.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
|
#include "fmt/base.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -26,6 +28,11 @@
|
||||||
class Error;
|
class Error;
|
||||||
class Image;
|
class Image;
|
||||||
|
|
||||||
|
// Enables debug event generation and object names for graphics debuggers.
|
||||||
|
#if defined(_DEBUG) || defined(_DEVEL)
|
||||||
|
#define ENABLE_GPU_OBJECT_NAMES
|
||||||
|
#endif
|
||||||
|
|
||||||
enum class RenderAPI : u8
|
enum class RenderAPI : u8
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
@ -97,7 +104,14 @@ public:
|
||||||
GPUSampler();
|
GPUSampler();
|
||||||
virtual ~GPUSampler();
|
virtual ~GPUSampler();
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
virtual void SetDebugName(std::string_view name) = 0;
|
virtual void SetDebugName(std::string_view name) = 0;
|
||||||
|
template<typename... T>
|
||||||
|
void SetDebugName(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
SetDebugName(TinyString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static Config GetNearestConfig();
|
static Config GetNearestConfig();
|
||||||
static Config GetLinearConfig();
|
static Config GetLinearConfig();
|
||||||
|
@ -135,7 +149,14 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE GPUShaderStage GetStage() const { return m_stage; }
|
ALWAYS_INLINE GPUShaderStage GetStage() const { return m_stage; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
virtual void SetDebugName(std::string_view name) = 0;
|
virtual void SetDebugName(std::string_view name) = 0;
|
||||||
|
template<typename... T>
|
||||||
|
void SetDebugName(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
SetDebugName(TinyString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GPUShaderStage m_stage;
|
GPUShaderStage m_stage;
|
||||||
|
@ -429,7 +450,14 @@ public:
|
||||||
GPUPipeline();
|
GPUPipeline();
|
||||||
virtual ~GPUPipeline();
|
virtual ~GPUPipeline();
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
virtual void SetDebugName(std::string_view name) = 0;
|
virtual void SetDebugName(std::string_view name) = 0;
|
||||||
|
template<typename... T>
|
||||||
|
void SetDebugName(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
SetDebugName(TinyString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class GPUTextureBuffer
|
class GPUTextureBuffer
|
||||||
|
@ -455,7 +483,14 @@ public:
|
||||||
virtual void* Map(u32 required_elements) = 0;
|
virtual void* Map(u32 required_elements) = 0;
|
||||||
virtual void Unmap(u32 used_elements) = 0;
|
virtual void Unmap(u32 used_elements) = 0;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
virtual void SetDebugName(std::string_view name) = 0;
|
virtual void SetDebugName(std::string_view name) = 0;
|
||||||
|
template<typename... T>
|
||||||
|
void SetDebugName(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
SetDebugName(TinyString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Format m_format;
|
Format m_format;
|
||||||
|
@ -739,11 +774,25 @@ public:
|
||||||
virtual std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config,
|
virtual std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config,
|
||||||
Error* error = nullptr) = 0;
|
Error* error = nullptr) = 0;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
/// Debug messaging.
|
/// Debug messaging.
|
||||||
virtual void PushDebugGroup(const char* name) = 0;
|
virtual void PushDebugGroup(const char* name) = 0;
|
||||||
virtual void PopDebugGroup() = 0;
|
virtual void PopDebugGroup() = 0;
|
||||||
virtual void InsertDebugMessage(const char* msg) = 0;
|
virtual void InsertDebugMessage(const char* msg) = 0;
|
||||||
|
|
||||||
|
/// Formatted debug variants.
|
||||||
|
template<typename... T>
|
||||||
|
void PushDebugGroup(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
PushDebugGroup(TinyString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
template<typename... T>
|
||||||
|
void InsertDebugMessage(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
InsertDebugMessage(TinyString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Vertex/index buffer abstraction.
|
/// Vertex/index buffer abstraction.
|
||||||
virtual void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
virtual void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
||||||
u32* map_base_vertex) = 0;
|
u32* map_base_vertex) = 0;
|
||||||
|
@ -929,24 +978,74 @@ ALWAYS_INLINE void GPUDevice::PooledTextureDeleter::operator()(GPUTexture* const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Macros for debug messages.
|
// Macros for debug messages.
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
struct GLAutoPop
|
struct GLAutoPop
|
||||||
{
|
{
|
||||||
GLAutoPop(int dummy) {}
|
GLAutoPop(const char* name)
|
||||||
~GLAutoPop() { g_gpu_device->PopDebugGroup(); }
|
{
|
||||||
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]]
|
||||||
|
g_gpu_device->PushDebugGroup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename... T>
|
||||||
|
GLAutoPop(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]]
|
||||||
|
g_gpu_device->PushDebugGroup(SmallString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
|
||||||
|
~GLAutoPop()
|
||||||
|
{
|
||||||
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]]
|
||||||
|
g_gpu_device->PopDebugGroup();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GL_SCOPE(name) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(name), 0))
|
#define GL_SCOPE(name) GLAutoPop gl_auto_pop(name)
|
||||||
#define GL_PUSH(name) g_gpu_device->PushDebugGroup(name)
|
#define GL_PUSH(name) \
|
||||||
#define GL_POP() g_gpu_device->PopDebugGroup()
|
do \
|
||||||
#define GL_INS(msg) g_gpu_device->InsertDebugMessage(msg)
|
{ \
|
||||||
#define GL_OBJECT_NAME(obj, name) (obj)->SetDebugName(name)
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]] \
|
||||||
|
g_gpu_device->PushDebugGroup(name); \
|
||||||
|
} while (0)
|
||||||
|
#define GL_POP() \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]] \
|
||||||
|
g_gpu_device->PopDebugGroup(); \
|
||||||
|
} while (0)
|
||||||
|
#define GL_INS(msg) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]] \
|
||||||
|
g_gpu_device->InsertDebugMessage(msg); \
|
||||||
|
} while (0)
|
||||||
|
#define GL_OBJECT_NAME(obj, name) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]] \
|
||||||
|
(obj)->SetDebugName(name); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define GL_SCOPE_FMT(...) \
|
#define GL_SCOPE_FMT(...) GLAutoPop gl_auto_pop(__VA_ARGS__)
|
||||||
GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(SmallString::from_format(__VA_ARGS__)), 0))
|
#define GL_PUSH_FMT(...) \
|
||||||
#define GL_PUSH_FMT(...) g_gpu_device->PushDebugGroup(SmallString::from_format(__VA_ARGS__))
|
do \
|
||||||
#define GL_INS_FMT(...) g_gpu_device->InsertDebugMessage(SmallString::from_format(__VA_ARGS__))
|
{ \
|
||||||
#define GL_OBJECT_NAME_FMT(obj, ...) (obj)->SetDebugName(SmallString::from_format(__VA_ARGS__))
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]] \
|
||||||
|
g_gpu_device->PushDebugGroup(__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
#define GL_INS_FMT(...) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]] \
|
||||||
|
g_gpu_device->InsertDebugMessage(__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
#define GL_OBJECT_NAME_FMT(obj, ...) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (g_gpu_device->IsDebugDevice()) [[unlikely]] \
|
||||||
|
(obj)->SetDebugName(__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define GL_SCOPE(name) (void)0
|
#define GL_SCOPE(name) (void)0
|
||||||
#define GL_PUSH(name) (void)0
|
#define GL_PUSH(name) (void)0
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/gsvector.h"
|
#include "common/gsvector.h"
|
||||||
|
#include "common/small_string.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
@ -184,7 +187,14 @@ public:
|
||||||
// Instructs the backend that we're finished rendering to this texture. It may transition it to a new layout.
|
// Instructs the backend that we're finished rendering to this texture. It may transition it to a new layout.
|
||||||
virtual void MakeReadyForSampling();
|
virtual void MakeReadyForSampling();
|
||||||
|
|
||||||
|
#if defined(_DEBUG) || defined(_DEVEL)
|
||||||
virtual void SetDebugName(std::string_view name) = 0;
|
virtual void SetDebugName(std::string_view name) = 0;
|
||||||
|
template<typename... T>
|
||||||
|
void SetDebugName(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
SetDebugName(TinyString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GPUTexture(u16 width, u16 height, u8 layers, u8 levels, u8 samples, Type type, Format format, Flags flags);
|
GPUTexture(u16 width, u16 height, u8 layers, u8 levels, u8 samples, Type type, Format format, Flags flags);
|
||||||
|
@ -252,8 +262,15 @@ public:
|
||||||
/// call to CopyFromTexture() and the Flush() call.
|
/// call to CopyFromTexture() and the Flush() call.
|
||||||
virtual void Flush() = 0;
|
virtual void Flush() = 0;
|
||||||
|
|
||||||
|
#if defined(_DEBUG) || defined(_DEVEL)
|
||||||
/// Sets object name that will be displayed in graphics debuggers.
|
/// Sets object name that will be displayed in graphics debuggers.
|
||||||
virtual void SetDebugName(std::string_view name) = 0;
|
virtual void SetDebugName(std::string_view name) = 0;
|
||||||
|
template<typename... T>
|
||||||
|
void SetDebugName(fmt::format_string<T...> fmt, T&&... args)
|
||||||
|
{
|
||||||
|
SetDebugName(TinyString::from_vformat(fmt, fmt::make_format_args(args...)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Reads the specified rectangle from the staging texture to out_ptr, with the specified stride
|
/// Reads the specified rectangle from the staging texture to out_ptr, with the specified stride
|
||||||
/// (length in bytes of each row). CopyFromTexture() must be called first. The contents of any
|
/// (length in bytes of each row). CopyFromTexture() must be called first. The contents of any
|
||||||
|
|
|
@ -285,9 +285,7 @@ bool MediaCaptureBase::DeliverVideoFrame(GPUTexture* stex)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
GL_OBJECT_NAME_FMT(pf.tex, "MediaCapture {}x{} Download Texture", stex->GetWidth(), stex->GetHeight());
|
GL_OBJECT_NAME_FMT(pf.tex, "MediaCapture {}x{} Download Texture", stex->GetWidth(), stex->GetHeight());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pf.tex->CopyFromTexture(0, 0, stex, 0, 0, m_video_width, m_video_height, 0, 0);
|
pf.tex->CopyFromTexture(0, 0, stex, 0, 0, m_video_width, m_video_height, 0, 0);
|
||||||
|
|
|
@ -44,7 +44,9 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE id<MTLSamplerState> GetSamplerState() const { return m_ss; }
|
ALWAYS_INLINE id<MTLSamplerState> GetSamplerState() const { return m_ss; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MetalSampler(id<MTLSamplerState> ss);
|
MetalSampler(id<MTLSamplerState> ss);
|
||||||
|
@ -62,7 +64,9 @@ public:
|
||||||
ALWAYS_INLINE id<MTLLibrary> GetLibrary() const { return m_library; }
|
ALWAYS_INLINE id<MTLLibrary> GetLibrary() const { return m_library; }
|
||||||
ALWAYS_INLINE id<MTLFunction> GetFunction() const { return m_function; }
|
ALWAYS_INLINE id<MTLFunction> GetFunction() const { return m_function; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MetalShader(GPUShaderStage stage, id<MTLLibrary> library, id<MTLFunction> function);
|
MetalShader(GPUShaderStage stage, id<MTLLibrary> library, id<MTLFunction> function);
|
||||||
|
@ -92,7 +96,9 @@ public:
|
||||||
ALWAYS_INLINE MTLCullMode GetCullMode() const { return m_cull_mode; }
|
ALWAYS_INLINE MTLCullMode GetCullMode() const { return m_cull_mode; }
|
||||||
ALWAYS_INLINE MTLPrimitiveType GetPrimitive() const { return m_primitive; }
|
ALWAYS_INLINE MTLPrimitiveType GetPrimitive() const { return m_primitive; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MetalPipeline(id pipeline, id<MTLDepthStencilState> depth, MTLCullMode cull_mode, MTLPrimitiveType primitive);
|
MetalPipeline(id pipeline, id<MTLDepthStencilState> depth, MTLCullMode cull_mode, MTLPrimitiveType primitive);
|
||||||
|
@ -122,7 +128,9 @@ public:
|
||||||
void MakeReadyForSampling() override;
|
void MakeReadyForSampling() override;
|
||||||
void GenerateMipmaps() override;
|
void GenerateMipmaps() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Call when the texture is bound to the pipeline, or read from in a copy.
|
// Call when the texture is bound to the pipeline, or read from in a copy.
|
||||||
ALWAYS_INLINE void SetUseFenceCounter(u64 counter) { m_use_fence_counter = counter; }
|
ALWAYS_INLINE void SetUseFenceCounter(u64 counter) { m_use_fence_counter = counter; }
|
||||||
|
@ -161,7 +169,9 @@ public:
|
||||||
|
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MetalDownloadTexture(u32 width, u32 height, GPUTexture::Format format, u8* import_buffer, size_t buffer_offset,
|
MetalDownloadTexture(u32 width, u32 height, GPUTexture::Format format, u8* import_buffer, size_t buffer_offset,
|
||||||
|
@ -187,7 +197,9 @@ public:
|
||||||
void* Map(u32 required_elements) override;
|
void* Map(u32 required_elements) override;
|
||||||
void Unmap(u32 used_elements) override;
|
void Unmap(u32 used_elements) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MetalStreamBuffer m_buffer;
|
MetalStreamBuffer m_buffer;
|
||||||
|
@ -265,9 +277,11 @@ public:
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void PushDebugGroup(const char* name) override;
|
void PushDebugGroup(const char* name) override;
|
||||||
void PopDebugGroup() override;
|
void PopDebugGroup() override;
|
||||||
void InsertDebugMessage(const char* msg) override;
|
void InsertDebugMessage(const char* msg) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
||||||
u32* map_base_vertex) override;
|
u32* map_base_vertex) override;
|
||||||
|
|
|
@ -643,6 +643,8 @@ MetalShader::~MetalShader()
|
||||||
MetalDevice::DeferRelease(m_library);
|
MetalDevice::DeferRelease(m_library);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void MetalShader::SetDebugName(std::string_view name)
|
void MetalShader::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
@autoreleasepool
|
@autoreleasepool
|
||||||
|
@ -651,6 +653,8 @@ void MetalShader::SetDebugName(std::string_view name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage, std::string_view source,
|
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage, std::string_view source,
|
||||||
std::string_view entry_point, Error* error)
|
std::string_view entry_point, Error* error)
|
||||||
{
|
{
|
||||||
|
@ -747,11 +751,15 @@ MetalPipeline::~MetalPipeline()
|
||||||
MetalDevice::DeferRelease(m_pipeline);
|
MetalDevice::DeferRelease(m_pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void MetalPipeline::SetDebugName(std::string_view name)
|
void MetalPipeline::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
// readonly property :/
|
// readonly property :/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
id<MTLDepthStencilState> MetalDevice::GetDepthState(const GPUPipeline::DepthState& ds)
|
id<MTLDepthStencilState> MetalDevice::GetDepthState(const GPUPipeline::DepthState& ds)
|
||||||
{
|
{
|
||||||
const auto it = m_depth_states.find(ds.key);
|
const auto it = m_depth_states.find(ds.key);
|
||||||
|
@ -1157,6 +1165,8 @@ void MetalTexture::GenerateMipmaps()
|
||||||
[encoder generateMipmapsForTexture:m_texture];
|
[encoder generateMipmapsForTexture:m_texture];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void MetalTexture::SetDebugName(std::string_view name)
|
void MetalTexture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
@autoreleasepool
|
@autoreleasepool
|
||||||
|
@ -1165,6 +1175,8 @@ void MetalTexture::SetDebugName(std::string_view name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUTexture> MetalDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
|
std::unique_ptr<GPUTexture> MetalDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
|
||||||
GPUTexture::Type type, GPUTexture::Format format,
|
GPUTexture::Type type, GPUTexture::Format format,
|
||||||
GPUTexture::Flags flags, const void* data, u32 data_stride,
|
GPUTexture::Flags flags, const void* data, u32 data_stride,
|
||||||
|
@ -1381,6 +1393,8 @@ void MetalDownloadTexture::Flush()
|
||||||
dev.WaitForFenceCounter(m_copy_fence_counter);
|
dev.WaitForFenceCounter(m_copy_fence_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void MetalDownloadTexture::SetDebugName(std::string_view name)
|
void MetalDownloadTexture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
@autoreleasepool
|
@autoreleasepool
|
||||||
|
@ -1389,6 +1403,8 @@ void MetalDownloadTexture::SetDebugName(std::string_view name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUDownloadTexture> MetalDevice::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format,
|
std::unique_ptr<GPUDownloadTexture> MetalDevice::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format,
|
||||||
Error* error)
|
Error* error)
|
||||||
{
|
{
|
||||||
|
@ -1408,11 +1424,15 @@ MetalSampler::MetalSampler(id<MTLSamplerState> ss) : m_ss(ss)
|
||||||
|
|
||||||
MetalSampler::~MetalSampler() = default;
|
MetalSampler::~MetalSampler() = default;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void MetalSampler::SetDebugName(std::string_view name)
|
void MetalSampler::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
// lame.. have to put it on the descriptor :/
|
// lame.. have to put it on the descriptor :/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUSampler> MetalDevice::CreateSampler(const GPUSampler::Config& config, Error* error)
|
std::unique_ptr<GPUSampler> MetalDevice::CreateSampler(const GPUSampler::Config& config, Error* error)
|
||||||
{
|
{
|
||||||
@autoreleasepool
|
@autoreleasepool
|
||||||
|
@ -1822,6 +1842,8 @@ void MetalTextureBuffer::Unmap(u32 used_elements)
|
||||||
m_buffer.CommitMemory(size);
|
m_buffer.CommitMemory(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void MetalTextureBuffer::SetDebugName(std::string_view name)
|
void MetalTextureBuffer::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
@autoreleasepool
|
@autoreleasepool
|
||||||
|
@ -1830,6 +1852,8 @@ void MetalTextureBuffer::SetDebugName(std::string_view name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUTextureBuffer> MetalDevice::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
std::unique_ptr<GPUTextureBuffer> MetalDevice::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
||||||
u32 size_in_elements, Error* error)
|
u32 size_in_elements, Error* error)
|
||||||
{
|
{
|
||||||
|
@ -1840,6 +1864,8 @@ std::unique_ptr<GPUTextureBuffer> MetalDevice::CreateTextureBuffer(GPUTextureBuf
|
||||||
return tb;
|
return tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void MetalDevice::PushDebugGroup(const char* name)
|
void MetalDevice::PushDebugGroup(const char* name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1852,6 +1878,8 @@ void MetalDevice::InsertDebugMessage(const char* msg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void MetalDevice::MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
void MetalDevice::MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
||||||
u32* map_base_vertex)
|
u32* map_base_vertex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -214,29 +214,26 @@ std::unique_ptr<GPUPipeline> OpenGLDevice::CreatePipeline(const GPUPipeline::Com
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void OpenGLDevice::PushDebugGroup(const char* name)
|
void OpenGLDevice::PushDebugGroup(const char* name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!glPushDebugGroup)
|
if (!glPushDebugGroup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, static_cast<GLsizei>(std::strlen(name)), name);
|
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, static_cast<GLsizei>(std::strlen(name)), name);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDevice::PopDebugGroup()
|
void OpenGLDevice::PopDebugGroup()
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!glPopDebugGroup)
|
if (!glPopDebugGroup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glPopDebugGroup();
|
glPopDebugGroup();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDevice::InsertDebugMessage(const char* msg)
|
void OpenGLDevice::InsertDebugMessage(const char* msg)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!glDebugMessageInsert)
|
if (!glDebugMessageInsert)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -245,9 +242,10 @@ void OpenGLDevice::InsertDebugMessage(const char* msg)
|
||||||
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, GL_DEBUG_SEVERITY_NOTIFICATION,
|
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, GL_DEBUG_SEVERITY_NOTIFICATION,
|
||||||
static_cast<GLsizei>(std::strlen(msg)), msg);
|
static_cast<GLsizei>(std::strlen(msg)), msg);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static void GLAD_API_PTR GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
static void GLAD_API_PTR GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
|
||||||
const GLchar* message, const void* userParam)
|
const GLchar* message, const void* userParam)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,9 +82,11 @@ public:
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void PushDebugGroup(const char* name) override;
|
void PushDebugGroup(const char* name) override;
|
||||||
void PopDebugGroup() override;
|
void PopDebugGroup() override;
|
||||||
void InsertDebugMessage(const char* msg) override;
|
void InsertDebugMessage(const char* msg) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
||||||
u32* map_base_vertex) override;
|
u32* map_base_vertex) override;
|
||||||
|
|
|
@ -78,9 +78,10 @@ OpenGLShader::~OpenGLShader()
|
||||||
glDeleteShader(m_id.value());
|
glDeleteShader(m_id.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void OpenGLShader::SetDebugName(std::string_view name)
|
void OpenGLShader::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (glObjectLabel)
|
if (glObjectLabel)
|
||||||
{
|
{
|
||||||
if (m_id.has_value())
|
if (m_id.has_value())
|
||||||
|
@ -94,9 +95,10 @@ void OpenGLShader::SetDebugName(std::string_view name)
|
||||||
m_debug_name = name;
|
m_debug_name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
bool OpenGLShader::Compile(Error* error)
|
bool OpenGLShader::Compile(Error* error)
|
||||||
{
|
{
|
||||||
if (m_compile_tried)
|
if (m_compile_tried)
|
||||||
|
@ -155,7 +157,7 @@ bool OpenGLShader::Compile(Error* error)
|
||||||
|
|
||||||
m_id = shader;
|
m_id = shader;
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
if (glObjectLabel && !m_debug_name.empty())
|
if (glObjectLabel && !m_debug_name.empty())
|
||||||
{
|
{
|
||||||
glObjectLabel(GL_SHADER, shader, static_cast<GLsizei>(m_debug_name.length()),
|
glObjectLabel(GL_SHADER, shader, static_cast<GLsizei>(m_debug_name.length()),
|
||||||
|
@ -584,14 +586,16 @@ OpenGLPipeline::~OpenGLPipeline()
|
||||||
dev.UnrefVAO(m_key.va_key);
|
dev.UnrefVAO(m_key.va_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void OpenGLPipeline::SetDebugName(std::string_view name)
|
void OpenGLPipeline::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (glObjectLabel)
|
if (glObjectLabel)
|
||||||
glObjectLabel(GL_PROGRAM, m_program, static_cast<u32>(name.length()), name.data());
|
glObjectLabel(GL_PROGRAM, m_program, static_cast<u32>(name.length()), name.data());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUPipeline> OpenGLDevice::CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error)
|
std::unique_ptr<GPUPipeline> OpenGLDevice::CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error)
|
||||||
{
|
{
|
||||||
const OpenGLPipeline::ProgramCacheKey pkey = OpenGLPipeline::GetProgramCacheKey(config);
|
const OpenGLPipeline::ProgramCacheKey pkey = OpenGLPipeline::GetProgramCacheKey(config);
|
||||||
|
|
|
@ -16,7 +16,9 @@ class OpenGLShader final : public GPUShader
|
||||||
public:
|
public:
|
||||||
~OpenGLShader() override;
|
~OpenGLShader() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool Compile(Error* error);
|
bool Compile(Error* error);
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ private:
|
||||||
std::optional<GLuint> m_id;
|
std::optional<GLuint> m_id;
|
||||||
bool m_compile_tried = false;
|
bool m_compile_tried = false;
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
std::string m_debug_name;
|
std::string m_debug_name;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -104,7 +106,9 @@ public:
|
||||||
ALWAYS_INLINE const BlendState& GetBlendState() const { return m_blend_state; }
|
ALWAYS_INLINE const BlendState& GetBlendState() const { return m_blend_state; }
|
||||||
ALWAYS_INLINE GLenum GetTopology() const { return m_topology; }
|
ALWAYS_INLINE GLenum GetTopology() const { return m_topology; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpenGLPipeline(const ProgramCacheKey& key, GLuint program, VertexArrayCache::const_iterator vao,
|
OpenGLPipeline(const ProgramCacheKey& key, GLuint program, VertexArrayCache::const_iterator vao,
|
||||||
|
|
|
@ -29,17 +29,19 @@ void OpenGLStreamBuffer::Unbind()
|
||||||
glBindBuffer(m_target, 0);
|
glBindBuffer(m_target, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_DEBUG) || defined(_DEVEL)
|
||||||
|
|
||||||
void OpenGLStreamBuffer::SetDebugName(std::string_view name)
|
void OpenGLStreamBuffer::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (glObjectLabel)
|
if (glObjectLabel)
|
||||||
{
|
{
|
||||||
glObjectLabel(GL_BUFFER, GetGLBufferId(), static_cast<GLsizei>(name.length()),
|
glObjectLabel(GL_BUFFER, GetGLBufferId(), static_cast<GLsizei>(name.length()),
|
||||||
static_cast<const GLchar*>(name.data()));
|
static_cast<const GLchar*>(name.data()));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Uses glBufferSubData() to update. Preferred for drivers which don't support {ARB,EXT}_buffer_storage.
|
// Uses glBufferSubData() to update. Preferred for drivers which don't support {ARB,EXT}_buffer_storage.
|
||||||
|
|
|
@ -26,7 +26,9 @@ public:
|
||||||
void Bind();
|
void Bind();
|
||||||
void Unbind();
|
void Unbind();
|
||||||
|
|
||||||
|
#if defined(_DEBUG) || defined(_DEVEL)
|
||||||
void SetDebugName(std::string_view name);
|
void SetDebugName(std::string_view name);
|
||||||
|
#endif
|
||||||
|
|
||||||
struct MappingResult
|
struct MappingResult
|
||||||
{
|
{
|
||||||
|
|
|
@ -485,18 +485,14 @@ void OpenGLTexture::GenerateMipmaps()
|
||||||
glBindTexture(target, 0);
|
glBindTexture(target, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void OpenGLTexture::SetDebugName(std::string_view name)
|
void OpenGLTexture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (glObjectLabel)
|
if (glObjectLabel)
|
||||||
glObjectLabel(GL_TEXTURE, m_id, static_cast<GLsizei>(name.length()), static_cast<const GLchar*>(name.data()));
|
glObjectLabel(GL_TEXTURE, m_id, static_cast<GLsizei>(name.length()), static_cast<const GLchar*>(name.data()));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// If we don't have border clamp.. too bad, just hope for the best.
|
|
||||||
if (!m_gl_context->IsGLES() || GLAD_GL_ES_VERSION_3_2 || GLAD_GL_NV_texture_border_clamp ||
|
|
||||||
GLAD_GL_EXT_texture_border_clamp || GLAD_GL_OES_texture_border_clamp)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -510,14 +506,16 @@ OpenGLSampler::~OpenGLSampler()
|
||||||
OpenGLDevice::GetInstance().UnbindSampler(m_id);
|
OpenGLDevice::GetInstance().UnbindSampler(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void OpenGLSampler::SetDebugName(std::string_view name)
|
void OpenGLSampler::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (glObjectLabel)
|
if (glObjectLabel)
|
||||||
glObjectLabel(GL_SAMPLER, m_id, static_cast<GLsizei>(name.length()), static_cast<const GLchar*>(name.data()));
|
glObjectLabel(GL_SAMPLER, m_id, static_cast<GLsizei>(name.length()), static_cast<const GLchar*>(name.data()));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUSampler> OpenGLDevice::CreateSampler(const GPUSampler::Config& config, Error* error /* = nullptr */)
|
std::unique_ptr<GPUSampler> OpenGLDevice::CreateSampler(const GPUSampler::Config& config, Error* error /* = nullptr */)
|
||||||
{
|
{
|
||||||
static constexpr std::array<GLenum, static_cast<u8>(GPUSampler::AddressMode::MaxCount)> ta = {{
|
static constexpr std::array<GLenum, static_cast<u8>(GPUSampler::AddressMode::MaxCount)> ta = {{
|
||||||
|
@ -798,17 +796,19 @@ void OpenGLTextureBuffer::Unmap(u32 used_elements)
|
||||||
m_buffer->Unmap(size);
|
m_buffer->Unmap(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void OpenGLTextureBuffer::SetDebugName(std::string_view name)
|
void OpenGLTextureBuffer::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (glObjectLabel)
|
if (glObjectLabel)
|
||||||
{
|
{
|
||||||
glObjectLabel(GL_TEXTURE, m_buffer->GetGLBufferId(), static_cast<GLsizei>(name.length()),
|
glObjectLabel(GL_TEXTURE, m_buffer->GetGLBufferId(), static_cast<GLsizei>(name.length()),
|
||||||
static_cast<const GLchar*>(name.data()));
|
static_cast<const GLchar*>(name.data()));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUTextureBuffer> OpenGLDevice::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
std::unique_ptr<GPUTextureBuffer> OpenGLDevice::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
||||||
u32 size_in_elements, Error* error)
|
u32 size_in_elements, Error* error)
|
||||||
{
|
{
|
||||||
|
@ -1037,6 +1037,8 @@ void OpenGLDownloadTexture::Flush()
|
||||||
m_sync = {};
|
m_sync = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void OpenGLDownloadTexture::SetDebugName(std::string_view name)
|
void OpenGLDownloadTexture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
|
@ -1046,6 +1048,8 @@ void OpenGLDownloadTexture::SetDebugName(std::string_view name)
|
||||||
glObjectLabel(GL_BUFFER, m_buffer_id, static_cast<GLsizei>(name.length()), name.data());
|
glObjectLabel(GL_BUFFER, m_buffer_id, static_cast<GLsizei>(name.length()), name.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUDownloadTexture>
|
std::unique_ptr<GPUDownloadTexture>
|
||||||
OpenGLDevice::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format, Error* error /* = nullptr */)
|
OpenGLDevice::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format, Error* error /* = nullptr */)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,9 @@ public:
|
||||||
void Unmap() override;
|
void Unmap() override;
|
||||||
void GenerateMipmaps() override;
|
void GenerateMipmaps() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
static std::unique_ptr<OpenGLTexture> Create(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type,
|
static std::unique_ptr<OpenGLTexture> Create(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type,
|
||||||
Format format, Flags flags, const void* data, u32 data_pitch,
|
Format format, Flags flags, const void* data, u32 data_pitch,
|
||||||
|
@ -78,7 +80,9 @@ public:
|
||||||
void* Map(u32 required_elements) override;
|
void* Map(u32 required_elements) override;
|
||||||
void Unmap(u32 used_elements) override;
|
void Unmap(u32 used_elements) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpenGLTextureBuffer(Format format, u32 size_in_elements, std::unique_ptr<OpenGLStreamBuffer> buffer,
|
OpenGLTextureBuffer(Format format, u32 size_in_elements, std::unique_ptr<OpenGLStreamBuffer> buffer,
|
||||||
|
@ -97,7 +101,9 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE GLuint GetID() const { return m_id; }
|
ALWAYS_INLINE GLuint GetID() const { return m_id; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpenGLSampler(GLuint id);
|
OpenGLSampler(GLuint id);
|
||||||
|
@ -121,7 +127,9 @@ public:
|
||||||
|
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpenGLDownloadTexture(u32 width, u32 height, GPUTexture::Format format, bool imported, GLuint buffer_id,
|
OpenGLDownloadTexture(u32 width, u32 height, GPUTexture::Format format, bool imported, GLuint buffer_id,
|
||||||
|
|
|
@ -1265,7 +1265,7 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||||
pass.samplers.push_back(std::move(sampler));
|
pass.samplers.push_back(std::move(sampler));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
pass.name = std::move(pi.name);
|
pass.name = std::move(pi.name);
|
||||||
#endif
|
#endif
|
||||||
m_passes.push_back(std::move(pass));
|
m_passes.push_back(std::move(pass));
|
||||||
|
|
|
@ -132,7 +132,7 @@ private:
|
||||||
llvm::SmallVector<Sampler, GPUDevice::MAX_TEXTURE_SAMPLERS> samplers;
|
llvm::SmallVector<Sampler, GPUDevice::MAX_TEXTURE_SAMPLERS> samplers;
|
||||||
u32 num_vertices;
|
u32 num_vertices;
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
std::string name;
|
std::string name;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -105,7 +105,7 @@ const std::array<VkFormat, static_cast<u32>(GPUTexture::Format::MaxCount)> Vulka
|
||||||
// Handles are always 64-bit, even on 32-bit platforms.
|
// Handles are always 64-bit, even on 32-bit platforms.
|
||||||
static const VkRenderPass DYNAMIC_RENDERING_RENDER_PASS = ((VkRenderPass) static_cast<s64>(-1LL));
|
static const VkRenderPass DYNAMIC_RENDERING_RENDER_PASS = ((VkRenderPass) static_cast<s64>(-1LL));
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
static u32 s_debug_scope_depth = 0;
|
static u32 s_debug_scope_depth = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ VulkanDevice::VulkanDevice()
|
||||||
{
|
{
|
||||||
m_render_api = RenderAPI::Vulkan;
|
m_render_api = RenderAPI::Vulkan;
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
s_debug_scope_depth = 0;
|
s_debug_scope_depth = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2327,7 +2327,7 @@ void VulkanDevice::SubmitPresent(GPUSwapChain* swap_chain)
|
||||||
QueuePresent(static_cast<VulkanSwapChain*>(swap_chain));
|
QueuePresent(static_cast<VulkanSwapChain*>(swap_chain));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
static std::array<float, 3> Palette(float phase, const std::array<float, 3>& a, const std::array<float, 3>& b,
|
static std::array<float, 3> Palette(float phase, const std::array<float, 3>& a, const std::array<float, 3>& b,
|
||||||
const std::array<float, 3>& c, const std::array<float, 3>& d)
|
const std::array<float, 3>& c, const std::array<float, 3>& d)
|
||||||
{
|
{
|
||||||
|
@ -2337,11 +2337,9 @@ static std::array<float, 3> Palette(float phase, const std::array<float, 3>& a,
|
||||||
result[2] = a[2] + b[2] * std::cos(6.28318f * (c[2] * phase + d[2]));
|
result[2] = a[2] + b[2] * std::cos(6.28318f * (c[2] * phase + d[2]));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void VulkanDevice::PushDebugGroup(const char* name)
|
void VulkanDevice::PushDebugGroup(const char* name)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!vkCmdBeginDebugUtilsLabelEXT || !m_debug_device)
|
if (!vkCmdBeginDebugUtilsLabelEXT || !m_debug_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2355,32 +2353,29 @@ void VulkanDevice::PushDebugGroup(const char* name)
|
||||||
{color[0], color[1], color[2], 1.0f},
|
{color[0], color[1], color[2], 1.0f},
|
||||||
};
|
};
|
||||||
vkCmdBeginDebugUtilsLabelEXT(GetCurrentCommandBuffer(), &label);
|
vkCmdBeginDebugUtilsLabelEXT(GetCurrentCommandBuffer(), &label);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanDevice::PopDebugGroup()
|
void VulkanDevice::PopDebugGroup()
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!vkCmdEndDebugUtilsLabelEXT || !m_debug_device)
|
if (!vkCmdEndDebugUtilsLabelEXT || !m_debug_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_debug_scope_depth = (s_debug_scope_depth == 0) ? 0 : (s_debug_scope_depth - 1u);
|
s_debug_scope_depth = (s_debug_scope_depth == 0) ? 0 : (s_debug_scope_depth - 1u);
|
||||||
|
|
||||||
vkCmdEndDebugUtilsLabelEXT(GetCurrentCommandBuffer());
|
vkCmdEndDebugUtilsLabelEXT(GetCurrentCommandBuffer());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanDevice::InsertDebugMessage(const char* msg)
|
void VulkanDevice::InsertDebugMessage(const char* msg)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) || defined(_DEVEL)
|
|
||||||
if (!vkCmdInsertDebugUtilsLabelEXT || !m_debug_device)
|
if (!vkCmdInsertDebugUtilsLabelEXT || !m_debug_device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const VkDebugUtilsLabelEXT label = {VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, nullptr, msg, {0.0f, 0.0f, 0.0f, 1.0f}};
|
const VkDebugUtilsLabelEXT label = {VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, nullptr, msg, {0.0f, 0.0f, 0.0f, 1.0f}};
|
||||||
vkCmdInsertDebugUtilsLabelEXT(GetCurrentCommandBuffer(), &label);
|
vkCmdInsertDebugUtilsLabelEXT(GetCurrentCommandBuffer(), &label);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
u32 VulkanDevice::GetMaxMultisamples(VkPhysicalDevice physical_device, const VkPhysicalDeviceProperties& properties)
|
u32 VulkanDevice::GetMaxMultisamples(VkPhysicalDevice physical_device, const VkPhysicalDeviceProperties& properties)
|
||||||
{
|
{
|
||||||
VkImageFormatProperties color_properties = {};
|
VkImageFormatProperties color_properties = {};
|
||||||
|
|
|
@ -118,9 +118,11 @@ public:
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error) override;
|
||||||
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::ComputeConfig& config, Error* error) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void PushDebugGroup(const char* name) override;
|
void PushDebugGroup(const char* name) override;
|
||||||
void PopDebugGroup() override;
|
void PopDebugGroup() override;
|
||||||
void InsertDebugMessage(const char* msg) override;
|
void InsertDebugMessage(const char* msg) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
|
||||||
u32* map_base_vertex) override;
|
u32* map_base_vertex) override;
|
||||||
|
|
|
@ -22,11 +22,15 @@ VulkanShader::~VulkanShader()
|
||||||
vkDestroyShaderModule(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, nullptr);
|
vkDestroyShaderModule(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void VulkanShader::SetDebugName(std::string_view name)
|
void VulkanShader::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, name);
|
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data,
|
std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data,
|
||||||
Error* error)
|
Error* error)
|
||||||
{
|
{
|
||||||
|
@ -107,11 +111,15 @@ VulkanPipeline::~VulkanPipeline()
|
||||||
VulkanDevice::GetInstance().DeferPipelineDestruction(m_pipeline);
|
VulkanDevice::GetInstance().DeferPipelineDestruction(m_pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void VulkanPipeline::SetDebugName(std::string_view name)
|
void VulkanPipeline::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_pipeline, name);
|
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_pipeline, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUPipeline> VulkanDevice::CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error)
|
std::unique_ptr<GPUPipeline> VulkanDevice::CreatePipeline(const GPUPipeline::GraphicsConfig& config, Error* error)
|
||||||
{
|
{
|
||||||
static constexpr std::array<std::pair<VkPrimitiveTopology, u32>, static_cast<u32>(GPUPipeline::Primitive::MaxCount)>
|
static constexpr std::array<std::pair<VkPrimitiveTopology, u32>, static_cast<u32>(GPUPipeline::Primitive::MaxCount)>
|
||||||
|
|
|
@ -15,7 +15,9 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE VkShaderModule GetModule() const { return m_module; }
|
ALWAYS_INLINE VkShaderModule GetModule() const { return m_module; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VulkanShader(GPUShaderStage stage, VkShaderModule mod);
|
VulkanShader(GPUShaderStage stage, VkShaderModule mod);
|
||||||
|
@ -34,7 +36,9 @@ public:
|
||||||
ALWAYS_INLINE Layout GetLayout() const { return m_layout; }
|
ALWAYS_INLINE Layout GetLayout() const { return m_layout; }
|
||||||
ALWAYS_INLINE u8 GetVerticesPerPrimitive() const { return m_vertices_per_primitive; }
|
ALWAYS_INLINE u8 GetVerticesPerPrimitive() const { return m_vertices_per_primitive; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VulkanPipeline(VkPipeline pipeline, Layout layout, u8 vertices_per_primitive, RenderPassFlag render_pass_flags);
|
VulkanPipeline(VkPipeline pipeline, Layout layout, u8 vertices_per_primitive, RenderPassFlag render_pass_flags);
|
||||||
|
|
|
@ -459,6 +459,8 @@ void VulkanTexture::OverrideImageLayout(Layout new_layout)
|
||||||
m_layout = new_layout;
|
m_layout = new_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void VulkanTexture::SetDebugName(std::string_view name)
|
void VulkanTexture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
VulkanDevice& dev = VulkanDevice::GetInstance();
|
VulkanDevice& dev = VulkanDevice::GetInstance();
|
||||||
|
@ -466,6 +468,8 @@ void VulkanTexture::SetDebugName(std::string_view name)
|
||||||
Vulkan::SetObjectName(dev.GetVulkanDevice(), m_view, name);
|
Vulkan::SetObjectName(dev.GetVulkanDevice(), m_view, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void VulkanTexture::TransitionToLayout(Layout layout)
|
void VulkanTexture::TransitionToLayout(Layout layout)
|
||||||
{
|
{
|
||||||
TransitionToLayout(VulkanDevice::GetInstance().GetCurrentCommandBuffer(), layout);
|
TransitionToLayout(VulkanDevice::GetInstance().GetCurrentCommandBuffer(), layout);
|
||||||
|
@ -775,11 +779,15 @@ VulkanSampler::~VulkanSampler()
|
||||||
// Cleaned up by main class.
|
// Cleaned up by main class.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void VulkanSampler::SetDebugName(std::string_view name)
|
void VulkanSampler::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_sampler, name);
|
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_sampler, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
VkSampler VulkanDevice::GetSampler(const GPUSampler::Config& config, Error* error)
|
VkSampler VulkanDevice::GetSampler(const GPUSampler::Config& config, Error* error)
|
||||||
{
|
{
|
||||||
const auto it = m_sampler_map.find(config.key);
|
const auto it = m_sampler_map.find(config.key);
|
||||||
|
@ -942,6 +950,8 @@ void VulkanTextureBuffer::Unmap(u32 used_elements)
|
||||||
m_buffer.CommitMemory(size);
|
m_buffer.CommitMemory(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void VulkanTextureBuffer::SetDebugName(std::string_view name)
|
void VulkanTextureBuffer::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
VulkanDevice& dev = VulkanDevice::GetInstance();
|
VulkanDevice& dev = VulkanDevice::GetInstance();
|
||||||
|
@ -950,6 +960,8 @@ void VulkanTextureBuffer::SetDebugName(std::string_view name)
|
||||||
Vulkan::SetObjectName(dev.GetVulkanDevice(), m_buffer_view, name);
|
Vulkan::SetObjectName(dev.GetVulkanDevice(), m_buffer_view, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUTextureBuffer> VulkanDevice::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
std::unique_ptr<GPUTextureBuffer> VulkanDevice::CreateTextureBuffer(GPUTextureBuffer::Format format,
|
||||||
u32 size_in_elements, Error* error)
|
u32 size_in_elements, Error* error)
|
||||||
{
|
{
|
||||||
|
@ -1195,6 +1207,8 @@ void VulkanDownloadTexture::Flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
|
|
||||||
void VulkanDownloadTexture::SetDebugName(std::string_view name)
|
void VulkanDownloadTexture::SetDebugName(std::string_view name)
|
||||||
{
|
{
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
|
@ -1203,6 +1217,8 @@ void VulkanDownloadTexture::SetDebugName(std::string_view name)
|
||||||
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_buffer, name);
|
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_buffer, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<GPUDownloadTexture>
|
std::unique_ptr<GPUDownloadTexture>
|
||||||
VulkanDevice::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format, Error* error /* = nullptr */)
|
VulkanDevice::CreateDownloadTexture(u32 width, u32 height, GPUTexture::Format format, Error* error /* = nullptr */)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,9 @@ public:
|
||||||
void MakeReadyForSampling() override;
|
void MakeReadyForSampling() override;
|
||||||
void GenerateMipmaps() override;
|
void GenerateMipmaps() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
void TransitionToLayout(Layout layout);
|
void TransitionToLayout(Layout layout);
|
||||||
void CommitClear();
|
void CommitClear();
|
||||||
|
@ -120,7 +122,9 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE VkSampler GetSampler() const { return m_sampler; }
|
ALWAYS_INLINE VkSampler GetSampler() const { return m_sampler; }
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VulkanSampler(VkSampler sampler);
|
VulkanSampler(VkSampler sampler);
|
||||||
|
@ -146,7 +150,9 @@ public:
|
||||||
void* Map(u32 required_elements) override;
|
void* Map(u32 required_elements) override;
|
||||||
void Unmap(u32 used_elements) override;
|
void Unmap(u32 used_elements) override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VulkanStreamBuffer m_buffer;
|
VulkanStreamBuffer m_buffer;
|
||||||
|
@ -170,7 +176,9 @@ public:
|
||||||
|
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
|
#ifdef ENABLE_GPU_OBJECT_NAMES
|
||||||
void SetDebugName(std::string_view name) override;
|
void SetDebugName(std::string_view name) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VulkanDownloadTexture(u32 width, u32 height, GPUTexture::Format format, VmaAllocation allocation,
|
VulkanDownloadTexture(u32 width, u32 height, GPUTexture::Format format, VmaAllocation allocation,
|
||||||
|
|
Loading…
Reference in New Issue