From 0e476f6c03d6273247c3d67484d5ca09f3782225 Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Tue, 7 Feb 2017 17:08:07 +0100 Subject: winsys/amdgpu: share common code in amdgpu_add_fence_dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 38 ++++++++++++++----------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c index 0381359ab79..2520affc1e4 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c @@ -994,36 +994,32 @@ static void amdgpu_add_fence(struct amdgpu_winsys_bo *bo, bo->num_fences++; } +static void amdgpu_add_fence_dependencies_list(struct amdgpu_cs *acs, + struct pipe_fence_handle *fence, + unsigned num_buffers, + struct amdgpu_cs_buffer *buffers) +{ + for (unsigned i = 0; i < num_buffers; i++) { + struct amdgpu_cs_buffer *buffer = &buffers[i]; + struct amdgpu_winsys_bo *bo = buffer->bo; + + amdgpu_add_fence_dependency(acs, buffer); + p_atomic_inc(&bo->num_active_ioctls); + amdgpu_add_fence(bo, fence); + } +} + /* Since the kernel driver doesn't synchronize execution between different * rings automatically, we have to add fence dependencies manually. */ static void amdgpu_add_fence_dependencies(struct amdgpu_cs *acs) { struct amdgpu_cs_context *cs = acs->csc; - unsigned num_buffers; - int i; cs->request.number_of_dependencies = 0; - num_buffers = cs->num_real_buffers; - for (i = 0; i < num_buffers; i++) { - struct amdgpu_cs_buffer *buffer = &cs->real_buffers[i]; - struct amdgpu_winsys_bo *bo = buffer->bo; - - amdgpu_add_fence_dependency(acs, buffer); - p_atomic_inc(&bo->num_active_ioctls); - amdgpu_add_fence(bo, cs->fence); - } - - num_buffers = cs->num_slab_buffers; - for (i = 0; i < num_buffers; i++) { - struct amdgpu_cs_buffer *buffer = &cs->slab_buffers[i]; - struct amdgpu_winsys_bo *bo = buffer->bo; - - amdgpu_add_fence_dependency(acs, buffer); - p_atomic_inc(&bo->num_active_ioctls); - amdgpu_add_fence(bo, cs->fence); - } + amdgpu_add_fence_dependencies_list(acs, cs->fence, cs->num_real_buffers, cs->real_buffers); + amdgpu_add_fence_dependencies_list(acs, cs->fence, cs->num_slab_buffers, cs->slab_buffers); } void amdgpu_cs_submit_ib(void *job, int thread_index) -- cgit v1.2.3