#include "lima_resource.h"
#include "lima_program.h"
#include "lima_bo.h"
-#include "lima_submit.h"
+#include "lima_job.h"
#include "lima_texture.h"
#include "lima_util.h"
#include "lima_gpu.h"
+#include "pan_minmax_cache.h"
+
#include <drm-uapi/lima_drm.h>
static bool
}
static void
-lima_update_submit_wb(struct lima_context *ctx, unsigned buffers)
+lima_update_job_wb(struct lima_context *ctx, unsigned buffers)
{
- struct lima_submit *submit = lima_submit_get(ctx);
+ struct lima_job *job = lima_job_get(ctx);
struct lima_context_framebuffer *fb = &ctx->framebuffer;
- /* add to submit when the buffer is dirty and resolve is clear (not added before) */
+ /* add to job when the buffer is dirty and resolve is clear (not added before) */
if (fb->base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0) &&
- !(ctx->resolve & PIPE_CLEAR_COLOR0)) {
+ !(job->resolve & PIPE_CLEAR_COLOR0)) {
struct lima_resource *res = lima_resource(fb->base.cbufs[0]->texture);
- lima_flush_submit_accessing_bo(ctx, res->bo, true);
- _mesa_hash_table_insert(ctx->write_submits, &res->base, submit);
- lima_submit_add_bo(submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
+ lima_flush_job_accessing_bo(ctx, res->bo, true);
+ _mesa_hash_table_insert(ctx->write_jobs, &res->base, job);
+ lima_job_add_bo(job, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
}
- /* add to submit when the buffer is dirty and resolve is clear (not added before) */
+ /* add to job when the buffer is dirty and resolve is clear (not added before) */
if (fb->base.zsbuf && (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) &&
- !(ctx->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
+ !(job->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
struct lima_resource *res = lima_resource(fb->base.zsbuf->texture);
- lima_flush_submit_accessing_bo(ctx, res->bo, true);
- _mesa_hash_table_insert(ctx->write_submits, &res->base, submit);
- lima_submit_add_bo(submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
+ lima_flush_job_accessing_bo(ctx, res->bo, true);
+ _mesa_hash_table_insert(ctx->write_jobs, &res->base, job);
+ lima_job_add_bo(job, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
}
- ctx->resolve |= buffers;
+ job->resolve |= buffers;
}
static void
-lima_damage_rect_union(struct lima_context *ctx, unsigned minx, unsigned maxx, unsigned miny, unsigned maxy)
+lima_damage_rect_union(struct pipe_scissor_state *rect,
+ unsigned minx, unsigned maxx,
+ unsigned miny, unsigned maxy)
{
- ctx->damage_rect.minx = MIN2(ctx->damage_rect.minx, minx);
- ctx->damage_rect.miny = MIN2(ctx->damage_rect.miny, miny);
- ctx->damage_rect.maxx = MAX2(ctx->damage_rect.maxx, maxx);
- ctx->damage_rect.maxy = MAX2(ctx->damage_rect.maxy, maxy);
+ rect->minx = MIN2(rect->minx, minx);
+ rect->miny = MIN2(rect->miny, miny);
+ rect->maxx = MAX2(rect->maxx, maxx);
+ rect->maxy = MAX2(rect->maxy, maxy);
}
static void
const union pipe_color_union *color, double depth, unsigned stencil)
{
struct lima_context *ctx = lima_context(pctx);
+ struct lima_job *job = lima_job_get(ctx);
- lima_flush(ctx);
+ /* flush if this job already contains any draw, otherwise multi clear can be
+ * combined into a single job */
+ if (lima_job_has_draw_pending(job)) {
+ lima_do_job(job);
+ job = lima_job_get(ctx);
+ }
- lima_update_submit_wb(ctx, buffers);
+ lima_update_job_wb(ctx, buffers);
/* no need to reload if cleared */
if (ctx->framebuffer.base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0)) {
surf->reload = false;
}
- struct lima_context_clear *clear = &ctx->clear;
+ struct lima_job_clear *clear = &job->clear;
clear->buffers = buffers;
if (buffers & PIPE_CLEAR_COLOR0) {
ctx->dirty |= LIMA_CONTEXT_DIRTY_CLEAR;
- lima_damage_rect_union(ctx, 0, ctx->framebuffer.base.width,
- 0, ctx->framebuffer.base.height);
+ lima_damage_rect_union(&job->damage_rect,
+ 0, ctx->framebuffer.base.width,
+ 0, ctx->framebuffer.base.height);
}
enum lima_attrib_type {
static void
lima_pack_vs_cmd(struct lima_context *ctx, const struct pipe_draw_info *info)
{
- VS_CMD_BEGIN(&ctx->vs_cmd_array, 24);
+ struct lima_job *job = lima_job_get(ctx);
+
+ VS_CMD_BEGIN(&job->vs_cmd_array, 24);
if (!info->index_size) {
VS_CMD_ARRAYS_SEMAPHORE_BEGIN_1();
if (lima_is_scissor_zero(ctx))
return;
- PLBU_CMD_BEGIN(&ctx->plbu_cmd_array, 32);
+ struct lima_job *job = lima_job_get(ctx);
+ PLBU_CMD_BEGIN(&job->plbu_cmd_array, 32);
PLBU_CMD_VIEWPORT_LEFT(fui(ctx->viewport.left));
PLBU_CMD_VIEWPORT_RIGHT(fui(ctx->viewport.right));
maxy = MIN2(maxy, ctx->viewport.top);
PLBU_CMD_SCISSORS(minx, maxx, miny, maxy);
- lima_damage_rect_union(ctx, minx, maxx, miny, maxy);
+ lima_damage_rect_union(&job->damage_rect, minx, maxx, miny, maxy);
PLBU_CMD_UNKNOWN1();
render->varyings_address = 0x00000000;
}
+ struct lima_job *job = lima_job_get(ctx);
+
lima_dump_command_stream_print(
- render, sizeof(*render), false, "add render state at va %x\n",
+ job->dump, render, sizeof(*render),
+ false, "add render state at va %x\n",
lima_ctx_buff_va(ctx, lima_ctx_buff_pp_plb_rsw));
lima_dump_rsw_command_stream_print(
- render, sizeof(*render), lima_ctx_buff_va(ctx, lima_ctx_buff_pp_plb_rsw));
-
+ job->dump, render, sizeof(*render),
+ lima_ctx_buff_va(ctx, lima_ctx_buff_pp_plb_rsw));
}
static void
lima_update_gp_attribute_info(struct lima_context *ctx, const struct pipe_draw_info *info)
{
- struct lima_submit *submit = lima_submit_get(ctx);
+ struct lima_job *job = lima_job_get(ctx);
struct lima_vertex_element_state *ve = ctx->vertex_elements;
struct lima_context_vertex_buffer *vb = &ctx->vertex_buffers;
struct pipe_vertex_buffer *pvb = vb->vb + pve->vertex_buffer_index;
struct lima_resource *res = lima_resource(pvb->buffer.resource);
- lima_submit_add_bo(submit, LIMA_PIPE_GP, res->bo, LIMA_SUBMIT_BO_READ);
+ lima_job_add_bo(job, LIMA_PIPE_GP, res->bo, LIMA_SUBMIT_BO_READ);
unsigned start = info->index_size ? (ctx->min_index + info->index_bias) : info->start;
attribute[n++] = res->bo->va + pvb->buffer_offset + pve->src_offset
}
lima_dump_command_stream_print(
- attribute, n * 4, false, "update attribute info at va %x\n",
+ job->dump, attribute, n * 4, false, "update attribute info at va %x\n",
lima_ctx_buff_va(ctx, lima_ctx_buff_gp_attribute_info));
}
memcpy(vs_const_buff + vs->uniform_pending_offset + 32,
vs->constant, vs->constant_size);
+ struct lima_job *job = lima_job_get(ctx);
+
+ if (lima_debug & LIMA_DEBUG_GP) {
+ float *vs_const_buff_f = vs_const_buff;
+ printf("gp uniforms:\n");
+ for (int i = 0; i < (size / sizeof(float)); i++) {
+ if ((i % 4) == 0)
+ printf("%4d:", i / 4);
+ printf(" %8.4f", vs_const_buff_f[i]);
+ if ((i % 4) == 3)
+ printf("\n");
+ }
+ printf("\n");
+ }
+
lima_dump_command_stream_print(
- vs_const_buff, size, true,
+ job->dump, vs_const_buff, size, true,
"update gp uniform at va %x\n",
lima_ctx_buff_va(ctx, lima_ctx_buff_gp_uniform));
}
*array = lima_ctx_buff_va(ctx, lima_ctx_buff_pp_uniform);
+ struct lima_job *job = lima_job_get(ctx);
+
lima_dump_command_stream_print(
- fp16_const_buff, const_buff_size * 2, false, "add pp uniform data at va %x\n",
+ job->dump, fp16_const_buff, const_buff_size * 2,
+ false, "add pp uniform data at va %x\n",
lima_ctx_buff_va(ctx, lima_ctx_buff_pp_uniform));
lima_dump_command_stream_print(
- array, 4, false, "add pp uniform info at va %x\n",
+ job->dump, array, 4, false, "add pp uniform info at va %x\n",
lima_ctx_buff_va(ctx, lima_ctx_buff_pp_uniform_array));
}
static void
lima_update_varying(struct lima_context *ctx, const struct pipe_draw_info *info)
{
- struct lima_submit *submit = lima_submit_get(ctx);
+ struct lima_job *job = lima_job_get(ctx);
struct lima_screen *screen = lima_screen(ctx->base.screen);
struct lima_vs_shader_state *vs = ctx->vs;
uint32_t gp_output_size;
*/
ctx->gp_output = lima_bo_create(screen, gp_output_size, 0);
assert(ctx->gp_output);
- lima_submit_add_bo(submit, LIMA_PIPE_GP, ctx->gp_output, LIMA_SUBMIT_BO_WRITE);
- lima_submit_add_bo(submit, LIMA_PIPE_PP, ctx->gp_output, LIMA_SUBMIT_BO_READ);
+ lima_job_add_bo(job, LIMA_PIPE_GP, ctx->gp_output, LIMA_SUBMIT_BO_WRITE);
+ lima_job_add_bo(job, LIMA_PIPE_PP, ctx->gp_output, LIMA_SUBMIT_BO_READ);
for (int i = 0; i < vs->num_outputs; i++) {
struct lima_varying_info *v = vs->varying + i;
}
lima_dump_command_stream_print(
- varying, n * 4, false, "update varying info at va %x\n",
+ job->dump, varying, n * 4, false, "update varying info at va %x\n",
lima_ctx_buff_va(ctx, lima_ctx_buff_gp_varying_info));
}
if (fb->base.nr_cbufs)
buffers |= PIPE_CLEAR_COLOR0;
- lima_update_submit_wb(ctx, buffers);
+ lima_update_job_wb(ctx, buffers);
lima_update_gp_attribute_info(ctx, info);
lima_pack_plbu_cmd(ctx, info);
if (ctx->gp_output) {
- lima_bo_unreference(ctx->gp_output); /* held by submit */
+ lima_bo_unreference(ctx->gp_output); /* held by job */
ctx->gp_output = NULL;
}
const struct pipe_draw_info *info)
{
struct lima_context *ctx = lima_context(pctx);
- struct lima_submit *submit = lima_submit_get(ctx);
+ struct lima_job *job = lima_job_get(ctx);
struct pipe_resource *indexbuf = NULL;
+ bool needs_indices = true;
/* Mali Utgard GPU always need min/max index info for index draw,
* compute it if upper layer does not do for us */
- if (info->max_index == ~0u)
- u_vbuf_get_minmax_index(pctx, info, &ctx->min_index, &ctx->max_index);
- else {
+ if (info->max_index != ~0u) {
ctx->min_index = info->min_index;
ctx->max_index = info->max_index;
+ needs_indices = false;
}
if (info->has_user_indices) {
else {
ctx->index_res = lima_resource(info->index.resource);
ctx->index_offset = 0;
+ needs_indices = !panfrost_minmax_cache_get(ctx->index_res->index_cache, info->start,
+ info->count, &ctx->min_index, &ctx->max_index);
+ }
+
+ if (needs_indices) {
+ u_vbuf_get_minmax_index(pctx, info, &ctx->min_index, &ctx->max_index);
+ if (!info->has_user_indices)
+ panfrost_minmax_cache_add(ctx->index_res->index_cache, info->start, info->count,
+ ctx->min_index, ctx->max_index);
}
- lima_submit_add_bo(submit, LIMA_PIPE_GP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
- lima_submit_add_bo(submit, LIMA_PIPE_PP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
+ lima_job_add_bo(job, LIMA_PIPE_GP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
+ lima_job_add_bo(job, LIMA_PIPE_PP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
lima_draw_vbo_update(pctx, info);
if (indexbuf)
if (!lima_update_vs_state(ctx) || !lima_update_fs_state(ctx))
return;
- struct lima_submit *submit = lima_submit_get(ctx);
+ struct lima_job *job = lima_job_get(ctx);
lima_dump_command_stream_print(
- ctx->vs->bo->map, ctx->vs->shader_size, false,
+ job->dump, ctx->vs->bo->map, ctx->vs->shader_size, false,
"add vs at va %x\n", ctx->vs->bo->va);
lima_dump_command_stream_print(
- ctx->fs->bo->map, ctx->fs->shader_size, false,
+ job->dump, ctx->fs->bo->map, ctx->fs->shader_size, false,
"add fs at va %x\n", ctx->fs->bo->va);
- lima_submit_add_bo(submit, LIMA_PIPE_GP, ctx->vs->bo, LIMA_SUBMIT_BO_READ);
- lima_submit_add_bo(submit, LIMA_PIPE_PP, ctx->fs->bo, LIMA_SUBMIT_BO_READ);
+ lima_job_add_bo(job, LIMA_PIPE_GP, ctx->vs->bo, LIMA_SUBMIT_BO_READ);
+ lima_job_add_bo(job, LIMA_PIPE_PP, ctx->fs->bo, LIMA_SUBMIT_BO_READ);
if (info->index_size)
lima_draw_vbo_indexed(pctx, info);