diff --git a/driver/ConsecutivePoolAllocator.c b/driver/ConsecutivePoolAllocator.c index 3947a5d..b527589 100644 --- a/driver/ConsecutivePoolAllocator.c +++ b/driver/ConsecutivePoolAllocator.c @@ -85,6 +85,11 @@ uint32_t consecutivePoolAllocate(ConsecutivePoolAllocator* pa, uint32_t numBlock pa->nextFreeBlock = *(uint32_t*)((char*)ptr + (numBlocks - 1) * pa->blockSize); break; } + + if(!(*ptr)) + { + return -1; + } } //TODO debug stuff, not for release @@ -175,6 +180,8 @@ uint32_t consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMe assert(currentMem); assert(currNumBlocks); + fprintf(stderr, "CPA realloc begin \n"); + uint32_t* nextCandidate = (char*)currentMem + pa->blockSize * currNumBlocks; uint32_t* prevPtr = 0; @@ -193,6 +200,8 @@ uint32_t consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMe pa->nextFreeBlock = *listPtr; } + fprintf(stderr, "CPA realloc end continue \n"); + return (char*)currentMem - pa->buf; } @@ -201,19 +210,24 @@ uint32_t consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMe { //try to allocate one more block - void* newMem = consecutivePoolAllocate(pa, currNumBlocks + 1); + uint32_t newMemOffset = consecutivePoolAllocate(pa, currNumBlocks + 1); - if(!newMem) + if(newMemOffset == -1) { return -1; } + fprintf(stderr, "CPA realloc pre-copy \n"); + fprintf(stderr, "new offset %u, buf %p, max size %u, to copy %u\n", newMemOffset, pa->buf, pa->size, currNumBlocks * pa->blockSize); + //copy over old content - memcpy(newMem, currentMem, currNumBlocks * pa->blockSize); + memcpy(pa->buf + newMemOffset, currentMem, currNumBlocks * pa->blockSize); //free current element consecutivePoolFree(pa, currentMem, currNumBlocks); - return (char*)newMem - pa->buf; + fprintf(stderr, "CPA realloc end copy \n"); + + return newMemOffset; } } @@ -221,7 +235,7 @@ void* getCPAptrFromOffset(ConsecutivePoolAllocator* pa, uint32_t offset) { assert(pa); assert(pa->buf); - assert(offset <= pa->size - pa->blockSize); + assert(offset < pa->size); return pa->buf + offset; } diff --git a/driver/ControlListUtil.c b/driver/ControlListUtil.c index 6482c93..a79e049 100644 --- a/driver/ControlListUtil.c +++ b/driver/ControlListUtil.c @@ -55,6 +55,7 @@ void clInsertNewCLMarker(ControlList* cl, assert(uniformsCL); CLMarker marker = {}; + marker.memGuard = 0xDDDDDDDD; marker.handlesBufOffset = handlesCL->offset; marker.shaderRecBufOffset = shaderRecCL->offset; marker.uniformsBufOffset = uniformsCL->offset; diff --git a/driver/ControlListUtil.h b/driver/ControlListUtil.h index 66733c6..d71a3fe 100644 --- a/driver/ControlListUtil.h +++ b/driver/ControlListUtil.h @@ -14,6 +14,8 @@ typedef struct ControlListAddress typedef struct CLMarker { + uint32_t memGuard; + //current binning cl buf position is this struct in the CL plus sizeof(this struct) //struct CLMarker* nextMarker; // uint32_t nextMarkerOffset; diff --git a/driver/command.c b/driver/command.c index 6ba0887..1f37415 100644 --- a/driver/command.c +++ b/driver/command.c @@ -49,8 +49,8 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateCommandPool( //initial number of command buffers to hold int numCommandBufs = 128; //TODO uniforms might need to realloc, which should be handled properly - int consecutiveBlockSize = ARM_PAGE_SIZE * 20; - int consecutiveBlockNumber = 64; + int consecutiveBlockSize = ARM_PAGE_SIZE;// * 20; + int consecutiveBlockNumber = 128; //int numCommandBufs = 30; //int consecutiveBlockSize = getCPABlockSize(256); //int consecutiveBlockNumber = 30; @@ -299,6 +299,8 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit( //first entry is assumed to be a marker CLMarker* marker = getCPAptrFromOffset(cmdbuf->binCl.CPA, cmdbuf->binCl.offset); + assert(marker->memGuard == 0xDDDDDDDD); + //a command buffer may contain multiple render passes //and commands outside render passes such as clear commands //each of these corresponds to a control list submit @@ -822,10 +824,19 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkResetCommandBuffer( //reset commandbuffer state commandBuffer->shaderRecCount = 0; - clInit(&commandBuffer->binCl, &commandBuffer->cp->cpa, commandBuffer->binCl.offset, commandBuffer->cp->cpa.blockSize); - clInit(&commandBuffer->handlesCl, &commandBuffer->cp->cpa, commandBuffer->handlesCl.offset, commandBuffer->cp->cpa.blockSize); - clInit(&commandBuffer->shaderRecCl, &commandBuffer->cp->cpa, commandBuffer->shaderRecCl.offset, commandBuffer->cp->cpa.blockSize); - clInit(&commandBuffer->uniformsCl, &commandBuffer->cp->cpa, commandBuffer->uniformsCl.offset, commandBuffer->cp->cpa.blockSize); + + //preserve allocated blocks, only free them if the app requests so + commandBuffer->binCl.nextFreeByteOffset = commandBuffer->binCl.offset; + commandBuffer->binCl.currMarkerOffset = -1; + + commandBuffer->handlesCl.nextFreeByteOffset = commandBuffer->handlesCl.offset; + commandBuffer->handlesCl.currMarkerOffset = -1; + + commandBuffer->shaderRecCl.nextFreeByteOffset = commandBuffer->shaderRecCl.offset; + commandBuffer->shaderRecCl.currMarkerOffset = -1; + + commandBuffer->uniformsCl.nextFreeByteOffset = commandBuffer->uniformsCl.offset; + commandBuffer->uniformsCl.currMarkerOffset = -1; commandBuffer->graphicsPipeline = 0; commandBuffer->computePipeline = 0; diff --git a/driver/common.c b/driver/common.c index 7265413..67243c0 100644 --- a/driver/common.c +++ b/driver/common.c @@ -535,10 +535,16 @@ void clFit(VkCommandBuffer cb, ControlList* cl, uint32_t commandSize) { uint32_t currSize = cl->nextFreeByteOffset - cl->offset; uint32_t currMarkerOffset = cl->currMarkerOffset - cl->offset; - cl->offset = consecutivePoolReAllocate(&cb->cp->cpa, getCPAptrFromOffset(cl->CPA, cl->offset), cl->numBlocks); assert(cl->offset != -1); + fprintf(stderr, "currOffset %u nextFreeByteOffset %u currMarkerOffset %u\n", cl->offset, cl->nextFreeByteOffset, cl->currMarkerOffset); + cl->offset = consecutivePoolReAllocate(cl->CPA, getCPAptrFromOffset(cl->CPA, cl->offset), cl->numBlocks); assert(cl->offset != -1); cl->nextFreeByteOffset = cl->offset + currSize; cl->numBlocks++; - cl->currMarkerOffset = cl->offset + currMarkerOffset; + cl->currMarkerOffset = cl->currMarkerOffset == -1 ? -1 : cl->offset + currMarkerOffset; + fprintf(stderr, "currOffset %u nextFreeByteOffset %u currMarkerOffset %u\n", cl->offset, cl->nextFreeByteOffset, cl->currMarkerOffset); + if(cl->currMarkerOffset != -1) + { + assert(((CLMarker*)getCPAptrFromOffset(cl->CPA, cl->currMarkerOffset))->memGuard == 0xDDDDDDDD); + } } } diff --git a/driver/draw.c b/driver/draw.c index afcabcd..595a369 100644 --- a/driver/draw.c +++ b/driver/draw.c @@ -8,7 +8,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) assert(commandBuffer); _commandBuffer* cb = commandBuffer; - CLMarker* currMarker = getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset); + + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); //TODO handle cases when submitting >65k vertices in a VBO //TODO HW-2116 workaround @@ -110,6 +111,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) cb->depthBoundsDirty = 0; } + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + //Point size clFit(commandBuffer, &commandBuffer->binCl, V3D21_POINT_SIZE_length); clInsertPointSize(&commandBuffer->binCl, 1.0f); @@ -202,6 +205,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) //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 + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + uint32_t vertexAttribSize = 0, coordAttribSize = 0; for(uint32_t c = 0; c < cb->graphicsPipeline->vertexAttributeDescriptionCount; ++c) { @@ -216,6 +221,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) assert(vertModule->numVertVPMreads == vertexAttribSize >> 2); assert(vertModule->numCoordVPMreads == coordAttribSize >> 2); + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + //number of attribs //3 is the number of type of possible shaders for(int c = 0; c < (3 + attribCount)*4; ++c) @@ -225,8 +232,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) clInsertShaderRecord(&commandBuffer->shaderRecCl, &relocCl, &commandBuffer->handlesCl, - currMarker->handlesBufOffset, - currMarker->handlesSize, + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, !fragModule->hasThreadSwitch, 0, //TODO point size included in shaded vertex data? 1, //enable clipping @@ -248,6 +255,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) coordCode //coordinate shader code address ); + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + uint32_t vertexAttribOffsets[8] = {}; uint32_t coordAttribOffsets[8] = {}; for(uint32_t c = 1; c < 8; ++c) @@ -266,6 +275,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) coordAttribOffsets[c] = vertexAttribOffsets[1]; } + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + uint32_t maxIndex = 0xffff; for(uint32_t c = 0 ; c < cb->graphicsPipeline->vertexAttributeDescriptionCount; ++c) { @@ -311,8 +322,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) clInsertAttributeRecord(&commandBuffer->shaderRecCl, &relocCl, &commandBuffer->handlesCl, - currMarker->handlesBufOffset, - currMarker->handlesSize, + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, vertexBuffer, //reloc address formatByteSize, stride, @@ -322,6 +333,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) } } + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + //write uniforms _pipelineLayout* pl = cb->graphicsPipeline->layout; @@ -350,7 +363,7 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) //emit reloc for texture BO clFit(commandBuffer, &commandBuffer->handlesCl, 4); - uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, di->imageView->image->boundMem->bo); + uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, di->imageView->image->boundMem->bo); //emit tex bo reloc index clFit(commandBuffer, &commandBuffer->uniformsCl, 4); @@ -369,7 +382,7 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) //emit reloc for BO clFit(commandBuffer, &commandBuffer->handlesCl, 4); - uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, db->buffer->boundMem->bo); + uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, db->buffer->boundMem->bo); //emit bo reloc index clFit(commandBuffer, &commandBuffer->uniformsCl, 4); @@ -386,7 +399,7 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) //emit reloc for BO clFit(commandBuffer, &commandBuffer->handlesCl, 4); - uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, dtb->bufferView->buffer->boundMem->bo); + uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, dtb->bufferView->buffer->boundMem->bo); //emit bo reloc index clFit(commandBuffer, &commandBuffer->uniformsCl, 4); @@ -401,6 +414,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) } } + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + assert(numTextureSamples == fragModule->numTextureSamples); //after relocs we can proceed with the usual uniforms @@ -509,6 +524,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) } } + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + assert(numVertUniformReads == vertModule->numVertUniformReads); uint32_t numCoordUniformReads = 0; @@ -543,6 +560,8 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer, int32_t vertexOffset) assert(numCoordUniformReads == vertModule->numCoordUniformReads); + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + return maxIndex; } @@ -568,6 +587,8 @@ void rpi_vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t clInsertVertexArrayPrimitives(&commandBuffer->binCl, firstVertex, vertexCount, getPrimitiveMode(cb->graphicsPipeline->topology)); cb->numDrawCallsSubmitted++; + + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); } VKAPI_ATTR void VKAPI_CALL rpi_vkCmdDrawIndexed( @@ -589,15 +610,21 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdDrawIndexed( uint32_t maxIndex = drawCommon(commandBuffer, vertexOffset); _commandBuffer* cb = commandBuffer; - CLMarker* currMarker = getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset); + + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); clFit(commandBuffer, &commandBuffer->handlesCl, 4); - uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, cb->indexBuffer->boundMem->bo); + uint32_t idx = clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, cb->indexBuffer->boundMem->bo); clInsertGEMRelocations(&commandBuffer->binCl, idx, 0); + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + //Submit draw call: vertex Array Primitives clFit(commandBuffer, &commandBuffer->binCl, V3D21_VERTEX_ARRAY_PRIMITIVES_length); + + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); + clInsertIndexedPrimitiveList(&commandBuffer->binCl, maxIndex, //max index cb->indexBuffer->boundOffset + cb->indexBufferOffset + firstIndex * 2, @@ -606,6 +633,8 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdDrawIndexed( getPrimitiveMode(cb->graphicsPipeline->topology)); cb->numDrawCallsSubmitted++; + + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); } VKAPI_ATTR void VKAPI_CALL rpi_vkCmdDrawIndexedIndirect( diff --git a/driver/renderpass.c b/driver/renderpass.c index ee3c566..49258c3 100644 --- a/driver/renderpass.c +++ b/driver/renderpass.c @@ -194,43 +194,43 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB if(writeImage) { clFit(commandBuffer, &commandBuffer->handlesCl, 4); - clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, writeImage->boundMem->bo); + clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, writeImage->boundMem->bo); } if(readImage) { clFit(commandBuffer, &commandBuffer->handlesCl, 4); - clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, readImage->boundMem->bo); + clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, readImage->boundMem->bo); } if(writeDepthStencilImage) { clFit(commandBuffer, &commandBuffer->handlesCl, 4); - clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, writeDepthStencilImage->boundMem->bo); + clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, writeDepthStencilImage->boundMem->bo); } if(readDepthStencilImage) { clFit(commandBuffer, &commandBuffer->handlesCl, 4); - clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, readDepthStencilImage->boundMem->bo); + clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, readDepthStencilImage->boundMem->bo); } if(writeMSAAimage) { clFit(commandBuffer, &commandBuffer->handlesCl, 4); - clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, writeMSAAimage->boundMem->bo); + clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, writeMSAAimage->boundMem->bo); } if(writeMSAAdepthStencilImage) { clFit(commandBuffer, &commandBuffer->handlesCl, 4); - clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, writeMSAAdepthStencilImage->boundMem->bo); + clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->handlesSize, writeMSAAdepthStencilImage->boundMem->bo); } uint32_t bpp = 0; - currMarker->width = fb->width; - currMarker->height = fb->height; + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->width = fb->width; + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->height = fb->height; if(writeImage) { @@ -248,11 +248,11 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB } //pad render size if we are rendering to a mip level - currMarker->mipLevel = biggestMip; + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->mipLevel = biggestMip; - uint32_t width = currMarker->width; + uint32_t width = ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->width; - if(currMarker->mipLevel > 0) + if(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->mipLevel > 0) { width = getPow2Pad(width); width = width < 4 ? 4 : width; @@ -266,7 +266,7 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB 0, //auto initialize tile state data array bpp == 64, //64 bit color mode writeMSAAimage || writeMSAAdepthStencilImage || performResolve ? 1 : 0, //msaa - width, currMarker->height, + width, ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->height, 0, //tile state data array address 0, //tile allocation memory size 0); //tile allocation memory address @@ -278,9 +278,11 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB clFit(commandBuffer, &commandBuffer->binCl, V3D21_START_TILE_BINNING_length); clInsertStartTileBinning(&commandBuffer->binCl); - currMarker->perfmonID = cb->perfmonID; + ((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->perfmonID = cb->perfmonID; cb->currRenderPass = rp; + + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); } /* @@ -305,6 +307,8 @@ void rpi_vkCmdEndRenderPass(VkCommandBuffer commandBuffer) clInsertFlush(&cb->binCl); cb->currRenderPass = 0; + + assert(((CLMarker*)getCPAptrFromOffset(cb->binCl.CPA, cb->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); } /* diff --git a/driver/stateChange.c b/driver/stateChange.c index 72aaeb2..f7ea647 100644 --- a/driver/stateChange.c +++ b/driver/stateChange.c @@ -513,12 +513,11 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdClearColorImage( clFit(commandBuffer, &commandBuffer->binCl, sizeof(CLMarker)); clInsertNewCLMarker(&commandBuffer->binCl, &commandBuffer->handlesCl, &commandBuffer->shaderRecCl, commandBuffer->shaderRecCount, &commandBuffer->uniformsCl); - CLMarker* currMarker = getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset); - currMarker->writeImage = i; + ((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->writeImage = i; //insert reloc for render target clFit(commandBuffer, &commandBuffer->handlesCl, 4); - clGetHandleIndex(&commandBuffer->handlesCl, currMarker->handlesBufOffset, currMarker->handlesSize, i->boundMem->bo); + clGetHandleIndex(&commandBuffer->handlesCl, ((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->handlesBufOffset, ((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->handlesSize, i->boundMem->bo); clFit(commandBuffer, &commandBuffer->binCl, V3D21_TILE_BINNING_MODE_CONFIGURATION_length); clInsertTileBinningModeConfiguration(&commandBuffer->binCl, @@ -550,11 +549,13 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdClearColorImage( clFit(commandBuffer, &commandBuffer->binCl, V3D21_FLUSH_length); clInsertFlush(&commandBuffer->binCl); - currMarker->clearColor[0] = currMarker->clearColor[1] = packVec4IntoABGR8(pColor->float32); - currMarker->flags |= VC4_SUBMIT_CL_USE_CLEAR_COLOR; + ((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->clearColor[0] = ((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->clearColor[1] = packVec4IntoABGR8(pColor->float32); + ((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->flags |= VC4_SUBMIT_CL_USE_CLEAR_COLOR; - currMarker->width = i->width; - currMarker->height = i->height; + ((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->width = i->width; + ((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->height = i->height; + + assert(((CLMarker*)getCPAptrFromOffset(commandBuffer->binCl.CPA, commandBuffer->binCl.currMarkerOffset))->memGuard == 0xDDDDDDDD); } }