enumerate all physical devices
This commit is contained in:
@@ -1,9 +1,16 @@
|
|||||||
|
#import "Metal/Metal.h"
|
||||||
#include "metal_functions.h"
|
#include "metal_functions.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
|
||||||
gnReturnCode metalEnumeratePhysicalDevices(gnInstance instance, uint32_t* deviceCount, gnPhysicalDevice* devices) {
|
gnReturnCode metalEnumeratePhysicalDevices(gnInstance instance, uint32_t* deviceCount, gnPhysicalDevice* devices) {
|
||||||
*deviceCount = 0;
|
NSArray<id<MTLDevice>>* mtlDevices = MTLCopyAllDevices();
|
||||||
|
uint32_t systemCount = (uint32_t)[mtlDevices count];
|
||||||
|
*deviceCount = systemCount;
|
||||||
|
|
||||||
|
if (devices == NULL)
|
||||||
|
return GN_SUCCESS;
|
||||||
|
for (uint32_t i = 0; i < *deviceCount; i++)
|
||||||
|
devices[i] = (gnPhysicalDevice)mtlDevices[i];
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
c
|
|
||||||
|
|||||||
Reference in New Issue
Block a user