@Test public void inlineRegressionTest2() throws Exception { String program = "struct _GLF_struct_761 {\n" + " bvec2 _f0;\n" + "};\n" + "struct _GLF_struct_762 {\n" + " _GLF_struct_761 _f0;\n" + "};\n" + "void f()\n" + "{\n" + " _GLF_struct_762 _GLF_struct_replacement_763 = _GLF_struct_762(_GLF_struct_761(" + "bvec2(true)));\n" + " _GLF_struct_762(_GLF_struct_761(bvec2(true)))._f0._f0;\n" + "}\n"; TranslationUnit tu = ParseHelper.parse(program).clone(); List<InlineStructifiedFieldReductionOpportunity> ops = InlineStructifiedFieldReductionOpportunities .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator())); assertEquals(1, ops.size()); ops.get(0).applyReduction(); final File shaderJobFile = testFolder.newFile("temp.json"); fileOps.writeShaderJobFile(new GlslShaderJob(Optional.empty(), new PipelineInfo(), tu), shaderJobFile); assertTrue(fileOps.areShadersValid(shaderJobFile, false)); }
static List<InlineStructifiedFieldReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item)) .reduce(Arrays.asList(), ListConcat::concatenate); }
InlineStructifiedFieldReductionOpportunities extends ScopeTrackingVisitor { static List<InlineStructifiedFieldReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item)) .reduce(Arrays.asList(), ListConcat::concatenate); } }
InlineStructifiedFieldReductionOpportunities extends ScopeTrackingVisitor { static List<InlineStructifiedFieldReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  InlineStructifiedFieldReductionOpportunities(TranslationUnit tu); }
InlineStructifiedFieldReductionOpportunities extends ScopeTrackingVisitor { static List<InlineStructifiedFieldReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  InlineStructifiedFieldReductionOpportunities(TranslationUnit tu); @Override void visitDeclarationStmt(DeclarationStmt declarationStmt); void findInliningOpportunities(StructNameType structType); }
InlineStructifiedFieldReductionOpportunities extends ScopeTrackingVisitor { static List<InlineStructifiedFieldReductionOpportunity> findOpportunities( ShaderJob shaderJob, ReducerContext context) { return shaderJob.getShaders() .stream() .map(item -> findOpportunitiesForShader(item)) .reduce(Arrays.asList(), ListConcat::concatenate); } private  InlineStructifiedFieldReductionOpportunities(TranslationUnit tu); @Override void visitDeclarationStmt(DeclarationStmt declarationStmt); void findInliningOpportunities(StructNameType structType);  }