[Mesa-dev] [PATCH v2 3/4] st/mesa: add support for nvidia conservative rasterization extensions

Rhys Perry pendingchaos02 at gmail.com
Thu Mar 22 14:40:03 UTC 2018


---
 src/mesa/state_tracker/st_atom_rasterizer.c | 12 ++++++++++
 src/mesa/state_tracker/st_atom_viewport.c   |  4 ++++
 src/mesa/state_tracker/st_context.c         |  2 ++
 src/mesa/state_tracker/st_extensions.c      | 34 +++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+)

diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index 1be072e6e3..451935d638 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -298,5 +298,17 @@ st_update_rasterizer(struct st_context *st)
    raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled;
    raster->clip_halfz = (ctx->Transform.ClipDepthMode == GL_ZERO_TO_ONE);
 
+    /* ST_NEW_RASTERIZER */
+   if (ctx->ConservativeRasterization) {
+      if (ctx->ConservativeRasterMode == GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV)
+         raster->conservative_raster_mode = PIPE_CONSERVATIVE_RASTER_POST_SNAP;
+      else
+         raster->conservative_raster_mode = PIPE_CONSERVATIVE_RASTER_PRE_SNAP;
+   } else {
+      raster->conservative_raster_mode = PIPE_CONSERVATIVE_RASTER_OFF;
+   }
+
+   raster->conservative_raster_dilate = ctx->ConservativeRasterDilate;
+
    cso_set_rasterizer(st->cso_context, raster);
 }
diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c
index 6e3347e7cf..1accaa363b 100644
--- a/src/mesa/state_tracker/st_atom_viewport.c
+++ b/src/mesa/state_tracker/st_atom_viewport.c
@@ -50,9 +50,13 @@ st_update_viewport( struct st_context *st )
    for (i = 0; i < st->state.num_viewports; i++) {
       float *scale = st->state.viewport[i].scale;
       float *translate = st->state.viewport[i].translate;
+      uint16_t* subpixel_precision = st->state.viewport[i].subpixel_precision;
 
       _mesa_get_viewport_xform(ctx, i, scale, translate);
 
+      subpixel_precision[0] = ctx->SubpixelPrecisionBias[0];
+      subpixel_precision[1] = ctx->SubpixelPrecisionBias[1];
+
       /* _NEW_BUFFERS */
       /* Drawing to a window where the coordinate system is upside down. */
       if (st->state.fb_orientation == Y_0_TOP) {
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index de30905dd2..0bcccdf84f 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -344,6 +344,8 @@ st_init_driver_flags(struct st_context *st)
    f->NewPolygonState = ST_NEW_RASTERIZER;
    f->NewPolygonStipple = ST_NEW_POLY_STIPPLE;
    f->NewViewport = ST_NEW_VIEWPORT;
+   f->NewNvConservativeRasterization = ST_NEW_RASTERIZER;
+   f->NewNvConservativeRasterizationParams = ST_NEW_RASTERIZER;
 }
 
 
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index bea61f21cb..02832f3951 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -494,6 +494,16 @@ void st_init_limits(struct pipe_screen *screen,
    c->UseSTD430AsDefaultPacking =
       screen->get_param(screen, PIPE_CAP_LOAD_CONSTBUF);
 
+   c->MaxSubpixelPrecisionBiasBits =
+      screen->get_param(screen, PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS);
+
+   c->ConservativeRasterDilateRange[0] =
+      screen->get_paramf(screen, PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE);
+   c->ConservativeRasterDilateRange[1] =
+      screen->get_paramf(screen, PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE);
+   c->ConservativeRasterDilateGranularity =
+      screen->get_paramf(screen, PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY);
+
    /* limit the max combined shader output resources to a driver limit */
    temp = screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES);
    if (temp > 0 && c->MaxCombinedShaderOutputResources > temp)
@@ -1363,4 +1373,28 @@ void st_init_extensions(struct pipe_screen *screen,
       extensions->ARB_texture_cube_map_array &&
       extensions->ARB_texture_stencil8 &&
       extensions->ARB_texture_multisample;
+
+   if (screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_TRIANGLES) &&
+       screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_POINTS_LINES) &&
+       screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE)) {
+      float max_dilate;
+      bool pre_snap_triangles, pre_snap_points_lines;
+
+      max_dilate = screen->get_paramf(screen, PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE);
+
+      pre_snap_triangles =
+         screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES);
+      pre_snap_points_lines =
+         screen->get_param(screen, PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_POINTS_LINES);
+
+      extensions->NV_conservative_raster =
+         screen->get_param(screen, PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS) > 1;
+
+      if (extensions->NV_conservative_raster) {
+         extensions->NV_conservative_raster_dilate = max_dilate>=0.75;
+         extensions->NV_conservative_raster_pre_snap_triangles = pre_snap_triangles;
+         extensions->NV_conservative_raster_pre_snap =
+            pre_snap_triangles && pre_snap_points_lines;
+      }
+   }
 }
-- 
2.14.3



More information about the mesa-dev mailing list