<div dir="ltr">On 28 June 2013 16:59, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im">Current implementation of ext_framebuffer_multisample_blit_scaled in<br>
i965/blorp uses nearest filtering for multisample scaled blits. Using<br>
nearest filtering produces blocky artifacts and negates the benefits<br>
of MSAA. That is the reason why extension was not enabled on i965.<br>
<br>
This patch implements the bilinear filtering of samples in blorp engine.<br>
Images generated with this patch are free from blocky artifacts and show<br>
big improvement in visual quality.<br>
<br>
Observed no piglit and gles3 regressions.<br>
<br>
V3:<br>
- Algorithm used for filtering assumes a rectangular grid of samples<br>
  roughly corresponding to sample locations.<br>
- Test the boundary conditions on the edges of texture.<br>
<br>
</div><div class="im">V4:<br>
- Clip texcoords and use conditional MOVs.<br>
- Send texture dimensions as push constants.<br>
- Remove the optimization in case of scaled multisample blits.<br>
<br>
</div>V5:<br>
- Move mcs_fetch() inside the 'for' loop after computing pixel coordinates.<br>
<div class="im"><br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>><br>
---<br>
<br>
 src/mesa/drivers/dri/i965/brw_blorp.h        |  16 ++<br>
</div> src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 278 +++++++++++++++++++++++++--<br>
 2 files changed, 273 insertions(+), 21 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
index ffc27cc..9277d09 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_blorp.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
<div class="im">@@ -178,8 +178,15 @@ struct brw_blorp_wm_push_constants<br>
    uint32_t dst_x1;<br>
    uint32_t dst_y0;<br>
    uint32_t dst_y1;<br>
+   /* Top right coordinates of the rectangular sample grid used for<br>
</div>+    * multisample scaled blitting.<br>
+    */<br>
<div class="im">+   float sample_grid_x1;<br>
+   float sample_grid_y1;<br>
    brw_blorp_coord_transform_params x_transform;<br>
    brw_blorp_coord_transform_params y_transform;<br>
+   /* Pad out to an integral number of registers */<br>
+   uint32_t pad[6];<br>
 };<br>
<br>
 /* Every 32 bytes of push constant data constitutes one GEN register. */<br>
</div>@@ -319,6 +326,15 @@ struct brw_blorp_blit_prog_key<br>
<div class="im">     * than one sample per pixel.<br>
     */<br>
    bool persample_msaa_dispatch;<br>
+<br>
+   /* True for scaled blitting. */<br>
+   bool blit_scaled;<br>
+<br>
</div><div class="im">+   /* Scale factors between the pixel grid and the grid of samples. We're<br>
+    * using grid of samples for bilinear filetring in multisample scaled blits.<br>
+    */<br>
+   float x_scale;<br>
+   float y_scale;<br>
 };<br>
<br>
</div><div class="im"> class brw_blorp_blit_params : public brw_blorp_params<br>
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
</div>index 8694128..d39bae1 100644<br>
<div class="im">--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
@@ -622,7 +622,8 @@ private:<br>
    void kill_if_outside_dst_rect();<br>
    void translate_dst_to_src();<br>
    void single_to_blend();<br>
-   void manual_blend(unsigned num_samples);<br>
+   void manual_blend_average(unsigned num_samples);<br>
</div>+   void manual_blend_bilinear(unsigned num_samples);<br>
<div class="im">    void sample(struct brw_reg dst);<br>
    void texel_fetch(struct brw_reg dst);<br>
    void mcs_fetch();<br>
</div><div class="im">@@ -651,6 +652,11 @@ private:<br>
    struct brw_reg dst_x1;<br>
    struct brw_reg dst_y0;<br>
    struct brw_reg dst_y1;<br>
