summaryrefslogtreecommitdiffstats
path: root/src/gallium/include
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/include
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/include')
-rw-r--r--src/gallium/include/pipe/p_context.h41
-rw-r--r--src/gallium/include/pipe/p_defines.h1
-rw-r--r--src/gallium/include/pipe/p_screen.h11
-rw-r--r--src/gallium/include/pipe/p_state.h1
4 files changed, 52 insertions, 2 deletions
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index c3dc5edf57d..7cf037f1abd 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -279,8 +279,35 @@ struct pipe_context {
void (*set_framebuffer_state)( struct pipe_context *,
const struct pipe_framebuffer_state * );
+ /**
+ * Set the sample locations used during rasterization. When NULL or sized
+ * zero, the default locations are used.
+ *
+ * Note that get_sample_position() still returns the default locations.
+ *
+ * The samples are accessed with
+ * locations[(pixel_y*grid_w+pixel_x)*ms+i],
+ * where:
+ * ms = the sample count
+ * grid_w = the pixel grid width for the sample count
+ * grid_w = the pixel grid height for the sample count
+ * pixel_x = the window x coordinate modulo grid_w
+ * pixel_y = the window y coordinate modulo grid_w
+ * i = the sample index
+ * This gives a result with the x coordinate as the low 4 bits and the y
+ * coordinate as the high 4 bits. For each coordinate 0 is the left or top
+ * edge of the pixel's rectangle and 16 (not 15) is the right or bottom edge.
+ *
+ * Out of bounds accesses are return undefined values.
+ *
+ * The pixel grid is used to vary sample locations across pixels and its
+ * size can be queried with get_sample_pixel_grid().
+ */
+ void (*set_sample_locations)( struct pipe_context *,
+ size_t size, const uint8_t *locations );
+
void (*set_polygon_stipple)( struct pipe_context *,
- const struct pipe_poly_stipple * );
+ const struct pipe_poly_stipple * );
void (*set_scissor_states)( struct pipe_context *,
unsigned start_slot,
@@ -485,6 +512,16 @@ struct pipe_context {
int clear_value_size);
/**
+ * If a depth buffer is rendered with different sample location state than
+ * what is current at the time of reading, the values may differ because
+ * depth buffer compression can depend the sample locations.
+ *
+ * This function is a hint to decompress the current depth buffer to avoid
+ * such problems.
+ */
+ void (*evaluate_depth_buffer)(struct pipe_context *pipe);
+
+ /**
* Flush draw commands.
*
* This guarantees that the new fence (if any) will finish in finite time,
@@ -720,7 +757,7 @@ struct pipe_context {
/*@}*/
/**
- * Get sample position for an individual sample point.
+ * Get the default sample position for an individual sample point.
*
* \param sample_count - total number of samples
* \param sample_index - sample to get the position values for
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 6cc73a31bfc..43db9f8fbaa 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -813,6 +813,7 @@ enum pipe_cap
PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_POINTS_LINES,
PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS,
PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE,
+ PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS,
};
/**
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 8fd81a4e9a9..0439060b606 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -132,6 +132,17 @@ struct pipe_screen {
void *ret);
/**
+ * Get the sample pixel grid's size. This function requires
+ * PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS to be callable.
+ *
+ * \param sample_count - total number of samples
+ * \param out_width - the width of the pixel grid
+ * \param out_height - the height of the pixel grid
+ */
+ void (*get_sample_pixel_grid)(struct pipe_screen *, unsigned sample_count,
+ unsigned *out_width, unsigned *out_height);
+
+ /**
* Query a timestamp in nanoseconds. The returned value should match
* PIPE_QUERY_TIMESTAMP. This function returns immediately and doesn't
* wait for rendering to complete (which cannot be achieved with queries).
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index db9fa1a8e9f..809aa087ce0 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -74,6 +74,7 @@ extern "C" {
#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT 8
#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT 2
#define PIPE_MAX_WINDOW_RECTANGLES 8
+#define PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE 4
#define PIPE_MAX_HW_ATOMIC_BUFFERS 32