mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2025-02-21 18:54:18 +01:00
added CPA debugging
This commit is contained in:
parent
126a5e7ac7
commit
df62eadb89
@ -48,7 +48,7 @@ void* consecutivePoolAllocate(ConsecutivePoolAllocator* pa, uint32_t numBlocks)
|
|||||||
{
|
{
|
||||||
assert(pa->buf);
|
assert(pa->buf);
|
||||||
|
|
||||||
// fprintf(stderr, "pa->nextFreeBlock %u\n", pa->nextFreeBlock);
|
CPAdebugPrint(pa);
|
||||||
|
|
||||||
if(!pa->nextFreeBlock)
|
if(!pa->nextFreeBlock)
|
||||||
{
|
{
|
||||||
@ -148,6 +148,8 @@ void consecutivePoolFree(ConsecutivePoolAllocator* pa, void* p, uint32_t numBloc
|
|||||||
//else it frees current block and allocates a new one
|
//else it frees current block and allocates a new one
|
||||||
void* consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMem, uint32_t currNumBlocks)
|
void* consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMem, uint32_t currNumBlocks)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "CPA realloc\n");
|
||||||
|
|
||||||
currentMem = (char*)currentMem - 4;
|
currentMem = (char*)currentMem - 4;
|
||||||
|
|
||||||
if(pa->nextFreeBlock == (uint32_t*)((char*)currentMem + currNumBlocks * pa->blockSize))
|
if(pa->nextFreeBlock == (uint32_t*)((char*)currentMem + currNumBlocks * pa->blockSize))
|
||||||
@ -168,3 +170,23 @@ void* consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMem,
|
|||||||
return newContents;
|
return newContents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPAdebugPrint(ConsecutivePoolAllocator* pa)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "\nCPA Debug Print\n");
|
||||||
|
fprintf(stderr, "pa->buf %p\n", pa->buf);
|
||||||
|
fprintf(stderr, "pa->nextFreeBlock %p\n", pa->nextFreeBlock);
|
||||||
|
|
||||||
|
fprintf(stderr, "Linear walk:\n");
|
||||||
|
for(char* ptr = pa->buf; ptr != pa->buf + pa->size; ptr += pa->blockSize)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%p: %p, ", ptr, *(uint32_t*)ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "\nLinked List walk:\n");
|
||||||
|
for(uint32_t* ptr = pa->nextFreeBlock; ptr; ptr = *ptr)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%p: %p, ", ptr, *ptr);
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@ void destroyConsecutivePoolAllocator(ConsecutivePoolAllocator* pa);
|
|||||||
void* consecutivePoolAllocate(ConsecutivePoolAllocator* pa, uint32_t numBlocks);
|
void* consecutivePoolAllocate(ConsecutivePoolAllocator* pa, uint32_t numBlocks);
|
||||||
void consecutivePoolFree(ConsecutivePoolAllocator* pa, void* p, uint32_t numBlocks);
|
void consecutivePoolFree(ConsecutivePoolAllocator* pa, void* p, uint32_t numBlocks);
|
||||||
void* consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMem, uint32_t currNumBlocks);
|
void* consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMem, uint32_t currNumBlocks);
|
||||||
void debugPrint(ConsecutivePoolAllocator*, const char* text);
|
void CPAdebugPrint(ConsecutivePoolAllocator* pa);
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,19 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateDescriptorPool(
|
|||||||
dp->bufferDescriptorCPA = 0;
|
dp->bufferDescriptorCPA = 0;
|
||||||
dp->texelBufferDescriptorCPA = 0;
|
dp->texelBufferDescriptorCPA = 0;
|
||||||
|
|
||||||
void* memem = ALLOCATE(sizeof(mapElem)*(imageDescriptorCount + bufferDescriptorCount + texelBufferDescriptorCount), 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
// fprintf(stderr, "imageDescriptorCount %u\n", imageDescriptorCount);
|
||||||
|
// fprintf(stderr, "bufferDescriptorCount %u\n", bufferDescriptorCount);
|
||||||
|
// fprintf(stderr, "texelBufferDescriptorCount %u\n", texelBufferDescriptorCount);
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t mapElemBlockSize = sizeof(mapElem);
|
||||||
|
uint32_t mapBufSize = mapElemBlockSize * (imageDescriptorCount + bufferDescriptorCount + texelBufferDescriptorCount);
|
||||||
|
void* memem = ALLOCATE(mapBufSize, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||||
if(!memem)
|
if(!memem)
|
||||||
{
|
{
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
dp->mapElementCPA = createConsecutivePoolAllocator(memem, sizeof(mapElem), sizeof(mapElem) * (imageDescriptorCount + bufferDescriptorCount + texelBufferDescriptorCount));
|
dp->mapElementCPA = createConsecutivePoolAllocator(memem, mapElemBlockSize, mapBufSize);
|
||||||
|
|
||||||
if(imageDescriptorCount > 0)
|
if(imageDescriptorCount > 0)
|
||||||
{
|
{
|
||||||
@ -69,12 +76,13 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateDescriptorPool(
|
|||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* mem = ALLOCATE(sizeof(_descriptorImage)*imageDescriptorCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
uint32_t blockSize = sizeof(_descriptorImage);
|
||||||
|
void* mem = ALLOCATE(blockSize*imageDescriptorCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||||
if(!mem)
|
if(!mem)
|
||||||
{
|
{
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
*dp->imageDescriptorCPA = createConsecutivePoolAllocator(mem, sizeof(_descriptorImage), sizeof(_descriptorImage) * imageDescriptorCount);
|
*dp->imageDescriptorCPA = createConsecutivePoolAllocator(mem, blockSize, blockSize * imageDescriptorCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bufferDescriptorCount > 0)
|
if(bufferDescriptorCount > 0)
|
||||||
@ -85,12 +93,13 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateDescriptorPool(
|
|||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* mem = ALLOCATE(sizeof(_descriptorBuffer)*bufferDescriptorCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
uint32_t blockSize = sizeof(_descriptorBuffer);
|
||||||
|
void* mem = ALLOCATE(blockSize*bufferDescriptorCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||||
if(!mem)
|
if(!mem)
|
||||||
{
|
{
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
*dp->bufferDescriptorCPA = createConsecutivePoolAllocator(mem, sizeof(_descriptorBuffer), sizeof(_descriptorBuffer) * bufferDescriptorCount);
|
*dp->bufferDescriptorCPA = createConsecutivePoolAllocator(mem, blockSize, blockSize * bufferDescriptorCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(texelBufferDescriptorCount > 0)
|
if(texelBufferDescriptorCount > 0)
|
||||||
@ -101,12 +110,13 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateDescriptorPool(
|
|||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* mem = ALLOCATE(sizeof(_descriptorTexelBuffer)*texelBufferDescriptorCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
uint32_t blockSize = sizeof(_descriptorBuffer);
|
||||||
|
void* mem = ALLOCATE(blockSize*texelBufferDescriptorCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||||
if(!mem)
|
if(!mem)
|
||||||
{
|
{
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
*dp->texelBufferDescriptorCPA = createConsecutivePoolAllocator(mem, sizeof(_descriptorTexelBuffer), sizeof(_descriptorTexelBuffer) * texelBufferDescriptorCount);
|
*dp->texelBufferDescriptorCPA = createConsecutivePoolAllocator(mem, blockSize, blockSize * texelBufferDescriptorCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
*pDescriptorPool = dp;
|
*pDescriptorPool = dp;
|
||||||
@ -165,6 +175,10 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkAllocateDescriptorSets(
|
|||||||
ds->bufferDescriptors = 0;
|
ds->bufferDescriptors = 0;
|
||||||
ds->texelBufferDescriptors = 0;
|
ds->texelBufferDescriptors = 0;
|
||||||
|
|
||||||
|
// fprintf(stderr, "imageDescriptorCount %u\n", imageDescriptorCount);
|
||||||
|
// fprintf(stderr, "bufferDescriptorCount %u\n", bufferDescriptorCount);
|
||||||
|
// fprintf(stderr, "texelBufferDescriptorCount %u\n", texelBufferDescriptorCount);
|
||||||
|
|
||||||
if(imageDescriptorCount > 0)
|
if(imageDescriptorCount > 0)
|
||||||
{
|
{
|
||||||
ds->imageDescriptors = consecutivePoolAllocate(dp->imageDescriptorCPA, imageDescriptorCount);
|
ds->imageDescriptors = consecutivePoolAllocate(dp->imageDescriptorCPA, imageDescriptorCount);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user