Esempio n. 1
0
        void setupVertexDescriptions()
        {
            // Binding description
            vDescription.bindingDescriptions              = VkVertexInputBindingDescription.Alloc();
            vDescription.bindingDescriptions[0].binding   = VERTEX_BUFFER_BIND_ID;
            vDescription.bindingDescriptions[0].stride    = (uint)sizeof(Vertex);
            vDescription.bindingDescriptions[0].inputRate = VkVertexInputRate.Vertex;

            // Attribute descriptions
            // Describes memory layout and shader positions
            vDescription.attributeDescriptions = VkVertexInputAttributeDescription.Alloc(3);
            // Location 0 : Position
            vDescription.attributeDescriptions[0].binding  = VERTEX_BUFFER_BIND_ID;
            vDescription.attributeDescriptions[0].location = 0;
            vDescription.attributeDescriptions[0].format   = VkFormat.R32g32b32Sfloat;
            vDescription.attributeDescriptions[0].offset   = Vertex.PositionOffset;
            // Location 1 : Texture coordinates
            vDescription.attributeDescriptions[1].binding  = VERTEX_BUFFER_BIND_ID;
            vDescription.attributeDescriptions[1].location = 1;
            vDescription.attributeDescriptions[1].format   = VkFormat.R32g32Sfloat;
            vDescription.attributeDescriptions[1].offset   = Vertex.UvOffset;
            // Location 1 : Vertex normal
            vDescription.attributeDescriptions[2].binding  = VERTEX_BUFFER_BIND_ID;
            vDescription.attributeDescriptions[2].location = 2;
            vDescription.attributeDescriptions[2].format   = VkFormat.R32g32b32Sfloat;
            vDescription.attributeDescriptions[2].offset   = Vertex.NormalOffset;

            vDescription.inputState = VkPipelineVertexInputStateCreateInfo.Alloc();
            vDescription.inputState[0].vertexBindingDescriptions.count     = 1;
            vDescription.inputState[0].vertexBindingDescriptions.pointer   = vDescription.bindingDescriptions;
            vDescription.inputState[0].vertexAttributeDescriptions.count   = 3;
            vDescription.inputState[0].vertexAttributeDescriptions.pointer = vDescription.attributeDescriptions;
        }
Esempio n. 2
0
        void setupVertexDescriptions()
        {
            // Binding description
            bindingDescs              = new VkVertexInputBindingDescription[1];
            bindingDescs[0].binding   = VERTEX_BUFFER_BIND_ID;
            bindingDescs[0].stride    = vertexLayout.stride();
            bindingDescs[0].inputRate = VkVertexInputRate.Vertex;// VK_VERTEX_INPUT_RATE_VERTEX;

            // Attribute descriptions
            attributeDescs = VkVertexInputAttributeDescription.Alloc(4);
            // Location 0 : Position
            attributeDescs[0].binding  = VERTEX_BUFFER_BIND_ID;
            attributeDescs[0].location = 0;
            attributeDescs[0].format   = VkFormat.R32g32b32Sfloat;// VK_FORMAT_R32G32B32_SFLOAT,
            attributeDescs[0].offset   = 0;
            // Location 1 : Texture coordinates
            attributeDescs[1].binding  = VERTEX_BUFFER_BIND_ID;
            attributeDescs[1].location = 1;
            attributeDescs[1].format   = VkFormat.R32g32Sfloat;// VK_FORMAT_R32G32_SFLOAT,
            attributeDescs[1].offset   = sizeof(float) * 3;
            // Location 2 : Color
            attributeDescs[2].binding  = VERTEX_BUFFER_BIND_ID;
            attributeDescs[2].location = 2;
            attributeDescs[2].format   = VkFormat.R32g32b32Sfloat;// VK_FORMAT_R32G32B32_SFLOAT,
            attributeDescs[2].offset   = sizeof(float) * 5;
            // Location 3 : Normal
            attributeDescs[3].binding  = VERTEX_BUFFER_BIND_ID;
            attributeDescs[3].location = 3;
            attributeDescs[3].format   = VkFormat.R32g32b32Sfloat;// VK_FORMAT_R32G32B32_SFLOAT,
            attributeDescs[3].offset   = sizeof(float) * 8;

            inputInfo = VkPipelineVertexInputStateCreateInfo.Alloc();
            inputInfo[0].vertexBindingDescriptions           = bindingDescs;
            inputInfo[0].vertexAttributeDescriptions.count   = 4;
            inputInfo[0].vertexAttributeDescriptions.pointer = attributeDescs;
        }