start smashing bugs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "vulkan_debugger.h"
|
||||
#include <instance/vulkan_instance.h>
|
||||
#include "core/instance/gryphn_instance.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT* createInfo) {
|
||||
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,
|
||||
void* pUserData) {
|
||||
|
||||
struct vk_userData_t userData = *(struct vk_userData_t*)pUserData;
|
||||
printf("Debuggger: %s\n", pCallbackData->pMessage);
|
||||
|
||||
gnMessageSeverity severity;
|
||||
gnMessageType type;
|
||||
gnMessageData data = {
|
||||
.message = gnCreateString(pCallbackData->pMessage)
|
||||
};
|
||||
// struct vk_userData_t userData = *(struct vk_userData_t*)pUserData;
|
||||
|
||||
switch (messageSeverity) {
|
||||
default: break;
|
||||
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
|
||||
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; 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;
|
||||
}
|
||||
// gnMessageSeverity severity;
|
||||
// gnMessageType type;
|
||||
// gnMessageData data = {
|
||||
// .message = gnCreateString(pCallbackData->pMessage)
|
||||
// };
|
||||
|
||||
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;
|
||||
}
|
||||
// switch (messageSeverity) {
|
||||
// default: break;
|
||||
// case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
|
||||
// case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; 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;
|
||||
gnBool result = callback(severity, type, data, userData.userData);
|
||||
if (result == gnFalse) return VK_FALSE;
|
||||
else if (result == gnTrue) return VK_TRUE;
|
||||
// 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;
|
||||
// }
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -115,8 +118,8 @@ gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle inst
|
||||
}
|
||||
}
|
||||
|
||||
if (instance->instance->instanceMessageCount > 0) free(instance->instance->instanceMessages);
|
||||
instance->instance->instanceMessageCount = 0;
|
||||
free(instance->instance->instanceMessages);
|
||||
|
||||
const char* layers[] = {
|
||||
"VK_LAYER_KHRONOS_validation"
|
||||
|
@@ -7,55 +7,57 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
|
||||
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||
void* pUserData) {
|
||||
printf("Created instance: %s\n", pCallbackData->pMessage);
|
||||
|
||||
gnMessageSeverity severity;
|
||||
gnMessageType type;
|
||||
gnMessageData data = {
|
||||
.message = gnCreateString(pCallbackData->pMessage)
|
||||
};
|
||||
|
||||
switch (messageSeverity) {
|
||||
default: break;
|
||||
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
|
||||
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; 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;
|
||||
}
|
||||
// gnMessageSeverity severity;
|
||||
// gnMessageType type;
|
||||
// gnMessageData data = {
|
||||
// .message = gnCreateString(pCallbackData->pMessage)
|
||||
// };
|
||||
|
||||
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;
|
||||
}
|
||||
// switch (messageSeverity) {
|
||||
// default: break;
|
||||
// case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: severity = GN_MESSAGE_VERBOSE; break;
|
||||
// case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: severity = GN_MESSAGE_INFO; 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) {
|
||||
instance->debugger->info.callback(
|
||||
severity, type, data, instance->debugger->info.userData
|
||||
);
|
||||
} else {
|
||||
instance->instance->instanceMessageCount++;
|
||||
if (instance->instance->instanceMessageCount == 1) {
|
||||
instance->instance->instanceMessages = malloc(sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
|
||||
}
|
||||
else {
|
||||
instance->instance->instanceMessages = realloc(instance->instance->instanceMessages, sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
|
||||
}
|
||||
instance->instance->instanceMessages[instance->instance->instanceMessageCount - 1] = (struct gnInstanceMessage){
|
||||
.data = data,
|
||||
.severity = severity,
|
||||
.type = type
|
||||
};
|
||||
}
|
||||
// gnInstanceHandle instance = (gnInstanceHandle)pUserData;
|
||||
|
||||
// if (instance->debugger) {
|
||||
// instance->debugger->info.callback(
|
||||
// severity, type, data, instance->debugger->info.userData
|
||||
// );
|
||||
// } else {
|
||||
// instance->instance->instanceMessageCount++;
|
||||
// if (instance->instance->instanceMessageCount == 1) {
|
||||
// instance->instance->instanceMessages = malloc(sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
|
||||
// }
|
||||
// else {
|
||||
// instance->instance->instanceMessages = realloc(instance->instance->instanceMessages, sizeof(struct gnInstanceMessage) * instance->instance->instanceMessageCount);
|
||||
// }
|
||||
// instance->instance->instanceMessages[instance->instance->instanceMessageCount - 1] = (struct gnInstanceMessage){
|
||||
// .data = data,
|
||||
// .severity = severity,
|
||||
// .type = type
|
||||
// };
|
||||
// }
|
||||
|
||||
return VK_FALSE;
|
||||
}
|
||||
|
||||
gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) {
|
||||
instance->instance = malloc(sizeof(gnPlatformInstance));
|
||||
|
||||
instance->instance->instanceMessageCount = 0;
|
||||
|
||||
#ifdef GN_PLATFORM_LINUX
|
||||
gnBool isX11 = gnTrue;
|
||||
@@ -89,6 +91,7 @@ gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instan
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
VkApplicationInfo appInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||
.pApplicationName = gnToCString(instanceInfo.applicationName),
|
||||
|
@@ -1,8 +1,15 @@
|
||||
#pragma once
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#ifdef GN_PLATFORM_MACOS
|
||||
static const uint32_t deviceExtensionCount = 2;
|
||||
static const char* deviceExtensions[2] = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||
"VK_KHR_portability_subset"
|
||||
};
|
||||
#else
|
||||
static const uint32_t deviceExtensionCount = 1;
|
||||
static const char* deviceExtensions[1] = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
||||
};
|
||||
#endif
|
||||
|
@@ -13,6 +13,7 @@ gnReturnCode gnCreateOutputDeviceFn(gnOutputDeviceHandle outputDevice, gnInstanc
|
||||
float queuePriority = 1.0f;
|
||||
for (int i = 0; i < deviceInfo.queueInfoCount; i++) {
|
||||
queueCreateInfos[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||
queueCreateInfos[i].flags = 0;
|
||||
queueCreateInfos[i].queueFamilyIndex = deviceInfo.queueInfos[i].queueIndex;
|
||||
queueCreateInfos[i].queueCount = deviceInfo.queueInfos[i].queueCount;
|
||||
queueCreateInfos[i].pQueuePriorities = &queuePriority;
|
||||
|
@@ -73,9 +73,10 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueueHandle presentationQ
|
||||
createInfo.clipped = VK_TRUE;
|
||||
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;
|
||||
}
|
||||
|
||||
vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, NULL);
|
||||
presentationQueue->presentationQueue->swapChainImages = malloc(sizeof(VkImage) * presentationQueue->imageCount);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "vulkan_render_pass_descriptor.h"
|
||||
#include "vulkan_surface/vulkan_surface.h"
|
||||
#include "output_device/vulkan_output_devices.h"
|
||||
#include "stdio.h"
|
||||
|
||||
VkAttachmentLoadOp vkGryphnLoadOperation(gnLoadOperation loadOperation) {
|
||||
switch(loadOperation) {
|
||||
@@ -32,6 +33,7 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
|
||||
VkAttachmentDescription* attachments = malloc(sizeof(VkAttachmentDescription) * info.attachmentCount);
|
||||
for (int i = 0; i < info.attachmentCount; i++) {
|
||||
attachments[i].format = vkGryphnFormatToVulkanFormat(info.attachmentInfos[i].format);
|
||||
attachments[i].flags = 0;
|
||||
attachments[i].samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
|
||||
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);
|
||||
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++) {
|
||||
subpasses[i].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
subpasses[i].colorAttachmentCount = info.subpassInfos[i].colorAttachmentCount;
|
||||
VkAttachmentReference* colorAttachments = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
|
||||
colorAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
|
||||
|
||||
for (int c = 0; c < info.subpassInfos[i].colorAttachmentCount; c++) {
|
||||
colorAttachments[c].attachment = info.subpassInfos[i].colorAttachments[c].index;
|
||||
colorAttachments[c].layout = vkGryphnImageLayout(info.subpassInfos[i].colorAttachments[c].imageLayout);
|
||||
colorAttachments[i][c] = (VkAttachmentReference){
|
||||
.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);
|
||||
@@ -71,20 +87,22 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
|
||||
|
||||
VkRenderPassCreateInfo renderPassInfo = (VkRenderPassCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
.flags = 0,
|
||||
.attachmentCount = info.attachmentCount,
|
||||
.pAttachments = attachments,
|
||||
.subpassCount = info.subpassCount,
|
||||
.pSubpasses = subpasses,
|
||||
.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;
|
||||
}
|
||||
|
||||
free(attachments);
|
||||
free(subpasses);
|
||||
free(dependencies);
|
||||
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include "vulkan_shader_module.h"
|
||||
#include "output_device/vulkan_output_devices.h"
|
||||
#include "stdio.h"
|
||||
|
||||
VkShaderStageFlagBits vkGryphnShaderModuleStage(gnShaderModuleStage stage) {
|
||||
VkShaderStageFlagBits outStage = 0;
|
||||
@@ -11,17 +12,17 @@ VkShaderStageFlagBits vkGryphnShaderModuleStage(gnShaderModuleStage stage) {
|
||||
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));
|
||||
|
||||
VkShaderModuleCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
createInfo.codeSize = shaderModuleInfo.size;
|
||||
createInfo.pCode = shaderModuleInfo.code;
|
||||
VkShaderModuleCreateInfo createInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
||||
.codeSize = shaderModuleInfo.size,
|
||||
.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;
|
||||
}
|
||||
|
||||
module->shaderModule->shaderStageInfo = (VkPipelineShaderStageCreateInfo){
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
|
@@ -7,6 +7,7 @@ gnReturnCode gnCommandPoolAllocateCommandBuffers(gnCommandBufferHandle* buffers,
|
||||
buffers[i] = malloc(sizeof(struct gnCommandBuffer_t));
|
||||
buffers[i]->commandPool = commandPool;
|
||||
}
|
||||
printf("Created the graphics pipeline: %p\n", commandPool->commandFunctions->_gnCommandBindGraphicsPipeline);
|
||||
return commandPool->commandFunctions->_gnCommandPoolAllocateCommandBuffers(buffers, count, commandPool);
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include "output_device/gryphn_physical_output_device.h"
|
||||
#include "output_device/gryphn_output_device.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 "renderpass/gryphn_render_pass_descriptor.h"
|
||||
#include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
|
||||
@@ -34,10 +34,9 @@ typedef struct gnFunctions_t {
|
||||
void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device);
|
||||
|
||||
|
||||
|
||||
#ifdef GN_PLATFORM_LINUX
|
||||
#ifdef GN_WINDOW_X11
|
||||
gnReturnCode (*_gnCreateX11WindowSurface)(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, struct gnX11WindowSurfaceInfo_t createInfo);
|
||||
gnReturnCode (*_gnCreateX11WindowSurface)(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, gnX11WindowSurfaceInfo createInfo);
|
||||
#endif
|
||||
#ifdef GN_WINDOW_WAYLAND
|
||||
gnReturnCode (*_gnCreateWaylandWindowSurface)(gnWindowSurfaceHandle windowSurface, gnInstanceHandle instance, struct gnWaylandWindowSurfaceInfo_t createInfo);
|
||||
|
@@ -3,8 +3,10 @@
|
||||
#include <core/gryphn_platform_functions.h>
|
||||
#include "core/debugger/gryphn_debugger.h"
|
||||
#include "core/instance/gryphn_instance.h"
|
||||
#include "stdio.h"
|
||||
|
||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInstanceInfo_t info) {
|
||||
|
||||
*instanceHandlePtr = malloc(sizeof(struct gnInstance_t));
|
||||
gnInstanceHandle instance = *instanceHandlePtr;
|
||||
|
||||
@@ -14,10 +16,14 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, struct gnInst
|
||||
instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI);
|
||||
if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY;
|
||||
instance->functions = malloc(sizeof(struct gnFunctions_t));
|
||||
instance->loadCommandFunctions = gnFalse;
|
||||
instance->loadDeviceFunctions = gnFalse;
|
||||
gnLoadFunctions(instance->dynamicLib, instance->functions);
|
||||
return instance->functions->_gnCreateInstance(instance, info);
|
||||
}
|
||||
void gnInstanceAttachDebugger(gnInstanceHandle instance, struct gnDebugger_t *debugger) {
|
||||
|
||||
|
||||
if (instance->debugger != NULL) {
|
||||
gnDebuggerSetErrorMessage(debugger, (gnMessageData){
|
||||
.message = gnCreateString("Debugger already attached to instance")
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info) {
|
||||
*renderPass = malloc(sizeof(struct gnRenderPassDescriptor_t));
|
||||
|
||||
(*renderPass)->device = device;
|
||||
(*renderPass)->info = info;
|
||||
return device->deviceFunctions->_gnCreateRenderPassDescriptor(*renderPass, device, info);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "utils/gryphn_image_format.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"
|
||||
|
||||
typedef enum gnRenderPassStage_e {
|
||||
|
@@ -1,12 +1,10 @@
|
||||
#define GN_WINDOW_X11
|
||||
#include "gryphn_surface_create_functions.h"
|
||||
#include "core/instance/gryphn_instance.h"
|
||||
#include "core/gryphn_platform_functions.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#ifdef GN_PLATFORM_LINUX
|
||||
#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)->instance = instance;
|
||||
return instance->functions->_gnCreateX11WindowSurface(*windowSurface, instance, createInfo);
|
||||
|
@@ -1,11 +1,15 @@
|
||||
#pragma once
|
||||
#ifndef GN_WINDOW_X11
|
||||
#define GN_WINDOW_X11
|
||||
#endif
|
||||
#include <platform/gryphn_platform_include.h>
|
||||
#include "core/gryphn_handles.h"
|
||||
#include "utils/gryphn_error_code.h"
|
||||
#include <core/gryphn_handles.h>
|
||||
#include <utils/gryphn_error_code.h>
|
||||
|
||||
|
||||
#ifdef GN_PLATFORM_LINUX
|
||||
#ifdef GN_WINDOW_X11
|
||||
typedef struct gnX11WindowSurfaceInfo_t {
|
||||
typedef struct gnX11WindowSurfaceInfo {
|
||||
Display* display;
|
||||
Window window;
|
||||
} gnX11WindowSurfaceInfo;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#include "core/gryphn_rendering_api.h"
|
||||
|
||||
#ifdef GN_PLATFORM_LINUX
|
||||
#include "platform_linux/gryphn_platform_linux.h"
|
||||
#include <platform/platform_linux/gryphn_platform_linux.h>
|
||||
#endif
|
||||
|
||||
#ifdef GN_PLATFORM_MACOS
|
||||
|
@@ -1,7 +1,8 @@
|
||||
#ifdef GN_WINDOW_X11
|
||||
#pragma once
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
// #ifdef GN_WINDOW_X11
|
||||
// #endif
|
||||
|
||||
#ifdef GN_WINDOW_WAYLAND
|
||||
#include <wayland-client.h>
|
||||
#endif
|
||||
// #ifdef GN_WINDOW_WAYLAND
|
||||
// #include <wayland-client.h>
|
||||
// #endif
|
||||
|
Reference in New Issue
Block a user