if (stencil.equals("td")) {
contents.append("\tTraverseTopDown(" + visit_name + ");\n");
} else if (stencil.equals("bu")) {
contents.append("\tTraverseBottomUp(" + visit_name + ");\n");
} else {
throw new InvalidGrammarException("Unsupported traversal order: " + stencil);
}
contents.append("}\n\n\n");
}
// Now write the render traversal
contents.append("void CLRunner::RunPass" + (visits.length - 1) + "(cl::Buffer& render_buffer) {\n");
String visit_name = "visit_" + (visits.length - 1);
contents.append("\t// Get references to our kernels we have compiled previously\n");
contents.append("\tcl::Kernel " + visit_name + " = cl::Kernel(_program, \"" + visit_name + "\");\n\n");
contents.append("\tSetKernelArguments(" + visit_name + ");\n");
// Set the render buffer, which will be the (num buffers) + 1 arguments,
// since tree_size is the first.
contents.append("\t" + visit_name + ".setArg(" + (fields.getBuffers().size() + 2)
+ ", render_buffer); // __global VertexAndColor* glBuffer\n\n");
// TODO: Rewrite in-order traversal to top-down/bottom-up?
String stencil = visits[visits.length - 1].arg(2).arg(1).toString();
if (stencil.equals("td")) {
contents.append("\tTraverseTopDown(" + visit_name + ");\n");
} else if (stencil.equals("bu")) {
contents.append("\tTraverseBottomUp(" + visit_name + ");\n");
} else {
throw new InvalidGrammarException("Unsupported traversal order: " + stencil);
}
contents.append("}\n\n\n");
return contents.toString();