From 2cda27371e3fbe66c9b8a999defb1d4510890367 Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Fri, 23 May 2025 21:59:28 -0400 Subject: [PATCH] delete all of the metal presentation queue --- .../metal_presentation_queue.cpp | 178 +++++++++--------- .../metal_presentation_queue.h | 22 +-- 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/rendering_api/metal/src/core/presentation_queue/metal_presentation_queue.cpp b/rendering_api/metal/src/core/presentation_queue/metal_presentation_queue.cpp index e0a2705..e02b558 100644 --- a/rendering_api/metal/src/core/presentation_queue/metal_presentation_queue.cpp +++ b/rendering_api/metal/src/core/presentation_queue/metal_presentation_queue.cpp @@ -1,107 +1,107 @@ -#define GN_TEXTURE_NO_TEXTURE_ID -#include -#include -#include "core/devices/metal_output_devices.h" -#include "core/metal_instance.h" -#include "core/textures/metal_texture.h" -#include "QuartzCore/CAMetalLayer.h" -#include "core/sync_objects/metal_semaphore.h" -#include "bridge/metal_bridge.h" -#include "metal_presentation_queue.h" +// #define GN_TEXTURE_NO_TEXTURE_ID +// #include +// #include +// #include "core/devices/metal_output_devices.h" +// #include "core/metal_instance.h" +// #include "core/textures/metal_texture.h" +// #include "QuartzCore/CAMetalLayer.h" +// #include "core/sync_objects/metal_semaphore.h" +// #include "bridge/metal_bridge.h" +// #include "metal_presentation_queue.h" -gnOutputDevice* mltGetOutputDevice(gnPlatformPresentationQueue* presentaionQueue) { - return presentaionQueue->outputDevice; -} +// gnOutputDevice* mltGetOutputDevice(gnPlatformPresentationQueue* presentaionQueue) { +// return presentaionQueue->outputDevice; +// } -#define MAXIMUM_DRAWABLES 3 +// #define MAXIMUM_DRAWABLES 3 -GN_EXPORT gnDevicePresentationDetails gnGetDevicePresentationDetailsFn(const gnPhysicalOutputDevice& physicalOutputDevice) { - return { MAXIMUM_DRAWABLES, MAXIMUM_DRAWABLES }; -} +// GN_EXPORT gnDevicePresentationDetails gnGetDevicePresentationDetailsFn(const gnPhysicalOutputDevice& physicalOutputDevice) { +// return { MAXIMUM_DRAWABLES, MAXIMUM_DRAWABLES }; +// } -GN_EXPORT gnReturnCode gnPresentationQueueGetNextImageAsyncFn(gnPresentationQueue& presentationQueue, const gnSyncSemaphore& semaphore, gnUInt* imageIndex) { - mtlObjectCSetContentViewsLayer( - presentationQueue.presentationQueue->outputDevice->outputDevice->instance->instance->metalContentView, - presentationQueue.presentationQueue->layer); +// GN_EXPORT gnReturnCode gnPresentationQueueGetNextImageAsyncFn(gnPresentationQueue& presentationQueue, const gnSyncSemaphore& semaphore, gnUInt* imageIndex) { +// mtlObjectCSetContentViewsLayer( +// presentationQueue.presentationQueue->outputDevice->outputDevice->instance->instance->metalContentView, +// presentationQueue.presentationQueue->layer); - presentationQueue.presentationQueue->currentDrawableIndex++; - presentationQueue.presentationQueue->currentDrawableIndex %= MAXIMUM_DRAWABLES; - *imageIndex = presentationQueue.presentationQueue->currentDrawableIndex; +// presentationQueue.presentationQueue->currentDrawableIndex++; +// presentationQueue.presentationQueue->currentDrawableIndex %= MAXIMUM_DRAWABLES; +// *imageIndex = presentationQueue.presentationQueue->currentDrawableIndex; - presentationQueue.presentationQueue->currentDrawable = presentationQueue.presentationQueue->layer->nextDrawable(); +// presentationQueue.presentationQueue->currentDrawable = presentationQueue.presentationQueue->layer->nextDrawable(); - dispatch_semaphore_signal(semaphore.semaphore->semaphore); - return GN_SUCCESS; -} +// dispatch_semaphore_signal(semaphore.semaphore->semaphore); +// return GN_SUCCESS; +// } -GN_EXPORT gnPresentationQueueState gnPresentationQueueGetStateFn(gnPresentationQueue& presentationQueue) { - return GN_VALID; -} +// GN_EXPORT gnPresentationQueueState gnPresentationQueueGetStateFn(gnPresentationQueue& presentationQueue) { +// return GN_VALID; +// } -GN_EXPORT gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDevice& device, gnPresentationDetails& details) { - presentationQueue->presentationQueue = new gnPlatformPresentationQueue(); - presentationQueue->presentationQueue->outputDevice = const_cast(&device); +// GN_EXPORT gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDevice& device, gnPresentationDetails& details) { +// presentationQueue->presentationQueue = new gnPlatformPresentationQueue(); +// presentationQueue->presentationQueue->outputDevice = const_cast(&device); - presentationQueue->presentationQueue->layer = CA::MetalLayer::layer(); - presentationQueue->presentationQueue->layer->setPixelFormat(MTL::PixelFormat::PixelFormatBGRA8Unorm); - presentationQueue->presentationQueue->layer->setFramebufferOnly(true); - presentationQueue->presentationQueue->layer->setDrawableSize({ (double)details.ImageSize.x, (double)details.ImageSize.y }); - presentationQueue->presentationQueue->layer->setDevice(device.outputDevice->device); +// presentationQueue->presentationQueue->layer = CA::MetalLayer::layer(); +// presentationQueue->presentationQueue->layer->setPixelFormat(MTL::PixelFormat::PixelFormatBGRA8Unorm); +// presentationQueue->presentationQueue->layer->setFramebufferOnly(true); +// presentationQueue->presentationQueue->layer->setDrawableSize({ (double)details.ImageSize.x, (double)details.ImageSize.y }); +// presentationQueue->presentationQueue->layer->setDevice(device.outputDevice->device); - mtlInitializeMetalLayer(presentationQueue->presentationQueue->layer, true); +// mtlInitializeMetalLayer(presentationQueue->presentationQueue->layer, true); - mtlObjectCSetContentViewsLayer( - device.outputDevice->instance->instance->metalContentView, - presentationQueue->presentationQueue->layer); +// mtlObjectCSetContentViewsLayer( +// device.outputDevice->instance->instance->metalContentView, +// presentationQueue->presentationQueue->layer); - for (int i = 0; i < details.ImageCount; i++) { - MTL::TextureDescriptor* desc = MTL::TextureDescriptor::texture2DDescriptor( - MTL::PixelFormat::PixelFormatBGRA8Unorm, - details.ImageSize.x, - details.ImageSize.y, - false - ); - desc->setUsage(MTL::TextureUsageRenderTarget | MTL::TextureUsageShaderRead); +// for (int i = 0; i < details.ImageCount; i++) { +// MTL::TextureDescriptor* desc = MTL::TextureDescriptor::texture2DDescriptor( +// MTL::PixelFormat::PixelFormatBGRA8Unorm, +// details.ImageSize.x, +// details.ImageSize.y, +// false +// ); +// desc->setUsage(MTL::TextureUsageRenderTarget | MTL::TextureUsageShaderRead); - gnTexture newImage = gnTexture(); - newImage.textureColorFormat = GN_BGRA8; - newImage.minFilter = GN_FILTER_NEAREST; - newImage.magFilter = GN_FILTER_NEAREST; - newImage.textureType = GN_TEXTURE_2D; - newImage.texture = new gnPlatformTexture(); - newImage.texture->texture = device.outputDevice->device->newTexture(desc); - gnListAdd(presentationQueue->images, newImage); - } +// gnTexture newImage = gnTexture(); +// newImage.textureColorFormat = GN_BGRA8; +// newImage.minFilter = GN_FILTER_NEAREST; +// newImage.magFilter = GN_FILTER_NEAREST; +// newImage.textureType = GN_TEXTURE_2D; +// newImage.texture = new gnPlatformTexture(); +// newImage.texture->texture = device.outputDevice->device->newTexture(desc); +// gnListAdd(presentationQueue->images, newImage); +// } - MTL::TextureDescriptor* afsdfsdf = MTL::TextureDescriptor::texture2DDescriptor( - MTL::PixelFormat::PixelFormatBGRA8Unorm, - 2, - 2, - false - ); - afsdfsdf->setUsage(MTL::TextureUsageRenderTarget | MTL::TextureUsageShaderRead); +// MTL::TextureDescriptor* afsdfsdf = MTL::TextureDescriptor::texture2DDescriptor( +// MTL::PixelFormat::PixelFormatBGRA8Unorm, +// 2, +// 2, +// false +// ); +// afsdfsdf->setUsage(MTL::TextureUsageRenderTarget | MTL::TextureUsageShaderRead); - gnTexture newImage = gnTexture(); - newImage.textureColorFormat = GN_BGRA8; - newImage.minFilter = GN_FILTER_NEAREST; - newImage.magFilter = GN_FILTER_NEAREST; - newImage.textureType = GN_TEXTURE_2D; - newImage.texture = new gnPlatformTexture(); - newImage.texture->texture = device.outputDevice->device->newTexture(afsdfsdf); - MTL::Region region = MTL::Region(0, 0, 2, 2); - uint32_t data[4] = { - 0xffffffff, 0xff000000, 0xffff0000, 0xffffff00 - }; - newImage.texture->texture->replaceRegion(region, 0, data, 8); +// gnTexture newImage = gnTexture(); +// newImage.textureColorFormat = GN_BGRA8; +// newImage.minFilter = GN_FILTER_NEAREST; +// newImage.magFilter = GN_FILTER_NEAREST; +// newImage.textureType = GN_TEXTURE_2D; +// newImage.texture = new gnPlatformTexture(); +// newImage.texture->texture = device.outputDevice->device->newTexture(afsdfsdf); +// MTL::Region region = MTL::Region(0, 0, 2, 2); +// uint32_t data[4] = { +// 0xffffffff, 0xff000000, 0xffff0000, 0xffffff00 +// }; +// newImage.texture->texture->replaceRegion(region, 0, data, 8); - gnListAdd(presentationQueue->images, newImage); +// gnListAdd(presentationQueue->images, newImage); - // so funny story I have no god damn clue how to implement a presentation queue on metal - return GN_SUCCESS; -} -GN_EXPORT void gnDestroyPresentationQueueFn(gnPresentationQueue& queue) { - for (int i = 0; i < gnListLength(queue.images); i++) { - gnDestroyTexture(queue.images[i]); - } - queue.images = gnCreateList(); -} +// // so funny story I have no god damn clue how to implement a presentation queue on metal +// return GN_SUCCESS; +// } +// GN_EXPORT void gnDestroyPresentationQueueFn(gnPresentationQueue& queue) { +// for (int i = 0; i < gnListLength(queue.images); i++) { +// gnDestroyTexture(queue.images[i]); +// } +// queue.images = gnCreateList(); +// } diff --git a/rendering_api/metal/src/core/presentation_queue/metal_presentation_queue.h b/rendering_api/metal/src/core/presentation_queue/metal_presentation_queue.h index 7d1a3cf..f23b99b 100644 --- a/rendering_api/metal/src/core/presentation_queue/metal_presentation_queue.h +++ b/rendering_api/metal/src/core/presentation_queue/metal_presentation_queue.h @@ -1,14 +1,14 @@ -#pragma once -#include "QuartzCore/CAMetalLayer.hpp" -#include "core/output_device/gryphn_output_device.h" +// #pragma once +// #include "QuartzCore/CAMetalLayer.hpp" +// #include "core/output_device/gryphn_output_device.h" -struct gnPlatformPresentationQueue { - int currentDrawableIndex = 0; - gnOutputDevice* outputDevice; - CA::MetalLayer* layer; +// struct gnPlatformPresentationQueue { +// int currentDrawableIndex = 0; +// gnOutputDevice* outputDevice; +// CA::MetalLayer* layer; - CA::MetalDrawable* currentDrawable; -}; +// CA::MetalDrawable* currentDrawable; +// }; -struct gnPlatformPresentationQueue; -gnOutputDevice* mltGetOutputDevice(gnPlatformPresentationQueue* presentaionQueue); +// struct gnPlatformPresentationQueue; +// gnOutputDevice* mltGetOutputDevice(gnPlatformPresentationQueue* presentaionQueue);