present command

This commit is contained in:
Greg Wells
2025-05-31 06:20:15 -04:00
parent 0d02d2e8fc
commit c9a2f3f872

View File

@@ -5,6 +5,7 @@
#include "core/sync/semaphore/metal_semaphore.h"
#include "core/presentation_queue/metal_presentation_queue.h"
#include "core/debugger/gryphn_debugger.h"
#include "core/texture/metal_texture.h"
#import <QuartzCore/CAMetalLayer.h>
gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t info) {
@@ -25,6 +26,20 @@ gnReturnCode gnPresentFn(struct gnOutputDevice_t* device, struct gnPresentInfo_t
id<MTLRenderCommandEncoder> render = [commandBuffer renderCommandEncoderWithDescriptor:passDesc];
[render endEncoding];
id<MTLBlitCommandEncoder> blit = [commandBuffer blitCommandEncoder];
[blit copyFromTexture:info.presentationQueues[0].images[info.imageIndices[0]].texture->texture
sourceSlice:0
sourceLevel:0
sourceOrigin:(MTLOrigin){0, 0, 0}
sourceSize:(MTLSize){info.presentationQueues[0].info.imageSize.x, info.presentationQueues[0].info.imageSize.y, 1}
toTexture:drawable.texture
destinationSlice:0
destinationLevel:0
destinationOrigin:(MTLOrigin){0, 0, 0}];
[blit endEncoding];
[commandBuffer presentDrawable:drawable];
[commandBuffer commit];