From 8bcabd8fb7fff2d409d791e1cc3db1cf20ff6e1b Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Mon, 26 Aug 2024 12:18:35 +0200 Subject: [PATCH] pan/lib: Simplify pan_blitter now that we use vk_meta, we can remove a good chunk there. Signed-off-by: Mary Guillemard Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/lib/pan_blitter.c | 264 --------------------------------- src/panfrost/lib/pan_blitter.h | 27 ---- 2 files changed, 291 deletions(-) diff --git a/src/panfrost/lib/pan_blitter.c b/src/panfrost/lib/pan_blitter.c index 7c45f9cc501..d6a8491d5b4 100644 --- a/src/panfrost/lib/pan_blitter.c +++ b/src/panfrost/lib/pan_blitter.c @@ -822,38 +822,6 @@ out: pthread_mutex_unlock(&cache->rsds.lock); return rsd->address; } - -static mali_ptr -pan_blit_get_rsd(struct pan_blitter_cache *cache, - const struct pan_image_view *src_views, - const struct pan_image_view *dst_view) -{ - const struct util_format_description *desc = - util_format_description(src_views[0].format); - - struct pan_blitter_views views = {}; - - if (util_format_has_depth(desc)) { - views.src_z = &src_views[0]; - views.dst_z = dst_view; - } - - if (src_views[1].format) { - views.src_s = &src_views[1]; - views.dst_s = dst_view; - } else if (util_format_has_stencil(desc)) { - views.src_s = &src_views[0]; - views.dst_s = dst_view; - } - - if (!views.src_z && !views.src_s) { - views.rt_count = 1; - views.src_rts[0] = src_views; - views.dst_rts[0] = dst_view; - } - - return pan_blitter_get_rsd(cache, &views); -} #endif static struct pan_blitter_views @@ -1258,39 +1226,6 @@ pan_preload_emit_dcd(struct pan_blitter_cache *cache, #endif } -#if PAN_ARCH <= 7 -static void * -pan_blit_emit_tiler_job(struct pan_pool *pool, struct pan_jc *jc, - mali_ptr tiler, struct panfrost_ptr *job) -{ - *job = pan_pool_alloc_desc(pool, TILER_JOB); - - pan_section_pack(job->cpu, TILER_JOB, PRIMITIVE, cfg) { - cfg.draw_mode = MALI_DRAW_MODE_TRIANGLE_STRIP; - cfg.index_count = 4; - cfg.job_task_split = 6; - } - - pan_section_pack(job->cpu, TILER_JOB, PRIMITIVE_SIZE, cfg) { - cfg.constant = 1.0f; - } - - void *invoc = pan_section_ptr(job->cpu, TILER_JOB, INVOCATION); - panfrost_pack_work_groups_compute(invoc, 1, 4, 1, 1, 1, 1, true, false); - -#if PAN_ARCH >= 6 - pan_section_pack(job->cpu, TILER_JOB, PADDING, cfg) - ; - pan_section_pack(job->cpu, TILER_JOB, TILER, cfg) { - cfg.address = tiler; - } -#endif - - pan_jc_add_job(jc, MALI_JOB_TYPE_TILER, false, false, 0, 0, job, false); - return pan_section_ptr(job->cpu, TILER_JOB, DRAW); -} -#endif - #if PAN_ARCH >= 6 static void pan_preload_fb_alloc_pre_post_dcds(struct pan_pool *desc_pool, @@ -1450,205 +1385,6 @@ GENX(pan_preload_fb)(struct pan_blitter_cache *cache, struct pan_pool *pool, return njobs; } -#if PAN_ARCH <= 7 -void -GENX(pan_blit_ctx_init)(struct pan_blitter_cache *cache, - const struct pan_blit_info *info, - struct pan_pool *blit_pool, - struct pan_blit_context *ctx) -{ - memset(ctx, 0, sizeof(*ctx)); - - struct pan_image_view sviews[2] = { - { - .format = info->src.planes[0].format, - .planes = - { - info->src.planes[0].image, - info->src.planes[1].image, - info->src.planes[2].image, - }, - .dim = - info->src.planes[0].image->layout.dim == MALI_TEXTURE_DIMENSION_CUBE - ? MALI_TEXTURE_DIMENSION_2D - : info->src.planes[0].image->layout.dim, - .first_level = info->src.level, - .last_level = info->src.level, - .first_layer = info->src.start.layer, - .last_layer = info->src.end.layer, - .swizzle = - { - PIPE_SWIZZLE_X, - PIPE_SWIZZLE_Y, - PIPE_SWIZZLE_Z, - PIPE_SWIZZLE_W, - }, - }, - }; - - struct pan_image_view dview = { - .format = info->dst.planes[0].format, - .planes = - { - info->dst.planes[0].image, - info->dst.planes[1].image, - info->dst.planes[2].image, - }, - .dim = info->dst.planes[0].image->layout.dim == MALI_TEXTURE_DIMENSION_1D - ? MALI_TEXTURE_DIMENSION_1D - : MALI_TEXTURE_DIMENSION_2D, - .first_level = info->dst.level, - .last_level = info->dst.level, - .first_layer = info->dst.start.layer, - .last_layer = info->dst.start.layer, - .swizzle = - { - PIPE_SWIZZLE_X, - PIPE_SWIZZLE_Y, - PIPE_SWIZZLE_Z, - PIPE_SWIZZLE_W, - }, - }; - - ctx->src.start.x = info->src.start.x; - ctx->src.start.y = info->src.start.y; - ctx->src.end.x = info->src.end.x; - ctx->src.end.y = info->src.end.y; - ctx->src.dim = sviews[0].dim; - - if (info->dst.planes[0].image->layout.dim == MALI_TEXTURE_DIMENSION_3D) { - unsigned max_z = - u_minify(info->dst.planes[0].image->layout.depth, info->dst.level) - 1; - - ctx->z_scale = (float)(info->src.end.z - info->src.start.z) / - (info->dst.end.z - info->dst.start.z); - assert(info->dst.start.z != info->dst.end.z); - if (info->dst.start.z > info->dst.end.z) { - ctx->dst.cur_layer = info->dst.start.z - 1; - ctx->dst.last_layer = info->dst.end.z; - } else { - ctx->dst.cur_layer = info->dst.start.z; - ctx->dst.last_layer = info->dst.end.z - 1; - } - ctx->dst.cur_layer = MIN2(MAX2(ctx->dst.cur_layer, 0), max_z); - ctx->dst.last_layer = MIN2(MAX2(ctx->dst.last_layer, 0), max_z); - ctx->dst.layer_offset = ctx->dst.cur_layer; - } else { - unsigned max_layer = info->dst.planes[0].image->layout.array_size - 1; - ctx->dst.layer_offset = info->dst.start.layer; - ctx->dst.cur_layer = info->dst.start.layer; - ctx->dst.last_layer = MIN2(info->dst.end.layer, max_layer); - ctx->z_scale = 1; - } - - if (sviews[0].dim == MALI_TEXTURE_DIMENSION_3D) { - if (info->src.start.z < info->src.end.z) - ctx->src.z_offset = info->src.start.z + fabs(ctx->z_scale * 0.5f); - else - ctx->src.z_offset = info->src.start.z - fabs(ctx->z_scale * 0.5f); - } else { - ctx->src.layer_offset = info->src.start.layer; - } - - /* Split depth and stencil */ - if (util_format_is_depth_and_stencil(sviews[0].format)) { - sviews[1] = sviews[0]; - sviews[0].format = util_format_get_depth_only(sviews[0].format); - sviews[1].format = util_format_stencil_only(sviews[1].format); - } else if (info->src.planes[1].format) { - sviews[1] = sviews[0]; - sviews[1].format = info->src.planes[1].format; - sviews[1].planes[0] = info->src.planes[1].image; - } - - ctx->rsd = pan_blit_get_rsd(cache, sviews, &dview); - - ASSERTED unsigned nlayers = info->src.end.layer - info->src.start.layer + 1; - - assert(nlayers == (info->dst.end.layer - info->dst.start.layer + 1)); - - unsigned dst_w = - u_minify(info->dst.planes[0].image->layout.width, info->dst.level); - unsigned dst_h = - u_minify(info->dst.planes[0].image->layout.height, info->dst.level); - unsigned maxx = MIN2(MAX2(info->dst.start.x, info->dst.end.x), dst_w - 1); - unsigned maxy = MIN2(MAX2(info->dst.start.y, info->dst.end.y), dst_h - 1); - unsigned minx = MAX2(MIN3(info->dst.start.x, info->dst.end.x, maxx), 0); - unsigned miny = MAX2(MIN3(info->dst.start.y, info->dst.end.y, maxy), 0); - - if (info->scissor.enable) { - minx = MAX2(minx, info->scissor.minx); - miny = MAX2(miny, info->scissor.miny); - maxx = MIN2(maxx, info->scissor.maxx); - maxy = MIN2(maxy, info->scissor.maxy); - } - - const struct pan_image_view *sview_ptrs[] = {&sviews[0], &sviews[1]}; - unsigned nviews = sviews[1].format ? 2 : 1; - - ctx->textures = pan_blitter_emit_textures(blit_pool, nviews, sview_ptrs); - ctx->samplers = pan_blitter_emit_sampler(blit_pool, info->nearest); - - ctx->vpd = pan_blitter_emit_viewport(blit_pool, minx, miny, maxx, maxy); - - float dst_rect[] = { - info->dst.start.x, info->dst.start.y, 0.0, 1.0, - info->dst.end.x, info->dst.start.y, 0.0, 1.0, - info->dst.start.x, info->dst.end.y, 0.0, 1.0, - info->dst.end.x, info->dst.end.y, 0.0, 1.0, - }; - - ctx->position = - pan_pool_upload_aligned(blit_pool, dst_rect, sizeof(dst_rect), 64); -} - -struct panfrost_ptr -GENX(pan_blit)(struct pan_blit_context *ctx, struct pan_pool *pool, - struct pan_jc *jc, mali_ptr tsd, mali_ptr tiler) -{ - if (ctx->dst.cur_layer < 0 || - (ctx->dst.last_layer >= ctx->dst.layer_offset && - ctx->dst.cur_layer > ctx->dst.last_layer) || - (ctx->dst.last_layer < ctx->dst.layer_offset && - ctx->dst.cur_layer < ctx->dst.last_layer)) - return (struct panfrost_ptr){0}; - - int32_t layer = ctx->dst.cur_layer - ctx->dst.layer_offset; - float src_z; - if (ctx->src.dim == MALI_TEXTURE_DIMENSION_3D) - src_z = (ctx->z_scale * layer) + ctx->src.z_offset; - else - src_z = ctx->src.layer_offset + layer; - - float src_rect[] = { - ctx->src.start.x, ctx->src.start.y, src_z, 1.0, - ctx->src.end.x, ctx->src.start.y, src_z, 1.0, - ctx->src.start.x, ctx->src.end.y, src_z, 1.0, - ctx->src.end.x, ctx->src.end.y, src_z, 1.0, - }; - - mali_ptr src_coords = - pan_pool_upload_aligned(pool, src_rect, sizeof(src_rect), 64); - - struct panfrost_ptr job = {0}; - void *dcd = pan_blit_emit_tiler_job(pool, jc, tiler, &job); - - pan_pack(dcd, DRAW, cfg) { - cfg.thread_storage = tsd; - cfg.state = ctx->rsd; - - cfg.position = ctx->position; - cfg.varyings = pan_blitter_emit_varying(pool); - cfg.varying_buffers = pan_blitter_emit_varying_buffer(pool, src_coords); - cfg.viewport = ctx->vpd; - cfg.textures = ctx->textures; - cfg.samplers = ctx->samplers; - } - - return job; -} -#endif - DERIVE_HASH_TABLE(pan_blit_shader_key); DERIVE_HASH_TABLE(pan_blit_blend_shader_key); DERIVE_HASH_TABLE(pan_blit_rsd_key); diff --git a/src/panfrost/lib/pan_blitter.h b/src/panfrost/lib/pan_blitter.h index 2041ca80448..390e80afae9 100644 --- a/src/panfrost/lib/pan_blitter.h +++ b/src/panfrost/lib/pan_blitter.h @@ -94,24 +94,6 @@ struct pan_blit_context { float z_scale; }; -static inline bool -pan_blit_next_surface(struct pan_blit_context *ctx) -{ - if (ctx->dst.last_layer < ctx->dst.layer_offset) { - if (ctx->dst.cur_layer <= ctx->dst.last_layer) - return false; - - ctx->dst.cur_layer--; - } else { - if (ctx->dst.cur_layer >= ctx->dst.last_layer) - return false; - - ctx->dst.cur_layer++; - } - - return true; -} - #ifdef PAN_ARCH void GENX(pan_blitter_cache_init)(struct pan_blitter_cache *cache, unsigned gpu_id, @@ -125,15 +107,6 @@ unsigned GENX(pan_preload_fb)(struct pan_blitter_cache *cache, struct pan_pool *desc_pool, struct pan_fb_info *fb, unsigned layer_idx, mali_ptr tsd, struct panfrost_ptr *jobs); - -void GENX(pan_blit_ctx_init)(struct pan_blitter_cache *cache, - const struct pan_blit_info *info, - struct pan_pool *blit_pool, - struct pan_blit_context *ctx); - -struct panfrost_ptr GENX(pan_blit)(struct pan_blit_context *ctx, - struct pan_pool *pool, struct pan_jc *jc, - mali_ptr tsd, mali_ptr tiler); #endif #endif