skia2/src/sksl/SkSLContext.h
John Stiles c1a98b8736 Move shader caps into SkSL context.
Previously these existed in each Program, but they are unchanging for
the lifetime of the Compiler. Also, their presence in the Context will
allow the SkSL::Setting class to access them outside of the IRGenerator.

Also, removed some code which allowed the IRGenerator to support null
shader-caps; this never actually happens. (The Compiler asserts that
they are non-null; the GLSL code generator uses the caps bits without a
null check, etc.)

Change-Id: Id58743a0c2ac068cb60ec35648b4f758bf28bbe3
Bug: skia:11365, skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375067
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-24 20:00:54 +00:00

51 lines
1.3 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SKSL_CONTEXT
#define SKSL_CONTEXT
#include <memory>
#include "src/sksl/SkSLBuiltinTypes.h"
#include "src/sksl/SkSLErrorReporter.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/ir/SkSLExpression.h"
#include "src/sksl/ir/SkSLType.h"
namespace SkSL {
struct ProgramConfig;
/**
* Contains compiler-wide objects, which currently means the core types.
*/
class Context {
public:
Context(ErrorReporter& errors, const ShaderCapsClass& caps);
// The Context holds all of the built-in types.
BuiltinTypes fTypes;
// The Context holds a reference to our error reporter.
ErrorReporter& fErrors;
// The Context holds a reference to our shader caps bits.
const ShaderCapsClass& fCaps;
// The Context holds a pointer to the configuration of the program being compiled.
ProgramConfig* fConfig = nullptr;
// A sentinel expression used to mark that a variable has a value during dataflow analysis (when
// it could have several different values, or the analyzer is otherwise unable to assign it a
// specific expression)
const std::unique_ptr<Expression> fDefined_Expression;
};
} // namespace SkSL
#endif