Compare commits
29 Commits
76a787d48f
...
5228b6630c
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5228b6630c | ||
![]() |
5ce0ff3350 | ||
![]() |
63ec31216e | ||
![]() |
ebc6ce724f | ||
![]() |
3a5ddac2c5 | ||
![]() |
f93853608c | ||
![]() |
481f590234 | ||
![]() |
d79a3c45bf | ||
![]() |
3bf252d582 | ||
![]() |
228d75e5ac | ||
![]() |
3066f7c2bd | ||
![]() |
427f0ee5b1 | ||
![]() |
4b981055bd | ||
![]() |
1095e20dc2 | ||
![]() |
a0450a0351 | ||
![]() |
c495a7a0e8 | ||
![]() |
eef7045ac2 | ||
![]() |
7ace503ab0 | ||
![]() |
6f278affc6 | ||
![]() |
f7e71b77c2 | ||
![]() |
88bdbe1e64 | ||
![]() |
17b7970aa0 | ||
![]() |
ef53ffd458 | ||
![]() |
a446d6e75f | ||
![]() |
0310652abc | ||
![]() |
88649174a9 | ||
![]() |
9244b82f79 | ||
![]() |
c5297cb17b | ||
![]() |
a709ff8808 |
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
// core functionality
|
// core functionality
|
||||||
#include <core/src/instance/gryphn_instance.h>
|
#include <core/src/instance/gryphn_instance.h>
|
||||||
#include <core/src/output_device/gryphn_physical_output_device.h>
|
#include <core/src/output_device/gryphn_physical_device.h>
|
||||||
#include <core/src/window_surface/gryphn_surface.h>
|
#include <core/src/window_surface/gryphn_surface.h>
|
||||||
#include <core/src/window_surface/gryphn_surface_create_functions.h>
|
#include <core/src/window_surface/gryphn_surface_create_functions.h>
|
||||||
#include <core/src/presentation_queue/gryphn_presentation_queue.h>
|
#include <core/src/presentation_queue/gryphn_presentation_queue.h>
|
||||||
|
@@ -6,14 +6,16 @@
|
|||||||
gryphnInstanceFunctionLayers metalLoadAPILayer(void) {
|
gryphnInstanceFunctionLayers metalLoadAPILayer(void) {
|
||||||
return (gryphnInstanceFunctionLayers) {
|
return (gryphnInstanceFunctionLayers) {
|
||||||
.createInstance = metalCreateInstance,
|
.createInstance = metalCreateInstance,
|
||||||
|
.queryDevices = metalQueryDevices,
|
||||||
.destroyInstance = metalDestroyInstance,
|
.destroyInstance = metalDestroyInstance,
|
||||||
|
.isSuitable = metalIsInstanceSuitable,
|
||||||
|
.getPhysicalDeviceProperties = metalQueryPhysicalDeviceProperties,
|
||||||
.next = NULL
|
.next = NULL
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
gnInstanceFunctions loadMetalInstanceFunctions(void) {
|
gnInstanceFunctions loadMetalInstanceFunctions(void) {
|
||||||
return (gnInstanceFunctions){
|
return (gnInstanceFunctions){
|
||||||
._gnGetPhysicalDevices = getMetalDevices,
|
|
||||||
._gnPhysicalDeviceCanPresentToSurface = metalCanDevicePresent,
|
._gnPhysicalDeviceCanPresentToSurface = metalCanDevicePresent,
|
||||||
._gnCreateOutputDevice = createMetalOutputDevice,
|
._gnCreateOutputDevice = createMetalOutputDevice,
|
||||||
._gnDestroyOutputDevice = destroyMetalOutputDevice,
|
._gnDestroyOutputDevice = destroyMetalOutputDevice,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include <output_device/gryphn_physical_output_device.h>
|
#include <output_device/gryphn_physical_device.h>
|
||||||
#include <Metal/Metal.h>
|
#include <Metal/Metal.h>
|
||||||
#include "metal_output_devices.h"
|
#include "metal_output_devices.h"
|
||||||
#include "instance/metal_instance.h"
|
#include "instance/metal_instance.h"
|
||||||
@@ -10,7 +10,7 @@ gnReturnCode createMetalOutputDevice(gnInstanceHandle instance, gnOutputDeviceHa
|
|||||||
if (instance == GN_NULL_HANDLE) return GN_INVALID_HANDLE;
|
if (instance == GN_NULL_HANDLE) return GN_INVALID_HANDLE;
|
||||||
|
|
||||||
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
||||||
outputDevice->outputDevice->device = deviceInfo.physicalDevice->physicalDevice->device.retain;
|
outputDevice->outputDevice->device = ((mtlDevice)deviceInfo.physicalDevice).retain;
|
||||||
outputDevice->outputDevice->transferQueue = outputDevice->outputDevice->device.newCommandQueue;
|
outputDevice->outputDevice->transferQueue = outputDevice->outputDevice->device.newCommandQueue;
|
||||||
|
|
||||||
outputDevice->outputDevice->stagingBuffer = [outputDevice->outputDevice->device newBufferWithLength:(128 * 1024 * 1024) options:MTLResourceStorageModeShared];
|
outputDevice->outputDevice->stagingBuffer = [outputDevice->outputDevice->device newBufferWithLength:(128 * 1024 * 1024) options:MTLResourceStorageModeShared];
|
||||||
|
@@ -4,9 +4,8 @@
|
|||||||
#include <Metal/Metal.h>
|
#include <Metal/Metal.h>
|
||||||
#include <MetalKit/MetalKit.h>
|
#include <MetalKit/MetalKit.h>
|
||||||
|
|
||||||
struct gnPlatformPhysicalDevice_t {
|
typedef id<MTLDevice> mtlDevice;
|
||||||
id<MTLDevice> device;
|
gnPhysicalDeviceProperties metalQueryPhysicalDeviceProperties(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers);
|
||||||
} gnPlatformPhysicalDevice;
|
|
||||||
|
|
||||||
struct gnPlatformOutputDevice_t {
|
struct gnPlatformOutputDevice_t {
|
||||||
id<MTLDevice> device;
|
id<MTLDevice> device;
|
||||||
@@ -24,7 +23,7 @@ struct gnPlatformOutputDevice_t {
|
|||||||
} gnPlatformOutputDevice;
|
} gnPlatformOutputDevice;
|
||||||
|
|
||||||
gnPhysicalDevice* getMetalDevices(gnInstanceHandle instance, uint32_t* deviceCount);
|
gnPhysicalDevice* getMetalDevices(gnInstanceHandle instance, uint32_t* deviceCount);
|
||||||
gnBool metalCanDevicePresent(gnPhysicalDevice device, gnWindowSurface windowSurface);
|
gnBool metalCanDevicePresent(gnInstance instance, gnPhysicalDevice device, gnWindowSurface windowSurface);
|
||||||
|
|
||||||
gnReturnCode createMetalOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle outputDevice, gnOutputDeviceInfo deviceInfo);
|
gnReturnCode createMetalOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle outputDevice, gnOutputDeviceInfo deviceInfo);
|
||||||
void waitForMetalDevice(gnOutputDeviceHandle device);
|
void waitForMetalDevice(gnOutputDeviceHandle device);
|
||||||
|
@@ -1,47 +1,29 @@
|
|||||||
#include <output_device/gryphn_physical_output_device.h>
|
#include <output_device/gryphn_physical_device.h>
|
||||||
#include <Metal/Metal.h>
|
#include <Metal/Metal.h>
|
||||||
#include "metal_output_devices.h"
|
#include "metal_output_devices.h"
|
||||||
#include "window_surface/gryphn_surface.h"
|
#include "window_surface/gryphn_surface.h"
|
||||||
|
|
||||||
gnPhysicalDevice* getMetalDevices(gnInstanceHandle instance, uint32_t* deviceCount) {
|
// i made some educated guesses on these conversions and I dont think they are going to work
|
||||||
if (instance == GN_NULL_HANDLE) return NULL;
|
// but for now im worried about the MVP
|
||||||
|
gnPhysicalDeviceType metalDeviceLocationToGryphn(MTLDeviceLocation location) {
|
||||||
NSArray *devices = MTLCopyAllDevices();
|
switch (location) {
|
||||||
*deviceCount = (uint32_t)[devices count];
|
case MTLDeviceLocationBuiltIn: return GN_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
|
||||||
gnPhysicalDevice* devicesList = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount);
|
case MTLDeviceLocationSlot: return GN_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
|
||||||
for (uint32_t i = 0; i < *deviceCount; i++) {
|
case MTLDeviceLocationExternal: return GN_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
|
||||||
devicesList[i] = malloc(sizeof(gnPhysicalOutputDevice_t));
|
case MTLDeviceLocationUnspecified: return GN_PHYSICAL_DEVICE_TYPE_FAKED_GPU; //very bad if we get here
|
||||||
devicesList[i]->physicalDevice = malloc(sizeof(gnPlatformPhysicalDevice));
|
|
||||||
devicesList[i]->physicalDevice->device = [devices objectAtIndex:0];
|
|
||||||
|
|
||||||
|
|
||||||
id<MTLDevice> device = [devices objectAtIndex:0];
|
|
||||||
devicesList[i]->properties.name = gnCreateString([[device name] cStringUsingEncoding:NSUTF8StringEncoding]);
|
|
||||||
MTLDeviceLocation deviceLocation = device.locationNumber;
|
|
||||||
if (deviceLocation == MTLDeviceLocationBuiltIn)
|
|
||||||
devicesList[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
|
||||||
else if (deviceLocation == MTLDeviceLocationSlot)
|
|
||||||
devicesList[i]->properties.deviceType = GN_DEDICATED_DEVICE;
|
|
||||||
else if (deviceLocation == MTLDeviceLocationExternal)
|
|
||||||
devicesList[i]->properties.deviceType = GN_EXTERNAL_DEVICE;
|
|
||||||
|
|
||||||
devicesList[i]->features.maxColorSamples = GN_SAMPLE_BIT_1;
|
|
||||||
if ([device supportsTextureSampleCount:2]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_2; } else {}
|
|
||||||
if ([device supportsTextureSampleCount:4]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_4; } else {}
|
|
||||||
if ([device supportsTextureSampleCount:8]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_8; } else {}
|
|
||||||
if ([device supportsTextureSampleCount:16]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_16; } else {}
|
|
||||||
if ([device supportsTextureSampleCount:32]) { devicesList[i]->features.maxColorSamples |= GN_SAMPLE_BIT_32; } else {}
|
|
||||||
devicesList[i]->features.maxDepthSamples = devicesList[i]->features.maxColorSamples;
|
|
||||||
|
|
||||||
devicesList[i]->features.maxMemoryAllocations = 0x40000000;
|
|
||||||
devicesList[i]->features.maxPushConstantSize = 4096;
|
|
||||||
}
|
}
|
||||||
[devices release];
|
|
||||||
return devicesList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gnBool metalCanDevicePresent(gnPhysicalDevice device, gnWindowSurface windowSurface) {
|
gnPhysicalDeviceProperties metalQueryPhysicalDeviceProperties(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers) {
|
||||||
if (device == GN_NULL_HANDLE || windowSurface == GN_NULL_HANDLE) return GN_FALSE;
|
return (gnPhysicalDeviceProperties){
|
||||||
|
.deviceID = ((mtlDevice)device).registryID,
|
||||||
|
.deviceName = gnCreateString(((mtlDevice)device).name.UTF8String),
|
||||||
|
.deviceType = metalDeviceLocationToGryphn(((mtlDevice)device).location),
|
||||||
|
.driverVersion = ((mtlDevice)device).hash // very bad hack, me should not do this
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
gnBool metalCanDevicePresent(gnInstance instance, gnPhysicalDevice device, gnWindowSurface windowSurface) {
|
||||||
|
if (device == GN_NULL_HANDLE || windowSurface == GN_NULL_HANDLE) return GN_FALSE;
|
||||||
return GN_TRUE; // I belive that a window should always be able to present to a surface in metal
|
return GN_TRUE; // I belive that a window should always be able to present to a surface in metal
|
||||||
}
|
}
|
||||||
|
@@ -8,4 +8,6 @@ typedef struct gnPlatformInstance_t {
|
|||||||
} gnPlatformInstance;
|
} gnPlatformInstance;
|
||||||
|
|
||||||
gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next, gnAllocators* allocators);
|
gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next, gnAllocators* allocators);
|
||||||
|
gnReturnCode metalQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next);
|
||||||
|
gnBool metalIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next);
|
||||||
void metalDestroyInstance(gnInstance instance, gryphnInstanceFunctionLayers* next, gnAllocators* allocators);
|
void metalDestroyInstance(gnInstance instance, gryphnInstanceFunctionLayers* next, gnAllocators* allocators);
|
||||||
|
@@ -8,6 +8,20 @@ gnReturnCode metalCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo
|
|||||||
instance->instance = allocators->malloc(sizeof(gnPlatformInstance), allocators->userData);
|
instance->instance = allocators->malloc(sizeof(gnPlatformInstance), allocators->userData);
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
gnReturnCode metalQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next) {
|
||||||
|
if (instance == GN_NULL_HANDLE) return GN_INVALID_HANDLE;
|
||||||
|
NSArray *metalDevices = MTLCopyAllDevices();
|
||||||
|
*count = (uint32_t)[metalDevices count];
|
||||||
|
if (devices == NULL) return GN_SUCCESS;
|
||||||
|
for (int i = 0; i < *count; i++)
|
||||||
|
devices[i] = (uint64_t)metalDevices[i];
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
||||||
|
gnBool metalIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next) {
|
||||||
|
switch (field) {
|
||||||
|
case GN_NON_EXISTANT_PHYSICAL_DEVICE: return GN_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
void metalDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* allocators) {
|
void metalDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* allocators) {
|
||||||
if (next != NULL) return;
|
if (next != NULL) return;
|
||||||
allocators->free(instance->instance, allocators->userData);
|
allocators->free(instance->instance, allocators->userData);
|
||||||
|
@@ -13,4 +13,4 @@ void metalTextureData(gnTextureHandle texture, void* pixelData);
|
|||||||
void metalDestroyTexture(gnTexture texture);
|
void metalDestroyTexture(gnTexture texture);
|
||||||
|
|
||||||
|
|
||||||
NSUInteger mtlSampleCount(gnMultisampleCountFlags flags);
|
NSUInteger mtlSampleCount(gnSampleCountFlags flags);
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#include "surface/metal_surface.h"
|
#include "surface/metal_surface.h"
|
||||||
#include "devices/metal_output_devices.h"
|
#include "devices/metal_output_devices.h"
|
||||||
|
|
||||||
NSUInteger mtlSampleCount(gnMultisampleCountFlags flags) {
|
NSUInteger mtlSampleCount(gnSampleCountFlags flags) {
|
||||||
if ((flags & GN_SAMPLE_BIT_64) == GN_SAMPLE_BIT_64) { return 64; }
|
if ((flags & GN_SAMPLE_BIT_64) == GN_SAMPLE_BIT_64) { return 64; }
|
||||||
if ((flags & GN_SAMPLE_BIT_32) == GN_SAMPLE_BIT_32) { return 32; }
|
if ((flags & GN_SAMPLE_BIT_32) == GN_SAMPLE_BIT_32) { return 32; }
|
||||||
if ((flags & GN_SAMPLE_BIT_16) == GN_SAMPLE_BIT_16) { return 16; }
|
if ((flags & GN_SAMPLE_BIT_16) == GN_SAMPLE_BIT_16) { return 16; }
|
||||||
|
@@ -2,7 +2,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS on)
|
|||||||
project(GryphnVulkanImpl)
|
project(GryphnVulkanImpl)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
add_compile_definitions(GN_REVEAL_IMPL)
|
add_compile_definitions(GN_REVEAL_IMPL GN_IMPLEMENTATION)
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS "src/*.c" "src/*.h")
|
file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS "src/*.c" "src/*.h")
|
||||||
file(GLOB_RECURSE LOADER_FILES CONFIGURE_DEPENDS "loader/*.c")
|
file(GLOB_RECURSE LOADER_FILES CONFIGURE_DEPENDS "loader/*.c")
|
||||||
|
@@ -7,15 +7,18 @@
|
|||||||
gryphnInstanceFunctionLayers loadVulkanAPILayer(void) {
|
gryphnInstanceFunctionLayers loadVulkanAPILayer(void) {
|
||||||
return (gryphnInstanceFunctionLayers) {
|
return (gryphnInstanceFunctionLayers) {
|
||||||
.createInstance = vulkanCreateInstance,
|
.createInstance = vulkanCreateInstance,
|
||||||
|
.isSuitable = vulkanIsInstanceSuitable,
|
||||||
.destroyInstance = vulkanDestroyInstance,
|
.destroyInstance = vulkanDestroyInstance,
|
||||||
|
.queryDevices = vulkanQueryDevices,
|
||||||
|
.getPhysicalDeviceProperties = vulkanQueryPhysicalDeviceProperties,
|
||||||
|
.getPhysicalDeviceFeatures = vulkanQueryPhysicalDeviceFeatures,
|
||||||
|
.getPhysicalDeviceLimits = vulkanQueryPhysicalDeviceLimits,
|
||||||
.next = NULL
|
.next = NULL
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
gnInstanceFunctions loadVulkanInstanceFunctions(void) {
|
gnInstanceFunctions loadVulkanInstanceFunctions(void) {
|
||||||
return (gnInstanceFunctions){
|
return (gnInstanceFunctions){
|
||||||
|
|
||||||
._gnGetPhysicalDevices = getPhysicalDevices,
|
|
||||||
._gnPhysicalDeviceCanPresentToSurface = deviceCanPresentToSurface,
|
._gnPhysicalDeviceCanPresentToSurface = deviceCanPresentToSurface,
|
||||||
|
|
||||||
._gnCreateOutputDevice = createVulkanOutputDevice,
|
._gnCreateOutputDevice = createVulkanOutputDevice,
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
#include "vulkan_device_queues.h"
|
#include "vulkan_device_queues.h"
|
||||||
#include "output_device/vulkan_output_devices.h"
|
#include "output_device/vulkan_output_devices.h"
|
||||||
|
|
||||||
gnReturnCode vulkanPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device, uint32_t queueFamilyCount, gnQueueFamilyProperties* queues) {
|
gnReturnCode vulkanPhysicalDeviceQueueProperties(gnPhysicalDeviceHandle device, uint32_t queueFamilyCount, gnQueueFamilyProperties* queues) {
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(device->physicalDevice->device, &queueFamilyCount, NULL);
|
vkGetPhysicalDeviceQueueFamilyProperties((VkPhysicalDevice)device, &queueFamilyCount, NULL);
|
||||||
if (queues == NULL) return GN_SUCCESS;
|
if (queues == NULL) return GN_SUCCESS;
|
||||||
|
|
||||||
VkQueueFamilyProperties* queueFamilies = malloc(sizeof(VkQueueFamilyProperties) * queueFamilyCount);
|
VkQueueFamilyProperties* queueFamilies = malloc(sizeof(VkQueueFamilyProperties) * queueFamilyCount);
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(device->physicalDevice->device, &queueFamilyCount, queueFamilies);
|
vkGetPhysicalDeviceQueueFamilyProperties((VkPhysicalDevice)device, &queueFamilyCount, queueFamilies);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < queueFamilyCount; i++) {
|
for (uint32_t i = 0; i < queueFamilyCount; i++) {
|
||||||
queues[i].queueCount = queueFamilies[i].queueCount;
|
queues[i].queueCount = queueFamilies[i].queueCount;
|
||||||
@@ -21,8 +21,9 @@ gnReturnCode vulkanPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle de
|
|||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void getVulkanDeviceQueue(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue) {
|
void getVulkanDeviceQueue(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue) {
|
||||||
VkQueue vulkanQueue;
|
VkQueue vulkanQueue;
|
||||||
vkGetDeviceQueue(device->outputDevice->device, queueFamily, queueIndex, &vulkanQueue);
|
vkGetDeviceQueue(device->outputDevice->device, queueFamily, queueIndex, &vulkanQueue);
|
||||||
*queue = (uint64_t)vulkanQueue;
|
*queue = (gnQueue)vulkanQueue;
|
||||||
}
|
}
|
||||||
|
@@ -4,5 +4,5 @@
|
|||||||
#include <output_device/vulkan_physical_device.h>
|
#include <output_device/vulkan_physical_device.h>
|
||||||
#include <extensions/queues/gryphn_physcial_device_queue.h>
|
#include <extensions/queues/gryphn_physcial_device_queue.h>
|
||||||
|
|
||||||
gnReturnCode vulkanPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device, uint32_t queueFamilyCount, gnQueueFamilyProperties* queues);
|
gnReturnCode vulkanPhysicalDeviceQueueProperties(gnPhysicalDeviceHandle device, uint32_t queueFamilyCount, gnQueueFamilyProperties* queues);
|
||||||
void getVulkanDeviceQueue(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue);
|
void getVulkanDeviceQueue(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue);
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#include "vulkan_instance.h"
|
#include "vulkan_instance.h"
|
||||||
|
// #include "output_device/vulkan_physical_device.h"
|
||||||
#include "vulkan_result_converter.h"
|
#include "vulkan_result_converter.h"
|
||||||
GN_ARRAY_LIST_DEFINITION(vkString)
|
GN_ARRAY_LIST_DEFINITION(vkString)
|
||||||
|
|
||||||
@@ -109,6 +110,17 @@ gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInf
|
|||||||
return VkResultToGnReturnCode(vkCreateInstance(&createInfo, NULL, &instance->instance->vk_instance));
|
return VkResultToGnReturnCode(vkCreateInstance(&createInfo, NULL, &instance->instance->vk_instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gnReturnCode vulkanQueryDevices(gnInstanceHandle handle, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next) {
|
||||||
|
return VkResultToGnReturnCode(vkEnumeratePhysicalDevices(handle->instance->vk_instance, count, (VkPhysicalDevice*)devices));
|
||||||
|
}
|
||||||
|
|
||||||
|
gnBool vulkanIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next) {
|
||||||
|
switch (field) {
|
||||||
|
case GN_NON_EXISTANT_PHYSICAL_DEVICE: return GN_FALSE;
|
||||||
|
}
|
||||||
|
return GN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors) {
|
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors) {
|
||||||
if (next != NULL) { return; }
|
if (next != NULL) { return; }
|
||||||
vkDestroyInstance(instance->instance->vk_instance, NULL);
|
vkDestroyInstance(instance->instance->vk_instance, NULL);
|
||||||
|
@@ -15,6 +15,8 @@ typedef struct gnPlatformInstance_t {
|
|||||||
} gnPlatformInstance;
|
} gnPlatformInstance;
|
||||||
|
|
||||||
gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
gnReturnCode vulkanCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* instanceInfo, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
||||||
|
gnBool vulkanIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next);
|
||||||
|
gnReturnCode vulkanQueryDevices(gnInstanceHandle handle, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next);
|
||||||
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
void vulkanDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
||||||
|
|
||||||
typedef const char* vkString;
|
typedef const char* vkString;
|
||||||
|
@@ -8,25 +8,27 @@
|
|||||||
#include "vulkan_result_converter.h"
|
#include "vulkan_result_converter.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
#include "stdio.h"
|
#include <stdio.h>
|
||||||
|
|
||||||
gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo) {
|
gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo) {
|
||||||
device->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
device->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
||||||
device->outputDevice->physicalDevice = deviceInfo.physicalDevice->physicalDevice->device;
|
device->outputDevice->physicalDevice = (VkPhysicalDevice)deviceInfo.physicalDevice;
|
||||||
|
|
||||||
int createQueueCount = 0;
|
int createQueueCount = 0;
|
||||||
VkDeviceQueueCreateInfo* queueCreateInfos = NULL;
|
VkDeviceQueueCreateInfo* queueCreateInfos = NULL;
|
||||||
|
|
||||||
if (!instance->enabledExtensions[GN_EXT_QUEUES]) {
|
if (!instance->enabledExtensions[GN_EXT_QUEUES]) {
|
||||||
queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * deviceInfo.physicalDevice->physicalDevice->neededQueueCount);
|
uint32_t neededQueueCount;
|
||||||
createQueueCount = deviceInfo.physicalDevice->physicalDevice->neededQueueCount;
|
vulkanNeededQueue* neededQueues = vulkanLoadNeededQueues(deviceInfo.physicalDevice, &neededQueueCount);
|
||||||
|
queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * neededQueueCount);
|
||||||
|
createQueueCount = neededQueueCount;
|
||||||
float queuePriority = 1.0f;
|
float queuePriority = 1.0f;
|
||||||
for (uint32_t i = 0; i < deviceInfo.physicalDevice->physicalDevice->neededQueueCount; i++) {
|
for (uint32_t i = 0; i < neededQueueCount; i++) {
|
||||||
queueCreateInfos[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
queueCreateInfos[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||||
queueCreateInfos[i].pNext = NULL;
|
queueCreateInfos[i].pNext = NULL;
|
||||||
queueCreateInfos[i].flags = 0;
|
queueCreateInfos[i].flags = 0;
|
||||||
queueCreateInfos[i].queueCount = 1;
|
queueCreateInfos[i].queueCount = 1;
|
||||||
queueCreateInfos[i].queueFamilyIndex = deviceInfo.physicalDevice->physicalDevice->neededQueues[i].queueIndex;
|
queueCreateInfos[i].queueFamilyIndex = neededQueues[i].queueIndex;
|
||||||
queueCreateInfos[i].pQueuePriorities = &queuePriority;
|
queueCreateInfos[i].pQueuePriorities = &queuePriority;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -54,7 +56,7 @@ gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceH
|
|||||||
.pQueueCreateInfos = queueCreateInfos,
|
.pQueueCreateInfos = queueCreateInfos,
|
||||||
.pEnabledFeatures = &deviceFeatures
|
.pEnabledFeatures = &deviceFeatures
|
||||||
};
|
};
|
||||||
deviceCreateInfo.ppEnabledExtensionNames = vkGetGryphnDeviceExtensions(&deviceCreateInfo.enabledExtensionCount, deviceInfo.physicalDevice->physicalDevice->device);
|
deviceCreateInfo.ppEnabledExtensionNames = vkGetGryphnDeviceExtensions(&deviceCreateInfo.enabledExtensionCount, (VkPhysicalDevice)deviceInfo.physicalDevice);
|
||||||
|
|
||||||
device->outputDevice->enabledOversizedDescriptorPools = GN_FALSE;
|
device->outputDevice->enabledOversizedDescriptorPools = GN_FALSE;
|
||||||
for (uint32_t i = 0; i < deviceCreateInfo.enabledExtensionCount; i++)
|
for (uint32_t i = 0; i < deviceCreateInfo.enabledExtensionCount; i++)
|
||||||
@@ -67,18 +69,16 @@ gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceH
|
|||||||
deviceCreateInfo.enabledLayerCount = 1;
|
deviceCreateInfo.enabledLayerCount = 1;
|
||||||
deviceCreateInfo.ppEnabledLayerNames = validation_layers;
|
deviceCreateInfo.ppEnabledLayerNames = validation_layers;
|
||||||
}
|
}
|
||||||
|
VkResult result = vkCreateDevice((VkPhysicalDevice)deviceInfo.physicalDevice, &deviceCreateInfo, NULL, &device->outputDevice->device);
|
||||||
VkResult result = vkCreateDevice(deviceInfo.physicalDevice->physicalDevice->device, &deviceCreateInfo, NULL, &device->outputDevice->device);
|
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
return VkResultToGnReturnCode(result);
|
return VkResultToGnReturnCode(result);
|
||||||
|
|
||||||
device->outputDevice->queues = malloc(sizeof(vulkanQueue) * deviceInfo.physicalDevice->physicalDevice->neededQueueCount);
|
device->outputDevice->queues = malloc(sizeof(vulkanQueue) * createQueueCount);
|
||||||
uint32_t transferQueue = 0;
|
uint32_t transferQueue = 0;
|
||||||
gnBool foundTransferQueue = GN_FALSE, foundGraphicsQueue = GN_FALSE;
|
gnBool foundTransferQueue = GN_FALSE, foundGraphicsQueue = GN_FALSE;
|
||||||
for (uint32_t i = 0; i < deviceInfo.physicalDevice->physicalDevice->neededQueueCount; i++) {
|
|
||||||
device->outputDevice->queues[i].queueInfo = deviceInfo.physicalDevice->physicalDevice->neededQueues[i];
|
|
||||||
|
|
||||||
vkGetDeviceQueue(device->outputDevice->device, deviceInfo.physicalDevice->physicalDevice->neededQueues[i].queueIndex, 0, &device->outputDevice->queues[i].queue);
|
for (uint32_t i = 0; i < createQueueCount; i++) {
|
||||||
|
vkGetDeviceQueue(device->outputDevice->device, queueCreateInfos[i].queueFamilyIndex, 0, &device->outputDevice->queues[i].queue);
|
||||||
if ((device->outputDevice->queues[i].queueInfo.createFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT && !foundTransferQueue) {
|
if ((device->outputDevice->queues[i].queueInfo.createFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT && !foundTransferQueue) {
|
||||||
device->outputDevice->transferQueueIndex = i;
|
device->outputDevice->transferQueueIndex = i;
|
||||||
transferQueue = device->outputDevice->queues[i].queueInfo.queueIndex;
|
transferQueue = device->outputDevice->queues[i].queueInfo.queueIndex;
|
||||||
@@ -89,8 +89,13 @@ gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceH
|
|||||||
device->outputDevice->graphicsQueueIndex = i;
|
device->outputDevice->graphicsQueueIndex = i;
|
||||||
foundGraphicsQueue = GN_FALSE;
|
foundGraphicsQueue = GN_FALSE;
|
||||||
}
|
}
|
||||||
|
if ((device->outputDevice->queues[i].queueInfo.createFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT && !foundGraphicsQueue) {
|
||||||
|
device->outputDevice->graphicsQueueIndex = i;
|
||||||
|
foundGraphicsQueue = GN_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkCommandPoolCreateInfo poolInfo = {
|
VkCommandPoolCreateInfo poolInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
||||||
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
|
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
|
||||||
|
@@ -3,8 +3,120 @@
|
|||||||
#include <output_device/vulkan_device_extensions.h>
|
#include <output_device/vulkan_device_extensions.h>
|
||||||
#include <vulkan_surface/vulkan_surface.h>
|
#include <vulkan_surface/vulkan_surface.h>
|
||||||
|
|
||||||
gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts) {
|
inline gnPhysicalDeviceType vulkanDeviceTypeToGryphn(VkPhysicalDeviceType type) {
|
||||||
gnMultisampleCountFlags sampleCount = 0;
|
switch (type) {
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_OTHER: return GN_PHYSICAL_DEVICE_TYPE_FAKED_GPU;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: return GN_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: return GN_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: return GN_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_CPU: return GN_PHYSICAL_DEVICE_TYPE_CPU;
|
||||||
|
case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: return GN_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU; // WE SHOULD NEVER HAVE TO DEAL WITH THIS ERROR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gnPhysicalDeviceProperties vulkanQueryPhysicalDeviceProperties(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers) {
|
||||||
|
VkPhysicalDeviceProperties properties;
|
||||||
|
vkGetPhysicalDeviceProperties((VkPhysicalDevice)device, &properties);
|
||||||
|
return (gnPhysicalDeviceProperties){
|
||||||
|
.deviceID = properties.deviceID,
|
||||||
|
.deviceName = gnCreateString(properties.deviceName),
|
||||||
|
.deviceType = vulkanDeviceTypeToGryphn(properties.deviceType),
|
||||||
|
.driverVersion = properties.driverVersion
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
gnPhysicalDeviceFeatures vulkanQueryPhysicalDeviceFeatures(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers) {
|
||||||
|
VkPhysicalDeviceFeatures features;
|
||||||
|
vkGetPhysicalDeviceFeatures((VkPhysicalDevice)device, &features);
|
||||||
|
return (gnPhysicalDeviceFeatures){
|
||||||
|
.uint32Index = features.fullDrawIndexUint32,
|
||||||
|
.geometryShader = features.geometryShader,
|
||||||
|
.tessellationShader = features.tessellationShader,
|
||||||
|
.multiDrawIndirect = features.multiDrawIndirect,
|
||||||
|
.drawIndirectFirstInstance = features.drawIndirectFirstInstance,
|
||||||
|
.fillModeNonSolid = features.fillModeNonSolid,
|
||||||
|
.wideLines = features.wideLines,
|
||||||
|
.largePoints = features.largePoints,
|
||||||
|
.samplerAnisotropy = features.samplerAnisotropy
|
||||||
|
};
|
||||||
|
}
|
||||||
|
gnPhysicalDeviceLimits vulkanQueryPhysicalDeviceLimits(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers) {
|
||||||
|
VkPhysicalDeviceProperties properties;
|
||||||
|
vkGetPhysicalDeviceProperties((VkPhysicalDevice)device, &properties);
|
||||||
|
VkPhysicalDeviceLimits limits = properties.limits;
|
||||||
|
return (gnPhysicalDeviceLimits) {
|
||||||
|
.maxImageExtent1D = limits.maxImageDimension1D,
|
||||||
|
.maxImageExtent2D = limits.maxImageDimension2D,
|
||||||
|
.maxImageExtent3D = limits.maxImageDimension3D,
|
||||||
|
.maxImageExtentCube = limits.maxImageDimensionCube,
|
||||||
|
.maxImageArrayLayers = limits.maxImageArrayLayers,
|
||||||
|
.maxTexelBufferElements = limits.maxTexelBufferElements,
|
||||||
|
.maxUniformBufferRange = limits.maxUniformBufferRange,
|
||||||
|
.maxStorageBufferRange = limits.maxStorageBufferRange,
|
||||||
|
.maxPushConstantsSize = limits.maxPushConstantsSize,
|
||||||
|
.maxMemoryAllocationCount = limits.maxMemoryAllocationCount,
|
||||||
|
.maxSamplerAllocationCount = limits.maxSamplerAllocationCount,
|
||||||
|
.maxBoundUniforms = limits.maxBoundDescriptorSets,
|
||||||
|
.maxPerStageUniformSamplers = limits.maxPerStageDescriptorSamplers,
|
||||||
|
.maxPerStageUniformUniformBuffers = limits.maxPerStageDescriptorUniformBuffers,
|
||||||
|
.maxPerStageUniformStorageBuffers = limits.maxPerStageDescriptorStorageBuffers,
|
||||||
|
.maxPerStageUniformSampledImages = limits.maxPerStageDescriptorSampledImages,
|
||||||
|
.maxPerStageUniformStorageImages = limits.maxPerStageDescriptorStorageBuffers,
|
||||||
|
.maxPerStageUniformInputAttachments = limits.maxPerStageDescriptorInputAttachments,
|
||||||
|
.maxPerStageResources = limits.maxPerStageResources,
|
||||||
|
.maxUniformSamplers = limits.maxPerStageDescriptorSamplers,
|
||||||
|
.maxUniformUniformBuffers = limits.maxDescriptorSetUniformBuffers,
|
||||||
|
.maxUniformUniformBuffersDynamic = limits.maxDescriptorSetUniformBuffersDynamic,
|
||||||
|
.maxUniformStorageBuffers = limits.maxDescriptorSetStorageBuffers,
|
||||||
|
.maxUniformStorageBuffersDynamic = limits.maxDescriptorSetStorageBuffersDynamic,
|
||||||
|
.maxUniformSampledImages = limits.maxDescriptorSetSampledImages,
|
||||||
|
.maxUniformStorageImages = limits.maxPerStageDescriptorStorageImages,
|
||||||
|
.maxUniformInputAttachments = limits.maxDescriptorSetInputAttachments,
|
||||||
|
.maxVertexInputAttributes = limits.maxVertexInputAttributes,
|
||||||
|
.maxVertexInputBindings = limits.maxVertexInputBindings,
|
||||||
|
.maxVertexInputAttributeOffset = limits.maxVertexInputAttributeOffset,
|
||||||
|
.maxVertexInputBindingStride = limits.maxVertexInputBindingStride,
|
||||||
|
.maxVertexOutputComponents = limits.maxVertexOutputComponents,
|
||||||
|
.maxTessellationGenerationLevel = limits.maxTessellationGenerationLevel,
|
||||||
|
.maxTessellationPatchSize = limits.maxTessellationPatchSize,
|
||||||
|
.maxTessellationControlPerVertexInputComponents = limits.maxTessellationControlPerVertexInputComponents,
|
||||||
|
.maxTessellationControlPerVertexOutputComponents = limits.maxTessellationControlPerVertexOutputComponents,
|
||||||
|
.maxTessellationControlPerPatchOutputComponents = limits.maxTessellationControlPerPatchOutputComponents,
|
||||||
|
.maxTessellationControlTotalOutputComponents = limits.maxTessellationControlTotalOutputComponents,
|
||||||
|
.maxTessellationEvaluationInputComponents = limits.maxTessellationEvaluationInputComponents,
|
||||||
|
.maxTessellationEvaluationOutputComponents = limits.maxTessellationControlPerVertexOutputComponents,
|
||||||
|
.maxGeometryShaderInvocations = limits.maxGeometryShaderInvocations,
|
||||||
|
.maxGeometryInputComponents = limits.maxGeometryInputComponents,
|
||||||
|
.maxGeometryOutputComponents = limits.maxGeometryOutputComponents,
|
||||||
|
.maxGeometryOutputVertices = limits.maxGeometryOutputVertices,
|
||||||
|
.maxGeometryTotalOutputComponents = limits.maxGeometryTotalOutputComponents,
|
||||||
|
.maxFragmentInputComponents = limits.maxFragmentInputComponents,
|
||||||
|
.maxFragmentOutputAttachments = limits.maxFragmentOutputAttachments,
|
||||||
|
.maxFragmentDualSrcAttachments = limits.maxFragmentDualSrcAttachments,
|
||||||
|
.maxFragmentCombinedOutputResources = limits.maxFragmentCombinedOutputResources,
|
||||||
|
.maxDrawIndexedIndexValue = limits.maxDrawIndexedIndexValue,
|
||||||
|
.maxDrawIndirectCount = limits.maxDrawIndirectCount,
|
||||||
|
.maxSamplerLodBias = limits.maxSamplerLodBias,
|
||||||
|
.maxSamplerAnisotropy = limits.maxSamplerAnisotropy,
|
||||||
|
.maxViewports = limits.maxViewports,
|
||||||
|
.maxViewportExtents = { limits.maxViewportDimensions[0], limits.maxViewportDimensions[1] },
|
||||||
|
.viewportBoundsRange = { limits.viewportBoundsRange[0], limits.viewportBoundsRange[1] },
|
||||||
|
.maxFramebufferExtent = {limits.maxFramebufferWidth, limits.maxFramebufferHeight},
|
||||||
|
.maxFramebufferLayers = limits.maxFramebufferLayers,
|
||||||
|
.framebufferColorSampleCounts = vkSampleCountToGryphn(limits.framebufferColorSampleCounts),
|
||||||
|
.framebufferDepthSampleCounts = vkSampleCountToGryphn(limits.framebufferDepthSampleCounts),
|
||||||
|
.framebufferStencilSampleCounts = vkSampleCountToGryphn(limits.framebufferStencilSampleCounts),
|
||||||
|
.framebufferNoAttachmentsSampleCounts = vkSampleCountToGryphn(limits.framebufferNoAttachmentsSampleCounts),
|
||||||
|
.maxColorAttachments = limits.maxColorAttachments,
|
||||||
|
.pointSizeRange = { limits.pointSizeRange[0], limits.pointSizeRange[1] },
|
||||||
|
.lineWidthRange = { limits.lineWidthRange[0], limits.lineWidthRange[1] },
|
||||||
|
.pointSizeGranularity = limits.pointSizeGranularity,
|
||||||
|
.lineWidthGranularity = limits.lineWidthGranularity,
|
||||||
|
.strictLines = limits.strictLines
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
gnSampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts) {
|
||||||
|
gnSampleCountFlags sampleCount = 0;
|
||||||
if ((counts & VK_SAMPLE_COUNT_64_BIT) == VK_SAMPLE_COUNT_64_BIT) { sampleCount |= GN_SAMPLE_BIT_64; }
|
if ((counts & VK_SAMPLE_COUNT_64_BIT) == VK_SAMPLE_COUNT_64_BIT) { sampleCount |= GN_SAMPLE_BIT_64; }
|
||||||
if ((counts & VK_SAMPLE_COUNT_32_BIT) == VK_SAMPLE_COUNT_32_BIT) { sampleCount |= GN_SAMPLE_BIT_32; }
|
if ((counts & VK_SAMPLE_COUNT_32_BIT) == VK_SAMPLE_COUNT_32_BIT) { sampleCount |= GN_SAMPLE_BIT_32; }
|
||||||
if ((counts & VK_SAMPLE_COUNT_16_BIT) == VK_SAMPLE_COUNT_16_BIT) { sampleCount |= GN_SAMPLE_BIT_16; }
|
if ((counts & VK_SAMPLE_COUNT_16_BIT) == VK_SAMPLE_COUNT_16_BIT) { sampleCount |= GN_SAMPLE_BIT_16; }
|
||||||
@@ -15,9 +127,7 @@ gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts) {
|
|||||||
return sampleCount;
|
return sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <stdio.h>
|
VkSampleCountFlags gnSampleCountToVulkan(gnSampleCountFlags counts) {
|
||||||
|
|
||||||
VkSampleCountFlags gnSampleCountToVulkan(gnMultisampleCountFlags counts) {
|
|
||||||
VkSampleCountFlags sampleCount = 0;
|
VkSampleCountFlags sampleCount = 0;
|
||||||
|
|
||||||
if ((counts & GN_SAMPLE_BIT_64) == GN_SAMPLE_BIT_64) { sampleCount |= VK_SAMPLE_COUNT_64_BIT; }
|
if ((counts & GN_SAMPLE_BIT_64) == GN_SAMPLE_BIT_64) { sampleCount |= VK_SAMPLE_COUNT_64_BIT; }
|
||||||
@@ -31,20 +141,28 @@ VkSampleCountFlags gnSampleCountToVulkan(gnMultisampleCountFlags counts) {
|
|||||||
return sampleCount;
|
return sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vulkanLoadNeededQueues(VkPhysicalDevice vulkanDevice, gnPhysicalDevice gryphnDevice) {
|
vulkanNeededQueue* vulkanLoadNeededQueues(gnPhysicalDevice physicalDevice, uint32_t* neededQueueCount) {
|
||||||
|
VkPhysicalDevice device = (VkPhysicalDevice)physicalDevice;
|
||||||
uint32_t queueFamilyCount = 0;
|
uint32_t queueFamilyCount = 0;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(vulkanDevice, &queueFamilyCount, NULL);
|
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, NULL);
|
||||||
VkQueueFamilyProperties* queueFamilies = malloc(sizeof(VkQueueFamilyProperties) * queueFamilyCount);
|
VkQueueFamilyProperties* queueFamilies = malloc(sizeof(VkQueueFamilyProperties) * queueFamilyCount);
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(vulkanDevice, &queueFamilyCount, queueFamilies);
|
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, queueFamilies);
|
||||||
|
*neededQueueCount = 0;
|
||||||
|
|
||||||
|
gnBool foundGraphicsQueue = GN_FALSE, foundTransferQueue = GN_FALSE;
|
||||||
|
vulkanNeededQueue* neededQueues = malloc(sizeof(vulkanNeededQueue) * queueFamilyCount);
|
||||||
|
|
||||||
|
|
||||||
gryphnDevice->physicalDevice->neededQueues = malloc(sizeof(vulkanNeededQueue) * queueFamilyCount);
|
|
||||||
for (uint32_t c = 0; c < queueFamilyCount; c++) {
|
for (uint32_t c = 0; c < queueFamilyCount; c++) {
|
||||||
gnBool hasNeededQueue = GN_FALSE;
|
gnBool hasNeededQueue = GN_FALSE;
|
||||||
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT && !foundGraphicsQueue) {
|
||||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT)
|
|
||||||
hasNeededQueue = GN_TRUE;
|
hasNeededQueue = GN_TRUE;
|
||||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT)
|
foundGraphicsQueue = GN_TRUE;
|
||||||
|
}
|
||||||
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT && !foundTransferQueue) {
|
||||||
hasNeededQueue = GN_TRUE;
|
hasNeededQueue = GN_TRUE;
|
||||||
|
foundTransferQueue = GN_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasNeededQueue) {
|
if (hasNeededQueue) {
|
||||||
vulkanNeededQueue neededQueue = {
|
vulkanNeededQueue neededQueue = {
|
||||||
@@ -55,98 +173,23 @@ void vulkanLoadNeededQueues(VkPhysicalDevice vulkanDevice, gnPhysicalDevice gryp
|
|||||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT)) neededQueue.createFlags |= VK_QUEUE_GRAPHICS_BIT;
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT)) neededQueue.createFlags |= VK_QUEUE_GRAPHICS_BIT;
|
||||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT)) neededQueue.createFlags |= VK_QUEUE_TRANSFER_BIT;
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT)) neededQueue.createFlags |= VK_QUEUE_TRANSFER_BIT;
|
||||||
|
|
||||||
gryphnDevice->physicalDevice->neededQueues[gryphnDevice->physicalDevice->neededQueueCount] = neededQueue;
|
neededQueues[*neededQueueCount] = neededQueue;
|
||||||
gryphnDevice->physicalDevice->neededQueueCount++;
|
(*neededQueueCount)++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(queueFamilies);
|
free(queueFamilies);
|
||||||
|
neededQueues = realloc(neededQueues, sizeof(vulkanNeededQueue) * *neededQueueCount);
|
||||||
|
return neededQueues;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* deviceCount) {
|
|
||||||
vkEnumeratePhysicalDevices(instance->instance->vk_instance, deviceCount, NULL);
|
|
||||||
if (deviceCount == 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
VkPhysicalDevice* physicalDevices = malloc(sizeof(VkPhysicalDevice) * *deviceCount);
|
gnBool deviceCanPresentToSurface(gnInstance instance, gnPhysicalDevice physicalDevice, gnWindowSurface surface) {;
|
||||||
vkEnumeratePhysicalDevices(instance->instance->vk_instance, deviceCount, physicalDevices);
|
|
||||||
gnPhysicalDevice* outputDevices = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < *deviceCount; i++) {
|
|
||||||
outputDevices[i] = malloc(sizeof(gnPhysicalOutputDevice_t));
|
|
||||||
outputDevices[i]->physicalDevice = malloc(sizeof(struct gnPlatformPhysicalDevice_t));
|
|
||||||
outputDevices[i]->physicalDevice->device = physicalDevices[i];
|
|
||||||
|
|
||||||
VkPhysicalDeviceProperties deviceProperties;
|
|
||||||
vkGetPhysicalDeviceProperties(physicalDevices[i], &deviceProperties);
|
|
||||||
outputDevices[i]->properties.name = gnCreateString(deviceProperties.deviceName);
|
|
||||||
switch(deviceProperties.deviceType) {
|
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_OTHER: outputDevices[i]->properties.deviceType = GN_EXTERNAL_DEVICE;
|
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: outputDevices[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: outputDevices[i]->properties.deviceType = GN_DEDICATED_DEVICE;
|
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: outputDevices[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_CPU: outputDevices[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
|
||||||
case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: outputDevices[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instance->enabledExtensions[GN_EXT_QUEUES] == GN_FALSE)
|
|
||||||
vulkanLoadNeededQueues(physicalDevices[i], outputDevices[i]);
|
|
||||||
|
|
||||||
|
|
||||||
VkPhysicalDeviceProperties physicalDeviceProperties;
|
|
||||||
vkGetPhysicalDeviceProperties(physicalDevices[i], &physicalDeviceProperties);
|
|
||||||
outputDevices[i]->features.maxColorSamples = vkSampleCountToGryphn(physicalDeviceProperties.limits.framebufferColorSampleCounts);
|
|
||||||
outputDevices[i]->features.maxDepthSamples = vkSampleCountToGryphn(physicalDeviceProperties.limits.framebufferDepthSampleCounts);
|
|
||||||
outputDevices[i]->features.maxMemoryAllocations = physicalDeviceProperties.limits.maxMemoryAllocationCount;
|
|
||||||
outputDevices[i]->features.maxPushConstantSize = physicalDeviceProperties.limits.maxPushConstantsSize;
|
|
||||||
}
|
|
||||||
free(physicalDevices);
|
|
||||||
|
|
||||||
return outputDevices;
|
|
||||||
}
|
|
||||||
|
|
||||||
gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surface) {
|
|
||||||
uint32_t queueFamilyCount = 0;
|
uint32_t queueFamilyCount = 0;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(device->physicalDevice->device, &queueFamilyCount, NULL);
|
vkGetPhysicalDeviceQueueFamilyProperties((VkPhysicalDevice)physicalDevice, &queueFamilyCount, NULL);
|
||||||
for (uint32_t i = 0; i < queueFamilyCount; i++) {
|
for (uint32_t i = 0; i < queueFamilyCount; i++) {
|
||||||
VkBool32 supportsPresent;
|
VkBool32 supportsPresent;
|
||||||
vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, i, surface->windowSurface->surface, &supportsPresent);
|
vkGetPhysicalDeviceSurfaceSupportKHR((VkPhysicalDevice)physicalDevice, i, surface->windowSurface->surface, &supportsPresent);
|
||||||
if (supportsPresent) return GN_TRUE;
|
if (supportsPresent) return GN_TRUE;
|
||||||
}
|
}
|
||||||
return GN_FALSE;
|
return GN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gnBool foundQueue = GN_FALSE;
|
|
||||||
// for (uint32_t i = 0; i < device->physicalDevice->neededQueueCount; i++) {
|
|
||||||
// VkBool32 supportsPresent = VK_FALSE;
|
|
||||||
// vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, device->physicalDevice->neededQueues[i].queueIndex, surface->windowSurface->surface, &supportsPresent);
|
|
||||||
// if (supportsPresent) {
|
|
||||||
// device->physicalDevice->neededQueues[i].usedForPresent = GN_TRUE;
|
|
||||||
// foundQueue = GN_TRUE;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// surface->windowSurface->presentQueueIndex = i;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!foundQueue) {
|
|
||||||
// uint32_t queueFamilyCount = 0;
|
|
||||||
// vkGetPhysicalDeviceQueueFamilyProperties(device->physicalDevice->device, &queueFamilyCount, NULL);
|
|
||||||
|
|
||||||
// for (uint32_t i = 0; i < queueFamilyCount; i++) {
|
|
||||||
// VkBool32 supportsPresent = VK_FALSE;
|
|
||||||
// vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, i, surface->windowSurface->surface, &supportsPresent);
|
|
||||||
// if (supportsPresent) {
|
|
||||||
// device->physicalDevice->neededQueues[device->physicalDevice->neededQueueCount] = (vulkanNeededQueue){
|
|
||||||
// .queueIndex = i,
|
|
||||||
// .createFlags = 0,
|
|
||||||
// .usedForPresent = GN_TRUE
|
|
||||||
// };
|
|
||||||
// foundQueue = GN_TRUE;
|
|
||||||
// surface->windowSurface->presentQueueIndex = device->physicalDevice->neededQueueCount;
|
|
||||||
// device->physicalDevice->neededQueueCount++;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return foundQueue;
|
|
||||||
|
@@ -1,23 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "loader/src/gryphn_instance_functions.h"
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <output_device/gryphn_physical_output_device.h>
|
#include <output_device/gryphn_physical_device.h>
|
||||||
|
|
||||||
typedef struct vulkanNeededQueue {
|
typedef struct vulkanNeededQueue {
|
||||||
VkQueueFlags createFlags;
|
VkQueueFlags createFlags;
|
||||||
gnBool usedForPresent;
|
gnBool usedForPresent;
|
||||||
uint32_t queueIndex;
|
uint32_t queueIndex;
|
||||||
} vulkanNeededQueue;
|
} vulkanNeededQueue;
|
||||||
|
vulkanNeededQueue* vulkanLoadNeededQueues(gnPhysicalDevice physicalDevice, uint32_t* neededQueueCount);
|
||||||
|
|
||||||
typedef struct gnPlatformPhysicalDevice_t {
|
gnPhysicalDeviceProperties vulkanQueryPhysicalDeviceProperties(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers);
|
||||||
VkPhysicalDevice device;
|
gnPhysicalDeviceFeatures vulkanQueryPhysicalDeviceFeatures(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers);
|
||||||
uint32_t neededQueueCount;
|
gnPhysicalDeviceLimits vulkanQueryPhysicalDeviceLimits(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers);
|
||||||
vulkanNeededQueue* neededQueues;
|
|
||||||
|
|
||||||
} gnPlatformPhysicalDevice;
|
gnBool deviceCanPresentToSurface(gnInstance instance, gnPhysicalDevice device, gnWindowSurface surface);
|
||||||
|
gnSampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts);
|
||||||
gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* deviceCount);
|
VkSampleCountFlags gnSampleCountToVulkan(gnSampleCountFlags counts);
|
||||||
gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surface);
|
|
||||||
|
|
||||||
|
|
||||||
gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts);
|
|
||||||
VkSampleCountFlags gnSampleCountToVulkan(gnMultisampleCountFlags counts);
|
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
#include <instance/vulkan_instance.h>
|
#include <instance/vulkan_instance.h>
|
||||||
#include "vulkan_surface.h"
|
#include "vulkan_surface.h"
|
||||||
#include <output_device/vulkan_physical_device.h>
|
#include <output_device/vulkan_physical_device.h>
|
||||||
#include "vulkan_result_converter.h"
|
|
||||||
|
|
||||||
#ifdef GN_PLATFORM_LINUX
|
#ifdef GN_PLATFORM_LINUX
|
||||||
#ifdef GN_WINDOW_X11
|
#ifdef GN_WINDOW_X11
|
||||||
@@ -57,16 +56,17 @@ void destroyWindowSurface(struct gnWindowSurface_t* windowSurface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnSurfaceFormat* vkGetSurfaceFormats(
|
gnSurfaceFormat* vkGetSurfaceFormats(
|
||||||
struct gnWindowSurface_t* windowSurface, gnPhysicalDevice device, uint32_t* formatCount
|
struct gnWindowSurface_t* windowSurface, gnPhysicalDevice deviceHandle, uint32_t* formatCount
|
||||||
) {
|
) {
|
||||||
gnSurfaceFormat* formats = NULL;
|
gnSurfaceFormat* formats = NULL;
|
||||||
|
VkPhysicalDevice device = (VkPhysicalDevice)deviceHandle;
|
||||||
|
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(device->physicalDevice->device, windowSurface->windowSurface->surface, formatCount, NULL);
|
vkGetPhysicalDeviceSurfaceFormatsKHR(device, windowSurface->windowSurface->surface, formatCount, NULL);
|
||||||
formats = malloc(sizeof(gnSurfaceFormat) * *formatCount);
|
formats = malloc(sizeof(gnSurfaceFormat) * *formatCount);
|
||||||
VkSurfaceFormatKHR* vkFormats = malloc(sizeof(VkSurfaceFormatKHR) * *formatCount);;
|
VkSurfaceFormatKHR* vkFormats = malloc(sizeof(VkSurfaceFormatKHR) * *formatCount);;
|
||||||
|
|
||||||
if (*formatCount > 0) {
|
if (*formatCount > 0) {
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(device->physicalDevice->device, windowSurface->windowSurface->surface, formatCount, vkFormats);
|
vkGetPhysicalDeviceSurfaceFormatsKHR(device, windowSurface->windowSurface->surface, formatCount, vkFormats);
|
||||||
for (uint32_t i = 0; i < *formatCount; i++) {
|
for (uint32_t i = 0; i < *formatCount; i++) {
|
||||||
switch (vkFormats[i].format) {
|
switch (vkFormats[i].format) {
|
||||||
case VK_FORMAT_B8G8R8A8_SRGB: { formats[i].format = GN_FORMAT_BGRA8_SRGB; break; }
|
case VK_FORMAT_B8G8R8A8_SRGB: { formats[i].format = GN_FORMAT_BGRA8_SRGB; break; }
|
||||||
@@ -85,13 +85,13 @@ gnSurfaceFormat* vkGetSurfaceFormats(
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnSurfaceDetails getSurfaceDetails(
|
gnSurfaceDetails getSurfaceDetails(
|
||||||
gnWindowSurfaceHandle windowSurface, gnPhysicalDevice device
|
gnWindowSurfaceHandle windowSurface, gnPhysicalDevice deviceHandle
|
||||||
) {
|
) {
|
||||||
gnSurfaceDetails surfaceDetails;
|
gnSurfaceDetails surfaceDetails;
|
||||||
surfaceDetails.formats = vkGetSurfaceFormats(windowSurface, device, &surfaceDetails.formatCount);
|
surfaceDetails.formats = vkGetSurfaceFormats(windowSurface, deviceHandle, &surfaceDetails.formatCount);
|
||||||
|
|
||||||
VkSurfaceCapabilitiesKHR details;
|
VkSurfaceCapabilitiesKHR details;
|
||||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device->physicalDevice->device, windowSurface->windowSurface->surface, &details);
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR((VkPhysicalDevice)deviceHandle, windowSurface->windowSurface->surface, &details);
|
||||||
|
|
||||||
surfaceDetails.minImageCount = details.minImageCount;
|
surfaceDetails.minImageCount = details.minImageCount;
|
||||||
surfaceDetails.maxImageCount = details.maxImageCount;
|
surfaceDetails.maxImageCount = details.maxImageCount;
|
||||||
|
@@ -10,9 +10,15 @@ typedef struct type##_t* type##Handle; \
|
|||||||
typedef struct type##_t* type
|
typedef struct type##_t* type
|
||||||
|
|
||||||
// The value of this handle is defined by the implementation
|
// The value of this handle is defined by the implementation
|
||||||
|
#ifndef GN_IMPLEMENTATION
|
||||||
#define GN_IMPLEMENTATION_HANDLE(type) \
|
#define GN_IMPLEMENTATION_HANDLE(type) \
|
||||||
typedef uint64_t type##Handle; \
|
typedef uint64_t type##Handle; \
|
||||||
typedef uint64_t type
|
typedef uint64_t type
|
||||||
|
#else
|
||||||
|
#define GN_IMPLEMENTATION_HANDLE(type) \
|
||||||
|
typedef uint64_t type##Handle; \
|
||||||
|
typedef uint64_t type
|
||||||
|
#endif
|
||||||
|
|
||||||
// can be used to alias a normal handle or an implementation handle
|
// can be used to alias a normal handle or an implementation handle
|
||||||
#define GN_HANDLE_ALIAS(handle, alias) \
|
#define GN_HANDLE_ALIAS(handle, alias) \
|
||||||
@@ -20,14 +26,12 @@ typedef struct handle##_t* alias##Handle; \
|
|||||||
typedef struct handle##_t* alias
|
typedef struct handle##_t* alias
|
||||||
|
|
||||||
GN_HANDLE(gnInstance);
|
GN_HANDLE(gnInstance);
|
||||||
|
GN_IMPLEMENTATION_HANDLE(gnPhysicalDevice); // NOTE: needs to become a impl handle
|
||||||
|
|
||||||
GN_HANDLE(gnWindowSurface);
|
GN_HANDLE(gnWindowSurface);
|
||||||
GN_HANDLE(gnPresentationQueue);
|
GN_HANDLE(gnPresentationQueue);
|
||||||
GN_HANDLE(gnTexture);
|
GN_HANDLE(gnTexture);
|
||||||
GN_HANDLE(gnRenderPassDescriptor);
|
GN_HANDLE(gnRenderPassDescriptor);
|
||||||
GN_HANDLE(gnPhysicalOutputDevice);
|
|
||||||
GN_HANDLE_ALIAS(gnPhysicalOutputDevice, gnPhysicalDevice);
|
|
||||||
GN_HANDLE(gnOutputDevice);
|
GN_HANDLE(gnOutputDevice);
|
||||||
GN_HANDLE_ALIAS(gnOutputDevice, gnDevice);
|
GN_HANDLE_ALIAS(gnOutputDevice, gnDevice);
|
||||||
GN_HANDLE(gnShaderModule);
|
GN_HANDLE(gnShaderModule);
|
||||||
|
@@ -84,6 +84,14 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo*
|
|||||||
return (*instance)->functions->createInstance(*instance, info, (*instance)->functions->next, &(*instance)->allocators);
|
return (*instance)->functions->createInstance(*instance, info, (*instance)->functions->next, &(*instance)->allocators);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gnBool gnIsInstanceSuitable(gnInstance instance, gnSuitableField field) {
|
||||||
|
return instance->functions->isSuitable(instance, field, instance->functions->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
gnReturnCode gnInstanceQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices) {
|
||||||
|
return instance->functions->queryDevices(instance, count, devices, instance->functions->next);
|
||||||
|
}
|
||||||
|
|
||||||
void gnDestroyInstance(gnInstanceHandle* instance) {
|
void gnDestroyInstance(gnInstanceHandle* instance) {
|
||||||
if (instance == GN_NULL_HANDLE) return;
|
if (instance == GN_NULL_HANDLE) return;
|
||||||
(*instance)->functions->destroyInstance(*instance, (*instance)->functions->next, &(*instance)->allocators);
|
(*instance)->functions->destroyInstance(*instance, (*instance)->functions->next, &(*instance)->allocators);
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#include "gryphn_allocators.h"
|
#include "gryphn_allocators.h"
|
||||||
#include <gryphn_extensions.h>
|
#include <gryphn_extensions.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct gnApplicationInfo {
|
typedef struct gnApplicationInfo {
|
||||||
gnString applicationName;
|
gnString applicationName;
|
||||||
gnVersion applicationVersion;
|
gnVersion applicationVersion;
|
||||||
@@ -16,6 +15,10 @@ typedef struct gnApplicationInfo {
|
|||||||
gnVersion engineVersion;
|
gnVersion engineVersion;
|
||||||
} gnApplicationInfo;
|
} gnApplicationInfo;
|
||||||
|
|
||||||
|
typedef enum gnSuitableField {
|
||||||
|
GN_NON_EXISTANT_PHYSICAL_DEVICE
|
||||||
|
} gnSuitableField;
|
||||||
|
|
||||||
typedef struct gnInstanceCreateInfo {
|
typedef struct gnInstanceCreateInfo {
|
||||||
gnApplicationInfo applicationInfo;
|
gnApplicationInfo applicationInfo;
|
||||||
gnDebuggerCreateInfo debuggerInfo;
|
gnDebuggerCreateInfo debuggerInfo;
|
||||||
@@ -45,4 +48,6 @@ struct gnInstance_t {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo* info);
|
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo* info);
|
||||||
|
gnBool gnIsInstanceSuitable(gnInstance instance, gnSuitableField field);
|
||||||
|
gnReturnCode gnInstanceQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices);
|
||||||
void gnDestroyInstance(gnInstanceHandle* instance);
|
void gnDestroyInstance(gnInstanceHandle* instance);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <output_device/gryphn_physical_output_device.h>
|
#include <output_device/gryphn_physical_device.h>
|
||||||
#include <core/gryphn_return_code.h>
|
#include <core/gryphn_return_code.h>
|
||||||
|
|
||||||
typedef struct gnOutputDeviceEnabledFeatures {
|
typedef struct gnOutputDeviceEnabledFeatures {
|
||||||
@@ -24,7 +24,6 @@ typedef struct gnOutputDeviceInfo {
|
|||||||
struct gnOutputDevice_t {
|
struct gnOutputDevice_t {
|
||||||
struct gnPlatformOutputDevice_t* outputDevice;
|
struct gnPlatformOutputDevice_t* outputDevice;
|
||||||
gnOutputDeviceInfo deviceInfo;
|
gnOutputDeviceInfo deviceInfo;
|
||||||
|
|
||||||
gnInstanceHandle instance;
|
gnInstanceHandle instance;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
19
projects/core/src/output_device/gryphn_physical_device.c
Normal file
19
projects/core/src/output_device/gryphn_physical_device.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "gryphn_physical_device.h"
|
||||||
|
#include "instance/gryphn_instance.h"
|
||||||
|
#include "loader/src/gryphn_instance_functions.h"
|
||||||
|
|
||||||
|
gnPhysicalDeviceProperties gnQueryPhysicalDeviceProperties(gnInstanceHandle instance, gnPhysicalDeviceHandle device) {
|
||||||
|
return instance->functions->getPhysicalDeviceProperties(instance, device, instance->functions->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
gnPhysicalDeviceFeatures gnQueryPhysicalDeviceFeatures(gnInstanceHandle instance, gnPhysicalDeviceHandle device) {
|
||||||
|
return instance->functions->getPhysicalDeviceFeatures(instance, device, instance->functions->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
gnPhysicalDeviceLimits gnQueryPhysicalDeviceLimits(gnInstanceHandle instance, gnPhysicalDeviceHandle device) {
|
||||||
|
return instance->functions->getPhysicalDeviceLimits(instance, device, instance->functions->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
gnBool gnPhysicalDeviceCanPresentToSurface(gnInstanceHandle instance, gnPhysicalDeviceHandle device, gnWindowSurfaceHandle windowSurface) {
|
||||||
|
return instance->callingLayer->instanceFunctions._gnPhysicalDeviceCanPresentToSurface(instance, device, windowSurface);
|
||||||
|
}
|
119
projects/core/src/output_device/gryphn_physical_device.h
Normal file
119
projects/core/src/output_device/gryphn_physical_device.h
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "utils/gryphn_string.h"
|
||||||
|
#include "gryphn_handles.h"
|
||||||
|
#include <utils/math/gryphn_vec2.h>
|
||||||
|
|
||||||
|
typedef enum gnPhysicalDeviceType {
|
||||||
|
GN_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
|
||||||
|
GN_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU,
|
||||||
|
GN_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU,
|
||||||
|
GN_PHYSICAL_DEVICE_TYPE_FAKED_GPU,
|
||||||
|
GN_PHYSICAL_DEVICE_TYPE_CPU,
|
||||||
|
} gnPhysicalDeviceType;
|
||||||
|
|
||||||
|
typedef enum gnSampleCountFlags {
|
||||||
|
GN_SAMPLE_BIT_1 = 1 << 0, // 0x01
|
||||||
|
GN_SAMPLE_BIT_2 = 1 << 1, // 0x02
|
||||||
|
GN_SAMPLE_BIT_4 = 1 << 2, // 0x04
|
||||||
|
GN_SAMPLE_BIT_8 = 1 << 3, // 0x08
|
||||||
|
GN_SAMPLE_BIT_16 = 1 << 4, // 0x10
|
||||||
|
GN_SAMPLE_BIT_32 = 1 << 5, // 0x20
|
||||||
|
GN_SAMPLE_BIT_64 = 1 << 6, // 0x40
|
||||||
|
} gnSampleCountFlags;
|
||||||
|
|
||||||
|
typedef struct gnPhysicalDeviceProperties {
|
||||||
|
uint32_t driverVersion;
|
||||||
|
uint32_t deviceID;
|
||||||
|
gnString deviceName;
|
||||||
|
gnPhysicalDeviceType deviceType;
|
||||||
|
} gnPhysicalDeviceProperties;
|
||||||
|
|
||||||
|
typedef struct gnPhysicalDeviceFeatures {
|
||||||
|
gnBool uint32Index;
|
||||||
|
gnBool geometryShader;
|
||||||
|
gnBool tessellationShader;
|
||||||
|
gnBool multiDrawIndirect;
|
||||||
|
gnBool drawIndirectFirstInstance;
|
||||||
|
gnBool fillModeNonSolid;
|
||||||
|
gnBool wideLines;
|
||||||
|
gnBool largePoints;
|
||||||
|
gnBool samplerAnisotropy;
|
||||||
|
} gnPhysicalDeviceFeatures;
|
||||||
|
|
||||||
|
typedef struct gnPhysicalDeviceLimits {
|
||||||
|
uint32_t maxImageExtent1D;
|
||||||
|
uint32_t maxImageExtent2D;
|
||||||
|
uint32_t maxImageExtent3D;
|
||||||
|
uint32_t maxImageExtentCube;
|
||||||
|
uint32_t maxImageArrayLayers;
|
||||||
|
uint32_t maxTexelBufferElements;
|
||||||
|
uint32_t maxUniformBufferRange;
|
||||||
|
uint32_t maxStorageBufferRange;
|
||||||
|
uint32_t maxPushConstantsSize;
|
||||||
|
uint32_t maxMemoryAllocationCount;
|
||||||
|
uint32_t maxSamplerAllocationCount;
|
||||||
|
uint32_t maxBoundUniforms;
|
||||||
|
uint32_t maxPerStageUniformSamplers;
|
||||||
|
uint32_t maxPerStageUniformUniformBuffers;
|
||||||
|
uint32_t maxPerStageUniformStorageBuffers;
|
||||||
|
uint32_t maxPerStageUniformSampledImages;
|
||||||
|
uint32_t maxPerStageUniformStorageImages;
|
||||||
|
uint32_t maxPerStageUniformInputAttachments;
|
||||||
|
uint32_t maxPerStageResources;
|
||||||
|
uint32_t maxUniformSamplers;
|
||||||
|
uint32_t maxUniformUniformBuffers;
|
||||||
|
uint32_t maxUniformUniformBuffersDynamic;
|
||||||
|
uint32_t maxUniformStorageBuffers;
|
||||||
|
uint32_t maxUniformStorageBuffersDynamic;
|
||||||
|
uint32_t maxUniformSampledImages;
|
||||||
|
uint32_t maxUniformStorageImages;
|
||||||
|
uint32_t maxUniformInputAttachments;
|
||||||
|
uint32_t maxVertexInputAttributes;
|
||||||
|
uint32_t maxVertexInputBindings;
|
||||||
|
uint32_t maxVertexInputAttributeOffset;
|
||||||
|
uint32_t maxVertexInputBindingStride;
|
||||||
|
uint32_t maxVertexOutputComponents;
|
||||||
|
uint32_t maxTessellationGenerationLevel;
|
||||||
|
uint32_t maxTessellationPatchSize;
|
||||||
|
uint32_t maxTessellationControlPerVertexInputComponents;
|
||||||
|
uint32_t maxTessellationControlPerVertexOutputComponents;
|
||||||
|
uint32_t maxTessellationControlPerPatchOutputComponents;
|
||||||
|
uint32_t maxTessellationControlTotalOutputComponents;
|
||||||
|
uint32_t maxTessellationEvaluationInputComponents;
|
||||||
|
uint32_t maxTessellationEvaluationOutputComponents;
|
||||||
|
uint32_t maxGeometryShaderInvocations;
|
||||||
|
uint32_t maxGeometryInputComponents;
|
||||||
|
uint32_t maxGeometryOutputComponents;
|
||||||
|
uint32_t maxGeometryOutputVertices;
|
||||||
|
uint32_t maxGeometryTotalOutputComponents;
|
||||||
|
uint32_t maxFragmentInputComponents;
|
||||||
|
uint32_t maxFragmentOutputAttachments;
|
||||||
|
uint32_t maxFragmentDualSrcAttachments;
|
||||||
|
uint32_t maxFragmentCombinedOutputResources;
|
||||||
|
uint32_t maxDrawIndexedIndexValue;
|
||||||
|
uint32_t maxDrawIndirectCount;
|
||||||
|
float maxSamplerLodBias;
|
||||||
|
float maxSamplerAnisotropy;
|
||||||
|
uint32_t maxViewports;
|
||||||
|
uint32_t maxViewportExtents[2];
|
||||||
|
float viewportBoundsRange[2];
|
||||||
|
gnExtent2D maxFramebufferExtent;
|
||||||
|
uint32_t maxFramebufferLayers;
|
||||||
|
gnSampleCountFlags framebufferColorSampleCounts;
|
||||||
|
gnSampleCountFlags framebufferDepthSampleCounts;
|
||||||
|
gnSampleCountFlags framebufferStencilSampleCounts;
|
||||||
|
gnSampleCountFlags framebufferNoAttachmentsSampleCounts;
|
||||||
|
uint32_t maxColorAttachments;
|
||||||
|
float pointSizeRange[2];
|
||||||
|
float lineWidthRange[2];
|
||||||
|
float pointSizeGranularity;
|
||||||
|
float lineWidthGranularity;
|
||||||
|
gnBool strictLines;
|
||||||
|
} gnPhysicalDeviceLimits;
|
||||||
|
|
||||||
|
gnPhysicalDeviceProperties gnQueryPhysicalDeviceProperties(gnInstanceHandle instance, gnPhysicalDeviceHandle device);
|
||||||
|
gnPhysicalDeviceFeatures gnQueryPhysicalDeviceFeatures(gnInstanceHandle instance, gnPhysicalDeviceHandle device);
|
||||||
|
gnPhysicalDeviceLimits gnQueryPhysicalDeviceLimits(gnInstanceHandle instance, gnPhysicalDeviceHandle device);
|
||||||
|
|
||||||
|
gnBool gnPhysicalDeviceCanPresentToSurface(gnInstance instance, gnPhysicalDeviceHandle device, gnWindowSurfaceHandle windowSurface);
|
@@ -1,17 +0,0 @@
|
|||||||
#include "gryphn_physical_output_device.h"
|
|
||||||
#include "instance/gryphn_instance.h"
|
|
||||||
#include "loader/src/gryphn_instance_functions.h"
|
|
||||||
|
|
||||||
gnPhysicalOutputDeviceHandle* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* count) {;
|
|
||||||
gnPhysicalOutputDeviceHandle* devices = instance->callingLayer->instanceFunctions._gnGetPhysicalDevices(instance, count);
|
|
||||||
for (uint32_t i = 0; i < *count; i++)
|
|
||||||
devices[i]->instance = instance;
|
|
||||||
return devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
gnBool gnPhysicalDeviceCanPresentToSurface(gnPhysicalOutputDeviceHandle device, gnWindowSurfaceHandle windowSurface) {
|
|
||||||
return device->instance->callingLayer->instanceFunctions._gnPhysicalDeviceCanPresentToSurface(device, windowSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalOutputDeviceHandle device) { return device->properties; }
|
|
||||||
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalOutputDeviceHandle device) { return device->features; }
|
|
@@ -1,45 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "stdint.h"
|
|
||||||
#include "utils/gryphn_string.h"
|
|
||||||
#include "gryphn_handles.h"
|
|
||||||
|
|
||||||
typedef enum gnDeviceType {
|
|
||||||
GN_DEDICATED_DEVICE, GN_INTEGRATED_DEVICE, GN_EXTERNAL_DEVICE
|
|
||||||
} gnDeviceType;
|
|
||||||
|
|
||||||
typedef enum gnMultisampleCountFlags {
|
|
||||||
GN_SAMPLE_BIT_1 = 1 << 0, // 0x01
|
|
||||||
GN_SAMPLE_BIT_2 = 1 << 1, // 0x02
|
|
||||||
GN_SAMPLE_BIT_4 = 1 << 2, // 0x04
|
|
||||||
GN_SAMPLE_BIT_8 = 1 << 3, // 0x08
|
|
||||||
GN_SAMPLE_BIT_16 = 1 << 4, // 0x10
|
|
||||||
GN_SAMPLE_BIT_32 = 1 << 5, // 0x20
|
|
||||||
GN_SAMPLE_BIT_64 = 1 << 6, // 0x40
|
|
||||||
} gnMultisampleCountFlags;
|
|
||||||
|
|
||||||
typedef struct gnPhysicalDeviceProperties {
|
|
||||||
gnString name;
|
|
||||||
gnDeviceType deviceType;
|
|
||||||
} gnPhysicalDeviceProperties;
|
|
||||||
|
|
||||||
typedef struct gnPhysicalDeviceFeatures {
|
|
||||||
gnMultisampleCountFlags maxColorSamples, maxDepthSamples;
|
|
||||||
uint32_t maxMemoryAllocations;
|
|
||||||
uint32_t maxPushConstantSize;
|
|
||||||
} gnPhysicalDeviceFeatures;
|
|
||||||
|
|
||||||
#ifdef GN_REVEAL_IMPL
|
|
||||||
typedef struct gnPhysicalOutputDevice_t {
|
|
||||||
struct gnPlatformPhysicalDevice_t* physicalDevice;
|
|
||||||
gnPhysicalDeviceProperties properties;
|
|
||||||
gnPhysicalDeviceFeatures features;
|
|
||||||
|
|
||||||
gnInstanceHandle instance;
|
|
||||||
} gnPhysicalOutputDevice_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gnPhysicalOutputDeviceHandle* gnGetPhyscialDevices(gnInstanceHandle instance, uint32_t* count);
|
|
||||||
gnBool gnPhysicalDeviceCanPresentToSurface(gnPhysicalOutputDeviceHandle device, gnWindowSurfaceHandle windowSurface);
|
|
||||||
|
|
||||||
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalOutputDeviceHandle device);
|
|
||||||
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalOutputDeviceHandle device);
|
|
@@ -47,7 +47,7 @@ typedef struct gnScissor {
|
|||||||
} gnScissor;
|
} gnScissor;
|
||||||
|
|
||||||
typedef struct gnMultisample {
|
typedef struct gnMultisample {
|
||||||
gnMultisampleCountFlags samples;
|
gnSampleCountFlags samples;
|
||||||
} gnMultisample;
|
} gnMultisample;
|
||||||
|
|
||||||
typedef enum gnFillMode {
|
typedef enum gnFillMode {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "core/gryphn_image_format.h"
|
#include "core/gryphn_image_format.h"
|
||||||
#include "core/gryphn_return_code.h"
|
#include "core/gryphn_return_code.h"
|
||||||
#include "core/src/output_device/gryphn_physical_output_device.h"
|
#include "core/src/output_device/gryphn_physical_device.h"
|
||||||
#include "gryphn_handles.h"
|
#include "gryphn_handles.h"
|
||||||
|
|
||||||
typedef enum gnRenderPassStage {
|
typedef enum gnRenderPassStage {
|
||||||
@@ -34,7 +34,7 @@ typedef struct gnRenderPassAttachmentInfo_t {
|
|||||||
gnImageLayout initialLayout;
|
gnImageLayout initialLayout;
|
||||||
gnImageLayout finalLayout;
|
gnImageLayout finalLayout;
|
||||||
|
|
||||||
gnMultisampleCountFlags samples;
|
gnSampleCountFlags samples;
|
||||||
} gnRenderPassAttachmentInfo;
|
} gnRenderPassAttachmentInfo;
|
||||||
|
|
||||||
typedef struct gnSubpassAttachmentInfo_t {
|
typedef struct gnSubpassAttachmentInfo_t {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#include "core/gryphn_image_format.h"
|
#include "core/gryphn_image_format.h"
|
||||||
#include "core/gryphn_return_code.h"
|
#include "core/gryphn_return_code.h"
|
||||||
#include "utils/math/gryphn_vec3.h"
|
#include "utils/math/gryphn_vec3.h"
|
||||||
#include "core/src/output_device/gryphn_physical_output_device.h"
|
#include "core/src/output_device/gryphn_physical_device.h"
|
||||||
#include <gryphn_handles.h>
|
#include <gryphn_handles.h>
|
||||||
|
|
||||||
typedef enum gnTextureType {
|
typedef enum gnTextureType {
|
||||||
@@ -27,7 +27,7 @@ typedef enum gnTextureUsageFlags {
|
|||||||
|
|
||||||
typedef struct gnTextureInfo {
|
typedef struct gnTextureInfo {
|
||||||
gnExtent3D extent;
|
gnExtent3D extent;
|
||||||
gnMultisampleCountFlags samples;
|
gnSampleCountFlags samples;
|
||||||
gnTextureUsageFlags usage;
|
gnTextureUsageFlags usage;
|
||||||
uint32_t mipmapLevels;
|
uint32_t mipmapLevels;
|
||||||
gnTextureType type;
|
gnTextureType type;
|
||||||
|
@@ -16,4 +16,4 @@ typedef struct gnQueueFamilyProperties {
|
|||||||
gnQueueTypeFlags queueTypeFlags;
|
gnQueueTypeFlags queueTypeFlags;
|
||||||
} gnQueueFamilyProperties;
|
} gnQueueFamilyProperties;
|
||||||
|
|
||||||
gnReturnCode gnGetPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues);
|
gnReturnCode gnGetPhysicalDeviceQueueProperties(gnPhysicalDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues);
|
||||||
|
@@ -10,7 +10,7 @@ typedef struct gnPresentInfo gnPresentInfo;
|
|||||||
typedef struct gnPresentSyncInfo gnPresentSyncInfo;
|
typedef struct gnPresentSyncInfo gnPresentSyncInfo;
|
||||||
|
|
||||||
typedef struct gnQueueExtFunctions {
|
typedef struct gnQueueExtFunctions {
|
||||||
gnReturnCode (*_gnGetPhysicalDeviceQueueProperties)(gnPhysicalOutputDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues);
|
gnReturnCode (*_gnGetPhysicalDeviceQueueProperties)(gnPhysicalDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues);
|
||||||
void (*_gnGetDeviceQueue)(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue);
|
void (*_gnGetDeviceQueue)(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue);
|
||||||
|
|
||||||
gnReturnCode (*_gnQueueSubmit)(gnOutputDevice device, gnQueue queue, gnSubmitInfo info);
|
gnReturnCode (*_gnQueueSubmit)(gnOutputDevice device, gnQueue queue, gnSubmitInfo info);
|
||||||
|
@@ -8,7 +8,10 @@
|
|||||||
typedef struct gnInstanceCreateInfo gnInstanceCreateInfo;
|
typedef struct gnInstanceCreateInfo gnInstanceCreateInfo;
|
||||||
typedef struct gnSurfaceDetails gnSurfaceDetails;
|
typedef struct gnSurfaceDetails gnSurfaceDetails;
|
||||||
typedef struct gnOutputDeviceInfo gnOutputDeviceInfo;
|
typedef struct gnOutputDeviceInfo gnOutputDeviceInfo;
|
||||||
|
typedef enum gnSuitableField gnSuitableField;
|
||||||
|
typedef struct gnPhysicalDeviceProperties gnPhysicalDeviceProperties;
|
||||||
|
typedef struct gnPhysicalDeviceFeatures gnPhysicalDeviceFeatures;
|
||||||
|
typedef struct gnPhysicalDeviceLimits gnPhysicalDeviceLimits;
|
||||||
|
|
||||||
#ifdef GN_PLATFORM_LINUX
|
#ifdef GN_PLATFORM_LINUX
|
||||||
#ifdef GN_WINDOW_X11
|
#ifdef GN_WINDOW_X11
|
||||||
@@ -20,12 +23,17 @@ typedef struct gnOutputDeviceInfo gnOutputDeviceInfo;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct gryphnInstanceFunctionLayers gryphnInstanceFunctionLayers;
|
typedef struct gryphnInstanceFunctionLayers gryphnInstanceFunctionLayers;
|
||||||
typedef gnReturnCode (*PFN_gnCreateInstance)(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
typedef gnReturnCode (*PFN_gnCreateInstance)(gnInstanceHandle, gnInstanceCreateInfo*, gryphnInstanceFunctionLayers*, gnAllocators*);
|
||||||
typedef void (*PFN_gnDestroyInstance)(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
typedef gnBool (*PFN_gnIsInstanceSuitable)(gnInstanceHandle, gnSuitableField, gryphnInstanceFunctionLayers*);
|
||||||
|
typedef gnReturnCode (*PFN_gnInstanceQueryDevices)(gnInstanceHandle, uint32_t*, gnPhysicalDeviceHandle*, gryphnInstanceFunctionLayers*);
|
||||||
|
typedef void (*PFN_gnDestroyInstance)(gnInstanceHandle, gryphnInstanceFunctionLayers*, gnAllocators*);
|
||||||
|
|
||||||
|
typedef gnPhysicalDeviceProperties (*PFN_gnQueryPhysicalDeviceProperties)(gnInstance, gnPhysicalDeviceHandle, gryphnInstanceFunctionLayers*);
|
||||||
|
typedef gnPhysicalDeviceFeatures (*PFN_gnQueryPhysicalDeviceFeatures)(gnInstanceHandle, gnPhysicalDeviceHandle, gryphnInstanceFunctionLayers*);
|
||||||
|
typedef gnPhysicalDeviceLimits (*PFN_gnQueryPhysicalDeviceLimits)(gnInstanceHandle, gnPhysicalDeviceHandle, gryphnInstanceFunctionLayers*);
|
||||||
|
|
||||||
typedef struct gnInstanceFunctions {
|
typedef struct gnInstanceFunctions {
|
||||||
gnPhysicalDevice* (*_gnGetPhysicalDevices)(gnInstanceHandle instance, uint32_t* count);
|
gnBool (*_gnPhysicalDeviceCanPresentToSurface)(gnInstance instance, gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
|
||||||
gnBool (*_gnPhysicalDeviceCanPresentToSurface)(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
|
|
||||||
|
|
||||||
gnReturnCode (*_gnCreateOutputDevice)(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo);
|
gnReturnCode (*_gnCreateOutputDevice)(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo);
|
||||||
void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device);
|
void (*_gnDestroyOutputDevice)(gnOutputDeviceHandle device);
|
||||||
|
@@ -15,7 +15,12 @@ typedef struct gryphnFunctionLayer {
|
|||||||
|
|
||||||
typedef struct gryphnInstanceFunctionLayers {
|
typedef struct gryphnInstanceFunctionLayers {
|
||||||
PFN_gnCreateInstance createInstance;
|
PFN_gnCreateInstance createInstance;
|
||||||
|
PFN_gnIsInstanceSuitable isSuitable;
|
||||||
|
PFN_gnInstanceQueryDevices queryDevices;
|
||||||
PFN_gnDestroyInstance destroyInstance;
|
PFN_gnDestroyInstance destroyInstance;
|
||||||
|
PFN_gnQueryPhysicalDeviceProperties getPhysicalDeviceProperties;
|
||||||
|
PFN_gnQueryPhysicalDeviceFeatures getPhysicalDeviceFeatures;
|
||||||
|
PFN_gnQueryPhysicalDeviceLimits getPhysicalDeviceLimits;
|
||||||
struct gryphnInstanceFunctionLayers* next;
|
struct gryphnInstanceFunctionLayers* next;
|
||||||
} gryphnInstanceFunctionLayers;
|
} gryphnInstanceFunctionLayers;
|
||||||
|
|
||||||
|
Submodule projects/utils updated: 9833dc3c12...7d818db7f9
@@ -1,6 +1,6 @@
|
|||||||
#include "queue_functions.h"
|
#include "queue_functions.h"
|
||||||
#include "loader_utils.h"
|
#include "loader_utils.h"
|
||||||
#include "core/src/output_device/gryphn_physical_output_device.h"
|
#include "core/src/output_device/gryphn_physical_device.h"
|
||||||
#include "core/src/output_device/gryphn_output_device.h"
|
#include "core/src/output_device/gryphn_output_device.h"
|
||||||
#include <core/src/instance/gryphn_debugger.h>
|
#include <core/src/instance/gryphn_debugger.h>
|
||||||
#include <core/src/instance/gryphn_instance.h>
|
#include <core/src/instance/gryphn_instance.h>
|
||||||
@@ -9,8 +9,9 @@
|
|||||||
#include "extensions/synchronization/commands/gryphn_sync_submit.h"
|
#include "extensions/synchronization/commands/gryphn_sync_submit.h"
|
||||||
#include "extensions/synchronization/commands/gryphn_sync_present.h"
|
#include "extensions/synchronization/commands/gryphn_sync_present.h"
|
||||||
|
|
||||||
gnReturnCode checkGetPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues) {
|
gnReturnCode checkGetPhysicalDeviceQueueProperties(gnPhysicalDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues) {
|
||||||
CHECK_FUNCTION_WITH_RETURN_CODE(device->instance, _gnGetPhysicalDeviceQueueProperties, queueFunctions, device, queueCount, queues);
|
// CHECK_FUNCTION_WITH_RETURN_CODE(device->instance, _gnGetPhysicalDeviceQueueProperties, queueFunctions, device, queueCount, queues);
|
||||||
|
return GN_UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
void checkGetDeviceQueue(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue) {
|
void checkGetDeviceQueue(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue) {
|
||||||
CHECK_VOID_FUNCTION(device->instance, _gnGetDeviceQueue, queueFunctions, device, queueFamily, queueIndex, queue);
|
CHECK_VOID_FUNCTION(device->instance, _gnGetDeviceQueue, queueFunctions, device, queueFamily, queueIndex, queue);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#include <loader/src/gryphn_loader.h>
|
#include <loader/src/gryphn_loader.h>
|
||||||
|
|
||||||
gnReturnCode checkGetPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues);
|
gnReturnCode checkGetPhysicalDeviceQueueProperties(gnPhysicalDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues);
|
||||||
void checkGetDeviceQueue(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue);
|
void checkGetDeviceQueue(gnOutputDevice device, uint32_t queueFamily, uint32_t queueIndex, gnQueue* queue);
|
||||||
|
|
||||||
gnReturnCode checkQueueSubmit(gnOutputDevice device, gnQueue queue, gnSubmitInfo info);
|
gnReturnCode checkQueueSubmit(gnOutputDevice device, gnQueue queue, gnSubmitInfo info);
|
||||||
|
@@ -8,13 +8,18 @@
|
|||||||
gryphnInstanceFunctionLayers checkerLoadInstanceFunctions(void) {
|
gryphnInstanceFunctionLayers checkerLoadInstanceFunctions(void) {
|
||||||
return (gryphnInstanceFunctionLayers) {
|
return (gryphnInstanceFunctionLayers) {
|
||||||
.createInstance = checkCreateInstance,
|
.createInstance = checkCreateInstance,
|
||||||
.destroyInstance = checkDestroyInstance
|
.isSuitable = checkIsInstanceSuitable,
|
||||||
|
.queryDevices = checkQueryDevices,
|
||||||
|
.destroyInstance = checkDestroyInstance,
|
||||||
|
.getPhysicalDeviceProperties = checkQueryPhysicalDeviceProperties,
|
||||||
|
.getPhysicalDeviceFeatures = checkQueryPhysicalDeviceFeatures,
|
||||||
|
.getPhysicalDeviceLimits = checkQueryPhysicalDeviceLimits,
|
||||||
|
.next = GN_NULL_HANDLE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
gnInstanceFunctions loadFunctionLoaderInstanceFunctions(void) {
|
gnInstanceFunctions loadFunctionLoaderInstanceFunctions(void) {
|
||||||
return (gnInstanceFunctions){
|
return (gnInstanceFunctions){
|
||||||
._gnGetPhysicalDevices = checkGetPhysicalDevices,
|
|
||||||
._gnPhysicalDeviceCanPresentToSurface = checkCanDevicePresent,
|
._gnPhysicalDeviceCanPresentToSurface = checkCanDevicePresent,
|
||||||
|
|
||||||
._gnCreateOutputDevice = checkCreateOutputDevice,
|
._gnCreateOutputDevice = checkCreateOutputDevice,
|
||||||
|
@@ -24,11 +24,61 @@ void checkDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayer
|
|||||||
next->destroyInstance(instance, next->next, alloctors);
|
next->destroyInstance(instance, next->next, alloctors);
|
||||||
}
|
}
|
||||||
|
|
||||||
gnPhysicalDevice* checkGetPhysicalDevices(gnInstanceHandle instance, uint32_t* count) {
|
gnBool checkIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next) {
|
||||||
CHECK_RETURNED_FUNCTION(instance, _gnGetPhysicalDevices, instanceFunctions, NULL, instance, count);
|
if (next == NULL || next->isSuitable == NULL) {
|
||||||
|
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
|
||||||
|
.message = gnCreateString("Failed to load gnIsInstanceSuitable this indicates a bug within gryphn")
|
||||||
|
});
|
||||||
|
return GN_FAILED_TO_LOAD_FUNCTION;
|
||||||
|
}
|
||||||
|
return next->isSuitable(instance, field, next);
|
||||||
}
|
}
|
||||||
gnBool checkCanDevicePresent(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface) {
|
|
||||||
CHECK_RETURNED_FUNCTION(device->instance, _gnPhysicalDeviceCanPresentToSurface, instanceFunctions, GN_FALSE, device, windowSurface);
|
gnReturnCode checkQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next) {
|
||||||
|
if (next == NULL || next->queryDevices == NULL) {
|
||||||
|
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
|
||||||
|
.message = gnCreateString("Failed to load gnQueryDevices this indicates a bug within gryphn")
|
||||||
|
});
|
||||||
|
return GN_FAILED_TO_LOAD_FUNCTION;
|
||||||
|
}
|
||||||
|
return next->queryDevices(instance, count, devices, next->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
gnPhysicalDeviceProperties checkQueryPhysicalDeviceProperties(gnInstanceHandle instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* next) {
|
||||||
|
if (next == NULL || next->getPhysicalDeviceProperties == NULL) {
|
||||||
|
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
|
||||||
|
.message = gnCreateString("Failed to load gnQueryPhysicalDeviceProperties this indicates a bug within gryphn")
|
||||||
|
});
|
||||||
|
return (gnPhysicalDeviceProperties){
|
||||||
|
.deviceID = -1,
|
||||||
|
.deviceName = gnCreateString("Invalid device"),
|
||||||
|
.deviceType = GN_PHYSICAL_DEVICE_TYPE_FAKED_GPU,
|
||||||
|
.driverVersion = -1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return next->getPhysicalDeviceProperties(instance, device, next->next);
|
||||||
|
}
|
||||||
|
gnPhysicalDeviceFeatures checkQueryPhysicalDeviceFeatures(gnInstanceHandle instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* next) {
|
||||||
|
if (next == NULL || next->getPhysicalDeviceFeatures == NULL) {
|
||||||
|
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
|
||||||
|
.message = gnCreateString("Failed to load gnQueryPhysicalDeviceFeatures this indicates a bug within gryphn")
|
||||||
|
});
|
||||||
|
return (gnPhysicalDeviceFeatures){};
|
||||||
|
}
|
||||||
|
return next->getPhysicalDeviceFeatures(instance, device, next->next);
|
||||||
|
}
|
||||||
|
gnPhysicalDeviceLimits checkQueryPhysicalDeviceLimits(gnInstanceHandle instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* next) {
|
||||||
|
if (next == NULL || next->getPhysicalDeviceLimits == NULL) {
|
||||||
|
gnDebuggerSetErrorMessage(instance->debugger, (gnMessageData){
|
||||||
|
.message = gnCreateString("Failed to load gnQueryPhysicalDeviceLimits this indicates a bug within gryphn")
|
||||||
|
});
|
||||||
|
return (gnPhysicalDeviceLimits){};
|
||||||
|
}
|
||||||
|
return next->getPhysicalDeviceLimits(instance, device, next->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
gnBool checkCanDevicePresent(gnInstance instance, gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface) {
|
||||||
|
CHECK_RETURNED_FUNCTION(instance, _gnPhysicalDeviceCanPresentToSurface, instanceFunctions, GN_FALSE, instance, device, windowSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode checkCreateOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo) {
|
gnReturnCode checkCreateOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo) {
|
||||||
|
@@ -3,11 +3,16 @@
|
|||||||
#include <core/src/window_surface/gryphn_surface_create_functions.h>
|
#include <core/src/window_surface/gryphn_surface_create_functions.h>
|
||||||
|
|
||||||
gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
gnReturnCode checkCreateInstance(gnInstanceHandle instance, gnInstanceCreateInfo* info, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
||||||
|
gnBool checkIsInstanceSuitable(gnInstanceHandle instance, gnSuitableField field, gryphnInstanceFunctionLayers* next);
|
||||||
|
gnReturnCode checkQueryDevices(gnInstanceHandle instance, uint32_t* count, gnPhysicalDeviceHandle* devices, gryphnInstanceFunctionLayers* next);
|
||||||
void checkDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
void checkDestroyInstance(gnInstanceHandle instance, gryphnInstanceFunctionLayers* next, gnAllocators* alloctors);
|
||||||
|
|
||||||
gnPhysicalDevice* checkGetPhysicalDevices(gnInstanceHandle instance, uint32_t* count);
|
gnPhysicalDeviceProperties checkQueryPhysicalDeviceProperties(gnInstanceHandle instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* next);
|
||||||
gnBool checkCanDevicePresent(gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
|
gnPhysicalDeviceFeatures checkQueryPhysicalDeviceFeatures(gnInstanceHandle instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* next);
|
||||||
|
gnPhysicalDeviceLimits checkQueryPhysicalDeviceLimits(gnInstanceHandle instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* next);
|
||||||
|
|
||||||
|
// old ahh functions (currently working on removing)
|
||||||
|
gnBool checkCanDevicePresent(gnInstance instance, gnPhysicalDevice device, gnWindowSurfaceHandle windowSurface);
|
||||||
gnReturnCode checkCreateOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo);
|
gnReturnCode checkCreateOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo);
|
||||||
void checkDestroyOutputDevice(gnOutputDeviceHandle device);
|
void checkDestroyOutputDevice(gnOutputDeviceHandle device);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user