mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-01 19:29:16 +01:00
[d3d11] Select memory type based on CPU access flags
This commit is contained in:
parent
302c6b5e6c
commit
6c8042033e
src/d3d11
@ -165,7 +165,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
// If necessary, create the mapped linear buffer
|
// If necessary, create the mapped linear buffer
|
||||||
if (m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER)
|
if (m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER)
|
||||||
m_buffer = CreateMappedBuffer();
|
m_buffer = CreateMappedBuffer(m_desc.CPUAccessFlags);
|
||||||
|
|
||||||
// Create the image on a host-visible memory type
|
// Create the image on a host-visible memory type
|
||||||
// in case it is going to be mapped directly.
|
// in case it is going to be mapped directly.
|
||||||
@ -173,8 +173,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) {
|
if (m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) {
|
||||||
memoryProperties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
|
memoryProperties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
|
||||||
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
|
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||||
| VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
|
||||||
|
if (m_desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ)
|
||||||
|
memoryProperties |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_image = m_device->GetDXVKDevice()->createImage(imageInfo, memoryProperties);
|
m_image = m_device->GetDXVKDevice()->createImage(imageInfo, memoryProperties);
|
||||||
@ -404,7 +406,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Rc<DxvkBuffer> D3D11CommonTexture::CreateMappedBuffer() const {
|
Rc<DxvkBuffer> D3D11CommonTexture::CreateMappedBuffer(UINT CPUAccessFlags) const {
|
||||||
const DxvkFormatInfo* formatInfo = imageFormatInfo(
|
const DxvkFormatInfo* formatInfo = imageFormatInfo(
|
||||||
m_device->LookupPackedFormat(m_desc.Format, GetFormatMode()).Format);
|
m_device->LookupPackedFormat(m_desc.Format, GetFormatMode()).Format);
|
||||||
|
|
||||||
@ -424,9 +426,13 @@ namespace dxvk {
|
|||||||
info.access = VK_ACCESS_TRANSFER_READ_BIT
|
info.access = VK_ACCESS_TRANSFER_READ_BIT
|
||||||
| VK_ACCESS_TRANSFER_WRITE_BIT;
|
| VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
|
|
||||||
return m_device->GetDXVKDevice()->createBuffer(info,
|
auto memoryType = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
|
||||||
|
if (CPUAccessFlags & D3D11_CPU_ACCESS_READ)
|
||||||
|
memoryType |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||||
|
|
||||||
|
return m_device->GetDXVKDevice()->createBuffer(info, memoryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,7 +198,8 @@ namespace dxvk {
|
|||||||
= { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 };
|
= { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 };
|
||||||
D3D11_MAP m_mapType = D3D11_MAP_READ;
|
D3D11_MAP m_mapType = D3D11_MAP_READ;
|
||||||
|
|
||||||
Rc<DxvkBuffer> CreateMappedBuffer() const;
|
Rc<DxvkBuffer> CreateMappedBuffer(
|
||||||
|
UINT CPUAccessFlags) const;
|
||||||
|
|
||||||
BOOL CheckImageSupport(
|
BOOL CheckImageSupport(
|
||||||
const DxvkImageCreateInfo* pImageInfo,
|
const DxvkImageCreateInfo* pImageInfo,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user