From 99d42c07c208453c32e5eb8c2f619be7ed2f1a6d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 8 Mar 2020 12:37:56 +1000 Subject: [PATCH] D3D11/StreamBuffer: Use WRITE_DISCARD at position 0 --- src/common/d3d11/stream_buffer.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/common/d3d11/stream_buffer.cpp b/src/common/d3d11/stream_buffer.cpp index 2b68915f9..c10acb276 100644 --- a/src/common/d3d11/stream_buffer.cpp +++ b/src/common/d3d11/stream_buffer.cpp @@ -55,24 +55,19 @@ void StreamBuffer::Release() StreamBuffer::MappingResult StreamBuffer::Map(ID3D11DeviceContext* context, u32 alignment, u32 min_size) { m_position = Common::AlignUp(m_position, alignment); - - D3D11_MAP map; if ((m_position + min_size) >= m_size) { // wrap around m_position = 0; - map = D3D11_MAP_WRITE_DISCARD; - } - else - { - map = D3D11_MAP_WRITE_NO_OVERWRITE; } D3D11_MAPPED_SUBRESOURCE sr; - const HRESULT hr = context->Map(m_buffer.Get(), 0, map, 0, &sr); + const D3D11_MAP map_type = (m_position == 0) ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE; + const HRESULT hr = context->Map(m_buffer.Get(), 0, map_type, 0, &sr); if (FAILED(hr)) { - Log_ErrorPrintf("Map failed: 0x%08X", hr); + Log_ErrorPrintf("Map failed: 0x%08X (alignment %u, minsize %u, size %u, position %u, map type %u)", hr, alignment, + min_size, m_size, m_position, static_cast(map_type)); Panic("Map failed"); return {}; }