mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 17:50:11 +01:00
anv: Enable VK_EXT_external_memory_acquire_unmodified
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com> Change-Id: If0480721f7f1fceec093e4ab7b5c9b712eb62ba1 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32295>
This commit is contained in:
parent
3613b9c4f7
commit
1bf8542490
2 changed files with 56 additions and 13 deletions
|
|
@ -283,6 +283,7 @@ get_device_extensions(const struct anv_physical_device *device,
|
|||
.EXT_extended_dynamic_state = true,
|
||||
.EXT_extended_dynamic_state2 = true,
|
||||
.EXT_extended_dynamic_state3 = true,
|
||||
.EXT_external_memory_acquire_unmodified = true,
|
||||
.EXT_external_memory_dma_buf = true,
|
||||
.EXT_external_memory_host = true,
|
||||
.EXT_fragment_shader_interlock = true,
|
||||
|
|
|
|||
|
|
@ -1019,6 +1019,13 @@ genX(set_fast_clear_state)(struct anv_cmd_buffer *cmd_buffer,
|
|||
}
|
||||
}
|
||||
|
||||
static bool ATTRIBUTE_CONST
|
||||
queue_family_is_external(uint32_t index)
|
||||
{
|
||||
return index == VK_QUEUE_FAMILY_FOREIGN_EXT ||
|
||||
index == VK_QUEUE_FAMILY_EXTERNAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transitions a color buffer from one layout to another.
|
||||
*
|
||||
|
|
@ -1029,6 +1036,9 @@ genX(set_fast_clear_state)(struct anv_cmd_buffer *cmd_buffer,
|
|||
* @param layer_count VK_REMAINING_ARRAY_LAYERS isn't supported. For 3D images,
|
||||
* this represents the maximum layers to transition at each
|
||||
* specified miplevel.
|
||||
* @param acquire_unmodified True if
|
||||
* VkExternalMemoryAcquireUnmodifiedEXT::acquireUnmodifiedMemory is set and
|
||||
* relevant.
|
||||
*/
|
||||
static void
|
||||
transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
||||
|
|
@ -1040,7 +1050,8 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||
VkImageLayout final_layout,
|
||||
uint32_t src_queue_family,
|
||||
uint32_t dst_queue_family,
|
||||
bool will_full_fast_clear)
|
||||
bool will_full_fast_clear,
|
||||
bool acquire_unmodified)
|
||||
{
|
||||
struct anv_device *device = cmd_buffer->device;
|
||||
const struct intel_device_info *devinfo = device->info;
|
||||
|
|
@ -1067,13 +1078,8 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||
? isl_drm_modifier_get_info(image->vk.drm_format_mod)
|
||||
: NULL;
|
||||
|
||||
const bool src_queue_external =
|
||||
src_queue_family == VK_QUEUE_FAMILY_FOREIGN_EXT ||
|
||||
src_queue_family == VK_QUEUE_FAMILY_EXTERNAL;
|
||||
|
||||
const bool dst_queue_external =
|
||||
dst_queue_family == VK_QUEUE_FAMILY_FOREIGN_EXT ||
|
||||
dst_queue_family == VK_QUEUE_FAMILY_EXTERNAL;
|
||||
const bool src_queue_external = queue_family_is_external(src_queue_family);
|
||||
const bool dst_queue_external = queue_family_is_external(dst_queue_family);
|
||||
|
||||
/* If the queues are external, consider the first queue family flags
|
||||
* (should be the most capable)
|
||||
|
|
@ -1223,8 +1229,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||
|
||||
must_init_aux_surface = false;
|
||||
}
|
||||
|
||||
} else if (private_binding_acquire) {
|
||||
} else if (private_binding_acquire && !acquire_unmodified) {
|
||||
/* The fast clear state lives in a driver-private bo, and therefore the
|
||||
* external/foreign queue is unaware of it.
|
||||
*
|
||||
|
|
@ -1257,6 +1262,19 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||
*/
|
||||
must_init_aux_surface = false;
|
||||
}
|
||||
} else if (private_binding_acquire && acquire_unmodified) {
|
||||
/* The Vulkan 1.3.302 spec ensures we have previously initialized the
|
||||
* image memory, and therefore initialized the fast clear state and aux
|
||||
* surface, because initial_layout_undefined is false and
|
||||
* acquireUnmodifiedMemory is true.
|
||||
*
|
||||
* Since the time of our most recent image ownership release and up
|
||||
* until the current ownership re-acquisition, the externally-shared
|
||||
* image memory has remained unmodified. Therefore the fast clear state
|
||||
* and aux surface are valid and consistent with the image content.
|
||||
*/
|
||||
must_init_fast_clear_state = false;
|
||||
must_init_aux_surface = false;
|
||||
}
|
||||
|
||||
if (must_init_fast_clear_state) {
|
||||
|
|
@ -4269,6 +4287,25 @@ cmd_buffer_has_pending_copy_query(struct anv_cmd_buffer *cmd_buffer)
|
|||
ANV_QUERY_WRITES_DATA_FLUSH) != 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
img_barrier_has_acquire_unmodified(const VkImageMemoryBarrier2 *img_barrier)
|
||||
{
|
||||
/* The Vulkan 1.3.302 spec says:
|
||||
*
|
||||
* This struct [VkExternalMemoryAcquireUnmodifiedEXT] is ignored if the
|
||||
* memory barrier's srcQueueFamilyIndex is not a special queue family
|
||||
* reserved for external memory ownership transfers.
|
||||
*/
|
||||
if (!queue_family_is_external(img_barrier->srcQueueFamilyIndex))
|
||||
return false;
|
||||
|
||||
const VkExternalMemoryAcquireUnmodifiedEXT *unmodified_info =
|
||||
vk_find_struct_const(img_barrier->pNext,
|
||||
EXTERNAL_MEMORY_ACQUIRE_UNMODIFIED_EXT);
|
||||
|
||||
return unmodified_info && unmodified_info->acquireUnmodifiedMemory;
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_buffer_accumulate_barrier_bits(struct anv_cmd_buffer *cmd_buffer,
|
||||
uint32_t n_dep_infos,
|
||||
|
|
@ -4462,6 +4499,8 @@ cmd_buffer_accumulate_barrier_bits(struct anv_cmd_buffer *cmd_buffer,
|
|||
}
|
||||
|
||||
if (range->aspectMask & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) {
|
||||
bool acquire_unmodified =
|
||||
img_barrier_has_acquire_unmodified(img_barrier);
|
||||
VkImageAspectFlags color_aspects =
|
||||
vk_image_expand_aspect_mask(&image->vk, range->aspectMask);
|
||||
anv_foreach_image_aspect_bit(aspect_bit, image, color_aspects) {
|
||||
|
|
@ -4471,7 +4510,8 @@ cmd_buffer_accumulate_barrier_bits(struct anv_cmd_buffer *cmd_buffer,
|
|||
old_layout, new_layout,
|
||||
img_barrier->srcQueueFamilyIndex,
|
||||
img_barrier->dstQueueFamilyIndex,
|
||||
false /* will_full_fast_clear */);
|
||||
false /* will_full_fast_clear */,
|
||||
acquire_unmodified);
|
||||
}
|
||||
}
|
||||
#if GFX_VER < 20
|
||||
|
|
@ -5437,7 +5477,8 @@ void genX(CmdBeginRendering)(
|
|||
initial_layout, att->imageLayout,
|
||||
VK_QUEUE_FAMILY_IGNORED,
|
||||
VK_QUEUE_FAMILY_IGNORED,
|
||||
fast_clear);
|
||||
fast_clear,
|
||||
false /* acquire_unmodified */);
|
||||
}
|
||||
} else {
|
||||
transition_color_buffer(cmd_buffer, iview->image,
|
||||
|
|
@ -5448,7 +5489,8 @@ void genX(CmdBeginRendering)(
|
|||
initial_layout, att->imageLayout,
|
||||
VK_QUEUE_FAMILY_IGNORED,
|
||||
VK_QUEUE_FAMILY_IGNORED,
|
||||
fast_clear);
|
||||
fast_clear,
|
||||
false /* acquire_unmodified */);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue