zink: add a function for getting the minimum framebuffer layers

this clamps the layer count to the smallest number of layers rather
than the largest

cc: mesa-stable

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17061>
(cherry picked from commit f74df6205d)

Conflicts:
	src/gallium/drivers/zink/zink_framebuffer.h
This commit is contained in:
Mike Blumenkrantz 2022-06-15 12:58:03 -04:00 committed by Dylan Baker
parent 494b4d0c41
commit 0c283ca156
3 changed files with 28 additions and 1 deletions

View file

@ -895,7 +895,7 @@
"description": "zink: add a function for getting the minimum framebuffer layers",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -378,3 +378,26 @@ zink_get_framebuffer(struct zink_context *ctx)
return fb;
}
/* same as u_framebuffer_get_num_layers, but clamp to lowest layer count */
unsigned
zink_framebuffer_get_num_layers(const struct pipe_framebuffer_state *fb)
{
unsigned i, num_layers = UINT32_MAX;
if (!(fb->nr_cbufs || fb->zsbuf))
return MAX2(fb->layers, 1);
for (i = 0; i < fb->nr_cbufs; i++) {
if (fb->cbufs[i]) {
unsigned num = fb->cbufs[i]->u.tex.last_layer -
fb->cbufs[i]->u.tex.first_layer + 1;
num_layers = MIN2(num_layers, num);
}
}
if (fb->zsbuf) {
unsigned num = fb->zsbuf->u.tex.last_layer -
fb->zsbuf->u.tex.first_layer + 1;
num_layers = MIN2(num_layers, num);
}
return MAX2(num_layers, 1);
}

View file

@ -95,4 +95,8 @@ zink_get_framebuffer_imageless(struct zink_context *ctx);
struct zink_framebuffer *
zink_get_framebuffer(struct zink_context *ctx);
unsigned
zink_framebuffer_get_num_layers(const struct pipe_framebuffer_state *fb);
#endif