[Mesa-dev] [PATCH] i965/blorp: Use LRP instruction to do manual blending.
Paul Berry
stereotype441 at gmail.com
Tue Mar 5 16:07:31 PST 2013
On 5 March 2013 15:56, Matt Turner <mattst88 at gmail.com> wrote:
> Replaces (samples - 1) ADDs and a MUL with (samples - 1) LRPs.
> ---
> src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 31
> +++++++++++--------------
> 1 files changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> index 37524ad..4d1ba90 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> @@ -1376,12 +1376,11 @@ brw_blorp_blit_program::manual_blend(unsigned
> num_samples)
> * For integer formats, we replace the add operations with average
> * operations and skip the final division.
> */
> - typedef struct brw_instruction *(*brw_op2_ptr)(struct brw_compile *,
> - struct brw_reg,
> - struct brw_reg,
> - struct brw_reg);
> - brw_op2_ptr combine_op =
> - key->texture_data_type == BRW_REGISTER_TYPE_F ? brw_ADD : brw_AVG;
> + struct brw_reg zero_point_five;
> + if (key->texture_data_type == BRW_REGISTER_TYPE_F) {
> + brw_MOV(&func, zero_point_five, brw_imm_f(0.5f));
> + }
> +
>
It looks like you're not initializing the struct zero_point_five. You need
to allocate a register in brw_blorp_blit_program::alloc_regs() and then
store it in this.
Other than that the patch looks good.
> unsigned stack_depth = 0;
> for (unsigned i = 0; i < num_samples; ++i) {
> assert(stack_depth == _mesa_bitcount(i)); /* Loop invariant */
> @@ -1423,9 +1422,17 @@ brw_blorp_blit_program::manual_blend(unsigned
> num_samples)
>
> /* TODO: should use a smaller loop bound for non_RGBA formats */
> for (int k = 0; k < 4; ++k) {
> - combine_op(&func, offset(texture_data[stack_depth - 1], 2*k),
> + if (key->texture_data_type == BRW_REGISTER_TYPE_F) {
> + /* LRP operands are (a, y, x). */
> + brw_LRP(&func, offset(texture_data[stack_depth - 1], 2*k),
> + zero_point_five,
> + offset(vec8(texture_data[stack_depth]), 2*k),
> + offset(vec8(texture_data[stack_depth - 1]), 2*k));
> + } else {
> + brw_AVG(&func, offset(texture_data[stack_depth - 1], 2*k),
> offset(vec8(texture_data[stack_depth - 1]), 2*k),
> offset(vec8(texture_data[stack_depth]), 2*k));
> + }
> }
> }
> }
> @@ -1433,16 +1440,6 @@ brw_blorp_blit_program::manual_blend(unsigned
> num_samples)
> /* We should have just 1 sample on the stack now. */
> assert(stack_depth == 1);
>
> - if (key->texture_data_type == BRW_REGISTER_TYPE_F) {
> - /* Scale the result down by a factor of num_samples */
> - /* TODO: should use a smaller loop bound for non-RGBA formats */
> - for (int j = 0; j < 4; ++j) {
> - brw_MUL(&func, offset(texture_data[0], 2*j),
> - offset(vec8(texture_data[0]), 2*j),
> - brw_imm_f(1.0/num_samples));
> - }
> - }
> -
> if (key->tex_layout == INTEL_MSAA_LAYOUT_CMS)
> brw_ENDIF(&func);
> }
> --
> 1.7.8.6
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130305/8d6a18c1/attachment.html>
More information about the mesa-dev
mailing list