7c59ab868d
Change-Id: I06631e7f0db518f4de19a39bf1ed368afbd5d409 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/403076 Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
84 lines
4.0 KiB
C++
84 lines
4.0 KiB
C++
|
|
|
|
/**************************************************************************************************
|
|
*** 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"
|
|
|
|
class GrGLSLDSLFPTest_IfStatement : public GrGLSLFragmentProcessor {
|
|
public:
|
|
GrGLSLDSLFPTest_IfStatement() {}
|
|
void emitCode(EmitArgs& args) override {
|
|
[[maybe_unused]] const GrDSLFPTest_IfStatement& _outer = args.fFp.cast<GrDSLFPTest_IfStatement>();
|
|
|
|
using namespace SkSL::dsl;
|
|
StartFragmentProcessor(this, &args);
|
|
[[maybe_unused]] const auto& one = _outer.one;
|
|
Var _one(kConst_Modifier, DSLType(kHalf_Type), "one", Half(one));
|
|
Declare(_one);
|
|
[[maybe_unused]] const auto& unused = _outer.unused;
|
|
Var _unused(kConst_Modifier, DSLType(kHalf_Type), "unused", Half(unused));
|
|
Declare(_unused);
|
|
alsoUnused = float(one + one);
|
|
Var _alsoUnused(kConst_Modifier, DSLType(kFloat_Type), "alsoUnused", Float(alsoUnused));
|
|
Declare(_alsoUnused);
|
|
Var _color(kNo_Modifier, DSLType(kHalf4_Type), "color", Half4(0.0f));
|
|
Declare(_color);
|
|
If(Swizzle(_color, X, Y) == Swizzle(_color, Z, W), /*Then:*/ _color.w() = _one);
|
|
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() == _one, /*Then:*/ Block(_color = Half4(-1.0f)), /*Else:*/ If(((_color.x() + _color.y()) + _color.z()) + _color.w() == 2.0f, /*Then:*/ Block(_color = Half4(-2.0f)), /*Else:*/ Block(_color = Swizzle(_color, Y, Y, W, W))));
|
|
If(_color.x() == _one, /*Then:*/ Block(If(_color.x() == 2.0f, /*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() == _one, /*Then:*/ Block(_color = Swizzle(_color, X, Z, Y, W)), /*Else:*/ Block(_color = Swizzle(_color, W, W, W, W)))));
|
|
StaticIf(_one != 1.0f, /*Then:*/ Block(_color.x() = 1.0f));
|
|
Return(_color);
|
|
EndFragmentProcessor();
|
|
}
|
|
private:
|
|
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
|
|
}
|
|
float alsoUnused = 0;
|
|
};
|
|
std::unique_ptr<GrGLSLFragmentProcessor> GrDSLFPTest_IfStatement::onMakeProgramImpl() const {
|
|
return std::make_unique<GrGLSLDSLFPTest_IfStatement>();
|
|
}
|
|
void GrDSLFPTest_IfStatement::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
|
|
b->add32(sk_bit_cast<uint32_t>(one), "one");
|
|
if (one != 1.0f) {
|
|
b->add32(sk_bit_cast<uint32_t>(unused), "unused");
|
|
}
|
|
float alsoUnused = float(one + one);
|
|
b->add32(sk_bit_cast<uint32_t>(alsoUnused), "alsoUnused");
|
|
}
|
|
bool GrDSLFPTest_IfStatement::onIsEqual(const GrFragmentProcessor& other) const {
|
|
const GrDSLFPTest_IfStatement& that = other.cast<GrDSLFPTest_IfStatement>();
|
|
(void) that;
|
|
if (one != that.one) return false;
|
|
if (unused != that.unused) return false;
|
|
return true;
|
|
}
|
|
GrDSLFPTest_IfStatement::GrDSLFPTest_IfStatement(const GrDSLFPTest_IfStatement& src)
|
|
: INHERITED(kGrDSLFPTest_IfStatement_ClassID, src.optimizationFlags())
|
|
, one(src.one)
|
|
, unused(src.unused) {
|
|
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 SkStringPrintf("(one=%f, unused=%f)", one, unused);
|
|
}
|
|
#endif
|