Revert "Revert "Revert "Don't build GL on Metal, Vulkan, Dawn, Direct3D bots"""

This reverts commit fb27c9a25f.

Revert "Remove MoltenVK support"

Reason: TSAN Vulkan bots hanging.

This reverts commit 6cafe73da9.

Change-Id: I8ec9db35c112f3c8da8636dab2065e6f18de7d0b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277936
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2020-03-19 08:47:44 -04:00
parent 6cafe73da9
commit 1171d314ef
45 changed files with 477 additions and 269 deletions

294
BUILD.gn
View File

@ -74,7 +74,7 @@ config("skia_private") {
}
libs = []
lib_dirs = []
if (skia_use_gl && skia_use_angle) {
if (skia_use_angle) {
defines += [ "SK_ANGLE" ]
}
}
@ -531,37 +531,36 @@ optional("gpu") {
}
libs = []
if (is_android) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
# this lib is required to link against AHardwareBuffer
if (defined(ndk_api) && ndk_api >= 26) {
libs += [ "android" ]
}
} else if (skia_use_egl) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
libs += [ "EGL" ]
} else if (is_linux && skia_use_x11) {
sources += [ "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp" ]
libs += [ "GL" ]
} else if (is_mac) {
sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ]
} else if (is_ios) {
sources += [ "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ]
} else if (is_win) {
sources += [ "src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp" ]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
}
} else {
sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ]
}
if (skia_use_gl) {
public_defines += [ "SK_GL" ]
if (is_android) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
# this lib is required to link against AHardwareBuffer
if (defined(ndk_api) && ndk_api >= 26) {
libs += [ "android" ]
}
} else if (skia_use_egl) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
libs += [ "EGL" ]
} else if (is_linux && skia_use_x11) {
sources += [ "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp" ]
libs += [ "GL" ]
} else if (is_mac) {
sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ]
} else if (is_ios) {
sources += [ "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ]
} else if (is_win) {
sources += [ "src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp" ]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
}
} else {
sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ]
}
sources += skia_gl_gpu_sources
}
if (skia_use_vulkan) {
public_defines += [ "SK_VULKAN" ]
deps += [ "third_party/vulkanmemoryallocator" ]
@ -578,13 +577,6 @@ optional("gpu") {
}
}
if (is_android && (skia_use_gl || skia_use_vulkan)) {
# this lib is required to link against AHardwareBuffer
if (defined(ndk_api) && ndk_api >= 26) {
libs += [ "android" ]
}
}
if (skia_use_dawn) {
public_defines += [ "SK_DAWN" ]
sources += skia_dawn_sources
@ -1384,39 +1376,45 @@ if (skia_enable_tools) {
"tools/gpu/YUVUtils.h",
"tools/gpu/mock/MockTestContext.cpp",
]
libs = []
if (skia_use_gl) {
sources += [
"tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp",
"tools/gpu/gl/GLTestContext.cpp",
"tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
]
if (is_android || skia_use_egl) {
sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
} else if (is_ios) {
sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
libs += [ "OpenGLES.framework" ]
} else if (is_linux) {
sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
libs += [
"GLU",
"X11",
]
} else if (is_mac) {
sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
} else if (is_win) {
sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
libs += [ "Gdi32.lib" ]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
}
}
if (skia_use_angle) {
deps += [ "//third_party/angle2" ]
sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
}
libs = []
if (is_android || skia_use_egl) {
sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
} else if (is_ios) {
sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
libs += [ "OpenGLES.framework" ]
} else if (is_linux) {
sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
libs += [
"GLU",
"X11",
]
} else if (is_mac) {
sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
} else if (is_win) {
sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
libs += [ "Gdi32.lib" ]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
}
} else if (is_fuchsia && using_fuchsia_sdk) {
libs +=
[ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
}
cflags_objcc = [ "-fobjc-arc" ]
if (skia_use_angle) {
deps += [ "//third_party/angle2" ]
sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
}
if (skia_use_vulkan) {
@ -1435,13 +1433,6 @@ if (skia_enable_tools) {
sources += [ "tools/gpu/dawn/DawnTestContext.cpp" ]
cflags_cc = [ "-Wno-microsoft-cast" ]
}
if (is_fuchsia && using_fuchsia_sdk) {
libs +=
[ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
}
cflags_objcc = [ "-fobjc-arc" ]
} # test_lib("gpu_tool_utils")
test_lib("flags") {
@ -2192,7 +2183,7 @@ if (skia_enable_tools) {
libs = [ "android" ]
}
}
if (is_android && skia_use_gl) {
if (is_android && skia_enable_gpu) {
test_app("skottie_android") {
is_shared_library = true
@ -2237,12 +2228,18 @@ if (skia_enable_tools) {
]
sources = [
"tools/sk_app/CommandSet.cpp",
"tools/sk_app/GLWindowContext.cpp",
"tools/sk_app/Window.cpp",
]
libs = []
if (skia_use_dawn) {
sources += [ "tools/sk_app/DawnWindowContext.cpp" ]
}
if (is_android) {
sources += [
"tools/sk_app/android/GLWindowContext_android.cpp",
"tools/sk_app/android/RasterWindowContext_android.cpp",
"tools/sk_app/android/Window_android.cpp",
"tools/sk_app/android/main_android.cpp",
@ -2251,27 +2248,50 @@ if (skia_enable_tools) {
libs += [ "android" ]
} else if (is_linux) {
sources += [
"tools/sk_app/unix/GLWindowContext_unix.cpp",
"tools/sk_app/unix/RasterWindowContext_unix.cpp",
"tools/sk_app/unix/Window_unix.cpp",
"tools/sk_app/unix/keysym2ucs.c",
"tools/sk_app/unix/main_unix.cpp",
]
if (skia_use_dawn) {
if (dawn_enable_vulkan) {
sources += [ "tools/sk_app/unix/DawnVulkanWindowContext_unix.cpp" ]
defines = [ "VK_USE_PLATFORM_XCB_KHR" ]
libs += [ "X11-xcb" ]
}
}
libs += [
"GL", # Used by raster window context, so cannot be behind skia_use_gl.
"GL",
"X11",
]
} else if (is_win) {
sources += [
"tools/sk_app/win/GLWindowContext_win.cpp",
"tools/sk_app/win/RasterWindowContext_win.cpp",
"tools/sk_app/win/Window_win.cpp",
"tools/sk_app/win/main_win.cpp",
]
if (skia_use_angle) {
sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ]
}
if (skia_use_dawn) {
if (dawn_enable_d3d12) {
sources += [ "tools/sk_app/win/DawnD3D12WindowContext_win.cpp" ]
}
}
} else if (is_mac) {
sources += [
"tools/sk_app/mac/GLWindowContext_mac.mm",
"tools/sk_app/mac/RasterWindowContext_mac.mm",
"tools/sk_app/mac/Window_mac.mm",
"tools/sk_app/mac/main_mac.mm",
]
if (skia_use_dawn) {
if (dawn_enable_metal) {
sources += [ "tools/sk_app/mac/DawnMTLWindowContext_mac.mm" ]
}
}
libs += [
"QuartzCore.framework",
"Cocoa.framework",
@ -2279,6 +2299,7 @@ if (skia_enable_tools) {
]
} else if (is_ios) {
sources += [
"tools/sk_app/ios/GLWindowContext_ios.mm",
"tools/sk_app/ios/RasterWindowContext_ios.mm",
"tools/sk_app/ios/Window_ios.mm",
"tools/sk_app/ios/main_ios.mm",
@ -2286,24 +2307,6 @@ if (skia_enable_tools) {
libs += [ "QuartzCore.framework" ]
}
if (skia_use_gl) {
sources += [ "tools/sk_app/GLWindowContext.cpp" ]
if (is_android) {
sources += [ "tools/sk_app/android/GLWindowContext_android.cpp" ]
} else if (is_linux) {
sources += [ "tools/sk_app/unix/GLWindowContext_unix.cpp" ]
} else if (is_win) {
sources += [ "tools/sk_app/win/GLWindowContext_win.cpp" ]
if (skia_use_angle) {
sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ]
}
} else if (is_mac) {
sources += [ "tools/sk_app/mac/GLWindowContext_mac.mm" ]
} else if (is_ios) {
sources += [ "tools/sk_app/ios/GLWindowContext_ios.mm" ]
}
}
if (skia_use_vulkan) {
sources += [ "tools/sk_app/VulkanWindowContext.cpp" ]
if (is_android) {
@ -2325,32 +2328,13 @@ if (skia_enable_tools) {
}
}
if (skia_use_dawn) {
sources += [ "tools/sk_app/DawnWindowContext.cpp" ]
if (is_linux) {
if (dawn_enable_vulkan) {
sources += [ "tools/sk_app/unix/DawnVulkanWindowContext_unix.cpp" ]
defines = [ "VK_USE_PLATFORM_XCB_KHR" ]
libs += [ "X11-xcb" ]
}
} else if (is_win) {
if (dawn_enable_d3d12) {
sources += [ "tools/sk_app/win/DawnD3D12WindowContext_win.cpp" ]
}
} else if (is_mac) {
if (dawn_enable_metal) {
sources += [ "tools/sk_app/mac/DawnMTLWindowContext_mac.mm" ]
}
}
}
deps = [
":tool_utils",
]
if (is_android) {
deps += [ "//third_party/native_app_glue" ]
}
if (skia_use_gl && skia_use_angle) {
if (skia_use_angle) {
deps += [ "//third_party/angle2" ]
}
}
@ -2376,57 +2360,53 @@ if (skia_enable_tools) {
]
}
}
test_app("viewer") {
is_shared_library = is_android
sources = [
"tools/viewer/AnimTimer.h",
"tools/viewer/BisectSlide.cpp",
"tools/viewer/GMSlide.cpp",
"tools/viewer/ImGuiLayer.cpp",
"tools/viewer/ImageSlide.cpp",
"tools/viewer/ParticlesSlide.cpp",
"tools/viewer/SKPSlide.cpp",
"tools/viewer/SampleSlide.cpp",
"tools/viewer/SkSLSlide.cpp",
"tools/viewer/SkottieSlide.cpp",
"tools/viewer/SlideDir.cpp",
"tools/viewer/StatsLayer.cpp",
"tools/viewer/SvgSlide.cpp",
"tools/viewer/TouchGesture.cpp",
"tools/viewer/TouchGesture.h",
"tools/viewer/Viewer.cpp",
]
libs = []
# sk_app can work without GL but viewer always runs raster through a GL window context.
if (skia_use_gl) {
test_app("viewer") {
is_shared_library = is_android
sources = [
"tools/viewer/AnimTimer.h",
"tools/viewer/BisectSlide.cpp",
"tools/viewer/GMSlide.cpp",
"tools/viewer/ImGuiLayer.cpp",
"tools/viewer/ImageSlide.cpp",
"tools/viewer/ParticlesSlide.cpp",
"tools/viewer/SKPSlide.cpp",
"tools/viewer/SampleSlide.cpp",
"tools/viewer/SkSLSlide.cpp",
"tools/viewer/SkottieSlide.cpp",
"tools/viewer/SlideDir.cpp",
"tools/viewer/StatsLayer.cpp",
"tools/viewer/SvgSlide.cpp",
"tools/viewer/TouchGesture.cpp",
"tools/viewer/TouchGesture.h",
"tools/viewer/Viewer.cpp",
]
libs = []
deps = [
":common_flags_gpu",
":experimental_svg_model",
":flags",
":gm",
":gpu_tool_utils",
":samples",
":sk_app",
":skia",
":tool_utils",
":trace",
"modules/particles",
"modules/skottie",
"modules/skottie:utils",
"modules/sksg",
"modules/sksg:samples",
"//third_party/imgui",
]
if (skia_use_experimental_xform) {
deps += [ ":experimental_xform" ]
sources += [ "gm/xform.cpp" ]
}
deps = [
":common_flags_gpu",
":experimental_svg_model",
":flags",
":gm",
":gpu_tool_utils",
":samples",
":sk_app",
":skia",
":tool_utils",
":trace",
"modules/particles",
"modules/skottie",
"modules/skottie:utils",
"modules/sksg",
"modules/sksg:samples",
"//third_party/imgui",
]
if (skia_use_experimental_xform) {
deps += [ ":experimental_xform" ]
sources += [ "gm/xform.cpp" ]
}
}
if (skia_use_gl && !skia_use_angle && (is_linux || is_win || is_mac)) {
if (!skia_use_angle && (is_linux || is_win || is_mac)) {
test_app("HelloWorld") {
sources = [
"example/HelloWorld.cpp",
@ -2443,8 +2423,8 @@ if (skia_enable_tools) {
}
}
if (skia_use_gl && (is_linux || is_mac || is_ios) &&
target_cpu != "mips64el" && target_cpu != "loongson3a") {
if ((is_linux || is_mac || is_ios) && target_cpu != "mips64el" &&
target_cpu != "loongson3a") {
test_app("SkiaSDLExample") {
sources = [
"example/SkiaSDLExample.cpp",
@ -2559,7 +2539,7 @@ if (skia_enable_tools) {
]
}
if (skia_use_gl && skia_use_icu && skia_use_harfbuzz) {
if (skia_use_icu && skia_use_harfbuzz) {
test_app("editor") {
is_shared_library = is_android
deps = [

View File

@ -9,11 +9,7 @@ Milestone 83
<Insert new notes here- top is most recent.>
* SkImage::makeTextureImage() takes an optional SkBudgeted param
* Made non-GL builds of GPU backend more robust.
https://review.skia.org/277456
* MoltenVK support removed. Use Metal backend instead.
https://review.skia.org/277612
*
* * *

View File

@ -252,7 +252,6 @@ struct GPUTarget : public Target {
return true;
}
void fillOptions(NanoJSONResultsWriter& log) override {
#ifdef SK_GL
const GrGLubyte* version;
if (this->contextInfo.backend() == GrBackendApi::kOpenGL) {
const GrGLInterface* gl =
@ -270,7 +269,6 @@ struct GPUTarget : public Target {
GR_GL_CALL_RET(gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
log.appendString("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
}
#endif
}
void dumpStats() override {

View File

@ -46,7 +46,7 @@ python tools/embed_resources.py \
--align 4
GN_GPU_FLAGS="\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\","
WASM_GPU="-lEGL -lGLESv2 -DSK_SUPPORT_GPU=1 -DSK_GL \
WASM_GPU="-lEGL -lGLESv2 -DSK_SUPPORT_GPU=1 \
-DSK_DISABLE_LEGACY_SHADERCONTEXT --pre-js $BASE_DIR/cpu.js --pre-js $BASE_DIR/gpu.js"
# Turn off exiting while we check for ninja (which may not be on PATH)

View File

@ -22,7 +22,7 @@
#include <emscripten.h>
#include <emscripten/bind.h>
#ifdef SK_GL
#if SK_SUPPORT_GPU
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/gl/GrGLInterface.h"
@ -369,7 +369,7 @@ class SkpDebugPlayer {
int fInspectedLayer = -1;
};
#ifdef SK_GL
#if SK_SUPPORT_GPU
sk_sp<GrContext> MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
{
EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current(context);
@ -507,7 +507,7 @@ EMSCRIPTEN_BINDINGS(my_module) {
self.clear(SkColor(color));
}));
#ifdef SK_GL
#if SK_SUPPORT_GPU
class_<GrContext>("GrContext")
.smart_ptr<sk_sp<GrContext>>("sk_sp<GrContext>");
function("currentContext", &emscripten_webgl_get_current_context);

View File

@ -48,7 +48,7 @@
#include "src/utils/SkUTF.h"
#include "tools/flags/CommandLineFlags.h"
#ifdef SK_GL
#if SK_SUPPORT_GPU
#include "include/gpu/gl/GrGLFunctions.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/gl/GrGLGpu.h"
@ -1607,7 +1607,7 @@ DEF_FUZZ(SerializedImageFilter, fuzz) {
canvas.restore();
}
#ifdef SK_GL
#if SK_SUPPORT_GPU
static void dump_GPU_info(GrContext* context) {
const GrGLInterface* gl = static_cast<GrGLGpu*>(context->priv().getGpu())

View File

@ -5,11 +5,9 @@
* found in the LICENSE file.
*/
// This test only works with the GL backend.
// This test only works with the GPU backend.
#include "gm/gm.h"
#ifdef SK_GL
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
@ -272,4 +270,3 @@ private:
DEF_GM(return new RectangleTexture;)
}
#endif

View File

@ -30,6 +30,7 @@ declare_args() {
clang_win = ""
clang_win_version = ""
skia_moltenvk_path = ""
werror = false
}
declare_args() {

View File

@ -84,7 +84,7 @@ declare_args() {
} else if (is_fuchsia) {
skia_use_vulkan = true
} else {
skia_use_vulkan = false
skia_use_vulkan = defined(skia_moltenvk_path) && skia_moltenvk_path != ""
}
}

View File

@ -15,7 +15,6 @@ tests_sources = [
"$_tests/ApplyGammaTest.cpp",
"$_tests/ArenaAllocTest.cpp",
"$_tests/AsADashTest.cpp",
"$_tests/BackendAllocationTest.cpp",
"$_tests/BadIcoTest.cpp",
"$_tests/BitSetTest.cpp",
"$_tests/BitmapCopyTest.cpp",
@ -49,7 +48,6 @@ tests_sources = [
"$_tests/ColorPrivTest.cpp",
"$_tests/ColorSpaceTest.cpp",
"$_tests/ColorTest.cpp",
"$_tests/CompressedBackendAllocationTest.cpp",
"$_tests/CopySurfaceTest.cpp",
"$_tests/CubicMapTest.cpp",
"$_tests/DebugLayerManagerTest.cpp",
@ -198,7 +196,6 @@ tests_sources = [
"$_tests/ProgramsTest.cpp",
"$_tests/PromiseImageTest.cpp",
"$_tests/ProxyConversionTest.cpp",
"$_tests/ProxyTest.cpp",
"$_tests/ProxyRefTest.cpp",
"$_tests/QuickRejectTest.cpp",
"$_tests/RRectInPathTest.cpp",
@ -220,7 +217,6 @@ tests_sources = [
"$_tests/RenderTargetContextTest.cpp",
"$_tests/RepeatedClippedBlurTest.cpp",
"$_tests/ResourceAllocatorTest.cpp",
"$_tests/ResourceCacheTest.cpp",
"$_tests/RoundRectTest.cpp",
"$_tests/SRGBReadWritePixelsTest.cpp",
"$_tests/SRGBTest.cpp",
@ -279,7 +275,6 @@ tests_sources = [
"$_tests/StrokerTest.cpp",
"$_tests/SubsetPath.cpp",
"$_tests/SubsetPath.h",
"$_tests/SurfaceSemaphoreTest.cpp",
"$_tests/SurfaceTest.cpp",
"$_tests/SwizzlerTest.cpp",
"$_tests/TArrayTest.cpp",
@ -298,7 +293,6 @@ tests_sources = [
"$_tests/TextureStripAtlasManagerTest.cpp",
"$_tests/Time.cpp",
"$_tests/TopoSortTest.cpp",
"$_tests/TraceMemoryDumpTest.cpp",
"$_tests/TracingTest.cpp",
"$_tests/TransferPixelsTest.cpp",
"$_tests/TypefaceTest.cpp",
@ -321,10 +315,16 @@ tests_sources = [
]
gl_tests_sources = [
"$_tests/BackendAllocationTest.cpp",
"$_tests/CompressedBackendAllocationTest.cpp",
"$_tests/EGLImageTest.cpp",
"$_tests/GrGLExtensionsTest.cpp",
"$_tests/ProxyTest.cpp",
"$_tests/RectangleTextureTest.cpp",
"$_tests/ResourceCacheTest.cpp",
"$_tests/SurfaceSemaphoreTest.cpp",
"$_tests/TextureBindingsResetTest.cpp",
"$_tests/TraceMemoryDumpTest.cpp",
]
metal_tests_sources = [

View File

@ -248,15 +248,9 @@
* and opting in to additional backends. TODO: Require explicit opt in for GL.
*/
#if SK_SUPPORT_GPU
# if !defined(SK_GL) && !defined(SK_VULKAN) && !defined(SK_METAL) && !defined(SK_DAWN) && !defined(SK_DIRECT3D)
# if !defined(SK_GL) && !defined(SK_VULKAN) && !defined(SK_METAL)
# define SK_GL
# endif
#else
# undef SK_GL
# undef SK_VULKAN
# undef SK_METAL
# undef SK_DAWN
# undef SK_DIRECT3D
#endif
#if !defined(SK_SUPPORT_ATLAS_TEXT)

View File

@ -47,7 +47,6 @@ class SkTraceMemoryDump;
class SK_API GrContext : public GrRecordingContext {
public:
#ifdef SK_GL
/**
* Creates a GrContext for a backend context. If no GrGLInterface is provided then the result of
* GrGLMakeNativeInterface() is used if it succeeds.
@ -56,7 +55,6 @@ public:
static sk_sp<GrContext> MakeGL(sk_sp<const GrGLInterface>);
static sk_sp<GrContext> MakeGL(const GrContextOptions&);
static sk_sp<GrContext> MakeGL();
#endif
/**
* The Vulkan context (VkQueue, VkDevice, VkInstance) must be kept alive until the returned

View File

@ -0,0 +1,11 @@
This asset is built from https://github.com/KhronosGroup/MoltenVK
Clone MoltenVK and open with *Xcode*:
git clone https://github.com/KhronosGroup/MoltenVK.git
cd MoltenVK
./fetchDependencies
open MoltenVKPackaging.xcodeproj
Edit Common/MVKLogging.h and turn off MVK_LOG_LEVEL_INFO
Build the "MoltenVK (Release)" scheme

View File

@ -0,0 +1 @@
2

View File

@ -0,0 +1,26 @@
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Common vars used by scripts in this directory."""
import os
import sys
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
sys.path.insert(0, INFRA_BOTS_DIR)
from assets import assets
ASSET_NAME = os.path.basename(FILE_DIR)
def run(cmd):
"""Run a command, eg. "upload" or "download". """
assets.main([cmd, ASSET_NAME] + sys.argv[1:])

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Download the current version of the asset."""
import common
if __name__ == '__main__':
common.run('download')

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Upload a new version of the asset."""
import common
if __name__ == '__main__':
common.run('upload')

View File

@ -1068,6 +1068,9 @@ func (b *jobBuilder) compile() string {
if b.extraConfig("CommandBuffer") {
b.timeout(2 * time.Hour)
}
if b.extraConfig("MoltenVK") {
b.asset("moltenvk")
}
if b.extraConfig("iOS") {
b.asset("provisioning_profile_ios")
}

View File

@ -82,6 +82,7 @@ def compile_fn(api, checkout_root, out_dir):
clang_linux = str(api.vars.slave_dir.join('clang_linux'))
win_toolchain = str(api.vars.slave_dir.join('win_toolchain'))
moltenvk = str(api.vars.slave_dir.join('moltenvk'))
cc, cxx, ccache = None, None, None
extra_cflags = []
@ -212,7 +213,6 @@ def compile_fn(api, checkout_root, out_dir):
args['is_debug'] = 'false'
if 'Dawn' in extra_tokens:
args['skia_use_dawn'] = 'true'
args['skia_use_gl'] = 'false'
# Dawn imports jinja2, which imports markupsafe. Along with DEPS, make it
# importable.
env['PYTHONPATH'] = api.path.pathsep.join([
@ -270,13 +270,12 @@ def compile_fn(api, checkout_root, out_dir):
if 'Vulkan' in extra_tokens and not 'Android' in extra_tokens:
args['skia_use_vulkan'] = 'true'
args['skia_enable_vulkan_debug_layers'] = 'true'
args['skia_use_gl'] = 'false'
if 'MoltenVK' in extra_tokens:
args['skia_moltenvk_path'] = '"%s"' % moltenvk
if 'Direct3D' in extra_tokens:
args['skia_use_direct3d'] = 'true'
args['skia_use_gl'] = 'false'
if 'Metal' in extra_tokens:
args['skia_use_metal'] = 'true'
args['skia_use_gl'] = 'false'
if 'OpenCL' in extra_tokens:
args['skia_use_opencl'] = 'true'
if api.vars.is_linux:

View File

@ -52,7 +52,7 @@
"[START_DIR]/cache/work/skia/bin/gn",
"gen",
"[START_DIR]/cache/work/skia/out/Build-Debian9-Clang-x86_64-Release-Vulkan/Release",
"--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cc_wrapper=\"[START_DIR]/ccache_linux/bin/ccache\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_cflags=[\"-B[START_DIR]/clang_linux/bin\", \"-DDUMMY_clang_linux_version=42\"] extra_ldflags=[\"-B[START_DIR]/clang_linux/bin\", \"-fuse-ld=lld\", \"-L[START_DIR]/clang_linux/lib\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_gl=false skia_use_vulkan=true target_cpu=\"x86_64\" werror=true"
"--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cc_wrapper=\"[START_DIR]/ccache_linux/bin/ccache\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_cflags=[\"-B[START_DIR]/clang_linux/bin\", \"-DDUMMY_clang_linux_version=42\"] extra_ldflags=[\"-B[START_DIR]/clang_linux/bin\", \"-fuse-ld=lld\", \"-L[START_DIR]/clang_linux/lib\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_vulkan=true target_cpu=\"x86_64\" werror=true"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {

View File

@ -70,7 +70,7 @@
"[START_DIR]/cache/work/skia/bin/gn",
"gen",
"[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Debug-Metal/Debug",
"--args=cc=\"clang\" cc_wrapper=\"[START_DIR]/ccache_mac/bin/ccache\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=11c29\", \"-O1\"] skia_use_gl=false skia_use_metal=true target_cpu=\"x86_64\" werror=true"
"--args=cc=\"clang\" cc_wrapper=\"[START_DIR]/ccache_mac/bin/ccache\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=11c29\", \"-O1\"] skia_use_metal=true target_cpu=\"x86_64\" werror=true"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {

View File

@ -0,0 +1,163 @@
[
{
"cmd": [],
"name": "ensure xcode",
"~followup_annotations": [
"@@@STEP_TEXT@Ensuring Xcode version 11c29 in [START_DIR]/cache/Xcode.app@@@"
]
},
{
"cmd": [
"[START_DIR]/mac_toolchain/mac_toolchain",
"install",
"-kind",
"ios",
"-xcode-version",
"11c29",
"-output-dir",
"[START_DIR]/cache/Xcode.app"
],
"name": "ensure xcode.install xcode",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@"
]
},
{
"cmd": [
"sudo",
"xcode-select",
"-switch",
"[START_DIR]/cache/Xcode.app"
],
"name": "ensure xcode.select xcode",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@"
]
},
{
"cmd": [
"python",
"-u",
"[START_DIR]/cache/work/skia/bin/fetch-gn"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {
"CHROME_HEADLESS": "1",
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
},
"infra_step": true,
"name": "fetch-gn"
},
{
"cmd": [
"[START_DIR]/ccache_mac/bin/ccache",
"-s"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {
"CCACHE_COMPILERCHECK": "content",
"CCACHE_DIR": "[START_DIR]/cache/ccache",
"CCACHE_MAXFILES": "0",
"CCACHE_MAXSIZE": "50G",
"CHROME_HEADLESS": "1",
"MACOSX_DEPLOYMENT_TARGET": "10.13",
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
},
"name": "ccache stats-start"
},
{
"cmd": [
"[START_DIR]/cache/work/skia/bin/gn",
"gen",
"[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan/Release",
"--args=cc=\"clang\" cc_wrapper=\"[START_DIR]/ccache_mac/bin/ccache\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=11c29\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_moltenvk_path=\"[START_DIR]/moltenvk\" skia_use_vulkan=true target_cpu=\"x86_64\" werror=true"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {
"CCACHE_COMPILERCHECK": "content",
"CCACHE_DIR": "[START_DIR]/cache/ccache",
"CCACHE_MAXFILES": "0",
"CCACHE_MAXSIZE": "50G",
"CHROME_HEADLESS": "1",
"MACOSX_DEPLOYMENT_TARGET": "10.13",
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
},
"name": "gn gen"
},
{
"cmd": [
"ninja",
"-C",
"[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan/Release"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {
"CCACHE_COMPILERCHECK": "content",
"CCACHE_DIR": "[START_DIR]/cache/ccache",
"CCACHE_MAXFILES": "0",
"CCACHE_MAXSIZE": "50G",
"CHROME_HEADLESS": "1",
"MACOSX_DEPLOYMENT_TARGET": "10.13",
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
},
"name": "ninja"
},
{
"cmd": [
"[START_DIR]/ccache_mac/bin/ccache",
"-s"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {
"CCACHE_COMPILERCHECK": "content",
"CCACHE_DIR": "[START_DIR]/cache/ccache",
"CCACHE_MAXFILES": "0",
"CCACHE_MAXSIZE": "50G",
"CHROME_HEADLESS": "1",
"MACOSX_DEPLOYMENT_TARGET": "10.13",
"PATH": "<PATH>:RECIPE_REPO[depot_tools]"
},
"name": "ccache stats-end"
},
{
"cmd": [
"python",
"-u",
"import errno\nimport glob\nimport os\nimport shutil\nimport sys\n\nsrc = sys.argv[1]\ndst = sys.argv[2]\nbuild_products = ['dm', 'dm.exe', 'dm.app', 'nanobench.app', 'get_images_from_skps', 'get_images_from_skps.exe', 'hello-opencl', 'hello-opencl.exe', 'nanobench', 'nanobench.exe', 'skpbench', 'skpbench.exe', '*.so', '*.dll', '*.dylib', 'skia_launcher', 'skottie_tool', 'lib/*.so', 'run_testlab', 'skqp-universal-debug.apk', 'whitelist_devices.json']\n\ntry:\n os.makedirs(dst)\nexcept OSError as e:\n if e.errno != errno.EEXIST:\n raise\n\nfor pattern in build_products:\n path = os.path.join(src, pattern)\n for f in glob.glob(path):\n dst_path = os.path.join(dst, os.path.relpath(f, src))\n if not os.path.isdir(os.path.dirname(dst_path)):\n os.makedirs(os.path.dirname(dst_path))\n print 'Copying build product %s to %s' % (f, dst_path)\n shutil.move(f, dst_path)\n",
"[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan/Release",
"[START_DIR]/[SWARM_OUT_DIR]/out/Release"
],
"infra_step": true,
"name": "copy build products",
"~followup_annotations": [
"@@@STEP_LOG_LINE@python.inline@import errno@@@",
"@@@STEP_LOG_LINE@python.inline@import glob@@@",
"@@@STEP_LOG_LINE@python.inline@import os@@@",
"@@@STEP_LOG_LINE@python.inline@import shutil@@@",
"@@@STEP_LOG_LINE@python.inline@import sys@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@src = sys.argv[1]@@@",
"@@@STEP_LOG_LINE@python.inline@dst = sys.argv[2]@@@",
"@@@STEP_LOG_LINE@python.inline@build_products = ['dm', 'dm.exe', 'dm.app', 'nanobench.app', 'get_images_from_skps', 'get_images_from_skps.exe', 'hello-opencl', 'hello-opencl.exe', 'nanobench', 'nanobench.exe', 'skpbench', 'skpbench.exe', '*.so', '*.dll', '*.dylib', 'skia_launcher', 'skottie_tool', 'lib/*.so', 'run_testlab', 'skqp-universal-debug.apk', 'whitelist_devices.json']@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@try:@@@",
"@@@STEP_LOG_LINE@python.inline@ os.makedirs(dst)@@@",
"@@@STEP_LOG_LINE@python.inline@except OSError as e:@@@",
"@@@STEP_LOG_LINE@python.inline@ if e.errno != errno.EEXIST:@@@",
"@@@STEP_LOG_LINE@python.inline@ raise@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@for pattern in build_products:@@@",
"@@@STEP_LOG_LINE@python.inline@ path = os.path.join(src, pattern)@@@",
"@@@STEP_LOG_LINE@python.inline@ for f in glob.glob(path):@@@",
"@@@STEP_LOG_LINE@python.inline@ dst_path = os.path.join(dst, os.path.relpath(f, src))@@@",
"@@@STEP_LOG_LINE@python.inline@ if not os.path.isdir(os.path.dirname(dst_path)):@@@",
"@@@STEP_LOG_LINE@python.inline@ os.makedirs(os.path.dirname(dst_path))@@@",
"@@@STEP_LOG_LINE@python.inline@ print 'Copying build product %s to %s' % (f, dst_path)@@@",
"@@@STEP_LOG_LINE@python.inline@ shutil.move(f, dst_path)@@@",
"@@@STEP_LOG_END@python.inline@@@"
]
},
{
"name": "$result"
}
]

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Dawn\\Release_x64",
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_use_dawn=true skia_use_gl=false target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_use_dawn=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
],
"cwd": "[START_DIR]\\cache\\work\\skia",
"env": {

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Direct3D\\Release_x64",
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_use_direct3d=true skia_use_gl=false target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_use_direct3d=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
],
"cwd": "[START_DIR]\\cache\\work\\skia",
"env": {

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Vulkan\\Release_x64",
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_gl=false skia_use_vulkan=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_vulkan=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
],
"cwd": "[START_DIR]\\cache\\work\\skia",
"env": {

View File

@ -70,6 +70,7 @@ TEST_BUILDERS = [
'Build-Mac-Clang-x86_64-Debug-ASAN',
'Build-Mac-Clang-x86_64-Debug-CommandBuffer',
'Build-Mac-Clang-x86_64-Debug-Metal',
'Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan',
'Build-Win-Clang-arm64-Release-Android',
'Build-Win-Clang-x86-Debug-Exceptions',
'Build-Win-Clang-x86_64-Debug-ANGLE',

View File

@ -59,7 +59,7 @@
#include <emscripten.h>
#include <emscripten/bind.h>
#ifdef SK_GL
#if SK_SUPPORT_GPU
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/gl/GrGLInterface.h"
@ -147,7 +147,7 @@ SkImageInfo toSkImageInfo(const SimpleImageInfo& sii) {
return SkImageInfo::Make(sii.width, sii.height, sii.colorType, sii.alphaType);
}
#ifdef SK_GL
#if SK_SUPPORT_GPU
sk_sp<GrContext> MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
{
EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current(context);
@ -722,7 +722,7 @@ namespace emscripten {
// types Pi, Pf"). But, we can just pretend they are numbers and cast them to be pointers and
// the compiler is happy.
EMSCRIPTEN_BINDINGS(Skia) {
#ifdef SK_GL
#if SK_SUPPORT_GPU
function("currentContext", &emscripten_webgl_get_current_context);
function("setCurrentContext", &emscripten_webgl_make_context_current);
function("MakeGrContext", &MakeGrContext);
@ -913,7 +913,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
flags, &localMatrix);
}), allow_raw_pointers());
#ifdef SK_GL
#if SK_SUPPORT_GPU
class_<GrContext>("GrContext")
.smart_ptr<sk_sp<GrContext>>("sk_sp<GrContext>")
.function("getResourceCacheLimitBytes", optional_override([](GrContext& self)->size_t {

View File

@ -57,7 +57,7 @@ rm -f $BUILD_DIR/*.a
GN_GPU="skia_enable_gpu=true skia_gl_standard = \"webgl\""
GN_GPU_FLAGS="\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\","
WASM_GPU="-lEGL -lGLESv2 -DSK_SUPPORT_GPU=1 -DSK_GL \
WASM_GPU="-lEGL -lGLESv2 -DSK_SUPPORT_GPU=1 \
-DSK_DISABLE_LEGACY_SHADERCONTEXT --pre-js $BASE_DIR/cpu.js --pre-js $BASE_DIR/gpu.js\
-s USE_WEBGL2=1"
if [[ $@ == *cpu* ]]; then

View File

@ -16,7 +16,6 @@
#include "src/core/SkRectPriv.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrMemoryPool.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrRenderTargetContextPriv.h"
@ -27,13 +26,10 @@
#include "src/gpu/ccpr/GrGSCoverageProcessor.h"
#include "src/gpu/ccpr/GrVSCoverageProcessor.h"
#include "src/gpu/geometry/GrPathUtils.h"
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ops/GrDrawOp.h"
#ifdef SK_GL
#include "src/gpu/gl/GrGLGpu.h"
#endif
using TriPointInstance = GrCCCoverageProcessor::TriPointInstance;
using QuadPointInstance = GrCCCoverageProcessor::QuadPointInstance;
using PrimitiveType = GrCCCoverageProcessor::PrimitiveType;
@ -333,7 +329,6 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state,
const SkRect& chainBounds) {
GrResourceProvider* rp = state->resourceProvider();
GrContext* context = state->gpu()->getContext();
#ifdef SK_GL
GrGLGpu* glGpu = GrBackendApi::kOpenGL == context->backend()
? static_cast<GrGLGpu*>(state->gpu())
: nullptr;
@ -342,7 +337,6 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state,
// GR_GL_CALL(glGpu->glInterface(), PolygonMode(GR_GL_FRONT_AND_BACK, GR_GL_LINE));
GR_GL_CALL(glGpu->glInterface(), Enable(GR_GL_LINE_SMOOTH));
}
#endif
GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kPlus,
state->drawOpArgs().outputSwizzle());
@ -405,11 +399,9 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state,
stroker.drawStrokes(state, proc.get(), batchID, ibounds);
}
#ifdef SK_GL
if (glGpu) {
context->resetContext(kMisc_GrGLBackendState);
}
#endif
}
class CCPRGeometryView::Click : public Sample::Click {

View File

@ -92,7 +92,6 @@ GrBackendFormat::GrBackendFormat(GrGLenum format, GrGLenum target)
SK_ABORT("Unexpected texture target");
}
}
#endif
GrGLFormat GrBackendFormat::asGLFormat() const {
if (this->isValid() && GrBackendApi::kOpenGL == fBackend) {
@ -100,6 +99,7 @@ GrGLFormat GrBackendFormat::asGLFormat() const {
}
return GrGLFormat::kUnknown;
}
#endif
GrBackendFormat GrBackendFormat::MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo) {
SkASSERT(ycbcrInfo.isValid());

View File

@ -15,6 +15,10 @@
#include "src/sksl/ir/SkSLNop.h"
#include "src/sksl/ir/SkSLVariableReference.h"
#ifdef SK_MOLTENVK
static const uint32_t MVKMagicNum = 0x19960412;
#endif
namespace SkSL {
void MetalCodeGenerator::setupIntrinsics() {
@ -533,7 +537,7 @@ void MetalCodeGenerator::writeVariableReference(const VariableReference& ref) {
break;
case SK_CLOCKWISE_BUILTIN:
// We'd set the front facing winding in the MTLRenderCommandEncoder to be counter
// clockwise to match Skia convention.
// clockwise to match Skia convention. This is also the default in MoltenVK.
this->write(fProgram.fSettings.fFlipY ? "_frontFacing" : "(!_frontFacing)");
break;
default:
@ -785,10 +789,18 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
if ("main" == f.fDeclaration.fName) {
switch (fProgram.fKind) {
case Program::kFragment_Kind:
#ifdef SK_MOLTENVK
this->write("fragment Outputs main0");
#else
this->write("fragment Outputs fragmentMain");
#endif
break;
case Program::kVertex_Kind:
#ifdef SK_MOLTENVK
this->write("vertex Outputs main0");
#else
this->write("vertex Outputs vertexMain");
#endif
break;
default:
SkASSERT(false);
@ -830,13 +842,21 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
this->write("& " );
this->write(fInterfaceBlockNameMap[&intf]);
this->write(" [[buffer(");
#ifdef SK_MOLTENVK
this->write(to_string(intf.fVariable.fModifiers.fLayout.fSet));
#else
this->write(to_string(intf.fVariable.fModifiers.fLayout.fBinding));
#endif
this->write(")]]");
}
}
if (fProgram.fKind == Program::kFragment_Kind) {
if (fProgram.fInputs.fRTHeight && fInterfaceBlockNameMap.empty()) {
#ifdef SK_MOLTENVK
this->write(", constant sksl_synthetic_uniforms& _anonInterface0 [[buffer(0)]]");
#else
this->write(", constant sksl_synthetic_uniforms& _anonInterface0 [[buffer(1)]]");
#endif
fRTHeightName = "_anonInterface0.u_skRTHeight";
}
this->write(", bool _frontFacing [[front_facing]]");
@ -1010,7 +1030,11 @@ void MetalCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int parentOffset,
const InterfaceBlock* parentIntf) {
#ifdef SK_MOLTENVK
MemoryLayout memoryLayout(MemoryLayout::k140_Standard);
#else
MemoryLayout memoryLayout(MemoryLayout::kMetal_Standard);
#endif
int currentOffset = 0;
for (const auto& field: fields) {
int fieldOffset = field.fModifiers.fLayout.fOffset;
@ -1035,6 +1059,21 @@ void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int
to_string((int) alignment));
}
}
#ifdef SK_MOLTENVK
if (fieldType->kind() == Type::kVector_Kind &&
fieldType->columns() == 3) {
SkASSERT(memoryLayout.size(*fieldType) == 3);
// Pack all vec3 types so that their size in bytes will match what was expected in the
// original SkSL code since MSL has vec3 sizes equal to 4 * component type, while SkSL
// has vec3 equal to 3 * component type.
// FIXME - Packed vectors can't be accessed by swizzles, but can be indexed into. A
// combination of this being a problem which only occurs when using MoltenVK and the
// fact that we haven't swizzled a vec3 yet means that this problem hasn't been
// addressed.
this->write(PACKED_PREFIX);
}
#endif
currentOffset += memoryLayout.size(*fieldType);
std::vector<int> sizes;
while (fieldType->kind() == Type::kArray_Kind) {
@ -1642,6 +1681,9 @@ MetalCodeGenerator::Requirements MetalCodeGenerator::requirements(const Function
bool MetalCodeGenerator::generateCode() {
OutputStream* rawOut = fOut;
fOut = &fHeader;
#ifdef SK_MOLTENVK
fOut->write((const char*) &MVKMagicNum, sizeof(MVKMagicNum));
#endif
fProgramKind = fProgram.fKind;
this->writeHeader();
this->writeUniformStruct();
@ -1659,6 +1701,9 @@ bool MetalCodeGenerator::generateCode() {
write_stringstream(fHeader, *rawOut);
write_stringstream(fExtraFunctions, *rawOut);
write_stringstream(body, *rawOut);
#ifdef SK_MOLTENVK
this->write("\0");
#endif
return true;
}

View File

@ -18,19 +18,19 @@
#include "src/gpu/GrPipeline.h"
#include "src/gpu/GrRenderTargetContextPriv.h"
#include "src/gpu/GrXferProcessor.h"
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
#include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
#include "src/gpu/effects/generated/GrConfigConversionEffect.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/gpu/ops/GrDrawOp.h"
#include "tests/Test.h"
#include "tools/gpu/GrContextFactory.h"
#ifdef SK_GL
#include "src/gpu/ops/GrDrawOp.h"
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
#include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
#include "src/gpu/effects/generated/GrConfigConversionEffect.h"
#include "src/gpu/gl/GrGLGpu.h"
#endif
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
/*
* A dummy processor which just tries to insert a massive key and verify that it can retrieve the
@ -343,9 +343,8 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
#endif
static int get_programs_max_stages(const sk_gpu_test::ContextInfo& ctxInfo) {
int maxStages = 6;
#ifdef SK_GL
GrContext* context = ctxInfo.grContext();
int maxStages = 6;
if (skiatest::IsGLContextType(ctxInfo.type())) {
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
if (kGLES_GrGLStandard == gpu->glStandard()) {
@ -368,7 +367,6 @@ static int get_programs_max_stages(const sk_gpu_test::ContextInfo& ctxInfo) {
maxStages = 3;
}
}
#endif
return maxStages;
}

View File

@ -118,7 +118,6 @@ static SkCanvas* prepare_canvas(SkCanvas * canvas) {
return canvas;
}
#ifdef SK_GL
static bool setup_backend_objects(GrContext* context,
const SkBitmap& bm,
const DrawOptions& options) {
@ -244,7 +243,6 @@ static bool setup_backend_objects(GrContext* context,
return true;
}
#endif
int main(int argc, char** argv) {
CommandLineFlags::Parse(argc, argv);
@ -291,7 +289,6 @@ int main(int argc, char** argv) {
draw(prepare_canvas(rasterSurface->getCanvas()));
rasterData = encode_snapshot(rasterSurface);
}
#ifdef SK_GL
if (options.gpu) {
std::unique_ptr<sk_gpu_test::GLTestContext> glContext;
sk_sp<GrContext> grContext = create_grcontext(gGLDriverInfo, &glContext);
@ -313,7 +310,6 @@ int main(int argc, char** argv) {
gpuData = encode_snapshot(surface);
}
}
#endif
if (options.pdf) {
SkDynamicMemoryWStream pdfStream;
auto document = SkPDF::MakeDocument(&pdfStream);

View File

@ -160,9 +160,7 @@ private:
bool fAbandoned;
};
SkTArray<Context, true> fContexts;
#ifdef SK_GL
std::unique_ptr<GLTestContext> fSentinelGLContext;
#endif
const GrContextOptions fGlobalOptions;
};
@ -178,12 +176,10 @@ public:
TestContext* testContext() const { return fTestContext; }
#ifdef SK_GL
GLTestContext* glContext() const {
SkASSERT(GrBackendApi::kOpenGL == this->backend());
return static_cast<GLTestContext*>(fTestContext);
}
#endif
const GrContextOptions& options() const { return fOptions; }

View File

@ -33,8 +33,8 @@
#endif
// We create our own function table and never directly call any functions via vk*(). So no
// need to include the prototype functions.
#if !defined(VK_NO_PROTOTYPES)
// need to include the prototype functions. We do them for molten vk however.
#if !defined(SK_MOLTENVK) && !defined(VK_NO_PROTOTYPES)
#define VK_NO_PROTOTYPES
#endif

View File

@ -33,6 +33,12 @@ namespace sk_gpu_test {
bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr* instProc,
PFN_vkGetDeviceProcAddr* devProc) {
#ifdef SK_MOLTENVK
// MoltenVK is a statically linked framework, so there is no Vulkan library to load.
*instProc = &vkGetInstanceProcAddr;
*devProc = &vkGetDeviceProcAddr;
return true;
#else
static void* vkLib = nullptr;
static PFN_vkGetInstanceProcAddr localInstProc = nullptr;
static PFN_vkGetDeviceProcAddr localDevProc = nullptr;
@ -52,6 +58,7 @@ bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr* instProc,
*instProc = localInstProc;
*devProc = localDevProc;
return true;
#endif
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -45,9 +45,7 @@ public:
virtual bool scaleContentToFit() const { return false; }
enum BackendType {
#ifdef SK_GL
kNativeGL_BackendType,
#endif
#if SK_ANGLE && defined(SK_BUILD_FOR_WIN)
kANGLE_BackendType,
#endif

View File

@ -47,15 +47,11 @@ bool Window_android::attach(BackendType attachType) {
void Window_android::initDisplay(ANativeWindow* window) {
SkASSERT(window);
switch (fBackendType) {
#ifdef SK_GL
case kNativeGL_BackendType:
default:
fWindowContext =
window_context_factory::MakeGLForAndroid(window, fRequestedDisplayParams);
break;
#else
default:
#endif
case kRaster_BackendType:
fWindowContext =
window_context_factory::MakeRasterForAndroid(window, fRequestedDisplayParams);

View File

@ -80,22 +80,18 @@ bool Window_ios::attach(BackendType attachType) {
info.fWindow = this;
info.fViewController = fWindow.rootViewController;
switch (attachType) {
case kRaster_BackendType:
fWindowContext = MakeRasterForIOS(info, fRequestedDisplayParams);
break;
#ifdef SK_METAL
case kMetal_BackendType:
fWindowContext = MakeMetalForIOS(info, fRequestedDisplayParams);
break;
#endif
#ifdef SK_GL
case kNativeGL_BackendType:
default:
fWindowContext = MakeGLForIOS(info, fRequestedDisplayParams);
break;
#else
default:
#endif
case kRaster_BackendType:
fWindowContext = MakeRasterForIOS(info, fRequestedDisplayParams);
break;
}
this->onBackendCreated();

View File

@ -119,6 +119,9 @@ bool Window_mac::attach(BackendType attachType) {
window_context_factory::MacWindowInfo info;
info.fMainView = [fWindow contentView];
switch (attachType) {
case kRaster_BackendType:
fWindowContext = MakeRasterForMac(info, fRequestedDisplayParams);
break;
#ifdef SK_DAWN
case kDawn_BackendType:
fWindowContext = MakeDawnMTLForMac(info, fRequestedDisplayParams);
@ -134,17 +137,10 @@ bool Window_mac::attach(BackendType attachType) {
fWindowContext = MakeMetalForMac(info, fRequestedDisplayParams);
break;
#endif
#ifdef SK_GL
case kNativeGL_BackendType:
default:
fWindowContext = MakeGLForMac(info, fRequestedDisplayParams);
break;
#else
default:
#endif
case kRaster_BackendType:
fWindowContext = MakeRasterForMac(info, fRequestedDisplayParams);
break;
}
this->onBackendCreated();

View File

@ -370,12 +370,10 @@ bool Window_unix::attach(BackendType attachType) {
window_context_factory::MakeVulkanForXlib(winInfo, fRequestedDisplayParams);
break;
#endif
#ifdef SK_GL
case kNativeGL_BackendType:
fWindowContext =
window_context_factory::MakeGLForXlib(winInfo, fRequestedDisplayParams);
break;
#endif
case kRaster_BackendType:
fWindowContext =
window_context_factory::MakeRasterForXlib(winInfo, fRequestedDisplayParams);

View File

@ -350,11 +350,9 @@ bool Window_win::attach(BackendType attachType) {
fBackend = attachType;
switch (attachType) {
#ifdef SK_GL
case kNativeGL_BackendType:
fWindowContext = window_context_factory::MakeGLForWin(fHWnd, fRequestedDisplayParams);
break;
#endif
#if SK_ANGLE
case kANGLE_BackendType:
fWindowContext =

View File

@ -49,7 +49,6 @@ sk_sp<SkData> Request::writeCanvasToPng(SkCanvas* canvas) {
}
SkCanvas* Request::getCanvas() {
#ifdef SK_GL
GrContextFactory* factory = fContextFactory;
GLTestContext* gl = factory->getContextInfo(GrContextFactory::kGL_ContextType,
GrContextFactory::ContextOverrides::kNone).glContext();
@ -60,7 +59,6 @@ SkCanvas* Request::getCanvas() {
if (gl) {
gl->makeCurrent();
}
#endif
SkASSERT(fDebugCanvas);
// create the appropriate surface if necessary

View File

@ -11,11 +11,9 @@
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/gl/GrGLInterface.h"
#ifdef SK_GL
GrContextHolder SkMakeGLContext() {
return GrContextHolder(GrContext::MakeGL(nullptr, GrContextOptions()).release());
}
#endif
void GrContextRelease::operator()(GrContext* ptr) { SkSafeUnref(ptr); }

View File

@ -131,10 +131,6 @@ static DEFINE_bool(redraw, false, "Toggle continuous redraw.");
static DEFINE_bool(offscreen, false, "Force rendering to an offscreen surface.");
#ifndef SK_GL
static_assert(false, "viewer requires GL backend for raster.")
#endif
const char* kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = {
"OpenGL",
#if SK_ANGLE && defined(SK_BUILD_FOR_WIN)