redo folder structure
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "device/gryphn_physical_device.h"
|
#include "device/gryphn_physical_device.h"
|
||||||
#include "device/gryphn_device.h"
|
#include "device/gryphn_device.h"
|
||||||
#include "surface/gryphn_surface.h"
|
#include "ext/instance/surface/gryphn_surface.h"
|
||||||
|
|
||||||
gnReturnCode metalEnumeratePhysicalDevices(gnInstance instance, uint32_t* deviceCount, gnPhysicalDevice* devices);
|
gnReturnCode metalEnumeratePhysicalDevices(gnInstance instance, uint32_t* deviceCount, gnPhysicalDevice* devices);
|
||||||
gnReturnCode metalGetPhysicalDeviceProperties(gnPhysicalDevice device, gnPhysicalDeviceProperties* properties);
|
gnReturnCode metalGetPhysicalDeviceProperties(gnPhysicalDevice device, gnPhysicalDeviceProperties* properties);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "../vulkan_functions.h"
|
#include "../vulkan_functions.h"
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
#include "instance/gryphn_instance.h"
|
#include "instance/gryphn_instance.h"
|
||||||
#include "surface/gryphn_surface.h"
|
#include "ext/instance/surface/gryphn_surface.h"
|
||||||
#include "../vulkan_helpers.h"
|
#include "../vulkan_helpers.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ extern "C" {
|
|||||||
#include "GryphnLoader/src/instance/gryphn_instance.h"
|
#include "GryphnLoader/src/instance/gryphn_instance.h"
|
||||||
#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/surface/gryphn_surface.h"
|
#include "GryphnLoader/src/ext/instance/surface/gryphn_surface.h"
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#define GN_USE_SURFACE_XLIB
|
#define GN_USE_SURFACE_XLIB
|
||||||
#include "Gryphn/gryphn.h"
|
#include <Gryphn/gryphn.h>
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "iostream"
|
#include "iostream"
|
||||||
#define GLFW_EXPOSE_NATIVE_X11
|
#define GLFW_EXPOSE_NATIVE_X11
|
||||||
@@ -21,6 +21,12 @@ gnInstance instance;
|
|||||||
gnPhysicalDevice pysicalDevice;
|
gnPhysicalDevice pysicalDevice;
|
||||||
gnDevice device;
|
gnDevice device;
|
||||||
gnSurface surface;
|
gnSurface surface;
|
||||||
|
gnSwapchain swapchain;
|
||||||
|
|
||||||
|
int min(int a, int b) {
|
||||||
|
if (a < b) return a;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
void createInstance() {
|
void createInstance() {
|
||||||
uint32_t backendCount = 0;
|
uint32_t backendCount = 0;
|
||||||
@@ -85,13 +91,63 @@ void createSurface() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CHECK(gnCreateXlibSurface(instance, &createInfo, &surface));
|
CHECK(gnCreateXlibSurface(instance, &createInfo, &surface));
|
||||||
|
|
||||||
gnSurfaceCapabilities capabilites;
|
|
||||||
gnGetSurfaceCapabilities(pysicalDevice, surface, &capabilites);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createSwapchain() {
|
gnSurfaceFormat getSurfaceFormat() {
|
||||||
|
uint32_t surfaceFormatCount = 0;
|
||||||
|
CHECK(gnGetSurfaceFormats(pysicalDevice, surface, &surfaceFormatCount, NULL));
|
||||||
|
|
||||||
|
if (surfaceFormatCount == 0)
|
||||||
|
throw std::runtime_error("Gryphn returned 0 avaliable surface formats");
|
||||||
|
|
||||||
|
gnSurfaceFormat* formats = (gnSurfaceFormat*)malloc(sizeof(gnSurfaceFormat) * surfaceFormatCount);
|
||||||
|
CHECK(gnGetSurfaceFormats(pysicalDevice, surface, &surfaceFormatCount, formats));
|
||||||
|
|
||||||
|
for (int i = 0; i < surfaceFormatCount; i++)
|
||||||
|
if (formats[i].format == GN_FORMAT_BGRA8_SRGB && formats[i].colorSpace == GN_COLOR_SPACE_SRGB_NONLINEAR) return formats[i];
|
||||||
|
return formats[0];
|
||||||
|
return (gnSurfaceFormat){
|
||||||
|
.format = GN_FORMAT_UNDEFINED,
|
||||||
|
.colorSpace = GN_COLOR_SPACE_UNKNOWN
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
gnPresentMode getPresentMode() {
|
||||||
|
uint32_t presentModeCount = 0;
|
||||||
|
CHECK(gnGetSurfacePresentModes(pysicalDevice, surface, &presentModeCount, NULL));
|
||||||
|
|
||||||
|
if (presentModeCount == 0)
|
||||||
|
throw std::runtime_error("Gryphn returned 0 avaliable presentMode");
|
||||||
|
|
||||||
|
gnPresentMode* presentModes = (gnPresentMode*)malloc(sizeof(gnPresentMode) * presentModeCount);
|
||||||
|
CHECK(gnGetSurfacePresentModes(pysicalDevice, surface, &presentModeCount, presentModes));
|
||||||
|
|
||||||
|
for (int i = 0; i < presentModeCount; i++)
|
||||||
|
if (presentModes[i] == GN_PRESENT_MODE_MAILBOX) return presentModes[i];
|
||||||
|
return presentModes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void createSwapchain() {
|
||||||
|
// gnSurfaceCapabilities capabilites;
|
||||||
|
// gnGetSurfaceCapabilities(pysicalDevice, surface, &capabilites);
|
||||||
|
|
||||||
|
// gnSurfaceFormat chosenFormat = getSurfaceFormat();
|
||||||
|
// gnPresentMode chosenMode = getPresentMode();
|
||||||
|
|
||||||
|
// int width, height;
|
||||||
|
// glfwGetWindowSize(window, &width, &height);
|
||||||
|
|
||||||
|
// gnSwapchainCreateInfo createInfo = {
|
||||||
|
// .surface = surface,
|
||||||
|
// .minImageCount = min(capabilites.minImageCount + 1, capabilites.maxImageCount),
|
||||||
|
// .imageFormat = chosenFormat.format,
|
||||||
|
// .imageColorSpace = chosenFormat.colorSpace,
|
||||||
|
// .imageExtent = { width, height },
|
||||||
|
// .imageArrayLayers = 1,
|
||||||
|
// .presentMode = chosenMode,
|
||||||
|
// };
|
||||||
|
// CHECK(gnCreateSwapchain(device, &createInfo, &swapchain));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
@@ -111,7 +167,7 @@ int main() {
|
|||||||
createInstance();
|
createInstance();
|
||||||
createDevice();
|
createDevice();
|
||||||
createSurface();
|
createSurface();
|
||||||
// createSwapchain();
|
createSwapchain();
|
||||||
while (!glfwWindowShouldClose(window)) {
|
while (!glfwWindowShouldClose(window)) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user