From bf9a1e0a4be96b5f74d792596b10394ca9092703 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 16 Oct 2020 12:18:59 -0400 Subject: [PATCH] zink: add a pipe_context::get_sample_position hook standard for most gallium drivers, not sure why it's not a util function Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/zink/zink_context.c | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 46545b741d7..f223c8366b6 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -310,6 +310,78 @@ zink_sampler_view_destroy(struct pipe_context *pctx, FREE(view); } +static void +zink_get_sample_position(struct pipe_context *ctx, + unsigned sample_count, + unsigned sample_index, + float *out_value) +{ + /* TODO: handle this I guess */ + assert(zink_screen(ctx->screen)->info.props.limits.standardSampleLocations); + /* from 26.4. Multisampling */ + switch (sample_count) { + case 0: + case 1: { + float pos[][2] = { {0.5,0.5}, }; + out_value[0] = pos[sample_index][0]; + out_value[1] = pos[sample_index][1]; + break; + } + case 2: { + float pos[][2] = { {0.75,0.75}, + {0.25,0.25}, }; + out_value[0] = pos[sample_index][0]; + out_value[1] = pos[sample_index][1]; + break; + } + case 4: { + float pos[][2] = { {0.375, 0.125}, + {0.875, 0.375}, + {0.125, 0.625}, + {0.625, 0.875}, }; + out_value[0] = pos[sample_index][0]; + out_value[1] = pos[sample_index][1]; + break; + } + case 8: { + float pos[][2] = { {0.5625, 0.3125}, + {0.4375, 0.6875}, + {0.8125, 0.5625}, + {0.3125, 0.1875}, + {0.1875, 0.8125}, + {0.0625, 0.4375}, + {0.6875, 0.9375}, + {0.9375, 0.0625}, }; + out_value[0] = pos[sample_index][0]; + out_value[1] = pos[sample_index][1]; + break; + } + case 16: { + float pos[][2] = { {0.5625, 0.5625}, + {0.4375, 0.3125}, + {0.3125, 0.625}, + {0.75, 0.4375}, + {0.1875, 0.375}, + {0.625, 0.8125}, + {0.8125, 0.6875}, + {0.6875, 0.1875}, + {0.375, 0.875}, + {0.5, 0.0625}, + {0.25, 0.125}, + {0.125, 0.75}, + {0.0, 0.5}, + {0.9375, 0.25}, + {0.875, 0.9375}, + {0.0625, 0.0}, }; + out_value[0] = pos[sample_index][0]; + out_value[1] = pos[sample_index][1]; + break; + } + default: + unreachable("unhandled sample count!"); + } +} + static void zink_set_polygon_stipple(struct pipe_context *pctx, const struct pipe_poly_stipple *ps) @@ -1104,6 +1176,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) ctx->base.create_sampler_view = zink_create_sampler_view; ctx->base.set_sampler_views = zink_set_sampler_views; ctx->base.sampler_view_destroy = zink_sampler_view_destroy; + ctx->base.get_sample_position = zink_get_sample_position; zink_program_init(ctx);