+   /* Top right coordinates of the rectangular sample grid used for<br>
+    * multisample scaled blitting.<br>
</div>+    */<br>
<div class="im">+   struct brw_reg sample_grid_x1;<br>
+   struct brw_reg sample_grid_y1;<br>
    struct {<br>
       struct brw_reg multiplier;<br>
       struct brw_reg offset;<br>
</div>@@ -676,6 +682,16 @@ private:<br>
<div class="im">     */<br>
    struct brw_reg y_coords[2];<br>
<br>
+   /* X, Y coordinates of the pixel from which we need to fetch the specific<br>
+    *  sample. These are used for multisample scaled blitting.<br>
</div>+    */<br>
<div class="im">+   struct brw_reg x_sample_coords;<br>
+   struct brw_reg y_sample_coords;<br>
+<br>
</div><div class="im">+   /* Fractional parts of the x and y coordinates, used as bilinear interpolation coefficients */<br>
+   struct brw_reg x_frac;<br>
+   struct brw_reg y_frac;<br>
+<br>
</div><div class="im">    /* Which element of x_coords and y_coords is currently in use.<br>
     */<br>
    int xy_coord_index;<br>
</div>@@ -814,15 +830,17 @@ brw_blorp_blit_program::compile(struct brw_context *brw,<br>
<div class="im">     * that we want to texture from.  Exception: if we are blending, then S is<br>
     * irrelevant, because we are going to fetch all samples.<br>
     */<br>
-   if (key->blend) {<br>
+   if (key->blend && !key->blit_scaled) {<br>
       if (brw->intel.gen == 6) {<br>
          /* Gen6 hardware an automatically blend using the SAMPLE message */<br>
          single_to_blend();<br>
          sample(texture_data[0]);<br>
       } else {<br>
          /* Gen7+ hardware doesn't automaticaly blend. */<br>
-         manual_blend(key->src_samples);<br>
+         manual_blend_average(key->src_samples);<br>
       }<br>
+   } else if(key->blend && key->blit_scaled) {<br>
</div>+      manual_blend_bilinear(key->src_samples);<br>
<div class="im">    } else {<br>
       /* We aren't blending, which means we just want to fetch a single sample<br>
        * from the source surface.  The address that we want to fetch from is<br>
</div><div><div class="h5">@@ -872,18 +890,21 @@ void<br>
 brw_blorp_blit_program::alloc_push_const_regs(int base_reg)<br>
 {<br>
 #define CONST_LOC(name) offsetof(brw_blorp_wm_push_constants, name)<br>
-#define ALLOC_REG(name) \<br>
+#define ALLOC_REG(name, offset) \<br>
    this->name = \<br>
-      brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, base_reg, CONST_LOC(name) / 4)<br>
-<br>
-   ALLOC_REG(dst_x0);<br>
-   ALLOC_REG(dst_x1);<br>
-   ALLOC_REG(dst_y0);<br>
-   ALLOC_REG(dst_y1);<br>
-   ALLOC_REG(x_transform.multiplier);<br>
-   ALLOC_REG(x_transform.offset);<br>
-   ALLOC_REG(y_transform.multiplier);<br>
-   ALLOC_REG(y_transform.offset);<br>
+      brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, base_reg + offset / 32, \<br>
+                   offset >= 32 ? (offset - 32) / 4 : offset / 4)<br></div></div></blockquote><div><br></div><div>I don't understand why it's necessary to add "offset" as a parameter to the ALLOC_REG macro.  Also, I see that you're trying to generalize ALLOC_REG to work when the offset is >= 32, which is great, but as long as we're generalizing it we should generalize it fully--what you've written doesn't work for offsets >= 64.  How about this instead:<br>
<br><br>#define ALLOC_REG(name) \<br>   this->name = \<br>      brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, \<br>                   base_reg + CONST_LOC(name) / 32, \<br>                   (CONST_LOC(name) % 32) / 4)<br><br>
</div><div>With that fixed, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br><br>Thanks for all your hard work on this, Anuj.<br></div><div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5">
+<br>
+   ALLOC_REG(dst_x0, CONST_LOC(dst_x0));<br>
+   ALLOC_REG(dst_x1, CONST_LOC(dst_x1));<br>
+   ALLOC_REG(dst_y0, CONST_LOC(dst_y0));<br>
+   ALLOC_REG(dst_y1, CONST_LOC(dst_y1));<br>
+   ALLOC_REG(sample_grid_x1, CONST_LOC(sample_grid_x1));<br>
+   ALLOC_REG(sample_grid_y1, CONST_LOC(sample_grid_y1));<br>
+   ALLOC_REG(x_transform.multiplier, CONST_LOC(x_transform.multiplier));<br>
+   ALLOC_REG(x_transform.offset, CONST_LOC(x_transform.offset));<br>
+   ALLOC_REG(y_transform.multiplier, CONST_LOC(y_transform.multiplier));<br>
+   ALLOC_REG(y_transform.offset, CONST_LOC(y_transform.offset));<br>
 #undef CONST_LOC<br>
 #undef ALLOC_REG<br>
 }<br>
</div></div>@@ -913,6 +934,18 @@ brw_blorp_blit_program::alloc_regs()<br>
<div class="im">          = retype(brw_vec8_grf(reg, 0), BRW_REGISTER_TYPE_UD);<br>
       reg += 2;<br>
    }<br>
+<br>
+   if (key->blit_scaled && key->blend) {<br>
+      this->x_sample_coords = brw_vec8_grf(reg, 0);<br>
+      reg += 2;<br>
+      this->y_sample_coords = brw_vec8_grf(reg, 0);<br>
+      reg += 2;<br>
</div>+      this->x_frac = brw_vec8_grf(reg, 0);<br>
+      reg += 2;<br>
+      this->y_frac = brw_vec8_grf(reg, 0);<br>
<div class="im">+      reg += 2;<br>
+   }<br>
+<br>
    this->xy_coord_index = 0;<br>
    this->sample_index<br>
       = retype(brw_vec8_grf(reg, 0), BRW_REGISTER_TYPE_UD);<br>
</div>@@ -1368,11 +1401,59 @@ brw_blorp_blit_program::translate_dst_to_src()<br>
<div class="im">    brw_MUL(&func, Y_f, Yp_f, y_transform.multiplier);<br>
    brw_ADD(&func, X_f, X_f, x_transform.offset);<br>
    brw_ADD(&func, Y_f, Y_f, y_transform.offset);<br>
-   /* Round the float coordinates down to nearest integer by moving to<br>
-    * UD registers.<br>
-    */<br>
-   brw_MOV(&func, Xp, X_f);<br>
-   brw_MOV(&func, Yp, Y_f);<br>
+   if (key->blit_scaled && key->blend) {<br>
</div><div class="im">+      /* Translate coordinates to lay out the samples in a rectangular  grid<br>
+       * roughly corresponding to sample locations.<br>
+       */<br>
</div><div class="im">+      brw_MUL(&func, X_f, X_f, brw_imm_f(key->x_scale));<br>
+      brw_MUL(&func, Y_f, Y_f, brw_imm_f(key->y_scale));<br>
+     /* Adjust coordinates so that integers represent pixel centers rather<br>
+      * than pixel edges.<br>
</div>+      */<br>
+      brw_ADD(&func, X_f, X_f, brw_imm_f(-0.5));<br>
+      brw_ADD(&func, Y_f, Y_f, brw_imm_f(-0.5));<br>
+<br>
+      /* Clamp the X, Y texture coordinates to properly handle the sampling of<br>
+       *  texels on texture edges.<br>
<div class="im">+       */<br>
+      brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L,<br>
</div><div class="im">+              X_f, brw_imm_f(0.0));<br>
+      brw_MOV(&func, X_f, brw_imm_f(0.0));<br>
</div>+      brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+<br>
+      brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_GE,<br>
<div class="im">+              X_f, sample_grid_x1);<br>
+      brw_MOV(&func, X_f, sample_grid_x1);<br>
</div>+      brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+<br>
+      brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L,<br>
<div class="im">+              Y_f, brw_imm_f(0.0));<br>
+      brw_MOV(&func, Y_f, brw_imm_f(0.0));<br>
</div>+      brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+<br>
<div class="im">+      brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_GE,<br>
+              Y_f, sample_grid_y1);<br>
+      brw_MOV(&func, Y_f, sample_grid_y1);<br>
</div>+      brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+<br>
<div class="im">+      /* Store the fractional parts to be used as bilinear interpolation<br>
+       *  coefficients.<br>
+      */<br>
+      brw_FRC(&func, x_frac, X_f);<br>
+      brw_FRC(&func, y_frac, Y_f);<br>
</div><div class="im">+<br>
+      /* Round the float coordinates down to nearest integer */<br>
+      brw_RNDD(&func, Xp_f, X_f);<br>
+      brw_RNDD(&func, Yp_f, Y_f);<br>
</div>+      brw_MUL(&func, X_f, Xp_f, brw_imm_f(1 / key->x_scale));<br>
+      brw_MUL(&func, Y_f, Yp_f, brw_imm_f(1 / key->y_scale));<br>
<div class="im">+   } else {<br>
+      /* Round the float coordinates down to nearest integer by moving to<br>
+       * UD registers.<br>
+       */<br>
+      brw_MOV(&func, Xp, X_f);<br>
+      brw_MOV(&func, Yp, Y_f);<br>
+   }<br>
    SWAP_XY_AND_XPYP();<br>
    brw_set_compression_control(&func, BRW_COMPRESSION_NONE);<br>
 }<br>
