Revert "Implement statements and expressions in DSL C++ code generator."

This reverts commit 16cbfb41df.

Reason for revert: using ES3 features, breaks on ANGLE ES2 bots

Original change's description:
> Implement statements and expressions in DSL C++ code generator.
>
> This CL removes the bulk of the existing C++ code generator, especially
> all the complex format-string assembly code. It has been replaced with
> actual DSL code generation. Simple IR can now be successfully translated
> to a working DSL fragment processor.
>
> This CL also adds a simple test harness which is patterned after the
> existing SkSLTest; it renders a pixel, reads it back, and fails the test
> if the result isn't solid green (RGBA=0101).
>
> This CL doesn't implement every feature. Some obvious gaps include:
> - Sampling from children
> - Uniforms/inputs of any kind
> - Function calls of any kind
>
> Change-Id: Ib80c23fe1ba4453f7c3cb43b65f93c5ea0deb709
> Bug: skia:11854
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396757
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Change-Id: I4f3e7667bf1e3a5539d0248b6c47d9ae2296aa88
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398739
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-04-20 19:59:23 +00:00 committed by Skia Commit-Bot
parent 72ca357cf2
commit 60191e0502
37 changed files with 661 additions and 1622 deletions

View File

@ -15,16 +15,7 @@ sksl_fp_error_tests = [
"/sksl/errors/GrRecursion.fp",
]
sksl_dsl_fp_tests = [
"/sksl/dslfp/GrDSLFPTest_HelloWorld.fp",
"/sksl/dslfp/GrDSLFPTest_DoStatement.fp",
"/sksl/dslfp/GrDSLFPTest_ForStatement.fp",
"/sksl/dslfp/GrDSLFPTest_IfStatement.fp",
"/sksl/dslfp/GrDSLFPTest_SwitchStatement.fp",
"/sksl/dslfp/GrDSLFPTest_Swizzle.fp",
"/sksl/dslfp/GrDSLFPTest_Ternary.fp",
"/sksl/dslfp/GrDSLFPTest_WhileStatement.fp",
]
sksl_dsl_fp_tests = [ "/sksl/fp/GrDSLHelloWorld.fp" ]
sksl_fp_tests = [
"/sksl/fp/GrChildProcessorAndGlobal.fp",

View File

@ -54,7 +54,6 @@ tests_sources = [
"$_tests/CompressedBackendAllocationTest.cpp",
"$_tests/CopySurfaceTest.cpp",
"$_tests/CubicMapTest.cpp",
"$_tests/DSLFPTest.cpp",
"$_tests/DashPathEffectTest.cpp",
"$_tests/DataRefTest.cpp",
"$_tests/DebugLayerManagerTest.cpp",
@ -330,20 +329,6 @@ tests_sources = [
"$_tests/Writer32Test.cpp",
"$_tests/YUVCacheTest.cpp",
"$_tests/YUVTest.cpp",
"$_tests/sksl/dslfp/GrDSLFPTest_DoStatement.dsl.cpp",
"$_tests/sksl/dslfp/GrDSLFPTest_DoStatement.h",
"$_tests/sksl/dslfp/GrDSLFPTest_ForStatement.dsl.cpp",
"$_tests/sksl/dslfp/GrDSLFPTest_ForStatement.h",
"$_tests/sksl/dslfp/GrDSLFPTest_IfStatement.dsl.cpp",
"$_tests/sksl/dslfp/GrDSLFPTest_IfStatement.h",
"$_tests/sksl/dslfp/GrDSLFPTest_SwitchStatement.dsl.cpp",
"$_tests/sksl/dslfp/GrDSLFPTest_SwitchStatement.h",
"$_tests/sksl/dslfp/GrDSLFPTest_Swizzle.dsl.cpp",
"$_tests/sksl/dslfp/GrDSLFPTest_Swizzle.h",
"$_tests/sksl/dslfp/GrDSLFPTest_Ternary.dsl.cpp",
"$_tests/sksl/dslfp/GrDSLFPTest_Ternary.h",
"$_tests/sksl/dslfp/GrDSLFPTest_WhileStatement.dsl.cpp",
"$_tests/sksl/dslfp/GrDSLFPTest_WhileStatement.h",
]
gl_tests_sources = [

View File

@ -1,23 +0,0 @@
// (This test code was largely borrowed from shared/DoWhileControlFlow.sksl.)
half4 main() {
half4 color = half4(1, 1, 1, 1);
// Simple do-while loop, with no Block.
do color.r -= 0.25; while (color.r > 0.5);
// Do-while loop with a Block and Break in the middle.
do {
color.r -= 0.25;
if (color.r <= 0) break;
} while (color.a == 1);
// Do-while loop with a Block and Continue in the middle.
do {
color.b -= 0.25;
if (color.a == 1) continue; // should always happen
color.g = 0;
} while (color.b > 0);
// color contains green.
return color;
}

View File

@ -1,28 +0,0 @@
// (This test code was largely borrowed from shared/ForLoopControlFlow.sksl.)
half4 main() {
half4 color = half4(1);
// A basic for-loop with no block.
for (half a = 0; a <= 1; ++a) color.a = a;
// A for-loop with a block and a break inside.
for (half r = -5; r < 5; r += 1) {
color.r = r;
if (color.r == 0) break;
}
// A for-loop with a block and a continue inside.
for (half b = 5; b >= 0; b -= 1) {
color.b = b;
if (color.a == 1) continue; // should always happen
color.g = 0;
}
// // A for-loop with two init-variables. TODO(skia:11868): currently unsupported in DSL
// for (half x = 0, y = 1; x <= y; ++x) {
// color.a = x;
// }
// color contains green.
return color;
}

View File

@ -1,6 +0,0 @@
/* HELLO WORLD */
half4 main() {
// Return green.
return half4(0, 1, 0, 1);
}

View File

@ -1,42 +0,0 @@
half4 main() {
half4 color = half4(0);
// Basic if statement. (00 == 00: true --> color=0001)
if (color.rg == color.ba) color.a = 1;
// Basic if statement with Block. (00 == 01: false)
if (color.rg == color.ba) {
color.r = color.a;
}
// TODO(skia:11872): Add test for If statement with comma-expression statement instead of Block.
// Basic if-else statement. (0 == 0: true --> color=1011)
if (color.r == color.g) color = color.araa; else color = color.rrra;
// Chained if-else statements.
if (color.r + color.g + color.b + color.a == 1) { // (3 == 1: false)
color = half4(-1);
} else if (color.r + color.g + color.b + color.a == 2) { // (3 == 2: false)
color = half4(-2);
} else {
color = color.ggaa; // (color=0011)
}
// Nested if-else statements.
if (color.r == 1) { // (0 == 1: false)
if (color.r == 2) {
color = color.rrrr;
} else {
color = color.gggg;
}
} else {
if (color.b * color.a == 1) { // (1*1 == 1: true)
color = color.rbga; // (color = 0101)
} else {
color = color.aaaa;
}
}
return color;
}

View File

@ -1,26 +0,0 @@
half4 main() {
half4 color = half4(0);
switch (int(color.r)) { // will take case 0
case 0: ++color.g; // fallthrough
case 1: break;
case 2: return half4(0);
case 3: // fallthrough
case 4: ++color.r; // fallthrough
case 5: { ++color.b; } break;
default: { --color.g; break; }
}
switch (int(color.g)) { // will take case 1
case 1: break;
case 0: { color.r = 1; color.b = 1; }
}
@switch (10) {
case 0: color.r = color.g; break;
case 20: color.b = color.g; break;
case 10: color.a = color.g; break;
}
return color;
}

View File

@ -1,69 +0,0 @@
half4 main() {
half4 v = half4(1, 2, 3, 4);
v = half4(v.x, 1, 1, 1);
v = half4(v.xy, 1, 1);
v = half4(v.x1, 1, 1);
v = half4(v.0y, 1, 1);
v = half4(v.xyz, 1);
v = half4(v.xy1, 1);
v = half4(v.x0z, 1);
v = half4(v.x10, 1);
v = half4(v.1yz, 1);
v = half4(v.0y1, 1);
v = half4(v.11z, 1);
v = v.xyzw;
v = v.xyz1;
v = v.wwww;
v = v.xy10;
v = v.xzzx;
v = v.x0z1;
v = v.x11w;
v = v.x101;
v = v.1yzw;
v = v.0yz1;
v = v.0y1w;
v = v.1y11;
v = v.00zw;
v = v.00z1;
v = v.011w;
v = v.rgba;
v = v.rgb0.abgr;
v = v.rgba.00ra;
v = v.rgba.rrra.00ra.11ab;
v = v.abga.gb11;
v = v.abgr.abgr;
v = half4(v.rrrr.bb, 1, 1);
v = half4(v.ba.grgr);
bool4 b = bool4(true, true, true, true);
b = bool4(b.x, true, true, true);
b = bool4(b.xy, false, true);
b = bool4(b.x1, true, false);
b = bool4(b.0y, true, true);
b = bool4(b.xyz, true);
b = bool4(b.xy1, true);
b = bool4(b.x0z, true);
b = bool4(b.x10, false);
b = bool4(b.1yz, false);
b = bool4(b.0y1, false);
b = bool4(b.11z, false);
b = b.xyzw;
b = b.xyz1;
b = b.wwww;
b = b.xy10;
b = b.xzzx;
b = b.x0z1;
b = b.x11w;
b = b.x101;
b = b.1yzw;
b = b.0yz1;
b = b.0y1w;
b = b.1y11;
b = b.00zw;
b = b.00z1;
b = b.011w;
return half4(b.xy, 0, v.z);
}

View File

@ -1,11 +0,0 @@
half4 main() {
half4 green = half4(0, 1, 0, 1);
half4 red = half4(1, 0, 0, 1);
bool t = true;
bool f = false;
return half4(t ? green.r : red.r, // true -> green.r
f ? red.g : green.g, // false -> green.g
(green.g == red.r) ? green.b : red.r, // true -> green.b
(green.a != red.a) ? red.g : green.a); // false -> green.a
}

View File

@ -1,23 +0,0 @@
// (This test code was largely borrowed from shared/WhileLoopControlFlow.sksl.)
half4 main() {
half4 color = half4(1);
// Basic while loop without a block.
while (color.r > 0.5) color.r -= 0.25;
// While loop with a block and a break statement.
while (color.a == 1) {
color.r -= 0.25;
if (color.r <= 0) break;
}
// While loop with a block and a continue statement.
while (color.b > 0) {
color.b -= 0.25;
if (color.a == 1) continue; // should always happen
color.g = 0;
}
// color contains green.
return color;
}

View File

@ -0,0 +1,5 @@
/* HELLO WORLD */
half4 main() {
return half4(1);
}

View File

@ -77,13 +77,6 @@ public:
kGrDistanceFieldLCDTextGeoProc_ClassID,
kGrDistanceFieldPathGeoProc_ClassID,
kGrDitherEffect_ClassID,
kGrDSLFPTest_DoStatement_ClassID,
kGrDSLFPTest_ForStatement_ClassID,
kGrDSLFPTest_IfStatement_ClassID,
kGrDSLFPTest_SwitchStatement_ClassID,
kGrDSLFPTest_Swizzle_ClassID,
kGrDSLFPTest_Ternary_ClassID,
kGrDSLFPTest_WhileStatement_ClassID,
kGrDualIntervalGradientColorizer_ClassID,
kGrEllipseEffect_ClassID,
kGrFillRRectOp_Processor_ClassID,

View File

@ -16,8 +16,8 @@
using std::abs;
struct SkSLFloat4 {
SkSLFloat4(float x, float y, float z, float w)
struct Float4 {
Float4(float x, float y, float z, float w)
: fX(x)
, fY(y)
, fZ(z)
@ -44,9 +44,9 @@ inline SkPoint float2(float xy) { return SkPoint::Make(xy, xy); }
inline SkPoint float2(float x, float y) { return SkPoint::Make(x, y); }
inline SkSLFloat4 float4(float xyzw) { return SkSLFloat4(xyzw, xyzw, xyzw, xyzw); }
inline Float4 float4(float xyzw) { return Float4(xyzw, xyzw, xyzw, xyzw); }
inline SkSLFloat4 float4(float x, float y, float z, float w) { return SkSLFloat4(x, y, z, w); }
inline Float4 float4(float x, float y, float z, float w) { return Float4(x, y, z, w); }
#define half2 float2

View File

@ -551,7 +551,7 @@ void CPPCodeGenerator::writeFunction(const FunctionDefinition& f) {
if (decl.isBuiltin()) {
return;
}
fFunctionHeader.clear();
fFunctionHeader = "";
OutputStream* oldOut = fOut;
StringStream buffer;
fOut = &buffer;

File diff suppressed because it is too large Load Diff

View File

@ -27,32 +27,6 @@ public:
private:
using Precedence = Operator::Precedence;
void writeAnyConstructor(const AnyConstructor& c, Precedence parentPrecedence) override;
void writeBlock(const Block& b);
void writeCastConstructor(const AnyConstructor& c, Precedence parentPrecedence) override;
void writeDoStatement(const DoStatement& d);
void writeForStatement(const ForStatement& f);
void writeFunctionBody(const Block& b);
void writeIfStatement(const IfStatement& r) override;
void writeReturnStatement(const ReturnStatement& r) override;
void writeStatement(const Statement& s);
void writeSwitchStatement(const SwitchStatement& s) override;
void writeTernaryExpression(const TernaryExpression& t, Precedence parentPrecedence) override;
void writeVar(const Variable& var);
void writeVarDeclaration(const VarDeclaration& var, bool global);
void writef(const char* s, va_list va) SK_PRINTF_LIKE(2, 0);
void writef(const char* s, ...) SK_PRINTF_LIKE(2, 3);
@ -65,14 +39,24 @@ private:
String getTypeName(const Type& type) override;
String getDSLType(const Type& type);
void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrecedence) override;
String getDSLModifiers(const Modifiers& type);
void writeIntLiteral(const IntLiteral& i) override;
void writeSwizzle(const Swizzle& swizzle) override;
void writeVariableReference(const VariableReference& ref) override;
String getSamplerHandle(const Variable& var);
void writeIfStatement(const IfStatement& s) override;
void writeReturnStatement(const ReturnStatement& s) override;
void writeSwitchStatement(const SwitchStatement& s) override;
String getSampleVarName(const char* prefix, int sampleCounter);
void writeFunctionCall(const FunctionCall& c) override;
void writeFunction(const FunctionDefinition& f) override;
@ -88,6 +72,7 @@ private:
void addUniform(const Variable& var);
// writes a printf escape that will be filled in at runtime by the given C++ expression string
void writeRuntimeValue(const Type& type, const Layout& layout, const String& cppCode);
String formatRuntimeValue(const Type& type, const Layout& layout, const String& cppCode,
std::vector<String>* formatArgs);
@ -99,24 +84,57 @@ private:
void writePrivateVarValues();
void writeCodeAppend(const String& code);
String assembleCodeAndFormatArgPrintf(const String& code);
bool writeEmitCode(std::vector<const Variable*>& uniforms);
void writeSetData(std::vector<const Variable*>& uniforms);
void writeGetKey();
void writeOnTextureSampler();
void writeClone();
void writeDumpInfo();
void writeTest();
// If the returned C++ is included in the generated code, then the variable name stored in
// cppVar will refer to a valid SkString that matches the Expression. Successful returns leave
// the output buffer (and related state) unmodified.
//
// In the simplest cases, this will return "SkString {cppVar}(\"{e}\");", while more advanced
// cases will properly insert format arguments.
String convertSKSLExpressionToCPP(const Expression& e, const String& cppVar);
// Process accumulated sksl to split it into appended code sections, properly interleaved with
// the extra emit code blocks, based on statement/block locations and the inserted tokens
// from newExtraEmitCodeBlock(). It is necessary to split the sksl after the program has been
// fully walked since many elements redirect fOut to simultaneously build header sections and
// bodies that are then concatenated; due to this it is not possible to split the sksl emission
// on the fly.
void flushEmittedCode();
// Start a new extra emit code block for accumulating C++ code. This will insert a token into
// the sksl stream to mark the fence between previous complete sksl statements and where the
// C++ code added to the new block will be added to emitCode(). These tokens are removed by
// flushEmittedCode() as it consumes them before passing pure sksl to writeCodeAppend().
void newExtraEmitCodeBlock();
// Append CPP code to the current extra emit code block.
void addExtraEmitCodeLine(const String& toAppend);
int getChildFPIndex(const Variable& var) const;
String fName;
String fFullName;
SectionAndParameterHelper fSectionAndParameterHelper;
std::vector<String> fExtraEmitCodeBlocks;
std::vector<String> fFormatArgs;
// true if the sksl declared its main() function with a float2 parameter AND referenced that
// parameter in its body.
bool fAccessSampleCoordsDirectly = false;
@ -127,6 +145,14 @@ private:
// True while compiling the main() function of the FP.
bool fInMain = false;
// Gives unique but predictable names to invocations of sample().
int fSampleCounter = 0;
// if not null, we are accumulating SkSL for emitCode into fOut, which
// replaced the original buffer with a StringStream. The original buffer is
// stored here for restoration.
OutputStream* fCPPBuffer = nullptr;
using INHERITED = GLSLCodeGenerator;
};

View File

@ -688,7 +688,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
proj = false;
break;
}
if (!fTextureFunctionOverride.empty()) {
if (fTextureFunctionOverride != "") {
this->write(fTextureFunctionOverride.c_str());
} else {
this->write("texture");
@ -1038,7 +1038,7 @@ void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) {
this->writeLine(" {");
fIndentation++;
fFunctionHeader.clear();
fFunctionHeader = "";
OutputStream* oldOut = fOut;
StringStream buffer;
fOut = &buffer;

View File

@ -135,9 +135,9 @@ protected:
virtual void writeFunctionCall(const FunctionCall& c);
virtual void writeAnyConstructor(const AnyConstructor& c, Precedence parentPrecedence);
void writeAnyConstructor(const AnyConstructor& c, Precedence parentPrecedence);
virtual void writeCastConstructor(const AnyConstructor& c, Precedence parentPrecedence);
void writeCastConstructor(const AnyConstructor& c, Precedence parentPrecedence);
virtual void writeFieldAccess(const FieldAccess& f);
@ -148,7 +148,7 @@ protected:
void writeShortCircuitWorkaroundExpression(const BinaryExpression& b,
Precedence parentPrecedence);
virtual void writeTernaryExpression(const TernaryExpression& t, Precedence parentPrecedence);
void writeTernaryExpression(const TernaryExpression& t, Precedence parentPrecedence);
virtual void writeIndexExpression(const IndexExpression& expr);

View File

@ -1643,7 +1643,7 @@ void MetalCodeGenerator::writeFunction(const FunctionDefinition& f) {
this->writeLine(" (void)_out;");
}
fFunctionHeader.clear();
fFunctionHeader = "";
StringStream buffer;
{
AutoOutputStream outputToBuffer(this, &buffer);

View File

@ -1,64 +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/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
#include "include/core/SkFont.h"
#include "include/core/SkPaint.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "src/gpu/GrSurfaceDrawContext.h"
#include "tests/Test.h"
#include "tests/sksl/dslfp/GrDSLFPTest_DoStatement.h"
#include "tests/sksl/dslfp/GrDSLFPTest_ForStatement.h"
#include "tests/sksl/dslfp/GrDSLFPTest_IfStatement.h"
#include "tests/sksl/dslfp/GrDSLFPTest_SwitchStatement.h"
#include "tests/sksl/dslfp/GrDSLFPTest_Swizzle.h"
#include "tests/sksl/dslfp/GrDSLFPTest_Ternary.h"
#include "tests/sksl/dslfp/GrDSLFPTest_WhileStatement.h"
#include "tools/Resources.h"
#include "tools/ToolUtils.h"
template <typename FPClass>
static void test_dsl_fp(skiatest::Reporter* r, GrDirectContext* ctx) {
std::unique_ptr<GrSurfaceDrawContext> rtCtx =
GrSurfaceDrawContext::Make(ctx,
GrColorType::kRGBA_8888,
/*colorSpace=*/nullptr,
SkBackingFit::kApprox,
/*dimensions=*/{1, 1},
SkSurfaceProps{});
rtCtx->fillRectWithFP(SkIRect::MakeWH(1, 1), FPClass::Make());
SkImageInfo dstInfo = SkImageInfo::Make(/*width=*/1, /*height=*/1, kRGBA_8888_SkColorType,
kPremul_SkAlphaType, /*cs=*/nullptr);
GrPixmap dstPM = GrPixmap::Allocate(dstInfo);
REPORTER_ASSERT(r, rtCtx->readPixels(ctx, dstPM, /*srcPt=*/{0, 0}));
const GrColor* color = static_cast<const GrColor*>(dstPM.addr());
REPORTER_ASSERT(r, *color == GrColorPackRGBA(0x00, 0xFF, 0x00, 0xFF),
"Expected: solid green. Actual: A=%02X R=%02X G=%02X B=%02X.",
GrColorUnpackA(*color), GrColorUnpackR(*color),
GrColorUnpackG(*color), GrColorUnpackB(*color));
}
#define DSL_FP_TEST(FPClass) \
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FPClass, r, ctxInfo) { \
return test_dsl_fp<Gr##FPClass>(r, ctxInfo.directContext()); \
}
DSL_FP_TEST(DSLFPTest_DoStatement)
DSL_FP_TEST(DSLFPTest_ForStatement)
DSL_FP_TEST(DSLFPTest_IfStatement)
DSL_FP_TEST(DSLFPTest_SwitchStatement)
DSL_FP_TEST(DSLFPTest_Swizzle)
DSL_FP_TEST(DSLFPTest_Ternary)
DSL_FP_TEST(DSLFPTest_WhileStatement)

View File

@ -1,65 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_DoStatement.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLFPTest_DoStatement.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcomma"
#endif
class GrGLSLDSLFPTest_DoStatement : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLFPTest_DoStatement() {}
void emitCode(EmitArgs& args) override {
const GrDSLFPTest_DoStatement& _outer = args.fFp.cast<GrDSLFPTest_DoStatement>();
(void) _outer;
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Var color(kNo_Modifier, DSLType(kHalf4_Type), "color", Half4(1.0, 1.0, 1.0, 1.0));
Declare(color);
Do(color.x() -= 0.25, /*While:*/ color.x() > 0.5);
Do(Block(color.x() -= 0.25, If(color.x() <= 0.0, /*Then:*/ Break())), /*While:*/ color.w() == 1.0);
Do(Block(color.z() -= 0.25, If(color.w() == 1.0, /*Then:*/ Continue()), color.y() = 0.0), /*While:*/ color.z() > 0.0);
Return(color);
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_DoStatement::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLFPTest_DoStatement>();
}
void GrDSLFPTest_DoStatement::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLFPTest_DoStatement::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLFPTest_DoStatement& that = other.cast<GrDSLFPTest_DoStatement>();
(void) that;
return true;
}
GrDSLFPTest_DoStatement::GrDSLFPTest_DoStatement(const GrDSLFPTest_DoStatement& src)
: INHERITED(kGrDSLFPTest_DoStatement_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_DoStatement::clone() const {
return std::make_unique<GrDSLFPTest_DoStatement>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLFPTest_DoStatement::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,36 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_DoStatement.fp; do not modify.
**************************************************************************************************/
#ifndef GrDSLFPTest_DoStatement_DEFINED
#define GrDSLFPTest_DoStatement_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrDSLFPTest_DoStatement : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make() {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_DoStatement());
}
GrDSLFPTest_DoStatement(const GrDSLFPTest_DoStatement& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_DoStatement"; }
private:
GrDSLFPTest_DoStatement()
: INHERITED(kGrDSLFPTest_DoStatement_ClassID, kNone_OptimizationFlags) {
}
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#if GR_TEST_UTILS
SkString onDumpInfo() const override;
#endif
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
using INHERITED = GrFragmentProcessor;
};
#endif

View File

@ -1,68 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_ForStatement.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLFPTest_ForStatement.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcomma"
#endif
class GrGLSLDSLFPTest_ForStatement : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLFPTest_ForStatement() {}
void emitCode(EmitArgs& args) override {
const GrDSLFPTest_ForStatement& _outer = args.fFp.cast<GrDSLFPTest_ForStatement>();
(void) _outer;
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Var color(kNo_Modifier, DSLType(kHalf4_Type), "color", Half4(1.0));
Var a(kNo_Modifier, DSLType(kHalf_Type), "a", 0.0);
Var r(kNo_Modifier, DSLType(kHalf_Type), "r", -5.0);
Var b(kNo_Modifier, DSLType(kHalf_Type), "b", 5.0);
Declare(color);
For(Declare(a), a <= 1.0, ++a, /*Body:*/ color.w() = a);
For(Declare(r), r < 5.0, r += 1.0, /*Body:*/ Block(color.x() = r, If(color.x() == 0.0, /*Then:*/ Break())));
For(Declare(b), b >= 0.0, b -= 1.0, /*Body:*/ Block(color.z() = b, If(color.w() == 1.0, /*Then:*/ Continue()), color.y() = 0.0));
Return(color);
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_ForStatement::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLFPTest_ForStatement>();
}
void GrDSLFPTest_ForStatement::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLFPTest_ForStatement::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLFPTest_ForStatement& that = other.cast<GrDSLFPTest_ForStatement>();
(void) that;
return true;
}
GrDSLFPTest_ForStatement::GrDSLFPTest_ForStatement(const GrDSLFPTest_ForStatement& src)
: INHERITED(kGrDSLFPTest_ForStatement_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_ForStatement::clone() const {
return std::make_unique<GrDSLFPTest_ForStatement>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLFPTest_ForStatement::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,36 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_ForStatement.fp; do not modify.
**************************************************************************************************/
#ifndef GrDSLFPTest_ForStatement_DEFINED
#define GrDSLFPTest_ForStatement_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrDSLFPTest_ForStatement : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make() {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_ForStatement());
}
GrDSLFPTest_ForStatement(const GrDSLFPTest_ForStatement& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_ForStatement"; }
private:
GrDSLFPTest_ForStatement()
: INHERITED(kGrDSLFPTest_ForStatement_ClassID, kNone_OptimizationFlags) {
}
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#if GR_TEST_UTILS
SkString onDumpInfo() const override;
#endif
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
using INHERITED = GrFragmentProcessor;
};
#endif

View File

@ -1,60 +0,0 @@
/* HELLO WORLD */
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_HelloWorld.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLFPTest_HelloWorld.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcomma"
#endif
class GrGLSLDSLFPTest_HelloWorld : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLFPTest_HelloWorld() {}
void emitCode(EmitArgs& args) override {
const GrDSLFPTest_HelloWorld& _outer = args.fFp.cast<GrDSLFPTest_HelloWorld>();
(void) _outer;
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Return(Half4(0.0, 1.0, 0.0, 1.0));
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_HelloWorld::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLFPTest_HelloWorld>();
}
void GrDSLFPTest_HelloWorld::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLFPTest_HelloWorld::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLFPTest_HelloWorld& that = other.cast<GrDSLFPTest_HelloWorld>();
(void) that;
return true;
}
GrDSLFPTest_HelloWorld::GrDSLFPTest_HelloWorld(const GrDSLFPTest_HelloWorld& src)
: INHERITED(kGrDSLFPTest_HelloWorld_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_HelloWorld::clone() const {
return std::make_unique<GrDSLFPTest_HelloWorld>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLFPTest_HelloWorld::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,36 +0,0 @@
/* HELLO WORLD */
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_HelloWorld.fp; do not modify.
**************************************************************************************************/
#ifndef GrDSLFPTest_HelloWorld_DEFINED
#define GrDSLFPTest_HelloWorld_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrDSLFPTest_HelloWorld : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make() {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_HelloWorld());
}
GrDSLFPTest_HelloWorld(const GrDSLFPTest_HelloWorld& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_HelloWorld"; }
private:
GrDSLFPTest_HelloWorld()
: INHERITED(kGrDSLFPTest_HelloWorld_ClassID, kNone_OptimizationFlags) {
}
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#if GR_TEST_UTILS
SkString onDumpInfo() const override;
#endif
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
using INHERITED = GrFragmentProcessor;
};
#endif

View File

@ -1,67 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_IfStatement.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLFPTest_IfStatement.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcomma"
#endif
class GrGLSLDSLFPTest_IfStatement : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLFPTest_IfStatement() {}
void emitCode(EmitArgs& args) override {
const GrDSLFPTest_IfStatement& _outer = args.fFp.cast<GrDSLFPTest_IfStatement>();
(void) _outer;
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Var color(kNo_Modifier, DSLType(kHalf4_Type), "color", Half4(0.0));
Declare(color);
If(Swizzle(color, X, Y) == Swizzle(color, Z, W), /*Then:*/ color.w() = 1.0);
If(Swizzle(color, X, Y) == Swizzle(color, Z, W), /*Then:*/ Block(color.x() = color.w()));
If(color.x() == color.y(), /*Then:*/ color = Swizzle(color, W, X, W, W), /*Else:*/ color = Swizzle(color, X, X, X, W));
If(((color.x() + color.y()) + color.z()) + color.w() == 1.0, /*Then:*/ Block(color = Half4(-1.0)), /*Else:*/ If(((color.x() + color.y()) + color.z()) + color.w() == 2.0, /*Then:*/ Block(color = Half4(-2.0)), /*Else:*/ Block(color = Swizzle(color, Y, Y, W, W))));
If(color.x() == 1.0, /*Then:*/ Block(If(color.x() == 2.0, /*Then:*/ Block(color = Swizzle(color, X, X, X, X)), /*Else:*/ Block(color = Swizzle(color, Y, Y, Y, Y)))), /*Else:*/ Block(If(color.z() * color.w() == 1.0, /*Then:*/ Block(color = Swizzle(color, X, Z, Y, W)), /*Else:*/ Block(color = Swizzle(color, W, W, W, W)))));
Return(color);
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_IfStatement::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLFPTest_IfStatement>();
}
void GrDSLFPTest_IfStatement::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLFPTest_IfStatement::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLFPTest_IfStatement& that = other.cast<GrDSLFPTest_IfStatement>();
(void) that;
return true;
}
GrDSLFPTest_IfStatement::GrDSLFPTest_IfStatement(const GrDSLFPTest_IfStatement& src)
: INHERITED(kGrDSLFPTest_IfStatement_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_IfStatement::clone() const {
return std::make_unique<GrDSLFPTest_IfStatement>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLFPTest_IfStatement::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,36 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_IfStatement.fp; do not modify.
**************************************************************************************************/
#ifndef GrDSLFPTest_IfStatement_DEFINED
#define GrDSLFPTest_IfStatement_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrDSLFPTest_IfStatement : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make() {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_IfStatement());
}
GrDSLFPTest_IfStatement(const GrDSLFPTest_IfStatement& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_IfStatement"; }
private:
GrDSLFPTest_IfStatement()
: INHERITED(kGrDSLFPTest_IfStatement_ClassID, kNone_OptimizationFlags) {
}
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#if GR_TEST_UTILS
SkString onDumpInfo() const override;
#endif
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
using INHERITED = GrFragmentProcessor;
};
#endif

View File

@ -1,74 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_SwitchStatement.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLFPTest_SwitchStatement.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcomma"
#endif
class GrGLSLDSLFPTest_SwitchStatement : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLFPTest_SwitchStatement() {}
void emitCode(EmitArgs& args) override {
const GrDSLFPTest_SwitchStatement& _outer = args.fFp.cast<GrDSLFPTest_SwitchStatement>();
(void) _outer;
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Var color(kNo_Modifier, DSLType(kHalf4_Type), "color", Half4(0.0));
Declare(color);
Switch(Int(color.x()),
Case(0, ++color.y()),
Case(1, Break()),
Case(2, Return(Half4(0.0))),
Case(3),
Case(4, ++color.x()),
Case(5, Block(++color.z()), Break()),
Default(Block(--color.y(), Break())));
Switch(Int(color.y()),
Case(1, Break()),
Case(0, Block(color.x() = 1.0, color.z() = 1.0)));
Block(color.w() = color.y());
Return(color);
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_SwitchStatement::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLFPTest_SwitchStatement>();
}
void GrDSLFPTest_SwitchStatement::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLFPTest_SwitchStatement::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLFPTest_SwitchStatement& that = other.cast<GrDSLFPTest_SwitchStatement>();
(void) that;
return true;
}
GrDSLFPTest_SwitchStatement::GrDSLFPTest_SwitchStatement(const GrDSLFPTest_SwitchStatement& src)
: INHERITED(kGrDSLFPTest_SwitchStatement_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_SwitchStatement::clone() const {
return std::make_unique<GrDSLFPTest_SwitchStatement>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLFPTest_SwitchStatement::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,36 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_SwitchStatement.fp; do not modify.
**************************************************************************************************/
#ifndef GrDSLFPTest_SwitchStatement_DEFINED
#define GrDSLFPTest_SwitchStatement_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrDSLFPTest_SwitchStatement : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make() {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_SwitchStatement());
}
GrDSLFPTest_SwitchStatement(const GrDSLFPTest_SwitchStatement& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_SwitchStatement"; }
private:
GrDSLFPTest_SwitchStatement()
: INHERITED(kGrDSLFPTest_SwitchStatement_ClassID, kNone_OptimizationFlags) {
}
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#if GR_TEST_UTILS
SkString onDumpInfo() const override;
#endif
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
using INHERITED = GrFragmentProcessor;
};
#endif

View File

@ -1,120 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_Swizzle.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLFPTest_Swizzle.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcomma"
#endif
class GrGLSLDSLFPTest_Swizzle : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLFPTest_Swizzle() {}
void emitCode(EmitArgs& args) override {
const GrDSLFPTest_Swizzle& _outer = args.fFp.cast<GrDSLFPTest_Swizzle>();
(void) _outer;
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Var v(kNo_Modifier, DSLType(kHalf4_Type), "v", Half4(1.0, 2.0, 3.0, 4.0));
Var b(kNo_Modifier, DSLType(kBool4_Type), "b", Bool4(true, true, true, true));
Declare(v);
v = Half4(v.x(), 1.0, 1.0, 1.0);
v = Half4(Swizzle(v, X, Y), 1.0, 1.0);
v = Half4(v.x(), 1.0, 1.0, 1.0);
v = Half4(0.0, v.y(), 1.0, 1.0);
v = Half4(Swizzle(v, X, Y, Z), 1.0);
v = Half4(Swizzle(v, X, Y), 1.0, 1.0);
v = Half4(v.x(), 0.0, v.z(), 1.0);
v = Half4(v.x(), 1.0, 0.0, 1.0);
v = Half4(1.0, Swizzle(v, Y, Z), 1.0);
v = Half4(0.0, v.y(), 1.0, 1.0);
v = Half4(1.0, 1.0, v.z(), 1.0);
v = Half4(Swizzle(v, X, Y, Z), 1.0);
v = Swizzle(v, W, W, W, W);
v = Half4(Swizzle(v, X, Y), 1.0, 0.0);
v = Swizzle(v, X, Z, Z, X);
v = Half4(v.x(), 0.0, v.z(), 1.0);
v = Half4(v.x(), 1.0, 1.0, v.w());
v = Half4(v.x(), 1.0, 0.0, 1.0);
v = Half4(1.0, Swizzle(v, Y, Z, W));
v = Half4(0.0, Swizzle(v, Y, Z), 1.0);
v = Half4(0.0, v.y(), 1.0, v.w());
v = Half4(1.0, v.y(), 1.0, 1.0);
v = Half4(0.0, 0.0, Swizzle(v, Z, W));
v = Half4(0.0, 0.0, v.z(), 1.0);
v = Half4(0.0, 1.0, 1.0, v.w());
v = Half4(0.0, Swizzle(v, Z, Y, X));
v = Half4(0.0, 0.0, Swizzle(v, X, W));
v = Half4(1.0, 1.0, Swizzle(v, W, X));
v = Half4(Swizzle(v, Z, Y), 1.0, 1.0);
v = Half4(Swizzle(v, X, X), 1.0, 1.0);
v = Swizzle(v, W, Z, W, Z);
Declare(b);
b = Bool4(b.x(), true, true, true);
b = Bool4(Swizzle(b, X, Y), false, true);
b = Bool4(b.x(), true, true, false);
b = Bool4(false, b.y(), true, true);
b = Bool4(Swizzle(b, X, Y, Z), true);
b = Bool4(Swizzle(b, X, Y), true, true);
b = Bool4(b.x(), false, b.z(), true);
b = Bool4(b.x(), true, false, false);
b = Bool4(true, Swizzle(b, Y, Z), false);
b = Bool4(false, b.y(), true, false);
b = Bool4(true, true, b.z(), false);
b = Bool4(Swizzle(b, X, Y, Z), true);
b = Swizzle(b, W, W, W, W);
b = Bool4(Swizzle(b, X, Y), true, false);
b = Swizzle(b, X, Z, Z, X);
b = Bool4(b.x(), false, b.z(), true);
b = Bool4(b.x(), true, true, b.w());
b = Bool4(b.x(), true, false, true);
b = Bool4(true, Swizzle(b, Y, Z, W));
b = Bool4(false, Swizzle(b, Y, Z), true);
b = Bool4(false, b.y(), true, b.w());
b = Bool4(true, b.y(), true, true);
b = Bool4(false, false, Swizzle(b, Z, W));
b = Bool4(false, false, b.z(), true);
b = Bool4(false, true, true, b.w());
Return(Half4(Half2(Swizzle(b, X, Y)), 0.0, v.z()));
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_Swizzle::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLFPTest_Swizzle>();
}
void GrDSLFPTest_Swizzle::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLFPTest_Swizzle::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLFPTest_Swizzle& that = other.cast<GrDSLFPTest_Swizzle>();
(void) that;
return true;
}
GrDSLFPTest_Swizzle::GrDSLFPTest_Swizzle(const GrDSLFPTest_Swizzle& src)
: INHERITED(kGrDSLFPTest_Swizzle_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_Swizzle::clone() const {
return std::make_unique<GrDSLFPTest_Swizzle>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLFPTest_Swizzle::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,68 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_Ternary.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLFPTest_Ternary.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcomma"
#endif
class GrGLSLDSLFPTest_Ternary : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLFPTest_Ternary() {}
void emitCode(EmitArgs& args) override {
const GrDSLFPTest_Ternary& _outer = args.fFp.cast<GrDSLFPTest_Ternary>();
(void) _outer;
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Var green(kNo_Modifier, DSLType(kHalf4_Type), "green", Half4(0.0, 1.0, 0.0, 1.0));
Var red(kNo_Modifier, DSLType(kHalf4_Type), "red", Half4(1.0, 0.0, 0.0, 1.0));
Var t(kNo_Modifier, DSLType(kBool_Type), "t", true);
Var f(kNo_Modifier, DSLType(kBool_Type), "f", false);
Declare(green);
Declare(red);
Declare(t);
Declare(f);
Return(Half4(Select(t, /*If True:*/ green.x(), /*If False:*/ red.x()), Select(f, /*If True:*/ red.y(), /*If False:*/ green.y()), Select(green.y() == red.x(), /*If True:*/ green.z(), /*If False:*/ red.x()), Select(green.w() != red.w(), /*If True:*/ red.y(), /*If False:*/ green.w())));
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_Ternary::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLFPTest_Ternary>();
}
void GrDSLFPTest_Ternary::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLFPTest_Ternary::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLFPTest_Ternary& that = other.cast<GrDSLFPTest_Ternary>();
(void) that;
return true;
}
GrDSLFPTest_Ternary::GrDSLFPTest_Ternary(const GrDSLFPTest_Ternary& src)
: INHERITED(kGrDSLFPTest_Ternary_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_Ternary::clone() const {
return std::make_unique<GrDSLFPTest_Ternary>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLFPTest_Ternary::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,36 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_Ternary.fp; do not modify.
**************************************************************************************************/
#ifndef GrDSLFPTest_Ternary_DEFINED
#define GrDSLFPTest_Ternary_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrDSLFPTest_Ternary : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make() {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_Ternary());
}
GrDSLFPTest_Ternary(const GrDSLFPTest_Ternary& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_Ternary"; }
private:
GrDSLFPTest_Ternary()
: INHERITED(kGrDSLFPTest_Ternary_ClassID, kNone_OptimizationFlags) {
}
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#if GR_TEST_UTILS
SkString onDumpInfo() const override;
#endif
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
using INHERITED = GrFragmentProcessor;
};
#endif

View File

@ -1,65 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_WhileStatement.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLFPTest_WhileStatement.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/dsl/priv/DSLFPs.h"
#include "src/sksl/dsl/priv/DSLWriter.h"
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcomma"
#endif
class GrGLSLDSLFPTest_WhileStatement : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLFPTest_WhileStatement() {}
void emitCode(EmitArgs& args) override {
const GrDSLFPTest_WhileStatement& _outer = args.fFp.cast<GrDSLFPTest_WhileStatement>();
(void) _outer;
using namespace SkSL::dsl;
StartFragmentProcessor(this, &args);
Var color(kNo_Modifier, DSLType(kHalf4_Type), "color", Half4(1.0));
Declare(color);
While(color.x() > 0.5, color.x() -= 0.25);
While(color.w() == 1.0, Block(color.x() -= 0.25, If(color.x() <= 0.0, /*Then:*/ Break())));
While(color.z() > 0.0, Block(color.z() -= 0.25, If(color.w() == 1.0, /*Then:*/ Continue()), color.y() = 0.0));
Return(color);
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_WhileStatement::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLFPTest_WhileStatement>();
}
void GrDSLFPTest_WhileStatement::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLFPTest_WhileStatement::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLFPTest_WhileStatement& that = other.cast<GrDSLFPTest_WhileStatement>();
(void) that;
return true;
}
GrDSLFPTest_WhileStatement::GrDSLFPTest_WhileStatement(const GrDSLFPTest_WhileStatement& src)
: INHERITED(kGrDSLFPTest_WhileStatement_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLFPTest_WhileStatement::clone() const {
return std::make_unique<GrDSLFPTest_WhileStatement>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLFPTest_WhileStatement::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,36 +0,0 @@
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_WhileStatement.fp; do not modify.
**************************************************************************************************/
#ifndef GrDSLFPTest_WhileStatement_DEFINED
#define GrDSLFPTest_WhileStatement_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrDSLFPTest_WhileStatement : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make() {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_WhileStatement());
}
GrDSLFPTest_WhileStatement(const GrDSLFPTest_WhileStatement& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_WhileStatement"; }
private:
GrDSLFPTest_WhileStatement()
: INHERITED(kGrDSLFPTest_WhileStatement_ClassID, kNone_OptimizationFlags) {
}
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
#if GR_TEST_UTILS
SkString onDumpInfo() const override;
#endif
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
using INHERITED = GrFragmentProcessor;
};
#endif

View File

@ -0,0 +1,53 @@
/* HELLO WORLD */
/**************************************************************************************************
*** This file was autogenerated from GrDSLHelloWorld.fp; do not modify.
**************************************************************************************************/
/* TODO(skia:11854): DSLCPPCodeGenerator is currently a work in progress. */
#include "GrDSLHelloWorld.h"
#include "src/core/SkUtils.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/sksl/SkSLCPP.h"
#include "src/sksl/SkSLUtil.h"
class GrGLSLDSLHelloWorld : public GrGLSLFragmentProcessor {
public:
GrGLSLDSLHelloWorld() {}
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrDSLHelloWorld& _outer = args.fFp.cast<GrDSLHelloWorld>();
(void) _outer;
fragBuilder->codeAppendf(
R"SkSL(return half4(1.0);
)SkSL"
);
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
}
};
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLHelloWorld::onMakeProgramImpl() const {
return std::make_unique<GrGLSLDSLHelloWorld>();
}
void GrDSLHelloWorld::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
}
bool GrDSLHelloWorld::onIsEqual(const GrFragmentProcessor& other) const {
const GrDSLHelloWorld& that = other.cast<GrDSLHelloWorld>();
(void) that;
return true;
}
GrDSLHelloWorld::GrDSLHelloWorld(const GrDSLHelloWorld& src)
: INHERITED(kGrDSLHelloWorld_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);
}
std::unique_ptr<GrFragmentProcessor> GrDSLHelloWorld::clone() const {
return std::make_unique<GrDSLHelloWorld>(*this);
}
#if GR_TEST_UTILS
SkString GrDSLHelloWorld::onDumpInfo() const {
return SkString();
}
#endif

View File

@ -1,10 +1,10 @@
/* HELLO WORLD */
/**************************************************************************************************
*** This file was autogenerated from GrDSLFPTest_Swizzle.fp; do not modify.
*** This file was autogenerated from GrDSLHelloWorld.fp; do not modify.
**************************************************************************************************/
#ifndef GrDSLFPTest_Swizzle_DEFINED
#define GrDSLFPTest_Swizzle_DEFINED
#ifndef GrDSLHelloWorld_DEFINED
#define GrDSLHelloWorld_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
@ -12,17 +12,17 @@
#include "src/gpu/GrFragmentProcessor.h"
class GrDSLFPTest_Swizzle : public GrFragmentProcessor {
class GrDSLHelloWorld : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make() {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_Swizzle());
return std::unique_ptr<GrFragmentProcessor>(new GrDSLHelloWorld());
}
GrDSLFPTest_Swizzle(const GrDSLFPTest_Swizzle& src);
GrDSLHelloWorld(const GrDSLHelloWorld& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_Swizzle"; }
const char* name() const override { return "DSLHelloWorld"; }
private:
GrDSLFPTest_Swizzle()
: INHERITED(kGrDSLFPTest_Swizzle_ClassID, kNone_OptimizationFlags) {
GrDSLHelloWorld()
: INHERITED(kGrDSLHelloWorld_ClassID, kNone_OptimizationFlags) {
}
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;