Remove DSLFP support.

Ganesh did not adopt DSL FPs, and Graphite is moving to a module-based
solution instead (where we precompile and rehydrate everything once at
startup).

Change-Id: Ie659535739b2d47de654625f65994912c61b0466
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/540301
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2022-05-16 11:36:09 -04:00 committed by SkCQ
parent 431f305d51
commit 9216ee97d5
19 changed files with 1 additions and 430 deletions

View File

@ -192,7 +192,6 @@ filegroup(
"dropshadowimagefilter.cpp",
"drrect.cpp",
"drrect_small_inner.cpp",
"dsl_processor_test.cpp",
"dstreadshuffle.cpp",
"ducky_yuv_blend.cpp",
"emboss.cpp",
@ -3834,23 +3833,6 @@ generated_cc_atom(
],
)
generated_cc_atom(
name = "dsl_processor_test_src",
srcs = ["dsl_processor_test.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":gm_hdr",
"//include/effects:SkRuntimeEffect_hdr",
"//include/sksl:DSL_hdr",
"//src/core:SkCanvasPriv_hdr",
"//src/gpu/ganesh:SurfaceFillContext_hdr",
"//src/gpu/ganesh/glsl:GrGLSLFragmentShaderBuilder_hdr",
"//src/sksl/dsl/priv:DSLFPs_hdr",
"//src/sksl/dsl/priv:DSLWriter_hdr",
"//src/sksl/ir:SkSLVariable_hdr",
],
)
generated_cc_atom(
name = "dstreadshuffle_src",
srcs = ["dstreadshuffle.cpp"],

View File

@ -1,70 +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/effects/SkRuntimeEffect.h"
#include "include/sksl/DSL.h"
#include "src/core/SkCanvasPriv.h"
#include "src/gpu/ganesh/SurfaceFillContext.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#include "src/sksl/ir/SkSLVariable.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 onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor& that) const override { return this == &that; }
std::unique_ptr<GrFragmentProcessor> clone() const override { return nullptr; }
std::unique_ptr<ProgramImpl> onMakeProgramImpl() const override {
class Impl : public ProgramImpl {
public:
void emitCode(EmitArgs& args) override {
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
// Test for skbug.com/11384
Var x(kInt_Type, 1);
Declare(x);
SkASSERT(DSLWriter::Var(x)->initialValue()->description() == "1");
GlobalVar blueAlpha(kUniform_Modifier, kHalf2_Type, "blueAlpha");
Declare(blueAlpha);
fBlueAlphaUniform = VarUniformHandle(blueAlpha);
Var coords(kFloat4_Type, sk_FragCoord());
Declare(coords);
Return(Half4(Swizzle(coords, X, Y) / 100, blueAlpha));
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& effect) override {
pdman.set2f(fBlueAlphaUniform, 0.0, 1.0);
}
GrGLSLProgramDataManager::UniformHandle fBlueAlphaUniform;
};
return std::make_unique<Impl>();
}
};
DEF_SIMPLE_GPU_GM(simple_dsl_test, rContext, canvas, 100, 100) {
auto sfc = SkCanvasPriv::TopDeviceSurfaceFillContext(canvas);
if (!sfc) {
return;
}
sfc->fillWithFP(std::make_unique<SimpleDSLEffect>());
}

View File

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

View File

