Revert "Minimal iOS app: Perform present subsequent to flush"

This reverts commit 4e385e21a4.

Reason for revert: Causing issues with iOS Skottie app.

Original change's description:
> Minimal iOS app: Perform present subsequent to flush
> 
> Currently the backbuffer present is not on the same MTLCommandQueue
> as the flush from Skia, which probably means that it's happening
> concurrently. This can overwhelm the GPU. This CL submits the present
> to the same queue as the flush.
> 
> Change-Id: Ibaf805553931c9dc46368b362a2391425ae3e60e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248557
> Reviewed-by: Hal Canary <halcanary@skia.org>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>

TBR=jvanverth@google.com,halcanary@google.com,halcanary@skia.org

Change-Id: I56a9f1f12ebceeb750948e459ff9f90e06b7b2e4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248561
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Jim Van Verth 2019-10-14 16:38:50 +00:00 committed by Skia Commit-Bot
parent 2c8891b6ac
commit 41b41f9d31
3 changed files with 6 additions and 12 deletions

View File

@ -44,7 +44,6 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati
@interface AppViewDelegate : NSObject <MTKViewDelegate>
@property (assign, nonatomic) GrContext* grContext; // non-owning pointer.
@property (assign, nonatomic) id<MTLCommandQueue> metalQueue;
@end
@implementation AppViewDelegate {
@ -71,10 +70,7 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati
// Must flush *and* present for this to work!
surface->flush();
surface = nullptr;
id<MTLCommandBuffer> commandBuffer = [[self metalQueue] commandBuffer];
[commandBuffer presentDrawable:[view currentDrawable]];
[commandBuffer commit];
[[view currentDrawable] present];
}
- (void)mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size {
@ -86,7 +82,6 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati
@interface AppViewController : UIViewController
@property (strong, nonatomic) id<MTLDevice> metalDevice;
@property (strong, nonatomic) id<MTLCommandQueue> metalQueue;
@end
@implementation AppViewController {
@ -101,9 +96,8 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati
[super viewDidLoad];
if (!fGrContext) {
[self setMetalDevice:MTLCreateSystemDefaultDevice()];
[self setMetalQueue:[[self metalDevice] newCommandQueue]];
GrContextOptions grContextOptions; // set different options here.
fGrContext = SkMetalDeviceToGrContext([self metalDevice], [self metalQueue], grContextOptions);
fGrContext = SkMetalDeviceToGrContext([self metalDevice], grContextOptions);
}
if (![self view] || ![self metalDevice]) {
NSLog(@"Metal is not supported on this device");
@ -116,7 +110,6 @@ static void draw_example(SkSurface* surface, const SkPaint& paint, double rotati
SkMtkViewConfigForSkia(mtkView);
AppViewDelegate* viewDelegate = [[AppViewDelegate alloc] init];
[viewDelegate setGrContext:fGrContext.get()];
[viewDelegate setMetalQueue:[self metalQueue]];
[viewDelegate mtkView:mtkView drawableSizeWillChange:[mtkView bounds].size];
[mtkView setDelegate:viewDelegate];
}

View File

@ -12,7 +12,7 @@ template <typename T> class sk_sp;
sk_sp<SkSurface> SkMtkViewToSurface(MTKView*, GrContext*);
sk_sp<GrContext> SkMetalDeviceToGrContext(id<MTLDevice>, id<MTLCommandQueue>, const GrContextOptions&);
sk_sp<GrContext> SkMetalDeviceToGrContext(id<MTLDevice>, const GrContextOptions&);
void SkMtkViewConfigForSkia(MTKView*);

View File

@ -41,8 +41,9 @@ sk_sp<SkSurface> SkMtkViewToSurface(MTKView* mtkView, GrContext* grContext) {
}
}
sk_sp<GrContext> SkMetalDeviceToGrContext(id<MTLDevice> device, id<MTLCommandQueue> queue, const GrContextOptions& opts) {
return GrContext::MakeMetal((void*)device, (void*)queue, opts);
sk_sp<GrContext> SkMetalDeviceToGrContext(id<MTLDevice> device, const GrContextOptions& opts) {
return GrContext::MakeMetal((void*)device,
(void*)[device newCommandQueue], opts);
}
void SkMtkViewConfigForSkia(MTKView* mtkView) {