Added DSL sk_SampleCoord var
Change-Id: I539a288765243b2b9d994240c7917b036590f49d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370916 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
24ec76454a
commit
8d03eb0945
@ -22,6 +22,24 @@ namespace dsl {
|
||||
|
||||
DSLVar::DSLVar(const char* name)
|
||||
: fName(name) {
|
||||
#if SK_SUPPORT_GPU && !defined(SKSL_STANDALONE)
|
||||
if (!strcmp(name, "sk_SampleCoord")) {
|
||||
fName = DSLWriter::CurrentEmitArgs()->fSampleCoord;
|
||||
// The actual sk_SampleCoord variable hasn't been created by GrGLSLFPFragmentBuilder yet, so
|
||||
// if we attempt to look it up in the symbol table we'll get null. As we are currently
|
||||
// converting all DSL code into strings rather than nodes, all we really need is a
|
||||
// correctly-named variable with the right type, so we just create a placeholder for it.
|
||||
// TODO(skia/11330): we'll need to fix this when switching over to nodes.
|
||||
fVar = DSLWriter::SymbolTable()->takeOwnershipOfIRNode(std::make_unique<SkSL::Variable>(
|
||||
/*offset=*/-1,
|
||||
DSLWriter::IRGenerator().fModifiers->addToPool(SkSL::Modifiers()),
|
||||
fName,
|
||||
DSLWriter::Context().fTypes.fFloat2.get(),
|
||||
/*builtin=*/true,
|
||||
SkSL::VariableStorage::kGlobal));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
const SkSL::Symbol* result = (*DSLWriter::SymbolTable())[fName];
|
||||
SkASSERTF(result, "could not find '%s' in symbol table", fName);
|
||||
fVar = &result->as<SkSL::Variable>();
|
||||
|
@ -119,6 +119,8 @@ private:
|
||||
const SkSL::Variable* fVar = nullptr;
|
||||
const char* fName;
|
||||
|
||||
friend DSLVar sk_SampleCoord();
|
||||
|
||||
friend class DSLCore;
|
||||
friend class DSLExpression;
|
||||
friend class DSLWriter;
|
||||
|
@ -25,6 +25,10 @@ void EndFragmentProcessor() {
|
||||
DSLWriter::EndFragmentProcessor();
|
||||
}
|
||||
|
||||
DSLVar sk_SampleCoord() {
|
||||
return DSLVar("sk_SampleCoord");
|
||||
}
|
||||
|
||||
DSLExpression SampleChild(int index, DSLExpression coords) {
|
||||
std::unique_ptr<SkSL::Expression> coordsExpr = coords.release();
|
||||
SkString code = DSLWriter::CurrentProcessor()->invokeChild(index, *DSLWriter::CurrentEmitArgs(),
|
||||
|
@ -23,6 +23,8 @@ void StartFragmentProcessor(GrGLSLFragmentProcessor* processor,
|
||||
|
||||
void EndFragmentProcessor();
|
||||
|
||||
DSLVar sk_SampleCoord();
|
||||
|
||||
DSLExpression SampleChild(int index, DSLExpression coords = DSLExpression());
|
||||
|
||||
GrGLSLUniformHandler::UniformHandle VarUniformHandle(const DSLVar& var);
|
||||
|
Loading…
Reference in New Issue
Block a user