Commit 1fdd85ab authored by Patrick Lerda's avatar Patrick Lerda Committed by repojohnray

WIP: lima: lima_draw: overcome the current maximum vertices limitation

The hardware can't handle more than 65535 vertices per operation. This
update configures the hardware accordingly.

Some code refactoring is still required.
Signed-off-by: default avatarPatrick Lerda <patrick9876@free.fr>
parent 6f8d66be
Pipeline #56945 passed with stages
in 16 minutes and 55 seconds
...@@ -45,10 +45,39 @@ ...@@ -45,10 +45,39 @@
int lima_ctx_num_plb = LIMA_CTX_PLB_DEF_NUM; int lima_ctx_num_plb = LIMA_CTX_PLB_DEF_NUM;
void
lima_ctx_buff_state_alloc(struct lima_context *ctx, uint32_t n)
{
if (!n)
n = ctx->state_depth ? ctx->state_depth : 1;
if (!ctx->buffer_state) {
ctx->buffer_state = rzalloc_size(ctx, n * sizeof(struct lima_ctx_buff_state[lima_ctx_buff_num]));
ctx->state_depth = n;
} else if (n != ctx->state_depth) {
ctx->buffer_state = reralloc_size(ctx, ctx->buffer_state, n * sizeof(struct lima_ctx_buff_state[lima_ctx_buff_num]));
if (n > ctx->state_depth)
memset(&(*ctx->buffer_state)[ctx->state_depth], 0, (n - ctx->state_depth) * sizeof(struct lima_ctx_buff_state[lima_ctx_buff_num]));
ctx->state_depth = n;
}
}
static void
lima_ctx_buff_state_free(struct lima_context *ctx)
{
if (ctx->buffer_state) {
ralloc_free(ctx->buffer_state);
ctx->buffer_state = NULL;
ctx->state_depth = 0;
}
}
uint32_t uint32_t
lima_ctx_buff_va(struct lima_context *ctx, enum lima_ctx_buff buff, unsigned submit) lima_ctx_buff_va(struct lima_context *ctx, enum lima_ctx_buff buff, unsigned submit, int k)
{ {
struct lima_ctx_buff_state *cbs = ctx->buffer_state + buff; struct lima_ctx_buff_state *cbs = (*ctx->buffer_state)[k] + buff;
struct lima_resource *res = lima_resource(cbs->res); struct lima_resource *res = lima_resource(cbs->res);
if (submit & LIMA_CTX_BUFF_SUBMIT_GP) if (submit & LIMA_CTX_BUFF_SUBMIT_GP)
...@@ -60,9 +89,9 @@ lima_ctx_buff_va(struct lima_context *ctx, enum lima_ctx_buff buff, unsigned sub ...@@ -60,9 +89,9 @@ lima_ctx_buff_va(struct lima_context *ctx, enum lima_ctx_buff buff, unsigned sub
} }
void * void *
lima_ctx_buff_map(struct lima_context *ctx, enum lima_ctx_buff buff) lima_ctx_buff_map(struct lima_context *ctx, enum lima_ctx_buff buff, int k)
{ {
struct lima_ctx_buff_state *cbs = ctx->buffer_state + buff; struct lima_ctx_buff_state *cbs = (*ctx->buffer_state)[k] + buff;
struct lima_resource *res = lima_resource(cbs->res); struct lima_resource *res = lima_resource(cbs->res);
return lima_bo_map(res->bo) + cbs->offset; return lima_bo_map(res->bo) + cbs->offset;
...@@ -70,9 +99,9 @@ lima_ctx_buff_map(struct lima_context *ctx, enum lima_ctx_buff buff) ...@@ -70,9 +99,9 @@ lima_ctx_buff_map(struct lima_context *ctx, enum lima_ctx_buff buff)
void * void *
lima_ctx_buff_alloc(struct lima_context *ctx, enum lima_ctx_buff buff, lima_ctx_buff_alloc(struct lima_context *ctx, enum lima_ctx_buff buff,
unsigned size, bool uploader) unsigned size, bool uploader, int k)
{ {
struct lima_ctx_buff_state *cbs = ctx->buffer_state + buff; struct lima_ctx_buff_state *cbs = (*ctx->buffer_state)[k] + buff;
void *ret = NULL; void *ret = NULL;
cbs->size = align(size, 0x40); cbs->size = align(size, 0x40);
...@@ -128,8 +157,10 @@ lima_context_destroy(struct pipe_context *pctx) ...@@ -128,8 +157,10 @@ lima_context_destroy(struct pipe_context *pctx)
if (ctx->gp_submit) if (ctx->gp_submit)
lima_submit_free(ctx->gp_submit); lima_submit_free(ctx->gp_submit);
for (int i = 0; i < lima_ctx_buff_num; i++) if (ctx->buffer_state)
pipe_resource_reference(&ctx->buffer_state[i].res, NULL); for (unsigned k = 0; k < ctx->state_depth; k++)
for (int i = 0; i < lima_ctx_buff_num; i++)
pipe_resource_reference(&(*ctx->buffer_state)[k][i].res, NULL);
lima_state_fini(ctx); lima_state_fini(ctx);
...@@ -159,6 +190,8 @@ lima_context_destroy(struct pipe_context *pctx) ...@@ -159,6 +190,8 @@ lima_context_destroy(struct pipe_context *pctx)
lima_context_free_drm_ctx(screen, ctx->id); lima_context_free_drm_ctx(screen, ctx->id);
lima_ctx_buff_state_free(ctx);
ralloc_free(ctx); ralloc_free(ctx);
} }
......
...@@ -31,6 +31,14 @@ ...@@ -31,6 +31,14 @@
#include "pipe/p_context.h" #include "pipe/p_context.h"
#include "pipe/p_state.h" #include "pipe/p_state.h"
#define LIMA_VERTICES_OUTPUTMAX 65535
static inline unsigned
lima_vertices_loop(const unsigned n)
{
return ((int)n - 1) / LIMA_VERTICES_OUTPUTMAX + 1;
}
struct lima_context_framebuffer { struct lima_context_framebuffer {
struct pipe_framebuffer_state base; struct pipe_framebuffer_state base;
int tiled_w, tiled_h; int tiled_w, tiled_h;
...@@ -233,7 +241,8 @@ struct lima_context { ...@@ -233,7 +241,8 @@ struct lima_context {
struct hash_table *plb_pp_stream; struct hash_table *plb_pp_stream;
uint32_t plb_index; uint32_t plb_index;
struct lima_ctx_buff_state buffer_state[lima_ctx_buff_num]; uint32_t state_depth;
struct lima_ctx_buff_state (*buffer_state)[][lima_ctx_buff_num];
struct util_dynarray vs_cmd_array; struct util_dynarray vs_cmd_array;
struct util_dynarray plbu_cmd_array; struct util_dynarray plbu_cmd_array;
...@@ -275,11 +284,13 @@ lima_sampler_view(struct pipe_sampler_view *psview) ...@@ -275,11 +284,13 @@ lima_sampler_view(struct pipe_sampler_view *psview)
#define LIMA_CTX_BUFF_SUBMIT_GP (1 << 0) #define LIMA_CTX_BUFF_SUBMIT_GP (1 << 0)
#define LIMA_CTX_BUFF_SUBMIT_PP (1 << 1) #define LIMA_CTX_BUFF_SUBMIT_PP (1 << 1)
void lima_ctx_buff_state_alloc(struct lima_context *ctx, uint32_t n);
uint32_t lima_ctx_buff_va(struct lima_context *ctx, enum lima_ctx_buff buff, uint32_t lima_ctx_buff_va(struct lima_context *ctx, enum lima_ctx_buff buff,
unsigned submit); unsigned submit, int k);
void *lima_ctx_buff_map(struct lima_context *ctx, enum lima_ctx_buff buff); void *lima_ctx_buff_map(struct lima_context *ctx, enum lima_ctx_buff buff, int k);
void *lima_ctx_buff_alloc(struct lima_context *ctx, enum lima_ctx_buff buff, void *lima_ctx_buff_alloc(struct lima_context *ctx, enum lima_ctx_buff buff,
unsigned size, bool uploader); unsigned size, bool uploader, int k);
void lima_state_init(struct lima_context *ctx); void lima_state_init(struct lima_context *ctx);
void lima_state_fini(struct lima_context *ctx); void lima_state_fini(struct lima_context *ctx);
......
This diff is collapsed.
...@@ -298,7 +298,7 @@ lima_update_textures(struct lima_context *ctx) ...@@ -298,7 +298,7 @@ lima_update_textures(struct lima_context *ctx)
} }
uint32_t *descs = uint32_t *descs =
lima_ctx_buff_alloc(ctx, lima_ctx_buff_pp_tex_desc, size, true); lima_ctx_buff_alloc(ctx, lima_ctx_buff_pp_tex_desc, size, true, 0);
off_t offset = lima_tex_list_size; off_t offset = lima_tex_list_size;
for (int i = 0; i < lima_tex->num_samplers; i++) { for (int i = 0; i < lima_tex->num_samplers; i++) {
...@@ -307,12 +307,12 @@ lima_update_textures(struct lima_context *ctx) ...@@ -307,12 +307,12 @@ lima_update_textures(struct lima_context *ctx)
unsigned desc_size = lima_calc_tex_desc_size(texture); unsigned desc_size = lima_calc_tex_desc_size(texture);
descs[i] = lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc, descs[i] = lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc,
LIMA_CTX_BUFF_SUBMIT_PP) + offset; LIMA_CTX_BUFF_SUBMIT_PP, 0) + offset;
lima_update_tex_desc(ctx, sampler, texture, (void *)descs + offset, desc_size); lima_update_tex_desc(ctx, sampler, texture, (void *)descs + offset, desc_size);
offset += desc_size; offset += desc_size;
} }
lima_dump_command_stream_print( lima_dump_command_stream_print(
descs, size, false, "add textures_desc at va %x\n", descs, size, false, "add textures_desc at va %x\n",
lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc, 0)); lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc, 0, 0));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment