1 //
2 //   Copyright 2015 Pixar
3 //
4 //   Licensed under the Apache License, Version 2.0 (the "Apache License")
5 //   with the following modification; you may not use this file except in
6 //   compliance with the Apache License and the following modification to it:
7 //   Section 6. Trademarks. is deleted and replaced with:
8 //
9 //   6. Trademarks. This License does not grant permission to use the trade
10 //      names, trademarks, service marks, or product names of the Licensor
11 //      and its affiliates, except as required to comply with Section 4(c) of
12 //      the License and to reproduce the content of the NOTICE file.
13 //
14 //   You may obtain a copy of the Apache License at
15 //
16 //       http://www.apache.org/licenses/LICENSE-2.0
17 //
18 //   Unless required by applicable law or agreed to in writing, software
19 //   distributed under the Apache License with the above modification is
20 //   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 //   KIND, either express or implied. See the Apache License for the specific
22 //   language governing permissions and limitations under the Apache License.
23 //
24 
25 #pragma once
26 
27 #import <Foundation/Foundation.h>
28 #import <Metal/Metal.h>
29 
30 typedef enum {
31     kEndCapBilinearBasis = 0,
32     kEndCapBSplineBasis,
33     kEndCapGregoryBasis,
34     kEndCapLegacyGregory,
35 } EndCap;
36 
37 typedef enum {
38     kFVarLinearNone = 0,
39     kFVarLinearCornersOnly,
40     kFVarLinearCornersPlus1,
41     kFVarLinearCornersPlus2,
42     kFVarLinearBoundaries,
43     kFVarLinearAll
44 } FVarLinearInterp;
45 
46 typedef enum {
47     kCPU = 0,
48     kMetal,
49 } KernelType;
50 
51 typedef enum {
52     kDisplayStyleWire = 0,
53     kDisplayStyleShaded,
54     kDisplayStyleWireOnShaded,
55 } DisplayStyle;
56 
57 typedef enum {
58     kShadingMaterial = 0,
59     kShadingFaceVaryingColor,
60     kShadingPatchType,
61     kShadingPatchDepth,
62     kShadingPatchCoord,
63     kShadingNormal,
64 } ShadingMode;
65 
66 typedef struct {
67     float rotationX;
68     float rotationY;
69     float dollyDistance;
70     float aspectRatio;
71 } Camera;
72 
73 @class OSDRenderer;
74 
75 @protocol OSDRendererDelegate <NSObject>
76 -(id<MTLDevice>)deviceFor:(OSDRenderer*)renderer;
77 -(id<MTLCommandQueue>)commandQueueFor:(OSDRenderer*)renderer;
78 -(MTLRenderPassDescriptor*)renderPassDescriptorFor:(OSDRenderer*)renderer;
79 -(void)setupDepthStencilState:(MTLDepthStencilDescriptor*)descriptor for:(OSDRenderer*)renderer;
80 -(void)setupRenderPipelineState:(MTLRenderPipelineDescriptor*)descriptor for:(OSDRenderer*)renderer;
81 @end
82 
83 @interface OSDRenderer : NSObject
84 
85 -(instancetype)initWithDelegate:(id<OSDRendererDelegate>)delegate;
86 
87 -(id<MTLRenderCommandEncoder>)drawFrame:(id<MTLCommandBuffer>)commandBuffer;
88 
89 -(void)fitFrame;
90 
91 @property (readonly, nonatomic) id<OSDRendererDelegate> delegate;
92 
93 @property (nonatomic) unsigned refinementLevel;
94 @property (nonatomic) int tessellationLevel;
95 
96 @property (readonly, nonatomic) NSArray<NSString*>* loadedModels;
97 @property (nonatomic) NSString* currentModel;
98 
99 @property (readonly, nonatomic) Camera* camera;
100 
101 @property (readonly, nonatomic) int* patchCounts;
102 
103 @property (nonatomic) bool useFractionalTessellation;
104 @property (nonatomic) bool useScreenspaceTessellation;
105 @property (nonatomic) bool usePatchIndexBuffer;
106 @property (nonatomic) bool usePatchBackfaceCulling;
107 @property (nonatomic) bool usePatchClipCulling;
108 @property (nonatomic) bool useSmoothCornerPatch;
109 @property (nonatomic) bool useSingleCreasePatch;
110 @property (nonatomic) bool useInfinitelySharpPatch;
111 @property (nonatomic) bool useStageIn;
112 @property (nonatomic) bool usePrimitiveBackfaceCulling;
113 @property (nonatomic) bool useAdaptive;
114 @property (nonatomic) bool yup;
115 @property (nonatomic) bool freeze;
116 @property (nonatomic) bool animateVertices;
117 @property (nonatomic) bool displayControlMeshEdges;
118 @property (nonatomic) bool displayControlMeshVertices;
119 @property (nonatomic) bool legacyGregoryEnabled;
120 @property (nonatomic) DisplayStyle displayStyle;
121 @property (nonatomic) ShadingMode shadingMode;
122 @property (nonatomic) EndCap endCapMode;
123 @property (nonatomic) FVarLinearInterp fVarLinearInterp;
124 @property (nonatomic) KernelType kernelType;
125 
126 @end
127