Пример #1
0
 // most types should be added via the ShaderType.* functions.
 // this function is used to ensure the shader type belongs to this container
 internal FoundryHandle AddShaderType(ShaderType shaderType, bool convertNonexistantToVoid)
 {
     if (shaderType.Exists)
     {
         if (shaderType.Container == this)
         {
             return(shaderType.handle);
         }
         else
         {
             // TODO: have to deep copy the definition from another container
             return(FoundryHandle.Invalid());
         }
     }
     else
     {
         // invalid shader type...
         if (convertNonexistantToVoid)
         {
             return(ShaderTypeInternal.Void(this));
         }
         else
         {
             return(FoundryHandle.Invalid());
         }
     }
 }
Пример #2
0
        public static FoundryHandle Build <T>(ShaderContainer container, List <T> items, Func <T, FoundryHandle> indexFunc)
        {
            if ((items == null) || (items.Count <= 0))
            {
                return(FoundryHandle.Invalid());
            }
            var listHandle = container.AddHandleBlob((uint)items.Count);

            for (var i = 0; i < items.Count; ++i)
            {
                container.SetHandleBlobElement(listHandle, (uint)i, indexFunc(items[i]));
            }
            return(listHandle);
        }
Пример #3
0
        public static FoundryHandle Build(ShaderContainer container, List <FoundryHandle> values)
        {
            if ((values == null) || (values.Count <= 0))
            {
                return(FoundryHandle.Invalid());
            }
            var listHandle = container.AddHandleBlob((uint)values.Count);

            for (var i = 0; i < values.Count; ++i)
            {
                container.SetHandleBlobElement(listHandle, (uint)i, values[i]);
            }
            return(listHandle);
        }
Пример #4
0
            public ShaderFunction Build()
            {
                if (finalized)
                {
                    return(new ShaderFunction(Container, functionHandle));
                }
                finalized = true;

                FoundryHandle parentBlockHandle = parentBlockBuilder?.blockHandle ?? FoundryHandle.Invalid();
                var           returnTypeHandle  = container.AddShaderType(returnType, true);
                var           builtFunction     = new ShaderFunction(container, functionHandle, name, ConvertToString(), returnTypeHandle, parameters, parentBlockHandle);

                if (parentBlockBuilder != null)
                {
                    // Register the new function with the parent block
                    parentBlockBuilder.AddFunction(builtFunction);
                }

                return(builtFunction);
            }
Пример #5
0
 public ShaderType GetType(string name)
 {
     return(new ShaderType(this, GetTypeByName(name, FoundryHandle.Invalid())));
 }
Пример #6
0
 public Builder(ShaderContainer container, string name)
     : this(container, name, FoundryHandle.Invalid(), FoundryHandle.Invalid())
 {
 }