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);
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);
internal extern static bool ValueEquals(ShaderContainer aContainer, FoundryHandle aHandle, ShaderContainer bContainer, FoundryHandle bHandle);
// private internal FunctionParameter(ShaderContainer container, FoundryHandle handle) { this.container = container; this.handle = handle; this.param = container?.GetFunctionParameter(handle) ?? FunctionParameterInternal.Invalid(); }
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(); }
// private internal TemplatePass(ShaderContainer container, FoundryHandle handle) { this.container = container; this.handle = handle; this.templatePass = container?.GetTemplatePass(handle) ?? TemplatePassInternal.Invalid(); }
public extern void SetElement(ShaderContainer container, uint elementIndex, FoundryHandle handle);
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);
// 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(); }
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);
internal ShaderFunction(ShaderContainer container, FoundryHandle handle) { this.container = container; this.handle = handle; this.function = container?.GetFunction(handle) ?? ShaderFunctionInternal.Invalid(); }