gallium,mesa/st: reverse logic for y flip for programmable sample locations

mesa/st flips y coordinates if fbo orientation is Y_0_BOTTOM (essentially
user fbos), and all 3 gallium drivers supporting the feature then
unconditionally reverse this flip. llvmpipe wants to support this as well,
and it would have to do the flip too, and it's actually problematic for
lavapipe, since then lavapipe would have to flip as well, which means that
we'd lose the ability to set y positions to 0 (as the flip with the 4 bit
values does 16-val), and vulkan requires the minimum to be 0.
Hence, reverse this and flip when fbo orientation is Y_0_TOP. I don't actually
pretend to know if this is correct or if just no flipping should occur, but at
least this is consistent with how default sample locations are reported by mesa
via glGetMultisamplefv (which does y flip with the values it gets via
pipe->get_sample_position() if it's a winsys fb).

Reviewed-by: Michal Krol <michal.krol@broadcom.com>
Reviewed-by: Brian Paul <brian.paul@broadcom.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37181>
This commit is contained in:
Roland Scheidegger 2025-09-13 15:53:52 +02:00 committed by Marge Bot
parent c3cf50e2f1
commit 60924b4819
4 changed files with 4 additions and 4 deletions

View file

@ -357,7 +357,7 @@ build_sample_locations(struct fd6_emit *emit)
uint32_t sample_locations = 0;
for (int i = 0; i < 4; i++) {
float x = (ctx->sample_locations[i] & 0xf) / 16.0f;
float y = (16 - (ctx->sample_locations[i] >> 4)) / 16.0f;
float y = (ctx->sample_locations[i] >> 4) / 16.0f;
x = CLAMP(x, 0.0f, 0.9375f);
y = CLAMP(y, 0.0f, 0.9375f);

View file

@ -66,7 +66,7 @@ gm200_validate_sample_locations(struct nvc0_context *nvc0, unsigned ms)
unsigned ri = (pixel_y * grid_width + pixel_x % grid_width);
ri = ri * ms + sample;
sample_locations[wi][0] = locations[ri] & 0xf;
sample_locations[wi][1] = 16 - (locations[ri] >> 4);
sample_locations[wi][1] = locations[ri] >> 4;
}
}
} else {

View file

@ -2900,7 +2900,7 @@ zink_update_vk_sample_locations(struct zink_context *ctx)
unsigned ri = (pixel_y * grid_size.width + pixel_x % grid_size.width);
ri = ri * samples + sample;
ctx->vk_sample_locations[wi].x = (ctx->sample_locations[ri] & 0xf) / 16.0f;
ctx->vk_sample_locations[wi].y = (16 - (ctx->sample_locations[ri] >> 4)) / 16.0f;
ctx->vk_sample_locations[wi].y = (ctx->sample_locations[ri] >> 4) / 16.0f;
}
}
}

View file

@ -80,7 +80,7 @@ update_sample_locations(struct st_context *st)
x = fb->SampleLocationTable[table_index*2];
y = fb->SampleLocationTable[table_index*2+1];
}
if (st->state.fb_orientation == Y_0_BOTTOM)
if (st->state.fb_orientation == Y_0_TOP)
y = 1.0 - y;
loc = roundf(CLAMP(x * 16.0f, 0.0f, 15.0f));