just create transfer queue for metal

This commit is contained in:
Greg Wells
2025-06-06 16:57:56 -04:00
parent e8a2a82d87
commit 73fd05e786
3 changed files with 13 additions and 14 deletions

View File

@@ -8,11 +8,12 @@
gnReturnCode gnCreateOutputDeviceFn(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) { gnReturnCode gnCreateOutputDeviceFn(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice)); outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
outputDevice->outputDevice->device = deviceInfo.physicalDevice.physicalDevice->device.retain; outputDevice->outputDevice->device = deviceInfo.physicalDevice.physicalDevice->device.retain;
outputDevice->outputDevice->queueCount = deviceInfo.queueInfoCount; outputDevice->outputDevice->transferQueue = outputDevice->outputDevice->device.newCommandQueue;
outputDevice->outputDevice->queues = malloc(sizeof(id<MTLCommandQueue>) * deviceInfo.queueInfoCount); // outputDevice->outputDevice->queueCount = deviceInfo.queueInfoCount;
for (int i = 0; i < deviceInfo.queueInfoCount; i++) { // outputDevice->outputDevice->queues = malloc(sizeof(id<MTLCommandQueue>) * deviceInfo.queueInfoCount);
outputDevice->outputDevice->queues[i] = outputDevice->outputDevice->device.newCommandQueue; // for (int i = 0; i < deviceInfo.queueInfoCount; i++) {
} // outputDevice->outputDevice->queues[i] = outputDevice->outputDevice->device.newCommandQueue;
// }
return GN_SUCCESS; return GN_SUCCESS;
} }
@@ -22,9 +23,10 @@ void gnWaitForDeviceFn(gnOutputDeviceHandle device) {
} }
void gnDestroyOutputDeviceFn(gnOutputDeviceHandle device) { void gnDestroyOutputDeviceFn(gnOutputDeviceHandle device) {
for (int i = 0; i < device->outputDevice->queueCount; i++) { // for (int i = 0; i < device->outputDevice->queueCount; i++) {
[device->outputDevice->queues[i] release]; // [device->outputDevice->queues[i] release];
} // }
[device->outputDevice->transferQueue release];
[device->outputDevice->device release]; [device->outputDevice->device release];
free(device->outputDevice); free(device->outputDevice);
} }

View File

@@ -12,10 +12,7 @@ struct gnPlatformOutputDevice_t {
id<MTLDevice> device; id<MTLDevice> device;
MTKView* contentView; MTKView* contentView;
int queueCount;
id<MTLCommandQueue>* queues;
id<MTLCommandBuffer> executingCommandBuffer; id<MTLCommandBuffer> executingCommandBuffer;
id<MTLCommandQueue> transferQueue;
id<MTLRenderPipelineState> framebuffer; // id<MTLRenderPipelineState> framebuffer;
} gnPlatformOutputDevice; } gnPlatformOutputDevice;

View File

@@ -20,7 +20,7 @@ gnReturnCode gnPresentFn(gnOutputDeviceHandle device, struct gnPresentInfo_t inf
return GN_FAILED_TO_CREATE_FRAMEBUFFER; return GN_FAILED_TO_CREATE_FRAMEBUFFER;
} }
id<MTLCommandBuffer> commandBuffer = [device->outputDevice->queues[info.queueIndex] commandBuffer]; id<MTLCommandBuffer> commandBuffer = [device->outputDevice->transferQueue commandBuffer];
MTLRenderPassDescriptor* passDesc = [MTLRenderPassDescriptor renderPassDescriptor]; MTLRenderPassDescriptor* passDesc = [MTLRenderPassDescriptor renderPassDescriptor];
passDesc.colorAttachments[0].texture = drawable.texture; passDesc.colorAttachments[0].texture = drawable.texture;