fix a lot of things

This commit is contained in:
Gregory Wells
2025-08-03 10:27:30 -04:00
parent 8a0ed5e7be
commit 9d0f42731b
9 changed files with 38 additions and 25 deletions

View File

@@ -2,7 +2,6 @@
#include "buffers/gryphn_buffer.h"
#include "output_device/gryphn_output_device.h"
#include "output_device/vulkan_output_devices.h"
#include "output_device/vulkan_physical_device.h"
#include <vulkan_result_converter.h>
VkBufferUsageFlags vkGryphnBufferType(gnBufferType type) {
@@ -49,7 +48,7 @@ gnReturnCode VkCreateBuffer(
VkMemoryAllocateInfo memoryAllocateInfo = {
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.allocationSize = bufferRequirements.size,
.memoryTypeIndex = VkMemoryIndex(device->physicalDevice->physicalDevice->device, bufferRequirements.memoryTypeBits, flags, &foundMemory)
.memoryTypeIndex = VkMemoryIndex(device->outputDevice->physicalDevice, bufferRequirements.memoryTypeBits, flags, &foundMemory)
};
if (!foundMemory) return GN_FAILED_TO_ALLOCATE_MEMORY;

View File

@@ -9,7 +9,7 @@
gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue, const gnDevice device, gnPresentationQueueInfo presentationInfo) {
presentationQueue->presentationQueue = malloc(sizeof(struct gnPlatformPresentationQueue_t));
vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->physicalDevice->physicalDevice->device, presentationInfo.surface->windowSurface->surface);
vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->outputDevice->physicalDevice, presentationInfo.surface->windowSurface->surface);
VkFormat convertedFormat = vkGryphnFormatToVulkanFormat(presentationInfo.format.format);
VkColorSpaceKHR convertedColorSpace = vkGryphnColorSpaceToVulkanColorSpace(presentationInfo.format.colorSpace);

View File

@@ -182,7 +182,7 @@ gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureIn
VkMemoryAllocateInfo allocInfo = {
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.allocationSize = memRequirements.size,
.memoryTypeIndex = VkMemoryIndex(device->physicalDevice->physicalDevice->device, memRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &foundMemory)
.memoryTypeIndex = VkMemoryIndex(device->outputDevice->physicalDevice, memRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &foundMemory)
};
if (!foundMemory) return GN_FAILED_TO_ALLOCATE_MEMORY;
@@ -209,7 +209,7 @@ gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureIn
if (image_view != VK_SUCCESS) return VkResultToGnReturnCode(image_view);
VkPhysicalDeviceProperties properties = {};
vkGetPhysicalDeviceProperties(device->physicalDevice->physicalDevice->device, &properties);
vkGetPhysicalDeviceProperties(device->outputDevice->physicalDevice, &properties);
VkSamplerCreateInfo samplerInfo = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,

View File

