Ejemplo n.º 1
0
        private void InitializeVertexDescriptor(MgPipelineVertexInputStateCreateInfo vertexInput)
        {
            {
                var noOfBindings = vertexInput.VertexBindingDescriptions.Length;
                Layouts = new AmtGraphicsPipelineVertexLayoutBinding[noOfBindings];
                for (var i = 0; i < noOfBindings; ++i)
                {
                    var binding = vertexInput.VertexBindingDescriptions[i];
                    Layouts[i] = new AmtGraphicsPipelineVertexLayoutBinding
                    {
                        Index        = (nint)i,
                        StepFunction = TranslateStepFunction(binding.InputRate),
                        Stride       = (nuint)binding.Stride,
                    };
                }
            }

            {
                var noOfAttributes = vertexInput.VertexAttributeDescriptions.Length;
                Attributes = new AmtGraphicsPipelineVertexAttribute[noOfAttributes];
                for (var i = 0; i < noOfAttributes; ++i)
                {
                    var attribute = vertexInput.VertexAttributeDescriptions[i];

                    Attributes[i] = new AmtGraphicsPipelineVertexAttribute
                    {
                        Index       = (nint)i,
                        Offset      = attribute.Offset,
                        BufferIndex = (nuint)attribute.Binding,
                        Format      = AmtFormatExtensions.GetVertexFormat(attribute.Format),
                    };
                }
            }
        }
Ejemplo n.º 2
0
        void PopulateVertexDefinition(MgPipelineVertexInputStateCreateInfo vertexInput)
        {
            var perInstance = new SortedDictionary <uint, GLVertexBufferBinding> ();

            foreach (var vbuf in vertexInput.VertexBindingDescriptions)
            {
                var def = new GLVertexBufferBinding(vbuf.Binding, vbuf.InputRate, vbuf.Stride);
                perInstance.Add(def.Binding, def);
            }

            var bindings = new GLVertexBufferBinding[perInstance.Values.Count];

            perInstance.Values.CopyTo(bindings, 0);

            var attributes = new List <GLVertexInputAttribute> ();

            foreach (var description in vertexInput.VertexAttributeDescriptions)
            {
                var binding = bindings[description.Binding];

                var elementInfo = GetAttributeFormat(description.Format);

                var divisor = (binding.InputRate == MgVertexInputRate.INSTANCE) ? 1U : 0U;

                if (binding.Stride > int.MaxValue)
                {
                    throw new ArgumentOutOfRangeException("binding.Stride[i]", "binding.Stride > int.MaxValue");
                }

                var attribute = new GLVertexInputAttribute {
                    Binding = description.Binding,

                    Location = description.Location,
                    Offset   = description.Offset,
                    Stride   = (int)binding.Stride,

                    Divisor      = divisor,
                    Size         = elementInfo.Size,
                    PointerType  = elementInfo.PointerType,
                    IsNormalized = elementInfo.IsNormalized,
                    Function     = elementInfo.Function,
                };

                attributes.Add(attribute);
            }

            VertexInput = new GLVertexBufferBinder(bindings, attributes.ToArray());
        }
Ejemplo n.º 3
0
        void InitializeResources(MgPipelineVertexInputStateCreateInfo vertexInputState)
        {
            // Vertex data is made up of
            // vertex buffers in vertex input state

            var slots = new SortedList <uint, AmtPipelineLayoutBufferBinding>();

            var bindingOffset = 0U;

            foreach (var definition in vertexInputState.VertexBindingDescriptions)
            {
                slots.Add(definition.Binding, new AmtPipelineLayoutBufferBinding
                {
                    Binding         = definition.Binding,
                    DescriptorCount = 1,
                    Category        = AmtPipelineLayoutBufferBindingCategory.VertexBuffer,
                });
                ++bindingOffset;
            }

            var combinedBuffers = new List <AmtPipelineLayoutBufferBinding>();

            combinedBuffers.AddRange(slots.Values);
            combinedBuffers.AddRange(Layout.VertexStage.VertexBuffers);

            VertexBufferBindings = combinedBuffers.ToArray();

            // then buffer, uniform, ssbo, ssbo dynamics sorted by binding


            // Next is samples and textures (with the same positional order no) sorted by binding

            // Fragment

            // Next is samples and textures (with the same positional order no) sorted by binding
        }
Ejemplo n.º 4
0
 public PerVertexInputPipelineState(PerVertexDefinition definition)
 {
     VertexMask       = PerVertexDefinitionEncoder.Encode(definition);
     VertexInputState = GenerateVertexInputState(definition);
 }