Beispiel #1
0
        public void Write(EndianWriter writer)
        {
            uint headerSize     = (uint)m_shaderSubprogram.ConstantBuffers.Length * 24;
            uint variableOffset = m_contantBufferOffset + headerSize;

            for (int i = 0; i < m_shaderSubprogram.ConstantBuffers.Length; i++)
            {
                ConstantBuffer constantBuffer = m_shaderSubprogram.ConstantBuffers[i];
                VariableChunk  variableChunk  = m_variables[i];
                uint           nameOffset     = m_nameLookup[constantBuffer.Name];
                writer.Write(nameOffset);
                writer.Write(variableChunk.Count);
                writer.Write(variableOffset);
                writer.Write((uint)constantBuffer.Size);
                //Flags
                writer.Write((uint)ConstantBufferFlags.None);
                //ContantBufferType
                writer.Write((uint)ConstantBufferType.ConstantBuffer);
                variableOffset += variableChunk.Size;
            }
            foreach (VariableChunk variableChunk in m_variables)
            {
                variableChunk.Write(writer);
            }
        }
Beispiel #2
0
        public ConstantBufferChunk(ShaderSubProgram shaderSubprogram, uint contantBufferOffset, Dictionary <string, uint> nameLookup)
        {
            m_shaderSubprogram    = shaderSubprogram;
            m_contantBufferOffset = contantBufferOffset;
            m_nameLookup          = nameLookup;

            uint headerSize                = (uint)Count * 24;
            uint variableOffset            = contantBufferOffset + headerSize;
            int  constantBufferIndex       = 0;
            List <VariableChunk> variables = new List <VariableChunk>();

            foreach (ConstantBuffer constantBuffer in shaderSubprogram.ConstantBuffers)
            {
                VariableChunk variableChunk = new VariableChunk(constantBuffer, constantBufferIndex++, variableOffset, shaderSubprogram.ProgramType);
                variables.Add(variableChunk);
                variableOffset += variableChunk.Size;
            }
            foreach (BufferBinding bufferBindings in shaderSubprogram.BufferParameters)
            {
                VariableChunk variableChunk = new VariableChunk(bufferBindings, constantBufferIndex++, variableOffset, shaderSubprogram.ProgramType);
                variables.Add(variableChunk);
                variableOffset += variableChunk.Size;
            }
            m_variables = variables;
            Size        = variableOffset - contantBufferOffset;
        }
        public ConstantBufferChunk(Version version, ref ShaderSubProgram shaderSubprogram, uint contantBufferOffset, Dictionary <string, uint> nameLookup)
        {
            m_shaderSubprogram    = shaderSubprogram;
            m_contantBufferOffset = contantBufferOffset;
            m_nameLookup          = nameLookup;

            ShaderGpuProgramType programType = shaderSubprogram.GetProgramType(version);
            uint headerSize                = (uint)Count * 24;
            uint variableOffset            = contantBufferOffset + headerSize;
            int  constantBufferIndex       = 0;
            List <VariableChunk> variables = new List <VariableChunk>();

            for (int i = 0; i < shaderSubprogram.ConstantBuffers.Length; i++)
            {
                ref ConstantBuffer constantBuffer = ref shaderSubprogram.ConstantBuffers[i];
                VariableChunk      variableChunk  = new VariableChunk(ref constantBuffer, constantBufferIndex++, variableOffset, programType);
                variables.Add(variableChunk);
                variableOffset += variableChunk.Size;
            }
Beispiel #4
0
        public void Write(EndianWriter writer)
        {
            uint headerSize     = (uint)Count * 24;
            uint variableOffset = m_contantBufferOffset + headerSize;
            int  variableIndex  = 0;

            for (int i = 0; i < m_shaderSubprogram.ConstantBuffers.Length; i++, variableIndex++)
            {
                ConstantBuffer constantBuffer = m_shaderSubprogram.ConstantBuffers[i];
                VariableChunk  variableChunk  = m_variables[variableIndex];
                uint           nameOffset     = m_nameLookup[constantBuffer.Name];
                writer.Write(nameOffset);
                writer.Write(variableChunk.Count);
                writer.Write(variableOffset);
                writer.Write((uint)constantBuffer.Size);
                //Flags
                writer.Write((uint)ConstantBufferFlags.None);
                //ContantBufferType
                writer.Write((uint)ConstantBufferType.ConstantBuffer);
                variableOffset += variableChunk.Size;
            }
            for (int i = 0; i < m_shaderSubprogram.BufferParameters.Length; i++, variableIndex++)
            {
                BufferBinding bufferParamater = m_shaderSubprogram.BufferParameters[i];
                VariableChunk variableChunk   = m_variables[variableIndex];
                uint          nameOffset      = m_nameLookup[bufferParamater.Name];
                writer.Write(nameOffset);
                writer.Write(variableChunk.Count);
                writer.Write(variableOffset);
                //Size
                writer.Write((uint)4);
                //Flags
                writer.Write((uint)ConstantBufferFlags.None);
                //ContantBufferType
                writer.Write((uint)ConstantBufferType.ResourceBindInformation);
                variableOffset += variableChunk.Size;
            }
            foreach (VariableChunk variableChunk in m_variables)
            {
                variableChunk.Write(writer);
            }
        }