@Test public void testInDead() throws Exception { final String shader = "void main() {\n" + " if(_GLF_DEAD(false)) {\n" + " vec4 GLF_merged1_3_1_10GLF_dead3r;\n" + " GLF_merged1_3_1_10GLF_dead3r.w;\n" + " for(int GLF_dead3r = 0;\n" + " GLF_dead3r < 15;\n" + " GLF_dead3r ++\n" + " ) { }\n" + " }\n" + "}\n"; final String expected = "void main() {\n" + " if(_GLF_DEAD(false)) {\n" + " float GLF_dead3r;\n" + " vec4 GLF_merged1_3_1_10GLF_dead3r;\n" + " GLF_dead3r;\n" + " for(int GLF_dead3r = 0;\n" + " GLF_dead3r < 15;\n" + " GLF_dead3r ++\n" + " ) { }\n" + " }\n" + "}\n"; final TranslationUnit tu = ParseHelper.parse(shader); final List<VectorizationReductionOpportunity> ops = VectorizationReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.GLSL_440, new RandomWrapper(0), new IdGenerator())); assertEquals(1, ops.size()); ops.get(0).applyReduction(); assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(expected)), PrettyPrinterVisitor.prettyPrintAsString(tu)); }
static List<VectorizationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); }
VectorizationReductionOpportunities extends ReductionOpportunitiesBase<VectorizationReductionOpportunity> { static List<VectorizationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } }
VectorizationReductionOpportunities extends ReductionOpportunitiesBase<VectorizationReductionOpportunity> { static List<VectorizationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  VectorizationReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); }
VectorizationReductionOpportunities extends ReductionOpportunitiesBase<VectorizationReductionOpportunity> { static List<VectorizationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  VectorizationReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); @Override void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration); @Override void visitVariableDeclInfo(VariableDeclInfo variableDeclInfo); }
VectorizationReductionOpportunities extends ReductionOpportunitiesBase<VectorizationReductionOpportunity> { static List<VectorizationReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item, context)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  VectorizationReductionOpportunities(
        TranslationUnit tu,
        ReducerContext context); @Override void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration); @Override void visitVariableDeclInfo(VariableDeclInfo variableDeclInfo);  }