mesa/st: add per sample shading state to fp key and set interpolation
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 5 Jul 2014 03:01:39 +0000 (23:01 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Wed, 9 Jul 2014 23:26:32 +0000 (19:26 -0400)
This enables a gallium driver not to care about the semantics of
ARB_sample_shading vs ARB_gpu_shader5 sample attributes. When
ARB_sample_shading-style sample shading is enabled, all of the fp inputs
are marked for interpolation at the sample location.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_program.h

index 67c6157135af01c15225937d4a81c1ee05811cee..6515a98a3fbca10b6bc95855d7bf6581c36de630 100644 (file)
@@ -89,6 +89,10 @@ update_fp( struct st_context *st )
    key.clamp_color = st->clamp_frag_color_in_shader &&
                      st->ctx->Color._ClampFragmentColor;
 
+   /* Ignore sample qualifier while computing this flag. */
+   key.persample_shading =
+      _mesa_get_min_invocations_per_fragment(st->ctx, &stfp->Base, true) > 1;
+
    st->fp_variant = st_get_fp_variant(st, stfp, &key);
 
    st_reference_fragprog(st, &st->fp, stfp);
@@ -108,7 +112,7 @@ update_fp( struct st_context *st )
 const struct st_tracked_state st_update_fp = {
    "st_update_fp",                                     /* name */
    {                                                   /* dirty */
-      _NEW_BUFFERS,                                    /* mesa */
+      _NEW_BUFFERS | _NEW_MULTISAMPLE,                 /* mesa */
       ST_NEW_FRAGMENT_PROGRAM                           /* st */
    },
    update_fp                                   /* update */
index b603759f8f8f50351b7e467158ea378988398916..9d7b7c475a632e968e32ae12ab09f93ada3eef11 100644 (file)
@@ -548,6 +548,9 @@ st_translate_fragment_program(struct st_context *st,
          else
             interpLocation[slot] = TGSI_INTERPOLATE_LOC_CENTER;
 
+         if (key->persample_shading)
+            interpLocation[slot] = TGSI_INTERPOLATE_LOC_SAMPLE;
+
          switch (attr) {
          case VARYING_SLOT_POS:
             input_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
index ce9174f67f8e5b989c66ba607f27e1f37029432a..9a5b6a847a5d86311458f6d18abe800997d1620f 100644 (file)
@@ -58,6 +58,9 @@ struct st_fp_variant_key
 
    /** for ARB_color_buffer_float */
    GLuint clamp_color:1;
+
+   /** for ARB_sample_shading */
+   GLuint persample_shading:1;
 };