mirror of
https://github.com/libretro/RetroArch
synced 2025-01-18 04:12:07 +00:00
a0900ec433
Menu TODOs: * understand why ribbon does not look the same as GL * add clear support to `MenuDisplay` for glui
60 lines
1.8 KiB
Objective-C
60 lines
1.8 KiB
Objective-C
//
|
|
// Context.h
|
|
// MetalRenderer
|
|
//
|
|
// Created by Stuart Carnie on 6/9/18.
|
|
// Copyright © 2018 Stuart Carnie. All rights reserved.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <Metal/Metal.h>
|
|
#import "RendererCommon.h"
|
|
|
|
@interface Texture : NSObject
|
|
@property (nonatomic, readonly) id<MTLTexture> texture;
|
|
@property (nonatomic, readonly) id<MTLSamplerState> sampler;
|
|
@end
|
|
|
|
typedef struct
|
|
{
|
|
void *data;
|
|
NSUInteger offset;
|
|
__unsafe_unretained id<MTLBuffer> buffer;
|
|
} BufferRange;
|
|
|
|
/*! @brief Context contains the render state used by various components */
|
|
@interface Context : NSObject
|
|
|
|
@property (nonatomic, readonly) id<MTLDevice> device;
|
|
@property (nonatomic, readonly) id<MTLLibrary> library;
|
|
@property (nonatomic, readwrite) MTLClearColor clearColor;
|
|
|
|
/*! @brief Returns the command buffer used for pre-render work,
|
|
* such as mip maps for applying filters
|
|
* */
|
|
@property (nonatomic, readonly) id<MTLCommandBuffer> blitCommandBuffer;
|
|
|
|
/*! @brief Returns the command buffer for the current frame */
|
|
@property (nonatomic, readonly) id<MTLCommandBuffer> commandBuffer;
|
|
@property (nonatomic, readonly) id<CAMetalDrawable> nextDrawable;
|
|
|
|
/*! @brief Main render encoder to back buffer */
|
|
@property (nonatomic, readonly) id<MTLRenderCommandEncoder> rce;
|
|
|
|
- (instancetype)initWithDevice:(id<MTLDevice>)d
|
|
layer:(CAMetalLayer *)layer
|
|
library:(id<MTLLibrary>)l;
|
|
|
|
- (Texture *)newTexture:(struct texture_image)image filter:(enum texture_filter_type)filter;
|
|
- (void)convertFormat:(RPixelFormat)fmt from:(id<MTLBuffer>)src to:(id<MTLTexture>)dst;
|
|
|
|
- (bool)allocRange:(BufferRange *)range length:(NSUInteger)length;
|
|
|
|
/*! @brief begin marks the beginning of a frame */
|
|
- (void)begin;
|
|
|
|
/*! @brief end commits the command buffer */
|
|
- (void)end;
|
|
|
|
@end
|