1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[d3d11] Select memory type based on CPU access flags

This commit is contained in:
Philip Rebohle 2019-03-26 21:17:52 +01:00
parent 302c6b5e6c
commit 6c8042033e
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 15 additions and 8 deletions

View File

@ -165,7 +165,7 @@ namespace dxvk {
// If necessary, create the mapped linear 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
// in case it is going to be mapped directly.
@ -173,8 +173,10 @@ namespace dxvk {
if (m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) {
memoryProperties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
| VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
if (m_desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ)
memoryProperties |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
}
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(
m_device->LookupPackedFormat(m_desc.Format, GetFormatMode()).Format);
@ -424,9 +426,13 @@ namespace dxvk {
info.access = VK_ACCESS_TRANSFER_READ_BIT
| VK_ACCESS_TRANSFER_WRITE_BIT;
return m_device->GetDXVKDevice()->createBuffer(info,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
auto memoryType = VK_MEMORY_PROPERTY_HOST_VISIBLE_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);
}

View File

@ -198,7 +198,8 @@ namespace dxvk {
= { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 };
D3D11_MAP m_mapType = D3D11_MAP_READ;
Rc<DxvkBuffer> CreateMappedBuffer() const;
Rc<DxvkBuffer> CreateMappedBuffer(
UINT CPUAccessFlags) const;
BOOL CheckImageSupport(
const DxvkImageCreateInfo* pImageInfo,