add Start/EndFragmentProcessor to DSLWriter
Change-Id: I6f9d414d55b3ba64c3f67f3a590f6b7b5642062a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/364599 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
dd520a3f7d
commit
c3bb9e3bbd
@ -74,6 +74,8 @@ skia_sksl_sources = [
|
||||
"$_src/sksl/dsl/DSLType.h",
|
||||
"$_src/sksl/dsl/DSLVar.cpp",
|
||||
"$_src/sksl/dsl/DSLVar.h",
|
||||
"$_src/sksl/dsl/priv/DSLFPs.cpp",
|
||||
"$_src/sksl/dsl/priv/DSLFPs.h",
|
||||
"$_src/sksl/dsl/priv/DSLWriter.cpp",
|
||||
"$_src/sksl/dsl/priv/DSLWriter.h",
|
||||
"$_src/sksl/ir/SkSLBinaryExpression.h",
|
||||
|
31
src/sksl/dsl/priv/DSLFPs.cpp
Normal file
31
src/sksl/dsl/priv/DSLFPs.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/sksl/dsl/priv/DSLFPs.h"
|
||||
|
||||
#include "src/sksl/dsl/priv/DSLWriter.h"
|
||||
|
||||
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
namespace dsl {
|
||||
|
||||
void StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
|
||||
GrGLSLFragmentProcessor::EmitArgs* emitArgs) {
|
||||
DSLWriter::StartFragmentProcessor(processor, emitArgs);
|
||||
}
|
||||
|
||||
void EndFragmentProcessor() {
|
||||
DSLWriter::EndFragmentProcessor();
|
||||
}
|
||||
|
||||
} // namespace dsl
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
32
src/sksl/dsl/priv/DSLFPs.h
Normal file
32
src/sksl/dsl/priv/DSLFPs.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SKSL_DSL_FPS
|
||||
#define SKSL_DSL_FPS
|
||||
|
||||
#include "src/sksl/dsl/DSL.h"
|
||||
|
||||
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
namespace dsl {
|
||||
|
||||
void StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
|
||||
GrGLSLFragmentProcessor::EmitArgs* emitArgs);
|
||||
|
||||
void EndFragmentProcessor();
|
||||
|
||||
} // namespace dsl
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
|
||||
#endif
|
@ -11,6 +11,7 @@
|
||||
#include "src/gpu/mock/GrMockCaps.h"
|
||||
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
#include "src/sksl/SkSLCompiler.h"
|
||||
#include "src/sksl/SkSLDefines.h"
|
||||
#include "src/sksl/SkSLIRGenerator.h"
|
||||
#include "src/sksl/dsl/DSLCore.h"
|
||||
|
||||
@ -65,6 +66,21 @@ void DSLWriter::SetCurrentFunction(const SkSL::FunctionDeclaration* fn) {
|
||||
IRGenerator().fCurrentFunction = fn;
|
||||
}
|
||||
|
||||
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
void DSLWriter::StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
|
||||
GrGLSLFragmentProcessor::EmitArgs* emitArgs) {
|
||||
Instance().fStack.push({processor, emitArgs});
|
||||
IRGenerator().pushSymbolTable();
|
||||
}
|
||||
|
||||
void DSLWriter::EndFragmentProcessor() {
|
||||
DSLWriter& instance = Instance();
|
||||
SkASSERT(!instance.fStack.empty());
|
||||
instance.fStack.pop();
|
||||
IRGenerator().popSymbolTable();
|
||||
}
|
||||
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
|
||||
std::unique_ptr<SkSL::Expression> DSLWriter::Check(std::unique_ptr<SkSL::Expression> expr) {
|
||||
if (expr == nullptr) {
|
||||
if (DSLWriter::Compiler().errorCount()) {
|
||||
|
@ -97,6 +97,36 @@ public:
|
||||
*/
|
||||
static void SetCurrentFunction(const SkSL::FunctionDeclaration* fn);
|
||||
|
||||
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
/**
|
||||
* Returns the fragment processor for which DSL output is being generated for the current
|
||||
* thread.
|
||||
*/
|
||||
static GrGLSLFragmentProcessor* CurrentProcessor() {
|
||||
SkASSERTF(!Instance().fStack.empty(), "This feature requires a FragmentProcessor");
|
||||
return Instance().fStack.top().fProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the EmitArgs for fragment processor output in the current thread.
|
||||
*/
|
||||
static GrGLSLFragmentProcessor::EmitArgs* CurrentEmitArgs() {
|
||||
SkASSERTF(!Instance().fStack.empty(), "This feature requires a FragmentProcessor");
|
||||
return Instance().fStack.top().fEmitArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes a new processor / emitArgs pair for the current thread.
|
||||
*/
|
||||
static void StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
|
||||
GrGLSLFragmentProcessor::EmitArgs* emitArgs);
|
||||
|
||||
/**
|
||||
* Pops the processor / emitArgs pair associated with the current thread.
|
||||
*/
|
||||
static void EndFragmentProcessor();
|
||||
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
|
||||
/**
|
||||
* Reports an error if the argument is null. Returns its argument unmodified.
|
||||
*/
|
||||
@ -149,6 +179,13 @@ private:
|
||||
ErrorHandler* fErrorHandler = nullptr;
|
||||
bool fMangle = true;
|
||||
Mangler fMangler;
|
||||
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
struct StackFrame {
|
||||
GrGLSLFragmentProcessor* fProcessor;
|
||||
GrGLSLFragmentProcessor::EmitArgs* fEmitArgs;
|
||||
};
|
||||
std::stack<StackFrame> fStack;
|
||||
#endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
|
||||
|
||||
friend class DSLCore;
|
||||
friend class ::AutoDSLContext;
|
||||
|
Loading…
Reference in New Issue
Block a user