summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/util/u_framebuffer.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-01-29 11:08:07 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-01-29 11:08:07 +0000
commit6b139c2063623e9310025247cd966490b9aa57ea (patch)
tree375acfd898ca3d721250aa17291bbb90a8d7250a /lib/mesa/src/gallium/auxiliary/util/u_framebuffer.c
parentcce99579dcfb1d54c54cff65573be3430e77f2c5 (diff)
Import Mesa 18.3.2
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/util/u_framebuffer.c')
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_framebuffer.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_framebuffer.c b/lib/mesa/src/gallium/auxiliary/util/u_framebuffer.c
index c2948a5cf..5bafddc72 100644
--- a/lib/mesa/src/gallium/auxiliary/util/u_framebuffer.c
+++ b/lib/mesa/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);
+}