fixing kvf issues

This commit is contained in:
2024-09-20 17:41:52 +02:00
parent 1e2705ef06
commit f9c05d6d7b
3 changed files with 14 additions and 10 deletions

View File

@@ -10,6 +10,7 @@
namespace mlx namespace mlx
{ {
// TODO : FIX THIS DAMN GOD CLASS !!!!!!!!!!!!!!!!
class Application class Application
{ {
public: public:

View File

@@ -90,7 +90,6 @@ namespace mlx
LoadKVFDeviceVulkanFunctionPointers(); LoadKVFDeviceVulkanFunctionPointers();
vkDestroySurfaceKHR(m_instance, surface, nullptr); vkDestroySurfaceKHR(m_instance, surface, nullptr);
FatalError("caca");
} }
#undef MLX_LOAD_FUNCTION #undef MLX_LOAD_FUNCTION
@@ -184,7 +183,7 @@ namespace mlx
MLX_LOAD_FUNCTION(vkDestroySwapchainKHR); MLX_LOAD_FUNCTION(vkDestroySwapchainKHR);
MLX_LOAD_FUNCTION(vkGetSwapchainImagesKHR); MLX_LOAD_FUNCTION(vkGetSwapchainImagesKHR);
MLX_LOAD_FUNCTION(vkQueuePresentKHR); MLX_LOAD_FUNCTION(vkQueuePresentKHR);
kvfPassDeviceVulkanFunctionPointers(m_device, &pfns); kvfPassDeviceVulkanFunctionPointers(m_physical_device, m_device, &pfns);
} }
#undef MLX_LOAD_FUNCTION #undef MLX_LOAD_FUNCTION

20
third_party/kvf.h vendored
View File

@@ -128,7 +128,7 @@ VkDevice kvfCreateDevice(VkPhysicalDevice physical, const char** extensions, uin
VkDevice kvfCreateDefaultDevicePhysicalDeviceAndCustomQueues(VkPhysicalDevice physical, int32_t graphics_queue, int32_t present_queue, int32_t compute_queue); VkDevice kvfCreateDefaultDevicePhysicalDeviceAndCustomQueues(VkPhysicalDevice physical, int32_t graphics_queue, int32_t present_queue, int32_t compute_queue);
VkDevice kvfCreateDeviceCustomPhysicalDeviceAndQueues(VkPhysicalDevice physical, const char** extensions, uint32_t extensions_count, VkPhysicalDeviceFeatures* features, int32_t graphics_queue, int32_t present_queue, int32_t compute_queue); VkDevice kvfCreateDeviceCustomPhysicalDeviceAndQueues(VkPhysicalDevice physical, const char** extensions, uint32_t extensions_count, VkPhysicalDeviceFeatures* features, int32_t graphics_queue, int32_t present_queue, int32_t compute_queue);
#ifdef KVF_IMPL_VK_NO_PROTOTYPES #ifdef KVF_IMPL_VK_NO_PROTOTYPES
void kvfPassDeviceVulkanFunctionPointers(VkDevice device, const KvfDeviceVulkanFunctions* fns); void kvfPassDeviceVulkanFunctionPointers(VkPhysicalDevice physical, VkDevice device, const KvfDeviceVulkanFunctions* fns);
#endif #endif
void kvfDestroyDevice(VkDevice device); void kvfDestroyDevice(VkDevice device);
@@ -1552,7 +1552,9 @@ VkDevice kvfCreateDevice(VkPhysicalDevice physical, const char** extensions, uin
VkDevice device; VkDevice device;
__kvfCheckVk(KVF_GET_INSTANCE_FUNCTION(vkCreateDevice)(physical, &createInfo, NULL, &device)); __kvfCheckVk(KVF_GET_INSTANCE_FUNCTION(vkCreateDevice)(physical, &createInfo, NULL, &device));
__kvfCompleteDevice(physical, device); #ifndef KVF_IMPL_VK_NO_PROTOTYPES
__kvfCompleteDevice(physical, device);
#endif
return device; return device;
} }
@@ -1621,19 +1623,22 @@ VkDevice kvfCreateDeviceCustomPhysicalDeviceAndQueues(VkPhysicalDevice physical,
VkDevice device; VkDevice device;
__kvfCheckVk(KVF_GET_INSTANCE_FUNCTION(vkCreateDevice)(physical, &createInfo, NULL, &device)); __kvfCheckVk(KVF_GET_INSTANCE_FUNCTION(vkCreateDevice)(physical, &createInfo, NULL, &device));
__kvfCompleteDeviceCustomPhysicalDeviceAndQueues(physical, device, graphics_queue, present_queue, compute_queue); #ifndef KVF_IMPL_VK_NO_PROTOTYPES
__kvfCompleteDeviceCustomPhysicalDeviceAndQueues(physical, device, graphics_queue, present_queue, compute_queue);
#endif
return device; return device;
} }
#ifdef KVF_IMPL_VK_NO_PROTOTYPES #ifdef KVF_IMPL_VK_NO_PROTOTYPES
void kvfPassDeviceVulkanFunctionPointers(VkDevice device, const KvfDeviceVulkanFunctions* fns) void kvfPassDeviceVulkanFunctionPointers(VkPhysicalDevice physical, VkDevice device, const KvfDeviceVulkanFunctions* fns)
{ {
KVF_ASSERT(device != VK_NULL_HANDLE); KVF_ASSERT(device != VK_NULL_HANDLE);
KVF_ASSERT(fns != NULL); KVF_ASSERT(fns != NULL);
__KvfDevice* kvf_device = __kvfGetKvfDeviceFromVkDevice(device); __KvfDevice* kvf_device = __kvfGetKvfDeviceFromVkPhysicalDevice(physical);
KVF_ASSERT(kvf_device != NULL); KVF_ASSERT(kvf_device != NULL);
kvf_device->fns = *fns; kvf_device->fns = *fns;
__kvfCompleteDevice(physical, device);
} }
#endif #endif
@@ -2318,10 +2323,9 @@ VkCommandBuffer kvfCreateCommandBufferLeveled(VkDevice device, VkCommandBufferLe
kvf_device->cmd_buffers_capacity += KVF_COMMAND_POOL_CAPACITY; kvf_device->cmd_buffers_capacity += KVF_COMMAND_POOL_CAPACITY;
kvf_device->cmd_buffers = (VkCommandBuffer*)KVF_REALLOC(kvf_device->cmd_buffers, kvf_device->cmd_buffers_capacity * sizeof(VkCommandBuffer)); kvf_device->cmd_buffers = (VkCommandBuffer*)KVF_REALLOC(kvf_device->cmd_buffers, kvf_device->cmd_buffers_capacity * sizeof(VkCommandBuffer));
KVF_ASSERT(kvf_device->cmd_buffers != NULL && "allocation failed :("); KVF_ASSERT(kvf_device->cmd_buffers != NULL && "allocation failed :(");
kvf_device->cmd_buffers[kvf_device->cmd_buffers_size] = buffer;
kvf_device->cmd_buffers_size++;
} }
kvf_device->cmd_buffers[kvf_device->cmd_buffers_size] = buffer;
kvf_device->cmd_buffers_size++;
return buffer; return buffer;
} }