v3dv: implement VK_KHR_buffer_device_address
This feature allows shaders to use pointers to buffers which may not be bound via descriptor sets. Access to these buffers is done via global intrinsics. Because the buffers are not accessed through descriptor sets, any live buffer flagged with VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR can be accessed by any shader using global intrinsics, so the driver needs to make sure all these buffers are mapped by the kernel when it submits the job for execution. We handle this by tracking if any draw call or compute dispatch in a job uses a pipeline that has any such shaders. If so, the job is flagged as using buffer device address and the kernel submission for that job will add all live BOs bound to buffers flagged with the buffer device address usage flag. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17275>
This commit is contained in:
@@ -770,6 +770,17 @@ handle_cl_job(struct v3dv_queue *queue,
|
||||
if (job->tmu_dirty_rcl)
|
||||
submit.flags |= DRM_V3D_SUBMIT_CL_FLUSH_CACHE;
|
||||
|
||||
/* If the job uses VK_KHR_buffer_device_addess we need to ensure all
|
||||
* buffers flagged with VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR
|
||||
* are included.
|
||||
*/
|
||||
if (job->uses_buffer_device_address) {
|
||||
util_dynarray_foreach(&queue->device->device_address_bo_list,
|
||||
struct v3dv_bo *, bo) {
|
||||
v3dv_job_add_bo(job, *bo);
|
||||
}
|
||||
}
|
||||
|
||||
submit.bo_handle_count = job->bo_count;
|
||||
uint32_t *bo_handles =
|
||||
(uint32_t *) malloc(sizeof(uint32_t) * submit.bo_handle_count);
|
||||
@@ -913,6 +924,17 @@ handle_csd_job(struct v3dv_queue *queue,
|
||||
|
||||
struct drm_v3d_submit_csd *submit = &job->csd.submit;
|
||||
|
||||
/* If the job uses VK_KHR_buffer_device_addess we need to ensure all
|
||||
* buffers flagged with VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR
|
||||
* are included.
|
||||
*/
|
||||
if (job->uses_buffer_device_address) {
|
||||
util_dynarray_foreach(&queue->device->device_address_bo_list,
|
||||
struct v3dv_bo *, bo) {
|
||||
v3dv_job_add_bo(job, *bo);
|
||||
}
|
||||
}
|
||||
|
||||
submit->bo_handle_count = job->bo_count;
|
||||
uint32_t *bo_handles =
|
||||
(uint32_t *) malloc(sizeof(uint32_t) * MAX2(4, submit->bo_handle_count * 2));
|
||||
|
||||
Reference in New Issue
Block a user