start smashing bugs

This commit is contained in:
Gregory Wells
2025-06-12 11:23:40 -04:00
parent 6c7c6f1b69
commit e0869b9ed3
16 changed files with 141 additions and 99 deletions

View File

@@ -1,6 +1,7 @@
#include "vulkan_debugger.h" #include "vulkan_debugger.h"
#include <instance/vulkan_instance.h> #include <instance/vulkan_instance.h>
#include "core/instance/gryphn_instance.h" #include "core/instance/gryphn_instance.h"
#include "stdio.h"
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT* createInfo) { void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT* createInfo) {
createInfo->sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT; createInfo->sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
@@ -45,33 +46,35 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData) { void* pUserData) {
struct vk_userData_t userData = *(struct vk_userData_t*)pUserData; printf("Debuggger: %s\n", pCallbackData->pMessage);
gnMessageSeverity severity; // struct vk_userData_t userData = *(struct vk_userData_t*)pUserData;
gnMessageType type;
gnMessageData data = {
.message = gnCreateString(pCallbackData->pMessage)
};
switch (messageSeverity) { // gnMessageSeverity severity;
default: break; // gnMessageType type;
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break; // gnMessageData data = {
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; break; // .message = gnCreateString(pCallbackData->pMessage)
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: severity = GN_MESSAGE_WARNING; break; // };
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: severity = GN_MESSAGE_ERROR; break;
}
switch (messageType) { // switch (messageSeverity) {
default: break; // default: break;
case VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: type = GN_DEBUG_MESSAGE_GENERAL; break; // case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
case VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: type = GN_DEBUG_MESSAGE_VALIDATION; break; // case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; break;
case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break; // case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: severity = GN_MESSAGE_WARNING; break;
} // case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: severity = GN_MESSAGE_ERROR; break;
// }
gnDebuggerCallback callback = *userData.debuggerCallback; // switch (messageType) {
gnBool result = callback(severity, type, data, userData.userData); // default: break;
if (result == gnFalse) return VK_FALSE; // case VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: type = GN_DEBUG_MESSAGE_GENERAL; break;
else if (result == gnTrue) return VK_TRUE; // case VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: type = GN_DEBUG_MESSAGE_VALIDATION; break;
// case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break;
// }
// gnDebuggerCallback callback = *userData.debuggerCallback;
// gnBool result = callback(severity, type, data, userData.userData);
// if (result == gnFalse) return VK_FALSE;
// else if (result == gnTrue) return VK_TRUE;
return VK_FALSE; return VK_FALSE;
} }
@@ -115,8 +118,8 @@ gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle inst
} }
} }
if (instance->instance->instanceMessageCount > 0) free(instance->instance->instanceMessages);
instance->instance->instanceMessageCount = 0; instance->instance->instanceMessageCount = 0;
free(instance->instance->instanceMessages);
const char* layers[] = { const char* layers[] = {
"VK_LAYER_KHRONOS_validation" "VK_LAYER_KHRONOS_validation"

View File

@@ -7,55 +7,57 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
VkDebugUtilsMessageTypeFlagsEXT messageType, VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData) { void* pUserData) {
printf("Created instance: %s\n", pCallbackData->pMessage);
gnMessageSeverity severity;
gnMessageType type;
gnMessageData data = {
.message = gnCreateString(pCallbackData->pMessage)
};
switch (messageSeverity) { // gnMessageSeverity severity;
default: break; // gnMessageType type;
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break; // gnMessageData data = {
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; break; // .message = gnCreateString(pCallbackData->pMessage)
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: severity = GN_MESSAGE_WARNING; break; // };
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: severity = GN_MESSAGE_ERROR; break;
}
switch (messageType) { // switch (messageSeverity) {
default: break; // default: break;
case VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: type = GN_DEBUG_MESSAGE_GENERAL; break; // case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
case VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: type = GN_DEBUG_MESSAGE_VALIDATION; break; // case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; break;
case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break; // case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: severity = GN_MESSAGE_WARNING; break;
} // case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: severity = GN_MESSAGE_ERROR; break;
// }
gnInstanceHandle instance = (gnInstanceHandle)pUserData; // switch (messageType) {
// default: break;
// case VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT: type = GN_DEBUG_MESSAGE_GENERAL; break;
// case VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT: type = GN_DEBUG_MESSAGE_VALIDATION; break;
// case VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT: type = GN_DEBUG_MESSAGE_PERFORMANCE; break;
// }
if (instance->debugger) { // gnInstanceHandle instance = (gnInstanceHandle)pUserData;
instance->debugger->info.callback(
severity, type, data, instance->debugger->info.userData // if (instance->debugger) {
); // instance->debugger->info.callback(
} else { // severity, type, data, instance->debugger->info.userData
instance->instance->instanceMessageCount++; // );
if (instance->instance->instanceMessageCount == 1) { // } else {
instance->instance->instanceMessages = malloc(sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount); // instance->instance->instanceMessageCount++;
} // if (instance->instance->instanceMessageCount == 1) {
else { // instance->instance->instanceMessages = malloc(sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
instance->instance->instanceMessages = realloc(instance->instance->instanceMessages, sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount); // }
} // else {
instance->instance->instanceMessages[instance->instance->instanceMessageCount - 1] = (struct gnInstanceMessage){ // instance->instance->instanceMessages = realloc(instance->instance->instanceMessages, sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
.data = data, // }
.severity = severity, // instance->instance->instanceMessages[instance->instance->instanceMessageCount - 1] = (struct gnInstanceMessage){
.type = type // .data = data,
}; // .severity = severity,
} // .type = type
// };
// }
return VK_FALSE; return VK_FALSE;
} }
gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) { gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) {
instance->instance = malloc(sizeof(gnPlatformInstance)); instance->instance = malloc(sizeof(gnPlatformInstance));
instance->instance->instanceMessageCount = 0;
#ifdef GN_PLATFORM_LINUX #ifdef GN_PLATFORM_LINUX
gnBool isX11 = gnTrue; gnBool isX11 = gnTrue;
@@ -89,6 +91,7 @@ gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instan
}; };
#endif #endif
VkApplicationInfo appInfo = { VkApplicationInfo appInfo = {
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.pApplicationName = gnToCString(instanceInfo.applicationName), .pApplicationName = gnToCString(instanceInfo.applicationName),

View File

@@ -1,8 +1,15 @@
#pragma once #pragma once
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#ifdef GN_PLATFORM_MACOS
static const uint32_t deviceExtensionCount = 2; static const uint32_t deviceExtensionCount = 2;
static const char* deviceExtensions[2] = { static const char* deviceExtensions[2] = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_EXTENSION_NAME,
"VK_KHR_portability_subset" "VK_KHR_portability_subset"
}; };
#else
static const uint32_t deviceExtensionCount = 1;
static const char* deviceExtensions[1] = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME
};
#endif

