@Test public void testCanRemoveLiveInjectedVariables() throws Exception { final String shader = "#version 310 es\n" + "void main() {\n" + " vec4 GLF_live6c = vec4(1.0);\n" + " GLF_live6c[0] = 1.0;\n" + "}\n"; final TranslationUnit tu = ParseHelper.parse(shader); List<IReductionOpportunity> ops = ReductionOpportunities.getReductionOpportunities( MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.ESSL_310, new RandomWrapper(0), new IdGenerator()), fileOps); assertFalse(ops.isEmpty()); }
public static List<IReductionOpportunity> getReductionOpportunities( ShaderJob shaderJob, ReducerContext context, ShaderJobFileOperations fileOps) { final List<IReductionOpportunity> opportunities = new ArrayList<>(); for (IReductionOpportunityFinder<?> ros : Arrays.asList( IReductionOpportunityFinder.loopMergeFinder(), IReductionOpportunityFinder.removeStructFieldFinder(), IReductionOpportunityFinder.destructifyFinder(), IReductionOpportunityFinder.inlineStructFieldFinder(), IReductionOpportunityFinder.outlinedStatementFinder(), IReductionOpportunityFinder.variableDeclFinder(), IReductionOpportunityFinder.globalVariablesDeclarationFinder(), IReductionOpportunityFinder.globalPrecisionDeclarationFinder(), IReductionOpportunityFinder.unwrapFinder(), IReductionOpportunityFinder.unswitchifyFinder(), IReductionOpportunityFinder.vectorizationFinder(), IReductionOpportunityFinder.functionFinder(), IReductionOpportunityFinder.stmtFinder(), IReductionOpportunityFinder.exprToConstantFinder(), IReductionOpportunityFinder.compoundExprToSubExprFinder(), IReductionOpportunityFinder.mutationFinder(), IReductionOpportunityFinder.flattenControlFlowFinder(), IReductionOpportunityFinder.inlineInitializerFinder(), IReductionOpportunityFinder.inlineFunctionFinder(), IReductionOpportunityFinder.liveFragColorWriteFinder(), IReductionOpportunityFinder.unusedParamFinder(), IReductionOpportunityFinder.foldConstantFinder(), IReductionOpportunityFinder.inlineUniformFinder(), IReductionOpportunityFinder.redundantUniformMetadataFinder(), IReductionOpportunityFinder.variableDeclToExprFinder(), IReductionOpportunityFinder.switchToLoopFinder(), IReductionOpportunityFinder.globalVariableDeclToExprFinder())) { final List<? extends IReductionOpportunity> currentOpportunities = ros .findOpportunities(shaderJob, context); if (ReductionDriver.DEBUG_REDUCER) { opportunities.addAll(currentOpportunities.stream() .map(item -> new CheckValidReductionOpportunityDecorator(item, shaderJob, context.getShadingLanguageVersion(), fileOps)) .collect(Collectors.toList())); } else { opportunities.addAll(currentOpportunities); } } return opportunities; }
ReductionOpportunities { public static List<IReductionOpportunity> getReductionOpportunities( ShaderJob shaderJob, ReducerContext context, ShaderJobFileOperations fileOps) { final List<IReductionOpportunity> opportunities = new ArrayList<>(); for (IReductionOpportunityFinder<?> ros : Arrays.asList( IReductionOpportunityFinder.loopMergeFinder(), IReductionOpportunityFinder.removeStructFieldFinder(), IReductionOpportunityFinder.destructifyFinder(), IReductionOpportunityFinder.inlineStructFieldFinder(), IReductionOpportunityFinder.outlinedStatementFinder(), IReductionOpportunityFinder.variableDeclFinder(), IReductionOpportunityFinder.globalVariablesDeclarationFinder(), IReductionOpportunityFinder.globalPrecisionDeclarationFinder(), IReductionOpportunityFinder.unwrapFinder(), IReductionOpportunityFinder.unswitchifyFinder(), IReductionOpportunityFinder.vectorizationFinder(), IReductionOpportunityFinder.functionFinder(), IReductionOpportunityFinder.stmtFinder(), IReductionOpportunityFinder.exprToConstantFinder(), IReductionOpportunityFinder.compoundExprToSubExprFinder(), IReductionOpportunityFinder.mutationFinder(), IReductionOpportunityFinder.flattenControlFlowFinder(), IReductionOpportunityFinder.inlineInitializerFinder(), IReductionOpportunityFinder.inlineFunctionFinder(), IReductionOpportunityFinder.liveFragColorWriteFinder(), IReductionOpportunityFinder.unusedParamFinder(), IReductionOpportunityFinder.foldConstantFinder(), IReductionOpportunityFinder.inlineUniformFinder(), IReductionOpportunityFinder.redundantUniformMetadataFinder(), IReductionOpportunityFinder.variableDeclToExprFinder(), IReductionOpportunityFinder.switchToLoopFinder(), IReductionOpportunityFinder.globalVariableDeclToExprFinder())) { final List<? extends IReductionOpportunity> currentOpportunities = ros .findOpportunities(shaderJob, context); if (ReductionDriver.DEBUG_REDUCER) { opportunities.addAll(currentOpportunities.stream() .map(item -> new CheckValidReductionOpportunityDecorator(item, shaderJob, context.getShadingLanguageVersion(), fileOps)) .collect(Collectors.toList())); } else { opportunities.addAll(currentOpportunities); } } return opportunities; } }
ReductionOpportunities { public static List<IReductionOpportunity> getReductionOpportunities( ShaderJob shaderJob, ReducerContext context, ShaderJobFileOperations fileOps) { final List<IReductionOpportunity> opportunities = new ArrayList<>(); for (IReductionOpportunityFinder<?> ros : Arrays.asList( IReductionOpportunityFinder.loopMergeFinder(), IReductionOpportunityFinder.removeStructFieldFinder(), IReductionOpportunityFinder.destructifyFinder(), IReductionOpportunityFinder.inlineStructFieldFinder(), IReductionOpportunityFinder.outlinedStatementFinder(), IReductionOpportunityFinder.variableDeclFinder(), IReductionOpportunityFinder.globalVariablesDeclarationFinder(), IReductionOpportunityFinder.globalPrecisionDeclarationFinder(), IReductionOpportunityFinder.unwrapFinder(), IReductionOpportunityFinder.unswitchifyFinder(), IReductionOpportunityFinder.vectorizationFinder(), IReductionOpportunityFinder.functionFinder(), IReductionOpportunityFinder.stmtFinder(), IReductionOpportunityFinder.exprToConstantFinder(), IReductionOpportunityFinder.compoundExprToSubExprFinder(), IReductionOpportunityFinder.mutationFinder(), IReductionOpportunityFinder.flattenControlFlowFinder(), IReductionOpportunityFinder.inlineInitializerFinder(), IReductionOpportunityFinder.inlineFunctionFinder(), IReductionOpportunityFinder.liveFragColorWriteFinder(), IReductionOpportunityFinder.unusedParamFinder(), IReductionOpportunityFinder.foldConstantFinder(), IReductionOpportunityFinder.inlineUniformFinder(), IReductionOpportunityFinder.redundantUniformMetadataFinder(), IReductionOpportunityFinder.variableDeclToExprFinder(), IReductionOpportunityFinder.switchToLoopFinder(), IReductionOpportunityFinder.globalVariableDeclToExprFinder())) { final List<? extends IReductionOpportunity> currentOpportunities = ros .findOpportunities(shaderJob, context); if (ReductionDriver.DEBUG_REDUCER) { opportunities.addAll(currentOpportunities.stream() .map(item -> new CheckValidReductionOpportunityDecorator(item, shaderJob, context.getShadingLanguageVersion(), fileOps)) .collect(Collectors.toList())); } else { opportunities.addAll(currentOpportunities); } } return opportunities; } private  ReductionOpportunities(); }
ReductionOpportunities { public static List<IReductionOpportunity> getReductionOpportunities( ShaderJob shaderJob, ReducerContext context, ShaderJobFileOperations fileOps) { final List<IReductionOpportunity> opportunities = new ArrayList<>(); for (IReductionOpportunityFinder<?> ros : Arrays.asList( IReductionOpportunityFinder.loopMergeFinder(), IReductionOpportunityFinder.removeStructFieldFinder(), IReductionOpportunityFinder.destructifyFinder(), IReductionOpportunityFinder.inlineStructFieldFinder(), IReductionOpportunityFinder.outlinedStatementFinder(), IReductionOpportunityFinder.variableDeclFinder(), IReductionOpportunityFinder.globalVariablesDeclarationFinder(), IReductionOpportunityFinder.globalPrecisionDeclarationFinder(), IReductionOpportunityFinder.unwrapFinder(), IReductionOpportunityFinder.unswitchifyFinder(), IReductionOpportunityFinder.vectorizationFinder(), IReductionOpportunityFinder.functionFinder(), IReductionOpportunityFinder.stmtFinder(), IReductionOpportunityFinder.exprToConstantFinder(), IReductionOpportunityFinder.compoundExprToSubExprFinder(), IReductionOpportunityFinder.mutationFinder(), IReductionOpportunityFinder.flattenControlFlowFinder(), IReductionOpportunityFinder.inlineInitializerFinder(), IReductionOpportunityFinder.inlineFunctionFinder(), IReductionOpportunityFinder.liveFragColorWriteFinder(), IReductionOpportunityFinder.unusedParamFinder(), IReductionOpportunityFinder.foldConstantFinder(), IReductionOpportunityFinder.inlineUniformFinder(), IReductionOpportunityFinder.redundantUniformMetadataFinder(), IReductionOpportunityFinder.variableDeclToExprFinder(), IReductionOpportunityFinder.switchToLoopFinder(), IReductionOpportunityFinder.globalVariableDeclToExprFinder())) { final List<? extends IReductionOpportunity> currentOpportunities = ros .findOpportunities(shaderJob, context); if (ReductionDriver.DEBUG_REDUCER) { opportunities.addAll(currentOpportunities.stream() .map(item -> new CheckValidReductionOpportunityDecorator(item, shaderJob, context.getShadingLanguageVersion(), fileOps)) .collect(Collectors.toList())); } else { opportunities.addAll(currentOpportunities); } } return opportunities; } private  ReductionOpportunities(); static List<IReductionOpportunity> getReductionOpportunities(
      ShaderJob shaderJob,
      ReducerContext context,
      ShaderJobFileOperations fileOps); }
