metal physical device properties function
This commit is contained in:
@@ -8,6 +8,8 @@ gryphnInstanceFunctionLayers metalLoadAPILayer(void) {
|
||||
.createInstance = metalCreateInstance,
|
||||
.queryDevices = metalQueryDevices,
|
||||
.destroyInstance = metalDestroyInstance,
|
||||
// .isSuitable = metalIsInstanceSuitable,
|
||||
.getPhysicalDeviceProperties = metalQueryPhysicalDeviceProperties,
|
||||
.next = NULL
|
||||
};
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include <MetalKit/MetalKit.h>
|
||||
|
||||
typedef id<MTLDevice> mtlDevice;
|
||||
gnPhysicalDeviceProperties metalQueryPhysicalDeviceProperties(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers);
|
||||
|
||||
struct gnPlatformOutputDevice_t {
|
||||
id<MTLDevice> device;
|
||||
|
@@ -3,39 +3,25 @@
|
||||
#include "metal_output_devices.h"
|
||||
#include "window_surface/gryphn_surface.h"
|
||||
|
||||
// gnPhysicalDevice* getMetalDevices(gnInstanceHandle instance, uint32_t* deviceCount) {
|
||||
// if (instance == GN_NULL_HANDLE) return NULL;
|
||||
// i made some educated guesses on these conversions and I dont think they are going to work
|
||||
// but for now im worried about the MVP
|
||||
gnPhysicalDeviceType metalDeviceLocationToGryphn(MTLDeviceLocation location) {
|
||||
switch (location) {
|
||||
case MTLDeviceLocationBuiltIn: return GN_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
|
||||
case MTLDeviceLocationSlot: return GN_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
|
||||
case MTLDeviceLocationExternal: return GN_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
|
||||
case MTLDeviceLocationUnspecified: return GN_PHYSICAL_DEVICE_TYPE_FAKED_GPU; //very bad if we get here
|
||||
}
|
||||
}
|
||||
|
||||
// NSArray *devices = MTLCopyAllDevices();
|
||||
// *deviceCount = (uint32_t)[devices count];
|
||||
// gnPhysicalDevice* devicesList = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount);
|
||||
// for (uint32_t i = 0; i < *deviceCount; i++) {
|
||||
// devicesList[i] = (uint64_t)[devices objectAtIndex:0];
|
||||
// mtlDevice device = (mtlDevice)devicesList[i];
|
||||
|
||||
// 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;
|
||||
// }
|
||||
gnPhysicalDeviceProperties metalQueryPhysicalDeviceProperties(gnInstance instance, gnPhysicalDeviceHandle device, gryphnInstanceFunctionLayers* layers) {
|
||||
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(gnPhysicalDevice device, gnWindowSurface windowSurface) {
|
||||
if (device == GN_NULL_HANDLE || windowSurface == GN_NULL_HANDLE) return GN_FALSE;
|
||||
|
Reference in New Issue
Block a user