@@ -139,6 +139,7 @@ loaderLayer null_layer() {
loaderLayer api_loaded_layer(gnRenderingAPI api) {
return (loaderLayer){
.instanceFunctions = loadAPIInstanceFunctions(api),
.deviceFunctions = loadAPIDeviceFunctions(api),
.commandFunctions = loadAPICommandFunctions(api),
};
@@ -146,6 +147,7 @@ loaderLayer api_loaded_layer(gnRenderingAPI api) {
loaderLayer function_check_layer() {
return (loaderLayer){
.instanceFunctions = loadFunctionLoaderInstanceFunctions(),
.deviceFunctions = loadFunctionLoaderDeviceFunctions(),
.commandFunctions = loadFunctionLoaderCommandFunctions(),

View File

@@ -4,7 +4,6 @@
#include "gryphn_command_functions.h"
#include "gryphn_loader_info.h"
#include "utils/lists/gryphn_array_list.h"
#include <Dispatcher/dispatcher.h>
#include "extensions/synchronization/loader/sync_functions.h"
#include "extensions/queues/queues_functions.h"
@@ -25,8 +24,7 @@ typedef struct loaderLayer {
// they used to be loaded seperatly but I guess there not anymore
// initlization is hard
// gnInstanceFunctions instanceFunctions;
gnInstanceFunctions instanceFunctions;
gnDeviceFunctions deviceFunctions;
gnCommandFunctions commandFunctions;

View File

@@ -5,11 +5,15 @@
#include "extensions/sync_functions.h"
#include "extensions/queue_functions.h"
gryphnInstanceFunctionLayers checkerLoadInstanceFunctions() {
return (gryphnInstanceFunctionLayers) {
.createInstance = { checkCreateInstance, NULL },
.destroyInstance = { checkDestroyInstance, NULL }
};
}
gnInstanceFunctions loadFunctionLoaderInstanceFunctions() {
return (gnInstanceFunctions){
._gnCreateInstance = checkCreateInstance,
._gnDestroyInstance = checkDestroyInstance,
._gnGetPhysicalDevices = checkGetPhysicalDevices,
._gnPhysicalDeviceCanPresentToSurface = checkCanDevicePresent,

View File

@@ -4,12 +4,23 @@
#include "core/src/output_device/gryphn_output_device.h"
#include "core/src/window_surface/gryphn_surface.h"
gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info) {
CHECK_FUNCTION_WITH_RETURN_CODE(instance, _gnCreateInstance, instanceFunctions, instance, info);
gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnFunctionLayer* next) {
if (next->function == NULL) {
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
.message = gnCreateString("Failed to load gnCreateInstance this indicates a bug within gryphn")
});
return GN_FAILED_TO_LOAD_FUNCTION;
}
return (*(PFN_gnCreateInstance*)next->function)(instance, info, next->next);
}
void checkDestroyInstance(gnInstance instance) {
CHECK_VOID_FUNCTION(instance, _gnDestroyInstance, instanceFunctions, instance);
void checkDestroyInstance(gnInstanceHandle instance, gryphnFunctionLayer* next) {
if (next->function == NULL) {
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
.message = gnCreateString("Failed to load gnDestroyInstance this indicates a bug within gryphn")
});
}
(*(PFN_gnDestroyInstance*)next->function)(instance, next->next);
}
gnPhysicalDevice* checkGetPhysicalDevices(gnInstanceHandle instance, uint32_t* count) {
@@ -19,11 +30,11 @@ gnBool checkCanDevicePresent(gnPhysicalDevice device, gnWindowSurfaceHandle wind
CHECK_RETURNED_FUNCTION(device->instance, _gnPhysicalDeviceCanPresentToSurface, instanceFunctions, GN_FALSE, device, windowSurface);
}
gnReturnCode checkCreateOutputDevice(gnOutputDeviceHandle device, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo) {
CHECK_FUNCTION_WITH_RETURN_CODE(instance, _gnCreateOutputDevice, instanceFunctions, device, instance, deviceInfo);
gnReturnCode checkCreateOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo) {
CHECK_FUNCTION_WITH_RETURN_CODE(instance, _gnCreateOutputDevice, instanceFunctions, instance, device, deviceInfo);
}
void checkDestroyOutputDevice(gnOutputDeviceHandle device) {
CHECK_VOID_FUNCTION(device->instance, _gnDestroyOutputDevice, instanceFunctions, device);
void checkDestroyOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device) {
CHECK_VOID_FUNCTION(device->instance, _gnDestroyOutputDevice, instanceFunctions, instance, device);
}
#ifdef GN_PLATFORM_MACOS

View File

@@ -2,14 +2,14 @@
#include "core/src/instance/gryphn_instance.h"
#include <core/src/window_surface/gryphn_surface_create_functions.h>
gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info);
void checkDestroyInstance(gnInstance instance);
gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnFunctionLayer* next);
void checkDestroyInstance(gnInstanceHandle instance, gryphnFunctionLayer* next);
gnPhysicalDevice* checkGetPhysicalDevices(gnInstanceHandle instance, uint32_t* count);
gnBool checkCanDevicePresent(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
gnReturnCode checkCreateOutputDevice(gnOutputDeviceHandle device, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo);
void checkDestroyOutputDevice(gnOutputDeviceHandle device);
gnReturnCode checkCreateOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo);
void checkDestroyOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device);
#ifdef GN_PLATFORM_MACOS
gnReturnCode checkCreateSurfaceMacOS(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, gnMacOSWindowSurfaceInfo createInfo);