[Mesa-dev] [PATCH 9/9] i965: compile replicated blorp clear program with fs generator

Topi Pohjolainen topi.pohjolainen at intel.com
Wed Nov 27 13:13:20 PST 2013


No regressions on Ivy Bridge. I also checked the eu-instruction
dump before and after, and they were identical:

0x00000000: mov(4)     g114<1>F  g2<4,4,1>F  { align1 WE_all };
0x00000010: sendc(16)  null      g114<8,8,1>F
  render ( RT write, 1, 1, 12) mlen 1 rlen 0 { align1 WE_normal 1H EOT };

The dump isn't available anymore with "blorp" option but with "fs".

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 77 ++++++---------------------
 1 file changed, 16 insertions(+), 61 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index 03614ea..af4e32c 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -34,7 +34,6 @@ extern "C" {
 
 #include "brw_blorp.h"
 #include "brw_context.h"
-#include "brw_eu.h"
 #include "brw_state.h"
 #include "brw_fs.h"
 
@@ -103,10 +102,6 @@ private:
    void *mem_ctx;
    struct brw_context *brw;
    const brw_blorp_const_color_prog_key *key;
-   struct brw_compile func;
-
-   /* Register with push constants (a single vec4) */
-   struct brw_reg clear_rgba;
 
    /* MRF used for render target writes */
    static const unsigned base_mrf = 2;
@@ -117,10 +112,8 @@ brw_blorp_const_color_program::brw_blorp_const_color_program(
       const brw_blorp_const_color_prog_key *key)
    : mem_ctx(ralloc_context(NULL)),
      brw(brw),
-     key(key),
-     clear_rgba()
+     key(key)
 {
-   brw_init_compile(brw, &func, mem_ctx);
 }
 
 brw_blorp_const_color_program::~brw_blorp_const_color_program()
@@ -352,18 +345,6 @@ brw_blorp_const_color_params::get_wm_prog(struct brw_context *brw,
    return prog_offset;
 }
 
-void
-brw_blorp_const_color_program::alloc_regs()
-{
-   int reg = prog_data.first_curbe_grf;
-
-   clear_rgba = retype(brw_vec4_grf(reg++, 0), BRW_REGISTER_TYPE_F);
-   reg += BRW_BLORP_NUM_PUSH_CONST_REGS;
-
-   /* Make sure we didn't run out of registers */
-   assert(reg <= GEN7_MRF_HACK_START);
-}
-
 const GLuint *
 brw_blorp_const_color_program::compile(struct brw_context *brw,
                                        GLuint *program_size)
@@ -379,24 +360,16 @@ brw_blorp_const_color_program::compile(struct brw_context *brw,
 
    struct brw_wm_compile *c = rzalloc(mem_ctx, struct brw_wm_compile);
 
-   alloc_regs();
-
-   brw_set_compression_control(&func, BRW_COMPRESSION_NONE);
-
-   struct brw_reg mrf_rt_write =
-      retype(vec16(brw_message_reg(base_mrf)), BRW_REGISTER_TYPE_F);
-
-   uint32_t mlen, msg_type;
    if (key->use_simd16_replicated_data) {
-      /* The message payload is a single register with the low 4 floats/ints
-       * filled with the constant clear color.
-       */
-      brw_set_mask_control(&func, BRW_MASK_DISABLE);
-      brw_MOV(&func, vec4(brw_message_reg(base_mrf)), clear_rgba);
-      brw_set_mask_control(&func, BRW_MASK_ENABLE);
+      inst = new (mem_ctx) fs_inst(
+         BRW_OPCODE_MOV,
+         fs_reg(vec4(brw_message_reg(base_mrf))),
+         fs_reg(brw_vec4_grf(prog_data.first_curbe_grf, 0)));
+      inst->force_writemask_all = true;
+      instructions.push_tail(inst);
 
-      msg_type = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED;
-      mlen = 1;
+      inst = new (mem_ctx) fs_inst(FS_OPCODE_FB_WRITE_SIMD16_REPLICATED);
+      inst->mlen = 1;
    } else {
       for (int i = 0; i < 4; i++) {
          /* The message payload is pairs of registers for 16 pixels each of r,
@@ -409,35 +382,17 @@ brw_blorp_const_color_program::compile(struct brw_context *brw,
       }
 
       inst = new (mem_ctx) fs_inst(FS_OPCODE_FB_WRITE);
-      inst->eot = true;
-      inst->base_mrf = base_mrf;
       inst->mlen = 8;
-      inst->target = BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX;
+   }
 
-      instructions.push_tail(inst);
+   inst->eot = true;
+   inst->base_mrf = base_mrf;
+   inst->target = BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX;
 
-      return fs_generator(brw, c, NULL, NULL, false).generate_assembly(
-               NULL, &instructions, program_size);
-   }
+   instructions.push_tail(inst);
 
-   /* Now write to the render target and terminate the thread */
-   brw_fb_WRITE(&func,
-                16 /* dispatch_width */,
-                base_mrf /* msg_reg_nr */,
-                mrf_rt_write /* src0 */,
-                msg_type,
-                BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX,
-                mlen,
-                0 /* response_length */,
-                true /* eot */,
-                false /* header present */);
-
-   if (unlikely(INTEL_DEBUG & DEBUG_BLORP)) {
-      printf("Native code for BLORP clear:\n");
-      brw_dump_compile(&func, stdout, 0, func.next_insn_offset);
-      printf("\n");
-   }
-   return brw_get_program(&func, program_size);
+   return fs_generator(brw, c, NULL, NULL, false).generate_assembly(
+      NULL, &instructions, program_size);
 }
 
 
-- 
1.8.3.1



More information about the mesa-dev mailing list