예제 #1
0
 def hasNameConflict(self, op, name):
     """Search for name conflicts regarding given name."""
     # If the input is a GLSL name strip, iterate over its blocks.
     if is_glsl_name_strip(op):
         for ii in op.getBlockList():
             if self.hasNameConflict(ii, name):
                 return True
         return False
     # If the parent is a source block, may need to check conflicts with other sources first.
     parent = find_parent_scope(op)
     if is_glsl_block_source(parent):
         for ii in self.__sources:
             # Only check other sources.
             if ii != parent:
                 # Checking against header sources always happens.
                 if (not parent.getType()) or (not ii.getType()):
                     if has_name_conflict(ii, op, name):
                         return True
                 # Uniforms clash within the source chain.
                 elif is_glsl_block_uniform(op):
                     chain = self.findCommonChain(ii, parent)
                     if chain:
                         for jj in flatten(ii):
                             if is_glsl_block_uniform(jj) and jj.hasLockedDeclaredName(name):
                                 return True
     # Above checks only work if uniforms are only declared in source scope.
     elif is_glsl_block_uniform(op):
         raise RuntimeError("found uniform block in non-source scope")
     # Always check for conflicts within the parent block anyway.
     return has_name_conflict(parent, op, name)
예제 #2
0
 def inline(self, block, names):
     """Perform inlining of block into where it is used."""
     ret = 0
     parent = find_parent_scope(block)
     if is_glsl_block_source(parent):
         for ii in self.__sources:
             if (ii != parent) and ((not parent.getType()) or (not ii.getType())):
                 ret += inline_instances(ii, block, names)
     ret += inline_instances(parent, block, names)
     block.removeFromParent()
     return ret
예제 #3
0
 def hasInlineConflict(self, block, names):
     """Tell if given block has an inlining conflict."""
     # If block is a listing, just go over all options.
     if is_listing(block):
         for ii in block:
             if self.hasInlineConflict(ii, names):
                 return True
         return False
     # Check for inline conflicts within this block.
     parent = find_parent_scope(block)
     if is_glsl_block_source(parent):
         for ii in self.__sources:
             if (ii != parent) and ((not parent.getType()) or (not ii.getType())):
                 if has_inline_conflict(ii, block, names):
                     return True
     return has_inline_conflict(parent, block, names)
예제 #4
0
 def hasNameConflict(self, block, name):
     """Tell if given block would have a conflict if renamed into given name."""
     # If block is a listing, just go over all options.
     if is_listing(block):
         for ii in block:
             if self.hasNameConflict(ii, name):
                 return True
         return False
     # Check for conflicts within this block.
     parent = find_parent_scope(block)
     if is_glsl_block_source(parent):
         for ii in self.__sources:
             if (ii != parent) and ((not parent.getType()) or
                                    (not ii.getType())):
                 if has_name_conflict(ii, block, name):
                     return True
     return has_name_conflict(parent, block, name)
예제 #5
0
def is_source_level_name_strip(op):
    """Tell if given name strip exists in source level."""
    blk = op.getBlock()
    return is_glsl_block_source(blk.getParent())