glsl: Make the swizzle-swizzle optimization greedy

If there is a long sequence of swizzled swizzles, compact all of them
down to a single swizzle.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: <thomashelland90@gmail.com>
This commit is contained in:
Ian Romanick
2017-10-31 23:16:38 -07:00
parent ae1fd09c1d
commit c858abb14f

View File

@@ -23,8 +23,7 @@
/**
* \file opt_swizzle_swizzle.cpp
*
* Eliminates the second swizzle in a swizzle chain.
* Compact a sequence of swizzled swizzles into a single swizzle.
*/
#include "ir.h"
@@ -51,11 +50,10 @@ public:
ir_visitor_status
ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir)
{
int mask2[4];
ir_swizzle *swiz2;
ir_swizzle *swiz2 = ir->val->as_swizzle();
if (!swiz2)
return visit_continue;
while ((swiz2 = ir->val->as_swizzle()) != NULL) {
int mask2[4];
memset(&mask2, 0, sizeof(mask2));
if (swiz2->mask.num_components >= 1)
@@ -79,6 +77,7 @@ ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir)
ir->val = swiz2->val;
this->progress = true;
}
return visit_continue;
}