View File

@@ -13,6 +13,7 @@ gnReturnCode gnCreateOutputDeviceFn(gnOutputDeviceHandle outputDevice, gnInstanc
float queuePriority = 1.0f; float queuePriority = 1.0f;
for (int i = 0; i < deviceInfo.queueInfoCount; i++) { for (int i = 0; i < deviceInfo.queueInfoCount; i++) {
queueCreateInfos[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; queueCreateInfos[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueCreateInfos[i].flags = 0;
queueCreateInfos[i].queueFamilyIndex = deviceInfo.queueInfos[i].queueIndex; queueCreateInfos[i].queueFamilyIndex = deviceInfo.queueInfos[i].queueIndex;
queueCreateInfos[i].queueCount = deviceInfo.queueInfos[i].queueCount; queueCreateInfos[i].queueCount = deviceInfo.queueInfos[i].queueCount;
queueCreateInfos[i].pQueuePriorities = &queuePriority; queueCreateInfos[i].pQueuePriorities = &queuePriority;

View File

@@ -73,9 +73,10 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueueHandle presentationQ
createInfo.clipped = VK_TRUE; createInfo.clipped = VK_TRUE;
createInfo.oldSwapchain = VK_NULL_HANDLE; createInfo.oldSwapchain = VK_NULL_HANDLE;
if (vkCreateSwapchainKHR(device->outputDevice->device, &createInfo, NULL, &presentationQueue->presentationQueue->swapChain) != VK_SUCCESS) { VkResult result = vkCreateSwapchainKHR(device->outputDevice->device, &createInfo, NULL, &presentationQueue->presentationQueue->swapChain);
if (result == VK_ERROR_NATIVE_WINDOW_IN_USE_KHR) return GN_WINDOW_IN_USE;
if (result != VK_SUCCESS)
return GN_FAILED_TO_CREATE_PRESENTATION_QUEUE; return GN_FAILED_TO_CREATE_PRESENTATION_QUEUE;
}
vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, NULL); vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, NULL);
presentationQueue->presentationQueue->swapChainImages = malloc(sizeof(VkImage) * presentationQueue->imageCount); presentationQueue->presentationQueue->swapChainImages = malloc(sizeof(VkImage) * presentationQueue->imageCount);

View File

@@ -1,6 +1,7 @@
#include "vulkan_render_pass_descriptor.h" #include "vulkan_render_pass_descriptor.h"
#include "vulkan_surface/vulkan_surface.h" #include "vulkan_surface/vulkan_surface.h"
#include "output_device/vulkan_output_devices.h" #include "output_device/vulkan_output_devices.h"
#include "stdio.h"
VkAttachmentLoadOp vkGryphnLoadOperation(gnLoadOperation loadOperation) { VkAttachmentLoadOp vkGryphnLoadOperation(gnLoadOperation loadOperation) {
switch(loadOperation) { switch(loadOperation) {
@@ -32,6 +33,7 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
VkAttachmentDescription* attachments = malloc(sizeof(VkAttachmentDescription) * info.attachmentCount); VkAttachmentDescription* attachments = malloc(sizeof(VkAttachmentDescription) * info.attachmentCount);
for (int i = 0; i < info.attachmentCount; i++) { for (int i = 0; i < info.attachmentCount; i++) {
attachments[i].format = vkGryphnFormatToVulkanFormat(info.attachmentInfos[i].format); attachments[i].format = vkGryphnFormatToVulkanFormat(info.attachmentInfos[i].format);
attachments[i].flags = 0;
attachments[i].samples = VK_SAMPLE_COUNT_1_BIT; attachments[i].samples = VK_SAMPLE_COUNT_1_BIT;
attachments[i].loadOp = vkGryphnLoadOperation(info.attachmentInfos[i].loadOperation); attachments[i].loadOp = vkGryphnLoadOperation(info.attachmentInfos[i].loadOperation);
@@ -45,16 +47,30 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
} }
VkSubpassDescription* subpasses = malloc(sizeof(VkSubpassDescription) * info.subpassCount); VkSubpassDescription* subpasses = malloc(sizeof(VkSubpassDescription) * info.subpassCount);
VkAttachmentReference** colorAttachments = malloc(sizeof(VkAttachmentReference*) * info.subpassCount);
VkAttachmentReference ref = {
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
};
for (int i = 0; i < info.subpassCount; i++) { for (int i = 0; i < info.subpassCount; i++) {
subpasses[i].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; colorAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
subpasses[i].colorAttachmentCount = info.subpassInfos[i].colorAttachmentCount;
VkAttachmentReference* colorAttachments = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
for (int c = 0; c < info.subpassInfos[i].colorAttachmentCount; c++) { for (int c = 0; c < info.subpassInfos[i].colorAttachmentCount; c++) {
colorAttachments[c].attachment = info.subpassInfos[i].colorAttachments[c].index; colorAttachments[i][c] = (VkAttachmentReference){
colorAttachments[c].layout = vkGryphnImageLayout(info.subpassInfos[i].colorAttachments[c].imageLayout); .attachment = info.subpassInfos[i].colorAttachments[c].index,
.layout = vkGryphnImageLayout(info.subpassInfos[i].colorAttachments[c].imageLayout)
};
} }
subpasses[i].pColorAttachments = colorAttachments;
subpasses[i] = (VkSubpassDescription){
.flags = 0,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.colorAttachmentCount = info.subpassInfos[i].colorAttachmentCount,
.pColorAttachments = colorAttachments[i]
};
} }
VkSubpassDependency* dependencies = malloc(sizeof(VkSubpassDependency) * info.dependencyCount); VkSubpassDependency* dependencies = malloc(sizeof(VkSubpassDependency) * info.dependencyCount);
@@ -71,20 +87,22 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
VkRenderPassCreateInfo renderPassInfo = (VkRenderPassCreateInfo) { VkRenderPassCreateInfo renderPassInfo = (VkRenderPassCreateInfo) {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
.pNext = NULL,
.flags = 0,
.attachmentCount = info.attachmentCount, .attachmentCount = info.attachmentCount,
.pAttachments = attachments, .pAttachments = attachments,
.subpassCount = info.subpassCount, .subpassCount = info.subpassCount,
.pSubpasses = subpasses, .pSubpasses = subpasses,
.dependencyCount = info.dependencyCount, .dependencyCount = info.dependencyCount,
.pDependencies = dependencies .pDependencies = dependencies,
}; };
if (vkCreateRenderPass(device->outputDevice->device, &renderPassInfo, NULL, &renderPass->renderPassDescriptor->renderPass) != VK_SUCCESS) { if (vkCreateRenderPass(device->outputDevice->device, &renderPassInfo, NULL, &renderPass->renderPassDescriptor->renderPass) != VK_SUCCESS)
return GN_FAILED_TO_CREATE_RENDER_PASS; return GN_FAILED_TO_CREATE_RENDER_PASS;
}
free(attachments); free(attachments);
free(subpasses); free(subpasses);
free(dependencies);
return GN_SUCCESS; return GN_SUCCESS;
} }

View File

@@ -1,5 +1,6 @@
#include "vulkan_shader_module.h" #include "vulkan_shader_module.h"
#include "output_device/vulkan_output_devices.h" #include "output_device/vulkan_output_devices.h"
#include "stdio.h"
VkShaderStageFlagBits vkGryphnShaderModuleStage(gnShaderModuleStage stage) { VkShaderStageFlagBits vkGryphnShaderModuleStage(gnShaderModuleStage stage) {
VkShaderStageFlagBits outStage = 0; VkShaderStageFlagBits outStage = 0;
@@ -11,17 +12,17 @@ VkShaderStageFlagBits vkGryphnShaderModuleStage(gnShaderModuleStage stage) {
return outStage; return outStage;
} }
gnReturnCode gnCreateShaderModuleFn(struct gnShaderModule_t *module, struct gnOutputDevice_t *device, struct gnShaderModuleInfo_t shaderModuleInfo) { gnReturnCode gnCreateShaderModuleFn(gnShaderModule module, gnDevice device, gnShaderModuleInfo shaderModuleInfo) {
module->shaderModule = malloc(sizeof(struct gnPlatformShaderModule_t)); module->shaderModule = malloc(sizeof(struct gnPlatformShaderModule_t));
VkShaderModuleCreateInfo createInfo = {}; VkShaderModuleCreateInfo createInfo = {
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
createInfo.codeSize = shaderModuleInfo.size; .codeSize = shaderModuleInfo.size,
createInfo.pCode = shaderModuleInfo.code; .pCode = shaderModuleInfo.code
};
if (vkCreateShaderModule(device->outputDevice->device, &createInfo, NULL, &module->shaderModule->shaderModule) != VK_SUCCESS) { if (vkCreateShaderModule(device->outputDevice->device, &createInfo, NULL, &module->shaderModule->shaderModule) != VK_SUCCESS)
return GN_FAILED_TO_CREATE_SHADER_MODULE; return GN_FAILED_TO_CREATE_SHADER_MODULE;
}
module->shaderModule->shaderStageInfo = (VkPipelineShaderStageCreateInfo){ module->shaderModule->shaderStageInfo = (VkPipelineShaderStageCreateInfo){
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,

View File

@@ -7,6 +7,7 @@ gnReturnCode gnCommandPoolAllocateCommandBuffers(gnCommandBufferHandle* buffers,
buffers[i] = malloc(sizeof(struct gnCommandBuffer_t)); buffers[i] = malloc(sizeof(struct gnCommandBuffer_t));
buffers[i]->commandPool = commandPool; buffers[i]->commandPool = commandPool;
} }
printf("Created the graphics pipeline: %p\n", commandPool->commandFunctions->_gnCommandBindGraphicsPipeline);
return commandPool->commandFunctions->_gnCommandPoolAllocateCommandBuffers(buffers, count, commandPool); return commandPool->commandFunctions->_gnCommandPoolAllocateCommandBuffers(buffers, count, commandPool);
} }

View File

@@ -6,7 +6,7 @@
#include "output_device/gryphn_physical_output_device.h" #include "output_device/gryphn_physical_output_device.h"
#include "output_device/gryphn_output_device.h" #include "output_device/gryphn_output_device.h"
#include "window_surface/gryphn_surface.h" #include "window_surface/gryphn_surface.h"
#include "window_surface/gryphn_surface_create_functions.h" #include <core/window_surface/gryphn_surface_create_functions.h>
#include "shader_module/gryphn_shader_module.h" #include "shader_module/gryphn_shader_module.h"
#include "renderpass/gryphn_render_pass_descriptor.h" #include "renderpass/gryphn_render_pass_descriptor.h"
#include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h" #include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
@@ -34,10 +34,9 @@ typedef struct gnFunctions_t {
void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device); void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device);
#ifdef GN_PLATFORM_LINUX #ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11 #ifdef GN_WINDOW_X11
gnReturnCode (*_gnCreateX11WindowSurface)(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, struct gnX11WindowSurfaceInfo_t createInfo); gnReturnCode (*_gnCreateX11WindowSurface)(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, gnX11WindowSurfaceInfo createInfo);
#endif #endif
#ifdef GN_WINDOW_WAYLAND #ifdef GN_WINDOW_WAYLAND
gnReturnCode (*_gnCreateWaylandWindowSurface)(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, struct gnWaylandWindowSurfaceInfo_t createInfo); gnReturnCode (*_gnCreateWaylandWindowSurface)(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, struct gnWaylandWindowSurfaceInfo_t createInfo);

View File

@@ -3,8 +3,10 @@
#include <core/gryphn_platform_functions.h> #include <core/gryphn_platform_functions.h>
#include "core/debugger/gryphn_debugger.h" #include "core/debugger/gryphn_debugger.h"
#include "core/instance/gryphn_instance.h" #include "core/instance/gryphn_instance.h"
#include "stdio.h"
gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInstanceInfo_t info) { gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInstanceInfo_t info) {
*instanceHandlePtr = malloc(sizeof(struct gnInstance_t)); *instanceHandlePtr = malloc(sizeof(struct gnInstance_t));
gnInstanceHandle instance = *instanceHandlePtr; gnInstanceHandle instance = *instanceHandlePtr;
@@ -14,10 +16,14 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInst
instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI); instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI);
if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY; if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY;
instance->functions = malloc(sizeof(struct gnFunctions_t)); instance->functions = malloc(sizeof(struct gnFunctions_t));
instance->loadCommandFunctions = gnFalse;
instance->loadDeviceFunctions = gnFalse;
gnLoadFunctions(instance->dynamicLib, instance->functions); gnLoadFunctions(instance->dynamicLib, instance->functions);
return instance->functions->_gnCreateInstance(instance, info); return instance->functions->_gnCreateInstance(instance, info);
} }
void gnInstanceAttachDebugger(gnInstanceHandle instance, struct gnDebugger_t *debugger) { void gnInstanceAttachDebugger(gnInstanceHandle instance, struct gnDebugger_t *debugger) {
if (instance->debugger != NULL) { if (instance->debugger != NULL) {
gnDebuggerSetErrorMessage(debugger, (gnMessageData){ gnDebuggerSetErrorMessage(debugger, (gnMessageData){
.message = gnCreateString("Debugger already attached to instance") .message = gnCreateString("Debugger already attached to instance")

View File

@@ -3,7 +3,6 @@
gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info) { gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info) {
*renderPass = malloc(sizeof(struct gnRenderPassDescriptor_t)); *renderPass = malloc(sizeof(struct gnRenderPassDescriptor_t));
(*renderPass)->device = device; (*renderPass)->device = device;
(*renderPass)->info = info; (*renderPass)->info = info;
return device->deviceFunctions->_gnCreateRenderPassDescriptor(*renderPass, device, info); return device->deviceFunctions->_gnCreateRenderPassDescriptor(*renderPass, device, info);

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include "utils/gryphn_image_format.h"
#include "stdint.h" #include "stdint.h"
#include "core/output_device/gryphn_output_device.h" #include "utils/gryphn_image_format.h"
#include "utils/gryphn_error_code.h"
#include "core/gryphn_handles.h" #include "core/gryphn_handles.h"
typedef enum gnRenderPassStage_e { typedef enum gnRenderPassStage_e {

View File

@@ -1,12 +1,10 @@
#define GN_WINDOW_X11
#include "gryphn_surface_create_functions.h" #include "gryphn_surface_create_functions.h"
#include "core/instance/gryphn_instance.h" #include "core/instance/gryphn_instance.h"
#include "core/gryphn_platform_functions.h" #include "core/gryphn_platform_functions.h"
#include "stdio.h"
#ifdef GN_PLATFORM_LINUX #ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11 #ifdef GN_WINDOW_X11
gnReturnCode gnCreateX11WindowSurface(gnWindowSurfaceHandle* windowSurface, gnInstanceHandle instance, struct gnX11WindowSurfaceInfo_t createInfo) { gnReturnCode gnCreateX11WindowSurface(gnWindowSurfaceHandle* windowSurface, gnInstanceHandle instance, gnX11WindowSurfaceInfo createInfo) {
*windowSurface = malloc(sizeof(struct gnWindowSurface_t)); *windowSurface = malloc(sizeof(struct gnWindowSurface_t));
(*windowSurface)->instance = instance; (*windowSurface)->instance = instance;
return instance->functions->_gnCreateX11WindowSurface(*windowSurface, instance, createInfo); return instance->functions->_gnCreateX11WindowSurface(*windowSurface, instance, createInfo);

View File

@@ -1,11 +1,15 @@
#pragma once #pragma once
#ifndef GN_WINDOW_X11
#define GN_WINDOW_X11
#endif
#include <platform/gryphn_platform_include.h> #include <platform/gryphn_platform_include.h>
#include "core/gryphn_handles.h" #include <core/gryphn_handles.h>
#include "utils/gryphn_error_code.h" #include <utils/gryphn_error_code.h>
#ifdef GN_PLATFORM_LINUX #ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11 #ifdef GN_WINDOW_X11
typedef struct gnX11WindowSurfaceInfo_t { typedef struct gnX11WindowSurfaceInfo {
Display* display; Display* display;
Window window; Window window;
} gnX11WindowSurfaceInfo; } gnX11WindowSurfaceInfo;

View File

@@ -2,7 +2,7 @@
#include "core/gryphn_rendering_api.h" #include "core/gryphn_rendering_api.h"
#ifdef GN_PLATFORM_LINUX #ifdef GN_PLATFORM_LINUX
#include "platform_linux/gryphn_platform_linux.h" #include <platform/platform_linux/gryphn_platform_linux.h>
#endif #endif
#ifdef GN_PLATFORM_MACOS #ifdef GN_PLATFORM_MACOS

View File

@@ -1,7 +1,8 @@
#ifdef GN_WINDOW_X11 #pragma once
#include <X11/Xlib.h> #include <X11/Xlib.h>
#endif // #ifdef GN_WINDOW_X11
// #endif
#ifdef GN_WINDOW_WAYLAND // #ifdef GN_WINDOW_WAYLAND
#include <wayland-client.h> // #include <wayland-client.h>
#endif // #endif