skia2/tests/sksl/dslfp/GrDSLFPTest_IfStatement.h
John Stiles c4e9588621 Improve DSL CPP support for global variables.
Global variables which can be calculated in C++ code are now written as
constant values in the DSL, instead of performing the same logic
redundantly in the shader.

In some cases this can be fairly significant, e.g. RectBlurEffect has
a global with the expression
    abs(rect.x) > 16000 || abs(rect.y) > 16000 ||
    abs(rect.z) > 16000 || abs(rect.w) > 16000

Change-Id: I84221f60a4986b3225afcf91ef95cdcfc941b4b7
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401437
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-27 21:59:41 +00:00

41 lines
1.5 KiB
C++

/**************************************************************************************************
*** 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(float one, float unused) {
return std::unique_ptr<GrFragmentProcessor>(new GrDSLFPTest_IfStatement(one, unused));
}
GrDSLFPTest_IfStatement(const GrDSLFPTest_IfStatement& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "DSLFPTest_IfStatement"; }
float one;
float unused;
private:
GrDSLFPTest_IfStatement(float one, float unused)
: INHERITED(kGrDSLFPTest_IfStatement_ClassID, kNone_OptimizationFlags)
, one(one)
, unused(unused) {
}
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