GPU/HW: Ensure buffers are unmapped before present
Darn DX11...
This commit is contained in:
@ -1046,12 +1046,14 @@ void D3D11Device::SetScissor(s32 x, s32 y, s32 width, s32 height)
|
||||
|
||||
void D3D11Device::Draw(u32 vertex_count, u32 base_vertex)
|
||||
{
|
||||
DebugAssert(!m_vertex_buffer.IsMapped() && !m_index_buffer.IsMapped());
|
||||
s_stats.num_draws++;
|
||||
m_context->Draw(vertex_count, base_vertex);
|
||||
}
|
||||
|
||||
void D3D11Device::DrawIndexed(u32 index_count, u32 base_index, u32 base_vertex)
|
||||
{
|
||||
DebugAssert(!m_vertex_buffer.IsMapped() && !m_index_buffer.IsMapped());
|
||||
s_stats.num_draws++;
|
||||
m_context->DrawIndexed(index_count, base_index, base_vertex);
|
||||
}
|
||||
|
||||
@ -74,6 +74,8 @@ void D3D11StreamBuffer::Destroy()
|
||||
|
||||
D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* context, u32 alignment, u32 min_size)
|
||||
{
|
||||
DebugAssert(!m_mapped);
|
||||
|
||||
m_position = Common::AlignUp(m_position, alignment);
|
||||
if ((m_position + min_size) >= m_size || !m_use_map_no_overwrite)
|
||||
{
|
||||
@ -91,12 +93,16 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||
Panic("Map failed");
|
||||
}
|
||||
|
||||
m_mapped = true;
|
||||
return MappingResult{static_cast<char*>(sr.pData) + m_position, m_position, m_position / alignment,
|
||||
(m_size - m_position) / alignment};
|
||||
}
|
||||
|
||||
void D3D11StreamBuffer::Unmap(ID3D11DeviceContext1* context, u32 used_size)
|
||||
{
|
||||
DebugAssert(m_mapped);
|
||||
|
||||
context->Unmap(m_buffer.Get(), 0);
|
||||
m_position += used_size;
|
||||
m_mapped = false;
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ public:
|
||||
ALWAYS_INLINE ID3D11Buffer* const* GetD3DBufferArray() const { return m_buffer.GetAddressOf(); }
|
||||
ALWAYS_INLINE u32 GetSize() const { return m_size; }
|
||||
ALWAYS_INLINE u32 GetPosition() const { return m_position; }
|
||||
ALWAYS_INLINE bool IsMapped() const { return m_mapped; }
|
||||
|
||||
bool Create(ID3D11Device* device, D3D11_BIND_FLAG bind_flags, u32 size);
|
||||
void Destroy();
|
||||
@ -43,4 +44,5 @@ private:
|
||||
u32 m_size;
|
||||
u32 m_position;
|
||||
bool m_use_map_no_overwrite = false;
|
||||
bool m_mapped = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user