Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    def makeField(self, t, name):
        bt = intrinsics.intrinsicTypeNodes[t]

        if self.mode is output:
            if self.builtin:
                # TODO check type?
                return glsl.Output(self.builtin)

            return glsl.Output(
                glsl.OutputDecl(None, False, False, False, bt, name))
        elif self.mode is uniform:
            if self.builtin:
                # TODO check type?
                return glsl.Uniform(self.builtin)

            return glsl.Uniform(glsl.UniformDecl(False, bt, name, None))
        elif self.mode is input:
            if self.builtin:
                # TODO check type?
                return glsl.Input(self.builtin)

            return glsl.Input(glsl.InputDecl(None, False, False, bt, name))
        elif self.mode is local:
            return glsl.Local(bt, name)
        else:
            assert False, self.mode
Ejemplo n.º 3
0
def makeRef(mode, t, name=None):
    bt = intrinsics.intrinsicTypeNodes[t]

    if mode is output:
        return glsl.Output(glsl.OutputDecl(None, False, False, False, bt,
                                           name))
    elif mode is uniform:
        return glsl.Uniform(glsl.UniformDecl(False, bt, name, None))
    elif mode is input:
        return glsl.Input(glsl.InputDecl(None, False, False, bt, name))
    elif mode is local:
        return glsl.Local(bt, name)
    else:
        assert False, mode
Ejemplo n.º 4
0
def makeRef(ref, subref):
    bt = intrinsics.intrinsicTypeNodes[subref.t]
    name = subref.name

    if not name:
        name = 'bogus%d' % id(subref)

    if not subref.impl:
        if ref.mode is model.OUTPUT:
            impl = glsl.Output(
                glsl.OutputDecl(None, False, False, subref.builtin, bt, name))
        elif ref.mode is model.UNIFORM:
            impl = glsl.Uniform(glsl.UniformDecl(False, bt, name, None))
        elif ref.mode is model.INPUT:
            impl = glsl.Input(
                glsl.InputDecl(None, False, subref.builtin, bt, name))
        elif ref.mode is model.LOCAL:
            impl = glsl.Local(bt, name)
        else:
            assert False, mode

        subref.impl = impl

    return subref.impl
Ejemplo n.º 5
0
 def getBuiltin(self, info):
     if self.depth:
         floatT = intrinsics.intrinsicTypeNodes[float]
         info.builtin[self.position.ioname] = glsl.OutputDecl(
             None, False, False, True, floatT, 'gl_Depth')
Ejemplo n.º 6
0
 def getBuiltin(self, info):
     vec4T = intrinsics.intrinsicTypeNodes[intrinsics.vec.vec4]
     info.builtin[self.position.ioname] = glsl.OutputDecl(
         None, False, False, True, vec4T, 'gl_Position')