< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLContext.m

Print this page

 82 }
 83 
 84 @end
 85 
 86 @implementation MTLContext {
 87     MTLCommandBufferWrapper * _commandBufferWrapper;
 88 
 89     MTLComposite *     _composite;
 90     MTLPaint *         _paint;
 91     MTLTransform *     _transform;
 92     MTLClip *           _clip;
 93 
 94     EncoderManager * _encoderManager;
 95 }
 96 
 97 @synthesize textureFunction,
 98             vertexCacheEnabled, aaEnabled, device, library, pipelineStateStorage,
 99             commandQueue, vertexBuffer,
100             texturePool;
101 


102 - (id)initWithDevice:(id<MTLDevice>)d shadersLib:(NSString*)shadersLib {
103     self = [super init];
104     if (self) {
105         // Initialization code here.
106         device = d;
107 
108         texturePool = [[MTLTexturePool alloc] initWithDevice:device];
109         pipelineStateStorage = [[MTLPipelineStatesStorage alloc] initWithDevice:device shaderLibPath:shadersLib];
110 
111         vertexBuffer = [device newBufferWithBytes:verts
112                                            length:sizeof(verts)
113                                           options:MTLResourceCPUCacheModeDefaultCache];
114 
115         NSError *error = nil;
116 
117         library = [device newLibraryWithFile:shadersLib error:&error];
118         if (!library) {
119             NSLog(@"Failed to load library. error %@", error);
120             exit(0);
121         }
122 
123         _encoderManager = [[EncoderManager alloc] init];
124         [_encoderManager setContext:self];
125         _composite = [[MTLComposite alloc] init];
126         _paint = [[MTLPaint alloc] init];
127         _transform = [[MTLTransform alloc] init];
128         _clip = [[MTLClip alloc] init];
129 
130         _commandBufferWrapper = nil;
131 
132         // Create command queue
133         commandQueue = [device newCommandQueue];


134     }
135     return self;
136 }
137 
138 - (void)dealloc {
139     J2dTraceLn(J2D_TRACE_INFO, "MTLContext.dealloc");
140 
141     self.texturePool = nil;
142     self.library = nil;
143     self.vertexBuffer = nil;
144     self.commandQueue = nil;
145     self.pipelineStateStorage = nil;
146     [_encoderManager release];
147     [_composite release];
148     [_paint release];
149     [_transform release];
150     [_clip release];
151     [super dealloc];
152 }
153 

 82 }
 83 
 84 @end
 85 
 86 @implementation MTLContext {
 87     MTLCommandBufferWrapper * _commandBufferWrapper;
 88 
 89     MTLComposite *     _composite;
 90     MTLPaint *         _paint;
 91     MTLTransform *     _transform;
 92     MTLClip *           _clip;
 93 
 94     EncoderManager * _encoderManager;
 95 }
 96 
 97 @synthesize textureFunction,
 98             vertexCacheEnabled, aaEnabled, device, library, pipelineStateStorage,
 99             commandQueue, vertexBuffer,
100             texturePool;
101 
102 extern void initSamplers(id<MTLDevice> device);
103 
104 - (id)initWithDevice:(id<MTLDevice>)d shadersLib:(NSString*)shadersLib {
105     self = [super init];
106     if (self) {
107         // Initialization code here.
108         device = d;
109 
110         texturePool = [[MTLTexturePool alloc] initWithDevice:device];
111         pipelineStateStorage = [[MTLPipelineStatesStorage alloc] initWithDevice:device shaderLibPath:shadersLib];
112 
113         vertexBuffer = [device newBufferWithBytes:verts
114                                            length:sizeof(verts)
115                                           options:MTLResourceCPUCacheModeDefaultCache];
116 
117         NSError *error = nil;
118 
119         library = [device newLibraryWithFile:shadersLib error:&error];
120         if (!library) {
121             NSLog(@"Failed to load library. error %@", error);
122             exit(0);
123         }
124 
125         _encoderManager = [[EncoderManager alloc] init];
126         [_encoderManager setContext:self];
127         _composite = [[MTLComposite alloc] init];
128         _paint = [[MTLPaint alloc] init];
129         _transform = [[MTLTransform alloc] init];
130         _clip = [[MTLClip alloc] init];
131 
132         _commandBufferWrapper = nil;
133 
134         // Create command queue
135         commandQueue = [device newCommandQueue];
136 
137         initSamplers(device);
138     }
139     return self;
140 }
141 
142 - (void)dealloc {
143     J2dTraceLn(J2D_TRACE_INFO, "MTLContext.dealloc");
144 
145     self.texturePool = nil;
146     self.library = nil;
147     self.vertexBuffer = nil;
148     self.commandQueue = nil;
149     self.pipelineStateStorage = nil;
150     [_encoderManager release];
151     [_composite release];
152     [_paint release];
153     [_transform release];
154     [_clip release];
155     [super dealloc];
156 }
157 
< prev index next >