diff options
author | Eric Anholt <[email protected]> | 2015-07-28 10:20:10 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2015-07-28 19:35:26 -0700 |
commit | 1f5e070dd7ddd344a913f2f5daddebb4c51abb8a (patch) | |
tree | df946fe4d40be76a32b2822a168ae1a027da6ee0 /src/gallium/drivers/vc4/kernel | |
parent | 044f7bbda077ea7029fb1004183b29127307bd84 (diff) |
vc4: Simplify vc4_use_bo and make sure it's not a shader.
Since the conversion to keeping validated shaders around for the BO's
lifetime, we haven't been checking that rendering doesn't happen to
shaders. Make vc4_use_bo check that always, and just don't use it for the
VC4_MODE_SHADER case (so now modes are unused)
Diffstat (limited to 'src/gallium/drivers/vc4/kernel')
-rw-r--r-- | src/gallium/drivers/vc4/kernel/vc4_drv.h | 16 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/kernel/vc4_render_cl.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/kernel/vc4_validate.c | 39 |
3 files changed, 23 insertions, 36 deletions
diff --git a/src/gallium/drivers/vc4/kernel/vc4_drv.h b/src/gallium/drivers/vc4/kernel/vc4_drv.h index 127a366fb3c..ffc973735ae 100644 --- a/src/gallium/drivers/vc4/kernel/vc4_drv.h +++ b/src/gallium/drivers/vc4/kernel/vc4_drv.h @@ -26,17 +26,6 @@ #include "vc4_simulator_validate.h" -enum vc4_bo_mode { - VC4_MODE_UNDECIDED, - VC4_MODE_RENDER, - VC4_MODE_SHADER, -}; - -struct vc4_bo_exec_state { - struct drm_gem_cma_object *bo; - enum vc4_bo_mode mode; -}; - struct vc4_exec_info { /* Sequence number for this bin/render job. */ uint64_t seqno; @@ -47,7 +36,7 @@ struct vc4_exec_info { /* This is the array of BOs that were looked up at the start of exec. * Command validation will use indices into this array. */ - struct vc4_bo_exec_state *bo; + struct drm_gem_cma_object **bo; uint32_t bo_count; /* List of other BOs used in the job that need to be released @@ -172,8 +161,7 @@ struct vc4_validated_shader_info * vc4_validate_shader(struct drm_gem_cma_object *shader_obj); struct drm_gem_cma_object *vc4_use_bo(struct vc4_exec_info *exec, - uint32_t hindex, - enum vc4_bo_mode mode); + uint32_t hindex); 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 a0681042155..b827eb7e9e1 100644 --- a/src/gallium/drivers/vc4/kernel/vc4_render_cl.c +++ b/src/gallium/drivers/vc4/kernel/vc4_render_cl.c @@ -286,7 +286,7 @@ static int vc4_rcl_surface_setup(struct vc4_exec_info *exec, if (surf->hindex == ~0) return 0; - *obj = vc4_use_bo(exec, surf->hindex, VC4_MODE_RENDER); + *obj = vc4_use_bo(exec, surf->hindex); if (!*obj) return -EINVAL; @@ -366,7 +366,7 @@ vc4_rcl_ms_surface_setup(struct vc4_exec_info *exec, if (surf->hindex == ~0) return 0; - *obj = vc4_use_bo(exec, surf->hindex, VC4_MODE_RENDER); + *obj = vc4_use_bo(exec, surf->hindex); if (!*obj) return -EINVAL; diff --git a/src/gallium/drivers/vc4/kernel/vc4_validate.c b/src/gallium/drivers/vc4/kernel/vc4_validate.c index 49bb64838ea..e81dd9935ca 100644 --- a/src/gallium/drivers/vc4/kernel/vc4_validate.c +++ b/src/gallium/drivers/vc4/kernel/vc4_validate.c @@ -95,38 +95,32 @@ size_is_lt(uint32_t width, uint32_t height, int cpp) } struct drm_gem_cma_object * -vc4_use_bo(struct vc4_exec_info *exec, - uint32_t hindex, - enum vc4_bo_mode mode) +vc4_use_bo(struct vc4_exec_info *exec, uint32_t hindex) { struct drm_gem_cma_object *obj; + struct drm_vc4_bo *bo; if (hindex >= exec->bo_count) { DRM_ERROR("BO index %d greater than BO count %d\n", hindex, exec->bo_count); return NULL; } - obj = exec->bo[hindex].bo; + obj = exec->bo[hindex]; + bo = to_vc4_bo(&obj->base); - if (exec->bo[hindex].mode != mode) { - if (exec->bo[hindex].mode == VC4_MODE_UNDECIDED) { - exec->bo[hindex].mode = mode; - } else { - DRM_ERROR("BO index %d reused with mode %d vs %d\n", - hindex, exec->bo[hindex].mode, mode); - return NULL; - } + if (bo->validated_shader) { + DRM_ERROR("Trying to use shader BO as something other than " + "a shader\n"); + return NULL; } return obj; } 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) +vc4_use_handle(struct vc4_exec_info *exec, uint32_t gem_handles_packet_index) { - return vc4_use_bo(exec, exec->bo_index[gem_handles_packet_index], mode); + return vc4_use_bo(exec, exec->bo_index[gem_handles_packet_index]); } static bool @@ -270,7 +264,7 @@ validate_indexed_prim_list(VALIDATE_ARGS) if (max_index > shader_state->max_index) shader_state->max_index = max_index; - ib = vc4_use_handle(exec, 0, VC4_MODE_RENDER); + ib = vc4_use_handle(exec, 0); if (!ib) return -EINVAL; @@ -588,7 +582,7 @@ reloc_tex(struct vc4_exec_info *exec, uint32_t cube_map_stride = 0; enum vc4_texture_data_type type; - tex = vc4_use_bo(exec, texture_handle_index, VC4_MODE_RENDER); + tex = vc4_use_bo(exec, texture_handle_index); if (!tex) return false; @@ -787,12 +781,17 @@ validate_gl_shader_rec(struct drm_device *dev, exec->shader_rec_size -= packet_size; for (i = 0; i < shader_reloc_count; i++) { - bo[i] = vc4_use_bo(exec, src_handles[i], VC4_MODE_SHADER); + if (src_handles[i] > exec->bo_count) { + DRM_ERROR("Shader handle %d too big\n", src_handles[i]); + return false; + } + + bo[i] = exec->bo[src_handles[i]]; if (!bo[i]) return false; } for (i = shader_reloc_count; i < nr_relocs; i++) { - bo[i] = vc4_use_bo(exec, src_handles[i], VC4_MODE_RENDER); + bo[i] = vc4_use_bo(exec, src_handles[i]); if (!bo[i]) return false; } |