mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-03-06 14:27:44 +00:00
GPUDevice: Replace remaining StdStringFromFromFormat() with fmt
This commit is contained in:
parent
c286112966
commit
00ccea84b8
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||||
|
|
||||||
#include "d3d12_builders.h"
|
#include "d3d12_builders.h"
|
||||||
|
@ -341,12 +341,4 @@ void D3D12::SetObjectName(ID3D12Object* object, std::string_view name)
|
||||||
object->SetName(StringUtil::UTF8StringToWideString(name).c_str());
|
object->SetName(StringUtil::UTF8StringToWideString(name).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D12::SetObjectNameFormatted(ID3D12Object* object, const char* format, ...)
|
|
||||||
{
|
|
||||||
std::va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
SetObjectName(object, StringUtil::StdStringFromFormatV(format, ap).c_str());
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -127,13 +127,9 @@ private:
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
void SetObjectName(ID3D12Object* object, std::string_view name);
|
void SetObjectName(ID3D12Object* object, std::string_view name);
|
||||||
void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...);
|
|
||||||
#else
|
#else
|
||||||
static inline void SetObjectName(ID3D12Object* object, std::string_view name)
|
static inline void SetObjectName(ID3D12Object* object, std::string_view name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
static inline void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
} // namespace D3D12
|
} // namespace D3D12
|
||||||
|
|
|
@ -585,24 +585,19 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion)
|
||||||
WaitForFence(res.fence_counter);
|
WaitForFence(res.fence_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D12Device::SubmitCommandList(bool wait_for_completion, const char* reason, ...)
|
void D3D12Device::SubmitCommandList(bool wait_for_completion, const std::string_view reason)
|
||||||
{
|
{
|
||||||
std::va_list ap;
|
WARNING_LOG("Executing command buffer due to '{}'", reason);
|
||||||
va_start(ap, reason);
|
|
||||||
const std::string reason_str(StringUtil::StdStringFromFormatV(reason, ap));
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
WARNING_LOG("Executing command buffer due to '{}'", reason_str);
|
|
||||||
SubmitCommandList(wait_for_completion);
|
SubmitCommandList(wait_for_completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D12Device::SubmitCommandListAndRestartRenderPass(const char* reason)
|
void D3D12Device::SubmitCommandListAndRestartRenderPass(const std::string_view reason)
|
||||||
{
|
{
|
||||||
if (InRenderPass())
|
if (InRenderPass())
|
||||||
EndRenderPass();
|
EndRenderPass();
|
||||||
|
|
||||||
D3D12Pipeline* pl = m_current_pipeline;
|
D3D12Pipeline* pl = m_current_pipeline;
|
||||||
SubmitCommandList(false, "%s", reason);
|
SubmitCommandList(false, reason);
|
||||||
|
|
||||||
SetPipeline(pl);
|
SetPipeline(pl);
|
||||||
BeginRenderPass();
|
BeginRenderPass();
|
||||||
|
@ -895,7 +890,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12::SetObjectNameFormatted(backbuffer.Get(), "Swap Chain Buffer #%u", i);
|
D3D12::SetObjectName(backbuffer.Get(), TinyString::from_format("Swap Chain Buffer #{}", i));
|
||||||
|
|
||||||
D3D12DescriptorHandle rtv;
|
D3D12DescriptorHandle rtv;
|
||||||
if (!m_rtv_heap_manager.Allocate(&rtv))
|
if (!m_rtv_heap_manager.Allocate(&rtv))
|
||||||
|
|
|
@ -176,8 +176,8 @@ public:
|
||||||
|
|
||||||
/// Ends any render pass, executes the command buffer, and invalidates cached state.
|
/// Ends any render pass, executes the command buffer, and invalidates cached state.
|
||||||
void SubmitCommandList(bool wait_for_completion);
|
void SubmitCommandList(bool wait_for_completion);
|
||||||
void SubmitCommandList(bool wait_for_completion, const char* reason, ...);
|
void SubmitCommandList(bool wait_for_completion, const std::string_view reason);
|
||||||
void SubmitCommandListAndRestartRenderPass(const char* reason);
|
void SubmitCommandListAndRestartRenderPass(const std::string_view reason);
|
||||||
|
|
||||||
void UnbindPipeline(D3D12Pipeline* pl);
|
void UnbindPipeline(D3D12Pipeline* pl);
|
||||||
void UnbindTexture(D3D12Texture* tex);
|
void UnbindTexture(D3D12Texture* tex);
|
||||||
|
|
|
@ -415,10 +415,10 @@ bool D3D12Texture::Update(u32 x, u32 y, u32 width, u32 height, const void* data,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT))
|
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||||
{
|
{
|
||||||
D3D12Device::GetInstance().SubmitCommandList(false, "While waiting for %u bytes in texture upload buffer",
|
D3D12Device::GetInstance().SubmitCommandList(
|
||||||
required_size);
|
false, TinyString::from_format("Needs {} bytes in texture upload buffer", required_size));
|
||||||
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||||
{
|
{
|
||||||
ERROR_LOG("Failed to reserve texture upload memory ({} bytes).", required_size);
|
ERROR_LOG("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||||
|
@ -485,10 +485,10 @@ bool D3D12Texture::Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32
|
||||||
if (req_size >= (buffer.GetSize() / 2))
|
if (req_size >= (buffer.GetSize() / 2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!buffer.ReserveMemory(req_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT))
|
if (!buffer.ReserveMemory(req_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||||
{
|
{
|
||||||
dev.SubmitCommandList(false, "While waiting for %u bytes in texture upload buffer", req_size);
|
dev.SubmitCommandList(false, TinyString::from_format("Needs {} bytes in texture upload buffer", req_size));
|
||||||
if (!buffer.ReserveMemory(req_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT))
|
if (!buffer.ReserveMemory(req_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||||
Panic("Failed to reserve texture upload memory");
|
Panic("Failed to reserve texture upload memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -6,10 +6,10 @@
|
||||||
#include "gpu_device.h"
|
#include "gpu_device.h"
|
||||||
#include "vulkan_loader.h"
|
#include "vulkan_loader.h"
|
||||||
|
|
||||||
|
#include "common/small_string.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdarg>
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#if defined(_DEBUG) && !defined(CPU_ARCH_ARM32) && !defined(CPU_ARCH_X86)
|
#if defined(_DEBUG) && !defined(CPU_ARCH_ARM32) && !defined(CPU_ARCH_X86)
|
||||||
|
@ -390,39 +390,19 @@ struct VkObjectTypeMap;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void SetFormattedObjectName(VkDevice device, void* object_handle, VkObjectType object_type,
|
template<typename T>
|
||||||
const char* format, va_list ap)
|
static inline void SetObjectName(VkDevice device, T object_handle, const std::string_view name)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_VULKAN_DEBUG_OBJECTS
|
#ifdef ENABLE_VULKAN_DEBUG_OBJECTS
|
||||||
if (!vkSetDebugUtilsObjectNameEXT)
|
if (!vkSetDebugUtilsObjectNameEXT)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
const std::string str(StringUtil::StdStringFromFormatV(format, ap));
|
const SmallString terminated_name(name);
|
||||||
const VkDebugUtilsObjectNameInfoEXT nameInfo{VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, nullptr, object_type,
|
const VkDebugUtilsObjectNameInfoEXT name_info{
|
||||||
reinterpret_cast<uint64_t>(object_handle), str.c_str()};
|
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, nullptr, VkObjectTypeMap<T>::value,
|
||||||
vkSetDebugUtilsObjectNameEXT(device, &nameInfo);
|
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(static_cast<typename VkObjectTypeMap<T>::type>(object_handle))),
|
||||||
#endif
|
terminated_name.c_str()};
|
||||||
}
|
vkSetDebugUtilsObjectNameEXT(device, &name_info);
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static inline void SetFormattedObjectName(VkDevice device, T object_handle, const char* format, ...)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VULKAN_DEBUG_OBJECTS
|
|
||||||
std::va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
SetFormattedObjectName(device, reinterpret_cast<void*>((typename VkObjectTypeMap<T>::type)object_handle),
|
|
||||||
VkObjectTypeMap<T>::value, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static inline void SetObjectName(VkDevice device, T object_handle, std::string_view sv)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_VULKAN_DEBUG_OBJECTS
|
|
||||||
SetFormattedObjectName(device, object_handle, "%.*s", static_cast<int>(sv.length()), sv.data());
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -1567,24 +1567,19 @@ void VulkanDevice::SubmitCommandBuffer(bool wait_for_completion)
|
||||||
InvalidateCachedState();
|
InvalidateCachedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanDevice::SubmitCommandBuffer(bool wait_for_completion, const char* reason, ...)
|
void VulkanDevice::SubmitCommandBuffer(bool wait_for_completion, const std::string_view reason)
|
||||||
{
|
{
|
||||||
std::va_list ap;
|
WARNING_LOG("Executing command buffer due to '{}'", reason);
|
||||||
va_start(ap, reason);
|
|
||||||
const std::string reason_str(StringUtil::StdStringFromFormatV(reason, ap));
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
WARNING_LOG("Executing command buffer due to '{}'", reason_str);
|
|
||||||
SubmitCommandBuffer(wait_for_completion);
|
SubmitCommandBuffer(wait_for_completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanDevice::SubmitCommandBufferAndRestartRenderPass(const char* reason)
|
void VulkanDevice::SubmitCommandBufferAndRestartRenderPass(const std::string_view reason)
|
||||||
{
|
{
|
||||||
if (InRenderPass())
|
if (InRenderPass())
|
||||||
EndRenderPass();
|
EndRenderPass();
|
||||||
|
|
||||||
VulkanPipeline* pl = m_current_pipeline;
|
VulkanPipeline* pl = m_current_pipeline;
|
||||||
SubmitCommandBuffer(false, "%s", reason);
|
SubmitCommandBuffer(false, reason);
|
||||||
|
|
||||||
SetPipeline(pl);
|
SetPipeline(pl);
|
||||||
BeginRenderPass();
|
BeginRenderPass();
|
||||||
|
|
|
@ -219,8 +219,8 @@ public:
|
||||||
|
|
||||||
/// Ends any render pass, executes the command buffer, and invalidates cached state.
|
/// Ends any render pass, executes the command buffer, and invalidates cached state.
|
||||||
void SubmitCommandBuffer(bool wait_for_completion);
|
void SubmitCommandBuffer(bool wait_for_completion);
|
||||||
void SubmitCommandBuffer(bool wait_for_completion, const char* reason, ...);
|
void SubmitCommandBuffer(bool wait_for_completion, const std::string_view reason);
|
||||||
void SubmitCommandBufferAndRestartRenderPass(const char* reason);
|
void SubmitCommandBufferAndRestartRenderPass(const std::string_view reason);
|
||||||
|
|
||||||
void UnbindFramebuffer(VulkanTexture* tex);
|
void UnbindFramebuffer(VulkanTexture* tex);
|
||||||
void UnbindPipeline(VulkanPipeline* pl);
|
void UnbindPipeline(VulkanPipeline* pl);
|
||||||
|
|
|
@ -329,10 +329,10 @@ bool VulkanTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!sbuffer.ReserveMemory(required_size, dev.GetBufferCopyOffsetAlignment()))
|
if (!sbuffer.ReserveMemory(required_size, dev.GetBufferCopyOffsetAlignment())) [[unlikely]]
|
||||||
{
|
{
|
||||||
dev.SubmitCommandBuffer(false, "While waiting for %u bytes in texture upload buffer", required_size);
|
dev.SubmitCommandBuffer(false, TinyString::from_format("Needs {} bytes in texture upload buffer", required_size));
|
||||||
if (!sbuffer.ReserveMemory(required_size, dev.GetBufferCopyOffsetAlignment()))
|
if (!sbuffer.ReserveMemory(required_size, dev.GetBufferCopyOffsetAlignment())) [[unlikely]]
|
||||||
{
|
{
|
||||||
ERROR_LOG("Failed to reserve texture upload memory ({} bytes).", required_size);
|
ERROR_LOG("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||||
return false;
|
return false;
|
||||||
|
@ -387,10 +387,10 @@ bool VulkanTexture::Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u3
|
||||||
if (req_size >= (buffer.GetCurrentSize() / 2))
|
if (req_size >= (buffer.GetCurrentSize() / 2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!buffer.ReserveMemory(req_size, dev.GetBufferCopyOffsetAlignment()))
|
if (!buffer.ReserveMemory(req_size, dev.GetBufferCopyOffsetAlignment())) [[unlikely]]
|
||||||
{
|
{
|
||||||
dev.SubmitCommandBuffer(false, "While waiting for %u bytes in texture upload buffer", req_size);
|
dev.SubmitCommandBuffer(false, TinyString::from_format("Needs {} bytes in texture upload buffer", req_size));
|
||||||
if (!buffer.ReserveMemory(req_size, dev.GetBufferCopyOffsetAlignment()))
|
if (!buffer.ReserveMemory(req_size, dev.GetBufferCopyOffsetAlignment())) [[unlikely]]
|
||||||
Panic("Failed to reserve texture upload memory");
|
Panic("Failed to reserve texture upload memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue