mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2025-02-19 16:54:18 +01:00
backup
This commit is contained in:
parent
643a8c6775
commit
40c24dce9c
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateInstance(
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateInstance(
|
||||||
@ -948,3 +952,7 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkDestroySurfaceKHR(
|
|||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
VkSurfaceKHR surface,
|
VkSurfaceKHR surface,
|
||||||
const VkAllocationCallbacks* pAllocator);
|
const VkAllocationCallbacks* pAllocator);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include <vulkan/vk_icd.h>
|
#include <vulkan/vk_icd.h>
|
||||||
|
|
||||||
#include "declarations.h"
|
#include "declarations.h"
|
||||||
#include "vkExt.h"
|
#include "vkExtFunctions.h"
|
||||||
|
|
||||||
#define RETFUNC(f) if(!strcmp(pName, #f)) return rpi_##f
|
#define RETFUNC(f) if(!strcmp(pName, #f)) return &rpi_##f
|
||||||
|
|
||||||
static uint32_t loaderVersion = -1;
|
static uint32_t loaderVersion = -1;
|
||||||
|
|
||||||
@ -14,20 +14,23 @@ VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t
|
|||||||
assert(pSupportedVersion);
|
assert(pSupportedVersion);
|
||||||
loaderVersion = *pSupportedVersion;
|
loaderVersion = *pSupportedVersion;
|
||||||
|
|
||||||
*pSupportedVersion = 2; //we support v2
|
*pSupportedVersion = 4; //we support v4
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName)
|
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "-----------------vk_icdGetInstanceProcAddr: %s\n", pName);
|
|
||||||
|
|
||||||
if(loaderVersion == -1)
|
if(loaderVersion == -1)
|
||||||
{
|
{
|
||||||
//dealing with legacy ICD loader, as vk_icdNegotiateLoaderICDInterfaceVersion has not been called
|
//dealing with legacy ICD loader, as vk_icdNegotiateLoaderICDInterfaceVersion has not been called
|
||||||
loaderVersion = 1;
|
loaderVersion = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpi_vkGetInstanceProcAddr(instance, pName);
|
void* ptr = rpi_vkGetInstanceProcAddr(instance, pName);
|
||||||
|
|
||||||
|
fprintf(stderr, "-----------------rpi_vkGetInstanceProcAddr: %s, %p\n", pName, ptr);
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance instance,
|
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance instance,
|
||||||
@ -35,7 +38,7 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInsta
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "-----------------vk_icdGetPhysicalDeviceProcAddr: %s\n", pName);
|
fprintf(stderr, "-----------------vk_icdGetPhysicalDeviceProcAddr: %s\n", pName);
|
||||||
|
|
||||||
|
RETFUNC(vkGetRpiExtensionPointerEXT);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -195,8 +198,6 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL rpi_vkGetInstanceProcAddr(
|
|||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
const char* pName)
|
const char* pName)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "-----------------rpi_vkGetInstanceProcAddr: %s\n", pName);
|
|
||||||
|
|
||||||
//TODO take instance into consideration
|
//TODO take instance into consideration
|
||||||
//eg only return extension functions that are enabled?
|
//eg only return extension functions that are enabled?
|
||||||
|
|
||||||
@ -376,9 +377,6 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL rpi_vkGetInstanceProcAddr(
|
|||||||
RETFUNC(vkGetDescriptorSetLayoutSupport);
|
RETFUNC(vkGetDescriptorSetLayoutSupport);
|
||||||
RETFUNC(vkBindBufferMemory2);
|
RETFUNC(vkBindBufferMemory2);
|
||||||
|
|
||||||
RETFUNC(vkCreateRpiSurfaceEXT);
|
|
||||||
RETFUNC(vkCreateShaderModuleFromRpiAssemblyEXT);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,12 +4,17 @@
|
|||||||
|
|
||||||
#include "QPUassembler/qpu_assembler.h"
|
#include "QPUassembler/qpu_assembler.h"
|
||||||
|
|
||||||
|
#include "vkExt.h"
|
||||||
|
|
||||||
//TODO collect shader performance data
|
//TODO collect shader performance data
|
||||||
//eg number of texture samples etc.
|
//eg number of texture samples etc.
|
||||||
//TODO check if shader has flow control and make sure instance also has flow control
|
//TODO check if shader has flow control and make sure instance also has flow control
|
||||||
//TODO make sure instance has threaded fs if shader contains thread switch
|
//TODO make sure instance has threaded fs if shader contains thread switch
|
||||||
|
|
||||||
VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(VkDevice device, VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
|
VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(VkDevice device,
|
||||||
|
VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator,
|
||||||
|
VkShaderModule* pShaderModule)
|
||||||
{
|
{
|
||||||
assert(device);
|
assert(device);
|
||||||
assert(pCreateInfo);
|
assert(pCreateInfo);
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//we need something like the other platforms to create surfaces on the RPI
|
//we need something like the other platforms to create surfaces on the RPI
|
||||||
//so I created this little "extension"
|
//so I created this little "extension"
|
||||||
//full spec in this file ;)
|
//full spec in this file ;)
|
||||||
@ -71,28 +67,3 @@ typedef struct VkRpiShaderModuleAssemblyCreateInfoEXT {
|
|||||||
VkRpiAssemblyMappingEXT* mappings;
|
VkRpiAssemblyMappingEXT* mappings;
|
||||||
uint32_t numMappings;
|
uint32_t numMappings;
|
||||||
} VkRpiShaderModuleAssemblyCreateInfoEXT;
|
} VkRpiShaderModuleAssemblyCreateInfoEXT;
|
||||||
|
|
||||||
//TODO could use this extension https://vulkan.lunarg.com/doc/view/1.0.30.0/windows/vkspec.chunked/ch29s03.html
|
|
||||||
|
|
||||||
//extension name something like: VK_KHR_rpi_surface
|
|
||||||
//extension that allows developers to create a surface to render to on Raspbian Stretch Lite
|
|
||||||
VkResult rpi_vkCreateRpiSurfaceEXT(
|
|
||||||
VkInstance instance,
|
|
||||||
const VkRpiSurfaceCreateInfoEXT* pCreateInfo,
|
|
||||||
const VkAllocationCallbacks* pAllocator,
|
|
||||||
VkSurfaceKHR* pSurface);
|
|
||||||
|
|
||||||
//extension that allows developers to submit QPU assembly directly and thus hand optimise code
|
|
||||||
VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(
|
|
||||||
VkDevice device,
|
|
||||||
VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo,
|
|
||||||
const VkAllocationCallbacks* pAllocator,
|
|
||||||
VkShaderModule* pShaderModule
|
|
||||||
);
|
|
||||||
|
|
||||||
//TODO performance counters / perfmon
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
48
driver/vkExtFunctions.h
Normal file
48
driver/vkExtFunctions.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "vkExt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//extension name something like: VK_KHR_rpi_surface
|
||||||
|
//extension that allows developers to create a surface to render to on Raspbian Stretch Lite
|
||||||
|
extern VkResult rpi_vkCreateRpiSurfaceEXT(
|
||||||
|
VkInstance instance,
|
||||||
|
const VkRpiSurfaceCreateInfoEXT* pCreateInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator,
|
||||||
|
VkSurfaceKHR* pSurface);
|
||||||
|
|
||||||
|
//extension that allows developers to submit QPU assembly directly and thus hand optimise code
|
||||||
|
extern VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(
|
||||||
|
VkDevice device,
|
||||||
|
VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator,
|
||||||
|
VkShaderModule* pShaderModule
|
||||||
|
);
|
||||||
|
|
||||||
|
extern void* _getFuncPtr(const char* name);
|
||||||
|
|
||||||
|
static VkResult rpi_vkGetRpiExtensionPointerEXT(
|
||||||
|
VkPhysicalDevice physicalDevice
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//TODO how do we handle our "custom" extensions towards the loader????
|
||||||
|
|
||||||
|
uint32_t ret = 0;//(uint32_t)_getFuncPtr((const char*)physicalDevice);
|
||||||
|
|
||||||
|
if(ret)
|
||||||
|
{
|
||||||
|
return (VkResult)ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO performance counters / perfmon
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
23
driver/wsi.c
23
driver/wsi.c
@ -5,6 +5,29 @@
|
|||||||
|
|
||||||
#include "declarations.h"
|
#include "declarations.h"
|
||||||
|
|
||||||
|
#include "vkExtFunctions.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void* _getFuncPtr(const char* name)
|
||||||
|
{
|
||||||
|
if(!strcmp(name, "vkCreateRpiSurfaceEXT"))
|
||||||
|
return (void*)&rpi_vkCreateRpiSurfaceEXT;
|
||||||
|
|
||||||
|
if(!strcmp(name, "vkCreateShaderModuleFromRpiAssemblyEXT"))
|
||||||
|
return (void*)&rpi_vkCreateShaderModuleFromRpiAssemblyEXT;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementation of our RPI specific "extension"
|
* Implementation of our RPI specific "extension"
|
||||||
*/
|
*/
|
||||||
|
@ -132,8 +132,8 @@ void run() {
|
|||||||
|
|
||||||
void setupVulkan() {
|
void setupVulkan() {
|
||||||
createInstance();
|
createInstance();
|
||||||
createWindowSurface();
|
|
||||||
findPhysicalDevice();
|
findPhysicalDevice();
|
||||||
|
createWindowSurface();
|
||||||
checkSwapChainSupport();
|
checkSwapChainSupport();
|
||||||
findQueueFamilies();
|
findQueueFamilies();
|
||||||
createLogicalDevice();
|
createLogicalDevice();
|
||||||
@ -253,17 +253,28 @@ void createInstance() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void createWindowSurface() {
|
extern "C" {
|
||||||
typedef VkResult (VKAPI_PTR *PFN_vkCreateRpiSurfaceEXT)(
|
typedef VkResult (*PFN_vkCreateRpiSurfaceEXT)(
|
||||||
VkInstance instance,
|
VkPhysicalDevice physicalDevice,
|
||||||
const VkRpiSurfaceCreateInfoEXT* pCreateInfo,
|
const VkRpiSurfaceCreateInfoEXT* pCreateInfo,
|
||||||
const VkAllocationCallbacks* pAllocator,
|
const VkAllocationCallbacks* pAllocator,
|
||||||
VkSurfaceKHR* pSurface);
|
VkSurfaceKHR* pSurface);
|
||||||
|
typedef VkResult (*PFN_vkGetRpiExtensionPointerEXT)(
|
||||||
|
VkPhysicalDevice physicalDevice
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT");
|
PFN_vkGetRpiExtensionPointerEXT vkGetRpiExtensionPointerEXT = 0;
|
||||||
|
|
||||||
|
void createWindowSurface() {
|
||||||
|
vkGetRpiExtensionPointerEXT = (PFN_vkGetRpiExtensionPointerEXT)vkGetInstanceProcAddr(instance, "vkGetRpiExtensionPointerEXT");
|
||||||
|
fprintf(stderr, "%p\n", vkGetRpiExtensionPointerEXT);
|
||||||
|
|
||||||
if (vkCreateRpiSurfaceEXT(instance, 0, 0, &windowSurface) != VK_SUCCESS) {
|
PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = 0;
|
||||||
|
vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetRpiExtensionPointerEXT((VkPhysicalDevice)"vkCreateRpiSurfaceEXT");
|
||||||
|
fprintf(stderr, "%p\n", vkCreateRpiSurfaceEXT);
|
||||||
|
|
||||||
|
if (vkCreateRpiSurfaceEXT(physicalDevice, 0, 0, &windowSurface) != VK_SUCCESS) {
|
||||||
std::cerr << "failed to create window surface!" << std::endl;
|
std::cerr << "failed to create window surface!" << std::endl;
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user