fix CAMetalLayers
This commit is contained in:
@@ -15,6 +15,9 @@ gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t
|
||||
|
||||
info.presentationQueues->info.surface.windowSurface->layer.device = device->outputDevice->device;
|
||||
id<CAMetalDrawable> drawable = [info.presentationQueues->info.surface.windowSurface->layer nextDrawable];
|
||||
if (drawable == nil) {
|
||||
return GN_FAILED_TO_CREATE_FRAMEBUFFER;
|
||||
}
|
||||
|
||||
id<MTLCommandBuffer> commandBuffer = [device->outputDevice->queues[info.queueIndex] commandBuffer];
|
||||
|
||||
@@ -42,6 +45,7 @@ gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t
|
||||
|
||||
[commandBuffer presentDrawable:drawable];
|
||||
[commandBuffer commit];
|
||||
[commandBuffer waitUntilScheduled];
|
||||
device->outputDevice->executingCommandBuffer = commandBuffer;
|
||||
|
||||
return GN_SUCCESS;
|
||||
|
@@ -46,12 +46,13 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue,
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
void gnPresentationQueueGetImageFn(gnPresentationQueue* presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex) {
|
||||
gnReturnCode gnPresentationQueueGetImageFn(gnPresentationQueue* presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex) {
|
||||
semaphore->semaphore->eventTriggered = gnFalse;
|
||||
*imageIndex = presentationQueue->presentationQueue->currentImage;
|
||||
presentationQueue->presentationQueue->currentImage++;
|
||||
presentationQueue->presentationQueue->currentImage %= presentationQueue->imageCount;
|
||||
semaphore->semaphore->eventTriggered = gnTrue;
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
void gnDestroyPresentationQueueFn(gnPresentationQueue *presentationQueue) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#include "core/window_surface/gryphn_surface.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
typedef struct gnPlatformWindowSurface_t{
|
||||
typedef struct gnPlatformWindowSurface_t {
|
||||
CAMetalLayer* layer;
|
||||
} gnPlatformWindowSurface;
|
||||
|
||||
|
@@ -9,20 +9,8 @@
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
gnReturnCode gnCreateMacOSWindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo) {
|
||||
NSWindow* window = (__bridge NSWindow*)createInfo.window;
|
||||
NSView* view = [window contentView];
|
||||
|
||||
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||
[layer setContentsScale:[window backingScaleFactor]];
|
||||
[layer setFramebufferOnly:YES];
|
||||
[layer setPixelFormat:MTLPixelFormatBGRA8Unorm_sRGB];
|
||||
[layer setFrame:view.bounds];
|
||||
|
||||
[view setLayer:layer];
|
||||
[view setWantsLayer:YES];
|
||||
|
||||
windowSurface->windowSurface = malloc(sizeof(gnPlatformWindowSurface));
|
||||
windowSurface->windowSurface->layer = layer;
|
||||
windowSurface->windowSurface->layer = createInfo.layer;
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user