skia2/tests/sksl/fp/golden/GrNestedCall.h
John Stiles 8744a5c820 Add unit test for nested function calls in FP files.
`func1` and `func2` emit bad code, `return %s()`, and because they don't
consume their `%s` format argument. This leaves the format argument list
unbalanced and all future args are wrong.

Another serious problem is that we don't actually know the names of the
functions that they need to call, because we haven't emitted them yet.

`func3` is not emitted at all. Sampling from a fragment processor
apparently fails in this context.

This is a more general case repro for skia:10684--it turns out that
recursion in particular wasn't the issue, but nested function calls just
don't work properly at all in FP files. This wasn't an issue in practice
because we don't have any existing FP files which nest function calls,
and the inliner also tends to aggressively flatten everything out if we
don't explicitly disable it.

Change-Id: Iff029c459c7d90be566f9b4c9be0e3150e459866
Bug: skia:10684
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329367
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-23 21:07:36 +00:00

38 lines
1.5 KiB
C++

/*#pragma settings NoInline*/
/**************************************************************************************************
*** This file was autogenerated from GrNestedCall.fp; do not modify.
**************************************************************************************************/
#ifndef GrNestedCall_DEFINED
#define GrNestedCall_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkTypes.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrNestedCall : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp) {
return std::unique_ptr<GrFragmentProcessor>(new GrNestedCall(std::move(fp)));
}
GrNestedCall(const GrNestedCall& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "NestedCall"; }
bool usesExplicitReturn() const override;
private:
GrNestedCall(std::unique_ptr<GrFragmentProcessor> fp)
: INHERITED(kGrNestedCall_ClassID, kNone_OptimizationFlags) {
SkASSERT(fp); this->registerChild(std::move(fp), SkSL::SampleUsage::PassThrough()); }
GrGLSLFragmentProcessor* onCreateGLSLInstance() 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