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)
|
||||
|
||||
#include "d3d12_builders.h"
|
||||
|
@ -341,12 +341,4 @@ void D3D12::SetObjectName(ID3D12Object* object, std::string_view name)
|
|||
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
|
||||
|
|
|
@ -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)
|
||||
|
||||
#pragma once
|
||||
|
@ -127,13 +127,9 @@ private:
|
|||
|
||||
#ifdef _DEBUG
|
||||
void SetObjectName(ID3D12Object* object, std::string_view name);
|
||||
void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...);
|
||||
#else
|
||||
static inline void SetObjectName(ID3D12Object* object, std::string_view name)
|
||||
{
|
||||
}
|
||||
static inline void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
} // namespace D3D12
|
||||
|
|
|
@ -585,24 +585,19 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion)
|
|||
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;
|
||||
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);
|
||||
WARNING_LOG("Executing command buffer due to '{}'", reason);
|
||||
SubmitCommandList(wait_for_completion);
|
||||
}
|
||||
|
||||
void D3D12Device::SubmitCommandListAndRestartRenderPass(const char* reason)
|
||||
void D3D12Device::SubmitCommandListAndRestartRenderPass(const std::string_view reason)
|
||||
{
|
||||
if (InRenderPass())
|
||||
EndRenderPass();
|
||||
|
||||
D3D12Pipeline* pl = m_current_pipeline;
|
||||
SubmitCommandList(false, "%s", reason);
|
||||
SubmitCommandList(false, reason);
|
||||
|
||||
SetPipeline(pl);
|
||||
BeginRenderPass();
|
||||
|
@ -895,7 +890,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
|||
return false;
|
||||
}
|
||||
|
||||
D3D12::SetObjectNameFormatted(backbuffer.Get(), "Swap Chain Buffer #%u", i);
|
||||
D3D12::SetObjectName(backbuffer.Get(), TinyString::from_format("Swap Chain Buffer #{}", i));
|
||||
|
||||
D3D12DescriptorHandle 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.
|
||||
void SubmitCommandList(bool wait_for_completion);
|
||||
void SubmitCommandList(bool wait_for_completion, const char* reason, ...);
|
||||
void SubmitCommandListAndRestartRenderPass(const char* reason);
|
||||
void SubmitCommandList(bool wait_for_completion, const std::string_view reason);
|
||||
void SubmitCommandListAndRestartRenderPass(const std::string_view reason);
|
||||
|
||||
void UnbindPipeline(D3D12Pipeline* pl);
|
||||
void UnbindTexture(D3D12Texture* tex);
|
||||
|
|
|
@ -415,10 +415,10 @@ bool D3D12Texture::Update(u32 x, u32 y, u32 width, u32 height, const void* data,
|
|||
}
|
||||
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",
|
||||
required_size);
|
||||
D3D12Device::GetInstance().SubmitCommandList(
|
||||
false, TinyString::from_format("Needs {} bytes in texture upload buffer", required_size));
|
||||
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||
{
|
||||
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))
|
||||
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);
|
||||
if (!buffer.ReserveMemory(req_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT))
|
||||
dev.SubmitCommandList(false, TinyString::from_format("Needs {} bytes in texture upload buffer", req_size));
|
||||
if (!buffer.ReserveMemory(req_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||
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)
|
||||
|
||||
#pragma once
|
||||
|
@ -6,10 +6,10 @@
|
|||
#include "gpu_device.h"
|
||||
#include "vulkan_loader.h"
|
||||
|
||||
#include "common/small_string.h"
|
||||
#include "common/string_util.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdarg>
|
||||
#include <string_view>
|
||||
|
||||
#if defined(_DEBUG) && !defined(CPU_ARCH_ARM32) && !defined(CPU_ARCH_X86)
|
||||
|
@ -390,39 +390,19 @@ struct VkObjectTypeMap;
|
|||
|
||||
#endif
|
||||
|
||||
static inline void SetFormattedObjectName(VkDevice device, void* object_handle, VkObjectType object_type,
|
||||
const char* format, va_list ap)
|
||||
template<typename T>
|
||||
static inline void SetObjectName(VkDevice device, T object_handle, const std::string_view name)
|
||||
{
|
||||
#ifdef ENABLE_VULKAN_DEBUG_OBJECTS
|
||||
if (!vkSetDebugUtilsObjectNameEXT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string str(StringUtil::StdStringFromFormatV(format, ap));
|
||||
const VkDebugUtilsObjectNameInfoEXT nameInfo{VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, nullptr, object_type,
|
||||
reinterpret_cast<uint64_t>(object_handle), str.c_str()};
|
||||
vkSetDebugUtilsObjectNameEXT(device, &nameInfo);
|
||||
#endif
|
||||
}
|
||||
|
||||
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());
|
||||
const SmallString terminated_name(name);
|
||||
const VkDebugUtilsObjectNameInfoEXT name_info{
|
||||
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, nullptr, VkObjectTypeMap<T>::value,
|
||||
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(static_cast<typename VkObjectTypeMap<T>::type>(object_handle))),
|
||||
terminated_name.c_str()};
|
||||
vkSetDebugUtilsObjectNameEXT(device, &name_info);
|
||||
#endif
|
||||
}
|
||||
} // namespace Vulkan
|
||||
|
|
|
@ -1567,24 +1567,19 @@ void VulkanDevice::SubmitCommandBuffer(bool wait_for_completion)
|
|||
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;
|
||||
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);
|
||||
WARNING_LOG("Executing command buffer due to '{}'", reason);
|
||||
SubmitCommandBuffer(wait_for_completion);
|
||||
}
|
||||
|
||||
void VulkanDevice::SubmitCommandBufferAndRestartRenderPass(const char* reason)
|
||||
void VulkanDevice::SubmitCommandBufferAndRestartRenderPass(const std::string_view reason)
|
||||
{
|
||||
if (InRenderPass())
|
||||
EndRenderPass();
|
||||
|
||||
VulkanPipeline* pl = m_current_pipeline;
|
||||
SubmitCommandBuffer(false, "%s", reason);
|
||||
SubmitCommandBuffer(false, reason);
|
||||
|
||||
SetPipeline(pl);
|
||||
BeginRenderPass();
|
||||
|
|
|
@ -219,8 +219,8 @@ public:
|
|||
|
||||
/// Ends any render pass, executes the command buffer, and invalidates cached state.
|
||||
void SubmitCommandBuffer(bool wait_for_completion);
|
||||
void SubmitCommandBuffer(bool wait_for_completion, const char* reason, ...);
|
||||
void SubmitCommandBufferAndRestartRenderPass(const char* reason);
|
||||
void SubmitCommandBuffer(bool wait_for_completion, const std::string_view reason);
|
||||
void SubmitCommandBufferAndRestartRenderPass(const std::string_view reason);
|
||||
|
||||
void UnbindFramebuffer(VulkanTexture* tex);
|
||||
void UnbindPipeline(VulkanPipeline* pl);
|
||||
|
|
|
@ -329,10 +329,10 @@ bool VulkanTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data
|
|||
}
|
||||
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);
|
||||
if (!sbuffer.ReserveMemory(required_size, dev.GetBufferCopyOffsetAlignment()))
|
||||
dev.SubmitCommandBuffer(false, TinyString::from_format("Needs {} bytes in texture upload buffer", required_size));
|
||||
if (!sbuffer.ReserveMemory(required_size, dev.GetBufferCopyOffsetAlignment())) [[unlikely]]
|
||||
{
|
||||
ERROR_LOG("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||
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))
|
||||
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);
|
||||
if (!buffer.ReserveMemory(req_size, dev.GetBufferCopyOffsetAlignment()))
|
||||
dev.SubmitCommandBuffer(false, TinyString::from_format("Needs {} bytes in texture upload buffer", req_size));
|
||||
if (!buffer.ReserveMemory(req_size, dev.GetBufferCopyOffsetAlignment())) [[unlikely]]
|
||||
Panic("Failed to reserve texture upload memory");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue