@@ -788,6 +788,8 @@ void GPUDevice::RenderEnd()
|
||||
void GPUDevice::OnCrash()
|
||||
{
|
||||
DumpResourcesToLog();
|
||||
|
||||
LOG(Info, "IsRendering: {}, VSync: {}, Resources: {}", IsRendering(), WasVSyncUsed(), _resources.Count());
|
||||
}
|
||||
|
||||
GPUTasksContext* GPUDevice::CreateTasksContext()
|
||||
|
||||
@@ -107,9 +107,17 @@ bool GPUBufferDX11::OnInit()
|
||||
data.SysMemPitch = bufferDesc.ByteWidth;
|
||||
data.SysMemSlicePitch = 0;
|
||||
}
|
||||
VALIDATE_DIRECTX_CALL(_device->GetDevice()->CreateBuffer(&bufferDesc, _desc.InitData ? &data : nullptr, &_resource));
|
||||
if (!_resource)
|
||||
HRESULT result = _device->GetDevice()->CreateBuffer(&bufferDesc, _desc.InitData ? &data : nullptr, &_resource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
LOG(Error, "ID3D11Device::CreateBuffer failed");
|
||||
LOG_STR(Error, _desc.ToString());
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
LOG_STR(Error, GetName());
|
||||
#endif
|
||||
RenderToolsDX::LogD3DResult(result, __FILE__, __LINE__, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set state
|
||||
DX_SET_DEBUG_NAME(_resource, GetName());
|
||||
|
||||
@@ -87,8 +87,16 @@ bool GPUTextureDX11::OnInit()
|
||||
result = device->CreateTexture2D(&textureDesc, nullptr, &texture);
|
||||
_resource = texture;
|
||||
}
|
||||
LOG_DIRECTX_RESULT_WITH_RETURN(result, true);
|
||||
ASSERT(_resource != nullptr);
|
||||
if (FAILED(result))
|
||||
{
|
||||
LOG(Error, "ID3D11Device::CreateTexture2D failed");
|
||||
LOG_STR(Error, _desc.ToString());
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
LOG_STR(Error, GetName());
|
||||
#endif
|
||||
RenderToolsDX::LogD3DResult(result, __FILE__, __LINE__);
|
||||
return true;
|
||||
}
|
||||
DX_SET_DEBUG_NAME(_resource, GetName());
|
||||
|
||||
// Update memory usage
|
||||
|
||||
@@ -133,7 +133,16 @@ bool GPUBufferDX12::OnInit()
|
||||
ID3D12Resource* resource;
|
||||
D3D12_RESOURCE_STATES initialState = D3D12_RESOURCE_STATE_COMMON;
|
||||
HRESULT result = _device->Allocator->CreateResource(&allocationDesc, &resourceDesc, initialState, nullptr, &_allocation, IID_PPV_ARGS(&resource));
|
||||
LOG_DIRECTX_RESULT_WITH_RETURN(result, true);
|
||||
if (FAILED(result))
|
||||
{
|
||||
LOG(Error, "CreatePlacedResource failed");
|
||||
LOG_STR(Error, _desc.ToString());
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
LOG_STR(Error, GetName());
|
||||
#endif
|
||||
RenderToolsDX::LogD3DResult(result, __FILE__, __LINE__);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set state
|
||||
initResource(resource, initialState, 1);
|
||||
|
||||
@@ -82,7 +82,16 @@ bool GPUTextureDX12::OnInit()
|
||||
resourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||
allocationDesc.HeapType = D3D12_HEAP_TYPE_READBACK;
|
||||
HRESULT result = _device->Allocator->CreateResource(&allocationDesc, &resourceDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, &_allocation, IID_PPV_ARGS(&resource));
|
||||
LOG_DIRECTX_RESULT_WITH_RETURN(result, true);
|
||||
if (FAILED(result))
|
||||
{
|
||||
LOG(Error, "CreatePlacedResource failed");
|
||||
LOG_STR(Error, _desc.ToString());
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
LOG_STR(Error, GetName());
|
||||
#endif
|
||||
RenderToolsDX::LogD3DResult(result, __FILE__, __LINE__);
|
||||
return true;
|
||||
}
|
||||
initResource(resource, D3D12_RESOURCE_STATE_COPY_DEST, 1);
|
||||
DX_SET_DEBUG_NAME(_resource, GetName());
|
||||
_memoryUsage = totalSize;
|
||||
@@ -146,7 +155,16 @@ bool GPUTextureDX12::OnInit()
|
||||
// Create texture
|
||||
allocationDesc.HeapType = D3D12_HEAP_TYPE_DEFAULT;
|
||||
HRESULT result = _device->Allocator->CreateResource(&allocationDesc, &resourceDesc, initialState, clearValuePtr, &_allocation, IID_PPV_ARGS(&resource));
|
||||
LOG_DIRECTX_RESULT_WITH_RETURN(result, true);
|
||||
if (FAILED(result))
|
||||
{
|
||||
LOG(Error, "CreatePlacedResource failed");
|
||||
LOG_STR(Error, _desc.ToString());
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
LOG_STR(Error, GetName());
|
||||
#endif
|
||||
RenderToolsDX::LogD3DResult(result, __FILE__, __LINE__);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set state
|
||||
bool isRead = useSRV || useUAV;
|
||||
|
||||
@@ -139,7 +139,16 @@ bool GPUBufferVulkan::OnInit()
|
||||
allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
||||
}
|
||||
const VkResult result = vmaCreateBuffer(_device->Allocator, &bufferInfo, &allocInfo, &_buffer, &_allocation, nullptr);
|
||||
LOG_VULKAN_RESULT_WITH_RETURN(result);
|
||||
if (result != VK_SUCCESS)
|
||||
{
|
||||
LOG(Error, "vmaCreateBuffer failed");
|
||||
LOG_STR(Error, _desc.ToString());
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
LOG_STR(Error, GetName());
|
||||
#endif
|
||||
RenderToolsVulkan::LogVkResult(result, __FILE__, __LINE__);
|
||||
return true;
|
||||
}
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
VK_SET_DEBUG_NAME(_device, _buffer, VK_OBJECT_TYPE_BUFFER, GetName());
|
||||
#endif
|
||||
|
||||
@@ -318,7 +318,16 @@ bool GPUTextureVulkan::OnInit()
|
||||
VmaAllocationCreateInfo allocInfo = {};
|
||||
allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
||||
const VkResult result = vmaCreateImage(_device->Allocator, &imageInfo, &allocInfo, &_image, &_allocation, nullptr);
|
||||
LOG_VULKAN_RESULT_WITH_RETURN(result);
|
||||
if (result != VK_SUCCESS)
|
||||
{
|
||||
LOG(Error, "vmaCreateImage failed");
|
||||
LOG_STR(Error, _desc.ToString());
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
LOG_STR(Error, GetName());
|
||||
#endif
|
||||
RenderToolsVulkan::LogVkResult(result, __FILE__, __LINE__);
|
||||
return true;
|
||||
}
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
VK_SET_DEBUG_NAME(_device, _image, VK_OBJECT_TYPE_IMAGE, GetName());
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user