16cbfb41df
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>
66 lines
2.6 KiB
C++
66 lines
2.6 KiB
C++
|
|
|
|
/**************************************************************************************************
|
|
*** 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
|