Skip to content

Commit

Permalink
trying to make the loader stuff work
Browse files Browse the repository at this point in the history
  • Loading branch information
Yours3lf committed Sep 29, 2019
1 parent 32cd6bc commit 16d5fc7
Show file tree
Hide file tree
Showing 43 changed files with 1,401 additions and 206 deletions.
6 changes: 3 additions & 3 deletions driver/CMakeLists.txt
Expand Up @@ -3,7 +3,7 @@ file(GLOB driverSrc
"*.c"
)

add_library(vulkan-1-rpi SHARED ${driverSrc})
target_compile_options(vulkan-1-rpi PRIVATE -Wall -Werror=implicit-function-declaration -std=c11)
add_library(rpi-vk-driver SHARED ${driverSrc})
target_compile_options(rpi-vk-driver PRIVATE -Wall -Werror=implicit-function-declaration -std=c11)

target_link_libraries(vulkan-1-rpi drm pthread brcm QPUassembler)
target_link_libraries(rpi-vk-driver drm pthread brcm QPUassembler)
26 changes: 14 additions & 12 deletions driver/command.c
Expand Up @@ -11,7 +11,7 @@
* not be used concurrently in multiple threads. That includes use via recording commands on any command buffers allocated from the pool,
* as well as operations that allocate, free, and reset command buffers or the pool itself.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateCommandPool(
VkDevice device,
const VkCommandPoolCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
Expand Down Expand Up @@ -83,7 +83,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(
* vkAllocateCommandBuffers can be used to create multiple command buffers. If the creation of any of those command buffers fails,
* the implementation must destroy all successfully created command buffer objects from this command, set all entries of the pCommandBuffers array to NULL and return the error.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkAllocateCommandBuffers(
VkDevice device,
const VkCommandBufferAllocateInfo* pAllocateInfo,
VkCommandBuffer* pCommandBuffers)
Expand All @@ -110,6 +110,8 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(
break;
}

set_loader_magic_value(&pCommandBuffers[c]->loaderData);

pCommandBuffers[c]->dev = device;

pCommandBuffers[c]->shaderRecCount = 0;
Expand Down Expand Up @@ -194,7 +196,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(
/*
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkBeginCommandBuffer
*/
VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkBeginCommandBuffer(
VkCommandBuffer commandBuffer,
const VkCommandBufferBeginInfo* pBeginInfo)
{
Expand Down Expand Up @@ -228,7 +230,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(
* If the application wishes to further use the command buffer, the command buffer must be reset. The command buffer must have been in the recording state,
* and is moved to the executable state.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkEndCommandBuffer(
VkCommandBuffer commandBuffer)
{
assert(commandBuffer);
Expand Down Expand Up @@ -256,7 +258,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(
* referenced by pSubmits is unaffected by the call or its failure. If vkQueueSubmit fails in such a way that the implementation is unable to make that guarantee,
* the implementation must return VK_ERROR_DEVICE_LOST. See Lost Device.
*/
VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
VkQueue queue,
uint32_t submitCount,
const VkSubmitInfo* pSubmits,
Expand Down Expand Up @@ -537,7 +539,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkFreeCommandBuffers
* Any primary command buffer that is in the recording or executable state and has any element of pCommandBuffers recorded into it, becomes invalid.
*/
VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(
VKAPI_ATTR void VKAPI_CALL rpi_vkFreeCommandBuffers(
VkDevice device,
VkCommandPool commandPool,
uint32_t commandBufferCount,
Expand Down Expand Up @@ -568,7 +570,7 @@ VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(
* Any primary command buffer allocated from another VkCommandPool that is in the recording or executable state and has a secondary command buffer
* allocated from commandPool recorded into it, becomes invalid.
*/
VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(
VKAPI_ATTR void VKAPI_CALL rpi_vkDestroyCommandPool(
VkDevice device,
VkCommandPool commandPool,
const VkAllocationCallbacks* pAllocator)
Expand All @@ -590,7 +592,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(
/*
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkTrimCommandPool
*/
VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool(
VKAPI_ATTR void VKAPI_CALL rpi_vkTrimCommandPool(
VkDevice device,
VkCommandPool commandPool,
VkCommandPoolTrimFlags flags)
Expand All @@ -608,7 +610,7 @@ VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool(
/*
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkResetCommandPool
*/
VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkResetCommandPool(
VkDevice device,
VkCommandPool commandPool,
VkCommandPoolResetFlags flags)
Expand Down Expand Up @@ -649,7 +651,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(
/*
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkResetCommandBuffer
*/
VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkResetCommandBuffer(
VkCommandBuffer commandBuffer,
VkCommandBufferResetFlags flags)
{
Expand Down Expand Up @@ -678,15 +680,15 @@ VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(
//TODO reset state?
}

VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdExecuteCommands(
VkCommandBuffer commandBuffer,
uint32_t commandBufferCount,
const VkCommandBuffer* pCommandBuffers)
{

}

VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdSetDeviceMask(
VkCommandBuffer commandBuffer,
uint32_t deviceMask)
{
Expand Down
8 changes: 4 additions & 4 deletions driver/common.c
Expand Up @@ -906,15 +906,15 @@ uint32_t getRenderTargetFormatVC4(VkFormat format)
////////////////////////////////////////////////////
////////////////////////////////////////////////////

VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties(
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceExternalBufferProperties(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
VkExternalBufferProperties* pExternalBufferProperties)
{
UNSUPPORTED(vkGetPhysicalDeviceExternalBufferProperties);
}

VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties(
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceExternalFenceProperties(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo,
VkExternalFenceProperties* pExternalFenceProperties)
Expand All @@ -923,15 +923,15 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties(
}


VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties(
VKAPI_ATTR void VKAPI_CALL rpi_vkGetPhysicalDeviceExternalSemaphoreProperties(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
VkExternalSemaphoreProperties* pExternalSemaphoreProperties)
{
UNSUPPORTED(vkGetPhysicalDeviceExternalSemaphoreProperties);
}

VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(
VKAPI_ATTR void VKAPI_CALL rpi_vkGetDeviceGroupPeerMemoryFeatures(
VkDevice device,
uint32_t heapIndex,
uint32_t localDeviceIndex,
Expand Down
7 changes: 7 additions & 0 deletions driver/common.h
Expand Up @@ -5,6 +5,7 @@
#include <drm/vc4_drm.h>

#include <vulkan/vulkan.h>
#include <vulkan/vk_icd.h>
#include "vkExt.h"

#include "AlignedAllocator.h"
Expand Down Expand Up @@ -53,6 +54,7 @@ typedef struct VkDevice_T _device;

typedef struct VkQueue_T
{
VK_LOADER_DATA loaderData;
uint64_t lastEmitSeqno;
_device* dev;
} _queue;
Expand All @@ -79,13 +81,15 @@ typedef struct VkInstance_T _instance;

typedef struct VkPhysicalDevice_T
{
VK_LOADER_DATA loaderData;
//hardware id?
char* path;
_instance* instance;
} _physicalDevice;

typedef struct VkInstance_T
{
VK_LOADER_DATA loaderData;
_physicalDevice dev;
//supposedly this should contain all the enabled layers?
int enabledExtensions[numInstanceExtensions];
Expand All @@ -100,6 +104,7 @@ typedef struct VkInstance_T

typedef struct VkDevice_T
{
VK_LOADER_DATA loaderData;
int enabledExtensions[numDeviceExtensions];
int numEnabledExtensions;
VkPhysicalDeviceFeatures enabledFeatures;
Expand Down Expand Up @@ -294,6 +299,8 @@ typedef struct VkPipeline_T

typedef struct VkCommandBuffer_T
{
VK_LOADER_DATA loaderData;

_device* dev; //device from which it was created

//Recorded commands include commands to bind pipelines and descriptor sets to the command buffer, commands to modify dynamic state, commands to draw (for graphics rendering),
Expand Down
8 changes: 4 additions & 4 deletions driver/compute.c
Expand Up @@ -3,7 +3,7 @@
//TODO
//compute shaders need kernel support

VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateComputePipelines(
VkDevice device,
VkPipelineCache pipelineCache,
uint32_t createInfoCount,
Expand All @@ -15,15 +15,15 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(
return VK_SUCCESS;
}

VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdDispatchIndirect(
VkCommandBuffer commandBuffer,
VkBuffer buffer,
VkDeviceSize offset)
{
UNSUPPORTED(vkCmdDispatchIndirect);
}

VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdDispatch(
VkCommandBuffer commandBuffer,
uint32_t groupCountX,
uint32_t groupCountY,
Expand All @@ -32,7 +32,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(
UNSUPPORTED(vkCmdDispatch);
}

VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBase(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdDispatchBase(
VkCommandBuffer commandBuffer,
uint32_t baseGroupX,
uint32_t baseGroupY,
Expand Down
12 changes: 6 additions & 6 deletions driver/copy.c
@@ -1,6 +1,6 @@
#include "common.h"

VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdCopyBufferToImage(
VkCommandBuffer commandBuffer,
VkBuffer srcBuffer,
VkImage dstImage,
Expand All @@ -11,7 +11,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(
//TODO
}

VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdBlitImage(
VkCommandBuffer commandBuffer,
VkImage srcImage,
VkImageLayout srcImageLayout,
Expand All @@ -24,7 +24,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(
//TODO
}

VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdResolveImage(
VkCommandBuffer commandBuffer,
VkImage srcImage,
VkImageLayout srcImageLayout,
Expand All @@ -36,7 +36,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(
//TODO
}

VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdCopyImageToBuffer(
VkCommandBuffer commandBuffer,
VkImage srcImage,
VkImageLayout srcImageLayout,
Expand All @@ -47,7 +47,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(
//TODO
}

VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdCopyImage(
VkCommandBuffer commandBuffer,
VkImage srcImage,
VkImageLayout srcImageLayout,
Expand All @@ -59,7 +59,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(
//TODO
}

VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer(
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdCopyBuffer(
VkCommandBuffer commandBuffer,
VkBuffer srcBuffer,
VkBuffer dstBuffer,
Expand Down

0 comments on commit 16d5fc7

Please sign in to comment.