Ejemplo n.º 1
0
 public extern uint GetSize(ShaderContainer container);
 internal extern static FoundryHandle Scalar(ShaderContainer container, string name, FoundryHandle includeListHandle);
 internal extern static FoundryHandle Matrix(ShaderContainer container, FoundryHandle scalarTypeHandle, int rows, int cols);
Ejemplo n.º 4
0
        void ProcessToken(string str, int startOffsetInclusive, int endOffsetExclusive, ShaderContainer container)
        {
            int length = endOffsetExclusive - startOffsetInclusive;

            if (length <= 2)
            {
                return; // can't possibly be a valid token
            }
            // Special tokens are used to done ids that are to be replaced with actual identifiers later:
            // - "$T:{id}$": Replaces the string with the type name with the given id.
            // - "$F:{id}$": Replaces the string with the function name with the given id.
            // - "$V:{id},{varName}$": Replaces the string with the variable declaration with the given id.
            // Variable declarations also need the variable name due to how arrays have to be declared: "type name[size]".
            // This may go away if we ever add a variable instance object.
            int offset = startOffsetInclusive;

            switch (str[offset])
            {
            case 'V':     // variable declaration
            {
                ParseTokenWithName(str, startOffsetInclusive, endOffsetExclusive, 'V', out int shaderTypeIndex, out string varName);
                // declare it!
                FoundryHandle shaderTypeHandle = new FoundryHandle();
                shaderTypeHandle.Handle = (uint)shaderTypeIndex;
                var shaderType = new ShaderType(container, shaderTypeHandle);
                VariableDeclarationInternal(shaderType, varName, DeclarationMode.NoSemicolon);
                break;
            }

            case 'F':     // function call - function name
            {
                int           tokenId = ParseSimpleToken(str, startOffsetInclusive, endOffsetExclusive, 'F');
                FoundryHandle shaderFunctionHandle = new FoundryHandle();
                shaderFunctionHandle.Handle = (uint)tokenId;
                var shaderFunction = new ShaderFunction(container, shaderFunctionHandle);
                AddFunctionNameInternal(shaderFunction);
                break;
            }

            case 'T':     // type name
            {
                int           typeId           = ParseSimpleToken(str, startOffsetInclusive, endOffsetExclusive, 'T');
                FoundryHandle shaderTypeHandle = new FoundryHandle();
                shaderTypeHandle.Handle = (uint)typeId;
                var shaderType = new ShaderType(container, shaderTypeHandle);
                AddNonArrayTypeNameInternal(shaderType);
                break;
            }

            default:
            {
                var tokenSubStr = str.Substring(startOffsetInclusive, endOffsetExclusive - startOffsetInclusive);
                throw new Exception($"Malformed token found when parsing '{tokenSubStr}'. Identifier {str[offset]} was unexpected.");
            }
            }
        }
 public Builder(ShaderContainer container)
 {
     this.container = container;
 }
 internal extern string GetName(ShaderContainer container);
 internal extern string GetOp(ShaderContainer container, int index);
Ejemplo n.º 8
0
 internal extern static bool ValueEquals(ShaderContainer aContainer, FoundryHandle aHandle, ShaderContainer bContainer, FoundryHandle bHandle);
Ejemplo n.º 9
0
 // private
 internal FunctionParameter(ShaderContainer container, FoundryHandle handle)
 {
     this.container = container;
     this.handle    = handle;
     this.param     = container?.GetFunctionParameter(handle) ?? FunctionParameterInternal.Invalid();
 }
Ejemplo n.º 10
0
 public Builder(ShaderContainer container, string name)
     : this(container, name, FoundryHandle.Invalid(), FoundryHandle.Invalid())
 {
 }
 // private
 internal TemplatePassStageElement(ShaderContainer container, FoundryHandle handle)
 {
     this.container = container;
     this.handle    = handle;
     this.templatePassStageElement = container?.GetTemplatePassStageElement(handle) ?? TemplatePassStageElementInternal.Invalid();
 }
Ejemplo n.º 12
0
 // private
 internal TemplatePass(ShaderContainer container, FoundryHandle handle)
 {
     this.container    = container;
     this.handle       = handle;
     this.templatePass = container?.GetTemplatePass(handle) ?? TemplatePassInternal.Invalid();
 }
Ejemplo n.º 13
0
 public extern void SetElement(ShaderContainer container, uint elementIndex, FoundryHandle handle);
Ejemplo n.º 14
0
 public extern FoundryHandle GetElement(ShaderContainer container, uint elementIndex);
 internal extern string GetDefinition(ShaderContainer container);
 // private
 internal CustomizationPointInstance(ShaderContainer container, FoundryHandle handle)
 {
     this.container = container;
     this.handle    = handle;
     this.customizationPointInstance = container?.GetCustomizationPointInstance(handle) ?? CustomizationPointInstanceInternal.Invalid();
 }
 internal extern string GetStage(ShaderContainer container);
 public Builder(ShaderContainer container, CustomizationPoint customizationPoint)
 {
     this.container          = container;
     this.customizationPoint = customizationPoint;
 }
 internal extern int GetOpCount(ShaderContainer container);
Ejemplo n.º 20
0
 // private
 internal BlockInstance(ShaderContainer container, FoundryHandle handle)
 {
     this.container     = container;
     this.handle        = handle;
     this.blockInstance = container?.GetBlockInstance(handle) ?? BlockInstanceInternal.Invalid();
 }
 // private
 internal KeywordDescriptor(ShaderContainer container, FoundryHandle handle)
 {
     this.container  = container;
     this.handle     = handle;
     this.descriptor = container?.GetKeywordDescriptor(handle) ?? KeywordDescriptorInternal.Invalid();
 }
Ejemplo n.º 22
0
 public Builder(ShaderContainer container, Block block)
 {
     this.container = container;
     this.block     = block;
 }
 // private
 internal BlockVariable(ShaderContainer container, FoundryHandle handle)
 {
     this.container = container;
     this.handle    = handle;
     this.variable  = container?.GetBlockVariable(handle) ?? BlockVariableInternal.Invalid();
 }
 internal extern void Setup(ShaderContainer container, string name, string[] ops);
 internal extern static FoundryHandle Void(ShaderContainer container);
 public Builder(ShaderContainer container, string name, IEnumerable <string> ops)
 {
     this.container = container;
     this.name      = name;
     this.ops       = ops.ToList();
 }
 internal extern static FoundryHandle Vector(ShaderContainer container, FoundryHandle scalarTypeHandle, int dimension);
 internal extern void Setup(ShaderContainer container, string definition, string scope, string stage, string name, string[] ops);
 internal extern static FoundryHandle Texture(ShaderContainer container, string name);
Ejemplo n.º 30
0
 internal ShaderFunction(ShaderContainer container, FoundryHandle handle)
 {
     this.container = container;
     this.handle    = handle;
     this.function  = container?.GetFunction(handle) ?? ShaderFunctionInternal.Invalid();
 }