summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2018-06-14 19:56:28 -0600
committerBrian Paul <[email protected]>2018-06-14 20:09:45 -0600
commit51a221e37869235ad5c81bbfec06a2564b3b2d3b (patch)
tree1b81ac61ab2cf2411f42944eb246c2d53af2c358 /src/gallium/auxiliary/util
parent67f40dadaa6666dacd90d1540eaadef20b9d48ba (diff)
gallium: add support for programmable sample locations
Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Brian Paul <[email protected]> (v2) Reviewed-by: Marek Olšák <[email protected]> (v2)
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_framebuffer.c30
-rw-r--r--src/gallium/auxiliary/util/u_framebuffer.h5
2 files changed, 35 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c
index c2948a5cfb3..5bafddc726f 100644
--- a/src/gallium/auxiliary/util/u_framebuffer.c
+++ b/src/gallium/auxiliary/util/u_framebuffer.c
@@ -240,3 +240,33 @@ util_framebuffer_get_num_samples(const struct pipe_framebuffer_state *fb)
return 1;
}
+
+
+/**
+ * Flip the sample location state along the Y axis.
+ */
+void
+util_sample_locations_flip_y(struct pipe_screen *screen, unsigned fb_height,
+ unsigned samples, uint8_t *locations)
+{
+ unsigned row, i, shift, grid_width, grid_height;
+ uint8_t new_locations[
+ PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE *
+ PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE * 32];
+
+ screen->get_sample_pixel_grid(screen, samples, &grid_width, &grid_height);
+
+ shift = fb_height % grid_height;
+
+ for (row = 0; row < grid_height; row++) {
+ unsigned row_size = grid_width * samples;
+ for (i = 0; i < row_size; i++) {
+ unsigned dest_row = grid_height - row - 1;
+ /* this relies on unsigned integer wraparound behaviour */
+ dest_row = (dest_row - shift) % grid_height;
+ new_locations[dest_row * row_size + i] = locations[row * row_size + i];
+ }
+ }
+
+ memcpy(locations, new_locations, grid_width * grid_height * samples);
+}
diff --git a/src/gallium/auxiliary/util/u_framebuffer.h b/src/gallium/auxiliary/util/u_framebuffer.h
index c73942c9c14..877e6e393f7 100644
--- a/src/gallium/auxiliary/util/u_framebuffer.h
+++ b/src/gallium/auxiliary/util/u_framebuffer.h
@@ -64,6 +64,11 @@ extern unsigned
util_framebuffer_get_num_samples(const struct pipe_framebuffer_state *fb);
+extern void
+util_sample_locations_flip_y(struct pipe_screen *screen, unsigned fb_height,
+ unsigned samples, uint8_t *locations);
+
+
#ifdef __cplusplus
}
#endif