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 <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7192>
This commit is contained in:
parent
b009bd9685
commit
bf9a1e0a4b
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue