mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2025-01-30 22:52:14 +01:00
format
This commit is contained in:
parent
a7918ba249
commit
601d21296e
@ -8,31 +8,31 @@ extern "C" {
|
||||
|
||||
void* alignedAlloc( unsigned bytes, unsigned alignment )
|
||||
{
|
||||
if( !bytes )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if( !bytes )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const unsigned maxBytes = 1024 * 1024 * 1024; //1GB is max on RPi
|
||||
const unsigned maxBytes = 1024 * 1024 * 1024; //1GB is max on RPi
|
||||
|
||||
if( bytes > maxBytes )
|
||||
{
|
||||
return 0; //bad alloc
|
||||
}
|
||||
if( bytes > maxBytes )
|
||||
{
|
||||
return 0; //bad alloc
|
||||
}
|
||||
|
||||
void* pv = 0;
|
||||
void* pv = 0;
|
||||
|
||||
if( posix_memalign( &pv, alignment, bytes ) )
|
||||
{
|
||||
pv = 0; //allocation failed
|
||||
}
|
||||
if( posix_memalign( &pv, alignment, bytes ) )
|
||||
{
|
||||
pv = 0; //allocation failed
|
||||
}
|
||||
|
||||
return pv;
|
||||
return pv;
|
||||
}
|
||||
|
||||
void alignedFree( void* p )
|
||||
{
|
||||
free( p );
|
||||
free( p );
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
@ -14,17 +14,17 @@ __inline__ static void DEBUG_BREAK(void)
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BUILD
|
||||
#define assert(expr) \
|
||||
if( expr ){} \
|
||||
else \
|
||||
{ \
|
||||
printf("Assert failed: %s\n" \
|
||||
"File: %s\n" \
|
||||
"Line: %i\n", #expr, __FILE__, __LINE__); \
|
||||
DEBUG_BREAK(); \
|
||||
}
|
||||
#define assert(expr) \
|
||||
if( expr ){} \
|
||||
else \
|
||||
{ \
|
||||
printf("Assert failed: %s\n" \
|
||||
"File: %s\n" \
|
||||
"Line: %i\n", #expr, __FILE__, __LINE__); \
|
||||
DEBUG_BREAK(); \
|
||||
}
|
||||
#else
|
||||
#define assert(expr) //do nothing
|
||||
#define assert(expr) //do nothing
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
226
driver/driver.c
226
driver/driver.c
@ -364,9 +364,9 @@ int findDeviceExtension(char* name)
|
||||
* e.g. if the layer implementation is replaced by a different version between those calls.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(
|
||||
const char* pLayerName,
|
||||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties)
|
||||
const char* pLayerName,
|
||||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties)
|
||||
{
|
||||
assert(!pLayerName); //TODO layers ignored for now
|
||||
assert(pPropertyCount);
|
||||
@ -399,9 +399,9 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(
|
||||
* created and returned to the application.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
|
||||
const VkInstanceCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkInstance* pInstance)
|
||||
const VkInstanceCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkInstance* pInstance)
|
||||
{
|
||||
assert(pInstance);
|
||||
assert(pCreateInfo);
|
||||
@ -466,9 +466,9 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
|
||||
* available physical devices were returned.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(
|
||||
VkInstance instance,
|
||||
uint32_t* pPhysicalDeviceCount,
|
||||
VkPhysicalDevice* pPhysicalDevices)
|
||||
VkInstance instance,
|
||||
uint32_t* pPhysicalDeviceCount,
|
||||
VkPhysicalDevice* pPhysicalDevices)
|
||||
{
|
||||
assert(instance);
|
||||
|
||||
@ -509,8 +509,8 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkGetPhysicalDeviceProperties
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceProperties* pProperties)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceProperties* pProperties)
|
||||
{
|
||||
assert(physicalDevice);
|
||||
assert(pProperties);
|
||||
@ -539,8 +539,8 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkGetPhysicalDeviceFeatures
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceFeatures* pFeatures)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceFeatures* pFeatures)
|
||||
{
|
||||
assert(physicalDevice);
|
||||
assert(pFeatures);
|
||||
@ -552,10 +552,10 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkEnumerateDeviceExtensionProperties
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const char* pLayerName,
|
||||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const char* pLayerName,
|
||||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties)
|
||||
{
|
||||
assert(physicalDevice);
|
||||
assert(!pLayerName); //layers ignored for now
|
||||
@ -588,9 +588,9 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(
|
||||
* is less than the number of queue families available, at most pQueueFamilyPropertyCount structures will be written.
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t* pQueueFamilyPropertyCount,
|
||||
VkQueueFamilyProperties* pQueueFamilyProperties)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t* pQueueFamilyPropertyCount,
|
||||
VkQueueFamilyProperties* pQueueFamilyProperties)
|
||||
{
|
||||
assert(physicalDevice);
|
||||
assert(pQueueFamilyPropertyCount);
|
||||
@ -617,10 +617,10 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(
|
||||
* does this queue family support presentation to this surface?
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
VkSurfaceKHR surface,
|
||||
VkBool32* pSupported)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
VkSurfaceKHR surface,
|
||||
VkBool32* pSupported)
|
||||
{
|
||||
assert(pSupported);
|
||||
assert(surface);
|
||||
@ -636,10 +636,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(
|
||||
* Implementation of our RPI specific "extension"
|
||||
*/
|
||||
VkResult vkCreateRpiSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkRpiSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface)
|
||||
VkInstance instance,
|
||||
const VkRpiSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface)
|
||||
{
|
||||
assert(instance);
|
||||
//assert(pCreateInfo); //ignored for now
|
||||
@ -659,9 +659,9 @@ VkResult vkCreateRpiSurfaceKHR(
|
||||
* (but we'll do so anyways...)
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR surface,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR surface,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
assert(instance);
|
||||
assert(surface);
|
||||
@ -684,10 +684,10 @@ VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(
|
||||
* fail due to lack of device-specific resources (in addition to the other errors). If that occurs, vkCreateDevice will return VK_ERROR_TOO_MANY_OBJECTS.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkDeviceCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkDevice* pDevice)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
const VkDeviceCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkDevice* pDevice)
|
||||
{
|
||||
assert(physicalDevice);
|
||||
assert(pDevice);
|
||||
@ -764,10 +764,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
|
||||
* To get queues that were created with a non-zero flags parameter use vkGetDeviceQueue2.
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(
|
||||
VkDevice device,
|
||||
uint32_t queueFamilyIndex,
|
||||
uint32_t queueIndex,
|
||||
VkQueue* pQueue)
|
||||
VkDevice device,
|
||||
uint32_t queueFamilyIndex,
|
||||
uint32_t queueIndex,
|
||||
VkQueue* pQueue)
|
||||
{
|
||||
assert(device);
|
||||
assert(pQueue);
|
||||
@ -792,10 +792,10 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(
|
||||
* When created, the semaphore is in the unsignaled state.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(
|
||||
VkDevice device,
|
||||
const VkSemaphoreCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSemaphore* pSemaphore)
|
||||
VkDevice device,
|
||||
const VkSemaphoreCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSemaphore* pSemaphore)
|
||||
{
|
||||
assert(device);
|
||||
assert(pSemaphore);
|
||||
@ -820,9 +820,9 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(
|
||||
* capabilities the specified device supports for a swapchain created for the surface
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkSurfaceKHR surface,
|
||||
VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkSurfaceKHR surface,
|
||||
VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
|
||||
{
|
||||
assert(physicalDevice);
|
||||
assert(surface);
|
||||
@ -855,10 +855,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
|
||||
* VK_INCOMPLETE will be returned instead of VK_SUCCESS to indicate that not all the available values were returned.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkSurfaceKHR surface,
|
||||
uint32_t* pSurfaceFormatCount,
|
||||
VkSurfaceFormatKHR* pSurfaceFormats)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkSurfaceKHR surface,
|
||||
uint32_t* pSurfaceFormatCount,
|
||||
VkSurfaceFormatKHR* pSurfaceFormats)
|
||||
{
|
||||
assert(physicalDevice);
|
||||
assert(surface);
|
||||
@ -902,10 +902,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(
|
||||
* VK_SUCCESS to indicate that not all the available values were returned.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkSurfaceKHR surface,
|
||||
uint32_t* pPresentModeCount,
|
||||
VkPresentModeKHR* pPresentModes)
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkSurfaceKHR surface,
|
||||
uint32_t* pPresentModeCount,
|
||||
VkPresentModeKHR* pPresentModes)
|
||||
{
|
||||
assert(physicalDevice);
|
||||
assert(surface);
|
||||
@ -942,10 +942,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCreateSwapchainKHR
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
|
||||
VkDevice device,
|
||||
const VkSwapchainCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSwapchainKHR* pSwapchain)
|
||||
VkDevice device,
|
||||
const VkSwapchainCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSwapchainKHR* pSwapchain)
|
||||
{
|
||||
assert(device);
|
||||
assert(pCreateInfo);
|
||||
@ -969,10 +969,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
|
||||
* indicate that not all the available values were returned.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain,
|
||||
uint32_t* pSwapchainImageCount,
|
||||
VkImage* pSwapchainImages)
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain,
|
||||
uint32_t* pSwapchainImageCount,
|
||||
VkImage* pSwapchainImages)
|
||||
{
|
||||
assert(device);
|
||||
assert(swapchain);
|
||||
@ -1013,10 +1013,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
|
||||
* as well as operations that allocate, free, and reset command buffers or the pool itself.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(
|
||||
VkDevice device,
|
||||
const VkCommandPoolCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkCommandPool* pCommandPool)
|
||||
VkDevice device,
|
||||
const VkCommandPoolCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkCommandPool* pCommandPool)
|
||||
{
|
||||
assert(device);
|
||||
assert(pCreateInfo);
|
||||
@ -1063,9 +1063,9 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(
|
||||
* 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(
|
||||
VkDevice device,
|
||||
const VkCommandBufferAllocateInfo* pAllocateInfo,
|
||||
VkCommandBuffer* pCommandBuffers)
|
||||
VkDevice device,
|
||||
const VkCommandBufferAllocateInfo* pAllocateInfo,
|
||||
VkCommandBuffer* pCommandBuffers)
|
||||
{
|
||||
assert(device);
|
||||
assert(pAllocateInfo);
|
||||
@ -1135,8 +1135,8 @@ 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(
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkCommandBufferBeginInfo* pBeginInfo)
|
||||
VkCommandBuffer commandBuffer,
|
||||
const VkCommandBufferBeginInfo* pBeginInfo)
|
||||
{
|
||||
assert(commandBuffer);
|
||||
assert(pBeginInfo);
|
||||
@ -1183,16 +1183,16 @@ VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(
|
||||
* If dependencyFlags includes VK_DEPENDENCY_BY_REGION_BIT, then any dependency between framebuffer-space pipeline stages is framebuffer-local - otherwise it is framebuffer-global.
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(
|
||||
VkCommandBuffer commandBuffer,
|
||||
VkPipelineStageFlags srcStageMask,
|
||||
VkPipelineStageFlags dstStageMask,
|
||||
VkDependencyFlags dependencyFlags,
|
||||
uint32_t memoryBarrierCount,
|
||||
const VkMemoryBarrier* pMemoryBarriers,
|
||||
uint32_t bufferMemoryBarrierCount,
|
||||
const VkBufferMemoryBarrier* pBufferMemoryBarriers,
|
||||
uint32_t imageMemoryBarrierCount,
|
||||
const VkImageMemoryBarrier* pImageMemoryBarriers)
|
||||
VkCommandBuffer commandBuffer,
|
||||
VkPipelineStageFlags srcStageMask,
|
||||
VkPipelineStageFlags dstStageMask,
|
||||
VkDependencyFlags dependencyFlags,
|
||||
uint32_t memoryBarrierCount,
|
||||
const VkMemoryBarrier* pMemoryBarriers,
|
||||
uint32_t bufferMemoryBarrierCount,
|
||||
const VkBufferMemoryBarrier* pBufferMemoryBarriers,
|
||||
uint32_t imageMemoryBarrierCount,
|
||||
const VkImageMemoryBarrier* pImageMemoryBarriers)
|
||||
{
|
||||
assert(commandBuffer);
|
||||
|
||||
@ -1205,12 +1205,12 @@ VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(
|
||||
* These commands are only allowed outside of a render pass instance.
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
|
||||
VkCommandBuffer commandBuffer,
|
||||
VkImage image,
|
||||
VkImageLayout imageLayout,
|
||||
const VkClearColorValue* pColor,
|
||||
uint32_t rangeCount,
|
||||
const VkImageSubresourceRange* pRanges)
|
||||
VkCommandBuffer commandBuffer,
|
||||
VkImage image,
|
||||
VkImageLayout imageLayout,
|
||||
const VkClearColorValue* pColor,
|
||||
uint32_t rangeCount,
|
||||
const VkImageSubresourceRange* pRanges)
|
||||
{
|
||||
assert(commandBuffer);
|
||||
|
||||
@ -1224,7 +1224,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
|
||||
* and is moved to the executable state.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(
|
||||
VkCommandBuffer commandBuffer)
|
||||
VkCommandBuffer commandBuffer)
|
||||
{
|
||||
assert(commandBuffer);
|
||||
|
||||
@ -1237,12 +1237,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkAcquireNextImageKHR
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain,
|
||||
uint64_t timeout,
|
||||
VkSemaphore semaphore,
|
||||
VkFence fence,
|
||||
uint32_t* pImageIndex)
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain,
|
||||
uint64_t timeout,
|
||||
VkSemaphore semaphore,
|
||||
VkFence fence,
|
||||
uint32_t* pImageIndex)
|
||||
{
|
||||
assert(device);
|
||||
assert(swapchain);
|
||||
@ -1271,10 +1271,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
|
||||
* the implementation must return VK_ERROR_DEVICE_LOST. See Lost Device.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(
|
||||
VkQueue queue,
|
||||
uint32_t submitCount,
|
||||
const VkSubmitInfo* pSubmits,
|
||||
VkFence fence)
|
||||
VkQueue queue,
|
||||
uint32_t submitCount,
|
||||
const VkSubmitInfo* pSubmits,
|
||||
VkFence fence)
|
||||
{
|
||||
assert(queue);
|
||||
|
||||
@ -1300,8 +1300,8 @@ VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(
|
||||
* the set of queue operations are still considered to be enqueued and thus any semaphore to be waited on gets unsignaled when the corresponding queue operation is complete.
|
||||
*/
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(
|
||||
VkQueue queue,
|
||||
const VkPresentInfoKHR* pPresentInfo)
|
||||
VkQueue queue,
|
||||
const VkPresentInfoKHR* pPresentInfo)
|
||||
{
|
||||
assert(queue);
|
||||
assert(pPresentInfo);
|
||||
@ -1366,9 +1366,9 @@ VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(
|
||||
* allocated from commandPool recorded into it, becomes invalid.
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(
|
||||
VkDevice device,
|
||||
VkCommandPool commandPool,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
VkDevice device,
|
||||
VkCommandPool commandPool,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
assert(device);
|
||||
assert(commandPool);
|
||||
@ -1396,9 +1396,9 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkDestroySemaphore
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(
|
||||
VkDevice device,
|
||||
VkSemaphore semaphore,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
VkDevice device,
|
||||
VkSemaphore semaphore,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
assert(device);
|
||||
assert(semaphore);
|
||||
@ -1413,9 +1413,9 @@ VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(
|
||||
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkDestroySwapchainKHR
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
VkDevice device,
|
||||
VkSwapchainKHR swapchain,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
assert(device);
|
||||
assert(swapchain);
|
||||
@ -1433,8 +1433,8 @@ VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(
|
||||
* first parameter of the corresponding vkCreate* or vkAllocate* command
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(
|
||||
VkDevice device,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
VkDevice device,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
assert(device);
|
||||
|
||||
@ -1449,8 +1449,8 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(
|
||||
*
|
||||
*/
|
||||
VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(
|
||||
VkInstance instance,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
VkInstance instance,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
assert(instance);
|
||||
|
||||
|
@ -42,59 +42,59 @@ static uint32_t align(uint32_t num, uint32_t alignment)
|
||||
|
||||
int vc4_get_chip_info(int fd)
|
||||
{
|
||||
struct drm_vc4_get_param ident0 = {
|
||||
.param = DRM_VC4_PARAM_V3D_IDENT0,
|
||||
};
|
||||
struct drm_vc4_get_param ident1 = {
|
||||
.param = DRM_VC4_PARAM_V3D_IDENT1,
|
||||
};
|
||||
int ret;
|
||||
struct drm_vc4_get_param ident0 = {
|
||||
.param = DRM_VC4_PARAM_V3D_IDENT0,
|
||||
};
|
||||
struct drm_vc4_get_param ident1 = {
|
||||
.param = DRM_VC4_PARAM_V3D_IDENT1,
|
||||
};
|
||||
int ret;
|
||||
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_PARAM, &ident0);
|
||||
if (ret != 0) {
|
||||
if (errno == EINVAL) {
|
||||
/* Backwards compatibility with 2835 kernels which
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_PARAM, &ident0);
|
||||
if (ret != 0) {
|
||||
if (errno == EINVAL) {
|
||||
/* Backwards compatibility with 2835 kernels which
|
||||
* only do V3D 2.1.
|
||||
*/
|
||||
return 21;
|
||||
} else {
|
||||
printf("Couldn't get V3D IDENT0: %s\n",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_PARAM, &ident1);
|
||||
if (ret != 0) {
|
||||
printf("Couldn't get V3D IDENT1: %s\n",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
return 21;
|
||||
} else {
|
||||
printf("Couldn't get V3D IDENT0: %s\n",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_PARAM, &ident1);
|
||||
if (ret != 0) {
|
||||
printf("Couldn't get V3D IDENT1: %s\n",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t major = (ident0.value >> 24) & 0xff;
|
||||
uint32_t minor = (ident1.value >> 0) & 0xf;
|
||||
uint32_t v3d_ver = major * 10 + minor;
|
||||
uint32_t major = (ident0.value >> 24) & 0xff;
|
||||
uint32_t minor = (ident1.value >> 0) & 0xf;
|
||||
uint32_t v3d_ver = major * 10 + minor;
|
||||
|
||||
if (v3d_ver != 21 && v3d_ver != 26) {
|
||||
printf("V3D %d.%d not supported.\n",
|
||||
v3d_ver / 10,
|
||||
v3d_ver % 10);
|
||||
return 0;
|
||||
}
|
||||
if (v3d_ver != 21 && v3d_ver != 26) {
|
||||
printf("V3D %d.%d not supported.\n",
|
||||
v3d_ver / 10,
|
||||
v3d_ver % 10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return v3d_ver;
|
||||
return v3d_ver;
|
||||
}
|
||||
|
||||
int vc4_has_feature(int fd, uint32_t feature)
|
||||
{
|
||||
struct drm_vc4_get_param p = {
|
||||
.param = feature,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_PARAM, &p);
|
||||
struct drm_vc4_get_param p = {
|
||||
.param = feature,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_PARAM, &p);
|
||||
|
||||
if (ret != 0)
|
||||
return 0;
|
||||
if (ret != 0)
|
||||
return 0;
|
||||
|
||||
return p.value;
|
||||
return p.value;
|
||||
}
|
||||
|
||||
int vc4_test_tiling(int fd)
|
||||
@ -104,7 +104,7 @@ int vc4_test_tiling(int fd)
|
||||
* 0 cannot be a valid GEM object, so use that.
|
||||
*/
|
||||
struct drm_vc4_get_tiling get_tiling = {
|
||||
.handle = 0x0,
|
||||
.handle = 0x0,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_TILING, &get_tiling);
|
||||
if (ret == -1 && errno == ENOENT)
|
||||
@ -118,29 +118,29 @@ int vc4_test_tiling(int fd)
|
||||
uint64_t vc4_bo_get_tiling(int fd, uint32_t bo, uint64_t mod)
|
||||
{
|
||||
struct drm_vc4_get_tiling get_tiling = {
|
||||
.handle = bo,
|
||||
.handle = bo,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_TILING, &get_tiling);
|
||||
|
||||
if (ret != 0) {
|
||||
return DRM_FORMAT_MOD_LINEAR;
|
||||
return DRM_FORMAT_MOD_LINEAR;
|
||||
} else if (mod == DRM_FORMAT_MOD_INVALID) {
|
||||
return get_tiling.modifier;
|
||||
return get_tiling.modifier;
|
||||
} else if (mod != get_tiling.modifier) {
|
||||
printf("Modifier 0x%llx vs. tiling (0x%llx) mismatch\n",
|
||||
(long long)mod, get_tiling.modifier);
|
||||
return 0;
|
||||
printf("Modifier 0x%llx vs. tiling (0x%llx) mismatch\n",
|
||||
(long long)mod, get_tiling.modifier);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int vc4_bo_set_tiling(int fd, uint32_t bo, uint64_t mod)
|
||||
{
|
||||
struct drm_vc4_set_tiling set_tiling = {
|
||||
.handle = bo,
|
||||
.modifier = mod,
|
||||
.handle = bo,
|
||||
.modifier = mod,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_SET_TILING,
|
||||
&set_tiling);
|
||||
&set_tiling);
|
||||
if (ret != 0)
|
||||
{
|
||||
return 0;
|
||||
@ -151,170 +151,170 @@ int vc4_bo_set_tiling(int fd, uint32_t bo, uint64_t mod)
|
||||
|
||||
void* vc4_bo_map_unsynchronized(int fd, uint32_t bo, uint32_t size)
|
||||
{
|
||||
uint64_t offset;
|
||||
int ret;
|
||||
uint64_t offset;
|
||||
int ret;
|
||||
|
||||
//if (bo->map)
|
||||
// return bo->map;
|
||||
//if (bo->map)
|
||||
// return bo->map;
|
||||
|
||||
struct drm_vc4_mmap_bo map;
|
||||
memset(&map, 0, sizeof(map));
|
||||
map.handle = bo;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_MMAP_BO, &map);
|
||||
offset = map.offset;
|
||||
if (ret != 0) {
|
||||
printf("map ioctl failure\n");
|
||||
return 0;
|
||||
}
|
||||
struct drm_vc4_mmap_bo map;
|
||||
memset(&map, 0, sizeof(map));
|
||||
map.handle = bo;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_MMAP_BO, &map);
|
||||
offset = map.offset;
|
||||
if (ret != 0) {
|
||||
printf("map ioctl failure\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* mapPtr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
fd, offset);
|
||||
if (mapPtr == MAP_FAILED) {
|
||||
printf("mmap of bo %d (offset 0x%016llx, size %d) failed\n",
|
||||
bo, (long long)offset, size);
|
||||
return 0;
|
||||
}
|
||||
//VG(VALGRIND_MALLOCLIKE_BLOCK(bo->map, bo->size, 0, false));
|
||||
void* mapPtr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
fd, offset);
|
||||
if (mapPtr == MAP_FAILED) {
|
||||
printf("mmap of bo %d (offset 0x%016llx, size %d) failed\n",
|
||||
bo, (long long)offset, size);
|
||||
return 0;
|
||||
}
|
||||
//VG(VALGRIND_MALLOCLIKE_BLOCK(bo->map, bo->size, 0, false));
|
||||
|
||||
return mapPtr;
|
||||
return mapPtr;
|
||||
}
|
||||
|
||||
static int vc4_bo_wait_ioctl(int fd, uint32_t handle, uint64_t timeout_ns)
|
||||
{
|
||||
struct drm_vc4_wait_bo wait = {
|
||||
.handle = handle,
|
||||
struct drm_vc4_wait_bo wait = {
|
||||
.handle = handle,
|
||||
.timeout_ns = timeout_ns,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_WAIT_BO, &wait);
|
||||
if (ret == -1)
|
||||
{
|
||||
printf("bo wait fail: %s", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_WAIT_BO, &wait);
|
||||
if (ret == -1)
|
||||
{
|
||||
printf("bo wait fail: %s", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int vc4_bo_wait(int fd, uint32_t bo, uint64_t timeout_ns)
|
||||
{
|
||||
int ret = vc4_bo_wait_ioctl(fd, bo, timeout_ns);
|
||||
if (ret) {
|
||||
if (ret != -ETIME) {
|
||||
fprintf(stderr, "wait failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
int ret = vc4_bo_wait_ioctl(fd, bo, timeout_ns);
|
||||
if (ret) {
|
||||
if (ret != -ETIME) {
|
||||
fprintf(stderr, "wait failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int vc4_seqno_wait_ioctl(int fd, uint64_t seqno, uint64_t timeout_ns)
|
||||
{
|
||||
struct drm_vc4_wait_seqno wait = {
|
||||
.seqno = seqno,
|
||||
struct drm_vc4_wait_seqno wait = {
|
||||
.seqno = seqno,
|
||||
.timeout_ns = timeout_ns,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_WAIT_SEQNO, &wait);
|
||||
if (ret == -1)
|
||||
{
|
||||
printf("bo wait fail: %s", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_WAIT_SEQNO, &wait);
|
||||
if (ret == -1)
|
||||
{
|
||||
printf("bo wait fail: %s", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int vc4_seqno_wait(int fd, uint64_t* lastFinishedSeqno, uint64_t seqno, uint64_t timeout_ns)
|
||||
{
|
||||
if (*lastFinishedSeqno >= seqno)
|
||||
return 1;
|
||||
if (*lastFinishedSeqno >= seqno)
|
||||
return 1;
|
||||
|
||||
int ret = vc4_seqno_wait_ioctl(fd, seqno, timeout_ns);
|
||||
if (ret) {
|
||||
if (ret != -ETIME) {
|
||||
printf("wait failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
int ret = vc4_seqno_wait_ioctl(fd, seqno, timeout_ns);
|
||||
if (ret) {
|
||||
if (ret != -ETIME) {
|
||||
printf("wait failed: %d\n", ret);
|
||||
}
|
||||
|
||||
*lastFinishedSeqno = seqno;
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*lastFinishedSeqno = seqno;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vc4_bo_flink(int fd, uint32_t bo, uint32_t *name)
|
||||
{
|
||||
struct drm_gem_flink flink = {
|
||||
.handle = bo,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
|
||||
if (ret) {
|
||||
printf("Failed to flink bo %d: %s\n",
|
||||
bo, strerror(errno));
|
||||
//free(bo);
|
||||
return 0;
|
||||
}
|
||||
struct drm_gem_flink flink = {
|
||||
.handle = bo,
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
|
||||
if (ret) {
|
||||
printf("Failed to flink bo %d: %s\n",
|
||||
bo, strerror(errno));
|
||||
//free(bo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//bo->private = false;
|
||||
*name = flink.name;
|
||||
//bo->private = false;
|
||||
*name = flink.name;
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t vc4_bo_alloc_shader(int fd, const void *data, uint32_t* size)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
uint32_t alignedSize = align(*size, ARM_PAGE_SIZE);
|
||||
uint32_t alignedSize = align(*size, ARM_PAGE_SIZE);
|
||||
|
||||
struct drm_vc4_create_shader_bo create = {
|
||||
.size = *alignedSize,
|
||||
struct drm_vc4_create_shader_bo create = {
|
||||
.size = *alignedSize,
|
||||
.data = (uintptr_t)data,
|
||||
};
|
||||
};
|
||||
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_CREATE_SHADER_BO,
|
||||
&create);
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_CREATE_SHADER_BO,
|
||||
&create);
|
||||
|
||||
if (ret != 0) {
|
||||
printf("create shader ioctl failure\n");
|
||||
return 0;
|
||||
}
|
||||
if (ret != 0) {
|
||||
printf("create shader ioctl failure\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*size = alignedSize;
|
||||
*size = alignedSize;
|
||||
|
||||
return create.handle;
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
uint32_t vc4_bo_open_name(int fd, uint32_t name)
|
||||
//uint32_t winsys_stride)
|
||||
//uint32_t winsys_stride)
|
||||
{
|
||||
struct drm_gem_open o = {
|
||||
.name = name
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_GEM_OPEN, &o);
|
||||
if (ret) {
|
||||
printf("Failed to open bo %d: %s\n",
|
||||
name, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
struct drm_gem_open o = {
|
||||
.name = name
|
||||
};
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_GEM_OPEN, &o);
|
||||
if (ret) {
|
||||
printf("Failed to open bo %d: %s\n",
|
||||
name, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return o.handle;
|
||||
return o.handle;
|
||||
}
|
||||
|
||||
uint32_t vc4_bo_alloc(int fd, uint32_t size, const char *name)
|
||||
{
|
||||
int cleared_and_retried = 0;
|
||||
struct drm_vc4_create_bo create;
|
||||
int ret;
|
||||
int cleared_and_retried = 0;
|
||||
struct drm_vc4_create_bo create;
|
||||
int ret;
|
||||
|
||||
uint32_t alignedSize = align(size, ARM_PAGE_SIZE);
|
||||
uint32_t alignedSize = align(size, ARM_PAGE_SIZE);
|
||||
|
||||
/*bo = vc4_bo_from_cache(screen, size, name);
|
||||
/*bo = vc4_bo_from_cache(screen, size, name);
|
||||
if (bo) {
|
||||
if (dump_stats) {
|
||||
fprintf(stderr, "Allocated %s %dkb from cache:\n",
|
||||
@ -324,14 +324,14 @@ uint32_t vc4_bo_alloc(int fd, uint32_t size, const char *name)
|
||||
return bo;
|
||||
}*/
|
||||
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.size = alignedSize;
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.size = alignedSize;
|
||||
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create);
|
||||
uint32_t handle = create.handle;
|
||||
ret = drmIoctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create);
|
||||
uint32_t handle = create.handle;
|
||||
|
||||
if (ret != 0) {
|
||||
/*if (!list_empty(&screen->bo_cache.time_list) &&
|
||||
if (ret != 0) {
|
||||
/*if (!list_empty(&screen->bo_cache.time_list) &&
|
||||
!cleared_and_retried) {
|
||||
cleared_and_retried = true;
|
||||
vc4_bo_cache_free_all(&screen->bo_cache);
|
||||
@ -339,37 +339,37 @@ uint32_t vc4_bo_alloc(int fd, uint32_t size, const char *name)
|
||||
}
|
||||
|
||||
free(bo);*/
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
vc4_bo_label(screen, bo, "%s", name);
|
||||
vc4_bo_label(screen, bo, "%s", name);
|
||||
|
||||
return handle;
|
||||
return handle;
|
||||
}
|
||||
|
||||
void vc4_bo_free(int fd, uint32_t bo, void* mappedAddr, uint32_t size)
|
||||
{
|
||||
if (mappedAddr) {
|
||||
munmap(mappedAddr, size);
|
||||
//VG(VALGRIND_FREELIKE_BLOCK(bo->map, 0));
|
||||
}
|
||||
if (mappedAddr) {
|
||||
munmap(mappedAddr, size);
|
||||
//VG(VALGRIND_FREELIKE_BLOCK(bo->map, 0));
|
||||
}
|
||||
|
||||
struct drm_gem_close c;
|
||||
memset(&c, 0, sizeof(c));
|
||||
c.handle = bo;
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &c);
|
||||
if (ret != 0)
|
||||
{
|
||||
printf("close object %d: %s\n", bo, strerror(errno));
|
||||
}
|
||||
struct drm_gem_close c;
|
||||
memset(&c, 0, sizeof(c));
|
||||
c.handle = bo;
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &c);
|
||||
if (ret != 0)
|
||||
{
|
||||
printf("close object %d: %s\n", bo, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
int vc4_bo_unpurgeable(int fd, uint32_t bo, int hasMadvise)
|
||||
{
|
||||
struct drm_vc4_gem_madvise arg = {
|
||||
.handle = bo,
|
||||
struct drm_vc4_gem_madvise arg = {
|
||||
.handle = bo,
|
||||
.madv = VC4_MADV_WILLNEED,
|
||||
};
|
||||
};
|
||||
|
||||
if (!hasMadvise)
|
||||
return 1;
|
||||
@ -382,10 +382,10 @@ int vc4_bo_unpurgeable(int fd, uint32_t bo, int hasMadvise)
|
||||
|
||||
void vc4_bo_purgeable(int fd, uint32_t bo, int hasMadvise)
|
||||
{
|
||||
struct drm_vc4_gem_madvise arg = {
|
||||
.handle = bo,
|
||||
struct drm_vc4_gem_madvise arg = {
|
||||
.handle = bo,
|
||||
.madv = VC4_MADV_DONTNEED,
|
||||
};
|
||||
};
|
||||
|
||||
if (hasMadvise)
|
||||
{
|
||||
@ -398,61 +398,61 @@ void vc4_bo_label(int fd, uint32_t bo, const char* name)
|
||||
//TODO don't use in release!
|
||||
|
||||
struct drm_vc4_label_bo label = {
|
||||
.handle = bo,
|
||||
.len = strlen(name),
|
||||
.name = (uintptr_t)name,
|
||||
.handle = bo,
|
||||
.len = strlen(name),
|
||||
.name = (uintptr_t)name,
|
||||
};
|
||||
drmIoctl(fd, DRM_IOCTL_VC4_LABEL_BO, &label);
|
||||
}
|
||||
|
||||
int vc4_bo_get_dmabuf(int fd, uint32_t bo)
|
||||
{
|
||||
int boFd;
|
||||
int ret = drmPrimeHandleToFD(fd, bo,
|
||||
O_CLOEXEC, &boFd);
|
||||
if (ret != 0) {
|
||||
printf("Failed to export gem bo %d to dmabuf\n",
|
||||
bo);
|
||||
return 0;
|
||||
}
|
||||
int boFd;
|
||||
int ret = drmPrimeHandleToFD(fd, bo,
|
||||
O_CLOEXEC, &boFd);
|
||||
if (ret != 0) {
|
||||
printf("Failed to export gem bo %d to dmabuf\n",
|
||||
bo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return boFd;
|
||||
return boFd;
|
||||
}
|
||||
|
||||
void* vc4_bo_map(int fd, uint32_t bo, uint32_t size)
|
||||
{
|
||||
void* map = vc4_bo_map_unsynchronized(fd, bo, size);
|
||||
void* map = vc4_bo_map_unsynchronized(fd, bo, size);
|
||||
|
||||
//wait infinitely
|
||||
int ok = vc4_bo_wait(fd, bo, WAIT_TIMEOUT_INFINITE);
|
||||
if (!ok) {
|
||||
printf("BO wait for map failed\n");
|
||||
return 0;
|
||||
}
|
||||
//wait infinitely
|
||||
int ok = vc4_bo_wait(fd, bo, WAIT_TIMEOUT_INFINITE);
|
||||
if (!ok) {
|
||||
printf("BO wait for map failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return map;
|
||||
return map;
|
||||
}
|
||||
|
||||
void vc4_cl_submit(int fd, struct drm_vc4_submit_cl submit, uint64_t* lastEmittedSeqno, uint64_t* lastFinishedSeqno)
|
||||
{
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_SUBMIT_CL, &submit);
|
||||
int ret = drmIoctl(fd, DRM_IOCTL_VC4_SUBMIT_CL, &submit);
|
||||
|
||||
static int warned = 0;
|
||||
if (ret && !warned) {
|
||||
printf("Draw call returned %s. "
|
||||
"Expect corruption.\n", strerror(errno));
|
||||
warned = 1;
|
||||
} else if (!ret) {
|
||||
*lastEmittedSeqno = submit.seqno;
|
||||
}
|
||||
static int warned = 0;
|
||||
if (ret && !warned) {
|
||||
printf("Draw call returned %s. "
|
||||
"Expect corruption.\n", strerror(errno));
|
||||
warned = 1;
|
||||
} else if (!ret) {
|
||||
*lastEmittedSeqno = submit.seqno;
|
||||
}
|
||||
|
||||
if (*lastEmittedSeqno - *lastFinishedSeqno > 5) {
|
||||
uint64_t seqno = *lastFinishedSeqno - 5;
|
||||
if (!vc4_seqno_wait(fd,
|
||||
&seqno,
|
||||
WAIT_TIMEOUT_INFINITE))
|
||||
{
|
||||
printf("Job throttling failed\n");
|
||||
}
|
||||
if (*lastEmittedSeqno - *lastFinishedSeqno > 5) {
|
||||
uint64_t seqno = *lastFinishedSeqno - 5;
|
||||
if (!vc4_seqno_wait(fd,
|
||||
&seqno,
|
||||
WAIT_TIMEOUT_INFINITE))
|
||||
{
|
||||
printf("Job throttling failed\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,11 +50,11 @@
|
||||
//static struct modeset_dev *modeset_list = NULL;
|
||||
|
||||
static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
struct modeset_dev *dev);
|
||||
struct modeset_dev *dev);
|
||||
static int modeset_create_fb(int fd, struct modeset_buf *buf);
|
||||
static void modeset_destroy_fb(int fd, struct modeset_buf *buf);
|
||||
static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
struct modeset_dev *dev);
|
||||
struct modeset_dev *dev);
|
||||
|
||||
|
||||
/*
|
||||
@ -144,10 +144,10 @@ modeset_dev* modeset_create(int fd)
|
||||
iter->saved_crtc = drmModeGetCrtc(fd, iter->crtc);
|
||||
buf = &iter->bufs[iter->front_buf];
|
||||
ret = drmModeSetCrtc(fd, iter->crtc, buf->fb, 0, 0,
|
||||
&iter->conn, 1, &iter->mode);
|
||||
&iter->conn, 1, &iter->mode);
|
||||
if (ret)
|
||||
printf("cannot set CRTC for connector %u (%d): %m\n",
|
||||
iter->conn, errno);
|
||||
iter->conn, errno);
|
||||
}
|
||||
|
||||
return ret_dev;
|
||||
@ -162,21 +162,21 @@ modeset_dev* modeset_create(int fd)
|
||||
*/
|
||||
|
||||
static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
struct modeset_dev *dev)
|
||||
struct modeset_dev *dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
// check if a monitor is connected
|
||||
if (conn->connection != DRM_MODE_CONNECTED) {
|
||||
printf("ignoring unused connector %u\n",
|
||||
conn->connector_id);
|
||||
conn->connector_id);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
// check if there is at least one valid mode
|
||||
if (conn->count_modes == 0) {
|
||||
printf("no valid mode for connector %u\n",
|
||||
conn->connector_id);
|
||||
conn->connector_id);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
@ -187,13 +187,13 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
dev->bufs[1].width = conn->modes[0].hdisplay;
|
||||
dev->bufs[1].height = conn->modes[0].vdisplay;
|
||||
printf("mode for connector %u is %ux%u\n",
|
||||
conn->connector_id, dev->bufs[0].width, dev->bufs[0].height);
|
||||
conn->connector_id, dev->bufs[0].width, dev->bufs[0].height);
|
||||
|
||||
// find a crtc for this connector
|
||||
ret = modeset_find_crtc(fd, res, conn, dev);
|
||||
if (ret) {
|
||||
printf("no valid crtc for connector %u\n",
|
||||
conn->connector_id);
|
||||
conn->connector_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
ret = modeset_create_fb(fd, &dev->bufs[0]);
|
||||
if (ret) {
|
||||
printf("cannot create framebuffer for connector %u\n",
|
||||
conn->connector_id);
|
||||
conn->connector_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
ret = modeset_create_fb(fd, &dev->bufs[1]);
|
||||
if (ret) {
|
||||
printf("cannot create framebuffer for connector %u\n",
|
||||
conn->connector_id);
|
||||
conn->connector_id);
|
||||
modeset_destroy_fb(fd, &dev->bufs[0]);
|
||||
return ret;
|
||||
}
|
||||
@ -222,7 +222,7 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
*/
|
||||
|
||||
static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
modeset_dev *dev)
|
||||
modeset_dev *dev)
|
||||
{
|
||||
drmModeEncoder *enc;
|
||||
unsigned int i, j;
|
||||
@ -263,7 +263,7 @@ static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
enc = drmModeGetEncoder(fd, conn->encoders[i]);
|
||||
if (!enc) {
|
||||
printf("cannot retrieve encoder %u:%u (%d): %m\n",
|
||||
i, conn->encoders[i], errno);
|
||||
i, conn->encoders[i], errno);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn,
|
||||
}
|
||||
|
||||
printf("cannot find suitable CRTC for connector %u\n",
|
||||
conn->connector_id);
|
||||
conn->connector_id);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ static int modeset_create_fb(int fd, struct modeset_buf *buf)
|
||||
ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq);
|
||||
if (ret < 0) {
|
||||
printf("cannot create dumb buffer (%d): %m\n",
|
||||
errno);
|
||||
errno);
|
||||
return -errno;
|
||||
}
|
||||
buf->stride = creq.pitch;
|
||||
@ -329,10 +329,10 @@ static int modeset_create_fb(int fd, struct modeset_buf *buf)
|
||||
|
||||
// create framebuffer object for the dumb-buffer
|
||||
ret = drmModeAddFB(fd, buf->width, buf->height, 24, 32, buf->stride,
|
||||
buf->handle, &buf->fb);
|
||||
buf->handle, &buf->fb);
|
||||
if (ret) {
|
||||
printf("cannot create framebuffer (%d): %m\n",
|
||||
errno);
|
||||
errno);
|
||||
ret = -errno;
|
||||
|
||||
memset(&dreq, 0, sizeof(dreq));
|
||||
@ -347,7 +347,7 @@ static int modeset_create_fb(int fd, struct modeset_buf *buf)
|
||||
ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq);
|
||||
if (ret) {
|
||||
printf("cannot map dumb buffer (%d): %m\n",
|
||||
errno);
|
||||
errno);
|
||||
ret = -errno;
|
||||
|
||||
drmModeRmFB(fd, buf->fb);
|
||||
@ -359,10 +359,10 @@ static int modeset_create_fb(int fd, struct modeset_buf *buf)
|
||||
|
||||
// perform actual memory mapping
|
||||
buf->map = mmap(0, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
fd, mreq.offset);
|
||||
fd, mreq.offset);
|
||||
if (buf->map == MAP_FAILED) {
|
||||
printf("cannot mmap dumb buffer (%d): %m\n",
|
||||
errno);
|
||||
errno);
|
||||
ret = -errno;
|
||||
|
||||
drmModeRmFB(fd, buf->fb);
|
||||
@ -447,10 +447,10 @@ void modeset_swapbuffer(int fd, modeset_dev* dev, unsigned index)
|
||||
buf = &iter->bufs[iter->front_buf ^ 1];
|
||||
|
||||
ret = drmModeSetCrtc(fd, iter->crtc, buf->fb, 0, 0,
|
||||
&iter->conn, 1, &iter->mode);
|
||||
&iter->conn, 1, &iter->mode);
|
||||
if (ret)
|
||||
printf("cannot flip CRTC for connector %u (%d): %m\n",
|
||||
iter->conn, errno);
|
||||
iter->conn, errno);
|
||||
else
|
||||
iter->front_buf ^= 1;
|
||||
}
|
||||
@ -472,13 +472,13 @@ void modeset_destroy(int fd, modeset_dev* dev)
|
||||
|
||||
// restore saved CRTC configuration
|
||||
drmModeSetCrtc(fd,
|
||||
iter->saved_crtc->crtc_id,
|
||||
iter->saved_crtc->buffer_id,
|
||||
iter->saved_crtc->x,
|
||||
iter->saved_crtc->y,
|
||||
&iter->conn,
|
||||
1,
|
||||
&iter->saved_crtc->mode);
|
||||
iter->saved_crtc->crtc_id,
|
||||
iter->saved_crtc->buffer_id,
|
||||
iter->saved_crtc->x,
|
||||
iter->saved_crtc->y,
|
||||
&iter->conn,
|
||||
1,
|
||||
&iter->saved_crtc->mode);
|
||||
drmModeFreeCrtc(iter->saved_crtc);
|
||||
|
||||
// destroy framebuffers
|
||||
|
@ -14,18 +14,18 @@ typedef enum VkRpiSurfaceCreateFlagsKHR {
|
||||
} VkRpiSurfaceCreateFlagsKHR;
|
||||
|
||||
typedef struct VkRpiSurfaceCreateInfoKHR {
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkRpiSurfaceCreateFlagsKHR flags; //reserved
|
||||
//maybe include some other stuff dunno
|
||||
} VkRpiSurfaceCreateInfoKHR;
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkRpiSurfaceCreateFlagsKHR flags; //reserved
|
||||
//maybe include some other stuff dunno
|
||||
} VkRpiSurfaceCreateInfoKHR;
|
||||
|
||||
//extension name something like: VK_KHR_rpi_surface
|
||||
VkResult vkCreateRpiSurfaceKHR(
|
||||
VkInstance instance,
|
||||
const VkRpiSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
VkInstance instance,
|
||||
const VkRpiSurfaceCreateInfoKHR* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkSurfaceKHR* pSurface);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -89,7 +89,7 @@ void mainLoop() {
|
||||
for(int c = 0; c < 120; ++c){
|
||||
draw();
|
||||
|
||||
// glfwPollEvents();
|
||||
// glfwPollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,7 +401,7 @@ void createSwapChain() {
|
||||
// Note: AMD driver bug, though it would be nice to implement a workaround that doesn't use transfering
|
||||
//if (!(surfaceCapabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT)) {
|
||||
// std::cerr << "swap chain image does not support VK_IMAGE_TRANSFER_DST usage" << std::endl;
|
||||
//assert(0);
|
||||
//assert(0);
|
||||
//}
|
||||
|
||||
// Determine transformation to use (preferring no transform)
|
||||
|
Loading…
x
Reference in New Issue
Block a user