tu: Add a flag for cached non-coherent BOs
We will have to flush/invalidate the memory backing an image in the driver when copying it to/from the host if it's cached and not coherent. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26578>
This commit is contained in:
@@ -44,6 +44,10 @@ tu_bo_init_new_explicit_iova(struct tu_device *dev,
|
|||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
if ((mem_property & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) &&
|
||||||
|
!(mem_property & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT))
|
||||||
|
(*out_bo)->cached_non_coherent = true;
|
||||||
|
|
||||||
vk_address_binding_report(&instance->vk, base ? base : &dev->vk.base,
|
vk_address_binding_report(&instance->vk, base ? base : &dev->vk.base,
|
||||||
(*out_bo)->iova, (*out_bo)->size,
|
(*out_bo)->iova, (*out_bo)->size,
|
||||||
VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT);
|
VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT);
|
||||||
@@ -57,7 +61,19 @@ tu_bo_init_dmabuf(struct tu_device *dev,
|
|||||||
uint64_t size,
|
uint64_t size,
|
||||||
int fd)
|
int fd)
|
||||||
{
|
{
|
||||||
return dev->instance->knl->bo_init_dmabuf(dev, bo, size, fd);
|
VkResult result = dev->instance->knl->bo_init_dmabuf(dev, bo, size, fd);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
/* If we have non-coherent cached memory, then defensively assume that it
|
||||||
|
* may need to be invalidated/flushed. If not, then we just have to assume
|
||||||
|
* that whatever dma-buf producer didn't allocate it non-coherent cached
|
||||||
|
* because we have no way of handling that.
|
||||||
|
*/
|
||||||
|
if (dev->physical_device->has_cached_non_coherent_memory)
|
||||||
|
(*bo)->cached_non_coherent = true;
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@@ -69,6 +69,7 @@ struct tu_bo {
|
|||||||
|
|
||||||
bool implicit_sync : 1;
|
bool implicit_sync : 1;
|
||||||
bool never_unmap : 1;
|
bool never_unmap : 1;
|
||||||
|
bool cached_non_coherent : 1;
|
||||||
|
|
||||||
/* Pointer to the vk_object_base associated with the BO
|
/* Pointer to the vk_object_base associated with the BO
|
||||||
* for the purposes of VK_EXT_device_address_binding_report
|
* for the purposes of VK_EXT_device_address_binding_report
|
||||||
|
Reference in New Issue
Block a user