Пример #1
0
        public static InputElementDescription[] CreateInputElements(this VertexBufferBinding[] vertexBuffers)
        {
            var inputElementCount = 0;

            foreach (var vertexBuffer in vertexBuffers)
            {
                inputElementCount += vertexBuffer.Declaration.VertexElements.Length;
            }

            var inputElements     = new InputElementDescription[inputElementCount];
            var inputElementIndex = 0;

            for (int inputSlot = 0; inputSlot < vertexBuffers.Length; inputSlot++)
            {
                var vertexBuffer = vertexBuffers[inputSlot];
                foreach (var element in vertexBuffer.Declaration.EnumerateWithOffsets())
                {
                    inputElements[inputElementIndex++] = new InputElementDescription
                    {
                        SemanticName      = element.VertexElement.SemanticName,
                        SemanticIndex     = element.VertexElement.SemanticIndex,
                        Format            = element.VertexElement.Format,
                        InputSlot         = inputSlot,
                        AlignedByteOffset = element.Offset,
                    };
                }
            }

            return(inputElements);
        }
Пример #2
0
        public unsafe PipelineStateDescription Clone()
        {
            InputElementDescription[] inputElements;
            if (InputElements != null)
            {
                inputElements = new InputElementDescription[InputElements.Length];
                for (int i = 0; i < inputElements.Length; ++i)
                {
                    inputElements[i] = InputElements[i];
                }
            }
            else
            {
                inputElements = null;
            }

            return(new PipelineStateDescription
            {
                RootSignature = RootSignature,
                EffectBytecode = EffectBytecode,
                BlendState = BlendState,
                SampleMask = SampleMask,
                RasterizerState = RasterizerState,
                DepthStencilState = DepthStencilState,

                InputElements = inputElements,

                PrimitiveType = PrimitiveType,

                Output = Output,
            });
        }
Пример #3
0
        public static InputElementDescription[] CreateInputElements(this VertexDeclaration vertexDeclaration)
        {
            var inputElements     = new InputElementDescription[vertexDeclaration.VertexElements.Length];
            var inputElementIndex = 0;

            foreach (var element in vertexDeclaration.EnumerateWithOffsets())
            {
                inputElements[inputElementIndex++] = new InputElementDescription
                {
                    SemanticName      = element.VertexElement.SemanticName,
                    SemanticIndex     = element.VertexElement.SemanticIndex,
                    Format            = element.VertexElement.Format,
                    InputSlot         = 0,
                    AlignedByteOffset = element.Offset,
                };
            }

            return(inputElements);
        }