llvmpipe: add get_sample_position support (v2)
authorDave Airlie <airlied@redhat.com>
Tue, 10 Mar 2020 03:04:01 +0000 (13:04 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
This just adds the sample values for 4xmsaa, and hooks them
up to the get_sample_position API

v2: move to vulkan standard sample positions

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>

src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_rast.h
src/gallium/drivers/llvmpipe/lp_surface.c

index 3d335e2ad383e9c0d4dc94f7abd9fcd45c64ebab..f9b368597d00553e67fe5321d1c6e5b78722f9ec 100644 (file)
@@ -56,6 +56,10 @@ const struct lp_rast_state *jit_state = NULL;
 const struct lp_rasterizer_task *jit_task = NULL;
 #endif
 
+const float lp_sample_pos_4x[4][2] = { { 0.375, 0.125 },
+                                       { 0.875, 0.375 },
+                                       { 0.125, 0.625 },
+                                       { 0.625, 0.875 } };
 
 /**
  * Begin rasterizing a scene.
index d9be7f392ef892fefaf4ca0889fe06b73edd0420..43a3064be77479a84f4fe075061eb36c402657fc 100644 (file)
@@ -72,6 +72,7 @@ struct cmd_bin;
 
 struct lp_rasterizer_task;
 
+extern const float lp_sample_pos_4x[4][2];
 
 /**
  * Rasterization state.
index 1cdabbb6cc3b14ae62e18d48b3377c4c5d487026..70c7911d1aafc9754f2bddb397f4d857d726d326 100644 (file)
@@ -33,7 +33,7 @@
 #include "lp_surface.h"
 #include "lp_texture.h"
 #include "lp_query.h"
-
+#include "lp_rast.h"
 
 static void
 lp_resource_copy(struct pipe_context *pipe,
@@ -225,6 +225,21 @@ llvmpipe_clear_depth_stencil(struct pipe_context *pipe,
                             dstx, dsty, width, height);
 }
 
+static void
+llvmpipe_get_sample_position(struct pipe_context *pipe,
+                             unsigned sample_count,
+                             unsigned sample_index,
+                             float *out_value)
+{
+   switch (sample_count) {
+   case 4:
+      out_value[0] = lp_sample_pos_4x[sample_index][0];
+      out_value[1] = lp_sample_pos_4x[sample_index][1];
+      break;
+   default:
+      break;
+   }
+}
 
 void
 llvmpipe_init_surface_functions(struct llvmpipe_context *lp)
@@ -238,4 +253,5 @@ llvmpipe_init_surface_functions(struct llvmpipe_context *lp)
    lp->pipe.resource_copy_region = lp_resource_copy;
    lp->pipe.blit = lp_blit;
    lp->pipe.flush_resource = lp_flush_resource;
+   lp->pipe.get_sample_position = llvmpipe_get_sample_position;
 }