diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index d98cf8d8f8a..94ea83e7625 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -2452,6 +2452,18 @@ struct anv_vb_cache_range { uint64_t end; }; +static inline void +anv_merge_vb_cache_range(struct anv_vb_cache_range *dirty, + const struct anv_vb_cache_range *bound) +{ + if (dirty->start == dirty->end) { + *dirty = *bound; + } else if (bound->start != bound->end) { + dirty->start = MIN2(dirty->start, bound->start); + dirty->end = MAX2(dirty->end, bound->end); + } +} + /* Check whether we need to apply the Gfx8-9 vertex buffer workaround*/ static inline bool anv_gfx8_9_vb_cache_range_needs_workaround(struct anv_vb_cache_range *bound, @@ -2474,9 +2486,7 @@ anv_gfx8_9_vb_cache_range_needs_workaround(struct anv_vb_cache_range *bound, bound->start &= ~(64ull - 1ull); bound->end = align64(bound->end, 64); - /* Compute the dirty range */ - dirty->start = MIN2(dirty->start, bound->start); - dirty->end = MAX2(dirty->end, bound->end); + anv_merge_vb_cache_range(dirty, bound); /* If our range is larger than 32 bits, we have to flush */ assert(bound->end - bound->start <= (1ull << 32)); diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 12674d7ca05..3a7eb7a0a26 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -6657,10 +6657,7 @@ genX(cmd_buffer_update_dirty_vbs_for_gfx8_vb_flush)(struct anv_cmd_buffer *cmd_b struct anv_vb_cache_range *bound = &cmd_buffer->state.gfx.ib_bound_range; struct anv_vb_cache_range *dirty = &cmd_buffer->state.gfx.ib_dirty_range; - if (bound->end > bound->start) { - dirty->start = MIN2(dirty->start, bound->start); - dirty->end = MAX2(dirty->end, bound->end); - } + anv_merge_vb_cache_range(dirty, bound); } uint64_t mask = vb_used; @@ -6674,10 +6671,7 @@ genX(cmd_buffer_update_dirty_vbs_for_gfx8_vb_flush)(struct anv_cmd_buffer *cmd_b bound = &cmd_buffer->state.gfx.vb_bound_ranges[i]; dirty = &cmd_buffer->state.gfx.vb_dirty_ranges[i]; - if (bound->end > bound->start) { - dirty->start = MIN2(dirty->start, bound->start); - dirty->end = MAX2(dirty->end, bound->end); - } + anv_merge_vb_cache_range(dirty, bound); } } #endif /* GFX_VER == 9 */