vc4: Make the object be the return value from vc4_use_bo().
authorEric Anholt <eric@anholt.net>
Tue, 28 Jul 2015 16:51:37 +0000 (09:51 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 29 Jul 2015 02:35:26 +0000 (19:35 -0700)
Drops 40 bytes of code from validation.

src/gallium/drivers/vc4/kernel/vc4_drv.h
src/gallium/drivers/vc4/kernel/vc4_render_cl.c
src/gallium/drivers/vc4/kernel/vc4_validate.c

index 5c8617939c8c7fe10a5102e71390278c66e46701..127a366fb3c845b41f6f4068dd61e19978b0998f 100644 (file)
@@ -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);
 
index f55ffe5a8db5986fe10d80042121fd0172cb3b16..a0681042155f797bb936fe3bc5578e80731bb753 100644 (file)
@@ -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) {
index c57ebecbb24a8616f47f6aedac3f56c20f83b19a..321e8115f8f4ac5383ecc94b2799f69c2cb8ac10 100644 (file)
@@ -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;
        }