From 044b3be14c4db7445a3e82b8d699a74f05619ad9 Mon Sep 17 00:00:00 2001 From: yours3lf <0.tamas.marton@gmail.com> Date: Sun, 7 Jun 2020 18:15:36 +0100 Subject: [PATCH] added asserts for a couple of hw bugs --- driver/ControlListUtil.c | 1 + driver/ControlListUtil.h | 2 ++ driver/command.c | 10 ++++++++-- driver/common.h | 2 -- driver/draw.c | 8 ++++++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/driver/ControlListUtil.c b/driver/ControlListUtil.c index 93822b1..3c8cdd9 100644 --- a/driver/ControlListUtil.c +++ b/driver/ControlListUtil.c @@ -60,6 +60,7 @@ void clInsertNewCLMarker(ControlList* cl, marker.shaderRecBufOffset = 0; marker.uniformsBufOffset = 0; marker.nextMarkerOffset = -1; + marker.numDrawCallsSubmitted = 0; //close current marker if(cl->currMarkerOffset != -1 && !((CLMarker*)getCPAptrFromOffset(cl->CPA, cl->currMarkerOffset))->size) diff --git a/driver/ControlListUtil.h b/driver/ControlListUtil.h index 9e49595..1fe2d77 100644 --- a/driver/ControlListUtil.h +++ b/driver/ControlListUtil.h @@ -42,6 +42,8 @@ typedef struct CLMarker uint32_t width, height; //render w/h uint32_t mipLevel; + uint32_t numDrawCallsSubmitted; + //pointers that point to where all the other CL data is //plus sizes //uint8_t* handlesBuf; // diff --git a/driver/command.c b/driver/command.c index 69d81c3..7b85c4a 100644 --- a/driver/command.c +++ b/driver/command.c @@ -11,6 +11,8 @@ static uint64_t lastFinishedSeqno = 0; static atomic_int lastSeqnoGuard = 0; +#define VC4_HW_2116_COUNT 0x1ef0 + /* * https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#commandbuffers-pools * Command pools are opaque objects that command buffer memory is allocated from, and which allow the implementation to amortize the @@ -132,7 +134,6 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkAllocateCommandBuffers)( pCommandBuffers[c]->graphicsPipeline = 0; pCommandBuffers[c]->computePipeline = 0; - pCommandBuffers[c]->numDrawCallsSubmitted = 0; pCommandBuffers[c]->indexBuffer = 0; pCommandBuffers[c]->indexBufferOffset = 0; pCommandBuffers[c]->vertexBufferDirty = 1; @@ -662,6 +663,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueueSubmit)( printf("perfmonID %u\n", submitCl.perfmonid); /**/ + assert(marker->numDrawCallsSubmitted <= VC4_HW_2116_COUNT); + assert(submitCl.bo_handle_count > 0); //TODO @@ -673,6 +676,10 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueueSubmit)( lastSeqnoGuard = 0; } + //see if it's a sync bug + //uint64_t timeout = WAIT_TIMEOUT_INFINITE; + //vc4_seqno_wait(controlFd, &lastFinishedSeqno, queue->lastEmitSeqno, &timeout); + //advance in linked list marker = marker->nextMarkerOffset == -1 ? 0 : getCPAptrFromOffset(cmdbuf->binCl.CPA, marker->nextMarkerOffset + cmdbuf->binCl.offset); } @@ -889,7 +896,6 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkResetCommandBuffer)( commandBuffer->graphicsPipeline = 0; commandBuffer->computePipeline = 0; - commandBuffer->numDrawCallsSubmitted = 0; commandBuffer->indexBuffer = 0; commandBuffer->indexBufferOffset = 0; commandBuffer->vertexBufferDirty = 1; diff --git a/driver/common.h b/driver/common.h index 66ecf27..edf80f1 100644 --- a/driver/common.h +++ b/driver/common.h @@ -382,8 +382,6 @@ typedef struct VkCommandBuffer_T _renderpass* currRenderPass; - uint32_t numDrawCallsSubmitted; - VkViewport viewport; VkRect2D scissor; float lineWidth; diff --git a/driver/draw.c b/driver/draw.c index 39e8fea..dddc9dd 100644 --- a/driver/draw.c +++ b/driver/draw.c @@ -584,6 +584,8 @@ void RPIFUNC(vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uin UNSUPPORTED(instancing); } + assert((firstVertex + vertexCount) <= ((1<<16) - 1)); + drawCommon(commandBuffer, 0); _commandBuffer* cb = commandBuffer; @@ -592,7 +594,7 @@ void RPIFUNC(vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uin clFit(commandBuffer, &commandBuffer->binCl, V3D21_VERTEX_ARRAY_PRIMITIVES_length); clInsertVertexArrayPrimitives(&commandBuffer->binCl, firstVertex, vertexCount, getPrimitiveMode(cb->graphicsPipeline->topology)); - cb->numDrawCallsSubmitted++; + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->numDrawCallsSubmitted++; PROFILEEND(RPIFUNC(vkCmdDraw)); } @@ -615,6 +617,8 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdDrawIndexed)( UNSUPPORTED(instancing); } + assert((firstIndex + indexCount) <= ((1<<16) - 1)); + uint32_t maxIndex = drawCommon(commandBuffer, vertexOffset); _commandBuffer* cb = commandBuffer; @@ -634,7 +638,7 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdDrawIndexed)( 1, //we only support 16 bit indices getPrimitiveMode(cb->graphicsPipeline->topology)); - cb->numDrawCallsSubmitted++; + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->numDrawCallsSubmitted++; PROFILEEND(RPIFUNC(vkCmdDrawIndexed)); }