D3D12: Specify read/write ranges when calling Map/Unmap
This commit is contained in:
parent
fde7dee652
commit
ccf9470241
|
@ -78,7 +78,8 @@ void BBox::Invalidate()
|
||||||
if (!s_bbox_staging_buffer_map)
|
if (!s_bbox_staging_buffer_map)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_bbox_staging_buffer->Unmap(0, nullptr);
|
D3D12_RANGE write_range = {};
|
||||||
|
s_bbox_staging_buffer->Unmap(0, &write_range);
|
||||||
s_bbox_staging_buffer_map = nullptr;
|
s_bbox_staging_buffer_map = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +140,8 @@ int BBox::Get(int index)
|
||||||
|
|
||||||
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
||||||
|
|
||||||
CheckHR(s_bbox_staging_buffer->Map(0, nullptr, &s_bbox_staging_buffer_map));
|
D3D12_RANGE read_range = { 0, BBOX_BUFFER_SIZE };
|
||||||
|
CheckHR(s_bbox_staging_buffer->Map(0, &read_range, &s_bbox_staging_buffer_map));
|
||||||
}
|
}
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
|
|
|
@ -400,8 +400,7 @@ HRESULT Create(HWND wnd)
|
||||||
D3D12_MESSAGE_ID id_list[] = {
|
D3D12_MESSAGE_ID id_list[] = {
|
||||||
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_MAP_INVALID_NULLRANGE, // Benign.
|
|
||||||
};
|
};
|
||||||
filter.DenyList.NumIDs = ARRAYSIZE(id_list);
|
filter.DenyList.NumIDs = ARRAYSIZE(id_list);
|
||||||
filter.DenyList.pIDList = id_list;
|
filter.DenyList.pIDList = id_list;
|
||||||
|
|
|
@ -29,7 +29,8 @@ D3DStreamBuffer::~D3DStreamBuffer()
|
||||||
{
|
{
|
||||||
D3D::command_list_mgr->RemoveQueueFenceCallback(this);
|
D3D::command_list_mgr->RemoveQueueFenceCallback(this);
|
||||||
|
|
||||||
m_buffer->Unmap(0, nullptr);
|
D3D12_RANGE write_range = { 0, m_buffer_size };
|
||||||
|
m_buffer->Unmap(0, &write_range);
|
||||||
D3D::command_list_mgr->DestroyResourceAfterCurrentCommandListExecuted(m_buffer);
|
D3D::command_list_mgr->DestroyResourceAfterCurrentCommandListExecuted(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +95,8 @@ void D3DStreamBuffer::AllocateBuffer(size_t size)
|
||||||
// First, put existing buffer (if it exists) in deferred destruction list.
|
// First, put existing buffer (if it exists) in deferred destruction list.
|
||||||
if (m_buffer)
|
if (m_buffer)
|
||||||
{
|
{
|
||||||
m_buffer->Unmap(0, nullptr);
|
D3D12_RANGE write_range = { 0, m_buffer_size };
|
||||||
|
m_buffer->Unmap(0, &write_range);
|
||||||
D3D::command_list_mgr->DestroyResourceAfterCurrentCommandListExecuted(m_buffer);
|
D3D::command_list_mgr->DestroyResourceAfterCurrentCommandListExecuted(m_buffer);
|
||||||
m_buffer = nullptr;
|
m_buffer = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +112,8 @@ void D3DStreamBuffer::AllocateBuffer(size_t size)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
CheckHR(m_buffer->Map(0, nullptr, &m_buffer_cpu_address));
|
D3D12_RANGE read_range = {};
|
||||||
|
CheckHR(m_buffer->Map(0, &read_range, &m_buffer_cpu_address));
|
||||||
|
|
||||||
m_buffer_gpu_address = m_buffer->GetGPUVirtualAddress();
|
m_buffer_gpu_address = m_buffer->GetGPUVirtualAddress();
|
||||||
m_buffer_size = size;
|
m_buffer_size = size;
|
||||||
|
|
|
@ -51,7 +51,8 @@ void ReplaceRGBATexture2D(ID3D12Resource* texture12, const u8* buffer, unsigned
|
||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(&upload_buffer)));
|
IID_PPV_ARGS(&upload_buffer)));
|
||||||
|
|
||||||
CheckHR(upload_buffer->Map(0, nullptr, reinterpret_cast<void**>(&dest_data)));
|
D3D12_RANGE read_range = {};
|
||||||
|
CheckHR(upload_buffer->Map(0, &read_range, reinterpret_cast<void**>(&dest_data)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -92,8 +93,11 @@ void ReplaceRGBATexture2D(ID3D12Resource* texture12, const u8* buffer, unsigned
|
||||||
// We block here because otherwise if there was a large number of texture uploads, we may run out of memory.
|
// We block here because otherwise if there was a large number of texture uploads, we may run out of memory.
|
||||||
if (!s_texture_upload_stream_buffer || upload_buffer != s_texture_upload_stream_buffer->GetBuffer())
|
if (!s_texture_upload_stream_buffer || upload_buffer != s_texture_upload_stream_buffer->GetBuffer())
|
||||||
{
|
{
|
||||||
|
D3D12_RANGE write_range = { 0, upload_size };
|
||||||
|
upload_buffer->Unmap(0, &write_range);
|
||||||
|
|
||||||
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
||||||
upload_buffer->Unmap(0, nullptr);
|
|
||||||
upload_buffer->Release();
|
upload_buffer->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,8 @@ void FramebufferManager::MapEFBColorAccessCopy()
|
||||||
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
||||||
|
|
||||||
// Resource copy has finished, so safe to map now
|
// Resource copy has finished, so safe to map now
|
||||||
m_efb.color_access_readback_buffer->Map(0, nullptr, reinterpret_cast<void**>(&m_efb.color_access_readback_map));
|
D3D12_RANGE read_range = { 0, m_efb.color_access_readback_pitch * EFB_HEIGHT };
|
||||||
|
m_efb.color_access_readback_buffer->Map(0, &read_range, reinterpret_cast<void**>(&m_efb.color_access_readback_map));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramebufferManager::MapEFBDepthAccessCopy()
|
void FramebufferManager::MapEFBDepthAccessCopy()
|
||||||
|
@ -380,20 +381,23 @@ void FramebufferManager::MapEFBDepthAccessCopy()
|
||||||
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
||||||
|
|
||||||
// Resource copy has finished, so safe to map now
|
// Resource copy has finished, so safe to map now
|
||||||
m_efb.depth_access_readback_buffer->Map(0, nullptr, reinterpret_cast<void**>(&m_efb.depth_access_readback_map));
|
D3D12_RANGE read_range = { 0, m_efb.depth_access_readback_pitch * EFB_HEIGHT };
|
||||||
|
m_efb.depth_access_readback_buffer->Map(0, &read_range, reinterpret_cast<void**>(&m_efb.depth_access_readback_map));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramebufferManager::InvalidateEFBAccessCopies()
|
void FramebufferManager::InvalidateEFBAccessCopies()
|
||||||
{
|
{
|
||||||
|
D3D12_RANGE write_range = {};
|
||||||
|
|
||||||
if (m_efb.color_access_readback_map)
|
if (m_efb.color_access_readback_map)
|
||||||
{
|
{
|
||||||
m_efb.color_access_readback_buffer->Unmap(0, nullptr);
|
m_efb.color_access_readback_buffer->Unmap(0, &write_range);
|
||||||
m_efb.color_access_readback_map = nullptr;
|
m_efb.color_access_readback_map = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_efb.depth_access_readback_map)
|
if (m_efb.depth_access_readback_map)
|
||||||
{
|
{
|
||||||
m_efb.depth_access_readback_buffer->Unmap(0, nullptr);
|
m_efb.depth_access_readback_buffer->Unmap(0, &write_range);
|
||||||
m_efb.depth_access_readback_map = nullptr;
|
m_efb.depth_access_readback_map = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,9 @@ void PSTextureEncoder::Init()
|
||||||
|
|
||||||
D3D::SetDebugObjectName12(m_encode_params_buffer, "efb encoder params buffer");
|
D3D::SetDebugObjectName12(m_encode_params_buffer, "efb encoder params buffer");
|
||||||
|
|
||||||
CheckHR(m_encode_params_buffer->Map(0, nullptr, &m_encode_params_buffer_data));
|
// NOTE: This upload buffer is okay to overwrite each time, since we block until completion when it's used anyway.
|
||||||
|
D3D12_RANGE read_range = {};
|
||||||
|
CheckHR(m_encode_params_buffer->Map(0, &read_range, &m_encode_params_buffer_data));
|
||||||
|
|
||||||
m_ready = true;
|
m_ready = true;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +225,8 @@ void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_p
|
||||||
|
|
||||||
// Transfer staging buffer to GameCube/Wii RAM
|
// Transfer staging buffer to GameCube/Wii RAM
|
||||||
void* readback_data_map;
|
void* readback_data_map;
|
||||||
CheckHR(m_out_readback_buffer->Map(0, nullptr, &readback_data_map));
|
D3D12_RANGE read_range = { 0, dst_location.PlacedFootprint.Footprint.RowPitch * num_blocks_y };
|
||||||
|
CheckHR(m_out_readback_buffer->Map(0, &read_range, &readback_data_map));
|
||||||
|
|
||||||
u8* src = static_cast<u8*>(readback_data_map);
|
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);
|
||||||
|
@ -235,7 +238,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);
|
D3D12_RANGE write_range = {};
|
||||||
|
m_out_readback_buffer->Unmap(0, &write_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_SHADER_BYTECODE PSTextureEncoder::SetStaticShader(unsigned int dst_format, PEControl::PixelFormat src_format,
|
D3D12_SHADER_BYTECODE PSTextureEncoder::SetStaticShader(unsigned int dst_format, PEControl::PixelFormat src_format,
|
||||||
|
|
|
@ -119,8 +119,8 @@ void PerfQuery::FlushOne()
|
||||||
UINT64 result;
|
UINT64 result;
|
||||||
memcpy(&result, reinterpret_cast<u8*>(readback_buffer_map) + sizeof(UINT64) * index, sizeof(UINT64));
|
memcpy(&result, reinterpret_cast<u8*>(readback_buffer_map) + sizeof(UINT64) * index, sizeof(UINT64));
|
||||||
|
|
||||||
D3D12_RANGE empty_range = {};
|
D3D12_RANGE write_range = {};
|
||||||
m_query_readback_buffer->Unmap(0, &empty_range);
|
m_query_readback_buffer->Unmap(0, &write_range);
|
||||||
|
|
||||||
// NOTE: Reported pixel metrics should be referenced to native resolution
|
// NOTE: Reported pixel metrics should be referenced to native resolution
|
||||||
m_results[entry.query_type] += (u32)(result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());
|
m_results[entry.query_type] += (u32)(result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());
|
||||||
|
|
|
@ -665,11 +665,13 @@ bool Renderer::SaveScreenshot(const std::string& filename, const TargetRectangle
|
||||||
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
D3D::command_list_mgr->ExecuteQueuedWork(true);
|
||||||
|
|
||||||
void* screenshot_texture_map;
|
void* screenshot_texture_map;
|
||||||
CheckHR(s_screenshot_texture->Map(0, nullptr, &screenshot_texture_map));
|
D3D12_RANGE read_range = { 0, dst_location.PlacedFootprint.Footprint.RowPitch * (source_box.bottom - source_box.top) };
|
||||||
|
CheckHR(s_screenshot_texture->Map(0, &read_range, &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);
|
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);
|
D3D12_RANGE write_range = {};
|
||||||
|
s_screenshot_texture->Unmap(0, &write_range);
|
||||||
|
|
||||||
if (saved_png)
|
if (saved_png)
|
||||||
{
|
{
|
||||||
|
@ -871,9 +873,12 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
||||||
}
|
}
|
||||||
|
|
||||||
void* screenshot_texture_map;
|
void* screenshot_texture_map;
|
||||||
CheckHR(s_screenshot_texture->Map(0, nullptr, &screenshot_texture_map));
|
D3D12_RANGE read_range = { 0, dst_location.PlacedFootprint.Footprint.RowPitch * source_height };
|
||||||
|
CheckHR(s_screenshot_texture->Map(0, &read_range, &screenshot_texture_map));
|
||||||
formatBufferDump(static_cast<u8*>(screenshot_texture_map), &frame_data[0], source_width, source_height, dst_location.PlacedFootprint.Footprint.RowPitch);
|
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);
|
|
||||||
|
D3D12_RANGE write_range = {};
|
||||||
|
s_screenshot_texture->Unmap(0, &write_range);
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -83,7 +83,8 @@ bool TextureCache::TCacheEntry::Save(const std::string& filename, unsigned int l
|
||||||
|
|
||||||
// Map readback buffer and save to file.
|
// Map readback buffer and save to file.
|
||||||
void* readback_texture_map;
|
void* readback_texture_map;
|
||||||
CheckHR(s_texture_cache_entry_readback_buffer->Map(0, nullptr, &readback_texture_map));
|
D3D12_RANGE read_range = { 0, required_readback_buffer_size };
|
||||||
|
CheckHR(s_texture_cache_entry_readback_buffer->Map(0, &read_range, &readback_texture_map));
|
||||||
|
|
||||||
bool saved = TextureToPng(
|
bool saved = TextureToPng(
|
||||||
static_cast<u8*>(readback_texture_map),
|
static_cast<u8*>(readback_texture_map),
|
||||||
|
@ -93,7 +94,8 @@ bool TextureCache::TCacheEntry::Save(const std::string& filename, unsigned int l
|
||||||
dst_location.PlacedFootprint.Footprint.Height
|
dst_location.PlacedFootprint.Footprint.Height
|
||||||
);
|
);
|
||||||
|
|
||||||
s_texture_cache_entry_readback_buffer->Unmap(0, nullptr);
|
D3D12_RANGE write_range = {};
|
||||||
|
s_texture_cache_entry_readback_buffer->Unmap(0, &write_range);
|
||||||
return saved;
|
return saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,8 @@ void XFBEncoder::EncodeTextureToRam(u8* dst, u32 dst_pitch, u32 dst_height,
|
||||||
// Copy from the readback buffer to dst.
|
// Copy from the readback buffer to dst.
|
||||||
// Can't be done as one memcpy due to pitch difference.
|
// Can't be done as one memcpy due to pitch difference.
|
||||||
void* readback_texture_map;
|
void* readback_texture_map;
|
||||||
CheckHR(m_readback_buffer->Map(0, nullptr, &readback_texture_map));
|
D3D12_RANGE read_range = { 0, readback_pitch * dst_height };
|
||||||
|
CheckHR(m_readback_buffer->Map(0, &read_range, &readback_texture_map));
|
||||||
|
|
||||||
for (u32 row = 0; row < dst_height; row++)
|
for (u32 row = 0; row < dst_height; row++)
|
||||||
{
|
{
|
||||||
|
@ -141,7 +142,8 @@ void XFBEncoder::EncodeTextureToRam(u8* dst, u32 dst_pitch, u32 dst_height,
|
||||||
memcpy(row_dst, row_src, std::min(dst_pitch, readback_pitch));
|
memcpy(row_dst, row_src, std::min(dst_pitch, readback_pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_readback_buffer->Unmap(0, nullptr);
|
D3D12_RANGE write_range = {};
|
||||||
|
m_readback_buffer->Unmap(0, &write_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFBEncoder::DecodeToTexture(D3DTexture2D* dst_texture, const u8* src, u32 src_width, u32 src_height)
|
void XFBEncoder::DecodeToTexture(D3DTexture2D* dst_texture, const u8* src, u32 src_width, u32 src_height)
|
||||||
|
|
Loading…
Reference in New Issue