Revert "Initial support for DSL FPs"

This reverts commit c48a23d774.

Reason for revert: Possibly breaking some builds on android roll

Original change's description:
> Initial support for DSL FPs
>
> Change-Id: I1abbe881f925ac6db4f7d672a391aadd349a33b5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361556
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

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

Change-Id: Ia76b24293ab676fbf9e43f470cf3c3d6b96b2d34
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362696
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2021-01-30 02:51:30 +00:00 committed by Skia Commit-Bot
parent e1314a391f
commit 29e521c533
22 changed files with 1 additions and 216 deletions

View File

@ -1,51 +0,0 @@
/*
* Copyright 2021 Google LLC.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm/gm.h"
#include "include/core/SkFont.h"
#include "include/effects/SkRuntimeEffect.h"
#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ops/GrFillRectOp.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "tools/ToolUtils.h"
class SimpleDSLEffect : public GrFragmentProcessor {
public:
static constexpr GrProcessor::ClassID CLASS_ID = (GrProcessor::ClassID) 100;
SimpleDSLEffect() : GrFragmentProcessor(CLASS_ID, kNone_OptimizationFlags) {
}
const char* name() const override { return "DSLEffect"; }
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor& that) const override { return this == &that; }
std::unique_ptr<GrFragmentProcessor> clone() const override { return nullptr; }
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
class Impl : public GrGLSLFragmentProcessor {
void emitCode(EmitArgs& args) override {
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Var coords(kFloat4);
args.fFragBuilder->codeAppend(Declare(coords, sk_FragCoord()));
args.fFragBuilder->codeAppend(Return(Half4(Swizzle(coords, X, Y) / 100, 0, 1)));
EndFragmentProcessor();
}
};
return new Impl;
}
};
DEF_SIMPLE_GPU_GM(simple_dsl_test, ctx, rtCtx, canvas, 100, 100) {
auto fp = std::make_unique<SimpleDSLEffect>();
GrPaint paint;
paint.setColorFragmentProcessor(std::move(fp));
rtCtx->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::MakeIWH(100, 100));
}

View File

@ -158,7 +158,6 @@ gm_sources = [
"$_gm/dropshadowimagefilter.cpp",
"$_gm/drrect.cpp",
"$_gm/drrect_small_inner.cpp",
"$_gm/dsl_processor_tests.cpp",
"$_gm/dstreadshuffle.cpp",
"$_gm/ducky_yuv_blend.cpp",
"$_gm/emboss.cpp",

View File

@ -65,7 +65,6 @@ skia_sksl_sources = [
"$_src/sksl/dsl/DSLStatement.cpp",
"$_src/sksl/dsl/DSLType.cpp",
"$_src/sksl/dsl/DSLVar.cpp",
"$_src/sksl/dsl/priv/DSLFPs.cpp",
"$_src/sksl/dsl/priv/DSLWriter.cpp",
"$_src/sksl/ir/SkSLBinaryExpression.h",
"$_src/sksl/ir/SkSLBlock.h",

View File

@ -58,10 +58,6 @@ const GrCaps* GrD3DPipelineStateBuilder::caps() const {
return fGpu->caps();
}
SkSL::Compiler* GrD3DPipelineStateBuilder::shaderCompiler() const {
return fGpu->shaderCompiler();
}
void GrD3DPipelineStateBuilder::finalizeFragmentOutputColor(GrShaderVar& outputColor) {
outputColor.addLayoutQualifier("location = 0, index = 0");
}

View File

@ -36,8 +36,6 @@ public:
GrD3DGpu* gpu() const { return fGpu; }
SkSL::Compiler* shaderCompiler() const override;
void finalizeFragmentOutputColor(GrShaderVar& outputColor) override;
void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) override;

View File

@ -450,10 +450,6 @@ const GrCaps* GrDawnProgramBuilder::caps() const {
return fGpu->caps();
}
SkSL::Compiler* GrDawnProgramBuilder::shaderCompiler() const {
return fGpu->shaderCompiler();
}
void GrDawnProgram::setRenderTargetState(const GrRenderTarget* rt, GrSurfaceOrigin origin) {
// Load the RT height uniform if it is needed to y-flip gl_FragCoord.
if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&

View File

@ -86,8 +86,6 @@ public:
GrDawnGpu* gpu() const { return fGpu; }
SkSL::Compiler* shaderCompiler() const override;
private:
GrDawnProgramBuilder(GrDawnGpu*,
GrRenderTarget*,

View File

@ -92,10 +92,6 @@ const GrCaps* GrGLProgramBuilder::caps() const {
return fGpu->caps();
}
SkSL::Compiler* GrGLProgramBuilder::shaderCompiler() const {
return fGpu->shaderCompiler();
}
bool GrGLProgramBuilder::compileAndAttachShaders(const SkSL::String& glsl,
GrGLuint programId,
GrGLenum type,

View File

@ -56,8 +56,6 @@ public:
GrGLGpu* gpu() const { return fGpu; }
SkSL::Compiler* shaderCompiler() const override;
private:
GrGLProgramBuilder(GrGLGpu*, GrRenderTarget*, const GrProgramDesc&, const GrProgramInfo&);

View File

@ -19,7 +19,6 @@
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLXferProcessor.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
const int GrGLSLProgramBuilder::kVarsPerBlock = 8;
@ -55,14 +54,12 @@ void GrGLSLProgramBuilder::addFeature(GrShaderFlags shaders,
bool GrGLSLProgramBuilder::emitAndInstallProcs() {
// First we loop over all of the installed processors and collect coord transforms. These will
// be sent to the GrGLSLPrimitiveProcessor in its emitCode function
SkSL::dsl::Start(this->shaderCompiler());
SkString inputColor;
SkString inputCoverage;
this->emitAndInstallPrimProc(&inputColor, &inputCoverage);
this->emitAndInstallFragProcs(&inputColor, &inputCoverage);
this->emitAndInstallXferProc(inputColor, inputCoverage);
fGeometryProcessor->emitTransformCode(&fVS, this->uniformHandler());
SkSL::dsl::End();
return this->checkSamplerCounts();
}

View File

@ -46,7 +46,6 @@ public:
return fProgramInfo.pipeline().snapVerticesToPixelCenters();
}
bool hasPointSize() const { return fProgramInfo.primitiveType() == GrPrimitiveType::kPoints; }
virtual SkSL::Compiler* shaderCompiler() const = 0;
// TODO: stop passing in the renderTarget for just the sampleLocations
int effectiveSampleCnt() {

View File

@ -13,7 +13,6 @@
#include "src/gpu/glsl/GrGLSLBlend.h"
#include "src/gpu/glsl/GrGLSLColorSpaceXformHelper.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program)
: fProgramBuilder(program)
@ -82,14 +81,6 @@ void GrGLSLShaderBuilder::emitFunctionPrototype(GrSLType returnType,
this->functions().append(";\n");
}
void GrGLSLShaderBuilder::codeAppend(SkSL::dsl::Statement stmt) {
SkASSERT(SkSL::dsl::DSLWriter::CurrentProcessor());
std::unique_ptr<SkSL::Statement> skslStmt = stmt.release();
if (skslStmt) {
this->codeAppend(skslStmt->description().c_str());
}
}
static inline void append_texture_swizzle(SkString* out, GrSwizzle swizzle) {
if (swizzle != GrSwizzle::RGBA()) {
out->appendf(".%s", swizzle.asString().c_str());

View File

@ -14,7 +14,6 @@
#include "src/gpu/GrTBlockList.h"
#include "src/gpu/glsl/GrGLSLUniformHandler.h"
#include "src/sksl/SkSLString.h"
#include "src/sksl/dsl/DSL.h"
#include <stdarg.h>
@ -110,8 +109,6 @@ public:
void codeAppend(const char* str, size_t length) { this->code().append(str, length); }
void codeAppend(SkSL::dsl::Statement stmt);
void codePrependf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
va_list args;
va_start(args, format);

View File

@ -45,8 +45,6 @@ private:
const GrCaps* caps() const override;
SkSL::Compiler* shaderCompiler() const override;
void finalizeFragmentOutputColor(GrShaderVar& outputColor) override;
void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) override;

View File

@ -54,10 +54,6 @@ const GrCaps* GrMtlPipelineStateBuilder::caps() const {
return fGpu->caps();
}
SkSL::Compiler* GrMtlPipelineStateBuilder::shaderCompiler() const {
return fGpu->shaderCompiler();
}
void GrMtlPipelineStateBuilder::finalizeFragmentOutputColor(GrShaderVar& outputColor) {
outputColor.addLayoutQualifier("location = 0, index = 0");
}

View File

@ -58,10 +58,6 @@ const GrCaps* GrVkPipelineStateBuilder::caps() const {
return fGpu->caps();
}
SkSL::Compiler* GrVkPipelineStateBuilder::shaderCompiler() const {
return fGpu->shaderCompiler();
}
void GrVkPipelineStateBuilder::finalizeFragmentOutputColor(GrShaderVar& outputColor) {
outputColor.addLayoutQualifier("location = 0, index = 0");
}

View File

@ -40,8 +40,6 @@ public:
GrVkGpu* gpu() const { return fGpu; }
SkSL::Compiler* shaderCompiler() const override;
void finalizeFragmentOutputColor(GrShaderVar& outputColor) override;
void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) override;

View File

@ -10,8 +10,7 @@
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "src/sksl/ir/SkSLExpression.h"
#include "src/sksl/ir/SkSLStatement.h"
#include "src/sksl/ir/SkSLIRNode.h"
#include <memory>

View File

@ -1,31 +0,0 @@
/*
* Copyright 2021 Google LLC.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
namespace SkSL {
namespace dsl {
void StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
GrGLSLFragmentProcessor::EmitArgs* emitArgs) {
DSLWriter::StartFragmentProcessor(processor, emitArgs);
}
void EndFragmentProcessor() {
DSLWriter::EndFragmentProcessor();
}
} // namespace dsl
} // namespace SkSL
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU

View File

@ -1,32 +0,0 @@
/*
* Copyright 2021 Google LLC.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SKSL_DSL_FPS
#define SKSL_DSL_FPS
#include "src/sksl/dsl/DSL.h"
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
namespace SkSL {
namespace dsl {
void StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
GrGLSLFragmentProcessor::EmitArgs* emitArgs);
void EndFragmentProcessor();
} // namespace dsl
} // namespace SkSL
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#endif

View File

@ -65,21 +65,6 @@ void DSLWriter::SetCurrentFunction(const SkSL::FunctionDeclaration* fn) {
IRGenerator().fCurrentFunction = fn;
}
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
void DSLWriter::StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
GrGLSLFragmentProcessor::EmitArgs* emitArgs) {
Instance().fStack.push({processor, emitArgs});
IRGenerator().pushSymbolTable();
}
void DSLWriter::EndFragmentProcessor() {
DSLWriter& instance = Instance();
SkASSERT(!instance.fStack.empty());
instance.fStack.pop();
IRGenerator().popSymbolTable();
}
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
std::unique_ptr<SkSL::Expression> DSLWriter::Check(std::unique_ptr<SkSL::Expression> expr) {
if (expr == nullptr) {
if (DSLWriter::Compiler().errorCount()) {

View File

@ -97,36 +97,6 @@ public:
*/
static void SetCurrentFunction(const SkSL::FunctionDeclaration* fn);
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
/**
* Returns the fragment processor for which DSL output is being generated for the current
* thread.
*/
static GrGLSLFragmentProcessor* CurrentProcessor() {
SkASSERTF(!Instance().fStack.empty(), "This feature requires a FragmentProcessor");
return Instance().fStack.top().fProcessor;
}
/**
* Returns the EmitArgs for fragment processor output in the current thread.
*/
static GrGLSLFragmentProcessor::EmitArgs* CurrentEmitArgs() {
SkASSERTF(!Instance().fStack.empty(), "This feature requires a FragmentProcessor");
return Instance().fStack.top().fEmitArgs;
}
/**
* Pushes a new processor / emitArgs pair for the current thread.
*/
static void StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
GrGLSLFragmentProcessor::EmitArgs* emitArgs);
/**
* Pops the processor / emitArgs pair associated with the current thread.
*/
static void EndFragmentProcessor();
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
/**
* Reports an error if the argument is null. Returns its argument unmodified.
*/
@ -179,13 +149,6 @@ private:
ErrorHandler* fErrorHandler = nullptr;
bool fMangle = true;
Mangler fMangler;
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
struct StackFrame {
GrGLSLFragmentProcessor* fProcessor;
GrGLSLFragmentProcessor::EmitArgs* fEmitArgs;
};
std::stack<StackFrame> fStack;
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
friend class DSLCore;
friend class ::AutoDSLContext;