v3dv: split framebuffer internal bpp calculations from tiling calculations

We want to reuse the latter aspect in a context were we already have
the internal bpp available.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga 2020-01-07 08:42:38 +01:00 committed by Marge Bot
parent 2b02117e64
commit 00cefce3ca

View file

@ -1302,6 +1302,19 @@ v3dv_DestroyBuffer(VkDevice _device,
vk_free2(&device->alloc, pAllocator, buffer);
}
static void
compute_internal_bpp_from_attachments(struct v3dv_framebuffer *framebuffer)
{
STATIC_ASSERT(RENDER_TARGET_MAXIMUM_32BPP == 0);
uint8_t max_bpp = RENDER_TARGET_MAXIMUM_32BPP;
for (uint32_t i = 0; i < framebuffer->attachment_count; i++) {
const struct v3dv_image_view *att = framebuffer->attachments[i];
if (att)
max_bpp = MAX2(max_bpp, att->internal_bpp);
}
framebuffer->internal_bpp = max_bpp;
}
static void
compute_tile_size_for_framebuffer(struct v3dv_framebuffer *framebuffer)
{
@ -1322,15 +1335,6 @@ compute_tile_size_for_framebuffer(struct v3dv_framebuffer *framebuffer)
else if (framebuffer->attachment_count > 1)
tile_size_index += 1;
STATIC_ASSERT(RENDER_TARGET_MAXIMUM_32BPP == 0);
uint8_t max_bpp = RENDER_TARGET_MAXIMUM_32BPP;
for (uint32_t i = 0; i < framebuffer->attachment_count; i++) {
const struct v3dv_image_view *att = framebuffer->attachments[i];
if (att)
max_bpp = MAX2(max_bpp, att->internal_bpp);
}
framebuffer->internal_bpp = max_bpp;
tile_size_index += framebuffer->internal_bpp;
assert(tile_size_index < ARRAY_SIZE(tile_sizes));
@ -1390,6 +1394,7 @@ v3dv_CreateFramebuffer(VkDevice _device,
v3dv_image_view_from_handle(pCreateInfo->pAttachments[i]);
}
compute_internal_bpp_from_attachments(framebuffer);
compute_tile_size_for_framebuffer(framebuffer);
*pFramebuffer = v3dv_framebuffer_to_handle(framebuffer);