コード例 #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));
 }