mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2024-11-28 10:24:15 +01:00
started adding code to correct handle indices but doesnt work yet
This commit is contained in:
parent
afa6104ba0
commit
80d90ca190
@ -57,11 +57,7 @@ void clInsertNewCLMarker(ControlList* cl,
|
||||
|
||||
CLMarker marker = {0};
|
||||
marker.memGuard = 0xDDDDDDDD;
|
||||
marker.handlesBufOffset = 0;
|
||||
marker.shaderRecBufOffset = 0;
|
||||
marker.uniformsBufOffset = 0;
|
||||
marker.nextMarkerOffset = -1;
|
||||
marker.numDrawCallsSubmitted = 0;
|
||||
|
||||
//close current marker
|
||||
if(cl->currMarkerOffset != ~0u && !((CLMarker*)getCPAptrFromOffset(cl->CPA, cl->currMarkerOffset))->size)
|
||||
|
@ -56,6 +56,14 @@ typedef struct CLMarker
|
||||
//uint8_t* uniformsBuf; //
|
||||
uint32_t uniformsBufOffset;
|
||||
uint32_t uniformsSize;
|
||||
|
||||
//secondary commandbuffer handle index relocations
|
||||
uint32_t uniformRelocOffset;
|
||||
uint32_t uniformRelocSize;
|
||||
uint32_t gemRelocOffset;
|
||||
uint32_t gemRelocSize;
|
||||
uint32_t shaderRecRelocOffset;
|
||||
uint32_t shaderRecRelocSize;
|
||||
} CLMarker;
|
||||
|
||||
typedef struct ControlList
|
||||
|
@ -132,6 +132,10 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkAllocateCommandBuffers)(
|
||||
clInit(&pCommandBuffers[c]->shaderRecCl, &cp->cpa, consecutivePoolAllocate(&cp->cpa, 1), cp->cpa.blockSize);
|
||||
clInit(&pCommandBuffers[c]->uniformsCl, &cp->cpa, consecutivePoolAllocate(&cp->cpa, 1), cp->cpa.blockSize);
|
||||
|
||||
clInit(&pCommandBuffers[c]->uniformRelocCl, &cp->cpa, consecutivePoolAllocate(&cp->cpa, 1), cp->cpa.blockSize);
|
||||
clInit(&pCommandBuffers[c]->gemRelocCl, &cp->cpa, consecutivePoolAllocate(&cp->cpa, 1), cp->cpa.blockSize);
|
||||
clInit(&pCommandBuffers[c]->shaderRecRelocCl, &cp->cpa, consecutivePoolAllocate(&cp->cpa, 1), cp->cpa.blockSize);
|
||||
|
||||
pCommandBuffers[c]->graphicsPipeline = 0;
|
||||
pCommandBuffers[c]->computePipeline = 0;
|
||||
pCommandBuffers[c]->indexBuffer = 0;
|
||||
@ -179,6 +183,24 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkAllocateCommandBuffers)(
|
||||
res = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
if(pCommandBuffers[c]->uniformRelocCl.offset == ~0u)
|
||||
{
|
||||
res = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
if(pCommandBuffers[c]->gemRelocCl.offset == ~0u)
|
||||
{
|
||||
res = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
if(pCommandBuffers[c]->shaderRecRelocCl.offset == ~0u)
|
||||
{
|
||||
res = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,6 +214,10 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkAllocateCommandBuffers)(
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->handlesCl.offset), pCommandBuffers[c]->handlesCl.numBlocks);
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->shaderRecCl.offset), pCommandBuffers[c]->shaderRecCl.numBlocks);
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->uniformsCl.offset), pCommandBuffers[c]->uniformsCl.numBlocks);
|
||||
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->uniformRelocCl.offset), pCommandBuffers[c]->uniformRelocCl.numBlocks);
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->gemRelocCl.offset), pCommandBuffers[c]->gemRelocCl.numBlocks);
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->shaderRecRelocCl.offset), pCommandBuffers[c]->shaderRecRelocCl.numBlocks);
|
||||
poolFree(&cp->pa, pCommandBuffers[c]);
|
||||
pCommandBuffers[c] = 0;
|
||||
}
|
||||
@ -570,7 +596,7 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueueSubmit)(
|
||||
submitCl.shader_rec_count = marker->shaderRecCount;
|
||||
submitCl.uniforms_size = marker->uniformsSize;
|
||||
|
||||
/**
|
||||
/**/
|
||||
printf("BCL:\n");
|
||||
uint8_t* mem = malloc(marker->size);
|
||||
memcpy(mem, marker+1, marker->size);
|
||||
@ -750,6 +776,10 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkFreeCommandBuffers)(
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->handlesCl.offset), pCommandBuffers[c]->handlesCl.numBlocks);
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->shaderRecCl.offset), pCommandBuffers[c]->shaderRecCl.numBlocks);
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->uniformsCl.offset), pCommandBuffers[c]->uniformsCl.numBlocks);
|
||||
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->uniformRelocCl.offset), pCommandBuffers[c]->uniformRelocCl.numBlocks);
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->gemRelocCl.offset), pCommandBuffers[c]->gemRelocCl.numBlocks);
|
||||
consecutivePoolFree(&cp->cpa, getCPAptrFromOffset(&cp->cpa, pCommandBuffers[c]->shaderRecRelocCl.offset), pCommandBuffers[c]->shaderRecRelocCl.numBlocks);
|
||||
poolFree(&cp->pa, pCommandBuffers[c]);
|
||||
}
|
||||
}
|
||||
@ -903,6 +933,14 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkResetCommandBuffer)(
|
||||
commandBuffer->uniformsCl.nextFreeByteOffset = commandBuffer->uniformsCl.offset;
|
||||
commandBuffer->uniformsCl.currMarkerOffset = -1;
|
||||
|
||||
commandBuffer->uniformRelocCl.nextFreeByteOffset = commandBuffer->uniformRelocCl.offset;
|
||||
commandBuffer->uniformRelocCl.currMarkerOffset = -1;
|
||||
commandBuffer->gemRelocCl.nextFreeByteOffset = commandBuffer->gemRelocCl.offset;
|
||||
commandBuffer->gemRelocCl.currMarkerOffset = -1;
|
||||
commandBuffer->shaderRecRelocCl.nextFreeByteOffset = commandBuffer->shaderRecRelocCl.offset;
|
||||
commandBuffer->shaderRecRelocCl.currMarkerOffset = -1;
|
||||
|
||||
|
||||
commandBuffer->graphicsPipeline = 0;
|
||||
commandBuffer->computePipeline = 0;
|
||||
commandBuffer->indexBuffer = 0;
|
||||
@ -956,6 +994,34 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdExecuteCommands)(
|
||||
if(!secondaryMarker->size)
|
||||
{
|
||||
clCloseCurrentMarker(&secondary->binCl, &secondary->handlesCl, &secondary->shaderRecCl, secondary->shaderRecCount, &secondary->uniformsCl);
|
||||
|
||||
secondaryMarker->uniformRelocSize = secondary->uniformRelocCl.nextFreeByteOffset - (secondaryMarker->uniformRelocOffset + secondary->uniformRelocCl.offset);
|
||||
secondaryMarker->gemRelocSize = secondary->gemRelocCl.nextFreeByteOffset - (secondaryMarker->gemRelocOffset + secondary->gemRelocCl.offset);
|
||||
secondaryMarker->shaderRecRelocSize = secondary->shaderRecRelocCl.nextFreeByteOffset - (secondaryMarker->shaderRecRelocOffset + secondary->shaderRecRelocCl.offset);
|
||||
}
|
||||
|
||||
for(uint32_t d = 0; d < secondaryMarker->uniformRelocSize; ++d)
|
||||
{
|
||||
uint32_t offset = *(uint32_t*)getCPAptrFromOffset(secondary->uniformRelocCl.CPA, secondaryMarker->uniformRelocOffset + secondary->uniformRelocCl.offset);
|
||||
|
||||
uint32_t* handleIdx = getCPAptrFromOffset(secondary->uniformsCl.CPA, secondary->uniformsCl.offset + offset);
|
||||
*handleIdx += primary->handlesCl.nextFreeByteOffset - primary->handlesCl.offset;
|
||||
}
|
||||
|
||||
for(uint32_t d = 0; d < secondaryMarker->gemRelocSize; ++d)
|
||||
{
|
||||
uint32_t offset = *(uint32_t*)getCPAptrFromOffset(secondary->gemRelocCl.CPA, secondaryMarker->gemRelocOffset + secondary->gemRelocCl.offset);
|
||||
|
||||
uint32_t* handleIdx = getCPAptrFromOffset(secondary->binCl.CPA, secondary->binCl.offset + offset);
|
||||
*handleIdx += primary->handlesCl.nextFreeByteOffset - primary->handlesCl.offset;
|
||||
}
|
||||
|
||||
for(uint32_t d = 0; d < secondaryMarker->shaderRecRelocSize; ++d)
|
||||
{
|
||||
uint32_t offset = *(uint32_t*)getCPAptrFromOffset(secondary->shaderRecRelocCl.CPA, secondaryMarker->shaderRecRelocOffset + secondary->shaderRecRelocCl.offset);
|
||||
|
||||
uint32_t* handleIdx = getCPAptrFromOffset(secondary->shaderRecCl.CPA, secondary->shaderRecCl.offset + offset);
|
||||
*handleIdx += primary->handlesCl.nextFreeByteOffset - primary->handlesCl.offset;
|
||||
}
|
||||
|
||||
clFit(&primary->binCl, secondaryMarker->size);
|
||||
@ -965,11 +1031,36 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdExecuteCommands)(
|
||||
|
||||
//TODO handles/handle indices might be grabled up like this...
|
||||
clFit(&primary->handlesCl, secondaryMarker->handlesSize);
|
||||
clInsertData(&primary->handlesCl, secondaryMarker->handlesSize, getCPAptrFromOffset(secondary->handlesCl.CPA, secondaryMarker->handlesBufOffset));
|
||||
clInsertData(&primary->handlesCl, secondaryMarker->handlesSize, getCPAptrFromOffset(secondary->handlesCl.CPA, secondaryMarker->handlesBufOffset + secondary->handlesCl.offset));
|
||||
clFit(&primary->uniformsCl, secondaryMarker->uniformsSize);
|
||||
clInsertData(&primary->uniformsCl, secondaryMarker->uniformsSize, getCPAptrFromOffset(secondary->uniformsCl.CPA, secondaryMarker->uniformsBufOffset));
|
||||
clInsertData(&primary->uniformsCl, secondaryMarker->uniformsSize, getCPAptrFromOffset(secondary->uniformsCl.CPA, secondaryMarker->uniformsBufOffset + secondary->uniformsCl.offset));
|
||||
clFit(&primary->shaderRecCl, secondaryMarker->shaderRecSize);
|
||||
clInsertData(&primary->shaderRecCl, secondaryMarker->shaderRecSize, getCPAptrFromOffset(secondary->shaderRecCl.CPA, secondaryMarker->shaderRecBufOffset));
|
||||
clInsertData(&primary->shaderRecCl, secondaryMarker->shaderRecSize, getCPAptrFromOffset(secondary->shaderRecCl.CPA, secondaryMarker->shaderRecBufOffset + secondary->shaderRecCl.offset));
|
||||
|
||||
|
||||
printf("\nUniforms: ");
|
||||
for(int d = 0; d < secondaryMarker->uniformsSize / 4; ++d)
|
||||
{
|
||||
printf("%i ", *(((uint32_t*)getCPAptrFromOffset(secondary->uniformsCl.CPA, secondaryMarker->uniformsBufOffset + secondary->uniformsCl.offset))+d));
|
||||
}
|
||||
|
||||
printf("\nUniforms: ");
|
||||
for(int d = 0; d < secondaryMarker->uniformsSize / 4; ++d)
|
||||
{
|
||||
printf("%i ", *(((uint32_t*)getCPAptrFromOffset(primary->uniformsCl.CPA, primary->uniformsCl.offset))+d));
|
||||
}
|
||||
|
||||
printf("\nBO handles: ");
|
||||
for(int d = 0; d < secondaryMarker->handlesSize / 4; ++d)
|
||||
{
|
||||
printf("%u ", *(((uint32_t*)getCPAptrFromOffset(secondary->handlesCl.CPA, secondaryMarker->handlesBufOffset + secondary->handlesCl.offset))+d));
|
||||
}
|
||||
|
||||
printf("\nBO handles: ");
|
||||
for(int d = 0; d < secondaryMarker->handlesSize / 4; ++d)
|
||||
{
|
||||
printf("%u ", *(((uint32_t*)getCPAptrFromOffset(primary->handlesCl.CPA, primary->handlesCl.offset))+d));
|
||||
}
|
||||
|
||||
primary->shaderRecCount += secondary->shaderRecCount;
|
||||
}
|
||||
|
@ -379,6 +379,10 @@ typedef struct VkCommandBuffer_T
|
||||
VkCommandBufferUsageFlags usageFlags;
|
||||
_commandPool* cp;
|
||||
|
||||
ControlList uniformRelocCl;
|
||||
ControlList gemRelocCl;
|
||||
ControlList shaderRecRelocCl;
|
||||
|
||||
//State data
|
||||
_pipeline* graphicsPipeline;
|
||||
_pipeline* computePipeline;
|
||||
|
@ -269,6 +269,17 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
|
||||
coordCode //coordinate shader code address
|
||||
);
|
||||
|
||||
if(commandBuffer->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)
|
||||
{
|
||||
uint32_t offset = commandBuffer->shaderRecCl.nextFreeByteOffset - commandBuffer->shaderRecCl.offset - 12;
|
||||
clFit(&commandBuffer->shaderRecRelocCl, 12);
|
||||
clInsertData(&commandBuffer->shaderRecRelocCl, 4, &offset);
|
||||
offset -= 16;
|
||||
clInsertData(&commandBuffer->shaderRecRelocCl, 4, &offset);
|
||||
offset -= 16;
|
||||
clInsertData(&commandBuffer->shaderRecRelocCl, 4, &offset);
|
||||
}
|
||||
|
||||
uint32_t vertexAttribOffsets[8] = {};
|
||||
uint32_t coordAttribOffsets[8] = {};
|
||||
for(uint32_t c = 1; c < 8; ++c)
|
||||
@ -330,6 +341,13 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
|
||||
vertexAttribOffsets[cb->graphicsPipeline->vertexAttributeDescriptions[c].location], //vertex vpm offset
|
||||
coordAttribOffsets[cb->graphicsPipeline->vertexAttributeDescriptions[c].location] //coordinte vpm offset
|
||||
);
|
||||
|
||||
if(commandBuffer->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)
|
||||
{
|
||||
uint32_t offset = commandBuffer->shaderRecCl.nextFreeByteOffset - commandBuffer->shaderRecCl.offset - 12;
|
||||
clFit(&commandBuffer->shaderRecRelocCl, 4);
|
||||
clInsertData(&commandBuffer->shaderRecRelocCl, 4, &offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,6 +390,13 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
|
||||
clFit(&commandBuffer->uniformsCl, 4);
|
||||
clInsertData(&commandBuffer->uniformsCl, 4, &idx);
|
||||
|
||||
if(commandBuffer->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)
|
||||
{
|
||||
uint32_t offset = commandBuffer->uniformsCl.nextFreeByteOffset - commandBuffer->uniformsCl.offset - 4;
|
||||
clFit(&commandBuffer->uniformRelocCl, 4);
|
||||
clInsertData(&commandBuffer->uniformRelocCl, 4, &offset);
|
||||
}
|
||||
|
||||
numFragUniformReads++;
|
||||
}
|
||||
else if(mapping.descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
|
||||
@ -391,6 +416,13 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
|
||||
clFit(&commandBuffer->uniformsCl, 4);
|
||||
clInsertData(&commandBuffer->uniformsCl, 4, &idx);
|
||||
|
||||
if(commandBuffer->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)
|
||||
{
|
||||
uint32_t offset = commandBuffer->uniformsCl.nextFreeByteOffset - commandBuffer->uniformsCl.offset - 4;
|
||||
clFit(&commandBuffer->uniformRelocCl, 4);
|
||||
clInsertData(&commandBuffer->uniformRelocCl, 4, &offset);
|
||||
}
|
||||
|
||||
numFragUniformReads++;
|
||||
}
|
||||
else if(mapping.descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER ||
|
||||
@ -408,6 +440,13 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset)
|
||||
clFit(&commandBuffer->uniformsCl, 4);
|
||||
clInsertData(&commandBuffer->uniformsCl, 4, &idx);
|
||||
|
||||
if(commandBuffer->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)
|
||||
{
|
||||
uint32_t offset = commandBuffer->uniformsCl.nextFreeByteOffset - commandBuffer->uniformsCl.offset - 4;
|
||||
clFit(&commandBuffer->uniformRelocCl, 4);
|
||||
clInsertData(&commandBuffer->uniformRelocCl, 4, &offset);
|
||||
}
|
||||
|
||||
numFragUniformReads++;
|
||||
}
|
||||
else
|
||||
@ -628,6 +667,13 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdDrawIndexed)(
|
||||
|
||||
clInsertGEMRelocations(&commandBuffer->binCl, idx, 0);
|
||||
|
||||
if(commandBuffer->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)
|
||||
{
|
||||
uint32_t offset = commandBuffer->binCl.nextFreeByteOffset - commandBuffer->binCl.offset - 8;
|
||||
clFit(&commandBuffer->gemRelocCl, 4);
|
||||
clInsertData(&commandBuffer->gemRelocCl, 4, &offset);
|
||||
}
|
||||
|
||||
//Submit draw call: vertex Array Primitives
|
||||
clFit(&commandBuffer->binCl, V3D21_VERTEX_ARRAY_PRIMITIVES_length);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user