</div>@@ -1418,7 +1499,7 @@ inline int count_trailing_one_bits(unsigned value)<br>
<div class="im"><br>
<br>
 void<br>
-brw_blorp_blit_program::manual_blend(unsigned num_samples)<br>
+brw_blorp_blit_program::manual_blend_average(unsigned num_samples)<br>
 {<br>
</div><div class="im">    if (key->tex_layout == INTEL_MSAA_LAYOUT_CMS)<br>
</div>       mcs_fetch();<br>
@@ -1523,6 +1604,143 @@ brw_blorp_blit_program::manual_blend(unsigned num_samples)<br>
       brw_ENDIF(&func);<br>
 }<br>
<br>
+void<br>
+brw_blorp_blit_program::manual_blend_bilinear(unsigned num_samples)<br>
<div class="im">+{<br>
+   /* We do this computation by performing the following operations:<br>
+    *<br>
+    * In case of 4x, 8x MSAA:<br>
+    * - Compute the pixel coordinates and sample numbers (a, b, c, d)<br>
+    *   which are later used for interpolation<br>
+    * - linearly interpolate samples a and b in X<br>
+    * - linearly interpolate samples c and d in X<br>
+    * - linearly interpolate the results of last two operations in Y<br>
+    *<br>
+    *   result = lrp(lrp(a + b) + lrp(c + d))<br>
+    */<br>
+   struct brw_reg Xp_f = retype(Xp, BRW_REGISTER_TYPE_F);<br>
+   struct brw_reg Yp_f = retype(Yp, BRW_REGISTER_TYPE_F);<br>
+   struct brw_reg t1_f = retype(t1, BRW_REGISTER_TYPE_F);<br>
+   struct brw_reg t2_f = retype(t2, BRW_REGISTER_TYPE_F);<br>
+<br>
+   for (unsigned i = 0; i < 4; ++i) {<br>
+      assert(i < ARRAY_SIZE(texture_data));<br>
+      s_is_zero = false;<br>
+<br>
+      /* Compute pixel coordinates */<br>
+      brw_ADD(&func, vec16(x_sample_coords), Xp_f,<br>
</div>+              brw_imm_f((float)(i & 0x1) * (1.0 / key->x_scale)));<br>
+      brw_ADD(&func, vec16(y_sample_coords), Yp_f,<br>
<div class="im">+              brw_imm_f((float)((i >> 1) & 0x1) * (1.0 / key->y_scale)));<br>
</div><div class="im">+      brw_MOV(&func, vec16(X), x_sample_coords);<br>
+      brw_MOV(&func, vec16(Y), y_sample_coords);<br>
+<br>
</div>+      /* The MCS value we fetch has to match up with the pixel that we're<br>
+       * sampling from. Since we sample from different pixels in each<br>
+       * iteration of this "for" loop, the call to mcs_fetch() should be<br>
+       * here inside the loop after computing the pixel coordinates.<br>
+       */<br>
<div class="im">+      if (key->tex_layout == INTEL_MSAA_LAYOUT_CMS)<br>
+         mcs_fetch();<br>
</div>+<br>
<div class="im">+     /* Compute sample index and map the sample index to a sample number.<br>
+      * Sample index layout shows the numbering of slots in a rectangular<br>
+      * grid of samples with in a pixel. Sample number layout shows the<br>
+      * rectangular grid of samples roughly corresponding to the real sample<br>
+      * locations with in a pixel.<br>
+      * In case of 4x MSAA, layout of sample indices matches the layout of<br>
+      * sample numbers:<br>
+      *           ---------<br>
+      *           | 0 | 1 |<br>
+      *           ---------<br>
+      *           | 2 | 3 |<br>
+      *           ---------<br>
</div>+      *<br>
<div class="im">+      * In case of 8x MSAA the two layouts don't match.<br>
+      * sample index layout :  ---------    sample number layout :  ---------<br>
+      *                        | 0 | 1 |                            | 5 | 2 |<br>
+      *                        ---------                            ---------<br>
+      *                        | 2 | 3 |                            | 4 | 6 |<br>
+      *                        ---------                            ---------<br>
+      *                        | 4 | 5 |                            | 0 | 3 |<br>
+      *                        ---------                            ---------<br>
+      *                        | 6 | 7 |                            | 7 | 1 |<br>
+      *                        ---------                            ---------<br>
+      */<br>
</div><div class="im">+      brw_FRC(&func, vec16(t1_f), x_sample_coords);<br>
+      brw_FRC(&func, vec16(t2_f), y_sample_coords);<br>
</div><div class="im">+      brw_MUL(&func, vec16(t1_f), t1_f, brw_imm_f(key->x_scale));<br>
</div>+      brw_MUL(&func, vec16(t2_f), t2_f, brw_imm_f(key->x_scale * key->y_scale));<br>
<div><div class="h5">+      brw_ADD(&func, vec16(t1_f), t1_f, t2_f);<br>
+      brw_MOV(&func, vec16(S), t1_f);<br>
+<br>
+      if (num_samples == 8) {<br>
+         /* Map the sample index to a sample number */<br>
+         brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L,<br>
+                 S, brw_imm_d(4));<br>
+         brw_IF(&func, BRW_EXECUTE_16);<br>
+         {<br>
+            brw_MOV(&func, vec16(t2), brw_imm_d(5));<br>
+            brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_EQ,<br>
+                    S, brw_imm_d(1));<br>
+            brw_MOV(&func, vec16(t2), brw_imm_d(2));<br>
+            brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+            brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_EQ,<br>
+                    S, brw_imm_d(2));<br>
+            brw_MOV(&func, vec16(t2), brw_imm_d(4));<br>
+            brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+            brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_EQ,<br>
+                    S, brw_imm_d(3));<br>
+            brw_MOV(&func, vec16(t2), brw_imm_d(6));<br>
+            brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+         }<br>
+         brw_ELSE(&func);<br>
+         {<br>
+            brw_MOV(&func, vec16(t2), brw_imm_d(0));<br>
+            brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_EQ,<br>
+                    S, brw_imm_d(5));<br>
+            brw_MOV(&func, vec16(t2), brw_imm_d(3));<br>
+            brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+            brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_EQ,<br>
+                    S, brw_imm_d(6));<br>
+            brw_MOV(&func, vec16(t2), brw_imm_d(7));<br>
+            brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+            brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_EQ,<br>
+                    S, brw_imm_d(7));<br>
+            brw_MOV(&func, vec16(t2), brw_imm_d(1));<br>
+            brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+         }<br>
+         brw_ENDIF(&func);<br>
+         brw_MOV(&func, vec16(S), t2);<br>
</div></div><div class="im">+      }<br>
+      texel_fetch(texture_data[i]);<br>
+   }<br>
+<br>
</div><div class="im">+#define SAMPLE(x, y) offset(texture_data[x], y)<br>
+   brw_set_access_mode(&func, BRW_ALIGN_16);<br>
+   for (int index = 3; index > 0; ) {<br>
</div><div class="im">+      /* Since we're doing SIMD16, 4 color channels fits in to 8 registers.<br>
+       * Counter value of 8 in 'for' loop below is used to interpolate all<br>
+       * the color components.<br>
+       */<br>
</div><div class="im">+      for (int k = 0; k < 8; ++k)<br>
+         brw_LRP(&func,<br>
+                 vec8(SAMPLE(index - 1, k)),<br>
</div>+                 offset(x_frac, k & 1),<br>
<div class="im">+                 SAMPLE(index, k),<br>
+                 SAMPLE(index - 1, k));<br>
+      index -= 2;<br>
+   }<br>
+   for (int k = 0; k < 8; ++k)<br>
+      brw_LRP(&func,<br>
+              vec8(SAMPLE(0, k)),<br>
</div>+              offset(y_frac, k & 1),<br>
<div class="im">+              vec8(SAMPLE(2, k)),<br>
+              vec8(SAMPLE(0, k)));<br>
+   brw_set_access_mode(&func, BRW_ALIGN_1);<br>
</div>+#undef SAMPLE<br>
<div class="im">+}<br>
+<br>
 /**<br>
  * Emit code to look up a value in the texture using the SAMPLE message (which<br>
  * does blending of MSAA surfaces).<br>
</div>@@ -1535,7 +1753,8 @@ brw_blorp_blit_program::sample(struct brw_reg dst)<br>
<div class="im">       SAMPLER_MESSAGE_ARG_V_FLOAT<br>
    };<br>
<br>
-   texture_lookup(dst, GEN5_SAMPLER_MESSAGE_SAMPLE, args, ARRAY_SIZE(args));<br>
+   texture_lookup(dst, GEN5_SAMPLER_MESSAGE_SAMPLE, args,<br>
+                  ARRAY_SIZE(args));<br>
 }<br>
<br>
 /**<br>
</div>@@ -1809,6 +2028,9 @@ brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw,<br>
<div class="im">                                              GLfloat dst_x1, GLfloat dst_y1,<br>
                                              bool mirror_x, bool mirror_y)<br>
 {<br>
+   struct gl_context *ctx = &brw->intel.ctx;<br>
+   const struct gl_framebuffer *read_fb = ctx->ReadBuffer;<br>
+<br>
    src.set(brw, src_mt, src_level, src_layer);<br>
    dst.set(brw, dst_mt, dst_level, dst_layer);<br>
<br>
</div>@@ -1872,6 +2094,17 @@ brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw,<br>
<div class="im">       wm_prog_key.persample_msaa_dispatch = true;<br>
    }<br>
<br>
+   /* Scaled blitting or not. */<br>
+   wm_prog_key.blit_scaled =<br>
+      ((dst_x1 - dst_x0) == (src_x1 - src_x0) &&<br>
+       (dst_y1 - dst_y0) == (src_y1 - src_y0)) ? false : true;<br>
+<br>
</div><div class="im">+   /* Scaling factors used for bilinear filtering in multisample scaled<br>
+    * blits.<br>
+    */<br>
+   wm_prog_key.x_scale = 2.0;<br>
+   wm_prog_key.y_scale = src_mt->num_samples / 2.0;<br>
</div><div class="im">+<br>
    /* The render path must be configured to use the same number of samples as<br>
     * the destination buffer.<br>
     */<br>
</div>@@ -1915,6 +2148,9 @@ brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw,<br>
<div class=""><div class="h5">    y0 = wm_push_consts.dst_y0 = dst_y0;<br>
    x1 = wm_push_consts.dst_x1 = dst_x1;<br>
    y1 = wm_push_consts.dst_y1 = dst_y1;<br>
+   wm_push_consts.sample_grid_x1 = read_fb->Width * wm_prog_key.x_scale - 1.0;<br>
+   wm_push_consts.sample_grid_y1 = read_fb->Height * wm_prog_key.y_scale - 1.0;<br>
+<br>
    wm_push_consts.x_transform.setup(src_x0, src_x1, dst_x0, dst_x1, mirror_x);<br>
    wm_push_consts.y_transform.setup(src_y0, src_y1, dst_y0, dst_y1, mirror_y);<br>
<br>
--<br>
1.8.1.4<br>
<br>
</div></div></blockquote></div><br></div></div>