lima: fix render to non-zero level texture

Current implementation won't respect level of surface to render.

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
(cherry picked from commit 54490b0b36)
This commit is contained in:
Qiang Yu 2019-05-15 17:35:19 +08:00 committed by Juan A. Suarez Romero
parent 87ac0bd86a
commit 4b3c805b88

View file

@ -1438,6 +1438,7 @@ lima_pack_wb_zsbuf_reg(struct lima_context *ctx, uint32_t *wb_reg, int wb_idx)
{
struct lima_context_framebuffer *fb = &ctx->framebuffer;
struct lima_resource *res = lima_resource(fb->base.zsbuf->texture);
int level = fb->base.zsbuf->u.tex.level;
uint32_t format;
@ -1455,14 +1456,14 @@ lima_pack_wb_zsbuf_reg(struct lima_context *ctx, uint32_t *wb_reg, int wb_idx)
struct lima_pp_wb_reg *wb = (void *)wb_reg;
wb[wb_idx].type = 0x01; /* 1 for depth, stencil */
wb[wb_idx].address = res->bo->va;
wb[wb_idx].address = res->bo->va + res->levels[level].offset;
wb[wb_idx].pixel_format = format;
if (res->tiled) {
wb[wb_idx].pixel_layout = 0x2;
wb[wb_idx].pitch = fb->tiled_w;
} else {
wb[wb_idx].pixel_layout = 0x0;
wb[wb_idx].pitch = res->levels[0].stride / 8;
wb[wb_idx].pitch = res->levels[level].stride / 8;
}
wb[wb_idx].mrt_bits = 0;
}
@ -1472,6 +1473,7 @@ lima_pack_wb_cbuf_reg(struct lima_context *ctx, uint32_t *wb_reg, int wb_idx)
{
struct lima_context_framebuffer *fb = &ctx->framebuffer;
struct lima_resource *res = lima_resource(fb->base.cbufs[0]->texture);
int level = fb->base.cbufs[0]->u.tex.level;
bool swap_channels = false;
switch (fb->base.cbufs[0]->format) {
@ -1485,14 +1487,14 @@ lima_pack_wb_cbuf_reg(struct lima_context *ctx, uint32_t *wb_reg, int wb_idx)
struct lima_pp_wb_reg *wb = (void *)wb_reg;
wb[wb_idx].type = 0x02; /* 2 for color buffer */
wb[wb_idx].address = res->bo->va;
wb[wb_idx].address = res->bo->va + res->levels[level].offset;
wb[wb_idx].pixel_format = LIMA_PIXEL_FORMAT_B8G8R8A8;
if (res->tiled) {
wb[wb_idx].pixel_layout = 0x2;
wb[wb_idx].pitch = fb->tiled_w;
} else {
wb[wb_idx].pixel_layout = 0x0;
wb[wb_idx].pitch = res->levels[0].stride / 8;
wb[wb_idx].pitch = res->levels[level].stride / 8;
}
wb[wb_idx].mrt_bits = swap_channels ? 0x4 : 0x0;
}