Ejemplo n.º 1
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.º 2
0
    def __init__(self, info):
        self.info = info
        assert info.unique

        if not info.impl:
            bt = intrinsics.intrinsicTypeNodes[info.t]
            info.impl = glsl.Uniform(
                glsl.UniformDecl(False, bt, info.name, None))

        self.ref = info.impl
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 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
Ejemplo n.º 5
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