ReductionOpportunities { public static List<IReductionOpportunity> getReductionOpportunities( ShaderJob shaderJob, ReducerContext context, ShaderJobFileOperations fileOps) { final List<IReductionOpportunity> opportunities = new ArrayList<>(); for (IReductionOpportunityFinder<?> ros : Arrays.asList( IReductionOpportunityFinder.loopMergeFinder(), IReductionOpportunityFinder.removeStructFieldFinder(), IReductionOpportunityFinder.destructifyFinder(), IReductionOpportunityFinder.inlineStructFieldFinder(), IReductionOpportunityFinder.outlinedStatementFinder(), IReductionOpportunityFinder.variableDeclFinder(), IReductionOpportunityFinder.globalVariablesDeclarationFinder(), IReductionOpportunityFinder.globalPrecisionDeclarationFinder(), IReductionOpportunityFinder.unwrapFinder(), IReductionOpportunityFinder.unswitchifyFinder(), IReductionOpportunityFinder.vectorizationFinder(), IReductionOpportunityFinder.functionFinder(), IReductionOpportunityFinder.stmtFinder(), IReductionOpportunityFinder.exprToConstantFinder(), IReductionOpportunityFinder.compoundExprToSubExprFinder(), IReductionOpportunityFinder.mutationFinder(), IReductionOpportunityFinder.flattenControlFlowFinder(), IReductionOpportunityFinder.inlineInitializerFinder(), IReductionOpportunityFinder.inlineFunctionFinder(), IReductionOpportunityFinder.liveFragColorWriteFinder(), IReductionOpportunityFinder.unusedParamFinder(), IReductionOpportunityFinder.foldConstantFinder(), IReductionOpportunityFinder.inlineUniformFinder(), IReductionOpportunityFinder.redundantUniformMetadataFinder(), IReductionOpportunityFinder.variableDeclToExprFinder(), IReductionOpportunityFinder.switchToLoopFinder(), IReductionOpportunityFinder.globalVariableDeclToExprFinder())) { final List<? extends IReductionOpportunity> currentOpportunities = ros .findOpportunities(shaderJob, context); if (ReductionDriver.DEBUG_REDUCER) { opportunities.addAll(currentOpportunities.stream() .map(item -> new CheckValidReductionOpportunityDecorator(item, shaderJob, context.getShadingLanguageVersion(), fileOps)) .collect(Collectors.toList())); } else { opportunities.addAll(currentOpportunities); } } return opportunities; } private  ReductionOpportunities(); static List<IReductionOpportunity> getReductionOpportunities(
      ShaderJob shaderJob,
      ReducerContext context,
      ShaderJobFileOperations fileOps);  }