Revert "Fix GPU improved noise impl and add to perlinnoise GM."

This reverts commit bef02dca9d.

Reason for revert: PreAbandonGpuContext failing on tree

Original change's description:
> Fix GPU improved noise impl and add to perlinnoise GM.
>
> GPU was recently busted when switching alpha-color type swizzles from
> aaaa to 000a.
>
> There was no GM that exercised SkPerlinNoiseShader::MakeImprovedNoise.
>
> It draws wrong before and after this change with the CPU backend.
>
> Bug: skia:10536
> Change-Id: I514e304d022fcccae80699a99facafa8ce947e9f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350916
> Auto-Submit: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,bsalomon@google.com

Change-Id: Iac635028b402e6008e3a8050bdfa66052d94fd10
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10536
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350956
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-01-06 23:30:09 +00:00 committed by Skia Commit-Bot
parent bef02dca9d
commit 9730dc4041
2 changed files with 10 additions and 35 deletions

View File

@ -25,7 +25,6 @@ namespace {
enum class Type {
kFractalNoise,
kTurbulence,
kImproved,
};
class PerlinNoiseGM : public skiagm::GM {
@ -35,7 +34,7 @@ class PerlinNoiseGM : public skiagm::GM {
SkString onShortName() override { return SkString("perlinnoise"); }
SkISize onISize() override { return {200, 600}; }
SkISize onISize() override { return {200, 500}; }
void drawRect(SkCanvas* canvas, int x, int y, const SkPaint& paint, const SkISize& size) {
canvas->save();
@ -47,33 +46,14 @@ class PerlinNoiseGM : public skiagm::GM {
}
void test(SkCanvas* canvas, int x, int y, Type type,
float baseFrequencyX, float baseFrequencyY, int numOctaves, float seedOrZ,
float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed,
bool stitchTiles) {
SkISize tileSize = SkISize::Make(fSize.width() / 2, fSize.height() / 2);
sk_sp<SkShader> shader;
switch (type) {
case Type::kFractalNoise:
shader = SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX,
baseFrequencyY,
numOctaves,
seedOrZ,
stitchTiles ? &tileSize : nullptr);
break;
case Type::kTurbulence:
shader = SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX,
baseFrequencyY,
numOctaves,
seedOrZ,
stitchTiles ? &tileSize : nullptr);
break;
case Type::kImproved:
SkASSERT(!stitchTiles);
shader = SkPerlinNoiseShader::MakeImprovedNoise(baseFrequencyX,
baseFrequencyY,
numOctaves,
seedOrZ);
break;
}
sk_sp<SkShader> shader = (type == Type::kFractalNoise) ?
SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves,
seed, stitchTiles ? &tileSize : nullptr) :
SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves,
seed, stitchTiles ? &tileSize : nullptr);
SkPaint paint;
paint.setShader(std::move(shader));
if (stitchTiles) {
@ -111,16 +91,11 @@ class PerlinNoiseGM : public skiagm::GM {
test(canvas, 100, 300, Type::kFractalNoise,
0.1f, 0.1f, 3, 4, false);
test(canvas, 0, 400, Type::kImproved,
0.0125f, 0.0125f, 4, 0, false);
test(canvas, 100, 400, Type::kImproved,
0.125f, 0.0075f, 2, 0, false);
canvas->scale(0.75f, 1.0f);
test(canvas, 0, 500, Type::kFractalNoise,
test(canvas, 0, 400, Type::kFractalNoise,
0.1f, 0.1f, 2, 0, false);
test(canvas, 100, 500, Type::kFractalNoise,
test(canvas, 100, 400, Type::kFractalNoise,
0.1f, 0.05f, 1, 0, true);
}

View File

@ -1222,7 +1222,7 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
};
SkString samplePerm = this->invokeChild(0, "half4(1)", args, "float2(x, 0.5)");
SkString permFuncName = fragBuilder->getMangledFunctionName("perm");
SkString permCode = SkStringPrintf("return %s.a * 255;", samplePerm.c_str());
SkString permCode = SkStringPrintf("return %s.r * 255;", samplePerm.c_str());
fragBuilder->emitFunction(kHalf_GrSLType, permFuncName.c_str(),
{permArgs, SK_ARRAY_COUNT(permArgs)}, permCode.c_str());