1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-05 01:24:14 +01:00

[d3d11] Use appropriate memory types for directly mapped images

This commit is contained in:
Philip Rebohle 2022-02-22 05:16:33 +01:00
parent 177e70949c
commit 33cf522647
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 17 additions and 5 deletions

View File

@ -203,11 +203,8 @@ namespace dxvk {
// in case it is going to be mapped directly.
VkMemoryPropertyFlags memoryProperties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
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;
}
if (m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT)
memoryProperties = GetMemoryFlags();
if (vkImage == VK_NULL_HANDLE)
m_image = m_device->GetDXVKDevice()->createImage(imageInfo, memoryProperties);
@ -531,6 +528,19 @@ namespace dxvk {
}
VkMemoryPropertyFlags D3D11CommonTexture::GetMemoryFlags() const {
VkMemoryPropertyFlags memoryFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
if ((m_desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ) || m_device->GetOptions()->apitraceMode)
memoryFlags |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
else if (m_desc.Usage == D3D11_USAGE_DEFAULT || m_desc.BindFlags)
memoryFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
return memoryFlags;
}
D3D11_COMMON_TEXTURE_MAP_MODE D3D11CommonTexture::DetermineMapMode(
const DxvkImageCreateInfo* pImageInfo) const {
// Don't map an image unless the application requests it

View File

@ -414,6 +414,8 @@ namespace dxvk {
VkFormat Format,
UINT CpuAccess) const;
VkMemoryPropertyFlags GetMemoryFlags() const;
D3D11_COMMON_TEXTURE_MAP_MODE DetermineMapMode(
const DxvkImageCreateInfo* pImageInfo) const;