diff --git a/driver/draw.c b/driver/draw.c index b0d1441..843753a 100644 --- a/driver/draw.c +++ b/driver/draw.c @@ -138,7 +138,7 @@ void vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t ins clInsertShaderState(&commandBuffer->binCl, 0, //shader state record address 0, //extended shader state record - cb->graphicsPipeline->vertexAttributeDescriptionCount & 0x7); //0 -> 8 + cb->graphicsPipeline->vertexAttributeDescriptionCount & 0x7); //number of attribute arrays, 0 -> 8 //Vertex Array Primitives (draw call) clFit(commandBuffer, &commandBuffer->binCl, V3D21_VERTEX_ARRAY_PRIMITIVES_length); @@ -165,14 +165,14 @@ void vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t ins clFit(commandBuffer, &commandBuffer->shaderRecCl, V3D21_SHADER_RECORD_length); ControlList relocCl = commandBuffer->shaderRecCl; - uint32_t bindingCount = 0; - uint32_t bindingSelectBits = 0; + uint32_t attribCount = 0; + uint32_t attribSelectBits = 0; for(uint32_t c = 0 ; c < cb->graphicsPipeline->vertexAttributeDescriptionCount; ++c) { if(cb->vertexBuffers[cb->graphicsPipeline->vertexAttributeDescriptions[c].binding]) { - bindingCount++; - bindingSelectBits |= 1 << cb->graphicsPipeline->vertexAttributeDescriptions[c].binding; + attribCount++; + attribSelectBits |= 1 << cb->graphicsPipeline->vertexAttributeDescriptions[c].location; } } @@ -184,7 +184,7 @@ void vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t ins //TODO number of attribs //3 is the number of type of possible shaders - for(int c = 0; c < (3 + bindingCount)*4; ++c) + for(int c = 0; c < (3 + attribCount)*4; ++c) { clInsertNop(&commandBuffer->shaderRecCl); } @@ -201,13 +201,15 @@ void vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t ins 0, //fragment uniform address? fragCode, //fragment code address 0, //TODO vertex number of used uniforms? - bindingSelectBits, //vertex attribute array select bits + attribSelectBits, //vertex attribute array select bits attribSize, //vertex total attribute size 0, //vertex uniform address vertCode, //vertex shader code address 0, //TODO coordinate number of used uniforms? - bindingSelectBits, //coordinate attribute array select bits - attribSize, //coordinate total attribute size + //TODO how do we know which attribute contains the vertices? + //for now the first one will be hardcoded to have the vertices... + 1 << 0, //coordinate attribute array select bits + getFormatByteSize(cb->graphicsPipeline->vertexAttributeDescriptions[0].format), //coordinate total attribute size 0, //coordinate uniform address coordCode //coordinate shader code address ); @@ -230,8 +232,8 @@ void vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t ins vertexBuffer, //reloc address getFormatByteSize(cb->graphicsPipeline->vertexAttributeDescriptions[cb->graphicsPipeline->vertexAttributeDescriptions[c].binding].format), cb->graphicsPipeline->vertexBindingDescriptions[cb->graphicsPipeline->vertexAttributeDescriptions[c].binding].stride, //stride - 0, //vertex vpm offset - 0 //coordinte vpm offset + cb->graphicsPipeline->vertexAttributeDescriptions[c].offset, //vertex vpm offset + cb->graphicsPipeline->vertexAttributeDescriptions[c].offset //coordinte vpm offset ); } }