intel/fs: Break out yet another FB write helper
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 3 Dec 2021 16:45:48 +0000 (10:45 -0600)
committerMarge Bot <emma+marge@anholt.net>
Mon, 6 Feb 2023 09:12:18 +0000 (09:12 +0000)
This new helper, do_emit_fb_writes() does the actual walk over all the
render targets to emit each of the different FB writes.  We want this in
a helper because we're about to go a bit crazy with coarse.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21094>

src/intel/compiler/brw_fs.h
src/intel/compiler/brw_fs_visitor.cpp

index b779601..454b587 100644 (file)
@@ -386,6 +386,7 @@ public:
    fs_inst *emit_single_fb_write(const brw::fs_builder &bld,
                                  fs_reg color1, fs_reg color2,
                                  fs_reg src0_alpha, unsigned components);
+   void do_emit_fb_writes(int nr_color_regions, bool replicate_alpha);
    void emit_fb_writes();
    fs_inst *emit_non_coherent_fb_read(const brw::fs_builder &bld,
                                       const fs_reg &dst, unsigned target);
index 791ef26..953c4ed 100644 (file)
@@ -808,42 +808,11 @@ fs_visitor::emit_single_fb_write(const fs_builder &bld,
 }
 
 void
-fs_visitor::emit_fb_writes()
+fs_visitor::do_emit_fb_writes(int nr_color_regions, bool replicate_alpha)
 {
-   assert(stage == MESA_SHADER_FRAGMENT);
-   struct brw_wm_prog_data *prog_data = brw_wm_prog_data(this->prog_data);
-   brw_wm_prog_key *key = (brw_wm_prog_key*) this->key;
-
    fs_inst *inst = NULL;
 
-   if (source_depth_to_render_target && devinfo->ver == 6) {
-      /* For outputting oDepth on gfx6, SIMD8 writes have to be used.  This
-       * would require SIMD8 moves of each half to message regs, e.g. by using
-       * the SIMD lowering pass.  Unfortunately this is more difficult than it
-       * sounds because the SIMD8 single-source message lacks channel selects
-       * for the second and third subspans.
-       */
-      limit_dispatch_width(8, "Depth writes unsupported in SIMD16+ mode.\n");
-   }
-
-   if (nir->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL)) {
-      /* From the 'Render Target Write message' section of the docs:
-       * "Output Stencil is not supported with SIMD16 Render Target Write
-       * Messages."
-       */
-      limit_dispatch_width(8, "gl_FragStencilRefARB unsupported "
-                           "in SIMD16+ mode.\n");
-   }
-
-   /* ANV doesn't know about sample mask output during the wm key creation
-    * so we compute if we need replicate alpha and emit alpha to coverage
-    * workaround here.
-    */
-   const bool replicate_alpha = key->alpha_test_replicate_alpha ||
-      (key->nr_color_regions > 1 && key->alpha_to_coverage &&
-       (sample_mask.file == BAD_FILE || devinfo->ver == 6));
-
-   for (int target = 0; target < key->nr_color_regions; target++) {
+   for (int target = 0; target < nr_color_regions; target++) {
       /* Skip over outputs that weren't written. */
       if (this->outputs[target].file == BAD_FILE)
          continue;
@@ -860,10 +829,6 @@ fs_visitor::emit_fb_writes()
       inst->target = target;
    }
 
-   prog_data->dual_src_blend = (this->dual_src_output.file != BAD_FILE &&
-                                this->outputs[0].file != BAD_FILE);
-   assert(!prog_data->dual_src_blend || key->nr_color_regions == 1);
-
    if (inst == NULL) {
       /* Even if there's no color buffers enabled, we still need to send
        * alpha out the pipeline to our null renderbuffer to support
@@ -883,6 +848,45 @@ fs_visitor::emit_fb_writes()
 
    inst->last_rt = true;
    inst->eot = true;
+}
+
+void
+fs_visitor::emit_fb_writes()
+{
+   assert(stage == MESA_SHADER_FRAGMENT);
+   struct brw_wm_prog_data *prog_data = brw_wm_prog_data(this->prog_data);
+   brw_wm_prog_key *key = (brw_wm_prog_key*) this->key;
+
+   if (source_depth_to_render_target && devinfo->ver == 6) {
+      /* For outputting oDepth on gfx6, SIMD8 writes have to be used.  This
+       * would require SIMD8 moves of each half to message regs, e.g. by using
+       * the SIMD lowering pass.  Unfortunately this is more difficult than it
+       * sounds because the SIMD8 single-source message lacks channel selects
+       * for the second and third subspans.
+       */
+      limit_dispatch_width(8, "Depth writes unsupported in SIMD16+ mode.\n");
+   }
+
+   if (nir->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_STENCIL)) {
+      /* From the 'Render Target Write message' section of the docs:
+       * "Output Stencil is not supported with SIMD16 Render Target Write
+       * Messages."
+       */
+      limit_dispatch_width(8, "gl_FragStencilRefARB unsupported "
+                           "in SIMD16+ mode.\n");
+   }
+
+   /* ANV doesn't know about sample mask output during the wm key creation
+    * so we compute if we need replicate alpha and emit alpha to coverage
+    * workaround here.
+    */
+   const bool replicate_alpha = key->alpha_test_replicate_alpha ||
+      (key->nr_color_regions > 1 && key->alpha_to_coverage &&
+       (sample_mask.file == BAD_FILE || devinfo->ver == 6));
+
+   prog_data->dual_src_blend = (this->dual_src_output.file != BAD_FILE &&
+                                this->outputs[0].file != BAD_FILE);
+   assert(!prog_data->dual_src_blend || key->nr_color_regions == 1);
 
    if (devinfo->ver >= 11 && devinfo->ver <= 12 &&
        prog_data->dual_src_blend) {
@@ -900,6 +904,8 @@ fs_visitor::emit_fb_writes()
       limit_dispatch_width(8, "Dual source blending unsupported "
                            "in SIMD16 and SIMD32 modes.\n");
    }
+
+   do_emit_fb_writes(key->nr_color_regions, replicate_alpha);
 }
 
 void