skia2/dm/DMGpuTestProcs.cpp
Timothy Liang 760dbc4b53 Reland "implemented metal gpu backend texture upload testing"
This reverts commit a80a012456.

Reason for revert: Fix bot failure.

Original change's description:
> Revert "implemented metal gpu backend texture upload testing"
>
> This reverts commit 36848f6b30.
>
> Reason for revert: Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-All-Android_CCPR failing.
>
> Original change's description:
> > implemented metal gpu backend texture upload testing
> >
> > Bug: skia:
> > Change-Id: Ia3af58a0710f7f9792b37682a3cc45dd14282b71
> > Reviewed-on: https://skia-review.googlesource.com/140248
> > Commit-Queue: Timothy Liang <timliang@google.com>
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,ethannicholas@google.com,timliang@google.com
>
> Change-Id: Idf40fc78b82aec1efbcc64221b6d2bbf63353960
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/141182
> Reviewed-by: Timothy Liang <timliang@google.com>
> Commit-Queue: Timothy Liang <timliang@google.com>

Bug: skia:
Change-Id: Ib8c5b2e0cf9de25c11c14741a32846bcc874d712
Reviewed-on: https://skia-review.googlesource.com/141183
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Timothy Liang <timliang@google.com>
2018-07-18 18:17:32 +00:00

75 lines
3.2 KiB
C++

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Test.h"
using sk_gpu_test::GrContextFactory;
using sk_gpu_test::GLTestContext;
using sk_gpu_test::ContextInfo;
namespace skiatest {
bool IsGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
return kOpenGL_GrBackend == GrContextFactory::ContextTypeBackend(type);
}
bool IsVulkanContextType(sk_gpu_test::GrContextFactory::ContextType type) {
return kVulkan_GrBackend == GrContextFactory::ContextTypeBackend(type);
}
bool IsMetalContextType(sk_gpu_test::GrContextFactory::ContextType type) {
return kMetal_GrBackend == GrContextFactory::ContextTypeBackend(type);
}
bool IsRenderingGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
return IsGLContextType(type) && GrContextFactory::IsRenderingContext(type);
}
bool IsNullGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
return type == GrContextFactory::kNullGL_ContextType;
}
void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contextTypeFilter,
Reporter* reporter, const GrContextOptions& options) {
#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
static constexpr auto kNativeGLType = GrContextFactory::kGL_ContextType;
#else
static constexpr auto kNativeGLType = GrContextFactory::kGLES_ContextType;
#endif
for (int typeInt = 0; typeInt < GrContextFactory::kContextTypeCnt; ++typeInt) {
GrContextFactory::ContextType contextType = (GrContextFactory::ContextType) typeInt;
// Use "native" instead of explicitly trying OpenGL and OpenGL ES. Do not use GLES on
// desktop since tests do not account for not fixing http://skbug.com/2809
if (contextType == GrContextFactory::kGL_ContextType ||
contextType == GrContextFactory::kGLES_ContextType) {
if (contextType != kNativeGLType) {
continue;
}
}
// We destroy the factory and its associated contexts after each test. This is due to the
// fact that the command buffer sits on top of the native GL windowing (cgl, wgl, ...) but
// also tracks which of its contexts is current above that API and gets tripped up if the
// native windowing API is used directly outside of the command buffer code.
GrContextFactory factory(options);
ContextInfo ctxInfo = factory.getContextInfo(
contextType, GrContextFactory::ContextOverrides::kDisableNVPR);
if (contextTypeFilter && !(*contextTypeFilter)(contextType)) {
continue;
}
ReporterContext ctx(reporter, SkString(GrContextFactory::ContextTypeName(contextType)));
if (ctxInfo.grContext()) {
(*test)(reporter, ctxInfo);
ctxInfo.grContext()->flush();
}
ctxInfo = factory.getContextInfo(contextType,
GrContextFactory::ContextOverrides::kRequireNVPRSupport);
if (ctxInfo.grContext()) {
(*test)(reporter, ctxInfo);
ctxInfo.grContext()->flush();
}
}
}
} // namespace skiatest