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] / 16.0f;
+       pos_out[1] = ptr[sample_index][1] / 16.0f;
+}
+
 void
 fd_resource_context_init(struct pipe_context *pctx)
 {
@@ -1206,4 +1250,5 @@ fd_resource_context_init(struct pipe_context *pctx)
        pctx->blit = fd_blit;
        pctx->flush_resource = fd_flush_resource;
        pctx->invalidate_resource = fd_invalidate_resource;
+       pctx->get_sample_position = fd_get_sample_position;
 }
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to