1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2024-11-28 10:24:15 +01:00
This commit is contained in:
Unknown 2018-10-16 19:34:17 +01:00
parent ad818070b0
commit 6ac318e0d0
6 changed files with 157 additions and 59 deletions

View File

@ -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??
}

View File

@ -1,4 +0,0 @@
#pragma once
void clFit(VkCommandBuffer cb, ControlList* cl, uint32_t commandSize);
void clDump(void* cl, uint32_t size);

View File

@ -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);
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}