anv: Enable implicit CCS for external images
AUX and clear state is stored in the VkDevice private binding Signed-off-by: Renato Pereyra <renatopereyra@google.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14416>
This commit is contained in:
parent
a4c9276de2
commit
b664349973
|
@ -1825,9 +1825,8 @@ anv_device_import_bo_from_host_ptr(struct anv_device *device,
|
|||
ANV_BO_ALLOC_SNOOPED |
|
||||
ANV_BO_ALLOC_FIXED_ADDRESS)));
|
||||
|
||||
/* We can't do implicit CCS with an aux table on shared memory */
|
||||
if (!device->physical->has_implicit_ccs || device->info.has_aux_map)
|
||||
assert(!(alloc_flags & ANV_BO_ALLOC_IMPLICIT_CCS));
|
||||
assert(!(alloc_flags & ANV_BO_ALLOC_IMPLICIT_CCS) ||
|
||||
(device->physical->has_implicit_ccs && device->info.has_aux_map));
|
||||
|
||||
struct anv_bo_cache *cache = &device->bo_cache;
|
||||
const uint32_t bo_flags =
|
||||
|
@ -1916,9 +1915,8 @@ anv_device_import_bo(struct anv_device *device,
|
|||
ANV_BO_ALLOC_SNOOPED |
|
||||
ANV_BO_ALLOC_FIXED_ADDRESS)));
|
||||
|
||||
/* We can't do implicit CCS with an aux table on shared memory */
|
||||
if (!device->physical->has_implicit_ccs || device->info.has_aux_map)
|
||||
assert(!(alloc_flags & ANV_BO_ALLOC_IMPLICIT_CCS));
|
||||
assert(!(alloc_flags & ANV_BO_ALLOC_IMPLICIT_CCS) ||
|
||||
(device->physical->has_implicit_ccs && device->info.has_aux_map));
|
||||
|
||||
struct anv_bo_cache *cache = &device->bo_cache;
|
||||
const uint32_t bo_flags =
|
||||
|
|
|
@ -3654,13 +3654,6 @@ VkResult anv_AllocateMemory(
|
|||
(host_ptr_info && host_ptr_info->handleType)) {
|
||||
/* Anything imported or exported is EXTERNAL */
|
||||
alloc_flags |= ANV_BO_ALLOC_EXTERNAL;
|
||||
|
||||
/* We can't have implicit CCS on external memory with an AUX-table.
|
||||
* Doing so would require us to sync the aux tables across processes
|
||||
* which is impractical.
|
||||
*/
|
||||
if (device->info.has_aux_map)
|
||||
alloc_flags &= ~ANV_BO_ALLOC_IMPLICIT_CCS;
|
||||
}
|
||||
|
||||
/* Check if we need to support Android HW buffer export. If so,
|
||||
|
|
|
@ -536,8 +536,14 @@ add_aux_state_tracking_buffer(struct anv_device *device,
|
|||
enum anv_image_memory_binding binding =
|
||||
ANV_IMAGE_MEMORY_BINDING_PLANE_0 + plane;
|
||||
|
||||
if (image->vk.drm_format_mod != DRM_FORMAT_MOD_INVALID)
|
||||
/* Ensure that AUX state is stored outside the buffer memory for any images
|
||||
* externally sharable. This prevents corruptions arising due to disjoint
|
||||
* processes working with the same image.
|
||||
*/
|
||||
if (image->vk.drm_format_mod != DRM_FORMAT_MOD_INVALID ||
|
||||
image->vk.external_handle_types != 0) {
|
||||
binding = ANV_IMAGE_MEMORY_BINDING_PRIVATE;
|
||||
}
|
||||
|
||||
/* We believe that 256B alignment may be sufficient, but we choose 4K due to
|
||||
* lack of testing. And MI_LOAD/STORE operations require dword-alignment.
|
||||
|
@ -944,9 +950,15 @@ check_memory_bindings(const struct anv_device *device,
|
|||
if (anv_surface_is_valid(&plane->aux_surface)) {
|
||||
enum anv_image_memory_binding binding = primary_binding;
|
||||
|
||||
if (image->vk.drm_format_mod != DRM_FORMAT_MOD_INVALID &&
|
||||
!isl_drm_modifier_has_aux(image->vk.drm_format_mod))
|
||||
/* Ensure that AUX state is stored outside the buffer memory for any
|
||||
* images externally sharable. This prevents corruptions arising due
|
||||
* to disjoint processes working with the same image.
|
||||
*/
|
||||
if ((image->vk.drm_format_mod != DRM_FORMAT_MOD_INVALID &&
|
||||
!isl_drm_modifier_has_aux(image->vk.drm_format_mod)) ||
|
||||
(image->vk.external_handle_types != 0)) {
|
||||
binding = ANV_IMAGE_MEMORY_BINDING_PRIVATE;
|
||||
}
|
||||
|
||||
/* Display hardware requires that the aux surface start at
|
||||
* a higher address than the primary surface. The 3D hardware
|
||||
|
@ -962,8 +974,14 @@ check_memory_bindings(const struct anv_device *device,
|
|||
if (plane->fast_clear_memory_range.size > 0) {
|
||||
enum anv_image_memory_binding binding = primary_binding;
|
||||
|
||||
if (image->vk.drm_format_mod != DRM_FORMAT_MOD_INVALID)
|
||||
/* Ensure that clear state is stored outside the buffer memory for any
|
||||
* images externally sharable. This prevents corruptions arising due
|
||||
* to disjoint processes working with the same image.
|
||||
*/
|
||||
if (image->vk.drm_format_mod != DRM_FORMAT_MOD_INVALID ||
|
||||
image->vk.external_handle_types != 0) {
|
||||
binding = ANV_IMAGE_MEMORY_BINDING_PRIVATE;
|
||||
}
|
||||
|
||||
/* We believe that 256B alignment may be sufficient, but we choose 4K
|
||||
* due to lack of testing. And MI_LOAD/STORE operations require
|
||||
|
|
|
@ -1214,16 +1214,18 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||
* image has a DRM format modifier because we store image data in
|
||||
* a driver-private bo which is inaccessible to the external queue.
|
||||
*/
|
||||
const bool mod_acquire =
|
||||
const bool private_binding_acquire =
|
||||
src_queue_external &&
|
||||
image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
|
||||
(image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT ||
|
||||
image->vk.external_handle_types != 0);
|
||||
|
||||
const bool mod_release =
|
||||
const bool private_binding_release =
|
||||
dst_queue_external &&
|
||||
image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
|
||||
(image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT ||
|
||||
image->vk.external_handle_types != 0);
|
||||
|
||||
if (initial_layout == final_layout &&
|
||||
!mod_acquire && !mod_release) {
|
||||
!private_binding_acquire && !private_binding_release) {
|
||||
/* No work is needed. */
|
||||
return;
|
||||
}
|
||||
|
@ -1267,7 +1269,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||
*/
|
||||
must_init_fast_clear_state = true;
|
||||
must_init_aux_surface = true;
|
||||
} else if (mod_acquire) {
|
||||
} else if (private_binding_acquire) {
|
||||
/* The fast clear state lives in a driver-private bo, and therefore the
|
||||
* external/foreign queue is unaware of it.
|
||||
*
|
||||
|
@ -1426,9 +1428,9 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||
/* We must override the anv_layout_to_* functions because they are unaware of
|
||||
* acquire/release direction.
|
||||
*/
|
||||
if (mod_acquire) {
|
||||
if (private_binding_acquire) {
|
||||
initial_aux_usage = isl_mod_info->aux_usage;
|
||||
} else if (mod_release) {
|
||||
} else if (private_binding_release) {
|
||||
final_aux_usage = isl_mod_info->aux_usage;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue