mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2024-11-28 10:24:15 +01:00
cleanup
This commit is contained in:
parent
d947979785
commit
27f7e593d9
@ -52,8 +52,6 @@ uint32_t consecutivePoolAllocate(ConsecutivePoolAllocator* pa, uint32_t numBlock
|
||||
assert(pa->buf);
|
||||
assert(numBlocks);
|
||||
|
||||
//CPAdebugPrint(pa);
|
||||
|
||||
uint32_t* ptr = pa->nextFreeBlock;
|
||||
|
||||
if(!ptr)
|
||||
@ -116,8 +114,9 @@ uint32_t consecutivePoolAllocate(ConsecutivePoolAllocator* pa, uint32_t numBlock
|
||||
}
|
||||
}
|
||||
|
||||
//TODO debug stuff, not for release
|
||||
#ifdef DEBUG_BUILD
|
||||
if(ptr) memset(ptr, 0, numBlocks * pa->blockSize);
|
||||
#endif
|
||||
|
||||
pa->numFreeBlocks -= numBlocks;
|
||||
|
||||
@ -132,8 +131,9 @@ void consecutivePoolFree(ConsecutivePoolAllocator* pa, void* p, uint32_t numBloc
|
||||
assert(p);
|
||||
assert(numBlocks);
|
||||
|
||||
//TODO debug stuff, not for release
|
||||
#ifdef DEBUG_BUILD
|
||||
memset(p, 0, numBlocks * pa->blockSize);
|
||||
#endif
|
||||
|
||||
//if linked list of free entries is empty
|
||||
if(!pa->nextFreeBlock)
|
||||
@ -270,16 +270,16 @@ void CPAdebugPrint(ConsecutivePoolAllocator* pa)
|
||||
fprintf(stderr, "pa->nextFreeBlock %p\n", pa->nextFreeBlock);
|
||||
fprintf(stderr, "pa->numFreeBlocks %u\n", pa->numFreeBlocks);
|
||||
|
||||
//fprintf(stderr, "Linear walk:\n");
|
||||
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, "%p: %p, ", ptr, *(uint32_t*)ptr);
|
||||
}
|
||||
|
||||
//fprintf(stderr, "\nLinked List walk:\n");
|
||||
fprintf(stderr, "\nLinked List walk:\n");
|
||||
for(uint32_t* ptr = pa->nextFreeBlock; ptr; ptr = *ptr)
|
||||
{
|
||||
//fprintf(stderr, "%p: %p, ", ptr, *ptr);
|
||||
fprintf(stderr, "%p: %p, ", ptr, *ptr);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkCreateCommandPool)(
|
||||
//This flag may be used by the implementation to control memory allocation behavior within the pool.
|
||||
//--> definitely use pool allocator
|
||||
|
||||
//TODO pool family ignored for now
|
||||
//TODO queue family index ignored for now
|
||||
|
||||
_commandPool* cp = ALLOCATE(sizeof(_commandPool), 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
|
||||
@ -51,12 +51,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(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 consecutiveBlockSize = ARM_PAGE_SIZE;
|
||||
int consecutiveBlockNumber = 64;
|
||||
//int numCommandBufs = 30;
|
||||
//int consecutiveBlockSize = getCPABlockSize(256);
|
||||
//int consecutiveBlockNumber = 30;
|
||||
int consecutivePoolSize = consecutiveBlockNumber * consecutiveBlockSize;
|
||||
|
||||
static int counter = 0;
|
||||
@ -225,6 +221,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkBeginCommandBuffer)(
|
||||
//TODO VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT
|
||||
//specifies that a command buffer can be resubmitted to a queue while it is in the pending state, and recorded into multiple primary command buffers
|
||||
|
||||
//TODO inheritance info
|
||||
|
||||
//When a command buffer begins recording, all state in that command buffer is undefined
|
||||
|
||||
commandBuffer->usageFlags = pBeginInfo->flags;
|
||||
@ -768,7 +766,6 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkTrimCommandPool)(
|
||||
|
||||
//TODO trim cp's pool allocator and consecutive pool allocator
|
||||
//by reallocating to just used size
|
||||
//kinda silly, as if you need memory afterwards we need to reallocate again...
|
||||
|
||||
PROFILEEND(RPIFUNC(vkTrimCommandPool));
|
||||
}
|
||||
@ -844,6 +841,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkResetCommandBuffer)(
|
||||
cb->state = CMDBUF_STATE_INITIAL;
|
||||
}
|
||||
|
||||
//TODO secondary cmdbufs
|
||||
|
||||
if(flags & VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT)
|
||||
{
|
||||
//TODO release resources
|
||||
@ -899,7 +898,7 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdExecuteCommands)(
|
||||
const VkCommandBuffer* pCommandBuffers)
|
||||
{
|
||||
PROFILESTART(RPIFUNC(vkCmdExecuteCommands));
|
||||
|
||||
//TODO
|
||||
PROFILEEND(RPIFUNC(vkCmdExecuteCommands));
|
||||
}
|
||||
|
||||
|
@ -1315,7 +1315,7 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdCopyImageToBuffer)(
|
||||
uint32_t regionCount,
|
||||
const VkBufferImageCopy* pRegions)
|
||||
{
|
||||
//TODO needs linear format support from kernel side
|
||||
//needs linear format support from kernel side
|
||||
UNSUPPORTED(vkCmdCopyImageToBuffer);
|
||||
}
|
||||
|
||||
@ -1340,6 +1340,6 @@ VKAPI_ATTR void VKAPI_CALL RPIFUNC(vkCmdCopyBuffer)(
|
||||
uint32_t regionCount,
|
||||
const VkBufferCopy* pRegions)
|
||||
{
|
||||
//TODO needs linear format support from kernel side
|
||||
//needs linear format support from kernel side
|
||||
UNSUPPORTED(vkCmdCopyImageToBuffer);
|
||||
}
|
||||
|
@ -21,7 +21,9 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkCreateDescriptorPool)(
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BUILD
|
||||
memset(dp, 0, sizeof(_descriptorPool));
|
||||
#endif
|
||||
|
||||
uint32_t imageDescriptorCount = 0, bufferDescriptorCount = 0, texelBufferDescriptorCount = 0;
|
||||
for(uint32_t c = 0; c < pCreateInfo->poolSizeCount; ++c)
|
||||
@ -130,8 +132,6 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkAllocateDescriptorSets)(
|
||||
|
||||
_descriptorSetLayout* dsl = pAllocateInfo->pSetLayouts[c];
|
||||
|
||||
//TODO dsl flags
|
||||
|
||||
uint32_t imageDescriptorCount = 0, bufferDescriptorCount = 0, texelBufferDescriptorCount = 0;
|
||||
for(uint32_t d = 0; d < dsl->bindingsCount; ++d)
|
||||
{
|
||||
@ -238,8 +238,6 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkCreateDescriptorSetLayout)(
|
||||
assert(device);
|
||||
assert(pCreateInfo);
|
||||
|
||||
//TODO flags
|
||||
|
||||
_descriptorSetLayout* dsl = ALLOCATE(sizeof(_descriptorSetLayout), 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
|
||||
if(!dsl)
|
||||
@ -258,6 +256,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkCreateDescriptorSetLayout)(
|
||||
|
||||
memcpy(dsl->bindings, pCreateInfo->pBindings, sizeof(VkDescriptorSetLayoutBinding)*pCreateInfo->bindingCount);
|
||||
|
||||
//TODO immutable samplers
|
||||
|
||||
dsl->flags = pCreateInfo->flags;
|
||||
dsl->bindingsCount = pCreateInfo->bindingCount;
|
||||
|
||||
|
@ -190,9 +190,13 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkCreateInstance)(
|
||||
|
||||
set_loader_magic_value(&(*pInstance)->dev.loaderData);
|
||||
|
||||
int ret = openIoctl(); assert(ret != -1);
|
||||
int ret = openIoctl();
|
||||
if(ret == -1)
|
||||
{
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
assert(vc4_get_chip_info(controlFd,
|
||||
ret = vc4_get_chip_info(controlFd,
|
||||
&(*pInstance)->technologyVersion,
|
||||
&(*pInstance)->IDstrUINT,
|
||||
&(*pInstance)->vpmMemorySize,
|
||||
@ -204,7 +208,11 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkCreateInstance)(
|
||||
&(*pInstance)->v3dRevision,
|
||||
&(*pInstance)-> tileBufferDoubleBufferModeSupported,
|
||||
&(*pInstance)->tileBufferSize,
|
||||
&(*pInstance)->vriMemorySize));
|
||||
&(*pInstance)->vriMemorySize);
|
||||
if(!ret)
|
||||
{
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
(*pInstance)->hasTiling = vc4_test_tiling(controlFd);
|
||||
|
||||
|
@ -455,9 +455,10 @@ uint32_t vc4_bo_alloc(int fd, uint32_t size, const char *name)
|
||||
|
||||
vc4_bo_label(fd, handle, name);
|
||||
|
||||
//TODO debug stuff, not for release
|
||||
#ifdef DEBUG_BUILD
|
||||
void* ptr = vc4_bo_map(fd, handle, 0, size);
|
||||
memset(ptr, 0, size);
|
||||
#endif
|
||||
|
||||
return handle;
|
||||
}
|
||||
@ -484,14 +485,13 @@ void vc4_bo_free(int fd, uint32_t bo, void* mappedAddr, uint32_t size)
|
||||
|
||||
void vc4_bo_label(int fd, uint32_t bo, const char* name)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
assert(fd);
|
||||
assert(bo);
|
||||
|
||||
char* str = name;
|
||||
if(!str) str = "";
|
||||
|
||||
//TODO don't use in release!
|
||||
|
||||
struct drm_vc4_label_bo label = {
|
||||
.handle = bo,
|
||||
.len = strlen(str),
|
||||
@ -503,6 +503,7 @@ void vc4_bo_label(int fd, uint32_t bo, const char* name)
|
||||
fprintf(stderr, "BO label failed: %s, bo %u\n",
|
||||
strerror(errno), bo);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int vc4_bo_get_dmabuf(int fd, uint32_t bo)
|
||||
|
@ -119,14 +119,12 @@ VkResult RPIFUNC(vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSi
|
||||
{
|
||||
assert(size > 0);
|
||||
assert(size <= ((_deviceMemory*)memory)->size - offset);
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
size = ((_deviceMemory*)memory)->size;
|
||||
}
|
||||
|
||||
//TODO check ppdata alignment
|
||||
//TODO multiple instances?
|
||||
|
||||
void* ptr = vc4_bo_map(controlFd, ((_deviceMemory*)memory)->bo, offset, size);
|
||||
if(!ptr)
|
||||
{
|
||||
@ -170,6 +168,7 @@ void RPIFUNC(vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAlloc
|
||||
_deviceMemory* mem = memory;
|
||||
if(mem)
|
||||
{
|
||||
vc4_set_madvise(controlFd, mem->bo, 0, device->dev->instance->hasMadvise);
|
||||
vc4_bo_free(controlFd, mem->bo, mem->mappedPtr, mem->size);
|
||||
FREE(mem);
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ void RPIFUNC(vkCmdBindPipeline)(VkCommandBuffer commandBuffer, VkPipelineBindPoi
|
||||
cb->computePipeline = pipeline;
|
||||
}
|
||||
|
||||
//TODO check that dynamic states are respected around the driver
|
||||
|
||||
PROFILEEND(RPIFUNC(vkCmdBindPipeline));
|
||||
}
|
||||
|
||||
@ -192,7 +194,6 @@ VkResult RPIFUNC(vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pip
|
||||
UNSUPPORTED(pipelineCache);
|
||||
}
|
||||
|
||||
//TODO pipeline caches
|
||||
//TODO flags
|
||||
|
||||
for(int c = 0; c < createInfoCount; ++c)
|
||||
|
@ -45,6 +45,8 @@ void RPIFUNC(vkCmdBeginRenderPass)(VkCommandBuffer commandBuffer, const VkRender
|
||||
uint32_t writeMSAAimageOffset = 0;
|
||||
uint32_t writeMSAAdepthStencilImageOffset = 0;
|
||||
|
||||
//TODO render area
|
||||
|
||||
//TODO handle multiple subpasses
|
||||
//TODO subpass contents ignored
|
||||
//TODO input attachments ignored
|
||||
|
@ -116,7 +116,7 @@ VkResult RPIFUNC(vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceM
|
||||
|
||||
assert(!buf->boundMem);
|
||||
assert(memoryOffset < mem->size);
|
||||
//assert(memoryOffset % buf->alignment == 0);
|
||||
assert(memoryOffset % buf->alignment == 0);
|
||||
assert(buf->alignedSize <= mem->size - memoryOffset);
|
||||
|
||||
buf->boundMem = mem;
|
||||
@ -450,7 +450,7 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkBindImageMemory)(
|
||||
|
||||
assert(!i->boundMem);
|
||||
assert(memoryOffset < m->size);
|
||||
//assert(memoryOffset % i->alignment == 0);
|
||||
assert(memoryOffset % i->alignment == 0);
|
||||
assert(i->size <= m->size - memoryOffset);
|
||||
|
||||
i->boundMem = m;
|
||||
|
@ -624,6 +624,8 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueuePresentKHR)(
|
||||
PROFILEEND(&frameProfile);
|
||||
}
|
||||
|
||||
//TODO vsync flip modes etc.
|
||||
|
||||
assert(queue);
|
||||
assert(pPresentInfo);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user