D3D12: Don't keep screenshot/encoder buffers mapped
Readback heaps do not support persistent mapping. See D3D12 docs.
This commit is contained in:
parent
c4d79d6db3
commit
74275bdfe3
|
@ -486,11 +486,7 @@ HRESULT Create(HWND wnd)
|
||||||
D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_DEPTHSTENCILVIEW_NOT_SET, // Benign.
|
D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_DEPTHSTENCILVIEW_NOT_SET, // Benign.
|
||||||
D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDERTARGETVIEW_NOT_SET, // Benign.
|
D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDERTARGETVIEW_NOT_SET, // Benign.
|
||||||
D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH, // Benign.
|
D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH, // Benign.
|
||||||
D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE, // Benign. Probably.
|
|
||||||
D3D12_MESSAGE_ID_INVALID_SUBRESOURCE_STATE,
|
|
||||||
D3D12_MESSAGE_ID_MAP_INVALID_NULLRANGE, // Benign.
|
D3D12_MESSAGE_ID_MAP_INVALID_NULLRANGE, // Benign.
|
||||||
D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_GPU_WRITTEN_READBACK_RESOURCE_MAPPED, // Benign.
|
|
||||||
D3D12_MESSAGE_ID_RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH // Benign. Probably.
|
|
||||||
};
|
};
|
||||||
filter.DenyList.NumIDs = ARRAYSIZE(id_list);
|
filter.DenyList.NumIDs = ARRAYSIZE(id_list);
|
||||||
filter.DenyList.pIDList = id_list;
|
filter.DenyList.pIDList = id_list;
|
||||||
|
|
|
@ -89,8 +89,6 @@ void PSTextureEncoder::Init()
|
||||||
|
|
||||||
D3D::SetDebugObjectName12(m_out_readback_buffer, "efb encoder output staging buffer");
|
D3D::SetDebugObjectName12(m_out_readback_buffer, "efb encoder output staging buffer");
|
||||||
|
|
||||||
CheckHR(m_out_readback_buffer->Map(0, nullptr, &m_out_readback_buffer_data));
|
|
||||||
|
|
||||||
// Create constant buffer for uploading data to shaders. Need to align to 256 bytes.
|
// Create constant buffer for uploading data to shaders. Need to align to 256 bytes.
|
||||||
unsigned int encode_params_buffer_size = (sizeof(EFBEncodeParams) + 0xff) & ~0xff;
|
unsigned int encode_params_buffer_size = (sizeof(EFBEncodeParams) + 0xff) & ~0xff;
|
||||||
|
|
||||||
|
@ -220,8 +218,10 @@ void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_p
|
||||||
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
||||||
|
|
||||||
// Transfer staging buffer to GameCube/Wii RAM
|
// Transfer staging buffer to GameCube/Wii RAM
|
||||||
|
void* readback_data_map;
|
||||||
|
CheckHR(m_out_readback_buffer->Map(0, nullptr, &readback_data_map));
|
||||||
|
|
||||||
u8* src = static_cast<u8*>(m_out_readback_buffer_data);
|
u8* src = static_cast<u8*>(readback_data_map);
|
||||||
u32 read_stride = std::min(bytes_per_row, dst_location.PlacedFootprint.Footprint.RowPitch);
|
u32 read_stride = std::min(bytes_per_row, dst_location.PlacedFootprint.Footprint.RowPitch);
|
||||||
for (unsigned int y = 0; y < num_blocks_y; ++y)
|
for (unsigned int y = 0; y < num_blocks_y; ++y)
|
||||||
{
|
{
|
||||||
|
@ -231,6 +231,8 @@ void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_p
|
||||||
src += dst_location.PlacedFootprint.Footprint.RowPitch;
|
src += dst_location.PlacedFootprint.Footprint.RowPitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_out_readback_buffer->Unmap(0, nullptr);
|
||||||
|
|
||||||
// Restores proper viewport/scissor settings.
|
// Restores proper viewport/scissor settings.
|
||||||
g_renderer->RestoreAPIState();
|
g_renderer->RestoreAPIState();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ private:
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE m_out_rtv_cpu = {};
|
D3D12_CPU_DESCRIPTOR_HANDLE m_out_rtv_cpu = {};
|
||||||
|
|
||||||
ID3D12Resource* m_out_readback_buffer = nullptr;
|
ID3D12Resource* m_out_readback_buffer = nullptr;
|
||||||
void* m_out_readback_buffer_data = nullptr;
|
|
||||||
|
|
||||||
ID3D12Resource* m_encode_params_buffer = nullptr;
|
ID3D12Resource* m_encode_params_buffer = nullptr;
|
||||||
void* m_encode_params_buffer_data = nullptr;
|
void* m_encode_params_buffer_data = nullptr;
|
||||||
|
|
|
@ -76,7 +76,6 @@ D3D12_DEPTH_STENCIL_DESC g_reset_depth_desc = {};
|
||||||
D3D12_RASTERIZER_DESC g_reset_rast_desc = {};
|
D3D12_RASTERIZER_DESC g_reset_rast_desc = {};
|
||||||
|
|
||||||
static ID3D12Resource* s_screenshot_texture = nullptr;
|
static ID3D12Resource* s_screenshot_texture = nullptr;
|
||||||
static void* s_screenshot_texture_data = nullptr;
|
|
||||||
|
|
||||||
// Nvidia stereo blitting struct defined in "nvstereo.h" from the Nvidia SDK
|
// Nvidia stereo blitting struct defined in "nvstereo.h" from the Nvidia SDK
|
||||||
typedef struct _Nv_Stereo_Image_Header
|
typedef struct _Nv_Stereo_Image_Header
|
||||||
|
@ -162,7 +161,6 @@ static void SetupDeviceObjects()
|
||||||
g_reset_rast_desc = rast_desc;
|
g_reset_rast_desc = rast_desc;
|
||||||
|
|
||||||
s_screenshot_texture = nullptr;
|
s_screenshot_texture = nullptr;
|
||||||
s_screenshot_texture_data = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill off all device objects
|
// Kill off all device objects
|
||||||
|
@ -200,8 +198,6 @@ void CreateScreenshotTexture()
|
||||||
IID_PPV_ARGS(&s_screenshot_texture)
|
IID_PPV_ARGS(&s_screenshot_texture)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
CheckHR(s_screenshot_texture->Map(0, nullptr, &s_screenshot_texture_data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static D3D12_BOX GetScreenshotSourceBox(const TargetRectangle& target_rc)
|
static D3D12_BOX GetScreenshotSourceBox(const TargetRectangle& target_rc)
|
||||||
|
@ -677,7 +673,12 @@ bool Renderer::SaveScreenshot(const std::string& filename, const TargetRectangle
|
||||||
|
|
||||||
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
||||||
|
|
||||||
saved_png = TextureToPng(static_cast<u8*>(s_screenshot_texture_data), dst_location.PlacedFootprint.Footprint.RowPitch, filename, source_box.right - source_box.left, source_box.bottom - source_box.top, false);
|
void* screenshot_texture_map;
|
||||||
|
CheckHR(s_screenshot_texture->Map(0, nullptr, &screenshot_texture_map));
|
||||||
|
|
||||||
|
saved_png = TextureToPng(static_cast<u8*>(screenshot_texture_map), dst_location.PlacedFootprint.Footprint.RowPitch, filename, source_box.right - source_box.left, source_box.bottom - source_box.top, false);
|
||||||
|
|
||||||
|
s_screenshot_texture->Unmap(0, nullptr);
|
||||||
|
|
||||||
if (saved_png)
|
if (saved_png)
|
||||||
{
|
{
|
||||||
|
@ -877,7 +878,12 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
||||||
w = s_record_width;
|
w = s_record_width;
|
||||||
h = s_record_height;
|
h = s_record_height;
|
||||||
}
|
}
|
||||||
formatBufferDump(static_cast<u8*>(s_screenshot_texture_data), &frame_data[0], source_width, source_height, dst_location.PlacedFootprint.Footprint.RowPitch);
|
|
||||||
|
void* screenshot_texture_map;
|
||||||
|
CheckHR(s_screenshot_texture->Map(0, nullptr, &screenshot_texture_map));
|
||||||
|
formatBufferDump(static_cast<u8*>(screenshot_texture_map), &frame_data[0], source_width, source_height, dst_location.PlacedFootprint.Footprint.RowPitch);
|
||||||
|
s_screenshot_texture->Unmap(0, nullptr);
|
||||||
|
|
||||||
FlipImageData(&frame_data[0], w, h);
|
FlipImageData(&frame_data[0], w, h);
|
||||||
AVIDump::AddFrame(&frame_data[0], source_width, source_height);
|
AVIDump::AddFrame(&frame_data[0], source_width, source_height);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue