[Mesa-dev] [PATCH] i965/blorp: Use LRP instruction to do manual blending.
Matt Turner
mattst88 at gmail.com
Tue Mar 5 15:56:35 PST 2013
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));
+ }
+
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
More information about the mesa-dev
mailing list