From: Kenneth Graunke Date: Tue, 21 Aug 2018 06:37:13 +0000 (-0700) Subject: iris: implement get_sample_position X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=701b47a197f8ec0b308e52002bc59614943fd2d1;p=mesa.git iris: implement get_sample_position Fixes arb_sample_shading/builtin-gl-sample-position --- diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c index 90c7a1829ba..daaa9409d2e 100644 --- a/src/gallium/drivers/iris/iris_context.c +++ b/src/gallium/drivers/iris/iris_context.c @@ -32,6 +32,7 @@ #include "iris_context.h" #include "iris_resource.h" #include "iris_screen.h" +#include "common/gen_sample_positions.h" static void iris_flush(struct pipe_context *ctx, @@ -75,6 +76,41 @@ iris_set_debug_callback(struct pipe_context *ctx, memset(&ice->dbg, 0, sizeof(ice->dbg)); } +static void +iris_get_sample_position(struct pipe_context *ctx, + unsigned sample_count, + unsigned sample_index, + float *out_value) +{ + union { + struct { + float x[16]; + float y[16]; + } a; + struct { + float _0XOffset, _1XOffset, _2XOffset, _3XOffset, + _4XOffset, _5XOffset, _6XOffset, _7XOffset, + _8XOffset, _9XOffset, _10XOffset, _11XOffset, + _12XOffset, _13XOffset, _14XOffset, _15XOffset; + float _0YOffset, _1YOffset, _2YOffset, _3YOffset, + _4YOffset, _5YOffset, _6YOffset, _7YOffset, + _8YOffset, _9YOffset, _10YOffset, _11YOffset, + _12YOffset, _13YOffset, _14YOffset, _15YOffset; + } v; + } u; + switch (sample_count) { + case 1: GEN_SAMPLE_POS_1X(u.v._); break; + case 2: GEN_SAMPLE_POS_2X(u.v._); break; + case 4: GEN_SAMPLE_POS_4X(u.v._); break; + case 8: GEN_SAMPLE_POS_8X(u.v._); break; + case 16: GEN_SAMPLE_POS_16X(u.v._); break; + default: unreachable("invalid sample count"); + } + + out_value[0] = u.a.x[sample_index]; + out_value[1] = u.a.y[sample_index]; +} + /** * Destroy a context, freeing any associated memory. */ @@ -140,6 +176,7 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags) ctx->destroy = iris_destroy_context; ctx->flush = iris_flush; ctx->set_debug_callback = iris_set_debug_callback; + ctx->get_sample_position = iris_get_sample_position; ice->shaders.urb_size = devinfo->urb.size;