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