generic OpenGL device
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
#include "opengl_loader.h"
|
#include "opengl_loader.h"
|
||||||
#include "instance/opengl_instance.h"
|
#include "instance/opengl_instance.h"
|
||||||
#include "surface/opengl_surface.h"
|
#include "surface/opengl_surface.h"
|
||||||
|
#include "device/opengl_physical_device.h"
|
||||||
|
|
||||||
gnInstanceFunctions loadOpenGLInstanceFunctions() {
|
gnInstanceFunctions loadOpenGLInstanceFunctions() {
|
||||||
return (gnInstanceFunctions){
|
return (gnInstanceFunctions){
|
||||||
._gnCreateInstance = createOpenGLInstance,
|
._gnCreateInstance = createOpenGLInstance,
|
||||||
._gnDestroyInstance = destroyOpenGLInstance,
|
._gnDestroyInstance = destroyOpenGLInstance,
|
||||||
// ._gnGetPhysicalDevices = getMetalDevices,
|
._gnGetPhysicalDevices = getOpenGLDevice,
|
||||||
// ._gnQueueCanPresentToSurface = metalCanQueuePresentToSurface,
|
._gnQueueCanPresentToSurface = openGLQueueCanPresent,
|
||||||
// ._gnCreateOutputDevice = createMetalOutputDevice,
|
// ._gnCreateOutputDevice = createMetalOutputDevice,
|
||||||
// ._gnDestroyOutputDevice = destroyMetalOutputDevice,
|
// ._gnDestroyOutputDevice = destroyMetalOutputDevice,
|
||||||
#ifdef GN_PLATFORM_LINUX
|
#ifdef GN_PLATFORM_LINUX
|
||||||
|
35
projects/apis/opengl/src/device/opengl_physical_device.c
Normal file
35
projects/apis/opengl/src/device/opengl_physical_device.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "opengl_physical_device.h"
|
||||||
|
|
||||||
|
gnPhysicalDevice* getOpenGLDevice(gnInstanceHandle instance, uint32_t* deviceCount) {
|
||||||
|
*deviceCount = 1;
|
||||||
|
|
||||||
|
gnPhysicalDevice* devices = malloc(sizeof(gnPhysicalDevice));
|
||||||
|
|
||||||
|
gnPhysicalDevice device = {
|
||||||
|
.physicalDevice = malloc(sizeof(gnPlatformPhysicalDevice)),
|
||||||
|
.features = {
|
||||||
|
.maxColorSamples = GN_SAMPLE_BIT_1,
|
||||||
|
.maxDepthSamples = GN_SAMPLE_BIT_1,
|
||||||
|
.maxMemoryAllocations = 0x40000000,
|
||||||
|
.maxPushConstantSize = 256
|
||||||
|
},
|
||||||
|
.properties = {
|
||||||
|
.deviceType = GN_DEDICATED_DEVICE,
|
||||||
|
.name = gnCreateString("Generic OpenGL device")
|
||||||
|
},
|
||||||
|
.queueProperties = {
|
||||||
|
.queueCount = 1,
|
||||||
|
.queueProperties = (gnQueueProperties[1]){
|
||||||
|
(gnQueueProperties){
|
||||||
|
.queueCount = 1,
|
||||||
|
.queueType = GN_QUEUE_GRAPHICS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
devices[0] = device;
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
gnBool openGLQueueCanPresent(const gnPhysicalDevice device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface) {
|
||||||
|
return gnTrue;
|
||||||
|
}
|
8
projects/apis/opengl/src/device/opengl_physical_device.h
Normal file
8
projects/apis/opengl/src/device/opengl_physical_device.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include "output_device/gryphn_physical_output_device.h"
|
||||||
|
|
||||||
|
typedef struct gnPlatformPhysicalDevice_t {} gnPlatformPhysicalDevice;
|
||||||
|
|
||||||
|
gnPhysicalDevice* getOpenGLDevice(gnInstanceHandle instance, uint32_t* deviceCount);
|
||||||
|
gnBool openGLQueueCanPresent(const gnPhysicalDevice device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface);
|
@@ -23,7 +23,7 @@ gnBool gnQueueCanPresentToSurface(const gnPhysicalDevice device, uint32_t queueI
|
|||||||
|
|
||||||
gnBool gnHasGraphicsQueue(const gnPhysicalDevice device) {
|
gnBool gnHasGraphicsQueue(const gnPhysicalDevice device) {
|
||||||
for (int i = 0; i < device.queueProperties.queueCount; i++) {
|
for (int i = 0; i < device.queueProperties.queueCount; i++) {
|
||||||
if (device.queueProperties.queueProperties[i].queueType & GN_QUEUE_GRAPHICS) {
|
if ((device.queueProperties.queueProperties[i].queueType & GN_QUEUE_GRAPHICS) == GN_QUEUE_GRAPHICS) {
|
||||||
return gnTrue;
|
return gnTrue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ gnBool gnHasPresentQueue(const gnPhysicalDevice device, gnWindowSurfaceHandle wi
|
|||||||
|
|
||||||
int gnGetGraphicsQueueIndex(const gnPhysicalDevice device) {
|
int gnGetGraphicsQueueIndex(const gnPhysicalDevice device) {
|
||||||
for (int i = 0; i < device.queueProperties.queueCount; i++) {
|
for (int i = 0; i < device.queueProperties.queueCount; i++) {
|
||||||
if (device.queueProperties.queueProperties[i].queueType & GN_QUEUE_GRAPHICS) {
|
if ((device.queueProperties.queueProperties[i].queueType & GN_QUEUE_GRAPHICS) == GN_QUEUE_GRAPHICS) {
|
||||||
return i;
|
return i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -29,10 +29,10 @@ typedef struct gnPhysicalDeviceFeatures {
|
|||||||
} gnPhysicalDeviceFeatures;
|
} gnPhysicalDeviceFeatures;
|
||||||
|
|
||||||
typedef enum gnQueueTypeFlags {
|
typedef enum gnQueueTypeFlags {
|
||||||
GN_QUEUE_GRAPHICS = 1,
|
GN_QUEUE_GRAPHICS = 1 << 0,
|
||||||
GN_QUEUE_COMPUTE = 2,
|
GN_QUEUE_COMPUTE = 1 << 1,
|
||||||
GN_QUEUE_TRANSFER = 4,
|
GN_QUEUE_TRANSFER = 1 << 2,
|
||||||
GN_QUEUE_SPARSE_BINDING = 8
|
GN_QUEUE_SPARSE_BINDING = 1 << 3
|
||||||
} gnQueueTypeFlags;
|
} gnQueueTypeFlags;
|
||||||
|
|
||||||
typedef struct gnQueueProperties {
|
typedef struct gnQueueProperties {
|
||||||
|
Reference in New Issue
Block a user