def generateEpilogue(self, node): epilogue = [] uid = 0 for name, node in node.reads.iteritems(): tree = self.outputLUT.get(name) if tree is None: continue # What should the output be named? name = tree.name if not name: name = "out_%d" % uid uid += 1 # Send data to the output if node.isExisting(): lcl = self.makeConstant(node.name.pyobj) else: lcl = self.localNodeRef(node) decl = glsl.OutputDecl(None, False, False, tree.builtin, lcl.type, name) output = glsl.Output(decl) epilogue.append(glsl.Assign(lcl, output)) print print "OUT" for stmt in epilogue: print stmt print return epilogue
def copyFrom(self, translator, src, filter): types = filterTypes(filter) # TODO constant if len(types) == 1 if len(types) == 1: expr = translator.typeID(types.pop()) else: expr = src.ref translator.emit(glsl.Assign(expr, self.ref))
def generatePrologue(self, node): # Output a flattened version of the input image, # and copies volatile inouts prologue = [] uid = 0 for name, node in node.modifies.iteritems(): tree = self.inputLUT.get(name) if tree is None: continue if node.isExisting(): lcl = self.makeConstant(node.name.pyobj) else: lcl = self.localNodeRef(node) # What should the output be named? base = tree.treetype name = tree.name if not name: name = "%s_%d" % (base, uid) uid += 1 tree.name = name if tree.treetype == 'uniform': decl = glsl.UniformDecl(tree.builtin, lcl.type, name, None) input = glsl.Uniform(decl) # HACK don't copy the uniforms. Samplers cannot be copied # Inputs are still copied due to inout RAW hazards. self.replaceLocal(node, input) else: decl = glsl.InputDecl(None, False, tree.builtin, lcl.type, name) input = glsl.Input(decl) prologue.append(glsl.Assign(input, lcl)) print print "IN" for stmt in prologue: print stmt print return prologue
print "SWITCH", g print conditional print condNode print condInfo = self.getSlotInfo(condNode) cases = [self(case) for case in node.cases] current = cases.pop() conditionSrc = self.typeRef(conditional, g) condition = glsl.Local(intrinsics.intrinsicTypeNodes[int], 'tempType') condAssign = glsl.Assign(conditionSrc, condition) while cases: case = cases.pop() #condition = glsl.Local(intrinsics.intrinsicTypeNodes[bool], 'bogus') current = glsl.Switch(condition, case, current) #node.merge return [condAssign, current] @dispatch(cfg.CFGBlock) def visitCFGBlock(self, node): return glsl.Suite([self(op) for op in node.ops])
def assignIntrinsic(self, translator, expr): translator.emit(glsl.Assign(expr, self.ref))
def copyFrom(self, translator, src, filter): types = filterTypes(filter) if self.info.t in types: translator.emit(glsl.Assign(src.ref, self.ref))
def emitAssign(self, expr, target): stmt = glsl.Assign(expr, target) self.emit(stmt)
def assignIntrinsic(self, trans, t, expr): trans.emit(glsl.Assign(expr, self.ref))
def copyFrom(self, translator, src, filter): translator.emit(glsl.Assign(self.ref, self.ref))
def set(self, expr): return glsl.Assign(expr, self.ref)
def visitLocal(self, dst, src): return glsl.Assign(src, dst)