Mesa (main): zink: update vk sample location info during framebuffer setup
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 9 17:40:58 UTC 2021
Module: Mesa
Branch: main
Commit: 7353d1d26b0ff0838360b1955fb8a1d1aa849ec8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7353d1d26b0ff0838360b1955fb8a1d1aa849ec8
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Fri Apr 2 17:36:28 2021 -0400
zink: update vk sample location info during framebuffer setup
this needs to be stored as a persistent thing on the ctx so it can be
reused without needing to be recalculated
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11189>
---
src/gallium/drivers/zink/zink_context.c | 18 ++++++++++++++++++
src/gallium/drivers/zink/zink_draw.c | 2 ++
2 files changed, 20 insertions(+)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index cb0ffb91444..65868d69732 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1517,6 +1517,24 @@ setup_framebuffer(struct zink_context *ctx)
struct zink_screen *screen = zink_screen(ctx->base.screen);
struct zink_render_pass *rp = ctx->gfx_pipeline_state.render_pass;
+ if (ctx->gfx_pipeline_state.sample_locations_enabled && ctx->sample_locations_changed) {
+ unsigned samples = ctx->gfx_pipeline_state.rast_samples;
+ unsigned idx = util_logbase2_ceil(MAX2(samples, 1));
+ VkExtent2D grid_size = screen->maxSampleLocationGridSize[idx];
+
+ for (unsigned pixel = 0; pixel < grid_size.width * grid_size.height; pixel++) {
+ for (unsigned sample = 0; sample < samples; sample++) {
+ unsigned pixel_x = pixel % grid_size.width;
+ unsigned pixel_y = pixel / grid_size.width;
+ unsigned wi = pixel * samples + sample;
+ 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;
+ }
+ }
+ }
+
if (rp)
ctx->rp_changed |= ctx->rp_clears_enabled != rp->state.clears;
if (ctx->rp_changed)
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c
index 0e70efed0de..3eedaa782a6 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -649,6 +649,8 @@ zink_draw_vbo(struct pipe_context *pctx,
else
vkCmdSetDepthBias(batch->state->cmdbuf, 0.0f, 0.0f, 0.0f);
+ ctx->sample_locations_changed = false;
+
if (ctx->gfx_pipeline_state.blend_state->need_blend_constants)
vkCmdSetBlendConstants(batch->state->cmdbuf, ctx->blend_constants);
More information about the mesa-commit
mailing list