public Block Build()
            {
                if (finalized)
                {
                    return(new Block(Container, blockHandle));
                }
                finalized = true;

                var blockInternal = new BlockInternal();

                blockInternal.m_NameHandle = container.AddString(name);

                blockInternal.m_DeclaredTypeListHandle       = FixedHandleListInternal.Build(container, types, (t) => (t.handle));
                blockInternal.m_ReferencedTypeListHandle     = FixedHandleListInternal.Build(container, referencedTypes, (t) => (t.handle));
                blockInternal.m_DeclaredFunctionListHandle   = FixedHandleListInternal.Build(container, functions, (f) => (f.handle));
                blockInternal.m_ReferencedFunctionListHandle = FixedHandleListInternal.Build(container, referencedFunctions, (f) => (f.handle));
                blockInternal.m_EntryPointFunctionHandle     = entryPointFunction.handle;

                // Build up the input/output variable list from the entry point function
                GetInOutTypes(entryPointFunction, out var inputType, out var outputType);
                var inputs  = BuildVariablesFromTypeFields(Container, inputType);
                var outputs = BuildVariablesFromTypeFields(Container, outputType);

                blockInternal.m_InputVariableListHandle  = FixedHandleListInternal.Build(container, inputs, (v) => (v.handle));
                blockInternal.m_OutputVariableListHandle = FixedHandleListInternal.Build(container, outputs, (v) => (v.handle));

                blockInternal.m_CommandListHandle    = FixedHandleListInternal.Build(container, m_Commands, (c) => (c.handle));
                blockInternal.m_DefineListHandle     = FixedHandleListInternal.Build(container, m_Defines, (d) => (d.handle));
                blockInternal.m_IncludeListHandle    = FixedHandleListInternal.Build(container, m_Includes, (i) => (i.handle));
                blockInternal.m_KeywordListHandle    = FixedHandleListInternal.Build(container, m_Keywords, (k) => (k.handle));
                blockInternal.m_PragmaListHandle     = FixedHandleListInternal.Build(container, m_Pragmas, (p) => (p.handle));
                blockInternal.m_PassParentHandle     = passParentHandle;
                blockInternal.m_TemplateParentHandle = templateParentHandle;

                container.SetBlockInternal(blockHandle, blockInternal);
                return(new Block(container, blockHandle));
            }
示例#2
0
 internal extern bool SetBlockInternal(FoundryHandle blockHandle, BlockInternal block);
 // private
 internal Block(ShaderContainer container, FoundryHandle handle)
 {
     this.container = container;
     this.handle    = handle;
     this.block     = container?.GetBlock(handle) ?? BlockInternal.Invalid();
 }