From 6ac318e0d0a4c38a45859597eec176b1cfc77dff Mon Sep 17 00:00:00 2001 From: Unknown <0.tamas.marton@gmail.com> Date: Tue, 16 Oct 2018 19:34:17 +0100 Subject: [PATCH] backup --- driver/command.c | 91 ++++++++++++++++++++--------------------------- driver/command.h | 4 --- driver/common.c | 60 +++++++++++++++++++++++++++++++ driver/common.h | 2 ++ driver/device.c | 45 ++++++++++++++++++++++- driver/instance.c | 14 +++++++- 6 files changed, 157 insertions(+), 59 deletions(-) delete mode 100644 driver/command.h diff --git a/driver/command.c b/driver/command.c index 204de41..7417c74 100644 --- a/driver/command.c +++ b/driver/command.c @@ -389,63 +389,48 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool( free(cp); } -void clFit(VkCommandBuffer cb, ControlList* cl, uint32_t commandSize) +/* + * https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkTrimCommandPool + */ +VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool( + VkDevice device, + VkCommandPool commandPool, + VkCommandPoolTrimFlags flags) { - if(!clHasEnoughSpace(cl, commandSize)) - { - uint32_t currSize = clSize(cl); - cl->buffer = consecutivePoolReAllocate(&cb->cp->cpa, cl->buffer, cl->numBlocks); assert(cl->buffer); - cl->nextFreeByte = cl->buffer + currSize; - } + assert(device); + assert(commandPool); + + _commandPool* cp = commandPool; + + //TODO?? } -void clDump(void* cl, uint32_t size) +/* + * https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkResetCommandPool + */ +VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool( + VkDevice device, + VkCommandPool commandPool, + VkCommandPoolResetFlags flags) { - struct v3d_device_info devinfo = { - /* While the driver supports V3D 2.1 and 2.6, we haven't split - * off a 2.6 XML yet (there are a couple of fields different - * in render target formatting) - */ - .ver = 21, - }; - struct v3d_spec* spec = v3d_spec_load(&devinfo); + assert(device); + assert(commandPool); - struct clif_dump *clif = clif_dump_init(&devinfo, stderr, true); + _commandPool* cp = commandPool; - uint32_t offset = 0, hw_offset = 0; - uint8_t *p = cl; - - while (offset < size) { - struct v3d_group *inst = v3d_spec_find_instruction(spec, p); - uint8_t header = *p; - uint32_t length; - - if (inst == NULL) { - printf("0x%08x 0x%08x: Unknown packet 0x%02x (%d)!\n", - offset, hw_offset, header, header); - return; - } - - length = v3d_group_get_length(inst); - - printf("0x%08x 0x%08x: 0x%02x %s\n", - offset, hw_offset, header, v3d_group_get_name(inst)); - - v3d_print_group(clif, inst, offset, p); - - switch (header) { - case VC4_PACKET_HALT: - case VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF: - return; - default: - break; - } - - offset += length; - if (header != VC4_PACKET_GEM_HANDLES) - hw_offset += length; - p += length; - } - - clif_dump_destroy(clif); + //TODO?? +} + +/* + * https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkResetCommandBuffer + */ +VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer( + VkCommandBuffer commandBuffer, + VkCommandBufferResetFlags flags) +{ + assert(commandBuffer); + + _commandBuffer* cb = commandBuffer; + + //TODO?? } diff --git a/driver/command.h b/driver/command.h deleted file mode 100644 index 5b9efbc..0000000 --- a/driver/command.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void clFit(VkCommandBuffer cb, ControlList* cl, uint32_t commandSize); -void clDump(void* cl, uint32_t size); diff --git a/driver/common.c b/driver/common.c index 813d8d0..51eb0d9 100644 --- a/driver/common.c +++ b/driver/common.c @@ -440,3 +440,63 @@ uint32_t ulog2(uint32_t v) return ret; } +void clFit(VkCommandBuffer cb, ControlList* cl, uint32_t commandSize) +{ + if(!clHasEnoughSpace(cl, commandSize)) + { + uint32_t currSize = clSize(cl); + cl->buffer = consecutivePoolReAllocate(&cb->cp->cpa, cl->buffer, cl->numBlocks); assert(cl->buffer); + cl->nextFreeByte = cl->buffer + currSize; + } +} + +void clDump(void* cl, uint32_t size) +{ + struct v3d_device_info devinfo = { + /* While the driver supports V3D 2.1 and 2.6, we haven't split + * off a 2.6 XML yet (there are a couple of fields different + * in render target formatting) + */ + .ver = 21, + }; + struct v3d_spec* spec = v3d_spec_load(&devinfo); + + struct clif_dump *clif = clif_dump_init(&devinfo, stderr, true); + + uint32_t offset = 0, hw_offset = 0; + uint8_t *p = cl; + + while (offset < size) { + struct v3d_group *inst = v3d_spec_find_instruction(spec, p); + uint8_t header = *p; + uint32_t length; + + if (inst == NULL) { + printf("0x%08x 0x%08x: Unknown packet 0x%02x (%d)!\n", + offset, hw_offset, header, header); + return; + } + + length = v3d_group_get_length(inst); + + printf("0x%08x 0x%08x: 0x%02x %s\n", + offset, hw_offset, header, v3d_group_get_name(inst)); + + v3d_print_group(clif, inst, offset, p); + + switch (header) { + case VC4_PACKET_HALT: + case VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF: + return; + default: + break; + } + + offset += length; + if (header != VC4_PACKET_GEM_HANDLES) + hw_offset += length; + p += length; + } + + clif_dump_destroy(clif); +} diff --git a/driver/common.h b/driver/common.h index 2b58b19..932696f 100644 --- a/driver/common.h +++ b/driver/common.h @@ -275,3 +275,5 @@ uint32_t getTopology(VkPrimitiveTopology topology); uint32_t getPrimitiveMode(VkPrimitiveTopology topology); uint32_t getFormatByteSize(VkFormat format); uint32_t ulog2(uint32_t v); +void clFit(VkCommandBuffer cb, ControlList* cl, uint32_t commandSize); +void clDump(void* cl, uint32_t size); diff --git a/driver/device.c b/driver/device.c index 89be256..b7540ef 100644 --- a/driver/device.c +++ b/driver/device.c @@ -310,5 +310,48 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyDevice( //TODO: allocator is ignored for now assert(pAllocator == 0); - //TODO + _device* dev = device; + for(int c = 0; c < numQueueFamilies; ++c) + { + for(int d = 0; d < dev->numQueues[c]; ++d) + { + free(dev->queues[d]); + } + } + + free(dev); +} + +/* + * https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkEnumeratePhysicalDeviceGroups + */ +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups( + VkInstance instance, + uint32_t* pPhysicalDeviceGroupCount, + VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties) +{ + assert(instance); + assert(pPhysicalDeviceGroupCount); + + if(!pPhysicalDeviceGroupProperties) + { + *pPhysicalDeviceGroupCount = 1; + return VK_SUCCESS; + } + + //TODO + uint32_t c = 0; + for(; c < *pPhysicalDeviceGroupCount; ++c) + { + pPhysicalDeviceGroupProperties[c].physicalDeviceCount = 1; + pPhysicalDeviceGroupProperties[c].physicalDevices = &instance->dev; + pPhysicalDeviceGroupProperties[c].subsetAllocation = 0; + } + + if(c < 1) + { + return VK_INCOMPLETE; + } + + return VK_SUCCESS; } diff --git a/driver/instance.c b/driver/instance.c index 413475f..a37f895 100644 --- a/driver/instance.c +++ b/driver/instance.c @@ -119,6 +119,18 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyInstance( //TODO: allocator is ignored for now assert(pAllocator == 0); - //TODO closeIoctl(); + + free(instance); +} + +/* + * https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkEnumerateInstanceVersion + */ +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion( + uint32_t* pApiVersion) +{ + assert(pApiVersion); + *pApiVersion = VK_MAKE_VERSION(1, 1, 0); + return VK_SUCCESS; }