mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-12-01 06:04:12 +08:00
venus: switch to use 64bit roundtrip seqno
This is to prepare for later async roundtrip waiting while seamlessly compatible with legacy way. Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21716>
This commit is contained in:
parent
932073d3e6
commit
9b7a78cac6
@ -31,7 +31,7 @@ struct vn_device_memory {
|
||||
struct vn_renderer_bo *base_bo;
|
||||
/* enforce kernel and ring ordering between memory export and free */
|
||||
bool bo_roundtrip_seqno_valid;
|
||||
uint32_t bo_roundtrip_seqno;
|
||||
uint64_t bo_roundtrip_seqno;
|
||||
VkDeviceSize base_offset;
|
||||
|
||||
VkDeviceSize map_end;
|
||||
|
@ -277,7 +277,7 @@ vn_instance_init_renderer(struct vn_instance *instance)
|
||||
|
||||
VkResult
|
||||
vn_instance_submit_roundtrip(struct vn_instance *instance,
|
||||
uint32_t *roundtrip_seqno)
|
||||
uint64_t *roundtrip_seqno)
|
||||
{
|
||||
uint32_t write_ring_extra_data[8];
|
||||
struct vn_cs_encoder local_enc = VN_CS_ENCODER_INITIALIZER_LOCAL(
|
||||
@ -285,7 +285,8 @@ vn_instance_submit_roundtrip(struct vn_instance *instance,
|
||||
|
||||
/* submit a vkWriteRingExtraMESA through the renderer */
|
||||
mtx_lock(&instance->ring.roundtrip_mutex);
|
||||
const uint32_t seqno = instance->ring.roundtrip_next++;
|
||||
const uint64_t seqno = instance->ring.roundtrip_next++;
|
||||
/* clamp to 32bit for legacy ring extra based roundtrip waiting */
|
||||
vn_encode_vkWriteRingExtraMESA(&local_enc, 0, instance->ring.id, 0, seqno);
|
||||
VkResult result =
|
||||
vn_renderer_submit_simple(instance->renderer, write_ring_extra_data,
|
||||
@ -305,7 +306,7 @@ roundtrip_seqno_ge(uint32_t a, uint32_t b)
|
||||
|
||||
void
|
||||
vn_instance_wait_roundtrip(struct vn_instance *instance,
|
||||
uint32_t roundtrip_seqno)
|
||||
uint64_t roundtrip_seqno)
|
||||
{
|
||||
VN_TRACE_FUNC();
|
||||
const struct vn_ring *ring = &instance->ring.ring;
|
||||
@ -313,6 +314,7 @@ vn_instance_wait_roundtrip(struct vn_instance *instance,
|
||||
uint32_t iter = 0;
|
||||
do {
|
||||
const uint32_t cur = atomic_load_explicit(ptr, memory_order_acquire);
|
||||
/* clamp to 32bit for legacy ring extra based roundtrip waiting */
|
||||
if (roundtrip_seqno_ge(cur, roundtrip_seqno))
|
||||
break;
|
||||
vn_relax(ring, &iter, "roundtrip");
|
||||
|
@ -55,7 +55,7 @@ struct vn_instance {
|
||||
|
||||
/* to synchronize renderer/ring */
|
||||
mtx_t roundtrip_mutex;
|
||||
uint32_t roundtrip_next;
|
||||
uint64_t roundtrip_next;
|
||||
} ring;
|
||||
|
||||
/* XXX staged features to be merged to core venus protocol */
|
||||
@ -95,16 +95,16 @@ VK_DEFINE_HANDLE_CASTS(vn_instance,
|
||||
|
||||
VkResult
|
||||
vn_instance_submit_roundtrip(struct vn_instance *instance,
|
||||
uint32_t *roundtrip_seqno);
|
||||
uint64_t *roundtrip_seqno);
|
||||
|
||||
void
|
||||
vn_instance_wait_roundtrip(struct vn_instance *instance,
|
||||
uint32_t roundtrip_seqno);
|
||||
uint64_t roundtrip_seqno);
|
||||
|
||||
static inline void
|
||||
vn_instance_roundtrip(struct vn_instance *instance)
|
||||
{
|
||||
uint32_t roundtrip_seqno;
|
||||
uint64_t roundtrip_seqno;
|
||||
if (vn_instance_submit_roundtrip(instance, &roundtrip_seqno) == VK_SUCCESS)
|
||||
vn_instance_wait_roundtrip(instance, roundtrip_seqno);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user