36b86aff6b
This reverts commit 6541013b53
.
Reason for revert: TSAN issues with GrFence, and crash in GrMtlPipelineStateBuilder::CreatePipelineState.
Original change's description:
> Remove ARC from Metal backend
>
> Change-Id: I5ab28f6eda3b37d1b82c94c7cc6eaa2ce59157da
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311113
> Reviewed-by: Adlai Holler <adlai@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>
TBR=jvanverth@google.com,bsalomon@google.com,adlai@google.com,johnstiles@google.com
Change-Id: I031629b483fc46de8bd3751253e5391c2ce87853
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/312843
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
71 lines
2.8 KiB
Plaintext
71 lines
2.8 KiB
Plaintext
/*
|
|
* Copyright 2019 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "include/core/SkSurface.h"
|
|
#include "include/gpu/GrDirectContext.h"
|
|
#include "src/gpu/GrContextPriv.h"
|
|
#include "src/gpu/GrProxyProvider.h"
|
|
#include "src/gpu/mtl/GrMtlGpu.h"
|
|
#include "tests/Test.h"
|
|
|
|
#import <Metal/Metal.h>
|
|
#import <MetalKit/MTKView.h>
|
|
|
|
#include "src/gpu/mtl/GrMtlCaps.h"
|
|
#include "src/gpu/mtl/GrMtlTextureRenderTarget.h"
|
|
|
|
DEF_GPUTEST_FOR_METAL_CONTEXT(MtlCopySurfaceTest, reporter, ctxInfo) {
|
|
static const int kWidth = 1024;
|
|
static const int kHeight = 768;
|
|
|
|
auto context = ctxInfo.directContext();
|
|
|
|
// This is a bit weird, but it's the only way to get a framebufferOnly surface
|
|
GrMtlGpu* gpu = (GrMtlGpu*) context->priv().getGpu();
|
|
|
|
MTKView* view = [[MTKView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)
|
|
device:gpu->device()];
|
|
id<CAMetalDrawable> drawable = [view currentDrawable];
|
|
REPORTER_ASSERT(reporter, drawable.texture.framebufferOnly);
|
|
REPORTER_ASSERT(reporter, drawable.texture.usage & MTLTextureUsageRenderTarget);
|
|
|
|
// Test to see if we can initiate a copy via GrSurfaceProxys
|
|
SkSurfaceProps props(0, kRGB_H_SkPixelGeometry);
|
|
|
|
// TODO: check multisampled RT as well
|
|
GrMtlTextureInfo fbInfo;
|
|
fbInfo.fTexture.retain((__bridge const void*)(drawable.texture));
|
|
GrBackendRenderTarget backendRT(kWidth, kHeight, 1, fbInfo);
|
|
|
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
|
sk_sp<GrSurfaceProxy> srcProxy = proxyProvider->wrapBackendRenderTarget(backendRT, nullptr);
|
|
|
|
auto dstProxy = GrSurfaceProxy::Copy(context,
|
|
srcProxy.get(),
|
|
kTopLeft_GrSurfaceOrigin,
|
|
GrMipmapped::kNo,
|
|
SkBackingFit::kExact,
|
|
SkBudgeted::kYes);
|
|
|
|
// TODO: GrSurfaceProxy::Copy doesn't check to see if the framebufferOnly bit is set yet.
|
|
// Update this when it does -- it should fail.
|
|
if (!dstProxy) {
|
|
ERRORF(reporter, "Expected copy to succeed");
|
|
}
|
|
|
|
// Try direct copy via GPU (should fail)
|
|
GrBackendFormat backendFormat = GrBackendFormat::MakeMtl(drawable.texture.pixelFormat);
|
|
GrSurface* src = srcProxy->peekSurface();
|
|
sk_sp<GrTexture> dst =
|
|
gpu->createTexture({kWidth, kHeight}, backendFormat, GrRenderable::kNo, 1,
|
|
GrMipmapped::kNo, SkBudgeted::kNo, GrProtected::kNo);
|
|
|
|
bool result = gpu->copySurface(dst.get(), src, SkIRect::MakeXYWH(0, 0, kWidth, kHeight),
|
|
SkIPoint::Make(0, 0));
|
|
REPORTER_ASSERT(reporter, !result);
|
|
}
|