예제 #1
0
 public bool FindVariable(string name, out ShaderVariableMapping variable)
 {
     foreach (var v in variables)
     {
         if (v.name == name)
         {
             variable = v;
             return(true);
         }
     }
     variable = null;
     return(false);
 }
예제 #2
0
        internal static void CalculateContantBufferVariableMappings(ShaderVariable[][] constantBufferVariables, out ReadOnlyCollection <ShaderConstantBufferMapping> constantBufferMappings)
        {
            int  offset = 0, dwordIndex = 0;
            bool firstVariableProcessed = false;
            var  constantBufferMappingsArray = new ShaderConstantBufferMapping[constantBufferVariables.Length];

            for (int i = 0; i != constantBufferVariables.Length; ++i)
            {
                var variables = constantBufferVariables[i];
                if (variables == null)
                {
                    throw new ArgumentException("Constant buffers cannot be empty");
                }

                var variablesMapping = new ShaderVariableMapping[variables.Length];
                for (int v = 0; v != variables.Length; ++v)
                {
                    var variable   = variables[v];
                    int stride     = VariableTypeToSrcStride(variable.type);
                    int dwordCount = VariableTypeToSrcDWORDCount(variable.type);
                    if (variable.elements >= 1)
                    {
                        stride     *= variable.elements;
                        dwordCount *= variable.elements;
                    }
                    if (firstVariableProcessed && dwordCount != 1)
                    {
                        int alignedIndex = dwordIndex % 4;
                        if (dwordCount > alignedIndex)
                        {
                            int remander = 4 - alignedIndex;
                            dwordIndex += remander;
                            offset     += remander * sizeof(float);
                        }
                    }
                    variablesMapping[v]    = new ShaderVariableMapping(variable.name, variable.type, variable.elements, offset);
                    firstVariableProcessed = true;
                    offset     += stride;
                    dwordIndex += dwordCount;
                }
                constantBufferMappingsArray[i] = new ShaderConstantBufferMapping(offset, variablesMapping);
            }
            constantBufferMappings = new ReadOnlyCollection <ShaderConstantBufferMapping>(constantBufferMappingsArray);
        }
예제 #3
0
 public abstract void Update <T>(T[] data, ShaderVariableMapping variable) where T : struct;
예제 #4
0
 public abstract void Update <T>(T data, ShaderVariableMapping variable) where T : unmanaged;
예제 #5
0
 /// <summary>
 /// Writes color as float4
 /// </summary>
 public abstract void Update(Color4[] colors, ShaderVariableMapping variable);
예제 #6
0
 public abstract void Update(Quat[] quaternions, ShaderVariableMapping variable);
예제 #7
0
 public abstract void Update(Mat4[] matrices, ShaderVariableMapping variable);
예제 #8
0
 public abstract void Update(Vec4[] vectors, ShaderVariableMapping variable);
예제 #9
0
 public abstract void Update(float[] values, ShaderVariableMapping variable);
예제 #10
0
 public abstract void Update(Mat4 matrix, ShaderVariableMapping variable);
예제 #11
0
        internal static bool FindVariable(ReadOnlyCollection <ShaderConstantBufferMapping> constantBufferMappings, string name, out ShaderVariableMapping variable)
        {
            if (constantBufferMappings == null)
            {
                variable = null;
                return(false);
            }

            foreach (var constantBuffer in constantBufferMappings)
            {
                if (constantBuffer.FindVariable(name, out variable))
                {
                    return(true);
                }
            }

            variable = null;
            return(false);
        }
예제 #12
0
 public bool FindVariable(string name, out ShaderVariableMapping variable)
 {
     return(ShaderBase.FindVariable(constantBufferMappings, name, out variable));
 }