From a2546b71ed6366b2cf8becd884874498da2230c1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 7 Apr 2023 15:02:32 -0400 Subject: [PATCH] asahi: Minify width/height in create_surface Otherwise framebuffer->width ends up being wrong with u_blitter, this is what other drivers do. If we needed to render to depth/stencil with u_blitter, this would cause us trouble. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_state.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 996fe025489..a3bdb1d9466 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -878,16 +878,22 @@ agx_create_surface(struct pipe_context *ctx, struct pipe_resource *texture, if (!surface) return NULL; + + unsigned level = surf_tmpl->u.tex.level; + pipe_reference_init(&surface->reference, 1); pipe_resource_reference(&surface->texture, texture); + + assert(texture->target != PIPE_BUFFER && "buffers are not renderable"); + surface->context = ctx; surface->format = surf_tmpl->format; - surface->width = texture->width0; - surface->height = texture->height0; + surface->width = u_minify(texture->width0, level); + surface->height = u_minify(texture->height0, level); surface->texture = texture; surface->u.tex.first_layer = surf_tmpl->u.tex.first_layer; surface->u.tex.last_layer = surf_tmpl->u.tex.last_layer; - surface->u.tex.level = surf_tmpl->u.tex.level; + surface->u.tex.level = level; return surface; }