[Mesa-dev] [PATCH 1/3] freedreno: implements get_sample_position
Erik Faye-Lund
erik.faye-lund at collabora.com
Tue Nov 6 16:28:34 UTC 2018
On Tue, 2018-11-06 at 19:27 +0900, Hyunjun Ko wrote:
> Since 1285f71d3e landed, it needs to provide apps with proper sample
> position for MSAA.
>
> Currently no way to query this to hw, these are taken from blob
> driver.
>
> Fixes: dEQP-
> GLES31.functional.texture.multisample.samples_#.sample_position
> ---
> .../drivers/freedreno/freedreno_resource.c | 43
> +++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c
> b/src/gallium/drivers/freedreno/freedreno_resource.c
> index 54d7385896..5047c43700 100644
> --- a/src/gallium/drivers/freedreno/freedreno_resource.c
> +++ b/src/gallium/drivers/freedreno/freedreno_resource.c
> @@ -1192,6 +1192,50 @@ fd_resource_screen_init(struct pipe_screen
> *pscreen)
> screen->setup_slices = fd_setup_slices;
> }
>
> +static void
> +fd_get_sample_position(struct pipe_context *context,
> + unsigned sample_count, unsigned
> sample_index,
> + float *pos_out)
> +{
> + /* The following is copied from nouveau/nv50 except for
> position
> + * values, which are taken from blob driver */
> + static const uint8_t pos1[1][2] = { { 0x8, 0x8 } };
> + static const uint8_t pos2[2][2] = {
> + { 0xc, 0xc }, { 0x4, 0x4 } };
> + static const uint8_t pos4[4][2] = {
> + { 0x6, 0x2 }, { 0xe, 0x6 },
> + { 0x2, 0xa }, { 0xa, 0xe } };
> + /* TODO needs to be verified on supported hw */
> + static const uint8_t pos8[8][2] = {
> + { 0x9, 0x5 }, { 0x7, 0xb },
> + { 0xd, 0x9 }, { 0x5, 0x3 },
> + { 0x3, 0xd }, { 0x1, 0x7 },
> + { 0xb, 0xf }, { 0xf, 0x1 } };
> +
> + const uint8_t (*ptr)[2];
> +
> + switch (sample_count) {
> + case 1:
> + ptr = pos1;
> + break;
> + case 2:
> + ptr = pos2;
> + break;
> + case 4:
> + ptr = pos4;
> + break;
> + case 8:
> + ptr = pos8;
> + break;
> + default:
> + assert(0);
> + return;
> + }
> +
> + pos_out[0] = ptr[sample_index][0] * 0.0625f;
> + pos_out[1] = ptr[sample_index][1] * 0.0625f;
I think...
pos_out[0] = ptr[sample_index][0] / 16.0f;
...etc would be a bit less cryptic here.
More information about the mesa-dev
mailing list