skia2/tests/sksl/dslfp/GrDSLFPTest_Ternary.dsl.cpp
John Stiles 47b48bc2be Reland "Add support for uniforms and layout(key)s to DSLCPPCodeGenerator."
This reverts commit 289da86e37.

Reason for revert: relanding

Original change's description:
> Revert "Add support for uniforms and layout(key)s to DSLCPPCodeGenerator."
>
> This reverts commit f33b061e3b.
>
> Reason for revert: Google3 roll and wasm build
>
> Original change's description:
> > Add support for uniforms and layout(key)s to DSLCPPCodeGenerator.
> >
> > Change-Id: I77c386e3d72fb4a5986e5efb8bc9d409200534d1
> > Bug: skia:11854
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398457
> > Commit-Queue: John Stiles <johnstiles@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: I006ece639fa6051ff6ef1c496e648db9d5d0b30a
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11854
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399498
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>


Bug: skia:11854
Change-Id: I1a4a4db471e2ad0b169b2b77784ca17e6286fbd2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400036
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-22 20:04:32 +00:00

80 lines
3.4 KiB
C++

/**************************************************************************************************
*** 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 colorGreen(kUniform_Modifier, DSLType(kHalf4_Type), "colorGreen");
colorGreenVar = VarUniformHandle(colorGreen);
Var colorRed(kUniform_Modifier, DSLType(kHalf4_Type), "colorRed");
colorRedVar = VarUniformHandle(colorRed);
Var t(kNo_Modifier, DSLType(kBool_Type), "t", true);
Var f(kNo_Modifier, DSLType(kBool_Type), "f", false);
Declare(t);
Declare(f);
Return(Half4(Select(t, /*If True:*/ colorGreen.x(), /*If False:*/ colorRed.x()), Select(f, /*If True:*/ colorRed.y(), /*If False:*/ colorGreen.y()), Select(colorGreen.y() == colorRed.x(), /*If True:*/ colorGreen.z(), /*If False:*/ colorRed.x()), Select(colorGreen.w() != colorRed.w(), /*If True:*/ colorRed.y(), /*If False:*/ colorGreen.w())));
EndFragmentProcessor();
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
const GrDSLFPTest_Ternary& _outer = _proc.cast<GrDSLFPTest_Ternary>();
{
pdman.set4fv(colorGreenVar, 1, (_outer.colorGreen).vec());
pdman.set4fv(colorRedVar, 1, (_outer.colorRed).vec());
}
}
UniformHandle colorGreenVar;
UniformHandle colorRedVar;
};
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;
if (colorGreen != that.colorGreen) return false;
if (colorRed != that.colorRed) return false;
return true;
}
GrDSLFPTest_Ternary::GrDSLFPTest_Ternary(const GrDSLFPTest_Ternary& src)
: INHERITED(kGrDSLFPTest_Ternary_ClassID, src.optimizationFlags())
, colorGreen(src.colorGreen)
, colorRed(src.colorRed) {
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 SkStringPrintf("(colorGreen=half4(%f, %f, %f, %f), colorRed=half4(%f, %f, %f, %f))", colorGreen.fR, colorGreen.fG, colorGreen.fB, colorGreen.fA, colorRed.fR, colorRed.fG, colorRed.fB, colorRed.fA);
}
#endif