@ -108,7 +108,6 @@ skia_sksl_sources = [
"$_src/sksl/dsl/DSLSymbols.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/dsl/priv/DSLWriter.h",
"$_src/sksl/ir/SkSLBinaryExpression.cpp",

View File

@ -101,7 +101,6 @@ generated_cc_atom(
"//src/gpu/ganesh:GrXferProcessor_hdr",
"//src/gpu/ganesh/effects:GrTextureEffect_hdr",
"//src/sksl:SkSLCompiler_hdr",
"//src/sksl/dsl/priv:DSLFPs_hdr",
],
)
@ -151,7 +150,6 @@ generated_cc_atom(
":GrGLSLColorSpaceXformHelper_hdr",
":GrGLSLProgramBuilder_hdr",
":GrGLSLShaderBuilder_hdr",
"//include/sksl:DSL_hdr",
"//src/gpu:Blend_hdr",
"//src/gpu:Swizzle_hdr",
"//src/gpu/ganesh:GrShaderCaps_hdr",

View File

@ -21,7 +21,6 @@
#include "src/gpu/ganesh/effects/GrTextureEffect.h"
#include "src/gpu/ganesh/glsl/GrGLSLVarying.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
const int GrGLSLProgramBuilder::kVarsPerBlock = 8;

View File

@ -7,7 +7,6 @@
#include "src/gpu/ganesh/glsl/GrGLSLShaderBuilder.h"
#include "include/sksl/DSL.h"
#include "src/gpu/Blend.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrShaderCaps.h"
@ -89,15 +88,6 @@ void GrGLSLShaderBuilder::emitFunctionPrototype(const char* declaration) {
this->functions().appendf("%s;\n", declaration);
}
void GrGLSLShaderBuilder::codeAppend(std::unique_ptr<SkSL::Statement> stmt) {
SkASSERT(SkSL::ThreadContext::CurrentProcessor());
SkASSERT(stmt);
this->codeAppend(stmt->description().c_str());
if (stmt->is<SkSL::VarDeclaration>()) {
fDeclarations.push_back(std::move(stmt));
}
}
static inline void append_texture_swizzle(SkString* out, skgpu::Swizzle swizzle) {
if (swizzle != skgpu::Swizzle::RGBA()) {
out->appendf(".%s", swizzle.asString().c_str());

View File

@ -117,8 +117,6 @@ public:
void codeAppend(const char* str, size_t length) { this->code().append(str, length); }
void codeAppend(std::unique_ptr<SkSL::Statement> stmt);
void codePrependf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
va_list args;
va_start(args, format);

View File

@ -71,7 +71,6 @@ cc_library(
"//src/sksl/dsl:DSLSymbols_src",
"//src/sksl/dsl:DSLType_src",
"//src/sksl/dsl:DSLVar_src",
"//src/sksl/dsl/priv:DSLFPs_src",
"//src/sksl/dsl/priv:DSLWriter_src",
"//src/sksl/ir:SkSLBinaryExpression_src",
"//src/sksl/ir:SkSLBlock_src",
@ -860,9 +859,7 @@ generated_cc_atom(
":SkSLThreadContext_hdr",
":SkSLUtil_hdr",
"//include/private:SkSLProgramElement_hdr",
"//include/sksl:DSLSymbols_hdr",
"//include/sksl:SkSLPosition_hdr",
"//src/gpu/ganesh/glsl:GrGLSLFragmentShaderBuilder_hdr",
"//src/sksl/ir:SkSLExternalFunction_hdr",
"//src/sksl/ir:SkSLSymbolTable_hdr",
],

View File

@ -8,7 +8,6 @@
#include "src/sksl/SkSLThreadContext.h"
#include "include/private/SkSLProgramElement.h"
#include "include/sksl/DSLSymbols.h"
#include "include/sksl/SkSLPosition.h"
#include "src/sksl/SkSLBuiltinMap.h"
#include "src/sksl/SkSLCompiler.h"
@ -21,10 +20,6 @@
#include <type_traits>
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
namespace SkSL {
ThreadContext::ThreadContext(SkSL::Compiler* compiler, SkSL::ProgramKind kind,
@ -109,24 +104,6 @@ ThreadContext::RTAdjustData& ThreadContext::RTAdjustState() {
return Instance().fRTAdjust;
}
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
void ThreadContext::StartFragmentProcessor(GrFragmentProcessor::ProgramImpl* processor,
GrFragmentProcessor::ProgramImpl::EmitArgs* emitArgs) {
ThreadContext& instance = ThreadContext::Instance();
instance.fStack.push({processor, emitArgs, StatementArray{}});
CurrentEmitArgs()->fFragBuilder->fDeclarations.swap(instance.fStack.top().fSavedDeclarations);
dsl::PushSymbolTable();
}
void ThreadContext::EndFragmentProcessor() {
ThreadContext& instance = Instance();
SkASSERT(!instance.fStack.empty());
CurrentEmitArgs()->fFragBuilder->fDeclarations.swap(instance.fStack.top().fSavedDeclarations);
instance.fStack.pop();
dsl::PopSymbolTable();
}
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
void ThreadContext::SetErrorReporter(ErrorReporter* errorReporter) {
SkASSERT(errorReporter);
Context().fErrors = errorReporter;

View File

@ -134,44 +134,6 @@ public:
*/
static RTAdjustData& RTAdjustState();
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
/**
* Returns the fragment processor for which DSL output is being generated for the current
* thread.
*/
static GrFragmentProcessor::ProgramImpl* 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 GrFragmentProcessor::ProgramImpl::EmitArgs* CurrentEmitArgs() {
SkASSERTF(!Instance().fStack.empty(), "This feature requires a FragmentProcessor");
return Instance().fStack.top().fEmitArgs;
}
static bool InFragmentProcessor() {
return !Instance().fStack.empty();
}
/**
* Pushes a new processor / emitArgs pair for the current thread.
*/
static void StartFragmentProcessor(GrFragmentProcessor::ProgramImpl* processor,
GrFragmentProcessor::ProgramImpl::EmitArgs* emitArgs);
/**
* Pops the processor / emitArgs pair associated with the current thread.
*/
static void EndFragmentProcessor();
#else
static bool InFragmentProcessor() {
return false;
}
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
static const char* Filename() {
return Instance().fFilename;
}

View File

@ -85,13 +85,10 @@ generated_cc_atom(
"//include/private:SkSLDefines_hdr",
"//include/sksl:DSLCore_hdr",
"//include/sksl:DSLExpression_hdr",
"//include/sksl:DSLStatement_hdr",
"//include/sksl:DSLType_hdr",
"//include/sksl:DSLVar_hdr",
"//include/sksl:DSLWrapper_hdr",
"//include/sksl:SkSLOperator_hdr",
"//src/gpu/ganesh:GrFragmentProcessor_hdr",
"//src/gpu/ganesh/glsl:GrGLSLFragmentShaderBuilder_hdr",
"//src/sksl:SkSLThreadContext_hdr",
"//src/sksl/dsl/priv:DSLWriter_hdr",
"//src/sksl/ir:SkSLBinaryExpression_hdr",
@ -171,8 +168,6 @@ generated_cc_atom(
"//include/sksl:DSLExpression_hdr",
"//include/sksl:DSLStatement_hdr",
"//include/sksl:SkSLPosition_hdr",
"//src/gpu/ganesh:GrFragmentProcessor_hdr",
"//src/gpu/ganesh/glsl:GrGLSLFragmentShaderBuilder_hdr",
"//src/sksl:SkSLThreadContext_hdr",
"//src/sksl/ir:SkSLBlock_hdr",
"//src/sksl/ir:SkSLExpressionStatement_hdr",
@ -231,25 +226,14 @@ generated_cc_atom(
deps = [
"//include/core:SkTypes_hdr",
"//include/private:SkSLDefines_hdr",
"//include/private:SkSLLayout_hdr",
"//include/private:SkSLModifiers_hdr",
"//include/private:SkSLStatement_hdr",
"//include/private:SkSLString_hdr",
"//include/private:SkSLSymbol_hdr",
"//include/private/gpu/ganesh:GrTypesPriv_hdr",
"//include/sksl:DSLModifiers_hdr",
"//include/sksl:DSLType_hdr",
"//include/sksl:DSLVar_hdr",
"//include/sksl:SkSLOperator_hdr",
"//src/core:SkSLTypeShared_hdr",
"//src/gpu/ganesh:GrFragmentProcessor_hdr",
"//src/gpu/ganesh/glsl:GrGLSLUniformHandler_hdr",
"//src/sksl:SkSLBuiltinTypes_hdr",
"//src/sksl:SkSLCompiler_hdr",
"//src/sksl:SkSLContext_hdr",
"//src/sksl:SkSLModifiersPool_hdr",
"//src/sksl:SkSLThreadContext_hdr",
"//src/sksl:SkSLUtil_hdr",
"//src/sksl/dsl/priv:DSLWriter_hdr",
"//src/sksl/ir:SkSLBinaryExpression_hdr",
"//src/sksl/ir:SkSLExpression_hdr",

View File

@ -73,8 +73,6 @@ void StartModule(SkSL::Compiler* compiler, ProgramKind kind, const ProgramSettin
}
void End() {
SkASSERTF(!ThreadContext::InFragmentProcessor(),
"more calls to StartFragmentProcessor than to EndFragmentProcessor");
ThreadContext::SetInstance(nullptr);
}

View File

@ -10,7 +10,6 @@
#include "include/core/SkTypes.h"
#include "include/private/SkSLDefines.h"
#include "include/sksl/DSLCore.h"
#include "include/sksl/DSLStatement.h"
#include "include/sksl/DSLType.h"
#include "include/sksl/DSLVar.h"
#include "include/sksl/DSLWrapper.h"
@ -31,11 +30,6 @@
#include <math.h>
#include <utility>
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#endif
namespace SkSL {
namespace dsl {
@ -117,13 +111,6 @@ DSLExpression DSLExpression::Poison(Position pos) {
}
DSLExpression::~DSLExpression() {
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
if (fExpression && ThreadContext::InFragmentProcessor()) {
ThreadContext::CurrentEmitArgs()->fFragBuilder->codeAppend(
DSLStatement(this->release()).release());
return;
}
#endif
SkASSERTF(!fExpression || !ThreadContext::Settings().fAssertDSLObjectsReleased,
"Expression destroyed without being incorporated into program (see "
"ProgramSettings::fAssertDSLObjectsReleased)");

View File

@ -17,11 +17,6 @@
#include "src/sksl/ir/SkSLExpressionStatement.h"
#include "src/sksl/ir/SkSLNop.h"
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#endif
namespace SkSL {
namespace dsl {
@ -65,12 +60,6 @@ DSLStatement::DSLStatement(DSLPossibleStatement stmt, Position pos) {
}
DSLStatement::~DSLStatement() {
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
if (fStatement && ThreadContext::InFragmentProcessor()) {
ThreadContext::CurrentEmitArgs()->fFragBuilder->codeAppend(this->release());
return;
}
#endif
SkASSERTF(!fStatement || !ThreadContext::Settings().fAssertDSLObjectsReleased,
"Statement destroyed without being incorporated into program (see "
"ProgramSettings::fAssertDSLObjectsReleased)");

View File

@ -9,22 +9,13 @@
#include "include/core/SkTypes.h"
#include "include/private/SkSLDefines.h"
#include "include/private/SkSLLayout.h"
#include "include/private/SkSLModifiers.h"
#include "include/private/SkSLStatement.h"
#include "include/private/SkSLString.h"
#include "include/private/SkSLSymbol.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "include/sksl/DSLModifiers.h"
#include "include/sksl/DSLType.h"
#include "include/sksl/SkSLOperator.h"
#include "src/core/SkSLTypeShared.h"
#include "src/sksl/SkSLBuiltinTypes.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLContext.h"
#include "src/sksl/SkSLModifiersPool.h"
#include "src/sksl/SkSLThreadContext.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#include "src/sksl/ir/SkSLBinaryExpression.h"
#include "src/sksl/ir/SkSLExpression.h"
@ -35,12 +26,6 @@
#include "src/sksl/ir/SkSLVariable.h"
#include <string>
#include <type_traits>
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/glsl/GrGLSLUniformHandler.h"
#endif
namespace SkSL {
@ -66,33 +51,7 @@ DSLVarBase::DSLVarBase(const DSLModifiers& modifiers, DSLType type, std::string_
, fName(fType.skslType().isOpaque() ? name : DSLWriter::Name(name))
, fInitialValue(std::move(initialValue))
, fDeclared(DSLWriter::MarkVarsDeclared())
, fPosition(pos) {
if (fModifiers.fModifiers.fFlags & Modifiers::kUniform_Flag) {
#if SK_SUPPORT_GPU && !defined(SKSL_STANDALONE)
if (ThreadContext::InFragmentProcessor()) {
const SkSL::Type& skslType = fType.skslType();
SkSLType gpuType;
int count;
if (skslType.isArray()) {
SkAssertResult(SkSL::type_to_sksltype(ThreadContext::Context(),
skslType.componentType(), &gpuType));
count = skslType.columns();
SkASSERT(count > 0);
} else {
SkAssertResult(SkSL::type_to_sksltype(ThreadContext::Context(), skslType,
&gpuType));
count = 0;
}
const char* uniformName;
SkASSERT(ThreadContext::CurrentEmitArgs());
fUniformHandle = ThreadContext::CurrentEmitArgs()->fUniformHandler->addUniformArray(
&ThreadContext::CurrentEmitArgs()->fFp, kFragment_GrShaderFlag, gpuType,
std::string(this->name()).c_str(), count, &uniformName).toIndex();
fName = uniformName;
}
#endif // SK_SUPPORT_GPU && !defined(SKSL_STANDALONE)
}
}
, fPosition(pos) {}
DSLVarBase::~DSLVarBase() {
if (fDeclaration && !fDeclared) {
@ -131,32 +90,6 @@ DSLGlobalVar::DSLGlobalVar(const char* name)
: INHERITED(kVoid_Type, name, DSLExpression(), Position(), Position()) {
fName = name;
DSLWriter::MarkDeclared(*this);
#if SK_SUPPORT_GPU && !defined(SKSL_STANDALONE)
if (!strcmp(name, "sk_SampleCoord")) {
fName = ThreadContext::CurrentEmitArgs()->fSampleCoord;
// The actual sk_SampleCoord variable hasn't been created by GrGLSLFPFragmentBuilder yet, so
// if we attempt to look it up in the symbol table we'll get null. As we are currently
// converting all DSL code into strings rather than nodes, all we really need is a
// correctly-named variable with the right type, so we just create a placeholder for it.
// TODO(skia/11330): we'll need to fix this when switching over to nodes.
const SkSL::Modifiers* modifiers = ThreadContext::Context().fModifiersPool->add(
SkSL::Modifiers(SkSL::Layout(/*flags=*/0, /*location=*/-1, /*offset=*/-1,
/*binding=*/-1, /*index=*/-1, /*set=*/-1,
SK_MAIN_COORDS_BUILTIN, /*inputAttachmentIndex=*/-1),
SkSL::Modifiers::kNo_Flag));
fVar = ThreadContext::SymbolTable()->takeOwnershipOfIRNode(std::make_unique<SkSL::Variable>(
/*pos=*/Position(),
/*modifiersPosition=*/Position(),
modifiers,
fName,
ThreadContext::Context().fTypes.fFloat2.get(),
/*builtin=*/true,
SkSL::VariableStorage::kGlobal));
fInitialized = true;
return;
}
#endif
const SkSL::Symbol* result = (*ThreadContext::SymbolTable())[fName];
SkASSERTF(result, "could not find '%.*s' in symbol table", (int)fName.length(), fName.data());
fVar = &result->as<SkSL::Variable>();

View File

@ -6,37 +6,6 @@ exports_files_legacy()
enforce_iwyu_on_package()
generated_cc_atom(
name = "DSLFPs_hdr",
hdrs = ["DSLFPs.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkTypes_hdr",
"//include/sksl:DSLExpression_hdr",
"//include/sksl:DSLVar_hdr",
"//src/gpu/ganesh:GrFragmentProcessor_hdr",
"//src/gpu/ganesh/glsl:GrGLSLUniformHandler_hdr",
],
)
generated_cc_atom(
name = "DSLFPs_src",
srcs = ["DSLFPs.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":DSLFPs_hdr",
":DSLWriter_hdr",
"//include/core:SkString_hdr",
"//include/core:SkTypes_hdr",
"//src/sksl:SkSLBuiltinTypes_hdr",
"//src/sksl:SkSLContext_hdr",
"//src/sksl:SkSLThreadContext_hdr",
"//src/sksl/ir:SkSLCodeStringExpression_hdr",
"//src/sksl/ir:SkSLExpression_hdr",
"//src/sksl/ir:SkSLType_hdr",
],
)
generated_cc_atom(
name = "DSLWriter_hdr",
hdrs = ["DSLWriter.h"],

View File

@ -1,79 +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"
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "src/sksl/SkSLBuiltinTypes.h"
#include "src/sksl/SkSLContext.h"
#include "src/sksl/SkSLThreadContext.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#include "src/sksl/ir/SkSLCodeStringExpression.h"
#include "src/sksl/ir/SkSLExpression.h"
#include "src/sksl/ir/SkSLType.h"
#include <memory>
#include <string>
namespace SkSL {
namespace dsl {
void StartFragmentProcessor(GrFragmentProcessor::ProgramImpl* processor,
GrFragmentProcessor::ProgramImpl::EmitArgs* emitArgs) {
ThreadContext::StartFragmentProcessor(processor, emitArgs);
}
void EndFragmentProcessor() {
ThreadContext::EndFragmentProcessor();
}
DSLGlobalVar sk_SampleCoord() {
return DSLGlobalVar("sk_SampleCoord");
}
DSLExpression SampleChild(int index, DSLExpression sampleExpr) {
std::unique_ptr<SkSL::Expression> expr = sampleExpr.releaseIfPossible();
if (expr) {
SkASSERT(expr->type().isVector());
SkASSERT(expr->type().componentType().isFloat());
}
GrFragmentProcessor::ProgramImpl* proc = ThreadContext::CurrentProcessor();
GrFragmentProcessor::ProgramImpl::EmitArgs& emitArgs = *ThreadContext::CurrentEmitArgs();
SkString code;
switch (expr ? expr->type().columns() : 0) {
default:
SkASSERTF(0, "unsupported SampleChild type: %s", expr->type().description().c_str());
[[fallthrough]];
case 0:
code = proc->invokeChild(index, emitArgs);
break;
case 2:
code = proc->invokeChild(index, emitArgs, /*skslCoords=*/expr->description());
break;
case 4:
code = proc->invokeChild(index, /*inputColor=*/expr->description().c_str(), emitArgs);
break;
}
return DSLExpression(std::make_unique<SkSL::CodeStringExpression>(
code.c_str(), ThreadContext::Context().fTypes.fHalf4.get()));
}
GrGLSLUniformHandler::UniformHandle VarUniformHandle(const DSLGlobalVar& var) {
return DSLWriter::VarUniformHandle(var);
}
} // namespace dsl
} // namespace SkSL
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU

View File

@ -1,41 +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 "include/core/SkTypes.h"
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#include "include/sksl/DSLExpression.h"
#include "include/sksl/DSLVar.h"
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/glsl/GrGLSLUniformHandler.h"
namespace SkSL {
namespace dsl {
void StartFragmentProcessor(GrFragmentProcessor::ProgramImpl* processor,
GrFragmentProcessor::ProgramImpl::EmitArgs* emitArgs);
void EndFragmentProcessor();
DSLGlobalVar sk_SampleCoord();
DSLExpression SampleChild(int index, DSLExpression coords = DSLExpression());
GrGLSLUniformHandler::UniformHandle VarUniformHandle(const DSLGlobalVar& var);
} // namespace dsl
} // namespace SkSL
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
#endif