2018-06-20 21:29:53 -07:00
|
|
|
//
|
|
|
|
// RendererCommon.h
|
|
|
|
// MetalRenderer
|
|
|
|
//
|
|
|
|
// Created by Stuart Carnie on 6/3/18.
|
|
|
|
// Copyright © 2018 Stuart Carnie. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef RendererCommon_h
|
|
|
|
#define RendererCommon_h
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
2018-07-12 21:33:18 -07:00
|
|
|
#import "ShaderTypes.h"
|
2018-06-20 21:29:53 -07:00
|
|
|
|
2018-06-23 13:32:46 -07:00
|
|
|
// TODO(sgc): implement triple buffering
|
2018-06-20 21:29:53 -07:00
|
|
|
/*! @brief maximum inflight frames */
|
2018-06-23 13:32:46 -07:00
|
|
|
#define MAX_INFLIGHT 1
|
2018-07-03 22:28:33 -07:00
|
|
|
#define CHAIN_LENGTH 3
|
|
|
|
|
|
|
|
/* macOS requires constants in a buffer to have a 256 byte alignment. */
|
|
|
|
#ifdef TARGET_OS_MAC
|
|
|
|
#define kMetalBufferAlignment 256
|
|
|
|
#else
|
|
|
|
#define kMetalBufferAlignment 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MTL_ALIGN_BUFFER(size) ((size + kMetalBufferAlignment - 1) & (~(kMetalBufferAlignment - 1)))
|
2018-06-20 21:29:53 -07:00
|
|
|
|
|
|
|
#pragma mark - Pixel Formats
|
|
|
|
|
2018-07-03 22:31:51 -07:00
|
|
|
typedef NS_ENUM(NSUInteger, RPixelFormat)
|
|
|
|
{
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2018-06-23 13:32:46 -07:00
|
|
|
RPixelFormatInvalid,
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2018-06-23 13:32:46 -07:00
|
|
|
/* 16-bit formats */
|
|
|
|
RPixelFormatBGRA4Unorm,
|
|
|
|
RPixelFormatB5G6R5Unorm,
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2018-06-23 13:32:46 -07:00
|
|
|
RPixelFormatBGRA8Unorm,
|
|
|
|
RPixelFormatBGRX8Unorm, // RetroArch XRGB
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2018-06-23 13:32:46 -07:00
|
|
|
RPixelFormatCount,
|
2018-06-20 21:29:53 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
extern NSUInteger RPixelFormatToBPP(RPixelFormat format);
|
|
|
|
extern NSString *NSStringFromRPixelFormat(RPixelFormat format);
|
|
|
|
|
2018-07-03 22:31:51 -07:00
|
|
|
typedef NS_ENUM(NSUInteger, RTextureFilter)
|
|
|
|
{
|
2018-06-23 13:32:46 -07:00
|
|
|
RTextureFilterNearest,
|
|
|
|
RTextureFilterLinear,
|
2019-02-03 15:49:35 -08:00
|
|
|
|
2018-06-23 13:32:46 -07:00
|
|
|
RTextureFilterCount,
|
2018-06-20 21:29:53 -07:00
|
|
|
};
|
|
|
|
|
2018-06-23 23:53:45 -07:00
|
|
|
extern matrix_float4x4 matrix_proj_ortho(float left, float right, float top, float bottom);
|
2018-11-29 22:04:43 -07:00
|
|
|
extern matrix_float4x4 matrix_rotate_z(float rot);
|
2018-07-04 00:16:14 -07:00
|
|
|
extern matrix_float4x4 make_matrix_float4x4(const float *v);
|
2018-06-23 23:53:45 -07:00
|
|
|
|
2018-06-20 21:29:53 -07:00
|
|
|
#endif /* RendererCommon_h */
|