[Mesa-dev] [PATCH 2/3] i965/blorp: Define a function to clamp texture coordinates
Paul Berry
stereotype441 at gmail.com
Tue Aug 6 15:06:44 PDT 2013
On 5 August 2013 15:37, Anuj Phogat <anuj.phogat at gmail.com> wrote:
> New function clamp_tex_coords() clamps the texture coordinates
> to texture boundaries. This function will also be utilized later
> for the BLORP implementation of single-sample scaled blit with
> bilinear filter.
>
> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
> ---
> src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 63
> +++++++++++++++++-----------
> 1 file changed, 39 insertions(+), 24 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> index c86734f..8c0db48 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> @@ -631,6 +631,9 @@ private:
> void decode_msaa(unsigned num_samples, intel_msaa_layout layout);
> void kill_if_outside_dst_rect();
> void translate_dst_to_src();
> + void clamp_tex_coords(struct brw_reg regX, struct brw_reg regY,
> + struct brw_reg clampX0, struct brw_reg clampY0,
> + struct brw_reg clampX1, struct brw_reg clampY1);
> void single_to_blend();
> void manual_blend_average(unsigned num_samples);
> void manual_blend_bilinear(unsigned num_samples);
> @@ -1389,6 +1392,10 @@ brw_blorp_blit_program::kill_if_outside_dst_rect()
> brw_pop_insn_state(&func);
> }
>
> +#define X_f retype(X, BRW_REGISTER_TYPE_F)
> +#define Y_f retype(Y, BRW_REGISTER_TYPE_F)
> +#define Xp_f retype(Xp, BRW_REGISTER_TYPE_F)
> +#define Yp_f retype(Yp, BRW_REGISTER_TYPE_F)
>
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.
With that part of the patch reverted, patches 1 and 2 are:
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
> /**
> * Emit code to translate from destination (X, Y) coordinates to source
> (X, Y)
> * coordinates.
> @@ -1396,11 +1403,6 @@ brw_blorp_blit_program::kill_if_outside_dst_rect()
> void
> brw_blorp_blit_program::translate_dst_to_src()
> {
> - struct brw_reg X_f = retype(X, BRW_REGISTER_TYPE_F);
> - struct brw_reg Y_f = retype(Y, BRW_REGISTER_TYPE_F);
> - struct brw_reg Xp_f = retype(Xp, BRW_REGISTER_TYPE_F);
> - struct brw_reg Yp_f = retype(Yp, BRW_REGISTER_TYPE_F);
> -
> brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED);
> /* Move the UD coordinates to float registers. */
> brw_MOV(&func, Xp_f, X);
> @@ -1425,25 +1427,9 @@ brw_blorp_blit_program::translate_dst_to_src()
> /* Clamp the X, Y texture coordinates to properly handle the
> sampling of
> * texels on texture edges.
> */
> - brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L,
> - X_f, brw_imm_f(0.0));
> - brw_MOV(&func, X_f, brw_imm_f(0.0));
> - brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
> -
> - brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_GE,
> - X_f, rect_grid_x1);
> - brw_MOV(&func, X_f, rect_grid_x1);
> - brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
> -
> - brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L,
> - Y_f, brw_imm_f(0.0));
> - brw_MOV(&func, Y_f, brw_imm_f(0.0));
> - brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
> -
> - brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_GE,
> - Y_f, rect_grid_y1);
> - brw_MOV(&func, Y_f, rect_grid_y1);
> - brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
> + clamp_tex_coords(X_f, Y_f,
> + brw_imm_f(0.0), brw_imm_f(0.0),
> + rect_grid_x1, rect_grid_y1);
>
> /* Store the fractional parts to be used as bilinear interpolation
> * coefficients.
> @@ -1467,6 +1453,35 @@ brw_blorp_blit_program::translate_dst_to_src()
> brw_set_compression_control(&func, BRW_COMPRESSION_NONE);
> }
>
> +void
> +brw_blorp_blit_program::clamp_tex_coords(struct brw_reg regX,
> + struct brw_reg regY,
> + struct brw_reg clampX0,
> + struct brw_reg clampY0,
> + struct brw_reg clampX1,
> + struct brw_reg clampY1)
> +{
> + brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L, regX,
> clampX0);
> + brw_MOV(&func, regX, clampX0);
> + brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
> +
> + brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_G, regX,
> clampX1);
> + brw_MOV(&func, regX, clampX1);
> + brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
> +
> + brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_L, regY,
> clampY0);
> + brw_MOV(&func, regY, clampY0);
> + brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
> +
> + brw_CMP(&func, vec16(brw_null_reg()), BRW_CONDITIONAL_G, regY,
> clampY1);
> + brw_MOV(&func, regY, clampY1);
> + brw_set_predicate_control(&func, BRW_PREDICATE_NONE);
> +}
> +#undef X_f
> +#undef Y_f
> +#undef Xp_f
> +#undef Yp_f
> +
> /**
> * Emit code to transform the X and Y coordinates as needed for blending
> * together the different samples in an MSAA texture.
> --
> 1.8.1.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130806/e0010a73/attachment.html>
More information about the mesa-dev
mailing list