Remove most uses of ES3Options, in favor of #version 300
Bug: skia:11209 Change-Id: I89d97bce1934a985c1efed602680dd534702a800 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541072 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
b6b7898599
commit
9c34707e2a
@ -95,8 +95,9 @@ static SkBitmap draw_shader(SkCanvas* canvas, sk_sp<SkShader> shader,
|
||||
'v1' : float2(1)
|
||||
'v2' : float2(2)
|
||||
*/
|
||||
static SkString make_unary_sksl_1d(const char* fn) {
|
||||
static SkString make_unary_sksl_1d(const char* fn, bool requireES3) {
|
||||
return SkStringPrintf(
|
||||
"#version %s\n"
|
||||
"uniform float xScale; uniform float xBias;"
|
||||
"uniform float yScale; uniform float yBias;"
|
||||
"half4 main(float2 p) {"
|
||||
@ -109,7 +110,7 @@ static SkString make_unary_sksl_1d(const char* fn) {
|
||||
" float y = float(%s) * yScale + yBias;"
|
||||
" return y.xxx1;"
|
||||
"}",
|
||||
fn);
|
||||
requireES3 ? "300" : "100", fn);
|
||||
}
|
||||
|
||||
// Draws one row of boxes, then advances the canvas translation vertically
|
||||
@ -125,9 +126,7 @@ static void plot(SkCanvas* canvas,
|
||||
|
||||
draw_label(canvas, label ? label : fn);
|
||||
|
||||
auto [effect, error] = SkRuntimeEffect::MakeForShader(
|
||||
make_unary_sksl_1d(fn),
|
||||
requireES3 ? SkRuntimeEffectPriv::ES3Options() : SkRuntimeEffect::Options{});
|
||||
auto [effect, error] = SkRuntimeEffect::MakeForShader(make_unary_sksl_1d(fn, requireES3));
|
||||
if (!effect) {
|
||||
SkDebugf("Error: %s\n", error.c_str());
|
||||
return;
|
||||
|
@ -403,7 +403,7 @@ static std::unique_ptr<GrFragmentProcessor> make_dither_effect(
|
||||
// between 0 and alpha to keep the color premultiplied.
|
||||
return half4(clamp(color.rgb + value * range, 0.0, color.a), color.a);
|
||||
}
|
||||
)", SkRuntimeEffectPriv::ES3Options());
|
||||
)");
|
||||
return GrSkSLFP::Make(effect,
|
||||
"Dither",
|
||||
std::move(inputFP),
|
||||
|
@ -277,6 +277,7 @@ static std::unique_ptr<GrFragmentProcessor> make_looping_colorizer(int intervalC
|
||||
// chunk` near the end via an @if statement, as the result will always be in chunk 0.
|
||||
int loopCount = SkNextLog2(intervalChunks);
|
||||
sksl.appendf(R"(
|
||||
#version 300
|
||||
uniform half4 thresholds[%d];
|
||||
uniform float4 scale[%d];
|
||||
uniform float4 bias[%d];
|
||||
@ -317,8 +318,7 @@ static std::unique_ptr<GrFragmentProcessor> make_looping_colorizer(int intervalC
|
||||
/* loopCount: */ loopCount,
|
||||
/* @if (loopCount > 0): */ loopCount);
|
||||
|
||||
auto result = SkRuntimeEffect::MakeForShader(std::move(sksl),
|
||||
SkRuntimeEffectPriv::ES3Options());
|
||||
auto result = SkRuntimeEffect::MakeForShader(std::move(sksl));
|
||||
SkASSERTF(result.effect, "%s", result.errorText.c_str());
|
||||
cacheEntry->effect = std::move(result.effect);
|
||||
});
|
||||
|
@ -100,6 +100,17 @@ DEF_TEST(SkRuntimeEffectCanDisableES2Restrictions, r) {
|
||||
test_valid_es3 (r, "float f[2] = float[2](0, 1);" EMPTY_MAIN);
|
||||
}
|
||||
|
||||
DEF_TEST(SkRuntimeEffectCanEnableVersion300, r) {
|
||||
auto test_valid = [](skiatest::Reporter* r, const char* sksl) {
|
||||
auto [effect, errorText] = SkRuntimeEffect::MakeForShader(SkString(sksl));
|
||||
REPORTER_ASSERT(r, effect, "%s", errorText.c_str());
|
||||
};
|
||||
|
||||
test_invalid_effect(r, "#version 100\nfloat f[2] = float[2](0, 1);" EMPTY_MAIN,
|
||||
"construction of array type");
|
||||
test_valid (r, "#version 300\nfloat f[2] = float[2](0, 1);" EMPTY_MAIN);
|
||||
}
|
||||
|
||||
DEF_TEST(SkRuntimeEffectForColorFilter, r) {
|
||||
// Tests that the color filter factory rejects or accepts certain SkSL constructs
|
||||
auto test_valid = [r](const char* sksl) {
|
||||
|
Loading…
Reference in New Issue
Block a user