<div dir="ltr">On 5 August 2013 15:37, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">New function clamp_tex_coords() clamps the texture coordinates<br>
to texture boundaries. This function will also be utilized later<br>
for the BLORP implementation of single-sample scaled blit with<br>
bilinear filter.<br>
<br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 63 +++++++++++++++++-----------<br>
1 file changed, 39 insertions(+), 24 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
index c86734f..8c0db48 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
@@ -631,6 +631,9 @@ private:<br>
void decode_msaa(unsigned num_samples, intel_msaa_layout layout);<br>
void kill_if_outside_dst_rect();<br>
void translate_dst_to_src();<br>
+ void clamp_tex_coords(struct brw_reg regX, struct brw_reg regY,<br>
+ struct brw_reg clampX0, struct brw_reg clampY0,<br>
+ struct brw_reg clampX1, struct brw_reg clampY1);<br>
void single_to_blend();<br>
void manual_blend_average(unsigned num_samples);<br>
void manual_blend_bilinear(unsigned num_samples);<br>
@@ -1389,6 +1392,10 @@ brw_blorp_blit_program::kill_if_outside_dst_rect()<br>
brw_pop_insn_state(&func);<br>
}<br>
<br>
+#define X_f retype(X, BRW_REGISTER_TYPE_F)<br>
+#define Y_f retype(Y, BRW_REGISTER_TYPE_F)<br>
+#define Xp_f retype(Xp, BRW_REGISTER_TYPE_F)<br>
+#define Yp_f retype(Yp, BRW_REGISTER_TYPE_F)<br></blockquote><div><br></div><div>I don't see why it's necessary to turn these into #defines. It looks like they are only used in translate_dst_to_src(), so it should be ok to keep them as local variables.<br>
<br></div><div>With that part of the patch reverted, patches 1 and 2 are:<br><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/**<br>
* Emit code to translate from destination (X, Y) coordinates to source (X, Y)<br>
* coordinates.<br>
@@ -1396,11 +1403,6 @@ brw_blorp_blit_program::kill_if_outside_dst_rect()<br>
void<br>
brw_blorp_blit_program::translate_dst_to_src()<br>
{<br>
- struct brw_reg X_f = retype(X, BRW_REGISTER_TYPE_F);<br>
- struct brw_reg Y_f = retype(Y, BRW_REGISTER_TYPE_F);<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>
-<br>
brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED);<br>
/* Move the UD coordinates to float registers. */<br>
brw_MOV(&func, Xp_f, X);<br>
@@ -1425,25 +1427,9 @@ brw_blorp_blit_program::translate_dst_to_src()<br>
/* Clamp the X, Y texture coordinates to properly handle the sampling of<br>
* texels on texture edges.<br>
*/<br>
- brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L,<br>
- X_f, brw_imm_f(0.0));<br>
- brw_MOV(&func, X_f, brw_imm_f(0.0));<br>
- brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
-<br>
- brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_GE,<br>
- X_f, rect_grid_x1);<br>
- brw_MOV(&func, X_f, rect_grid_x1);<br>
- brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
-<br>
- brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L,<br>
- Y_f, brw_imm_f(0.0));<br>
- brw_MOV(&func, Y_f, brw_imm_f(0.0));<br>
- brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
-<br>
- brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_GE,<br>
- Y_f, rect_grid_y1);<br>
- brw_MOV(&func, Y_f, rect_grid_y1);<br>
- brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+ clamp_tex_coords(X_f, Y_f,<br>
+ brw_imm_f(0.0), brw_imm_f(0.0),<br>
+ rect_grid_x1, rect_grid_y1);<br>
<br>
/* Store the fractional parts to be used as bilinear interpolation<br>
* coefficients.<br>
@@ -1467,6 +1453,35 @@ brw_blorp_blit_program::translate_dst_to_src()<br>
brw_set_compression_control(&func, BRW_COMPRESSION_NONE);<br>
}<br>
<br>
+void<br>
+brw_blorp_blit_program::clamp_tex_coords(struct brw_reg regX,<br>
+ struct brw_reg regY,<br>
+ struct brw_reg clampX0,<br>
+ struct brw_reg clampY0,<br>
+ struct brw_reg clampX1,<br>
+ struct brw_reg clampY1)<br>
+{<br>
+ brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L, regX, clampX0);<br>
+ brw_MOV(&func, regX, clampX0);<br>
+ brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+<br>
+ brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_G, regX, clampX1);<br>
+ brw_MOV(&func, regX, clampX1);<br>
+ brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+<br>
+ brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L, regY, clampY0);<br>
+ brw_MOV(&func, regY, clampY0);<br>
+ brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+<br>
+ brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_G, regY, clampY1);<br>
+ brw_MOV(&func, regY, clampY1);<br>
+ brw_set_predicate_control(&func, BRW_PREDICATE_NONE);<br>
+}<br>
+#undef X_f<br>
+#undef Y_f<br>
+#undef Xp_f<br>
+#undef Yp_f<br>
+<br>
/**<br>
* Emit code to transform the X and Y coordinates as needed for blending<br>
* together the different samples in an MSAA texture.<br>
<span><font color="#888888">--<br>
1.8.1.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>