get vulkan functions up and running
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
#include "gryphn_swapchain.h"
|
||||||
|
#include "gryphn_return_code.h"
|
||||||
|
#include <device/gryphn_device.h>
|
||||||
|
|
||||||
|
gnReturnCode gnCreateSwapchain(gnDevice device, gnSwapchainCreateInfo* createInfo, gnSwapchain* swapchain) {
|
||||||
|
return device->dispatchTable.createSwapchain(device, createInfo, swapchain);
|
||||||
|
}
|
||||||
|
gnReturnCode gnDestroySwapchain(gnDevice device, gnSwapchain* swapchain) {
|
||||||
|
return device->dispatchTable.destroySwapchain(device, swapchain);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <gryphn_handle.h>
|
||||||
|
#include "core/gryphn_format.h"
|
||||||
|
#include "core/gryphn_present_mode.h"
|
||||||
|
#include "core/gryphn_vec2d.h"
|
||||||
|
#include "gryphn_return_code.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
|
typedef struct gnSwapchainCreateInfo {
|
||||||
|
gnSurface surface;
|
||||||
|
uint32_t minImageCount;
|
||||||
|
gnFormat imageFormat;
|
||||||
|
gnColorSpace imageColorSpace;
|
||||||
|
gnExtent2D imageExtent;
|
||||||
|
uint32_t imageArrayLayers;
|
||||||
|
gnPresentMode presentMode;
|
||||||
|
} gnSwapchainCreateInfo;
|
||||||
|
|
||||||
|
gnReturnCode gnCreateSwapchain(gnDevice device, gnSwapchainCreateInfo* createInfo, gnSwapchain* swapchain);
|
||||||
|
gnReturnCode gnDestroySwapchain(gnDevice device, gnSwapchain* swapchain);
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "gryphn_handle.h"
|
#include "gryphn_handle.h"
|
||||||
|
typedef struct gnSwapchainCreateInfo gnSwapchainCreateInfo;
|
||||||
|
|
||||||
typedef gnReturnCode (*PFN_gnDestroyDevice)(gnDevice);
|
typedef gnReturnCode (*PFN_gnDestroyDevice)(gnDevice);
|
||||||
|
typedef gnReturnCode (*PFN_gnCreateSwapchain)(gnDevice, gnSwapchainCreateInfo*, gnSwapchain*);
|
||||||
|
typedef gnReturnCode (*PFN_gnDestroySwapchain)(gnDevice, gnSwapchain*);
|
||||||
|
|
||||||
typedef struct gnDeviceDispatchTable {
|
typedef struct gnDeviceDispatchTable {
|
||||||
PFN_gnDestroyDevice destroyDevice;
|
PFN_gnDestroyDevice destroyDevice;
|
||||||
|
PFN_gnCreateSwapchain createSwapchain;
|
||||||
|
PFN_gnDestroySwapchain destroySwapchain;
|
||||||
} gnDeviceDispatchTable;
|
} gnDeviceDispatchTable;
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include "../vulkan_functions.h"
|
||||||
|
#include "gryphn_return_code.h"
|
||||||
|
|
||||||
|
gnReturnCode vulkanCreateSwapchain(gnDevice device, gnSwapchainCreateInfo* createInfo, gnSwapchain* swapchain) {
|
||||||
|
return GN_UNSUPPORTED_BACKEND;
|
||||||
|
}
|
||||||
|
gnReturnCode vulkanDestroySwapchain(gnDevice device, gnSwapchain* swapchain) {
|
||||||
|
return GN_UNSUPPORTED_BACKEND;
|
||||||
|
}
|
||||||
@@ -64,6 +64,8 @@ gnReturnCode vulkanCreateDevice(gnInstance instance, gnDeviceCreateInfo* info, g
|
|||||||
if (strcmp(info->enabledExtensions[i], "GN_EXT_swapchain") == 0) {
|
if (strcmp(info->enabledExtensions[i], "GN_EXT_swapchain") == 0) {
|
||||||
extensions[realEnabledExtensionCount] = VK_KHR_SWAPCHAIN_EXTENSION_NAME;
|
extensions[realEnabledExtensionCount] = VK_KHR_SWAPCHAIN_EXTENSION_NAME;
|
||||||
realEnabledExtensionCount++;
|
realEnabledExtensionCount++;
|
||||||
|
device->dispatchTable.createSwapchain = vulkanCreateSwapchain;
|
||||||
|
device->dispatchTable.destroySwapchain = vulkanDestroySwapchain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,5 @@ gnReturnCode vulkanGetSurfaceCapabilities(gnPhysicalDevice device, gnSurface sur
|
|||||||
gnReturnCode vulkanGetSurfaceFormats(gnPhysicalDevice device, gnSurface surface, uint32_t* formatCount, gnSurfaceFormat* formats);
|
gnReturnCode vulkanGetSurfaceFormats(gnPhysicalDevice device, gnSurface surface, uint32_t* formatCount, gnSurfaceFormat* formats);
|
||||||
gnReturnCode vulkanGetSurfacePresentModes(gnPhysicalDevice device, gnSurface surface, uint32_t* presentModeCount, gnPresentMode* presentModes);
|
gnReturnCode vulkanGetSurfacePresentModes(gnPhysicalDevice device, gnSurface surface, uint32_t* presentModeCount, gnPresentMode* presentModes);
|
||||||
gnReturnCode vulkanDestroySurface(gnInstance instance, gnSurface* surface);
|
gnReturnCode vulkanDestroySurface(gnInstance instance, gnSurface* surface);
|
||||||
|
gnReturnCode vulkanCreateSwapchain(gnDevice device, gnSwapchainCreateInfo* createInfo, gnSwapchain* swapchain);
|
||||||
|
gnReturnCode vulkanDestroySwapchain(gnDevice device, gnSwapchain* swapchain);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ extern "C" {
|
|||||||
#include "GryphnLoader/src/device/gryphn_physical_device.h"
|
#include "GryphnLoader/src/device/gryphn_physical_device.h"
|
||||||
#include "GryphnLoader/src/device/gryphn_device.h"
|
#include "GryphnLoader/src/device/gryphn_device.h"
|
||||||
#include "GryphnLoader/src/ext/instance/surface/gryphn_surface.h"
|
#include "GryphnLoader/src/ext/instance/surface/gryphn_surface.h"
|
||||||
|
#include "GryphnLoader/src/ext/device/swapchain/gryphn_swapchain.h"
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ gnDevice device;
|
|||||||
gnSurface surface;
|
gnSurface surface;
|
||||||
gnSwapchain swapchain;
|
gnSwapchain swapchain;
|
||||||
|
|
||||||
int min(int a, int b) {
|
uint32_t min(uint32_t a, uint32_t b) {
|
||||||
if (a < b) return a;
|
if (a < b) return a;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
@@ -129,25 +129,25 @@ gnPresentMode getPresentMode() {
|
|||||||
|
|
||||||
|
|
||||||
void createSwapchain() {
|
void createSwapchain() {
|
||||||
// gnSurfaceCapabilities capabilites;
|
gnSurfaceCapabilities capabilites;
|
||||||
// gnGetSurfaceCapabilities(pysicalDevice, surface, &capabilites);
|
gnGetSurfaceCapabilities(pysicalDevice, surface, &capabilites);
|
||||||
|
|
||||||
// gnSurfaceFormat chosenFormat = getSurfaceFormat();
|
gnSurfaceFormat chosenFormat = getSurfaceFormat();
|
||||||
// gnPresentMode chosenMode = getPresentMode();
|
gnPresentMode chosenMode = getPresentMode();
|
||||||
|
|
||||||
// int width, height;
|
int width, height;
|
||||||
// glfwGetWindowSize(window, &width, &height);
|
glfwGetWindowSize(window, &width, &height);
|
||||||
|
|
||||||
// gnSwapchainCreateInfo createInfo = {
|
gnSwapchainCreateInfo createInfo = {
|
||||||
// .surface = surface,
|
.surface = surface,
|
||||||
// .minImageCount = min(capabilites.minImageCount + 1, capabilites.maxImageCount),
|
.minImageCount = min(capabilites.minImageCount + 1, capabilites.maxImageCount),
|
||||||
// .imageFormat = chosenFormat.format,
|
.imageFormat = chosenFormat.format,
|
||||||
// .imageColorSpace = chosenFormat.colorSpace,
|
.imageColorSpace = chosenFormat.colorSpace,
|
||||||
// .imageExtent = { width, height },
|
.imageExtent = { (uint32_t)width, (uint32_t)height },
|
||||||
// .imageArrayLayers = 1,
|
.imageArrayLayers = 1,
|
||||||
// .presentMode = chosenMode,
|
.presentMode = chosenMode,
|
||||||
// };
|
};
|
||||||
// CHECK(gnCreateSwapchain(device, &createInfo, &swapchain));
|
CHECK(gnCreateSwapchain(device, &createInfo, &swapchain));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user