begin rewriting metal classes in objective c
This commit is contained in:
9
rendering_api/metal/src/core/debugger/metal_debugger.m
Normal file
9
rendering_api/metal/src/core/debugger/metal_debugger.m
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <core/debugger/gryphn_debugger.h>
|
||||
|
||||
// these do nothing because I am too lazy to write a debugger for metal at this point in time
|
||||
gnReturnCode gnCreateDebuggerFn(gnDebugger* debugger, gnInstance* instance, const struct gnDebuggerInfo_t info) {
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
void gnDestroyDebuggerFn(gnDebugger* instance) {
|
||||
|
||||
}
|
@@ -1,16 +1,15 @@
|
||||
// #pragma once
|
||||
// #include <Metal/Metal.hpp>
|
||||
// #include <MetalKit/MetalKit.hpp>
|
||||
#pragma once
|
||||
#include "core/instance/gryphn_instance.h"
|
||||
#include "core/output_device/gryphn_output_device.h"
|
||||
#include <Metal/Metal.h>
|
||||
#include <MetalKit/MetalKit.h>
|
||||
|
||||
// struct gnPlatformPhysicalOutputDevice {
|
||||
// MTL::Device* device;
|
||||
// };
|
||||
// struct gnInstance;
|
||||
struct gnPlatformPhysicalDevice_t {
|
||||
id<MTLDevice> device;
|
||||
} gnPlatformPhysicalDevice;
|
||||
|
||||
// struct gnPlatformOutputDevice {
|
||||
// MTL::Device* device;
|
||||
// MTL::CommandQueue* commandQueue;
|
||||
// MTK::View* contentView;
|
||||
|
||||
// gnInstance* instance;
|
||||
// };
|
||||
struct gnPlatformOutputDevice_t {
|
||||
id<MTLDevice> device;
|
||||
// MTLCommandQueue* commandQueue;
|
||||
MTKView* contentView;
|
||||
} gnPlatformOutputDevice;
|
||||
|
@@ -1,23 +0,0 @@
|
||||
// #include <core/output_device/gryphn_physical_output_device.h>
|
||||
// #include <Metal/Metal.hpp>
|
||||
// #include "metal_output_devices.h"
|
||||
|
||||
// GN_EXPORT gnPhysicalOutputDevice* gnGetPhysicalOutputDevicesFn(const gnInstance& instance, uint32_t* count) {
|
||||
// // gnList<gnPhysicalOutputDevice> physicalOutputDevices = gnCreateList<gnPhysicalOutputDevice>();
|
||||
// NS::Array *devices = MTL::CopyAllDevices();
|
||||
// gnPhysicalOutputDevice* devicesList = (gnPhysicalOutputDevice*)malloc(sizeof(gnPhysicalOutputDevice) * devices->count());
|
||||
// for (int i = 0; i < devices->count(); i++) {
|
||||
// devicesList[i].outputDeviceName = reinterpret_cast<MTL::Device*>(devices->object(0))->name()->cString(NS::StringEncoding::UTF8StringEncoding);
|
||||
// devicesList[i].physicalOutputDevice = new gnPlatformPhysicalOutputDevice();
|
||||
// devicesList[i].physicalOutputDevice->device = reinterpret_cast<MTL::Device*>(devices->object(0));
|
||||
// }
|
||||
// *count = devices->count();
|
||||
// return devicesList;
|
||||
// }
|
||||
|
||||
// GN_EXPORT gnBool gnDeviceSupportsAPIFn(const gnPhysicalOutputDevice& device) {
|
||||
// // so as far as my understanding goes which is not very far I dont think that the
|
||||
// // method I am using to ge the devices would return a list of devices that are not supported on
|
||||
// // metal but idk or really care cuz fuck you for using metal
|
||||
// return true;
|
||||
// }
|
31
rendering_api/metal/src/core/devices/metal_physical_device.m
Normal file
31
rendering_api/metal/src/core/devices/metal_physical_device.m
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <core/output_device/gryphn_physical_output_device.h>
|
||||
#include <Metal/Metal.h>
|
||||
#include "metal_output_devices.h"
|
||||
#include "core/window_surface/gryphn_surface.h"
|
||||
|
||||
gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstance* instance, uint32_t* deviceCount) {
|
||||
NSArray *devices = MTLCopyAllDevices();
|
||||
*deviceCount = [devices count];
|
||||
gnPhysicalDevice* devicesList = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * *deviceCount);
|
||||
for (int i = 0; i < *deviceCount; i++) {
|
||||
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]);
|
||||
|
||||
|
||||
// below I am going to fake that there is one queue that can support graphics, compute, and transfer queues
|
||||
devicesList[i].queueProperties.queueProperties = malloc(sizeof(gnQueueProperties));
|
||||
devicesList[i].queueProperties.queueProperties[0] = (gnQueueProperties){
|
||||
.queueCount = 1,
|
||||
.queueType = GN_QUEUE_GRAPHICS | GN_QUEUE_COMPUTE | GN_QUEUE_TRANSFER
|
||||
};
|
||||
}
|
||||
[devices release];
|
||||
return devicesList;
|
||||
}
|
||||
|
||||
gnBool gnQueueCanPresentToSurfaceFn(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface) {
|
||||
return gnTrue; // I belive that a window should always be able to present to a surface in metal
|
||||
}
|
Reference in New Issue
Block a user