i965: Introduce state flag for blorp
[mesa.git] / src / mesa / drivers / dri / i965 / brw_wm.c
index 5c49db9e63eeeb7ae38ab590ef641fb3f625ed15..dbc626c0933d41c3b4daf15fbd2875265fb38b7c 100644 (file)
@@ -36,6 +36,7 @@
 #include "program/program.h"
 #include "intel_mipmap_tree.h"
 #include "brw_nir.h"
+#include "brw_program.h"
 
 #include "util/ralloc.h"
 
@@ -179,17 +180,6 @@ brw_codegen_wm_prog(struct brw_context *brw,
    return true;
 }
 
-static bool
-key_debug(struct brw_context *brw, const char *name, int a, int b)
-{
-   if (a != b) {
-      perf_debug("  %s %d->%d\n", name, a, b);
-      return true;
-   } else {
-      return false;
-   }
-}
-
 bool
 brw_debug_recompile_sampler_key(struct brw_context *brw,
                                 const struct brw_sampler_prog_key_data *old_key,
@@ -212,6 +202,9 @@ brw_debug_recompile_sampler_key(struct brw_context *brw,
    found |= key_debug(brw, "compressed multisample layout",
                       old_key->compressed_multisample_layout_mask,
                       key->compressed_multisample_layout_mask);
+   found |= key_debug(brw, "16x msaa",
+                      old_key->msaa_16,
+                      key->msaa_16);
 
    for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
       found |= key_debug(brw, "textureGather workarounds",
@@ -259,8 +252,6 @@ brw_wm_debug_recompile(struct brw_context *brw,
                       old_key->flat_shade, key->flat_shade);
    found |= key_debug(brw, "per-sample shading",
                       old_key->persample_shading, key->persample_shading);
-   found |= key_debug(brw, "per-sample shading and 2x MSAA",
-                      old_key->persample_2x, key->persample_2x);
    found |= key_debug(brw, "number of color buffers",
                       old_key->nr_color_regions, key->nr_color_regions);
    found |= key_debug(brw, "MRT alpha test or alpha-to-coverage",
@@ -269,6 +260,8 @@ brw_wm_debug_recompile(struct brw_context *brw,
                       old_key->render_to_fbo, key->render_to_fbo);
    found |= key_debug(brw, "fragment color clamping",
                       old_key->clamp_fragment_color, key->clamp_fragment_color);
+   found |= key_debug(brw, "multisampled FBO",
+                      old_key->multisample_fbo, key->multisample_fbo);
    found |= key_debug(brw, "line smoothing",
                       old_key->line_aa, key->line_aa);
    found |= key_debug(brw, "renderbuffer height",
@@ -371,6 +364,11 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
          if (brw->gen >= 7 &&
              intel_tex->mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
             key->compressed_multisample_layout_mask |= 1 << s;
+
+            if (intel_tex->mt->num_samples >= 16) {
+               assert(brw->gen >= 9);
+               key->msaa_16 |= 1 << s;
+            }
          }
       }
    }
@@ -408,7 +406,6 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
    GLuint lookup = 0;
    GLuint line_aa;
    bool program_uses_dfdy = fp->program.UsesDFdy;
-   const bool multisample_fbo = _mesa_geometric_samples(ctx->DrawBuffer) > 1;
 
    memset(key, 0, sizeof(*key));
 
@@ -517,6 +514,10 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
    /* _NEW_BUFFERS */
    key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers;
 
+   /* _NEW_COLOR */
+   key->force_dual_color_blend = brw->dual_color_blend_by_location &&
+      (ctx->Color.BlendEnabled & 1) && ctx->Color.Blend[0]._UsesDualSrc;
+
    /* _NEW_MULTISAMPLE, _NEW_COLOR, _NEW_BUFFERS */
    key->replicate_alpha = ctx->DrawBuffer->_NumColorDrawBuffers > 1 &&
       (ctx->Multisample.SampleAlphaToCoverage || ctx->Color.AlphaEnabled);
@@ -525,17 +526,13 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
    /* Ignore sample qualifier while computing this flag. */
    key->persample_shading =
       _mesa_get_min_invocations_per_fragment(ctx, &fp->program, true) > 1;
-   if (key->persample_shading)
-      key->persample_2x = _mesa_geometric_samples(ctx->DrawBuffer) == 2;
 
    key->compute_pos_offset =
       _mesa_get_min_invocations_per_fragment(ctx, &fp->program, false) > 1 &&
       fp->program.Base.SystemValuesRead & SYSTEM_BIT_SAMPLE_POS;
 
-   key->compute_sample_id =
-      multisample_fbo &&
-      ctx->Multisample.Enabled &&
-      (fp->program.Base.SystemValuesRead & SYSTEM_BIT_SAMPLE_ID);
+   key->multisample_fbo = ctx->Multisample.Enabled &&
+                          _mesa_geometric_samples(ctx->DrawBuffer) > 1;
 
    /* BRW_NEW_VUE_MAP_GEOM_OUT */
    if (brw->gen < 6 || _mesa_bitcount_64(fp->program.Base.InputsRead &