[graphite] Add compile guards to precompile system (take 2)

Bug: skia:13430
Change-Id: I64d6049fec8cc942a8f7c56c01ba292cc8f3835c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554378
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Robert Phillips 2022-06-29 14:12:27 -04:00 committed by SkCQ
parent 9666709f37
commit c0cd71d4fd
26 changed files with 378 additions and 59 deletions

View File

@ -45,6 +45,9 @@ config("skia_public") {
if (skia_enable_sksl) {
defines += [ "SK_ENABLE_SKSL" ]
}
if (skia_enable_precompile) {
defines += [ "SK_ENABLE_PRECOMPILE" ]
}
if (is_fuchsia) {
defines += fuchsia_defines
}
@ -1407,6 +1410,11 @@ skia_component("skia") {
}
}
if (skia_enable_precompile) {
public += skia_precompile_public
sources += skia_precompile_sources
}
if (skia_build_for_debugger) {
defines += [ "SK_BUILD_FOR_DEBUGGER" ]
}
@ -2127,6 +2135,9 @@ if (skia_enable_tools) {
if (!skia_enable_skgpu_v1) {
sources -= skgpu_v1_tests_sources
}
if (skia_enable_precompile) {
sources += precompile_tests_sources
}
deps = [
":flags",
":fontmgr_android_tests",

View File

@ -22,7 +22,6 @@ skia_core_public = [
"$_include/core/SkColorFilter.h",
"$_include/core/SkColorPriv.h",
"$_include/core/SkColorSpace.h",
"$_include/core/SkCombinationBuilder.h",
"$_include/core/SkContourMeasure.h",
"$_include/core/SkCoverageMode.h",
"$_include/core/SkCubicMap.h",
@ -162,7 +161,6 @@ skia_core_sources = [
"$_src/core/SkColorFilter_Matrix.h",
"$_src/core/SkColorSpace.cpp",
"$_src/core/SkColorSpaceXformSteps.cpp",
"$_src/core/SkCombinationBuilder.cpp",
"$_src/core/SkCompressedDataUtils.cpp",
"$_src/core/SkCompressedDataUtils.h",
"$_src/core/SkContourMeasure.cpp",
@ -212,8 +210,6 @@ skia_core_sources = [
"$_src/core/SkEnumerate.h",
"$_src/core/SkExecutor.cpp",
"$_src/core/SkFDot6.h",
"$_src/core/SkFactoryFunctions.cpp",
"$_src/core/SkFactoryFunctions.h",
"$_src/core/SkFlattenable.cpp",
"$_src/core/SkFont.cpp",
"$_src/core/SkFontDescriptor.cpp",
@ -319,7 +315,6 @@ skia_core_sources = [
"$_src/core/SkPixmap.cpp",
"$_src/core/SkPoint.cpp",
"$_src/core/SkPoint3.cpp",
"$_src/core/SkPrecompile.h",
"$_src/core/SkPromiseImageTexture.cpp",
"$_src/core/SkPtrRecorder.cpp",
"$_src/core/SkPtrRecorder.h",
@ -581,6 +576,15 @@ skia_pathops_sources = [
"$_src/pathops/SkReduceOrder.h",
]
skia_precompile_public = [ "$_include/core/SkCombinationBuilder.h" ]
skia_precompile_sources = [
"$_src/core/SkCombinationBuilder.cpp",
"$_src/core/SkFactoryFunctions.cpp",
"$_src/core/SkFactoryFunctions.h",
"$_src/core/SkPrecompile.h",
]
skia_skpicture_public = [
"$_include/core/SkPicture.h",
"$_include/core/SkPictureRecorder.h",

View File

@ -24,6 +24,7 @@ declare_args() {
skia_enable_pdf = !is_wasm
skia_enable_skottie = !(is_win && is_component_build) ||
(is_wasm && skia_canvaskit_enable_skottie)
skia_enable_precompile = true
skia_enable_sksl = true
skia_enable_sksl_tracing = is_skia_dev_build
skia_enable_skvm_jit_when_possible = is_skia_dev_build

View File

@ -335,12 +335,9 @@ metal_tests_sources = [
graphite_tests_sources = [
"$_tests/graphite/BackendTextureTest.cpp",
"$_tests/graphite/BoundsManagerTest.cpp",
"$_tests/graphite/CombinationBuilderTest.cpp",
"$_tests/graphite/CombinationBuilderTestAccess.h",
"$_tests/graphite/GraphiteResourceCacheTest.cpp",
"$_tests/graphite/IntersectionTreeTest.cpp",
"$_tests/graphite/KeyTest.cpp",
"$_tests/graphite/PaintParamsKeyTest.cpp",
"$_tests/graphite/PipelineDataCacheTest.cpp",
"$_tests/graphite/RTEffectTest.cpp",
"$_tests/graphite/RecorderTest.cpp",
@ -350,6 +347,12 @@ graphite_tests_sources = [
"$_tests/graphite/UploadBufferManagerTest.cpp",
]
precompile_tests_sources = [
"$_tests/graphite/CombinationBuilderTest.cpp",
"$_tests/graphite/CombinationBuilderTestAccess.h",
"$_tests/graphite/PaintParamsKeyTest.cpp",
]
graphite_metal_tests_sources = [ "$_tests/graphite/MtlBackendTextureTest.mm" ]
pathops_tests_sources = [

View File

@ -23,7 +23,6 @@ filegroup(
"SkColorPriv.h",
"SkColorSpace.h",
"SkColorType.h",
"SkCombinationBuilder.h",
"SkContourMeasure.h",
"SkCoverageMode.h",
"SkCubicMap.h",

View File

@ -8,6 +8,10 @@
#ifndef SkCombinationBuilder_DEFINED
#define SkCombinationBuilder_DEFINED
#include "include/core/SkTypes.h"
#ifdef SK_ENABLE_PRECOMPILE
#include <functional>
#include <memory>
#include <vector>
@ -123,11 +127,7 @@ public:
kAll
};
#ifdef SK_GRAPHITE_ENABLED
SkCombinationBuilder(skgpu::graphite::Context*);
#else
SkCombinationBuilder(SkShaderCodeDictionary*);
#endif
~SkCombinationBuilder();
// Blend Modes
@ -187,4 +187,6 @@ private:
SkDEBUGCODE(int fEpoch = 0;)
};
#endif // SK_ENABLE_PRECOMPILE
#endif // SkCombinationBuilder_DEFINED

View File

@ -59,11 +59,13 @@ public:
*/
void checkAsyncWorkCompletion();
#ifdef SK_ENABLE_PRECOMPILE
// TODO: add "SkShaderID addUserDefinedShader(sk_sp<SkRuntimeEffect>)" here
// TODO: add "SkColorFilterID addUserDefinedColorFilter(sk_sp<SkRuntimeEffect>)" here
SkBlenderID addUserDefinedBlender(sk_sp<SkRuntimeEffect>);
void precompile(SkCombinationBuilder*);
#endif
/**
* Creates a new backend gpu texture matching the dimensinos and TextureInfo. If an invalid

View File

@ -10,6 +10,7 @@
"ASAN",
"AbandonGpuContext",
"Coverage",
"NoPrecompile",
"MSAN",
"TSAN",
"Valgrind",

View File

@ -153,6 +153,7 @@
{"name": "Build-Mac-Clang-arm64-Debug-Graphite_NoGpu",
"cq_config": {}
},
{"name": "Build-Mac-Clang-arm64-Debug-Graphite_NoPrecompile"},
{"name": "Build-Mac-Clang-arm64-Debug-ASAN"},
{"name": "Build-Mac-Clang-arm64-Debug-ASAN_Graphite",
"cq_config": {"location_regexes": ["src/gpu/graphite/.*"]}

View File

@ -234,6 +234,8 @@ def compile_fn(api, checkout_root, out_dir):
args['skia_use_fontconfig'] = 'false'
if 'ASAN' in extra_tokens:
args['skia_enable_spirv_validation'] = 'false'
if 'NoPrecompile' in extra_tokens:
args['skia_enable_precompile'] = 'false'
if 'Graphite' in extra_tokens:
args['skia_enable_graphite'] = 'true'
args['skia_use_metal'] = 'true'

View File

@ -0,0 +1,163 @@
[
{
"cmd": [],
"name": "ensure xcode",
"~followup_annotations": [
"@@@STEP_TEXT@Ensuring Xcode version 12c33 in [START_DIR]/cache/Xcode.app@@@"
]
},
{
"cmd": [
"[START_DIR]/mac_toolchain/mac_toolchain",
"install",
"-kind",
"ios",
"-xcode-version",
"12c33",
"-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-arm64-Debug-Graphite_NoPrecompile/Debug",
"--args=cc=\"clang\" cc_wrapper=\"[START_DIR]/ccache_mac/bin/ccache\" cxx=\"clang++\" extra_cflags=[\"-DREBUILD_IF_CHANGED_xcode_build_version=12c33\", \"-O1\"] skia_enable_graphite=true skia_enable_precompile=false skia_use_metal=true target_cpu=\"arm64\" 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-arm64-Debug-Graphite_NoPrecompile/Debug"
],
"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', 'fm', 'fm.exe', 'nanobench.app', 'get_images_from_skps', 'get_images_from_skps.exe', 'nanobench', 'nanobench.exe', 'skpbench', 'skpbench.exe', '*.so', '*.dll', '*.dylib', 'skia_launcher', 'skottie_tool', 'lib/*.so', 'run_testlab']\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-arm64-Debug-Graphite_NoPrecompile/Debug",
"[START_DIR]/[SWARM_OUT_DIR]/out/Debug"
],
"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', 'fm', 'fm.exe', 'nanobench.app', 'get_images_from_skps', 'get_images_from_skps.exe', 'nanobench', 'nanobench.exe', 'skpbench', 'skpbench.exe', '*.so', '*.dll', '*.dylib', 'skia_launcher', 'skottie_tool', 'lib/*.so', 'run_testlab']@@@",
"@@@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

@ -67,6 +67,7 @@ TEST_BUILDERS = [
'Build-Mac-Clang-arm64-Debug-iOS',
"Build-Mac-Clang-arm64-Debug-Graphite",
"Build-Mac-Clang-arm64-Debug-Graphite_NoGpu",
"Build-Mac-Clang-arm64-Debug-Graphite_NoPrecompile",
"Build-Mac-Clang-arm64-Release-Graphite",
'Build-Mac-Xcode11.4.1-arm64-Debug-iOS',
'Build-Mac-Clang-x86_64-Debug-ASAN',

View File

@ -461,6 +461,11 @@
"Build-Mac-Clang-arm64-Debug-Graphite_NoGpu"
]
},
"Build-Mac-Clang-arm64-Debug-Graphite_NoPrecompile": {
"tasks": [
"Build-Mac-Clang-arm64-Debug-Graphite_NoPrecompile"
]
},
"Build-Mac-Clang-arm64-Debug-Metal": {
"tasks": [
"Build-Mac-Clang-arm64-Debug-Metal"
@ -11631,6 +11636,107 @@
],
"service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
},
"Build-Mac-Clang-arm64-Debug-Graphite_NoPrecompile": {
"caches": [
{
"name": "ccache",
"path": "cache/ccache"
},
{
"name": "vpython",
"path": "cache/vpython"
},
{
"name": "xcode",
"path": "cache/Xcode.app"
}
],
"casSpec": "compile",
"cipd_packages": [
{
"name": "infra/3pp/tools/cpython3/mac-amd64",
"path": "cipd_bin_packages/cpython3",
"version": "version:2@3.8.10.chromium.19"
},
{
"name": "infra/tools/luci-auth/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:34ecdc8775563915792e05ba9d921342808ae2dc"
},
{
"name": "infra/tools/luci/kitchen/${platform}",
"path": ".",
"version": "git_revision:34ecdc8775563915792e05ba9d921342808ae2dc"
},
{
"name": "infra/tools/luci/vpython-native/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:34ecdc8775563915792e05ba9d921342808ae2dc"
},
{
"name": "infra/tools/luci/vpython/${platform}",
"path": "cipd_bin_packages",
"version": "git_revision:34ecdc8775563915792e05ba9d921342808ae2dc"
},
{
"name": "infra/tools/mac_toolchain/${platform}",
"path": "mac_toolchain",
"version": "git_revision:796d2b92cff93fc2059623ce0a66284373ceea0a"
},
{
"name": "skia/bots/ccache_mac",
"path": "ccache_mac",
"version": "version:1"
}
],
"command": [
"cipd_bin_packages/vpython3${EXECUTABLE_SUFFIX}",
"-u",
"skia/infra/bots/run_recipe.py",
"${ISOLATED_OUTDIR}",
"compile",
"{\"$kitchen\":{\"devshell\":true,\"git_auth\":true},\"buildername\":\"Build-Mac-Clang-arm64-Debug-Graphite_NoPrecompile\",\"swarm_out_dir\":\"build\"}",
"skia"
],
"dependencies": [
"Housekeeper-PerCommit-BundleRecipes"
],
"dimensions": [
"cores:12",
"cpu:x86-64",
"os:Mac-10.15.7",
"pool:Skia"
],
"environment": {
"RECIPES_USE_PY3": "true",
"VPYTHON_LOG_TRACE": "1"
},
"env_prefixes": {
"PATH": [
"cipd_bin_packages/cpython3",
"cipd_bin_packages/cpython3/bin",
"cipd_bin_packages",
"cipd_bin_packages/bin"
],
"VPYTHON_DEFAULT_SPEC": [
"skia/.vpython"
],
"VPYTHON_VIRTUALENV_ROOT": [
"cache/vpython"
]
},
"execution_timeout_ns": 3600000000000,
"extra_tags": {
"log_location": "logdog://logs.chromium.org/skia/${SWARMING_TASK_ID}/+/annotations"
},
"idempotent": true,
"io_timeout_ns": 3600000000000,
"max_attempts": 2,
"outputs": [
"build"
],
"service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
},
"Build-Mac-Clang-arm64-Debug-Metal": {
"caches": [
{

View File

@ -48,7 +48,6 @@ SKIA_PUBLIC_HDRS = [
"include/core/SkColorPriv.h",
"include/core/SkColorSpace.h",
"include/core/SkColorType.h",
"include/core/SkCombinationBuilder.h",
"include/core/SkContourMeasure.h",
"include/core/SkCoverageMode.h",
"include/core/SkCubicMap.h",
@ -405,7 +404,6 @@ BASE_SRCS_ALL = [
"src/core/SkColorSpacePriv.h",
"src/core/SkColorSpaceXformSteps.cpp",
"src/core/SkColorSpaceXformSteps.h",
"src/core/SkCombinationBuilder.cpp",
"src/core/SkCompressedDataUtils.cpp",
"src/core/SkCompressedDataUtils.h",
"src/core/SkContourMeasure.cpp",
@ -457,8 +455,6 @@ BASE_SRCS_ALL = [
"src/core/SkEnumerate.h",
"src/core/SkExecutor.cpp",
"src/core/SkFDot6.h",
"src/core/SkFactoryFunctions.h",
"src/core/SkFactoryFunctions.cpp",
"src/core/SkFlattenable.cpp",
"src/core/SkFont.cpp",
"src/core/SkFontDescriptor.cpp",
@ -591,7 +587,6 @@ BASE_SRCS_ALL = [
"src/core/SkPoint.cpp",
"src/core/SkPoint3.cpp",
"src/core/SkPointPriv.h",
"src/core/SkPrecompile.h",
"src/core/SkPromiseImageTexture.cpp",
"src/core/SkPtrRecorder.cpp",
"src/core/SkPtrRecorder.h",

View File

@ -404,15 +404,11 @@ split_srcs_and_hdrs(
# These files are only needed if SkSL is enabled (GPU backend or SkVM).
SKSL_FILES = [
"SkCombinationBuilder.cpp",
"SkFactoryFunctions.h",
"SkFactoryFunctions.cpp",
"SkKeyContext.h",
"SkKeyHelpers.cpp",
"SkKeyHelpers.h",
"SkPaintParamsKey.cpp",
"SkPaintParamsKey.h",
"SkPrecompile.h",
"SkRuntimeEffect.cpp",
"SkSLTypeShared.h",
"SkScopeExit.h",

View File

@ -524,19 +524,11 @@ int SkCombinationOption::numChildSlots() const { return fDataInArena->numSlots()
SkDEBUGCODE(int SkCombinationOption::epoch() const { return fDataInArena->epoch(); })
//--------------------------------------------------------------------------------------------------
#ifdef SK_GRAPHITE_ENABLED
SkCombinationBuilder::SkCombinationBuilder(skgpu::graphite::Context* context)
: fDictionary(context->priv().shaderCodeDictionary()) {
fArena = std::make_unique<SkArenaAllocWithReset>(64);
this->reset();
}
#else
SkCombinationBuilder::SkCombinationBuilder(SkShaderCodeDictionary* dict)
: fDictionary(dict) {
fArena = std::make_unique<SkArenaAllocWithReset>(64);
this->reset();
}
#endif
SkCombinationBuilder::~SkCombinationBuilder() = default;

View File

@ -5,6 +5,10 @@
* found in the LICENSE file.
*/
#include "include/core/SkTypes.h"
#ifdef SK_ENABLE_PRECOMPILE
#include "src/core/SkFactoryFunctions.h"
#include "src/core/SkPrecompile.h"
@ -109,3 +113,5 @@ sk_sp<SkPrecompileImageFilter> SkPrecompileImageFilters::Image() {
}
//--------------------------------------------------------------------------------------------------
#endif // SK_ENABLE_PRECOMPILE

View File

@ -8,6 +8,10 @@
#ifndef SkFactoryFunctions_DEFINED
#define SkFactoryFunctions_DEFINED
#include "include/core/SkTypes.h"
#ifdef SK_ENABLE_PRECOMPILE
#include "include/core/SkBlendMode.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSpan.h"
@ -21,8 +25,6 @@ class SkRuntimeEffect;
// All of these factory functions will be moved elsewhere once the pre-compile API becomes public
// TODO: wrap this in an SK_PRECOMPILE check
//--------------------------------------------------------------------------------------------------
// This will move to be beside SkShaders in include/core/SkShader.h
class SkPrecompileShaders {
@ -87,4 +89,6 @@ private:
SkPrecompileImageFilters() = delete;
};
#endif // SK_ENABLE_PRECOMPILE
#endif // SkFactoryFunctions_DEFINED

View File

@ -7,7 +7,6 @@
#include "src/core/SkKeyHelpers.h"
#include "include/core/SkCombinationBuilder.h"
#include "include/core/SkData.h"
#include "include/effects/SkRuntimeEffect.h"
#include "src/core/SkDebugUtils.h"

View File

@ -8,6 +8,10 @@
#ifndef SkPrecompile_DEFINED
#define SkPrecompile_DEFINED
#include "include/core/SkTypes.h"
#ifdef SK_ENABLE_PRECOMPILE
#include "include/core/SkBlendMode.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSpan.h"
@ -17,8 +21,6 @@
class SkRuntimeEffect;
// TODO: wrap this in an SK_PRECOMPILE check
//--------------------------------------------------------------------------------------------------
class SkPrecompileShader : public SkRefCnt {
public:
@ -85,4 +87,6 @@ private:
std::vector<sk_sp<SkPrecompileBlender>> fBlenders;
};
#endif // SK_ENABLE_PRECOMPILE
#endif // SkPrecompile_DEFINED

View File

@ -7,7 +7,6 @@
#include "src/core/SkShaderCodeDictionary.h"
#include "include/core/SkCombinationBuilder.h"
#include "include/effects/SkRuntimeEffect.h"
#include "include/private/SkSLString.h"
#include "src/core/SkOpts.h"
@ -18,6 +17,10 @@
#include "include/gpu/graphite/Context.h"
#endif
#ifdef SK_ENABLE_PRECOMPILE
#include "include/core/SkCombinationBuilder.h"
#endif
using DataPayloadField = SkPaintParamsKey::DataPayloadField;
using DataPayloadType = SkPaintParamsKey::DataPayloadType;
@ -282,10 +285,6 @@ const SkShaderSnippet* SkShaderCodeDictionary::getEntry(int codeSnippetID) const
return nullptr;
}
const SkShaderSnippet* SkShaderCodeDictionary::getEntry(SkBlenderID id) const {
return this->getEntry(id.asUInt());
}
void SkShaderCodeDictionary::getShaderInfo(SkUniquePaintParamsID uniqueID, SkShaderInfo* info) {
auto entry = this->lookup(uniqueID);
@ -715,6 +714,7 @@ int SkShaderCodeDictionary::addUserDefinedSnippet(
dataPayloadExpectations);
}
#ifdef SK_ENABLE_PRECOMPILE
SkBlenderID SkShaderCodeDictionary::addUserDefinedBlender(sk_sp<SkRuntimeEffect> effect) {
if (!effect) {
return {};
@ -735,6 +735,12 @@ SkBlenderID SkShaderCodeDictionary::addUserDefinedBlender(sk_sp<SkRuntimeEffect>
return SkBlenderID(codeSnippetID);
}
const SkShaderSnippet* SkShaderCodeDictionary::getEntry(SkBlenderID id) const {
return this->getEntry(id.asUInt());
}
#endif // SK_ENABLE_PRECOMPILE
static SkSLType uniform_type_to_sksl_type(const SkRuntimeEffect::Uniform& u) {
using Type = SkRuntimeEffect::Uniform::Type;
if (u.flags & SkRuntimeEffect::Uniform::kHalfPrecision_Flag) {

View File

@ -195,7 +195,6 @@ public:
const SkShaderSnippet* getEntry(SkBuiltInCodeSnippetID codeSnippetID) const {
return this->getEntry(SkTo<int>(codeSnippetID));
}
const SkShaderSnippet* getEntry(SkBlenderID) const;
void getShaderInfo(SkUniquePaintParamsID, SkShaderInfo*);
@ -204,7 +203,10 @@ public:
int addUserDefinedSnippet(const char* name,
SkSpan<const SkPaintParamsKey::DataPayloadField> expectations);
#ifdef SK_ENABLE_PRECOMPILE
SkBlenderID addUserDefinedBlender(sk_sp<SkRuntimeEffect>);
const SkShaderSnippet* getEntry(SkBlenderID) const;
#endif
private:
#ifdef SK_GRAPHITE_ENABLED

View File

@ -115,6 +115,8 @@ void Context::checkAsyncWorkCompletion() {
fQueueManager->checkForFinishedWork(SyncToCpu::kNo);
}
#ifdef SK_ENABLE_PRECOMPILE
SkBlenderID Context::addUserDefinedBlender(sk_sp<SkRuntimeEffect> effect) {
auto dict = this->priv().shaderCodeDictionary();
@ -159,6 +161,8 @@ void Context::precompile(SkCombinationBuilder* combinationBuilder) {
// shading, and just use ShaderType::kNone.
}
#endif // SK_ENABLE_PRECOMPILE
BackendTexture Context::createBackendTexture(SkISize dimensions, const TextureInfo& info) {
ASSERT_SINGLE_OWNER

View File

@ -7,9 +7,12 @@
#include "tests/Test.h"
#ifdef SK_GRAPHITE_ENABLED
#include "include/core/SkCombinationBuilder.h"
#include "src/core/SkFactoryFunctions.h"
#include "src/core/SkPrecompile.h"
#include "src/gpu/graphite/ContextPriv.h"
#include "tests/graphite/CombinationBuilderTestAccess.h"
#include <array>
@ -20,16 +23,16 @@ namespace {
// For an entirely empty combination builder, both solid color shader and kSrcOver options
// will be added
void empty_test(Context* context, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(context);
void empty_test(SkShaderCodeDictionary* dict, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(dict);
REPORTER_ASSERT(reporter, CombinationBuilderTestAccess::NumCombinations(&builder) == 1);
}
// It is expected that the builder will supply a default solid color shader if no other shader
// option is provided
void no_shader_option_test(Context* context, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(context);
void no_shader_option_test(SkShaderCodeDictionary* dict, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(dict);
builder.addOption(SkBlendMode::kSrcOver);
@ -38,15 +41,15 @@ void no_shader_option_test(Context* context, skiatest::Reporter* reporter) {
// It is expected that the builder will supply a default kSrcOver blend mode if no other
// options are added
void no_blend_mode_option_test(Context* context, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(context);
void no_blend_mode_option_test(SkShaderCodeDictionary* dict, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(dict);
builder.addOption(SkShaderType::kSolidColor);
REPORTER_ASSERT(reporter, CombinationBuilderTestAccess::NumCombinations(&builder) == 1);
}
void big_test_new(Context* context, skiatest::Reporter* reporter) {
void big_test_new(SkShaderCodeDictionary* dict, skiatest::Reporter* reporter) {
// paintOptions
// |- sweepGrad_0 | blendShader_0
@ -101,8 +104,8 @@ void big_test_new(Context* context, skiatest::Reporter* reporter) {
// context->precompile({paintOptions});
}
void big_test(Context* context, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(context);
void big_test(SkShaderCodeDictionary* dict, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(dict);
static constexpr int kMinNumStops = 4;
static constexpr int kMaxNumStops = 8;
@ -186,8 +189,8 @@ void big_test(Context* context, skiatest::Reporter* reporter) {
}
#ifdef SK_DEBUG
void epoch_test(Context* context, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(context);
void epoch_test(SkShaderCodeDictionary* dict, skiatest::Reporter* reporter) {
SkCombinationBuilder builder(dict);
// Check that epochs are updated upon builder reset
{
@ -206,11 +209,15 @@ void epoch_test(Context* context, skiatest::Reporter* reporter) {
} // anonymous namespace
DEF_GRAPHITE_TEST_FOR_CONTEXTS(CombinationBuilderTest, reporter, context) {
big_test_new(context, reporter);
SkShaderCodeDictionary* dict = context->priv().shaderCodeDictionary();
empty_test(context, reporter);
no_shader_option_test(context, reporter);
no_blend_mode_option_test(context, reporter);
big_test(context, reporter);
SkDEBUGCODE(epoch_test(context, reporter));
big_test_new(dict, reporter);
empty_test(dict, reporter);
no_shader_option_test(dict, reporter);
no_blend_mode_option_test(dict, reporter);
big_test(dict, reporter);
SkDEBUGCODE(epoch_test(dict, reporter));
}
#endif // SK_GRAPHITE_ENABLED

View File

@ -7,6 +7,8 @@
#include "tests/Test.h"
#ifdef SK_GRAPHITE_ENABLED
#include "include/core/SkBitmap.h"
#include "include/core/SkCombinationBuilder.h"
#include "include/core/SkM44.h"
@ -114,7 +116,7 @@ SkUniquePaintParamsID create_key(Context* context,
SkBlendMode blendMode) {
SkShaderCodeDictionary* dict = context->priv().shaderCodeDictionary();
SkCombinationBuilder combinationBuilder(context);
SkCombinationBuilder combinationBuilder(context->priv().shaderCodeDictionary());
switch (shaderType) {
case SkShaderType::kSolidColor:
@ -231,3 +233,5 @@ DEF_GRAPHITE_TEST_FOR_CONTEXTS(PaintParamsKeyTest, reporter, context) {
}
}
}
#endif // SK_GRAPHITE_ENABLED

View File

@ -17,6 +17,8 @@
using namespace skgpu::graphite;
#ifdef SK_ENABLE_PRECOMPILE
namespace {
// combines two child blenders using 'blendFrac'
@ -128,6 +130,8 @@ DEF_GRAPHITE_TEST_FOR_CONTEXTS(RTEffectTest, reporter, context) {
// check that the uniforms can be extracted from 'blender' correctly
}
#endif // SK_ENABLE_PRECOMPILE
DEF_GRAPHITE_TEST_FOR_CONTEXTS(FindOrCreateSnippetForRuntimeEffectWorks, reporter, context) {
SkShaderCodeDictionary* dict = context->priv().shaderCodeDictionary();