Module: Mesa Branch: master Commit: 6089b00e893115440e657480a75afa5317b3ce2c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6089b00e893115440e657480a75afa5317b3ce2c
Author: Samuel Iglesias Gonsálvez <[email protected]> Date: Tue May 19 17:37:39 2020 +0200 turnip: create LRZ buffer v2: - Add missing vulkan subpass support. (Jonathan Marek) - When creating the BO, mark it as not valid until it is cleared. - Move LRZ struct to tu_image. (Jonathan Marek) - Destroy BO when we destroy the image. (Jonathan Marek) v3: - Allocate the buffer as part of the image's BO (Connor) - Moved image's LRZ values to its layout. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5146> --- src/freedreno/vulkan/tu_image.c | 30 ++++++++++++++++++++++++++++++ src/freedreno/vulkan/tu_private.h | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c index 51dc897dc94..d6684db089e 100644 --- a/src/freedreno/vulkan/tu_image.c +++ b/src/freedreno/vulkan/tu_image.c @@ -271,6 +271,36 @@ tu_image_create(VkDevice _device, image->total_size = MAX2(image->total_size, layout->size); } + const struct util_format_description *desc = util_format_description(image->layout[0].format); + if (util_format_has_depth(desc) && !(device->instance->debug_flags & TU_DEBUG_NOLRZ)) + { + /* Depth plane is the first one */ + struct fdl_layout *layout = &image->layout[0]; + unsigned width = layout->width0; + unsigned height = layout->height0; + + /* LRZ buffer is super-sampled */ + switch (layout->nr_samples) { + case 4: + width *= 2; + /* fallthru */ + case 2: + height *= 2; + break; + default: + break; + } + + unsigned lrz_pitch = align(DIV_ROUND_UP(width, 8), 32); + unsigned lrz_height = align(DIV_ROUND_UP(height, 8), 16); + + image->lrz_height = lrz_height; + image->lrz_pitch = lrz_pitch; + image->lrz_offset = image->total_size; + unsigned lrz_size = lrz_pitch * lrz_height * 2; + image->total_size += lrz_size; + } + *pImage = tu_image_to_handle(image); return VK_SUCCESS; diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index a823f9921a1..0917481e2aa 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1250,6 +1250,10 @@ struct tu_image /* Set when bound */ struct tu_bo *bo; VkDeviceSize bo_offset; + + uint32_t lrz_height; + uint32_t lrz_pitch; + uint32_t lrz_offset; }; static inline uint32_t _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
