mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
venus: refactor to add vn_sync_payload_external
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
891af34bca
commit
a37771b42a
2 changed files with 38 additions and 28 deletions
|
|
@ -63,9 +63,7 @@ struct vn_queue_submission {
|
|||
bool has_feedback_semaphore;
|
||||
const struct vn_device_memory *wsi_mem;
|
||||
uint32_t sem_cmd_buffer_count;
|
||||
|
||||
bool ring_seqno_valid;
|
||||
uint32_t ring_seqno;
|
||||
struct vn_sync_payload_external external;
|
||||
|
||||
/* Temporary storage allocation for submission
|
||||
* A single alloc for storage is performed and the offsets inside
|
||||
|
|
@ -285,6 +283,7 @@ vn_queue_submission_prepare(struct vn_queue_submission *submit)
|
|||
* - has an external signal semaphore
|
||||
*/
|
||||
struct vn_queue *queue = vn_queue_from_handle(submit->queue_handle);
|
||||
submit->external.ring_idx = queue->ring_idx;
|
||||
submit->synchronous =
|
||||
has_external_fence ||
|
||||
(!queue->device->instance->experimental.asyncRoundtrip &&
|
||||
|
|
@ -805,15 +804,15 @@ vn_queue_wsi_present(struct vn_queue_submission *submit)
|
|||
|
||||
if (dev->instance->renderer->info.has_implicit_fencing) {
|
||||
struct vn_renderer_submit_batch batch = {
|
||||
.ring_idx = queue->ring_idx,
|
||||
.ring_idx = submit->external.ring_idx,
|
||||
};
|
||||
|
||||
uint32_t local_data[8];
|
||||
struct vn_cs_encoder local_enc =
|
||||
VN_CS_ENCODER_INITIALIZER_LOCAL(local_data, sizeof(local_data));
|
||||
if (submit->ring_seqno_valid) {
|
||||
if (submit->external.ring_seqno_valid) {
|
||||
vn_encode_vkWaitRingSeqno100000MESA(&local_enc, 0, instance->ring.id,
|
||||
submit->ring_seqno);
|
||||
submit->external.ring_seqno);
|
||||
batch.cs_data = local_data;
|
||||
batch.cs_size = vn_cs_encoder_get_len(&local_enc);
|
||||
}
|
||||
|
|
@ -883,8 +882,8 @@ vn_queue_submit(struct vn_queue_submission *submit)
|
|||
vn_queue_submission_cleanup(submit);
|
||||
return vn_error(dev->instance, VK_ERROR_DEVICE_LOST);
|
||||
}
|
||||
submit->ring_seqno_valid = true;
|
||||
submit->ring_seqno = instance_submit.ring_seqno;
|
||||
submit->external.ring_seqno_valid = true;
|
||||
submit->external.ring_seqno = instance_submit.ring_seqno;
|
||||
}
|
||||
|
||||
/* If external fence, track the submission's ring_idx to facilitate
|
||||
|
|
@ -894,9 +893,10 @@ vn_queue_submit(struct vn_queue_submission *submit)
|
|||
* because an fd is already available.
|
||||
*/
|
||||
struct vn_fence *fence = vn_fence_from_handle(submit->fence_handle);
|
||||
if (fence && fence->is_external &&
|
||||
fence->payload->type == VN_SYNC_TYPE_DEVICE_ONLY)
|
||||
fence->ring_idx = queue->ring_idx;
|
||||
if (fence && fence->is_external) {
|
||||
assert(fence->payload->type == VN_SYNC_TYPE_DEVICE_ONLY);
|
||||
fence->external = submit->external;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < submit->batch_count; i++) {
|
||||
uint32_t signal_semaphore_count =
|
||||
|
|
@ -904,9 +904,9 @@ vn_queue_submit(struct vn_queue_submission *submit)
|
|||
for (uint32_t j = 0; j < signal_semaphore_count; j++) {
|
||||
struct vn_semaphore *sem =
|
||||
vn_semaphore_from_handle(vn_get_signal_semaphore(submit, i, j));
|
||||
if (sem->is_external &&
|
||||
sem->payload->type == VN_SYNC_TYPE_DEVICE_ONLY) {
|
||||
sem->ring_idx = queue->ring_idx;
|
||||
if (sem->is_external) {
|
||||
assert(sem->payload->type == VN_SYNC_TYPE_DEVICE_ONLY);
|
||||
sem->external = submit->external;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1351,7 +1351,9 @@ vn_WaitForFences(VkDevice device,
|
|||
}
|
||||
|
||||
static VkResult
|
||||
vn_create_sync_file(struct vn_device *dev, uint32_t ring_idx, int *out_fd)
|
||||
vn_create_sync_file(struct vn_device *dev,
|
||||
struct vn_sync_payload_external *payload,
|
||||
int *out_fd)
|
||||
{
|
||||
struct vn_renderer_sync *sync;
|
||||
VkResult result = vn_renderer_sync_create(dev->renderer, 0,
|
||||
|
|
@ -1365,7 +1367,7 @@ vn_create_sync_file(struct vn_device *dev, uint32_t ring_idx, int *out_fd)
|
|||
.syncs = &sync,
|
||||
.sync_values = &(const uint64_t){ 1 },
|
||||
.sync_count = 1,
|
||||
.ring_idx = ring_idx,
|
||||
.ring_idx = payload->ring_idx,
|
||||
},
|
||||
.batch_count = 1,
|
||||
};
|
||||
|
|
@ -1433,7 +1435,7 @@ vn_GetFenceFdKHR(VkDevice device,
|
|||
|
||||
int fd = -1;
|
||||
if (payload->type == VN_SYNC_TYPE_DEVICE_ONLY) {
|
||||
result = vn_create_sync_file(dev, fence->ring_idx, &fd);
|
||||
result = vn_create_sync_file(dev, &fence->external, &fd);
|
||||
if (result != VK_SUCCESS)
|
||||
return vn_error(dev->instance, result);
|
||||
|
||||
|
|
@ -1888,7 +1890,7 @@ vn_GetSemaphoreFdKHR(VkDevice device,
|
|||
|
||||
int fd = -1;
|
||||
if (payload->type == VN_SYNC_TYPE_DEVICE_ONLY) {
|
||||
VkResult result = vn_create_sync_file(dev, sem->ring_idx, &fd);
|
||||
VkResult result = vn_create_sync_file(dev, &sem->external, &fd);
|
||||
if (result != VK_SUCCESS)
|
||||
return vn_error(dev->instance, result);
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,22 @@ struct vn_sync_payload {
|
|||
int fd;
|
||||
};
|
||||
|
||||
/* For external fences and external semaphores submitted to be signaled. The
|
||||
* Vulkan spec guarantees those external syncs are on permanent payload.
|
||||
*/
|
||||
struct vn_sync_payload_external {
|
||||
/* ring_idx of the last queue submission */
|
||||
uint32_t ring_idx;
|
||||
/* ring_seqno_valid is false when:
|
||||
* - feature asyncRoundtrip is not supported by the renderer
|
||||
* - NO_ASYNC_QUEUE_SUBMIT perf option is used
|
||||
* - external fence and external semaphore
|
||||
*/
|
||||
bool ring_seqno_valid;
|
||||
/* ring seqno of the last queue submission */
|
||||
uint32_t ring_seqno;
|
||||
};
|
||||
|
||||
struct vn_fence {
|
||||
struct vn_object_base base;
|
||||
|
||||
|
|
@ -67,11 +83,7 @@ struct vn_fence {
|
|||
} feedback;
|
||||
|
||||
bool is_external;
|
||||
|
||||
/* ring_idx of the last queue submission (only used for permanent
|
||||
* payload of external fences)
|
||||
*/
|
||||
uint32_t ring_idx;
|
||||
struct vn_sync_payload_external external;
|
||||
};
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_fence,
|
||||
base.base,
|
||||
|
|
@ -121,11 +133,7 @@ struct vn_semaphore {
|
|||
} feedback;
|
||||
|
||||
bool is_external;
|
||||
|
||||
/* ring_idx of the last queue submission (only used for permanent
|
||||
* payload of external semaphores)
|
||||
*/
|
||||
uint32_t ring_idx;
|
||||
struct vn_sync_payload_external external;
|
||||
};
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_semaphore,
|
||||
base.base,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue