Ejemplo n.º 1
0
        protected virtual void SetupNormalVertexDescriptions()
        {
            // Binding description
            vertices_bindingDescriptions.Count = 1;
            vertices_bindingDescriptions[0]    =
                Initializers.vertexInputBindingDescription(
                    Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
                    (uint)sizeof(Vertex),
                    VkVertexInputRate.Vertex);

            // Attribute descriptions
            // Describes memory layout and shader positions
            vertices_attributeDescriptions.Count = 3;
            // Location 0 : Position
            vertices_attributeDescriptions[0] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
                    0,
                    VkFormat.R32g32b32Sfloat,
                    0);
            // Location 1 : Normal
            vertices_attributeDescriptions[1] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
                    1,
                    VkFormat.R32g32b32Sfloat,
                    12);
            // Location 2 : Texture coordinates
            vertices_attributeDescriptions[2] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
                    2,
                    VkFormat.R32g32Sfloat,
                    24);
            // Location 3 : Color
            //vertices_attributeDescriptions[3] =
            //    Initializers.vertexInputAttributeDescription(
            //     Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
            //        3,
            //        VkFormat.R32g32b32Sfloat,
            //        32);


            vertices_inputState = Initializers.pipelineVertexInputStateCreateInfo();
            vertices_inputState.vertexBindingDescriptionCount   = (vertices_bindingDescriptions.Count);
            vertices_inputState.pVertexBindingDescriptions      = (VkVertexInputBindingDescription *)vertices_bindingDescriptions.Data;
            vertices_inputState.vertexAttributeDescriptionCount = (vertices_attributeDescriptions.Count);
            vertices_inputState.pVertexAttributeDescriptions    = (VkVertexInputAttributeDescription *)vertices_attributeDescriptions.Data;
        }
Ejemplo n.º 2
0
        protected virtual void SetupInstancedVertexDescriptions()
        {
            // Binding description
            vertices_bindingDescriptions.Count = 2;
            vertices_bindingDescriptions[0]    =
                Initializers.vertexInputBindingDescription(
                    Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
                    (uint)sizeof(Vertex),
                    VkVertexInputRate.Vertex);

            vertices_bindingDescriptions[1] =
                Initializers.vertexInputBindingDescription(
                    Pipeline.VERTEX_INSTANCE_BUFFER_BIND_ID,
                    (uint)sizeof(ObjectToWorld),
                    VkVertexInputRate.Instance);

            // Attribute descriptions
            // Describes memory layout and shader positions
            vertices_attributeDescriptions.Count = 10;
            // Location 0 : Position
            vertices_attributeDescriptions[0] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
                    0,
                    VkFormat.R32g32b32Sfloat,
                    0);
            // Location 1 : Normal
            vertices_attributeDescriptions[1] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
                    1,
                    VkFormat.R32g32b32Sfloat,
                    12);
            // Location 2 : Texture coordinates
            vertices_attributeDescriptions[2] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
                    2,
                    VkFormat.R32g32Sfloat,
                    24);
            // Location 3 : Color
            //vertices_attributeDescriptions[3] =
            //    Initializers.vertexInputAttributeDescription(
            //     Pipeline.VERTEX_DATA_BUFFER_BIND_ID,
            //        3,
            //        VkFormat.R32g32b32Sfloat,
            //        32);



            //Location 3-9 Instance model matrix and normal matrix
            vertices_attributeDescriptions[3] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_INSTANCE_BUFFER_BIND_ID,
                    3,
                    VkFormat.R32g32b32a32Sfloat,
                    0);
            vertices_attributeDescriptions[4] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_INSTANCE_BUFFER_BIND_ID,
                    4,
                    VkFormat.R32g32b32a32Sfloat,
                    16);
            vertices_attributeDescriptions[5] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_INSTANCE_BUFFER_BIND_ID,
                    5,
                    VkFormat.R32g32b32a32Sfloat,
                    32);
            vertices_attributeDescriptions[6] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_INSTANCE_BUFFER_BIND_ID,
                    6,
                    VkFormat.R32g32b32a32Sfloat,
                    48);
            vertices_attributeDescriptions[7] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_INSTANCE_BUFFER_BIND_ID,
                    7,
                    VkFormat.R32g32b32Sfloat,
                    64);
            vertices_attributeDescriptions[8] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_INSTANCE_BUFFER_BIND_ID,
                    8,
                    VkFormat.R32g32b32Sfloat,
                    76);
            vertices_attributeDescriptions[9] =
                Initializers.vertexInputAttributeDescription(
                    Pipeline.VERTEX_INSTANCE_BUFFER_BIND_ID,
                    9,
                    VkFormat.R32g32b32Sfloat,
                    88);


            vertices_inputState = Initializers.pipelineVertexInputStateCreateInfo();
            vertices_inputState.vertexBindingDescriptionCount   = (vertices_bindingDescriptions.Count);
            vertices_inputState.pVertexBindingDescriptions      = (VkVertexInputBindingDescription *)vertices_bindingDescriptions.Data;
            vertices_inputState.vertexAttributeDescriptionCount = (vertices_attributeDescriptions.Count);
            vertices_inputState.pVertexAttributeDescriptions    = (VkVertexInputAttributeDescription *)vertices_attributeDescriptions.Data;
        }