From: Eric Anholt Date: Tue, 28 Jul 2015 16:51:37 +0000 (-0700) Subject: vc4: Make the object be the return value from vc4_use_bo(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22954db71cd1d8d9ef6e5a16f568e4b3c7845777;p=mesa.git vc4: Make the object be the return value from vc4_use_bo(). Drops 40 bytes of code from validation. --- diff --git a/src/gallium/drivers/vc4/kernel/vc4_drv.h b/src/gallium/drivers/vc4/kernel/vc4_drv.h index 5c8617939c8..127a366fb3c 100644 --- a/src/gallium/drivers/vc4/kernel/vc4_drv.h +++ b/src/gallium/drivers/vc4/kernel/vc4_drv.h @@ -171,10 +171,9 @@ vc4_validate_shader_recs(struct drm_device *dev, struct vc4_exec_info *exec); struct vc4_validated_shader_info * vc4_validate_shader(struct drm_gem_cma_object *shader_obj); -bool vc4_use_bo(struct vc4_exec_info *exec, - uint32_t hindex, - enum vc4_bo_mode mode, - struct drm_gem_cma_object **obj); +struct drm_gem_cma_object *vc4_use_bo(struct vc4_exec_info *exec, + uint32_t hindex, + enum vc4_bo_mode mode); int vc4_get_rcl(struct drm_device *dev, struct vc4_exec_info *exec); diff --git a/src/gallium/drivers/vc4/kernel/vc4_render_cl.c b/src/gallium/drivers/vc4/kernel/vc4_render_cl.c index f55ffe5a8db..a0681042155 100644 --- a/src/gallium/drivers/vc4/kernel/vc4_render_cl.c +++ b/src/gallium/drivers/vc4/kernel/vc4_render_cl.c @@ -286,7 +286,8 @@ static int vc4_rcl_surface_setup(struct vc4_exec_info *exec, if (surf->hindex == ~0) return 0; - if (!vc4_use_bo(exec, surf->hindex, VC4_MODE_RENDER, obj)) + *obj = vc4_use_bo(exec, surf->hindex, VC4_MODE_RENDER); + if (!*obj) return -EINVAL; if (surf->bits & ~(VC4_LOADSTORE_TILE_BUFFER_TILING_MASK | @@ -365,7 +366,8 @@ vc4_rcl_ms_surface_setup(struct vc4_exec_info *exec, if (surf->hindex == ~0) return 0; - if (!vc4_use_bo(exec, surf->hindex, VC4_MODE_RENDER, obj)) + *obj = vc4_use_bo(exec, surf->hindex, VC4_MODE_RENDER); + if (!*obj) return -EINVAL; if (tiling > VC4_TILING_FORMAT_LT) { diff --git a/src/gallium/drivers/vc4/kernel/vc4_validate.c b/src/gallium/drivers/vc4/kernel/vc4_validate.c index c57ebecbb24..321e8115f8f 100644 --- a/src/gallium/drivers/vc4/kernel/vc4_validate.c +++ b/src/gallium/drivers/vc4/kernel/vc4_validate.c @@ -94,19 +94,19 @@ size_is_lt(uint32_t width, uint32_t height, int cpp) height <= 4 * utile_height(cpp)); } -bool +struct drm_gem_cma_object * vc4_use_bo(struct vc4_exec_info *exec, uint32_t hindex, - enum vc4_bo_mode mode, - struct drm_gem_cma_object **obj) + enum vc4_bo_mode mode) { - *obj = NULL; + struct drm_gem_cma_object *obj; if (hindex >= exec->bo_count) { DRM_ERROR("BO index %d greater than BO count %d\n", hindex, exec->bo_count); - return false; + return NULL; } + obj = exec->bo[hindex].bo; if (exec->bo[hindex].mode != mode) { if (exec->bo[hindex].mode == VC4_MODE_UNDECIDED) { @@ -114,22 +114,19 @@ vc4_use_bo(struct vc4_exec_info *exec, } else { DRM_ERROR("BO index %d reused with mode %d vs %d\n", hindex, exec->bo[hindex].mode, mode); - return false; + return NULL; } } - *obj = exec->bo[hindex].bo; - return true; + return obj; } -static bool +static struct drm_gem_cma_object * vc4_use_handle(struct vc4_exec_info *exec, uint32_t gem_handles_packet_index, - enum vc4_bo_mode mode, - struct drm_gem_cma_object **obj) + enum vc4_bo_mode mode) { - return vc4_use_bo(exec, exec->bo_index[gem_handles_packet_index], - mode, obj); + return vc4_use_bo(exec, exec->bo_index[gem_handles_packet_index], mode); } static bool @@ -273,7 +270,8 @@ validate_indexed_prim_list(VALIDATE_ARGS) if (max_index > shader_state->max_index) shader_state->max_index = max_index; - if (!vc4_use_handle(exec, 0, VC4_MODE_RENDER, &ib)) + ib = vc4_use_handle(exec, 0, VC4_MODE_RENDER); + if (!ib) return -EINVAL; if (offset > ib->base.size || @@ -590,7 +588,8 @@ reloc_tex(struct vc4_exec_info *exec, uint32_t cube_map_stride = 0; enum vc4_texture_data_type type; - if (!vc4_use_bo(exec, texture_handle_index, VC4_MODE_RENDER, &tex)) + tex = vc4_use_bo(exec, texture_handle_index, VC4_MODE_RENDER); + if (!tex) return false; if (sample->is_direct) { @@ -789,11 +788,13 @@ validate_gl_shader_rec(struct drm_device *dev, exec->shader_rec_size -= packet_size; for (i = 0; i < shader_reloc_count; i++) { - if (!vc4_use_bo(exec, src_handles[i], VC4_MODE_SHADER, &bo[i])) + bo[i] = vc4_use_bo(exec, src_handles[i], VC4_MODE_SHADER); + if (!bo[i]) return false; } for (i = shader_reloc_count; i < nr_relocs; i++) { - if (!vc4_use_bo(exec, src_handles[i], VC4_MODE_RENDER, &bo[i])) + bo[i] = vc4_use_bo(exec, src_handles[i], VC4_MODE_RENDER); + if (!bo[i]) return false; }