venus: add vn_ring_get_id and hide vn_ring internals entirely
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26179>
This commit is contained in:
parent
9e38c74139
commit
a0ef347a82
5 changed files with 53 additions and 43 deletions
|
|
@ -70,11 +70,11 @@ vn_device_memory_wait_alloc(struct vn_device *dev,
|
|||
/* fine to false it here since renderer submission failure is fatal */
|
||||
mem->bo_ring_seqno_valid = false;
|
||||
|
||||
const uint64_t ring_id = vn_ring_get_id(dev->instance->ring.ring);
|
||||
uint32_t local_data[8];
|
||||
struct vn_cs_encoder local_enc =
|
||||
VN_CS_ENCODER_INITIALIZER_LOCAL(local_data, sizeof(local_data));
|
||||
vn_encode_vkWaitRingSeqnoMESA(&local_enc, 0, dev->instance->ring.ring->id,
|
||||
mem->bo_ring_seqno);
|
||||
vn_encode_vkWaitRingSeqnoMESA(&local_enc, 0, ring_id, mem->bo_ring_seqno);
|
||||
return vn_renderer_submit_simple(dev->renderer, local_data,
|
||||
vn_cs_encoder_get_len(&local_enc));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,14 +213,14 @@ VkResult
|
|||
vn_instance_submit_roundtrip(struct vn_instance *instance,
|
||||
uint64_t *roundtrip_seqno)
|
||||
{
|
||||
const uint64_t ring_id = vn_ring_get_id(instance->ring.ring);
|
||||
uint32_t local_data[8];
|
||||
struct vn_cs_encoder local_enc =
|
||||
VN_CS_ENCODER_INITIALIZER_LOCAL(local_data, sizeof(local_data));
|
||||
|
||||
mtx_lock(&instance->ring.roundtrip_mutex);
|
||||
const uint64_t seqno = instance->ring.roundtrip_next++;
|
||||
vn_encode_vkSubmitVirtqueueSeqnoMESA(&local_enc, 0,
|
||||
instance->ring.ring->id, seqno);
|
||||
vn_encode_vkSubmitVirtqueueSeqnoMESA(&local_enc, 0, ring_id, seqno);
|
||||
VkResult result = vn_renderer_submit_simple(
|
||||
instance->renderer, local_data, vn_cs_encoder_get_len(&local_enc));
|
||||
mtx_unlock(&instance->ring.roundtrip_mutex);
|
||||
|
|
|
|||
|
|
@ -1044,7 +1044,8 @@ vn_queue_wsi_present(struct vn_queue_submission *submit)
|
|||
struct vn_cs_encoder local_enc =
|
||||
VN_CS_ENCODER_INITIALIZER_LOCAL(local_data, sizeof(local_data));
|
||||
if (submit->external_payload.ring_seqno_valid) {
|
||||
vn_encode_vkWaitRingSeqnoMESA(&local_enc, 0, instance->ring.ring->id,
|
||||
const uint64_t ring_id = vn_ring_get_id(instance->ring.ring);
|
||||
vn_encode_vkWaitRingSeqnoMESA(&local_enc, 0, ring_id,
|
||||
submit->external_payload.ring_seqno);
|
||||
batch.cs_data = local_data;
|
||||
batch.cs_size = vn_cs_encoder_get_len(&local_enc);
|
||||
|
|
@ -1832,8 +1833,8 @@ vn_create_sync_file(struct vn_device *dev,
|
|||
struct vn_cs_encoder local_enc =
|
||||
VN_CS_ENCODER_INITIALIZER_LOCAL(local_data, sizeof(local_data));
|
||||
if (external_payload->ring_seqno_valid) {
|
||||
vn_encode_vkWaitRingSeqnoMESA(&local_enc, 0,
|
||||
dev->instance->ring.ring->id,
|
||||
const uint64_t ring_id = vn_ring_get_id(dev->instance->ring.ring);
|
||||
vn_encode_vkWaitRingSeqnoMESA(&local_enc, 0, ring_id,
|
||||
external_payload->ring_seqno);
|
||||
batch.cs_data = local_data;
|
||||
batch.cs_size = vn_cs_encoder_get_len(&local_enc);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,42 @@
|
|||
#include "vn_instance.h"
|
||||
#include "vn_renderer.h"
|
||||
|
||||
static_assert(ATOMIC_INT_LOCK_FREE == 2 && sizeof(atomic_uint) == 4,
|
||||
"vn_ring_shared requires lock-free 32-bit atomic_uint");
|
||||
|
||||
/* pointers to a ring in a BO */
|
||||
struct vn_ring_shared {
|
||||
const volatile atomic_uint *head;
|
||||
volatile atomic_uint *tail;
|
||||
volatile atomic_uint *status;
|
||||
void *buffer;
|
||||
void *extra;
|
||||
};
|
||||
|
||||
struct vn_ring {
|
||||
uint64_t id;
|
||||
struct vn_instance *instance;
|
||||
struct vn_renderer_shmem *shmem;
|
||||
|
||||
uint32_t buffer_size;
|
||||
uint32_t buffer_mask;
|
||||
|
||||
struct vn_ring_shared shared;
|
||||
uint32_t cur;
|
||||
|
||||
/* This mutex ensures below:
|
||||
* - atomic of ring submission
|
||||
* - reply shmem resource set and ring submission are paired
|
||||
*/
|
||||
mtx_t mutex;
|
||||
|
||||
/* used for indirect submission of large command (non-VkCommandBuffer) */
|
||||
struct vn_cs_encoder upload;
|
||||
|
||||
struct list_head submits;
|
||||
struct list_head free_submits;
|
||||
};
|
||||
|
||||
struct vn_ring_submit {
|
||||
uint32_t seqno;
|
||||
|
||||
|
|
@ -307,6 +343,12 @@ vn_ring_destroy(struct vn_ring *ring)
|
|||
vk_free(alloc, ring);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
vn_ring_get_id(struct vn_ring *ring)
|
||||
{
|
||||
return ring->id;
|
||||
}
|
||||
|
||||
static struct vn_ring_submit *
|
||||
vn_ring_get_submit(struct vn_ring *ring, uint32_t shmem_count)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,42 +39,6 @@ struct vn_ring_layout {
|
|||
size_t shmem_size;
|
||||
};
|
||||
|
||||
static_assert(ATOMIC_INT_LOCK_FREE == 2 && sizeof(atomic_uint) == 4,
|
||||
"vn_ring_shared requires lock-free 32-bit atomic_uint");
|
||||
|
||||
/* pointers to a ring in a BO */
|
||||
struct vn_ring_shared {
|
||||
const volatile atomic_uint *head;
|
||||
volatile atomic_uint *tail;
|
||||
volatile atomic_uint *status;
|
||||
void *buffer;
|
||||
void *extra;
|
||||
};
|
||||
|
||||
struct vn_ring {
|
||||
uint64_t id;
|
||||
struct vn_instance *instance;
|
||||
struct vn_renderer_shmem *shmem;
|
||||
|
||||
uint32_t buffer_size;
|
||||
uint32_t buffer_mask;
|
||||
|
||||
struct vn_ring_shared shared;
|
||||
uint32_t cur;
|
||||
|
||||
/* This mutex ensures below:
|
||||
* - atomic of ring submission
|
||||
* - reply shmem resource set and ring submission are paired
|
||||
*/
|
||||
mtx_t mutex;
|
||||
|
||||
/* used for indirect submission of large command (non-VkCommandBuffer) */
|
||||
struct vn_cs_encoder upload;
|
||||
|
||||
struct list_head submits;
|
||||
struct list_head free_submits;
|
||||
};
|
||||
|
||||
void
|
||||
vn_ring_get_layout(size_t buf_size,
|
||||
size_t extra_size,
|
||||
|
|
@ -87,6 +51,9 @@ vn_ring_create(struct vn_instance *instance,
|
|||
void
|
||||
vn_ring_destroy(struct vn_ring *ring);
|
||||
|
||||
uint64_t
|
||||
vn_ring_get_id(struct vn_ring *ring);
|
||||
|
||||
uint32_t
|
||||
vn_ring_load_status(const struct vn_ring *ring);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue