tu: Fix FDM texel size calculation
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

It turns out that it was intended to round down when dividing the
framebuffer size by FDM size and all other implementations of
VK_EXT_fragment_density_map did that. We followed the spec, which
doesn't say to round (which is equivalent to rounding up), but the spec
will be updated to reflect the intended behavior.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39434>
This commit is contained in:
Connor Abbott 2026-01-21 10:33:33 -05:00 committed by Marge Bot
parent fbc97b24d1
commit 09b9205117

View file

@ -1428,8 +1428,8 @@ tu_fragment_density_map_sample(const struct tu_image_view *fdm,
{
assert(fdm->image->layout[0].tile_mode == TILE6_LINEAR);
uint32_t fdm_shift_x = util_logbase2_ceil(DIV_ROUND_UP(width, fdm->vk.extent.width));
uint32_t fdm_shift_y = util_logbase2_ceil(DIV_ROUND_UP(height, fdm->vk.extent.height));
uint32_t fdm_shift_x = util_logbase2_ceil(width / fdm->vk.extent.width);
uint32_t fdm_shift_y = util_logbase2_ceil(height / fdm->vk.extent.height);
fdm_shift_x = CLAMP(fdm_shift_x, MIN_FDM_TEXEL_SIZE_LOG2, MAX_FDM_TEXEL_SIZE_LOG2);
fdm_shift_y = CLAMP(fdm_shift_y, MIN_FDM_TEXEL_SIZE_LOG2, MAX_FDM_TEXEL_SIZE_LOG2);