Skip to content

Commit

Permalink
shared context for same thread added
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenkopylov committed Jun 16, 2020
1 parent 9c925e6 commit e43f8b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions Classes/SKAsyncGLView.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@property (nonatomic) BOOL log;
@property (atomic) BOOL inactive;
@property (nonatomic) BOOL fullResolutionOnSimulator;
@property (atomic) BOOL useSharedContextInSameThread;

@property (nonatomic, weak) id<SKAsyncGLViewDelegate> delegate;

Expand Down
18 changes: 16 additions & 2 deletions Classes/SKAsyncGLView.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ @interface SKAsyncGLView ()
@property (nonatomic) CGFloat contentScale;
@end

static NSMutableDictionary<NSString*, EAGLSharegroup*> * sharedGroups;

@implementation SKAsyncGLView

+ (Class)layerClass
Expand Down Expand Up @@ -99,7 +101,20 @@ - (void)applicationWillEnterForegroundNotification:(NSNotification *)notificatio
- (void)createContexts
{

self.mainContext = [[EAGLContext alloc] initWithAPI:[self.delegate getApi]];
if(self.useSharedContextInSameThread){

NSString *renderQueueID = [NSString stringWithUTF8String:dispatch_queue_get_label(self.renderQueue)];

if(sharedGroups[renderQueueID]){
self.mainContext = [[EAGLContext alloc] initWithAPI:[self.delegate getApi] sharegroup:sharedGroups[renderQueueID]];
}else{
self.mainContext = [[EAGLContext alloc] initWithAPI:[self.delegate getApi]];
sharedGroups[renderQueueID] = self.mainContext.sharegroup;
}
}else{
self.mainContext = [[EAGLContext alloc] initWithAPI:[self.delegate getApi]];
}

dispatch_async(self.renderQueue, ^{
self.renderContext = [[EAGLContext alloc] initWithAPI:self.mainContext.API sharegroup:self.mainContext.sharegroup];
dispatch_async(dispatch_get_main_queue(), ^{
Expand All @@ -108,7 +123,6 @@ - (void)createContexts
});
}


- (void)createBuffers
{
CGRect rect = self.frame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
</BreakpointActionProxy>
</Actions>
<Locations>
<Location
uuid = "CCD96C64-F466-4A49-BFA5-80CEE43AB505 - a05ad514897eeee0"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "__GPUTOOLS_HAS_DETECTED_AN_OPENGL_ERROR__"
moduleName = "libglInterpose.dylib"
usesParentBreakpointCondition = "Yes"
offsetFromSymbolStart = "0">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
Expand Down

0 comments on commit e43f8b5

Please sign in to comment.