VideoBackends/D3D12: Include HRESULT in error messages
This commit is contained in:
parent
23cdb5c576
commit
1b32e6dae2
|
@ -42,7 +42,7 @@ std::vector<BBoxType> D3D12BoundingBox::Read(u32 index, u32 length)
|
||||||
static constexpr D3D12_RANGE read_range = {0, BUFFER_SIZE};
|
static constexpr D3D12_RANGE read_range = {0, BUFFER_SIZE};
|
||||||
void* mapped_pointer;
|
void* mapped_pointer;
|
||||||
HRESULT hr = m_readback_buffer->Map(0, &read_range, &mapped_pointer);
|
HRESULT hr = m_readback_buffer->Map(0, &read_range, &mapped_pointer);
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Map bounding box CPU buffer failed");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Map bounding box CPU buffer failed: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return values;
|
return values;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ bool D3D12BoundingBox::CreateBuffers()
|
||||||
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
||||||
&gpu_heap_properties, D3D12_HEAP_FLAG_NONE, &buffer_desc,
|
&gpu_heap_properties, D3D12_HEAP_FLAG_NONE, &buffer_desc,
|
||||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, IID_PPV_ARGS(&m_gpu_buffer));
|
D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, IID_PPV_ARGS(&m_gpu_buffer));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating bounding box GPU buffer failed");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating bounding box GPU buffer failed: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr) || !g_dx_context->GetDescriptorHeapManager().Allocate(&m_gpu_descriptor))
|
if (FAILED(hr) || !g_dx_context->GetDescriptorHeapManager().Allocate(&m_gpu_descriptor))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ bool D3D12BoundingBox::CreateBuffers()
|
||||||
hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
||||||
&cpu_heap_properties, D3D12_HEAP_FLAG_NONE, &buffer_desc, D3D12_RESOURCE_STATE_COPY_DEST,
|
&cpu_heap_properties, D3D12_HEAP_FLAG_NONE, &buffer_desc, D3D12_RESOURCE_STATE_COPY_DEST,
|
||||||
nullptr, IID_PPV_ARGS(&m_readback_buffer));
|
nullptr, IID_PPV_ARGS(&m_readback_buffer));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating bounding box CPU buffer failed");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating bounding box CPU buffer failed: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ bool PerfQuery::Initialize()
|
||||||
{
|
{
|
||||||
constexpr D3D12_QUERY_HEAP_DESC desc = {D3D12_QUERY_HEAP_TYPE_OCCLUSION, PERF_QUERY_BUFFER_SIZE};
|
constexpr D3D12_QUERY_HEAP_DESC desc = {D3D12_QUERY_HEAP_TYPE_OCCLUSION, PERF_QUERY_BUFFER_SIZE};
|
||||||
HRESULT hr = g_dx_context->GetDevice()->CreateQueryHeap(&desc, IID_PPV_ARGS(&m_query_heap));
|
HRESULT hr = g_dx_context->GetDevice()->CreateQueryHeap(&desc, IID_PPV_ARGS(&m_query_heap));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create query heap");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create query heap: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ bool PerfQuery::Initialize()
|
||||||
hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
||||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST,
|
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST,
|
||||||
nullptr, IID_PPV_ARGS(&m_query_readback_buffer));
|
nullptr, IID_PPV_ARGS(&m_query_readback_buffer));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create query buffer");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create query buffer: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ void PerfQuery::AccumulateQueriesFromBuffer(u32 query_count)
|
||||||
(m_query_readback_pos + query_count) * sizeof(PerfQueryDataType)};
|
(m_query_readback_pos + query_count) * sizeof(PerfQueryDataType)};
|
||||||
u8* mapped_ptr;
|
u8* mapped_ptr;
|
||||||
HRESULT hr = m_query_readback_buffer->Map(0, &read_range, reinterpret_cast<void**>(&mapped_ptr));
|
HRESULT hr = m_query_readback_buffer->Map(0, &read_range, reinterpret_cast<void**>(&mapped_ptr));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map query readback buffer");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map query readback buffer: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,14 @@ bool StreamBuffer::AllocateBuffer(u32 size)
|
||||||
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
||||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ,
|
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ,
|
||||||
nullptr, IID_PPV_ARGS(&m_buffer));
|
nullptr, IID_PPV_ARGS(&m_buffer));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to allocate buffer of size {}", size);
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to allocate buffer of size {}: {}", size,
|
||||||
|
DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
static const D3D12_RANGE read_range = {};
|
static const D3D12_RANGE read_range = {};
|
||||||
hr = m_buffer->Map(0, &read_range, reinterpret_cast<void**>(&m_host_pointer));
|
hr = m_buffer->Map(0, &read_range, reinterpret_cast<void**>(&m_host_pointer));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map buffer of size {}", size);
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map buffer of size {}: {}", size, DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ bool SwapChain::CreateSwapChainBuffers()
|
||||||
{
|
{
|
||||||
ComPtr<ID3D12Resource> resource;
|
ComPtr<ID3D12Resource> resource;
|
||||||
HRESULT hr = m_swap_chain->GetBuffer(i, IID_PPV_ARGS(&resource));
|
HRESULT hr = m_swap_chain->GetBuffer(i, IID_PPV_ARGS(&resource));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to get swap chain buffer {}", i);
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to get swap chain buffer {}: {}", i, DX12HRWrap(hr));
|
||||||
|
|
||||||
BufferResources buffer;
|
BufferResources buffer;
|
||||||
buffer.texture = DXTexture::CreateAdopted(resource.Get());
|
buffer.texture = DXTexture::CreateAdopted(resource.Get());
|
||||||
|
|
|
@ -152,7 +152,7 @@ bool DXContext::CreateDevice(u32 adapter_index, bool enable_debug_layer)
|
||||||
HRESULT hr = m_dxgi_factory->EnumAdapters(adapter_index, &adapter);
|
HRESULT hr = m_dxgi_factory->EnumAdapters(adapter_index, &adapter);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(VIDEO, "Adapter {} not found, using default", adapter_index);
|
ERROR_LOG_FMT(VIDEO, "Adapter {} not found, using default: {}", adapter_index, DX12HRWrap(hr));
|
||||||
adapter = nullptr;
|
adapter = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,14 +166,14 @@ bool DXContext::CreateDevice(u32 adapter_index, bool enable_debug_layer)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(VIDEO, "Debug layer requested but not available.");
|
ERROR_LOG_FMT(VIDEO, "Debug layer requested but not available: {}", DX12HRWrap(hr));
|
||||||
enable_debug_layer = false;
|
enable_debug_layer = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the actual device.
|
// Create the actual device.
|
||||||
hr = s_d3d12_create_device(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device));
|
hr = s_d3d12_create_device(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create D3D12 device");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create D3D12 device: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ bool DXContext::CreateCommandQueue()
|
||||||
D3D12_COMMAND_QUEUE_PRIORITY_NORMAL,
|
D3D12_COMMAND_QUEUE_PRIORITY_NORMAL,
|
||||||
D3D12_COMMAND_QUEUE_FLAG_NONE};
|
D3D12_COMMAND_QUEUE_FLAG_NONE};
|
||||||
HRESULT hr = m_device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&m_command_queue));
|
HRESULT hr = m_device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&m_command_queue));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command queue");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command queue: {}", DX12HRWrap(hr));
|
||||||
return SUCCEEDED(hr);
|
return SUCCEEDED(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ bool DXContext::CreateFence()
|
||||||
{
|
{
|
||||||
HRESULT hr =
|
HRESULT hr =
|
||||||
m_device->CreateFence(m_completed_fence_value, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_fence));
|
m_device->CreateFence(m_completed_fence_value, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_fence));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create fence");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create fence: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -303,14 +303,15 @@ static bool BuildRootSignature(ID3D12Device* device, ID3D12RootSignature** sig_p
|
||||||
&root_signature_blob, &root_signature_error_blob);
|
&root_signature_blob, &root_signature_error_blob);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
PanicAlertFmt("Failed to serialize root signature: {}",
|
PanicAlertFmt("Failed to serialize root signature: {}\n{}",
|
||||||
static_cast<const char*>(root_signature_error_blob->GetBufferPointer()));
|
static_cast<const char*>(root_signature_error_blob->GetBufferPointer()),
|
||||||
|
DX12HRWrap(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = device->CreateRootSignature(0, root_signature_blob->GetBufferPointer(),
|
hr = device->CreateRootSignature(0, root_signature_blob->GetBufferPointer(),
|
||||||
root_signature_blob->GetBufferSize(), IID_PPV_ARGS(sig_ptr));
|
root_signature_blob->GetBufferSize(), IID_PPV_ARGS(sig_ptr));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create root signature");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create root signature: {}", DX12HRWrap(hr));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,13 +418,13 @@ bool DXContext::CreateCommandLists()
|
||||||
CommandListResources& res = m_command_lists[i];
|
CommandListResources& res = m_command_lists[i];
|
||||||
HRESULT hr = m_device->CreateCommandAllocator(
|
HRESULT hr = m_device->CreateCommandAllocator(
|
||||||
D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(res.command_allocator.GetAddressOf()));
|
D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(res.command_allocator.GetAddressOf()));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command allocator");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command allocator: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
hr = m_device->CreateCommandList(1, D3D12_COMMAND_LIST_TYPE_DIRECT, res.command_allocator.Get(),
|
hr = m_device->CreateCommandList(1, D3D12_COMMAND_LIST_TYPE_DIRECT, res.command_allocator.Get(),
|
||||||
nullptr, IID_PPV_ARGS(res.command_list.GetAddressOf()));
|
nullptr, IID_PPV_ARGS(res.command_list.GetAddressOf()));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command list");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command list: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -431,7 +432,7 @@ bool DXContext::CreateCommandLists()
|
||||||
|
|
||||||
// Close the command list, since the first thing we do is reset them.
|
// Close the command list, since the first thing we do is reset them.
|
||||||
hr = res.command_list->Close();
|
hr = res.command_list->Close();
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Closing new command list failed");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Closing new command list failed: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -473,7 +474,7 @@ void DXContext::ExecuteCommandList(bool wait_for_completion)
|
||||||
|
|
||||||
// Close and queue command list.
|
// Close and queue command list.
|
||||||
HRESULT hr = res.command_list->Close();
|
HRESULT hr = res.command_list->Close();
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to close command list");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to close command list: {}", DX12HRWrap(hr));
|
||||||
const std::array<ID3D12CommandList*, 1> execute_lists{res.command_list.Get()};
|
const std::array<ID3D12CommandList*, 1> execute_lists{res.command_list.Get()};
|
||||||
m_command_queue->ExecuteCommandLists(static_cast<UINT>(execute_lists.size()),
|
m_command_queue->ExecuteCommandLists(static_cast<UINT>(execute_lists.size()),
|
||||||
execute_lists.data());
|
execute_lists.data());
|
||||||
|
@ -481,7 +482,7 @@ void DXContext::ExecuteCommandList(bool wait_for_completion)
|
||||||
// Update fence when GPU has completed.
|
// Update fence when GPU has completed.
|
||||||
hr = m_command_queue->Signal(m_fence.Get(), m_current_fence_value);
|
hr = m_command_queue->Signal(m_fence.Get(), m_current_fence_value);
|
||||||
|
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to signal fence");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to signal fence: {}", DX12HRWrap(hr));
|
||||||
|
|
||||||
MoveToNextCommandList();
|
MoveToNextCommandList();
|
||||||
if (wait_for_completion)
|
if (wait_for_completion)
|
||||||
|
@ -534,7 +535,7 @@ void DXContext::WaitForFence(u64 fence)
|
||||||
{
|
{
|
||||||
// Fall back to event.
|
// Fall back to event.
|
||||||
HRESULT hr = m_fence->SetEventOnCompletion(fence, m_fence_event);
|
HRESULT hr = m_fence->SetEventOnCompletion(fence, m_fence_event);
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to set fence event on completion");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to set fence event on completion: {}", DX12HRWrap(hr));
|
||||||
WaitForSingleObject(m_fence_event, INFINITE);
|
WaitForSingleObject(m_fence_event, INFINITE);
|
||||||
m_completed_fence_value = m_fence->GetCompletedValue();
|
m_completed_fence_value = m_fence->GetCompletedValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
|
|
||||||
#include "VideoBackends/D3D12/Common.h"
|
#include "VideoBackends/D3D12/Common.h"
|
||||||
#include "VideoBackends/D3D12/D3D12StreamBuffer.h"
|
#include "VideoBackends/D3D12/D3D12StreamBuffer.h"
|
||||||
#include "VideoBackends/D3D12/DescriptorAllocator.h"
|
#include "VideoBackends/D3D12/DescriptorAllocator.h"
|
||||||
|
@ -187,4 +189,34 @@ private:
|
||||||
|
|
||||||
extern std::unique_ptr<DXContext> g_dx_context;
|
extern std::unique_ptr<DXContext> g_dx_context;
|
||||||
|
|
||||||
|
// Wrapper for HRESULT to be used with fmt. Note that we can't create a fmt::formatter directly
|
||||||
|
// for HRESULT as HRESULT is simply a typedef on long and not a distinct type.
|
||||||
|
// Unlike the version in Common, this variant also knows to call GetDeviceRemovedReason if needed.
|
||||||
|
struct DX12HRWrap
|
||||||
|
{
|
||||||
|
constexpr explicit DX12HRWrap(HRESULT hr) : m_hr(hr) {}
|
||||||
|
const HRESULT m_hr;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace DX12
|
} // namespace DX12
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct fmt::formatter<DX12::DX12HRWrap>
|
||||||
|
{
|
||||||
|
constexpr auto parse(fmt::format_parse_context& ctx) { return ctx.begin(); }
|
||||||
|
template <typename FormatContext>
|
||||||
|
auto format(const DX12::DX12HRWrap& hr, FormatContext& ctx)
|
||||||
|
{
|
||||||
|
if (hr.m_hr == DXGI_ERROR_DEVICE_REMOVED && DX12::g_dx_context != nullptr &&
|
||||||
|
DX12::g_dx_context->GetDevice() != nullptr)
|
||||||
|
{
|
||||||
|
return fmt::format_to(
|
||||||
|
ctx.out(), "{}\nDevice removal reason: {}", Common::HRWrap(hr.m_hr),
|
||||||
|
Common::HRWrap(DX12::g_dx_context->GetDevice()->GetDeviceRemovedReason()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return fmt::format_to(ctx.out(), "{}", Common::HRWrap(hr.m_hr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -210,8 +210,8 @@ std::unique_ptr<DXPipeline> DXPipeline::Create(const AbstractPipelineConfig& con
|
||||||
HRESULT hr = g_dx_context->GetDevice()->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso));
|
HRESULT hr = g_dx_context->GetDevice()->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
WARN_LOG_FMT(VIDEO, "CreateGraphicsPipelineState() {}failed with HRESULT {:08X}",
|
WARN_LOG_FMT(VIDEO, "CreateGraphicsPipelineState() {}failed: {}",
|
||||||
cache_data ? "with cache data " : "", hr);
|
cache_data ? "with cache data " : "", DX12HRWrap(hr));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ AbstractPipeline::CacheData DXPipeline::GetCacheData() const
|
||||||
HRESULT hr = m_pipeline->GetCachedBlob(&blob);
|
HRESULT hr = m_pipeline->GetCachedBlob(&blob);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
WARN_LOG_FMT(VIDEO, "ID3D12Pipeline::GetCachedBlob() failed with HRESULT {:08X}", hr);
|
WARN_LOG_FMT(VIDEO, "ID3D12Pipeline::GetCachedBlob() failed: {}", DX12HRWrap(hr));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ bool DXShader::CreateComputePipeline()
|
||||||
|
|
||||||
HRESULT hr = g_dx_context->GetDevice()->CreateComputePipelineState(
|
HRESULT hr = g_dx_context->GetDevice()->CreateComputePipelineState(
|
||||||
&desc, IID_PPV_ARGS(&m_compute_pipeline));
|
&desc, IID_PPV_ARGS(&m_compute_pipeline));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating compute pipeline failed");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating compute pipeline failed: {}", DX12HRWrap(hr));
|
||||||
|
|
||||||
if (m_compute_pipeline && !m_name.empty())
|
if (m_compute_pipeline && !m_name.empty())
|
||||||
m_compute_pipeline->SetName(m_name.c_str());
|
m_compute_pipeline->SetName(m_name.c_str());
|
||||||
|
|
|
@ -39,7 +39,7 @@ static ComPtr<ID3D12Resource> CreateTextureUploadBuffer(u32 buffer_size)
|
||||||
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
||||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
&heap_properties, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
||||||
IID_PPV_ARGS(&resource));
|
IID_PPV_ARGS(&resource));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create texture upload buffer");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create texture upload buffer: {}", DX12HRWrap(hr));
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ std::unique_ptr<DXTexture> DXTexture::Create(const TextureConfig& config, std::s
|
||||||
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
|
||||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, resource_state,
|
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, resource_state,
|
||||||
config.IsRenderTarget() ? &optimized_clear_value : nullptr, IID_PPV_ARGS(&resource));
|
config.IsRenderTarget() ? &optimized_clear_value : nullptr, IID_PPV_ARGS(&resource));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create D3D12 texture resource");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create D3D12 texture resource: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -230,9 +230,15 @@ void DXTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8*
|
||||||
{
|
{
|
||||||
const D3D12_RANGE read_range = {0, 0};
|
const D3D12_RANGE read_range = {0, 0};
|
||||||
staging_buffer = CreateTextureUploadBuffer(upload_size);
|
staging_buffer = CreateTextureUploadBuffer(upload_size);
|
||||||
if (!staging_buffer || FAILED(staging_buffer->Map(0, &read_range, &upload_buffer_ptr)))
|
if (!staging_buffer)
|
||||||
{
|
{
|
||||||
PanicAlertFmt("Failed to allocate/map temporary texture upload buffer");
|
PanicAlertFmt("Failed to allocate temporary texture upload buffer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HRESULT hr = staging_buffer->Map(0, &read_range, &upload_buffer_ptr);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
PanicAlertFmt("Failed to map temporary texture upload buffer: {}", DX12HRWrap(hr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +604,7 @@ bool DXStagingTexture::Map()
|
||||||
|
|
||||||
const D3D12_RANGE read_range = {0u, m_type == StagingTextureType::Upload ? 0u : m_buffer_size};
|
const D3D12_RANGE read_range = {0u, m_type == StagingTextureType::Upload ? 0u : m_buffer_size};
|
||||||
HRESULT hr = m_resource->Map(0, &read_range, reinterpret_cast<void**>(&m_map_pointer));
|
HRESULT hr = m_resource->Map(0, &read_range, reinterpret_cast<void**>(&m_map_pointer));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Map resource failed");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Map resource failed: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -663,7 +669,7 @@ std::unique_ptr<DXStagingTexture> DXStagingTexture::Create(StagingTextureType ty
|
||||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &desc,
|
&heap_properties, D3D12_HEAP_FLAG_NONE, &desc,
|
||||||
is_upload ? D3D12_RESOURCE_STATE_GENERIC_READ : D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
is_upload ? D3D12_RESOURCE_STATE_GENERIC_READ : D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
|
||||||
IID_PPV_ARGS(&resource));
|
IID_PPV_ARGS(&resource));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create staging texture resource");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create staging texture resource: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ bool DescriptorAllocator::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYP
|
||||||
const D3D12_DESCRIPTOR_HEAP_DESC desc = {type, static_cast<UINT>(num_descriptors),
|
const D3D12_DESCRIPTOR_HEAP_DESC desc = {type, static_cast<UINT>(num_descriptors),
|
||||||
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE};
|
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE};
|
||||||
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
|
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating descriptor heap for linear allocator failed");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating descriptor heap for linear allocator failed: {}",
|
||||||
|
DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ bool DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_T
|
||||||
D3D12_DESCRIPTOR_HEAP_FLAG_NONE};
|
D3D12_DESCRIPTOR_HEAP_FLAG_NONE};
|
||||||
|
|
||||||
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
|
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create descriptor heap");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create descriptor heap: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ bool SamplerHeapManager::Create(ID3D12Device* device, u32 num_descriptors)
|
||||||
{
|
{
|
||||||
const D3D12_DESCRIPTOR_HEAP_DESC desc = {D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, num_descriptors};
|
const D3D12_DESCRIPTOR_HEAP_DESC desc = {D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, num_descriptors};
|
||||||
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
|
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
|
||||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create sampler descriptor heap");
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create sampler descriptor heap: {}", DX12HRWrap(hr));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue