[d3d9] Store buffer map mode in D3D9CommonBuffer

This commit is contained in:
Robin Kertels 2022-02-12 21:03:23 +01:00 committed by Joshie
parent 97ae14b6a0
commit 6d71eea516
2 changed files with 12 additions and 4 deletions

View File

@ -8,9 +8,9 @@ namespace dxvk {
D3D9CommonBuffer::D3D9CommonBuffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc)
: m_parent ( pDevice ), m_desc ( *pDesc ) {
: m_parent ( pDevice ), m_desc ( *pDesc ), m_mapMode(DetermineMapMode()) {
m_buffer = CreateBuffer();
if (GetMapMode() == D3D9_COMMON_BUFFER_MAP_MODE_BUFFER)
if (m_mapMode == D3D9_COMMON_BUFFER_MAP_MODE_BUFFER)
m_stagingBuffer = CreateStagingBuffer();
m_sliceHandle = GetMapBuffer()->getSliceHandle();
@ -83,7 +83,7 @@ namespace dxvk {
info.access |= VK_ACCESS_INDEX_READ_BIT;
}
if (GetMapMode() == D3D9_COMMON_BUFFER_MAP_MODE_DIRECT) {
if (m_mapMode == D3D9_COMMON_BUFFER_MAP_MODE_DIRECT) {
info.stages |= VK_PIPELINE_STAGE_HOST_BIT;
info.access |= VK_ACCESS_HOST_WRITE_BIT;

View File

@ -88,12 +88,19 @@ namespace dxvk {
/**
* \brief Determine the mapping mode of the buffer, (ie. direct mapping or backed)
*/
inline D3D9_COMMON_BUFFER_MAP_MODE GetMapMode() const {
inline D3D9_COMMON_BUFFER_MAP_MODE DetermineMapMode() const {
return (m_desc.Pool == D3DPOOL_DEFAULT && (m_desc.Usage & (D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY)))
? D3D9_COMMON_BUFFER_MAP_MODE_DIRECT
: D3D9_COMMON_BUFFER_MAP_MODE_BUFFER;
}
/**
* \brief Get the mapping mode of the buffer, (ie. direct mapping or backed)
*/
inline D3D9_COMMON_BUFFER_MAP_MODE GetMapMode() const {
return m_mapMode;
}
/**
* \brief Abstraction for getting a type of buffer (mapping/staging/the real buffer) across mapping modes.
*/
@ -231,6 +238,7 @@ namespace dxvk {
DWORD m_mapFlags;
bool m_wasWrittenByGPU = false;
bool m_uploadUsingStaging = false;
D3D9_COMMON_BUFFER_MAP_MODE m_mapMode;
Rc<DxvkBuffer> m_buffer;
Rc<DxvkBuffer> m_stagingBuffer;