1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2025-02-18 15:54:21 +01:00

fixed attrib setup, app needs to be somewhat cooperative tho

This commit is contained in:
yours3lf 2020-05-01 20:37:33 +01:00
parent 03f98aff82
commit 13e7a67197
4 changed files with 27 additions and 43 deletions

View File

@ -554,7 +554,7 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
printf("%i ", *((uint32_t*)(marker->uniformsBuf)+d));
}
printf("\nShader recs: ");
uint8_t* ptr = marker->shaderRecBuf + (3 + 2) * 4;
uint8_t* ptr = marker->shaderRecBuf + (3 + 3) * 4;
for(int d = 0; d < marker->shaderRecCount; ++d)
{
uint8_t flags = *ptr;

View File

@ -252,8 +252,6 @@ typedef struct VkShaderModule_T
uint32_t numMappings[VK_RPI_ASSEMBLY_TYPE_MAX];
uint32_t hasThreadSwitch;
uint32_t numVaryings;
uint32_t numVertVPMWrites;
uint32_t numCoordVPMWrites;
} _shaderModule;
typedef struct VkDescriptorSetLayout_T

View File

@ -184,15 +184,23 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
}
}
//TODO
//attrib size is simply how many times we wrote VPM x 4bytes minus the usual stuff (so 3x4bytes for Xs/Ys etc.)
//for CS it's always 12
//for attrib offsets
//vertex coords will obviouslly have offset 0
//coord offsets will always be 12 unless it's vertex coords then it's 0
//the rest:
//for VS we need to add the size of Xs/Ys, Zs, and 1/Wc (+point size if ever), so 3x4bytes
//attrib size is simply how many times we read VPM (x4 bytes) in VS and CS
//attrib records:
//base address, num bytes, stride are for the kernel side to assemble our vpm
//VPM offsets: these would be how many vpm reads were before a specific attrib (x4 bytes)
//we don't really have that info, so we have to play with strides/formats
uint32_t vertexAttribSize = 0, coordAttribSize = 0;
for(uint32_t c = 0; c < cb->graphicsPipeline->vertexAttributeDescriptionCount; ++c)
{
vertexAttribSize += getFormatBpp(cb->graphicsPipeline->vertexAttributeDescriptions[c].format) >> 3;
if(cb->graphicsPipeline->vertexAttributeDescriptions[c].location == 0)
{
//this should be the vertex coordinates location
coordAttribSize = getFormatBpp(cb->graphicsPipeline->vertexAttributeDescriptions[c].format) >> 3;
}
}
//number of attribs
//3 is the number of type of possible shaders
@ -214,34 +222,36 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
fragCode, //fragment code address
0, //TODO vertex number of used uniforms?
attribSelectBits, //vertex attribute array select bits
vertModule->numVertVPMWrites * 4 - 12, //vertex total attribute size
vertexAttribSize, //vertex total attribute size
0, //vertex uniform address
vertCode, //vertex shader code address
0, //TODO coordinate number of used uniforms?
//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
12, //coordinate total attribute size
coordAttribSize, //coordinate total attribute size
0, //coordinate uniform address
coordCode //coordinate shader code address
);
uint32_t vertexAttribOffsets[8] = {};
uint32_t coordAttribOffsets[8] = {};
vertexAttribOffsets[1] = 12;
coordAttribOffsets[1] = 12;
for(uint32_t c = 2 ; c < 8; ++c)
for(uint32_t c = 1; c < 8; ++c)
{
coordAttribOffsets[c] = 12;
for(uint32_t d = 0; d < cb->graphicsPipeline->vertexAttributeDescriptionCount; ++d)
{
if(cb->graphicsPipeline->vertexAttributeDescriptions[d].location < c && cb->graphicsPipeline->vertexAttributeDescriptions[d].location > 0)
if(cb->graphicsPipeline->vertexAttributeDescriptions[d].location < c)
{
vertexAttribOffsets[c] += cb->graphicsPipeline->vertexBindingDescriptions[cb->graphicsPipeline->vertexAttributeDescriptions[d].binding].stride;
vertexAttribOffsets[c] += getFormatBpp(cb->graphicsPipeline->vertexAttributeDescriptions[d].format) >> 3;
}
}
}
for(uint32_t c = 1; c < 8; ++c)
{
coordAttribOffsets[c] = vertexAttribOffsets[1];
}
uint32_t maxIndex = 0xffff;
for(uint32_t c = 0 ; c < cb->graphicsPipeline->vertexAttributeDescriptionCount; ++c)
{

View File

@ -38,8 +38,6 @@ VkResult rpi_vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInf
shader->hasThreadSwitch = 0;
shader->numVaryings = 0;
shader->numCoordVPMWrites = 0;
shader->numVertVPMWrites = 0;
uint32_t hadVertex = 0, hadCoordinate = 0;
@ -93,28 +91,6 @@ VkResult rpi_vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInf
}
}
if(c == VK_RPI_ASSEMBLY_TYPE_VERTEX || c == VK_RPI_ASSEMBLY_TYPE_COORDINATE)
{
for(uint64_t d = 0; d < ci->numInstructions[c]; ++d)
{
unsigned waddr_add = ((ci->instructions[c][d] & (0x3fll << 38)) >> 38);
unsigned waddr_mul = ((ci->instructions[c][d] & (0x3fll << 32)) >> 32);
if(waddr_add == 48 || waddr_mul == 48)
{
if(c == VK_RPI_ASSEMBLY_TYPE_VERTEX)
{
shader->numVertVPMWrites++;
}
else if(c == VK_RPI_ASSEMBLY_TYPE_COORDINATE)
{
shader->numCoordVPMWrites++;
}
}
}
}
shader->sizes[c] = ci->numInstructions[c]*sizeof(uint64_t);
/**