D3D11/StreamBuffer: Check feature support for MAP_NO_OVERWRITE before using
This commit is contained in:
parent
99d42c07c2
commit
2249b873ff
|
@ -24,7 +24,7 @@ bool StreamBuffer::Create(ID3D11Device* device, D3D11_BIND_FLAG bind_flags, u32
|
||||||
{
|
{
|
||||||
CD3D11_BUFFER_DESC desc(size, bind_flags, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE, 0, 0);
|
CD3D11_BUFFER_DESC desc(size, bind_flags, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE, 0, 0);
|
||||||
ComPtr<ID3D11Buffer> buffer;
|
ComPtr<ID3D11Buffer> buffer;
|
||||||
const HRESULT hr = device->CreateBuffer(&desc, nullptr, &buffer);
|
HRESULT hr = device->CreateBuffer(&desc, nullptr, &buffer);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
Log_ErrorPrintf("Creating buffer failed: 0x%08X", hr);
|
Log_ErrorPrintf("Creating buffer failed: 0x%08X", hr);
|
||||||
|
@ -34,6 +34,31 @@ bool StreamBuffer::Create(ID3D11Device* device, D3D11_BIND_FLAG bind_flags, u32
|
||||||
m_buffer = std::move(buffer);
|
m_buffer = std::move(buffer);
|
||||||
m_size = size;
|
m_size = size;
|
||||||
m_position = 0;
|
m_position = 0;
|
||||||
|
|
||||||
|
D3D11_FEATURE_DATA_D3D11_OPTIONS options = {};
|
||||||
|
hr = device->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &options, sizeof(options));
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
if (bind_flags & D3D11_BIND_CONSTANT_BUFFER)
|
||||||
|
m_use_map_no_overwrite = options.MapNoOverwriteOnDynamicConstantBuffer;
|
||||||
|
else if (bind_flags & D3D11_BIND_SHADER_RESOURCE)
|
||||||
|
m_use_map_no_overwrite = options.MapNoOverwriteOnDynamicBufferSRV;
|
||||||
|
else
|
||||||
|
m_use_map_no_overwrite = true;
|
||||||
|
|
||||||
|
if (!m_use_map_no_overwrite)
|
||||||
|
{
|
||||||
|
Log_WarningPrintf("Unable to use MAP_NO_OVERWRITE on buffer with bind flag %u, this may affect performance. "
|
||||||
|
"Update your driver/operating system.",
|
||||||
|
static_cast<unsigned>(bind_flags));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log_WarningPrintf("ID3D11Device::CheckFeatureSupport() failed: 0x%08X", hr);
|
||||||
|
m_use_map_no_overwrite = false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +80,7 @@ void StreamBuffer::Release()
|
||||||
StreamBuffer::MappingResult StreamBuffer::Map(ID3D11DeviceContext* context, u32 alignment, u32 min_size)
|
StreamBuffer::MappingResult StreamBuffer::Map(ID3D11DeviceContext* context, u32 alignment, u32 min_size)
|
||||||
{
|
{
|
||||||
m_position = Common::AlignUp(m_position, alignment);
|
m_position = Common::AlignUp(m_position, alignment);
|
||||||
if ((m_position + min_size) >= m_size)
|
if ((m_position + min_size) >= m_size || !m_use_map_no_overwrite)
|
||||||
{
|
{
|
||||||
// wrap around
|
// wrap around
|
||||||
m_position = 0;
|
m_position = 0;
|
||||||
|
|
|
@ -39,5 +39,6 @@ private:
|
||||||
ComPtr<ID3D11Buffer> m_buffer;
|
ComPtr<ID3D11Buffer> m_buffer;
|
||||||
u32 m_size;
|
u32 m_size;
|
||||||
u32 m_position;
|
u32 m_position;
|
||||||
|
bool m_use_map_no_overwrite = false;
|
||||||
};
|
};
|
||||||
} // namespace GL
|
} // namespace GL
|
Loading…
Reference in New Issue