From 8c017a932c451c810025f9035ef8f5aa1974b7d2 Mon Sep 17 00:00:00 2001 From: Unknown <0.tamas.marton@gmail.com> Date: Tue, 1 Oct 2019 19:23:52 +0100 Subject: [PATCH] loader stuff is now fully functional --- driver/declarations.h | 18 ++++++ driver/instance.c | 4 ++ driver/vkExt.h | 48 ++++++++-------- driver/vkExtFunctions.c | 41 +++++++------- driver/vkExtFunctions.h | 6 +- test/blending/blending.cpp | 72 ++++++------------------ test/clear/clear.cpp | 33 +++++++---- test/depthTest/depthTest.cpp | 53 +++++++++-------- test/indexedTriangle/indexedTriangle.cpp | 53 +++++++++-------- test/stencilTest/stencilTest.cpp | 56 ++++++++++-------- test/texturing/texturing.cpp | 57 +++++++++++-------- test/triangle/triangle.cpp | 55 ++++++++++-------- test/varyings/varyings.cpp | 53 +++++++++-------- 13 files changed, 293 insertions(+), 256 deletions(-) diff --git a/driver/declarations.h b/driver/declarations.h index de7e225..c677255 100644 --- a/driver/declarations.h +++ b/driver/declarations.h @@ -983,6 +983,24 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkGetPhysicalDeviceSurfacePresentModesKHR( uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes); +VKAPI_ATTR VkResult VKAPI_CALL rpi_vkGetSwapchainImagesKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint32_t* pSwapchainImageCount, + VkImage* pSwapchainImages); + +VKAPI_ATTR VkResult VKAPI_CALL rpi_vkAcquireNextImageKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint64_t timeout, + VkSemaphore semaphore, + VkFence fence, + uint32_t* pImageIndex); + +VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueuePresentKHR( + VkQueue queue, + const VkPresentInfoKHR* pPresentInfo); + #ifdef __cplusplus } #endif diff --git a/driver/instance.c b/driver/instance.c index c06229b..f0104d0 100644 --- a/driver/instance.c +++ b/driver/instance.c @@ -387,6 +387,10 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL rpi_vkGetInstanceProcAddr( RETFUNC(vkGetPhysicalDeviceSurfaceFormatsKHR); RETFUNC(vkGetPhysicalDeviceSurfacePresentModesKHR); + RETFUNC(vkGetSwapchainImagesKHR); + RETFUNC(vkAcquireNextImageKHR); + RETFUNC(vkQueuePresentKHR); + return 0; } diff --git a/driver/vkExt.h b/driver/vkExt.h index 4529290..52a45c0 100644 --- a/driver/vkExt.h +++ b/driver/vkExt.h @@ -38,28 +38,6 @@ typedef struct LoaderTrampoline LoaderTerminator* loaderTerminator; } LoaderTrampoline; -//we need something like the other platforms to create surfaces on the RPI -//so I created this little "extension" -//full spec in this file ;) - -typedef enum VkRpiSurfaceCreateFlagsEXT { - //reserved - VK_RPI_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkRpiSurfaceCreateFlagsEXT; - -typedef struct VkRpiSurfaceCreateInfoEXT { - VkStructureType sType; - const void* pNext; - VkRpiSurfaceCreateFlagsEXT flags; //reserved - //maybe include some other stuff dunno -} VkRpiSurfaceCreateInfoEXT; - -typedef enum VkRpiAssemblyMappingTypeEXT { - VK_RPI_ASSEMBLY_MAPPING_TYPE_DESCRIPTOR = 0, - VK_RPI_ASSEMBLY_MAPPING_TYPE_PUSH_CONSTANT = 1, - VK_RPI_ASSEMBLY_MAPPING_TYPE_MAX -} VkRpiAssemblyMappingTypeEXT; - /* * assembly to vulkan resource mapping * @@ -87,6 +65,18 @@ typedef enum VkRpiAssemblyMappingTypeEXT { * */ +typedef enum VkRpiSurfaceCreateFlagsEXT { + //reserved + VK_RPI_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkRpiSurfaceCreateFlagsEXT; + + +typedef enum VkRpiAssemblyMappingTypeEXT { + VK_RPI_ASSEMBLY_MAPPING_TYPE_DESCRIPTOR = 0, + VK_RPI_ASSEMBLY_MAPPING_TYPE_PUSH_CONSTANT = 1, + VK_RPI_ASSEMBLY_MAPPING_TYPE_MAX +} VkRpiAssemblyMappingTypeEXT; + //defines mapping for a single uniform FIFO read to a Vulkan resource typedef struct VkRpiAssemblyMappingEXT { VkRpiAssemblyMappingTypeEXT mappingType; @@ -98,12 +88,26 @@ typedef struct VkRpiAssemblyMappingEXT { VkShaderStageFlagBits shaderStage; } VkRpiAssemblyMappingEXT; +//we need something like the other platforms to create surfaces on the RPI +//so I created this little "extension" +//full spec in this file ;) + +typedef struct VkRpiSurfaceCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkRpiSurfaceCreateFlagsEXT flags; //reserved + const VkAllocationCallbacks* pAllocator; + VkSurfaceKHR* pSurface; +} VkRpiSurfaceCreateInfoEXT; + typedef struct VkRpiShaderModuleAssemblyCreateInfoEXT { VkStructureType sType; const void* pNext; char** asmStrings; VkRpiAssemblyMappingEXT* mappings; uint32_t numMappings; + const VkAllocationCallbacks* pAllocator; + VkShaderModule* pShaderModule; } VkRpiShaderModuleAssemblyCreateInfoEXT; #ifdef __cplusplus diff --git a/driver/vkExtFunctions.c b/driver/vkExtFunctions.c index a5d4f24..253858f 100644 --- a/driver/vkExtFunctions.c +++ b/driver/vkExtFunctions.c @@ -12,18 +12,17 @@ extern "C" { /* * Implementation of our RPI specific "extension" */ -VkResult rpi_vkCreateRpiSurfaceEXT( - VkPhysicalDevice physicalDevice) +VkResult rpi_vkCreateRpiSurfaceEXT(VkPhysicalDevice physicalDevice) { assert(physicalDevice); //TODO use allocator! _physicalDevice* ptr = physicalDevice; - VkSurfaceKHR* surfPtr = ptr->customData; + VkRpiSurfaceCreateInfoEXT* ci = ptr->customData; VkSurfaceKHR surfRes = (VkSurfaceKHR)modeset_create(controlFd); - *surfPtr = surfRes; + *ci->pSurface = surfRes; return VK_SUCCESS; } @@ -33,15 +32,17 @@ VkResult rpi_vkCreateRpiSurfaceEXT( //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 -VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(VkPhysicalDevice physicalDevice, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule) +VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(VkPhysicalDevice physicalDevice) { assert(physicalDevice); - assert(pCreateInfo); - assert(pShaderModule); - assert(pCreateInfo->asmStrings); + + _physicalDevice* ptr = physicalDevice; + VkRpiShaderModuleAssemblyCreateInfoEXT* ci = ptr->customData; + const const VkAllocationCallbacks* pAllocator = ci->pAllocator; + + assert(ci); + assert(ci->pShaderModule); + assert(ci->asmStrings); _shaderModule* shader = ALLOCATE(sizeof(_shaderModule), 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); @@ -54,9 +55,9 @@ VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(VkPhysicalDevice for(int c = 0; c < RPI_ASSEMBLY_TYPE_MAX; ++c) { - if(pCreateInfo->asmStrings[c]) + if(ci->asmStrings[c]) { - uint32_t numInstructions = get_num_instructions(pCreateInfo->asmStrings[c]); + uint32_t numInstructions = get_num_instructions(ci->asmStrings[c]); uint32_t size = sizeof(uint64_t)*numInstructions; //TODO this alloc feels kinda useless, we just copy the data anyway to kernel space //why not map kernel space mem to user space instead? @@ -67,9 +68,9 @@ VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(VkPhysicalDevice } //need to create a temporary copy as the assembly algorithm is destructive - uint32_t stringLength = strlen(pCreateInfo->asmStrings[c]); + uint32_t stringLength = strlen(ci->asmStrings[c]); char* tmpShaderStr = ALLOCATE(stringLength+1, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - memcpy(tmpShaderStr, pCreateInfo->asmStrings[c], stringLength+1); + memcpy(tmpShaderStr, ci->asmStrings[c], stringLength+1); assemble_qpu_asm(tmpShaderStr, shader->instructions[c]); @@ -119,21 +120,21 @@ VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT(VkPhysicalDevice } } - shader->numMappings = pCreateInfo->numMappings; + shader->numMappings = ci->numMappings; - if(pCreateInfo->numMappings > 0) + if(ci->numMappings > 0) { - shader->mappings = ALLOCATE(sizeof(VkRpiAssemblyMappingEXT)*pCreateInfo->numMappings, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + shader->mappings = ALLOCATE(sizeof(VkRpiAssemblyMappingEXT)*ci->numMappings, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if(!shader->mappings) { return VK_ERROR_OUT_OF_HOST_MEMORY; } - memcpy(shader->mappings, pCreateInfo->mappings, sizeof(VkRpiAssemblyMappingEXT)*pCreateInfo->numMappings); + memcpy(shader->mappings, ci->mappings, sizeof(VkRpiAssemblyMappingEXT)*ci->numMappings); } - *pShaderModule = shader; + *ci->pShaderModule = shader; return VK_SUCCESS; } diff --git a/driver/vkExtFunctions.h b/driver/vkExtFunctions.h index 66c52ae..3c8b256 100644 --- a/driver/vkExtFunctions.h +++ b/driver/vkExtFunctions.h @@ -13,11 +13,7 @@ extern VkResult rpi_vkCreateRpiSurfaceEXT( //extension that allows developers to submit QPU assembly directly and thus hand optimise code extern VkResult rpi_vkCreateShaderModuleFromRpiAssemblyEXT( - VkPhysicalDevice physicalDevice, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule - ); + VkPhysicalDevice physicalDevice); //TODO performance counters / perfmon diff --git a/test/blending/blending.cpp b/test/blending/blending.cpp index 7f770bf..b4f088c 100644 --- a/test/blending/blending.cpp +++ b/test/blending/blending.cpp @@ -158,42 +158,6 @@ void mainLoop() { } } -VkBool32 debugCallback( - VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objectType, - uint64_t object, - size_t location, - int32_t messageCode, - const char* pLayerPrefix, - const char* pMessage, - void* pUserData) -{ - std::cerr << "Debug callback: "; - if(flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) - std::cerr << "info "; - - if(flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) - std::cerr << "warn "; - if(flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) - std::cerr << "perf "; - - if(flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) - std::cerr << "error "; - - if(flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) - std::cerr << "debug "; - - std::cerr << std::endl - << "object type: " << objectType - << " object: " << object - << " location: " << location - << " message code: " << messageCode << std::endl - << " layer prefix: " << pLayerPrefix << std::endl - << " message: " << pMessage - << std::endl; - -} - void createInstance() { VkApplicationInfo appInfo = {}; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; @@ -226,11 +190,6 @@ void createInstance() { std::cout << "\t" << extension.extensionName << std::endl; } - VkDebugReportCallbackCreateInfoEXT debugCallbackInfo = {}; - debugCallbackInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; - debugCallbackInfo.flags = 0xffffffff; - debugCallbackInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)debugCallback; - const char* enabledExtensions[] = { "VK_KHR_surface", "VK_KHR_display" @@ -238,13 +197,13 @@ void createInstance() { VkInstanceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - createInfo.pNext = &debugCallbackInfo; + createInfo.pNext = 0; createInfo.pApplicationInfo = &appInfo; createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*); createInfo.ppEnabledExtensionNames = enabledExtensions; createInfo.enabledLayerCount = 0; createInfo.ppEnabledLayerNames = 0; - +// // Initialize Vulkan instance VkResult res; if ((res = vkCreateInstance(&createInfo, nullptr, &instance)) != VK_SUCCESS) { @@ -264,7 +223,11 @@ void createWindowSurface() { LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; - realPhysicalDevice->customData = (uintptr_t)&windowSurface; + + VkRpiSurfaceCreateInfoEXT ci = {}; + ci.pSurface = &windowSurface; + + realPhysicalDevice->customData = (uintptr_t)&ci; if (vkCreateRpiSurfaceEXT(physicalDevice) != VK_SUCCESS) { std::cerr << "failed to create window surface!" << std::endl; @@ -876,15 +839,6 @@ void CreateFramebuffer() void CreateShaders() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModuleFromRpiAssemblyEXT)( - VkDevice device, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule - ); - - PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); - char vs_asm_code[] = ///0x40000000 = 2.0 ///uni = 1.0 @@ -1102,12 +1056,20 @@ void CreateShaders() } }; - VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo; + VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo = {}; shaderModuleCreateInfo.asmStrings = asm_strings; shaderModuleCreateInfo.mappings = mappings; shaderModuleCreateInfo.numMappings = sizeof(mappings) / sizeof(VkRpiAssemblyMappingEXT); + shaderModuleCreateInfo.pShaderModule = &shaderModule; - VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &shaderModule); + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + + realPhysicalDevice->customData = (uintptr_t)&shaderModuleCreateInfo; + + PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); + + VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(shaderModule); } diff --git a/test/clear/clear.cpp b/test/clear/clear.cpp index 9c4703b..b621d18 100644 --- a/test/clear/clear.cpp +++ b/test/clear/clear.cpp @@ -74,8 +74,8 @@ void run() { void setupVulkan() { createInstance(); - createWindowSurface(); findPhysicalDevice(); + createWindowSurface(); checkSwapChainSupport(); findQueueFamilies(); createLogicalDevice(); @@ -146,13 +146,17 @@ void createInstance() { std::cout << "\t" << extension.extensionName << std::endl; } + const char* enabledExtensions[] = { + "VK_KHR_surface", + "VK_KHR_display" + }; + VkInstanceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + createInfo.pNext = 0; createInfo.pApplicationInfo = &appInfo; - //createInfo.enabledExtensionCount = glfwExtensionCount; - createInfo.enabledExtensionCount = 0; - //createInfo.ppEnabledExtensionNames = glfwExtensions; - createInfo.ppEnabledExtensionNames = 0; + createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*); + createInfo.ppEnabledExtensionNames = enabledExtensions; createInfo.enabledLayerCount = 0; createInfo.ppEnabledLayerNames = 0; @@ -167,15 +171,20 @@ void createInstance() { } void createWindowSurface() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateRpiSurfaceEXT)( - VkInstance instance, - const VkRpiSurfaceCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); + PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = 0; + vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); - PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); + windowSurface = 0; +// + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; - if (vkCreateRpiSurfaceEXT(instance, 0, 0, &windowSurface) != VK_SUCCESS) { + VkRpiSurfaceCreateInfoEXT ci = {}; + ci.pSurface = &windowSurface; + + realPhysicalDevice->customData = (uintptr_t)&ci; + + if (vkCreateRpiSurfaceEXT(physicalDevice) != VK_SUCCESS) { std::cerr << "failed to create window surface!" << std::endl; assert(0); } diff --git a/test/depthTest/depthTest.cpp b/test/depthTest/depthTest.cpp index 66c9f90..0738d2f 100644 --- a/test/depthTest/depthTest.cpp +++ b/test/depthTest/depthTest.cpp @@ -137,8 +137,8 @@ void run() { void setupVulkan() { createInstance(); - createWindowSurface(); findPhysicalDevice(); + createWindowSurface(); checkSwapChainSupport(); findQueueFamilies(); createLogicalDevice(); @@ -196,13 +196,17 @@ void createInstance() { std::cout << "\t" << extension.extensionName << std::endl; } + const char* enabledExtensions[] = { + "VK_KHR_surface", + "VK_KHR_display" + }; + VkInstanceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + createInfo.pNext = 0; createInfo.pApplicationInfo = &appInfo; - //createInfo.enabledExtensionCount = glfwExtensionCount; - createInfo.enabledExtensionCount = 0; - //createInfo.ppEnabledExtensionNames = glfwExtensions; - createInfo.ppEnabledExtensionNames = 0; + createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*); + createInfo.ppEnabledExtensionNames = enabledExtensions; createInfo.enabledLayerCount = 0; createInfo.ppEnabledLayerNames = 0; @@ -217,16 +221,20 @@ void createInstance() { } void createWindowSurface() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateRpiSurfaceEXT)( - VkInstance instance, - const VkRpiSurfaceCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); + PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = 0; + vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); - PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); + windowSurface = 0; + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; - if (vkCreateRpiSurfaceEXT(instance, 0, 0, &windowSurface) != VK_SUCCESS) { + VkRpiSurfaceCreateInfoEXT ci = {}; + ci.pSurface = &windowSurface; + + realPhysicalDevice->customData = (uintptr_t)&ci; + + if (vkCreateRpiSurfaceEXT(physicalDevice) != VK_SUCCESS) { std::cerr << "failed to create window surface!" << std::endl; assert(0); } @@ -967,15 +975,6 @@ void CreateFramebuffer() void CreateShaders() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModuleFromRpiAssemblyEXT)( - VkDevice device, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule - ); - - PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); - char vs_asm_code[] = ///0x40000000 = 2.0 ///uni = 1.0 @@ -1174,12 +1173,20 @@ void CreateShaders() } }; - VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo; + VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo = {}; shaderModuleCreateInfo.asmStrings = asm_strings; shaderModuleCreateInfo.mappings = mappings; shaderModuleCreateInfo.numMappings = sizeof(mappings) / sizeof(VkRpiAssemblyMappingEXT); + shaderModuleCreateInfo.pShaderModule = &shaderModule; - VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &shaderModule); + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + + realPhysicalDevice->customData = (uintptr_t)&shaderModuleCreateInfo; + + PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); + + VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(shaderModule); } diff --git a/test/indexedTriangle/indexedTriangle.cpp b/test/indexedTriangle/indexedTriangle.cpp index 2e730b6..59d89b3 100644 --- a/test/indexedTriangle/indexedTriangle.cpp +++ b/test/indexedTriangle/indexedTriangle.cpp @@ -131,8 +131,8 @@ void run() { void setupVulkan() { createInstance(); - createWindowSurface(); findPhysicalDevice(); + createWindowSurface(); checkSwapChainSupport(); findQueueFamilies(); createLogicalDevice(); @@ -189,13 +189,17 @@ void createInstance() { std::cout << "\t" << extension.extensionName << std::endl; } + const char* enabledExtensions[] = { + "VK_KHR_surface", + "VK_KHR_display" + }; + VkInstanceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + createInfo.pNext = 0; createInfo.pApplicationInfo = &appInfo; - //createInfo.enabledExtensionCount = glfwExtensionCount; - createInfo.enabledExtensionCount = 0; - //createInfo.ppEnabledExtensionNames = glfwExtensions; - createInfo.ppEnabledExtensionNames = 0; + createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*); + createInfo.ppEnabledExtensionNames = enabledExtensions; createInfo.enabledLayerCount = 0; createInfo.ppEnabledLayerNames = 0; @@ -210,17 +214,20 @@ void createInstance() { } void createWindowSurface() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateRpiSurfaceEXT)( - VkInstance instance, - const VkRpiSurfaceCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); + PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = 0; + vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); - PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); + windowSurface = 0; + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + VkRpiSurfaceCreateInfoEXT ci = {}; + ci.pSurface = &windowSurface; - if (vkCreateRpiSurfaceEXT(instance, 0, 0, &windowSurface) != VK_SUCCESS) { + realPhysicalDevice->customData = (uintptr_t)&ci; + + if (vkCreateRpiSurfaceEXT(physicalDevice) != VK_SUCCESS) { std::cerr << "failed to create window surface!" << std::endl; assert(0); } @@ -816,16 +823,6 @@ void CreateFramebuffer() void CreateShaders() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModuleFromRpiAssemblyEXT)( - VkDevice device, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule - ); - - PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); - - char vs_asm_code[] = ///0x40000000 = 2.0 ///uni = 1.0 @@ -1006,12 +1003,20 @@ void CreateShaders() } }; - VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo; + VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo = {}; shaderModuleCreateInfo.asmStrings = asm_strings; shaderModuleCreateInfo.mappings = mappings; shaderModuleCreateInfo.numMappings = sizeof(mappings) / sizeof(VkRpiAssemblyMappingEXT); + shaderModuleCreateInfo.pShaderModule = &shaderModule; - VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &shaderModule); + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + + realPhysicalDevice->customData = (uintptr_t)&shaderModuleCreateInfo; + + PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); + + VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(shaderModule); } diff --git a/test/stencilTest/stencilTest.cpp b/test/stencilTest/stencilTest.cpp index fa044f2..c75d98d 100644 --- a/test/stencilTest/stencilTest.cpp +++ b/test/stencilTest/stencilTest.cpp @@ -139,8 +139,8 @@ void run() { void setupVulkan() { createInstance(); - createWindowSurface(); findPhysicalDevice(); + createWindowSurface(); checkSwapChainSupport(); findQueueFamilies(); createLogicalDevice(); @@ -198,13 +198,17 @@ void createInstance() { std::cout << "\t" << extension.extensionName << std::endl; } + const char* enabledExtensions[] = { + "VK_KHR_surface", + "VK_KHR_display" + }; + VkInstanceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + createInfo.pNext = 0; createInfo.pApplicationInfo = &appInfo; - //createInfo.enabledExtensionCount = glfwExtensionCount; - createInfo.enabledExtensionCount = 0; - //createInfo.ppEnabledExtensionNames = glfwExtensions; - createInfo.ppEnabledExtensionNames = 0; + createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*); + createInfo.ppEnabledExtensionNames = enabledExtensions; createInfo.enabledLayerCount = 0; createInfo.ppEnabledLayerNames = 0; @@ -219,16 +223,20 @@ void createInstance() { } void createWindowSurface() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateRpiSurfaceEXT)( - VkInstance instance, - const VkRpiSurfaceCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); + PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = 0; + vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); - PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); + windowSurface = 0; + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; - if (vkCreateRpiSurfaceEXT(instance, 0, 0, &windowSurface) != VK_SUCCESS) { + VkRpiSurfaceCreateInfoEXT ci = {}; + ci.pSurface = &windowSurface; + + realPhysicalDevice->customData = (uintptr_t)&ci; + + if (vkCreateRpiSurfaceEXT(physicalDevice) != VK_SUCCESS) { std::cerr << "failed to create window surface!" << std::endl; assert(0); } @@ -968,15 +976,6 @@ void CreateFramebuffer() void CreateShaders() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModuleFromRpiAssemblyEXT)( - VkDevice device, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule - ); - - PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); - char vs_asm_code[] = ///0x40000000 = 2.0 ///uni = 1.0 @@ -1186,17 +1185,26 @@ void CreateShaders() } }; - VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo; + VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo = {}; shaderModuleCreateInfo.asmStrings = asm_strings; shaderModuleCreateInfo.mappings = mappings; shaderModuleCreateInfo.numMappings = sizeof(mappings) / sizeof(VkRpiAssemblyMappingEXT); + shaderModuleCreateInfo.pShaderModule = &shaderModule1; - VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &shaderModule1); + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + + realPhysicalDevice->customData = (uintptr_t)&shaderModuleCreateInfo; + + PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); + + VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(shaderModule1); + shaderModuleCreateInfo.pShaderModule = &shaderModule2; asm_strings[2] = (char*)fs_asm_code2; - res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &shaderModule2); + res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(shaderModule2); } diff --git a/test/texturing/texturing.cpp b/test/texturing/texturing.cpp index c2e1867..3eda623 100644 --- a/test/texturing/texturing.cpp +++ b/test/texturing/texturing.cpp @@ -101,6 +101,7 @@ char* readPPM(const char* fileName) ((uint8_t*)&ppm_magic)[1] = '6'; FILE* fd = fopen(fileName, "rb"); + assert(fd); fseek (fd , 0 , SEEK_END); uint32_t fsize = ftell(fd); rewind(fd); @@ -205,8 +206,8 @@ void run() { void setupVulkan() { createInstance(); - createWindowSurface(); findPhysicalDevice(); + createWindowSurface(); checkSwapChainSupport(); findQueueFamilies(); createLogicalDevice(); @@ -264,13 +265,17 @@ void createInstance() { std::cout << "\t" << extension.extensionName << std::endl; } + const char* enabledExtensions[] = { + "VK_KHR_surface", + "VK_KHR_display" + }; + VkInstanceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + createInfo.pNext = 0; createInfo.pApplicationInfo = &appInfo; - //createInfo.enabledExtensionCount = glfwExtensionCount; - createInfo.enabledExtensionCount = 0; - //createInfo.ppEnabledExtensionNames = glfwExtensions; - createInfo.ppEnabledExtensionNames = 0; + createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*); + createInfo.ppEnabledExtensionNames = enabledExtensions; createInfo.enabledLayerCount = 0; createInfo.ppEnabledLayerNames = 0; @@ -285,16 +290,20 @@ void createInstance() { } void createWindowSurface() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateRpiSurfaceEXT)( - VkInstance instance, - const VkRpiSurfaceCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); + PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = 0; + vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); - PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); + windowSurface = 0; + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; - if (vkCreateRpiSurfaceEXT(instance, 0, 0, &windowSurface) != VK_SUCCESS) { + VkRpiSurfaceCreateInfoEXT ci = {}; + ci.pSurface = &windowSurface; + + realPhysicalDevice->customData = (uintptr_t)&ci; + + if (vkCreateRpiSurfaceEXT(physicalDevice) != VK_SUCCESS) { std::cerr << "failed to create window surface!" << std::endl; assert(0); } @@ -936,15 +945,6 @@ void CreateFramebuffer() void CreateShaders() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModuleFromRpiAssemblyEXT)( - VkDevice device, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule - ); - - PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); - char vs_asm_code[] = ///0x40000000 = 2.0 ///uni = 1.0 @@ -1245,19 +1245,28 @@ void CreateShaders() } }; - VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo; + VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo = {}; shaderModuleCreateInfo.asmStrings = blit_asm_strings; shaderModuleCreateInfo.mappings = blit_mappings; shaderModuleCreateInfo.numMappings = sizeof(blit_mappings) / sizeof(VkRpiAssemblyMappingEXT); + shaderModuleCreateInfo.pShaderModule = &blitShaderModule; - VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &blitShaderModule); + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + + realPhysicalDevice->customData = (uintptr_t)&shaderModuleCreateInfo; + + PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); + + VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(blitShaderModule); shaderModuleCreateInfo.asmStrings = sample_asm_strings; shaderModuleCreateInfo.mappings = sample_mappings; shaderModuleCreateInfo.numMappings = sizeof(sample_mappings) / sizeof(VkRpiAssemblyMappingEXT); + shaderModuleCreateInfo.pShaderModule = &sampleShaderModule; - res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &sampleShaderModule); + res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(sampleShaderModule); //exit(-1); diff --git a/test/triangle/triangle.cpp b/test/triangle/triangle.cpp index 571bc4a..a329c1b 100644 --- a/test/triangle/triangle.cpp +++ b/test/triangle/triangle.cpp @@ -129,8 +129,8 @@ void run() { void setupVulkan() { createInstance(); - createWindowSurface(); findPhysicalDevice(); + createWindowSurface(); checkSwapChainSupport(); findQueueFamilies(); createLogicalDevice(); @@ -187,13 +187,17 @@ void createInstance() { std::cout << "\t" << extension.extensionName << std::endl; } + const char* enabledExtensions[] = { + "VK_KHR_surface", + "VK_KHR_display" + }; + VkInstanceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + createInfo.pNext = 0; createInfo.pApplicationInfo = &appInfo; - //createInfo.enabledExtensionCount = glfwExtensionCount; - createInfo.enabledExtensionCount = 0; - //createInfo.ppEnabledExtensionNames = glfwExtensions; - createInfo.ppEnabledExtensionNames = 0; + createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*); + createInfo.ppEnabledExtensionNames = enabledExtensions; createInfo.enabledLayerCount = 0; createInfo.ppEnabledLayerNames = 0; @@ -208,15 +212,20 @@ void createInstance() { } void createWindowSurface() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateRpiSurfaceEXT)( - VkInstance instance, - const VkRpiSurfaceCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); + PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = 0; + vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); - PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); + windowSurface = 0; - if (vkCreateRpiSurfaceEXT(instance, 0, 0, &windowSurface) != VK_SUCCESS) { + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + + VkRpiSurfaceCreateInfoEXT ci = {}; + ci.pSurface = &windowSurface; + + realPhysicalDevice->customData = (uintptr_t)&ci; + + if (vkCreateRpiSurfaceEXT(physicalDevice) != VK_SUCCESS) { std::cerr << "failed to create window surface!" << std::endl; assert(0); } @@ -810,16 +819,6 @@ void CreateFramebuffer() void CreateShaders() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModuleFromRpiAssemblyEXT)( - VkDevice device, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule - ); - - PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); - - char vs_asm_code[] = ///0x40000000 = 2.0 ///uni = 1.0 @@ -1000,12 +999,20 @@ void CreateShaders() } }; - VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo; + VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo = {}; shaderModuleCreateInfo.asmStrings = asm_strings; shaderModuleCreateInfo.mappings = mappings; shaderModuleCreateInfo.numMappings = sizeof(mappings) / sizeof(VkRpiAssemblyMappingEXT); + shaderModuleCreateInfo.pShaderModule = &shaderModule; - VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &shaderModule); + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + + realPhysicalDevice->customData = (uintptr_t)&shaderModuleCreateInfo; + + PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); + + VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(shaderModule); } diff --git a/test/varyings/varyings.cpp b/test/varyings/varyings.cpp index 6690bd0..0eec954 100644 --- a/test/varyings/varyings.cpp +++ b/test/varyings/varyings.cpp @@ -129,8 +129,8 @@ void run() { void setupVulkan() { createInstance(); - createWindowSurface(); findPhysicalDevice(); + createWindowSurface(); checkSwapChainSupport(); findQueueFamilies(); createLogicalDevice(); @@ -187,13 +187,17 @@ void createInstance() { std::cout << "\t" << extension.extensionName << std::endl; } + const char* enabledExtensions[] = { + "VK_KHR_surface", + "VK_KHR_display" + }; + VkInstanceCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + createInfo.pNext = 0; createInfo.pApplicationInfo = &appInfo; - //createInfo.enabledExtensionCount = glfwExtensionCount; - createInfo.enabledExtensionCount = 0; - //createInfo.ppEnabledExtensionNames = glfwExtensions; - createInfo.ppEnabledExtensionNames = 0; + createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(const char*); + createInfo.ppEnabledExtensionNames = enabledExtensions; createInfo.enabledLayerCount = 0; createInfo.ppEnabledLayerNames = 0; @@ -208,16 +212,20 @@ void createInstance() { } void createWindowSurface() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateRpiSurfaceEXT)( - VkInstance instance, - const VkRpiSurfaceCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); + PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = 0; + vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); - PFN_vkCreateRpiSurfaceEXT vkCreateRpiSurfaceEXT = (PFN_vkCreateRpiSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateRpiSurfaceEXT"); + windowSurface = 0; + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; - if (vkCreateRpiSurfaceEXT(instance, 0, 0, &windowSurface) != VK_SUCCESS) { + VkRpiSurfaceCreateInfoEXT ci = {}; + ci.pSurface = &windowSurface; + + realPhysicalDevice->customData = (uintptr_t)&ci; + + if (vkCreateRpiSurfaceEXT(physicalDevice) != VK_SUCCESS) { std::cerr << "failed to create window surface!" << std::endl; assert(0); } @@ -811,15 +819,6 @@ void CreateFramebuffer() void CreateShaders() { - typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModuleFromRpiAssemblyEXT)( - VkDevice device, - VkRpiShaderModuleAssemblyCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule - ); - - PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); - /** //FS prog reading tex with varyings 0x100049e0203e303e nop nop, r0, r0 ; fmul r0, vary, ra15 //mul by w @@ -1062,12 +1061,20 @@ void CreateShaders() } }; - VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo; + VkRpiShaderModuleAssemblyCreateInfoEXT shaderModuleCreateInfo = {}; shaderModuleCreateInfo.asmStrings = asm_strings; shaderModuleCreateInfo.mappings = mappings; shaderModuleCreateInfo.numMappings = sizeof(mappings) / sizeof(VkRpiAssemblyMappingEXT); + shaderModuleCreateInfo.pShaderModule = &shaderModule; - VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(device, &shaderModuleCreateInfo, 0, &shaderModule); + LoaderTrampoline* trampoline = (LoaderTrampoline*)physicalDevice; + VkRpiPhysicalDevice* realPhysicalDevice = trampoline->loaderTerminator->physicalDevice; + + realPhysicalDevice->customData = (uintptr_t)&shaderModuleCreateInfo; + + PFN_vkCreateShaderModuleFromRpiAssemblyEXT vkCreateShaderModuleFromRpiAssemblyEXT = (PFN_vkCreateShaderModuleFromRpiAssemblyEXT)vkGetInstanceProcAddr(instance, "vkCreateShaderModuleFromRpiAssemblyEXT"); + + VkResult res = vkCreateShaderModuleFromRpiAssemblyEXT(physicalDevice); assert(shaderModule); }