Revert "fixed sample(..., matrix) with runtime effects"

This reverts commit fb5ede576d.

Reason for revert: major performance regression due to constant shader recompilation

Original change's description:
> fixed sample(..., matrix) with runtime effects
> 
> Change-Id: Id5b7f1b5e992c587be000e112706bedfe00c90fd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294697
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

TBR=bsalomon@google.com,brianosman@google.com,ethannicholas@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ica8322e0eab8f00bfc1d4f6d33778eb6493b278f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295835
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Ethan Nicholas 2020-06-11 21:10:26 +00:00 committed by Skia Commit-Bot
parent 9290d01c6f
commit 77968f0d32
8 changed files with 14 additions and 42 deletions

View File

@ -115,8 +115,8 @@ class ThresholdRT : public skiagm::GM {
}
void main(float2 xy, inout half4 color) {
half4 after = sample(after_map, float3x3(1));
half4 before = sample(before_map, xy);
half4 after = sample(after_map, xy);
float m = smooth_cutoff(sample(threshold_map, xy).r);
color = mix(before, after, half(m));

View File

@ -27,7 +27,6 @@ namespace SkSL {
class ByteCode;
struct PipelineStageArgs;
struct Program;
struct SampleMatrix;
class SharedCompiler;
}

View File

@ -27,6 +27,7 @@
#if SK_SUPPORT_GPU
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrFPArgs.h"
#include "src/gpu/effects/GrMatrixEffect.h"
#include "src/gpu/effects/GrSkSLFP.h"
#endif

View File

@ -19,7 +19,7 @@
class GrGLSLSkSLFP : public GrGLSLFragmentProcessor {
public:
GrGLSLSkSLFP(const SkSL::PipelineStageArgs& args) : fArgs(std::move(args)) {}
GrGLSLSkSLFP(SkSL::PipelineStageArgs&& args) : fArgs(std::move(args)) {}
SkSL::String expandFormatArgs(const SkSL::String& raw,
EmitArgs& args,
@ -57,13 +57,6 @@ public:
result += this->invokeChild(arg.fIndex, args, coords).c_str();
break;
}
case SkSL::Compiler::FormatArg::Kind::kChildProcessorWithMatrix: {
SkSL::String coords = this->expandFormatArgs(arg.fCoords, args,
fmtArg, coordsName);
result += this->invokeChildWithMatrix(arg.fIndex, args,
coords).c_str();
break;
}
case SkSL::Compiler::FormatArg::Kind::kFunctionName:
SkASSERT((int) fFunctionNames.size() > arg.fIndex);
result += fFunctionNames[arg.fIndex].c_str();
@ -102,8 +95,7 @@ public:
// We need to ensure that we call invokeChild on each child FP at least once.
// Any child FP that isn't sampled won't trigger a call otherwise, leading to asserts later.
for (int i = 0; i < this->numChildProcessors(); ++i) {
bool isExplicit = args.fFp.childProcessor(i).isSampledWithExplicitCoords();
(void)this->invokeChild(i, args, isExplicit ? SkSL::String("_coords") : "");
(void)this->invokeChild(i, args, SkSL::String("_coords"));
}
for (const auto& f : fArgs.fFunctions) {
fFunctionNames.emplace_back();
@ -189,7 +181,6 @@ GrSkSLFP::GrSkSLFP(sk_sp<const GrShaderCaps> shaderCaps, ShaderErrorHandler* sha
, fName(name)
, fInputs(std::move(inputs)) {
this->addCoordTransform(&fCoordTransform);
fEffect->toPipelineStage(fInputs->data(), fShaderCaps.get(), fShaderErrorHandler, &fArgs);
}
GrSkSLFP::GrSkSLFP(const GrSkSLFP& other)
@ -198,8 +189,7 @@ GrSkSLFP::GrSkSLFP(const GrSkSLFP& other)
, fShaderErrorHandler(other.fShaderErrorHandler)
, fEffect(other.fEffect)
, fName(other.fName)
, fInputs(other.fInputs)
, fArgs(other.fArgs) {
, fInputs(other.fInputs) {
this->addCoordTransform(&fCoordTransform);
}
@ -208,18 +198,15 @@ const char* GrSkSLFP::name() const {
}
void GrSkSLFP::addChild(std::unique_ptr<GrFragmentProcessor> child) {
int newIndex = this->numChildProcessors();
if ((int) fArgs.fSampleMatrices.size() > newIndex &&
fArgs.fSampleMatrices[newIndex].fKind != SkSL::SampleMatrix::Kind::kNone) {
child->setSampleMatrix(fArgs.fSampleMatrices[newIndex]);
} else {
child->setSampledWithExplicitCoords();
}
child->setSampledWithExplicitCoords();
this->registerChildProcessor(std::move(child));
}
GrGLSLFragmentProcessor* GrSkSLFP::onCreateGLSLInstance() const {
return new GrGLSLSkSLFP(fArgs);
// Note: This is actually SkSL (again) but with inline format specifiers.
SkSL::PipelineStageArgs args;
fEffect->toPipelineStage(fInputs->data(), fShaderCaps.get(), fShaderErrorHandler, &args);
return new GrGLSLSkSLFP(std::move(args));
}
void GrSkSLFP::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {

View File

@ -94,10 +94,9 @@ private:
sk_sp<const GrShaderCaps> fShaderCaps;
ShaderErrorHandler* fShaderErrorHandler;
sk_sp<SkRuntimeEffect> fEffect;
const char* fName;
sk_sp<SkData> fInputs;
SkSL::PipelineStageArgs fArgs;
sk_sp<SkRuntimeEffect> fEffect;
const char* fName;
sk_sp<SkData> fInputs;
GrCoordTransform fCoordTransform;

View File

@ -81,7 +81,6 @@ SkString GrGLSLFragmentProcessor::invokeChild(int childIndex, const char* inputC
SkString GrGLSLFragmentProcessor::invokeChildWithMatrix(int childIndex, const char* inputColor,
EmitArgs& args,
SkSL::String skslMatrix) {
SkASSERT(!args.fFp.isSampledWithExplicitCoords());
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
while (childIndex >= (int) fFunctionNames.size()) {
fFunctionNames.emplace_back();

View File

@ -17,7 +17,6 @@
#include "src/sksl/SkSLContext.h"
#include "src/sksl/SkSLErrorReporter.h"
#include "src/sksl/SkSLLexer.h"
#include "src/sksl/SkSLSampleMatrix.h"
#include "src/sksl/ir/SkSLProgram.h"
#include "src/sksl/ir/SkSLSymbolTable.h"
@ -80,7 +79,6 @@ public:
kCoords,
kUniform,
kChildProcessor,
kChildProcessorWithMatrix,
kFunctionName
};
@ -247,7 +245,6 @@ struct PipelineStageArgs {
String fCode;
std::vector<Compiler::FormatArg> fFormatArgs;
std::vector<Compiler::GLSLFunction> fFunctions;
std::vector<SkSL::SampleMatrix> fSampleMatrices;
};
#endif

View File

@ -81,18 +81,8 @@ void PipelineStageCodeGenerator::writeFunctionCall(const FunctionCall& c) {
SkASSERT(found);
this->write("%s");
size_t childCallIndex = fArgs->fFormatArgs.size();
bool matrixCall = c.fArguments.size() == 2 &&
c.fArguments[1]->fType.kind() == Type::kMatrix_Kind;
fArgs->fFormatArgs.push_back(
Compiler::FormatArg(matrixCall ? Compiler::FormatArg::Kind::kChildProcessorWithMatrix
: Compiler::FormatArg::Kind::kChildProcessor,
index));
while ((int) fArgs->fSampleMatrices.size() <= index) {
fArgs->fSampleMatrices.push_back(SampleMatrix(SampleMatrix::Kind::kNone));
}
if (matrixCall) {
fArgs->fSampleMatrices[index] = SampleMatrix(SampleMatrix::Kind::kVariable);
}
Compiler::FormatArg(Compiler::FormatArg::Kind::kChildProcessor, index));
OutputStream* oldOut = fOut;
StringStream buffer;
fOut = &buffer;