Remove large swaths of code related to .fp files
Change-Id: Id2061ebe7873aa8b9480a2d8b0133c2fb79e79bb Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424098 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
ed5181e7bf
commit
8c26479048
17
BUILD.gn
17
BUILD.gn
@ -661,20 +661,6 @@ if (skia_compile_sksl_tests) {
|
||||
skslc_path += ".exe"
|
||||
}
|
||||
|
||||
action("create_sksl_fp") {
|
||||
script = "gn/create_sksl_fp.py"
|
||||
sources = [
|
||||
"include/private/GrSharedEnums.h",
|
||||
"src/sksl/sksl_fp_raw.sksl",
|
||||
]
|
||||
outputs = [ "$root_out_dir/sksl_fp.sksl" ]
|
||||
args = [
|
||||
rebase_path(sources[0]),
|
||||
rebase_path(sources[1]),
|
||||
rebase_path(outputs[0]),
|
||||
]
|
||||
}
|
||||
|
||||
copy("sksl_pre_includes") {
|
||||
sources = [
|
||||
"src/sksl/sksl_frag.sksl",
|
||||
@ -690,7 +676,6 @@ if (skia_compile_sksl_tests) {
|
||||
}
|
||||
|
||||
dehydrate_sksl_sources = get_target_outputs(":sksl_pre_includes")
|
||||
dehydrate_sksl_sources += get_target_outputs(":create_sksl_fp")
|
||||
|
||||
dehydrate_sksl_outputs = []
|
||||
foreach(src, dehydrate_sksl_sources) {
|
||||
@ -706,7 +691,6 @@ if (skia_compile_sksl_tests) {
|
||||
action("dehydrate_sksl") {
|
||||
script = "gn/dehydrate_sksl.py"
|
||||
deps = [
|
||||
":create_sksl_fp",
|
||||
":sksl_pre_includes",
|
||||
":skslc(//gn/toolchain:$host_toolchain)",
|
||||
]
|
||||
@ -731,7 +715,6 @@ if (skia_compile_sksl_tests) {
|
||||
action("compile_sksl_${target_name}") {
|
||||
script = "gn/compile_sksl_tests.py"
|
||||
deps = [
|
||||
":create_sksl_fp",
|
||||
":sksl_pre_includes",
|
||||
":skslc(//gn/toolchain:$host_toolchain)",
|
||||
]
|
||||
|
@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import sys
|
||||
|
||||
def copy(src, dst):
|
||||
for line in src.readlines():
|
||||
if not line.startswith("#"):
|
||||
dst.write(line)
|
||||
src.close()
|
||||
|
||||
dst = open(sys.argv[3], 'wb')
|
||||
dst.write("// *********************************************************\n")
|
||||
dst.write("// *** AUTOGENERATED BY create_sksl_fp.py, DO NOT EDIT ***\n")
|
||||
dst.write("// *********************************************************\n\n\n")
|
||||
copy(open(sys.argv[1], 'r'), dst)
|
||||
copy(open(sys.argv[2], 'r'), dst)
|
||||
dst.close()
|
11
gn/sksl.gni
11
gn/sksl.gni
@ -71,8 +71,6 @@ skia_sksl_sources = [
|
||||
"$_src/sksl/SkSLRehydrator.cpp",
|
||||
"$_src/sksl/SkSLRehydrator.h",
|
||||
"$_src/sksl/SkSLSampleUsage.cpp",
|
||||
"$_src/sksl/SkSLSectionAndParameterHelper.cpp",
|
||||
"$_src/sksl/SkSLSectionAndParameterHelper.h",
|
||||
"$_src/sksl/SkSLString.cpp",
|
||||
"$_src/sksl/SkSLStringStream.h",
|
||||
"$_src/sksl/SkSLUtil.cpp",
|
||||
@ -158,7 +156,6 @@ skia_sksl_sources = [
|
||||
"$_src/sksl/ir/SkSLPrefixExpression.h",
|
||||
"$_src/sksl/ir/SkSLProgram.h",
|
||||
"$_src/sksl/ir/SkSLReturnStatement.h",
|
||||
"$_src/sksl/ir/SkSLSection.h",
|
||||
"$_src/sksl/ir/SkSLSetting.cpp",
|
||||
"$_src/sksl/ir/SkSLSetting.h",
|
||||
"$_src/sksl/ir/SkSLStructDefinition.h",
|
||||
@ -186,17 +183,9 @@ skia_sksl_sources = [
|
||||
]
|
||||
|
||||
skia_sksl_gpu_sources = [
|
||||
"$_src/sksl/SkSLCPPUniformCTypes.cpp",
|
||||
"$_src/sksl/SkSLCPPUniformCTypes.h",
|
||||
"$_src/sksl/codegen/SkSLCPPCodeGenerator.cpp",
|
||||
"$_src/sksl/codegen/SkSLCPPCodeGenerator.h",
|
||||
"$_src/sksl/codegen/SkSLCodeGenerator.h",
|
||||
"$_src/sksl/codegen/SkSLDSLCPPCodeGenerator.cpp",
|
||||
"$_src/sksl/codegen/SkSLDSLCPPCodeGenerator.h",
|
||||
"$_src/sksl/codegen/SkSLGLSLCodeGenerator.cpp",
|
||||
"$_src/sksl/codegen/SkSLGLSLCodeGenerator.h",
|
||||
"$_src/sksl/codegen/SkSLHCodeGenerator.cpp",
|
||||
"$_src/sksl/codegen/SkSLHCodeGenerator.h",
|
||||
"$_src/sksl/codegen/SkSLMetalCodeGenerator.cpp",
|
||||
"$_src/sksl/codegen/SkSLMetalCodeGenerator.h",
|
||||
"$_src/sksl/codegen/SkSLPipelineStageCodeGenerator.cpp",
|
||||
|
@ -258,7 +258,6 @@ tests_sources = [
|
||||
"$_tests/SkSLDSLErrorLineNumbers.cpp",
|
||||
"$_tests/SkSLDSLOnlyTest.cpp",
|
||||
"$_tests/SkSLDSLTest.cpp",
|
||||
"$_tests/SkSLFPTestbed.cpp",
|
||||
"$_tests/SkSLGLSLTestbed.cpp",
|
||||
"$_tests/SkSLInterpreterTest.cpp",
|
||||
"$_tests/SkSLMemoryLayoutTest.cpp",
|
||||
|
@ -23,21 +23,18 @@ struct Layout {
|
||||
kPushConstant_Flag = 1 << 1,
|
||||
kBlendSupportAllEquations_Flag = 1 << 2,
|
||||
kSRGBUnpremul_Flag = 1 << 3,
|
||||
kKey_Flag = 1 << 4,
|
||||
|
||||
// These flags indicate if the qualifier appeared, regardless of the accompanying value.
|
||||
kLocation_Flag = 1 << 5,
|
||||
kOffset_Flag = 1 << 6,
|
||||
kBinding_Flag = 1 << 7,
|
||||
kIndex_Flag = 1 << 8,
|
||||
kSet_Flag = 1 << 9,
|
||||
kBuiltin_Flag = 1 << 10,
|
||||
kInputAttachmentIndex_Flag = 1 << 11,
|
||||
kPrimitive_Flag = 1 << 12,
|
||||
kMaxVertices_Flag = 1 << 13,
|
||||
kInvocations_Flag = 1 << 14,
|
||||
kWhen_Flag = 1 << 15,
|
||||
kCType_Flag = 1 << 16,
|
||||
kLocation_Flag = 1 << 4,
|
||||
kOffset_Flag = 1 << 5,
|
||||
kBinding_Flag = 1 << 6,
|
||||
kIndex_Flag = 1 << 7,
|
||||
kSet_Flag = 1 << 8,
|
||||
kBuiltin_Flag = 1 << 9,
|
||||
kInputAttachmentIndex_Flag = 1 << 10,
|
||||
kPrimitive_Flag = 1 << 11,
|
||||
kMaxVertices_Flag = 1 << 12,
|
||||
kInvocations_Flag = 1 << 13,
|
||||
};
|
||||
|
||||
enum Primitive {
|
||||
@ -51,56 +48,8 @@ struct Layout {
|
||||
kTrianglesAdjacency_Primitive
|
||||
};
|
||||
|
||||
enum class CType {
|
||||
kDefault, // Default for:
|
||||
kFloat, // float, half
|
||||
kInt32, // int, short
|
||||
kSkRect, // float4, half4
|
||||
kSkIRect, // int4, short4
|
||||
kSkPMColor4f,
|
||||
kSkV4,
|
||||
kSkPoint, // float2, half2
|
||||
kSkIPoint, // int2, short2
|
||||
kSkMatrix, // float3x3, half3x3
|
||||
kSkM44, // float4x4, half4x4
|
||||
kGrFragmentProcessor, // fragmentProcessor
|
||||
};
|
||||
|
||||
static const char* CTypeToStr(CType ctype) {
|
||||
switch (ctype) {
|
||||
case CType::kDefault:
|
||||
return nullptr;
|
||||
case CType::kFloat:
|
||||
return "float";
|
||||
case CType::kInt32:
|
||||
return "int32_t";
|
||||
case CType::kSkRect:
|
||||
return "SkRect";
|
||||
case CType::kSkIRect:
|
||||
return "SkIRect";
|
||||
case CType::kSkPMColor4f:
|
||||
return "SkPMColor4f";
|
||||
case CType::kSkV4:
|
||||
return "SkV4";
|
||||
case CType::kSkPoint:
|
||||
return "SkPoint";
|
||||
case CType::kSkIPoint:
|
||||
return "SkIPoint";
|
||||
case CType::kSkMatrix:
|
||||
return "SkMatrix";
|
||||
case CType::kSkM44:
|
||||
return "SkM44";
|
||||
case CType::kGrFragmentProcessor:
|
||||
return "std::unique_ptr<GrFragmentProcessor>";
|
||||
default:
|
||||
SkASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Layout(int flags, int location, int offset, int binding, int index, int set, int builtin,
|
||||
int inputAttachmentIndex, Primitive primitive, int maxVertices, int invocations,
|
||||
skstd::string_view when, CType ctype)
|
||||
int inputAttachmentIndex, Primitive primitive, int maxVertices, int invocations)
|
||||
: fFlags(flags)
|
||||
, fLocation(location)
|
||||
, fOffset(offset)
|
||||
@ -111,9 +60,7 @@ struct Layout {
|
||||
, fInputAttachmentIndex(inputAttachmentIndex)
|
||||
, fPrimitive(primitive)
|
||||
, fMaxVertices(maxVertices)
|
||||
, fInvocations(invocations)
|
||||
, fWhen(when)
|
||||
, fCType(ctype) {}
|
||||
, fInvocations(invocations) {}
|
||||
|
||||
Layout()
|
||||
: fFlags(0)
|
||||
@ -126,8 +73,7 @@ struct Layout {
|
||||
, fInputAttachmentIndex(-1)
|
||||
, fPrimitive(kUnspecified_Primitive)
|
||||
, fMaxVertices(-1)
|
||||
, fInvocations(-1)
|
||||
, fCType(CType::kDefault) {}
|
||||
, fInvocations(-1) {}
|
||||
|
||||
static Layout builtin(int builtin) {
|
||||
Layout result;
|
||||
@ -208,15 +154,9 @@ struct Layout {
|
||||
if (fInvocations >= 0) {
|
||||
result += separator() + "invocations = " + to_string(fInvocations);
|
||||
}
|
||||
if (fWhen.length()) {
|
||||
result += separator() + "when = " + fWhen;
|
||||
}
|
||||
if (result.size() > 0) {
|
||||
result = "layout (" + result + ")";
|
||||
}
|
||||
if (fFlags & kKey_Flag) {
|
||||
result += "/* key */ const";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -231,9 +171,7 @@ struct Layout {
|
||||
fInputAttachmentIndex == other.fInputAttachmentIndex &&
|
||||
fPrimitive == other.fPrimitive &&
|
||||
fMaxVertices == other.fMaxVertices &&
|
||||
fInvocations == other.fInvocations &&
|
||||
fWhen == other.fWhen &&
|
||||
fCType == other.fCType;
|
||||
fInvocations == other.fInvocations;
|
||||
}
|
||||
|
||||
bool operator!=(const Layout& other) const {
|
||||
@ -255,8 +193,6 @@ struct Layout {
|
||||
Primitive fPrimitive;
|
||||
int fMaxVertices;
|
||||
int fInvocations;
|
||||
skstd::string_view fWhen;
|
||||
CType fCType;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
|
@ -27,7 +27,6 @@ public:
|
||||
kGlobalVar,
|
||||
kInterfaceBlock,
|
||||
kModifiers,
|
||||
kSection,
|
||||
kStructDefinition,
|
||||
|
||||
kFirst = kEnum,
|
||||
|
@ -19,7 +19,6 @@ enum class ProgramKind : int8_t {
|
||||
kFragment,
|
||||
kVertex,
|
||||
kGeometry,
|
||||
kFragmentProcessor,
|
||||
kRuntimeColorFilter, // Runtime effect only suitable as SkColorFilter
|
||||
kRuntimeShader, // " " " " " SkShader
|
||||
kRuntimeBlender, // " " " " " SkBlender
|
||||
|
@ -3,7 +3,6 @@ layout (
|
||||
push_constant,
|
||||
blend_support_all_equations,
|
||||
srgb_unpremul,
|
||||
key,
|
||||
location = 1,
|
||||
offset = 1,
|
||||
binding = 1,
|
||||
@ -12,9 +11,7 @@ layout (
|
||||
builtin = 1,
|
||||
input_attachment_index = 1,
|
||||
max_vertices = 1,
|
||||
invocations = 1,
|
||||
when = one,
|
||||
ctype = SkPMColor4f)
|
||||
invocations = 1)
|
||||
void on_return() {}
|
||||
|
||||
void on_param(
|
||||
@ -23,7 +20,6 @@ layout (
|
||||
push_constant,
|
||||
blend_support_all_equations,
|
||||
srgb_unpremul,
|
||||
key,
|
||||
location = 1,
|
||||
offset = 1,
|
||||
binding = 1,
|
||||
@ -32,6 +28,4 @@ layout (
|
||||
builtin = 1,
|
||||
input_attachment_index = 1,
|
||||
max_vertices = 1,
|
||||
invocations = 1,
|
||||
when = one,
|
||||
ctype = SkPMColor4f) float x) {}
|
||||
invocations = 1) float x) {}
|
||||
|
@ -3,7 +3,6 @@ layout (
|
||||
push_constant,
|
||||
blend_support_all_equations,
|
||||
srgb_unpremul,
|
||||
key,
|
||||
location = 1,
|
||||
offset = 1,
|
||||
binding = 1,
|
||||
@ -13,14 +12,11 @@ layout (
|
||||
input_attachment_index = 1,
|
||||
max_vertices = 1,
|
||||
invocations = 1,
|
||||
when = one,
|
||||
ctype = SkPMColor4f,
|
||||
|
||||
origin_upper_left,
|
||||
push_constant,
|
||||
blend_support_all_equations,
|
||||
srgb_unpremul,
|
||||
key,
|
||||
location = 2,
|
||||
offset = 2,
|
||||
binding = 2,
|
||||
@ -29,7 +25,5 @@ layout (
|
||||
builtin = 2,
|
||||
input_attachment_index = 2,
|
||||
max_vertices = 2,
|
||||
invocations = 2,
|
||||
when = two,
|
||||
ctype = SkV4
|
||||
invocations = 2
|
||||
) float x;
|
||||
|
@ -1,5 +1,5 @@
|
||||
enum class E {
|
||||
hello,
|
||||
world,
|
||||
fragmentProcessor
|
||||
float
|
||||
};
|
||||
|
@ -66,102 +66,3 @@ Differences from GLSL
|
||||
its normal inlining heuristics and inline the function if at all possible
|
||||
* some built-in functions and one or two rarely-used language features are not
|
||||
yet supported (sorry!)
|
||||
|
||||
|
||||
SkSL Fragment Processors
|
||||
========================
|
||||
|
||||
********************************************************************************
|
||||
*** IMPORTANT: You must set gn arg "skia_compile_processors = true" to cause ***
|
||||
*** .fp files to be recompiled! In order for compilation to succeed, you ***
|
||||
*** must run bin/fetch-clang-format (once) to install our blessed version. ***
|
||||
********************************************************************************
|
||||
|
||||
An extension of SkSL allows for the creation of fragment processors in pure
|
||||
SkSL. The program defines its inputs similarly to a normal SkSL program (with
|
||||
'in' and 'uniform' variables), but the 'main()' function represents only this
|
||||
fragment processor's portion of the overall fragment shader. The 'main' function
|
||||
can optionally have a 'float2' parameter that holds the sample coordinates the
|
||||
processor is evaluated at.
|
||||
|
||||
Processors do not need to declare this parameter if they do not rely on local
|
||||
coordinates or only invoke child processors using the no-arg and matrix-based
|
||||
sample() functions.
|
||||
|
||||
Within an '.fp' fragment processor file:
|
||||
|
||||
* C++ code can be embedded in sections of the form:
|
||||
|
||||
@section_name { <arbitrary C++ code> }
|
||||
|
||||
Supported section are:
|
||||
@header (in the .h file, outside the class declaration)
|
||||
@headerEnd (at the end of the .h file)
|
||||
@class (in the .h file, inside the class declaration)
|
||||
@cpp (in the .cpp file)
|
||||
@cppEnd (at the end of the .cpp file)
|
||||
@constructorParams (extra parameters to the constructor, comma-separated)
|
||||
@constructor (replaces the default constructor)
|
||||
@initializers (constructor initializer list, comma-separated)
|
||||
@emitCode (extra code for the emitCode function)
|
||||
@fields (extra private fields, each terminated with a semicolon)
|
||||
@make (replaces the default Make function)
|
||||
@clone (replaces the default clone() function)
|
||||
@dumpInfo (replaces the default dumpInfo() function)
|
||||
@setData(<pdman>) (extra code for the setData function, where <pdman> is
|
||||
the name of the GrGLSLProgramDataManager)
|
||||
@test(<testData>) (the body of the TestCreate function, where <testData> is
|
||||
the name of the GrProcessorTestData* parameter)
|
||||
* global 'in' variables represent data passed to the fragment processor at
|
||||
construction time. These variables become constructor parameters and are
|
||||
stored in fragment processor fields. By default float2/half2 maps to SkPoints,
|
||||
and float4/half4 maps to SkRects (in x, y, width, height) order. Similarly,
|
||||
int2/short2 maps to SkIPoint and int4/half4 maps to SkIRect. Use ctype
|
||||
(below) to override this default mapping.
|
||||
* global variables support an additional 'ctype' layout key, providing the type
|
||||
they should be represented as from within the C++ code. For instance, you can
|
||||
use 'layout(ctype=SkPMColor4f) in half4 color;' to create a variable that looks
|
||||
like a half4 on the SkSL side of things, and a SkPMColor4f on the C++ side of
|
||||
things.
|
||||
* 'uniform' variables become, as one would expect, top-level uniforms. By
|
||||
default they do not have any data provided to them; you will need to provide
|
||||
them with data via the @setData section.
|
||||
* 'in uniform' variables are uniforms that are automatically wired up to
|
||||
fragment processor constructor parameters. The fragment processor will accept
|
||||
a parameter representing the uniform's value, and automatically plumb it
|
||||
through to the uniform's value in its generated setData() function.
|
||||
* 'in uniform' variables support a 'tracked' flag in the layout that will
|
||||
have the generated code automatically implement state tracking on the uniform
|
||||
value to minimize GPU calls.
|
||||
* Uniform variables support an additional 'when' layout key.
|
||||
'layout(when=foo) uniform int x;' means that this uniform will only be
|
||||
emitted when the 'foo' expression is true.
|
||||
* 'in' variables support an additional 'key' layout key.
|
||||
'layout(key) in uniform int x;' means that this uniform should be included in
|
||||
the program's key. Matrix variables additionally support 'key=identity',
|
||||
which causes the key to consider only whether or not the matrix is an
|
||||
identity matrix.
|
||||
* child processors can be declared with 'in fragmentProcessor <name>;', and can
|
||||
be invoked by calling 'sample(<name>)' or 'sample(<name>, <inputColor>)'.
|
||||
The first variant emits the child with a solid white input color. The second
|
||||
variant emits the child with the result of the 2nd argument's expression,
|
||||
which must evaluate to a half4. The process function returns a half4.
|
||||
Invoking 'sample()' on a null fragment processor will return the inputColor
|
||||
unchanged (this defaults to solid white if not explicitly specified).
|
||||
|
||||
|
||||
Creating a new .fp file
|
||||
=======================
|
||||
|
||||
1. Ensure that you have set gn arg "skia_compile_processors = true"
|
||||
2. Create your new .fp file, generally under src/gpu/effects.
|
||||
3. Add the .fp file to sksl.gni.
|
||||
4. Build Skia. This will cause the .fp file to be compiled, resulting in a new
|
||||
.cpp and .h file for the fragment processor.
|
||||
5. Add the .cpp and .h files to gpu.gni.
|
||||
6. Add the new processor's ClassID (k<ProcessorName>_ClassID) to
|
||||
GrProcessor::ClassID.
|
||||
7. At this point you can reference the new fragment processor from within Skia.
|
||||
|
||||
Once you have done this initial setup, simply re-build Skia to pick up any
|
||||
changes to the .fp file.
|
||||
|
@ -172,8 +172,6 @@ String ASTNode::description() const {
|
||||
return "return;";
|
||||
case Kind::kScope:
|
||||
return this->begin()->description() + "::" + getStringView();
|
||||
case Kind::kSection:
|
||||
return "@section { ... }";
|
||||
case Kind::kSwitchCase: {
|
||||
auto iter = this->begin();
|
||||
String result;
|
||||
|
@ -106,8 +106,6 @@ struct ASTNode {
|
||||
kReturn,
|
||||
// data: field(string_view), children: base
|
||||
kScope,
|
||||
// ...
|
||||
kSection,
|
||||
// children: value, statement 1, statement 2...
|
||||
kSwitchCase,
|
||||
// children: value, case 1, case 2...
|
||||
@ -237,19 +235,6 @@ struct ASTNode {
|
||||
bool fIsArray;
|
||||
};
|
||||
|
||||
struct SectionData {
|
||||
SectionData() {}
|
||||
|
||||
SectionData(skstd::string_view name, skstd::string_view argument, skstd::string_view text)
|
||||
: fName(name)
|
||||
, fArgument(argument)
|
||||
, fText(text) {}
|
||||
|
||||
skstd::string_view fName;
|
||||
skstd::string_view fArgument;
|
||||
skstd::string_view fText;
|
||||
};
|
||||
|
||||
struct NodeData {
|
||||
// We use fBytes as a union which can hold any type of AST node, and use placement-new to
|
||||
// copy AST objects into fBytes. Note that none of the AST objects have interesting
|
||||
@ -263,8 +248,7 @@ struct ASTNode {
|
||||
sizeof(FunctionData),
|
||||
sizeof(ParameterData),
|
||||
sizeof(VarData),
|
||||
sizeof(InterfaceBlockData),
|
||||
sizeof(SectionData)})];
|
||||
sizeof(InterfaceBlockData)})];
|
||||
|
||||
enum class Kind {
|
||||
kOperator,
|
||||
@ -277,7 +261,6 @@ struct ASTNode {
|
||||
kParameterData,
|
||||
kVarData,
|
||||
kInterfaceBlockData,
|
||||
kSectionData
|
||||
} fKind;
|
||||
|
||||
NodeData() = default;
|
||||
@ -331,11 +314,6 @@ struct ASTNode {
|
||||
: fKind(Kind::kInterfaceBlockData) {
|
||||
new (fBytes) InterfaceBlockData(data);
|
||||
}
|
||||
|
||||
NodeData(const SectionData& data)
|
||||
: fKind(Kind::kSectionData) {
|
||||
new (fBytes) SectionData(data);
|
||||
}
|
||||
};
|
||||
|
||||
ASTNode()
|
||||
@ -445,12 +423,6 @@ struct ASTNode {
|
||||
, fOffset(offset)
|
||||
, fKind(kind) {}
|
||||
|
||||
ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind, SectionData s)
|
||||
: fNodes(nodes)
|
||||
, fData(s)
|
||||
, fOffset(offset)
|
||||
, fKind(kind) {}
|
||||
|
||||
operator bool() const {
|
||||
return fKind != Kind::kNull;
|
||||
}
|
||||
@ -525,11 +497,6 @@ struct ASTNode {
|
||||
new (fData.fBytes) InterfaceBlockData(id);
|
||||
}
|
||||
|
||||
const SectionData& getSectionData() const {
|
||||
SkASSERT(fData.fKind == NodeData::Kind::kSectionData);
|
||||
return *reinterpret_cast<const SectionData*>(fData.fBytes);
|
||||
}
|
||||
|
||||
void addChild(ID id) {
|
||||
SkASSERT(!(*fNodes)[id.fValue].fNext);
|
||||
if (fLastChild) {
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "src/sksl/ir/SkSLExtension.h"
|
||||
#include "src/sksl/ir/SkSLFunctionDefinition.h"
|
||||
#include "src/sksl/ir/SkSLInterfaceBlock.h"
|
||||
#include "src/sksl/ir/SkSLSection.h"
|
||||
#include "src/sksl/ir/SkSLVarDeclarations.h"
|
||||
|
||||
// Statements
|
||||
@ -1331,7 +1330,6 @@ template <typename T> bool TProgramVisitor<T>::visitProgramElement(typename T::P
|
||||
case ProgramElement::Kind::kFunctionPrototype:
|
||||
case ProgramElement::Kind::kInterfaceBlock:
|
||||
case ProgramElement::Kind::kModifiers:
|
||||
case ProgramElement::Kind::kSection:
|
||||
case ProgramElement::Kind::kStructDefinition:
|
||||
// Leaf program elements just return false by default
|
||||
return false;
|
||||
|
@ -178,8 +178,6 @@ BuiltinTypes::BuiltinTypes()
|
||||
, fBVec(Type::MakeGenericType("$bvec", {fInvalid.get(), fBool2.get(), fBool3.get(),
|
||||
fBool4.get()}))
|
||||
, fSkCaps(Type::MakeSpecialType("$sk_Caps", "O", Type::TypeKind::kOther))
|
||||
, fFragmentProcessor(Type::MakeSpecialType("fragmentProcessor", "fp",
|
||||
Type::TypeKind::kFragmentProcessor))
|
||||
, fColorFilter(Type::MakeSpecialType("colorFilter", "CF", Type::TypeKind::kColorFilter))
|
||||
, fShader(Type::MakeSpecialType("shader", "SH", Type::TypeKind::kShader)) {}
|
||||
|
||||
|
@ -127,7 +127,6 @@ public:
|
||||
const std::unique_ptr<Type> fBVec;
|
||||
|
||||
const std::unique_ptr<Type> fSkCaps;
|
||||
const std::unique_ptr<Type> fFragmentProcessor;
|
||||
|
||||
const std::unique_ptr<Type> fColorFilter;
|
||||
const std::unique_ptr<Type> fShader;
|
||||
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/sksl/SkSLCPPUniformCTypes.h"
|
||||
|
||||
#include "include/private/SkMutex.h"
|
||||
#include "src/sksl/SkSLStringStream.h"
|
||||
#include "src/sksl/codegen/SkSLHCodeGenerator.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#if defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
/////////////////////////
|
||||
// Template evaluation //
|
||||
/////////////////////////
|
||||
|
||||
static String eval_template(const String& format,
|
||||
std::initializer_list<String> tokens,
|
||||
std::initializer_list<String> replacements) {
|
||||
SkASSERT(tokens.size() == replacements.size());
|
||||
String str = format;
|
||||
|
||||
// Replace every token with its replacement.
|
||||
auto tokenIter = tokens.begin();
|
||||
auto replacementIter = replacements.begin();
|
||||
for (; tokenIter != tokens.end(); ++tokenIter, ++replacementIter) {
|
||||
size_t position = 0;
|
||||
for (;;) {
|
||||
// Replace one instance of the current token with the requested replacement.
|
||||
position = str.find(*tokenIter, position);
|
||||
if (position == String::npos) {
|
||||
break;
|
||||
}
|
||||
str.replace(position, tokenIter->size(), *replacementIter);
|
||||
position += replacementIter->size();
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
// UniformCTypeMapper implementation //
|
||||
///////////////////////////////////////
|
||||
|
||||
String UniformCTypeMapper::setUniform(const String& pdman, const String& uniform,
|
||||
const String& var) const {
|
||||
return eval_template(fSetUniformTemplate,
|
||||
{"${pdman}", "${uniform}", "${var}"},
|
||||
{pdman, uniform, var});
|
||||
}
|
||||
|
||||
const UniformCTypeMapper* UniformCTypeMapper::Get(const Context& context, const Type& type,
|
||||
const Layout& layout) {
|
||||
SkASSERT(!type.isArray());
|
||||
|
||||
static const auto* kRegisteredMappers =
|
||||
new std::unordered_map<Layout::CType, UniformCTypeMapper>{
|
||||
{Layout::CType::kSkRect,
|
||||
"${pdman}.set4fv(${uniform}, 1, reinterpret_cast<const float*>(&${var}))"},
|
||||
{Layout::CType::kSkIRect,
|
||||
"${pdman}.set4iv(${uniform}, 1, reinterpret_cast<const int*>(&${var}))"},
|
||||
{Layout::CType::kSkPMColor4f, "${pdman}.set4fv(${uniform}, 1, ${var}.vec())"},
|
||||
{Layout::CType::kSkV4, "${pdman}.set4fv(${uniform}, 1, ${var}.ptr())"},
|
||||
{Layout::CType::kSkPoint, "${pdman}.set2f(${uniform}, ${var}.fX, ${var}.fY)"},
|
||||
{Layout::CType::kSkIPoint, "${pdman}.set2i(${uniform}, ${var}.fX, ${var}.fY)"},
|
||||
{Layout::CType::kSkMatrix, "${pdman}.setSkMatrix(${uniform}, ${var})"},
|
||||
{Layout::CType::kSkM44, "${pdman}.setSkM44(${uniform}, ${var})"},
|
||||
{Layout::CType::kFloat, "${pdman}.set1f(${uniform}, ${var})"},
|
||||
{Layout::CType::kInt32, "${pdman}.set1i(${uniform}, ${var})"},
|
||||
};
|
||||
|
||||
Layout::CType ctype = layout.fCType;
|
||||
// If there's no custom ctype declared in the layout, use the default type mapping
|
||||
if (ctype == Layout::CType::kDefault) {
|
||||
ctype = HCodeGenerator::ParameterCType(context, type, layout);
|
||||
}
|
||||
|
||||
auto it = kRegisteredMappers->find(ctype);
|
||||
return it == kRegisteredMappers->end() ? nullptr : &it->second;
|
||||
}
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif // defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkSLUniformCTypes_DEFINED
|
||||
#define SkSLUniformCTypes_DEFINED
|
||||
|
||||
#include "include/private/SkSLString.h"
|
||||
#include "src/sksl/SkSLContext.h"
|
||||
#include "src/sksl/ir/SkSLType.h"
|
||||
#include "src/sksl/ir/SkSLVariable.h"
|
||||
|
||||
#if defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
// This uses templates to define setUniform(). The template can reference token names formatted
|
||||
// ${name} that are replaced with the actual values passed into the function.
|
||||
//
|
||||
// setUniform() supports these tokens:
|
||||
// - ${pdman} replaced with value of pdmanName (1st argument)
|
||||
// - ${uniform} replaced with value of uniformHandleName (2nd argument)
|
||||
// - ${var} replaced with value of valueVarName (3rd argument)
|
||||
//
|
||||
// All templates and C++ snippets should produce valid expressions, but do not need to include
|
||||
// semicolons or newlines, which will be handled by the code generation itself.
|
||||
class UniformCTypeMapper {
|
||||
public:
|
||||
UniformCTypeMapper(const char* setUniformTemplate) : fSetUniformTemplate(setUniformTemplate) {}
|
||||
|
||||
// Returns nullptr if the type and layout are not supported; the returned pointer's ownership
|
||||
// is not transfered to the caller.
|
||||
//
|
||||
// The returned mapper can support tracking even if tracking is disabled based on the flags in
|
||||
// the layout.
|
||||
static const UniformCTypeMapper* Get(const Context& context, const Type& type,
|
||||
const Layout& layout);
|
||||
|
||||
static const UniformCTypeMapper* Get(const Context& context, const Variable& variable) {
|
||||
return Get(context, variable.type(), variable.modifiers().fLayout);
|
||||
}
|
||||
|
||||
// Return a statement that invokes the appropriate setX method on the GrGLSLProgramDataManager
|
||||
// specified by pdmanName, where the uniform is provided by the expression stored in
|
||||
// uniformHandleName, and valueVarName is the variable name pointing to the ctype instance
|
||||
// holding the new value.
|
||||
//
|
||||
// The returned snippet will be a valid expression.
|
||||
String setUniform(const String& pdmanName, const String& uniformHandleName,
|
||||
const String& valueVarName) const;
|
||||
|
||||
private:
|
||||
String fSetUniformTemplate;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif // defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
#endif // SkSLUniformCTypes_DEFINED
|
@ -19,10 +19,7 @@
|
||||
#include "src/sksl/SkSLOperators.h"
|
||||
#include "src/sksl/SkSLProgramSettings.h"
|
||||
#include "src/sksl/SkSLRehydrator.h"
|
||||
#include "src/sksl/codegen/SkSLCPPCodeGenerator.h"
|
||||
#include "src/sksl/codegen/SkSLDSLCPPCodeGenerator.h"
|
||||
#include "src/sksl/codegen/SkSLGLSLCodeGenerator.h"
|
||||
#include "src/sksl/codegen/SkSLHCodeGenerator.h"
|
||||
#include "src/sksl/codegen/SkSLMetalCodeGenerator.h"
|
||||
#include "src/sksl/codegen/SkSLSPIRVCodeGenerator.h"
|
||||
#include "src/sksl/codegen/SkSLSPIRVtoHLSL.h"
|
||||
@ -61,7 +58,6 @@
|
||||
#else
|
||||
|
||||
// At runtime, we load the dehydrated sksl data files. The data is a (pointer, size) pair.
|
||||
#include "src/sksl/generated/sksl_fp.dehydrated.sksl"
|
||||
#include "src/sksl/generated/sksl_frag.dehydrated.sksl"
|
||||
#include "src/sksl/generated/sksl_geom.dehydrated.sksl"
|
||||
#include "src/sksl/generated/sksl_gpu.dehydrated.sksl"
|
||||
@ -186,8 +182,6 @@ Compiler::Compiler(const ShaderCapsClass* caps)
|
||||
|
||||
TYPE(Sampler),
|
||||
TYPE(Texture2D),
|
||||
|
||||
TYPE(FragmentProcessor),
|
||||
};
|
||||
|
||||
for (const SkSL::Symbol* type : rootTypes) {
|
||||
@ -245,14 +239,6 @@ const ParsedModule& Compiler::loadGeometryModule() {
|
||||
return fGeometryModule;
|
||||
}
|
||||
|
||||
const ParsedModule& Compiler::loadFPModule() {
|
||||
if (!fFPModule.fSymbols) {
|
||||
fFPModule = this->parseModule(ProgramKind::kFragmentProcessor, MODULE_DATA(fp),
|
||||
this->loadGPUModule());
|
||||
}
|
||||
return fFPModule;
|
||||
}
|
||||
|
||||
const ParsedModule& Compiler::loadPublicModule() {
|
||||
if (!fPublicModule.fSymbols) {
|
||||
fPublicModule = this->parseModule(ProgramKind::kGeneric, MODULE_DATA(public), fRootModule);
|
||||
@ -312,7 +298,6 @@ const ParsedModule& Compiler::moduleForProgramKind(ProgramKind kind) {
|
||||
case ProgramKind::kVertex: return this->loadVertexModule(); break;
|
||||
case ProgramKind::kFragment: return this->loadFragmentModule(); break;
|
||||
case ProgramKind::kGeometry: return this->loadGeometryModule(); break;
|
||||
case ProgramKind::kFragmentProcessor: return this->loadFPModule(); break;
|
||||
case ProgramKind::kRuntimeColorFilter: return this->loadRuntimeColorFilterModule(); break;
|
||||
case ProgramKind::kRuntimeShader: return this->loadRuntimeShaderModule(); break;
|
||||
case ProgramKind::kRuntimeBlender: return this->loadRuntimeBlenderModule(); break;
|
||||
@ -878,9 +863,7 @@ bool Compiler::optimize(Program& program) {
|
||||
// Unreachable code can confuse some drivers, so it's worth removing. (skia:12012)
|
||||
this->removeUnreachableCode(program, usage);
|
||||
|
||||
if (program.fConfig->fKind != ProgramKind::kFragmentProcessor) {
|
||||
this->removeDeadGlobalVariables(program, usage);
|
||||
}
|
||||
this->removeDeadGlobalVariables(program, usage);
|
||||
}
|
||||
|
||||
if (fErrorCount == 0) {
|
||||
@ -993,29 +976,6 @@ bool Compiler::toMetal(Program& program, String* out) {
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
bool Compiler::toCPP(Program& program, String name, OutputStream& out) {
|
||||
AutoSource as(this, program.fSource.get());
|
||||
CPPCodeGenerator cg(fContext.get(), &program, this, name, &out);
|
||||
bool result = cg.generateCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Compiler::toDSLCPP(Program& program, String name, OutputStream& out) {
|
||||
AutoSource as(this, program.fSource.get());
|
||||
DSLCPPCodeGenerator cg(fContext.get(), &program, this, name, &out);
|
||||
bool result = cg.generateCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Compiler::toH(Program& program, String name, OutputStream& out) {
|
||||
AutoSource as(this, program.fSource.get());
|
||||
HCodeGenerator cg(fContext.get(), &program, this, name, &out);
|
||||
bool result = cg.generateCode();
|
||||
return result;
|
||||
}
|
||||
#endif // defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
#endif // defined(SKSL_STANDALONE) || SK_SUPPORT_GPU
|
||||
|
||||
Position Compiler::position(int offset) {
|
||||
|
@ -161,14 +161,6 @@ public:
|
||||
|
||||
bool toMetal(Program& program, String* out);
|
||||
|
||||
#if defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
bool toCPP(Program& program, String name, OutputStream& out);
|
||||
|
||||
bool toDSLCPP(Program& program, String name, OutputStream& out);
|
||||
|
||||
bool toH(Program& program, String name, OutputStream& out);
|
||||
#endif
|
||||
|
||||
void error(int offset, String msg) override;
|
||||
|
||||
String errorText(bool showCount = true);
|
||||
@ -215,7 +207,6 @@ private:
|
||||
const ParsedModule& loadGPUModule();
|
||||
const ParsedModule& loadFragmentModule();
|
||||
const ParsedModule& loadVertexModule();
|
||||
const ParsedModule& loadFPModule();
|
||||
const ParsedModule& loadGeometryModule();
|
||||
const ParsedModule& loadPublicModule();
|
||||
const ParsedModule& loadRuntimeColorFilterModule();
|
||||
@ -255,7 +246,6 @@ private:
|
||||
ParsedModule fVertexModule; // [GPU] + Vertex stage decls
|
||||
ParsedModule fFragmentModule; // [GPU] + Fragment stage decls
|
||||
ParsedModule fGeometryModule; // [GPU] + Geometry stage decls
|
||||
ParsedModule fFPModule; // [GPU] + FP features
|
||||
|
||||
ParsedModule fPublicModule; // [Root] + Public features
|
||||
ParsedModule fRuntimeColorFilterModule; // [Public] + Runtime shader decls
|
||||
|
@ -100,8 +100,6 @@ void Dehydrator::write(Layout l) {
|
||||
this->writeS8(l.fPrimitive);
|
||||
this->writeS8(l.fMaxVertices);
|
||||
this->writeS8(l.fInvocations);
|
||||
this->write(l.fWhen);
|
||||
this->writeS8((int) l.fCType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,9 +590,6 @@ void Dehydrator::write(const ProgramElement& e) {
|
||||
case ProgramElement::Kind::kModifiers:
|
||||
SkASSERT(false);
|
||||
break;
|
||||
case ProgramElement::Kind::kSection:
|
||||
SkASSERT(false);
|
||||
break;
|
||||
case ProgramElement::Kind::kStructDefinition: {
|
||||
const StructDefinition& structDef = e.as<StructDefinition>();
|
||||
this->writeCommand(Rehydrator::kStructDefinition_Command);
|
||||
|
@ -260,28 +260,11 @@ void IRGenerator::checkVarDeclaration(int offset, const Modifiers& modifiers, co
|
||||
offset,
|
||||
"variables of type '" + baseType->displayName() + "' must be global");
|
||||
}
|
||||
if (this->programKind() != ProgramKind::kFragmentProcessor) {
|
||||
if ((modifiers.fFlags & Modifiers::kIn_Flag) && baseType->isMatrix()) {
|
||||
this->errorReporter().error(offset, "'in' variables may not have matrix type");
|
||||
}
|
||||
if ((modifiers.fFlags & Modifiers::kIn_Flag) &&
|
||||
(modifiers.fFlags & Modifiers::kUniform_Flag)) {
|
||||
this->errorReporter().error(
|
||||
offset,
|
||||
"'in uniform' variables only permitted within fragment processors");
|
||||
}
|
||||
if (modifiers.fLayout.fWhen.length()) {
|
||||
this->errorReporter().error(offset,
|
||||
"'when' is only permitted within fragment processors");
|
||||
}
|
||||
if (modifiers.fLayout.fCType != Layout::CType::kDefault) {
|
||||
this->errorReporter().error(offset,
|
||||
"'ctype' is only permitted within fragment processors");
|
||||
}
|
||||
if (modifiers.fLayout.fFlags & Layout::kKey_Flag) {
|
||||
this->errorReporter().error(offset,
|
||||
"'key' is only permitted within fragment processors");
|
||||
}
|
||||
if ((modifiers.fFlags & Modifiers::kIn_Flag) && baseType->isMatrix()) {
|
||||
this->errorReporter().error(offset, "'in' variables may not have matrix type");
|
||||
}
|
||||
if ((modifiers.fFlags & Modifiers::kIn_Flag) && (modifiers.fFlags & Modifiers::kUniform_Flag)) {
|
||||
this->errorReporter().error(offset, "'in uniform' variables not permitted");
|
||||
}
|
||||
if (this->programKind() == ProgramKind::kRuntimeColorFilter ||
|
||||
this->programKind() == ProgramKind::kRuntimeShader) {
|
||||
@ -293,10 +276,6 @@ void IRGenerator::checkVarDeclaration(int offset, const Modifiers& modifiers, co
|
||||
this->errorReporter().error(
|
||||
offset, "variables of type '" + baseType->displayName() + "' must be uniform");
|
||||
}
|
||||
if ((modifiers.fLayout.fFlags & Layout::kKey_Flag) &&
|
||||
(modifiers.fFlags & Modifiers::kUniform_Flag)) {
|
||||
this->errorReporter().error(offset, "'key' is not permitted on 'uniform' variables");
|
||||
}
|
||||
if (modifiers.fLayout.fFlags & Layout::kSRGBUnpremul_Flag) {
|
||||
if (this->programKind() != ProgramKind::kRuntimeColorFilter &&
|
||||
this->programKind() != ProgramKind::kRuntimeShader) {
|
||||
@ -663,8 +642,7 @@ std::unique_ptr<Statement> IRGenerator::convertContinue(const ASTNode& c) {
|
||||
|
||||
std::unique_ptr<Statement> IRGenerator::convertDiscard(const ASTNode& d) {
|
||||
SkASSERT(d.fKind == ASTNode::Kind::kDiscard);
|
||||
if (this->programKind() != ProgramKind::kFragment &&
|
||||
this->programKind() != ProgramKind::kFragmentProcessor) {
|
||||
if (this->programKind() != ProgramKind::kFragment) {
|
||||
this->errorReporter().error(d.fOffset,
|
||||
"discard statement is only permitted in fragment shaders");
|
||||
return nullptr;
|
||||
@ -780,7 +758,6 @@ void IRGenerator::CheckModifiers(const Context& context,
|
||||
checkLayout(Layout::kPushConstant_Flag, "push_constant");
|
||||
checkLayout(Layout::kBlendSupportAllEquations_Flag, "blend_support_all_equations");
|
||||
checkLayout(Layout::kSRGBUnpremul_Flag, "srgb_unpremul");
|
||||
checkLayout(Layout::kKey_Flag, "key");
|
||||
checkLayout(Layout::kLocation_Flag, "location");
|
||||
checkLayout(Layout::kOffset_Flag, "offset");
|
||||
checkLayout(Layout::kBinding_Flag, "binding");
|
||||
@ -791,8 +768,6 @@ void IRGenerator::CheckModifiers(const Context& context,
|
||||
checkLayout(Layout::kPrimitive_Flag, "primitive-type");
|
||||
checkLayout(Layout::kMaxVertices_Flag, "max_vertices");
|
||||
checkLayout(Layout::kInvocations_Flag, "invocations");
|
||||
checkLayout(Layout::kWhen_Flag, "when");
|
||||
checkLayout(Layout::kCType_Flag, "ctype");
|
||||
SkASSERT(layoutFlags == 0);
|
||||
}
|
||||
|
||||
@ -1277,30 +1252,6 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(int offset, skstd::st
|
||||
fInputs.fUseFlipRTUniform = true;
|
||||
break;
|
||||
}
|
||||
if (this->programKind() == ProgramKind::kFragmentProcessor &&
|
||||
(modifiers.fFlags & Modifiers::kIn_Flag) &&
|
||||
!(modifiers.fFlags & Modifiers::kUniform_Flag) &&
|
||||
!(modifiers.fLayout.fFlags & Layout::kKey_Flag) &&
|
||||
modifiers.fLayout.fBuiltin == -1 &&
|
||||
!var->type().isFragmentProcessor() &&
|
||||
var->type().typeKind() != Type::TypeKind::kSampler) {
|
||||
bool valid = false;
|
||||
for (const auto& decl : fFile->root()) {
|
||||
if (decl.fKind == ASTNode::Kind::kSection) {
|
||||
const ASTNode::SectionData& section = decl.getSectionData();
|
||||
if (section.fName == "setData") {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
this->errorReporter().error(
|
||||
offset,
|
||||
"'in' variable must be either 'uniform' or 'layout(key)', or there "
|
||||
"must be a custom @setData function");
|
||||
}
|
||||
}
|
||||
// default to kRead_RefKind; this will be corrected later if the variable is written to
|
||||
return VariableReference::Make(offset, var, VariableReference::RefKind::kRead);
|
||||
}
|
||||
@ -1328,16 +1279,6 @@ std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTNode& identi
|
||||
return this->convertIdentifier(identifier.fOffset, identifier.getStringView());
|
||||
}
|
||||
|
||||
std::unique_ptr<Section> IRGenerator::convertSection(const ASTNode& s) {
|
||||
if (this->programKind() != ProgramKind::kFragmentProcessor) {
|
||||
this->errorReporter().error(s.fOffset, "syntax error");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ASTNode::SectionData& section = s.getSectionData();
|
||||
return std::make_unique<Section>(s.fOffset, section.fName, section.fArgument, section.fText);
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> IRGenerator::coerce(std::unique_ptr<Expression> expr,
|
||||
const Type& type) {
|
||||
return type.coerceExpression(std::move(expr), fContext);
|
||||
@ -1993,13 +1934,6 @@ IRGenerator::IRBundle IRGenerator::convertProgram(
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ASTNode::Kind::kSection: {
|
||||
std::unique_ptr<Section> s = this->convertSection(decl);
|
||||
if (s) {
|
||||
fProgramElements->push_back(std::move(s));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ASTNode::Kind::kType: {
|
||||
std::unique_ptr<StructDefinition> s = this->convertStructDefinition(decl);
|
||||
if (s) {
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "src/sksl/ir/SkSLInterfaceBlock.h"
|
||||
#include "src/sksl/ir/SkSLModifiersDeclaration.h"
|
||||
#include "src/sksl/ir/SkSLProgram.h"
|
||||
#include "src/sksl/ir/SkSLSection.h"
|
||||
#include "src/sksl/ir/SkSLSymbolTable.h"
|
||||
#include "src/sksl/ir/SkSLType.h"
|
||||
#include "src/sksl/ir/SkSLTypeReference.h"
|
||||
@ -212,7 +211,6 @@ private:
|
||||
std::unique_ptr<Expression> convertPrefixExpression(const ASTNode& expression);
|
||||
std::unique_ptr<Statement> convertReturn(int offset, std::unique_ptr<Expression> result);
|
||||
std::unique_ptr<Statement> convertReturn(const ASTNode& r);
|
||||
std::unique_ptr<Section> convertSection(const ASTNode& e);
|
||||
std::unique_ptr<Expression> convertCallExpression(const ASTNode& expression);
|
||||
std::unique_ptr<Expression> convertFieldExpression(const ASTNode& expression);
|
||||
std::unique_ptr<Expression> convertIndexExpression(const ASTNode& expression);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -51,7 +51,6 @@ struct Token {
|
||||
TK_CLASS,
|
||||
TK_IDENTIFIER,
|
||||
TK_DIRECTIVE,
|
||||
TK_SECTION,
|
||||
TK_LPAREN,
|
||||
TK_RPAREN,
|
||||
TK_LBRACE,
|
||||
|
@ -278,8 +278,6 @@ ResultCode processCommand(std::vector<SkSL::String>& args) {
|
||||
kind = SkSL::ProgramKind::kFragment;
|
||||
} else if (inputPath.ends_with(".geom")) {
|
||||
kind = SkSL::ProgramKind::kGeometry;
|
||||
} else if (inputPath.ends_with(".fp")) {
|
||||
kind = SkSL::ProgramKind::kFragmentProcessor;
|
||||
} else if (inputPath.ends_with(".rtb")) {
|
||||
kind = SkSL::ProgramKind::kRuntimeBlender;
|
||||
} else if (inputPath.ends_with(".rtcf")) {
|
||||
@ -287,7 +285,7 @@ ResultCode processCommand(std::vector<SkSL::String>& args) {
|
||||
} else if (inputPath.ends_with(".rts")) {
|
||||
kind = SkSL::ProgramKind::kRuntimeShader;
|
||||
} else {
|
||||
printf("input filename must end in '.vert', '.frag', '.geom', '.fp', '.rtb', '.rtcf', "
|
||||
printf("input filename must end in '.vert', '.frag', '.geom', '.rtb', '.rtcf', "
|
||||
"'.rts', or '.sksl'\n");
|
||||
return ResultCode::kInputError;
|
||||
}
|
||||
@ -382,28 +380,6 @@ ResultCode processCommand(std::vector<SkSL::String>& args) {
|
||||
[](SkSL::Compiler& compiler, SkSL::Program& program, SkSL::OutputStream& out) {
|
||||
return compiler.toMetal(program, out);
|
||||
});
|
||||
} else if (outputPath.ends_with(".h")) {
|
||||
settings.fReplaceSettings = false;
|
||||
settings.fPermitInvalidStaticTests = true;
|
||||
return compileProgram(
|
||||
[&](SkSL::Compiler& compiler, SkSL::Program& program, SkSL::OutputStream& out) {
|
||||
return compiler.toH(program, base_name(inputPath.c_str(), "Gr", ".fp"), out);
|
||||
});
|
||||
} else if (outputPath.ends_with(".dsl.cpp")) {
|
||||
settings.fReplaceSettings = false;
|
||||
settings.fPermitInvalidStaticTests = true;
|
||||
return compileProgram(
|
||||
[&](SkSL::Compiler& compiler, SkSL::Program& program, SkSL::OutputStream& out) {
|
||||
return compiler.toDSLCPP(program, base_name(inputPath.c_str(), "Gr", ".fp"),
|
||||
out);
|
||||
});
|
||||
} else if (outputPath.ends_with(".cpp")) {
|
||||
settings.fReplaceSettings = false;
|
||||
settings.fPermitInvalidStaticTests = true;
|
||||
return compileProgram(
|
||||
[&](SkSL::Compiler& compiler, SkSL::Program& program, SkSL::OutputStream& out) {
|
||||
return compiler.toCPP(program, base_name(inputPath.c_str(), "Gr", ".fp"), out);
|
||||
});
|
||||
} else if (outputPath.ends_with(".skvm")) {
|
||||
return compileProgram(
|
||||
[](SkSL::Compiler&, SkSL::Program& program, SkSL::OutputStream& out) {
|
||||
|
@ -105,12 +105,7 @@ void Parser::InitLayoutMap() {
|
||||
TOKEN(TRIANGLES_ADJACENCY, "triangles_adjacency");
|
||||
TOKEN(MAX_VERTICES, "max_vertices");
|
||||
TOKEN(INVOCATIONS, "invocations");
|
||||
TOKEN(WHEN, "when");
|
||||
TOKEN(KEY, "key");
|
||||
TOKEN(SRGB_UNPREMUL, "srgb_unpremul");
|
||||
TOKEN(CTYPE, "ctype");
|
||||
TOKEN(SKPMCOLOR4F, "SkPMColor4f");
|
||||
TOKEN(SKV4, "SkV4");
|
||||
#undef TOKEN
|
||||
}
|
||||
|
||||
@ -162,16 +157,6 @@ std::unique_ptr<ASTFile> Parser::compilationUnit() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Token::Kind::TK_SECTION: {
|
||||
ASTNode::ID section = this->section();
|
||||
if (fErrors.errorCount()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (section) {
|
||||
getNode(result).addChild(section);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Token::Kind::TK_INVALID: {
|
||||
this->error(this->peek(), String("invalid token"));
|
||||
return nullptr;
|
||||
@ -313,57 +298,6 @@ ASTNode::ID Parser::directive() {
|
||||
}
|
||||
}
|
||||
|
||||
/* SECTION LBRACE (LPAREN IDENTIFIER RPAREN)? <any sequence of tokens with balanced braces>
|
||||
RBRACE */
|
||||
ASTNode::ID Parser::section() {
|
||||
Token start;
|
||||
if (!this->expect(Token::Kind::TK_SECTION, "a section token", &start)) {
|
||||
return ASTNode::ID::Invalid();
|
||||
}
|
||||
skstd::string_view argument;
|
||||
if (this->peek().fKind == Token::Kind::TK_LPAREN) {
|
||||
this->nextToken();
|
||||
Token argToken;
|
||||
if (!this->expectIdentifier(&argToken)) {
|
||||
return ASTNode::ID::Invalid();
|
||||
}
|
||||
argument = this->text(argToken);
|
||||
if (!this->expect(Token::Kind::TK_RPAREN, "')'")) {
|
||||
return ASTNode::ID::Invalid();
|
||||
}
|
||||
}
|
||||
if (!this->expect(Token::Kind::TK_LBRACE, "'{'")) {
|
||||
return ASTNode::ID::Invalid();
|
||||
}
|
||||
Token codeStart = this->nextRawToken();
|
||||
size_t startOffset = codeStart.fOffset;
|
||||
this->pushback(codeStart);
|
||||
int level = 1;
|
||||
skstd::string_view text;
|
||||
Token next;
|
||||
while (level > 0) {
|
||||
next = this->nextRawToken();
|
||||
switch (next.fKind) {
|
||||
case Token::Kind::TK_LBRACE:
|
||||
++level;
|
||||
break;
|
||||
case Token::Kind::TK_RBRACE:
|
||||
--level;
|
||||
break;
|
||||
case Token::Kind::TK_END_OF_FILE:
|
||||
this->error(start, "reached end of file while parsing section");
|
||||
return ASTNode::ID::Invalid();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
text = skstd::string_view(fText.begin() + startOffset, next.fOffset - startOffset);
|
||||
skstd::string_view name = this->text(start);
|
||||
name.remove_prefix(1);
|
||||
return this->createNode(start.fOffset, ASTNode::Kind::kSection,
|
||||
ASTNode::SectionData(name, argument, text));
|
||||
}
|
||||
|
||||
/* ENUM CLASS IDENTIFIER LBRACE (IDENTIFIER (EQ expression)? (COMMA IDENTIFIER (EQ expression))*)?
|
||||
RBRACE */
|
||||
ASTNode::ID Parser::enumDeclaration() {
|
||||
@ -797,68 +731,6 @@ skstd::string_view Parser::layoutIdentifier() {
|
||||
return this->text(resultToken);
|
||||
}
|
||||
|
||||
|
||||
/** EQ <any sequence of tokens with balanced parentheses and no top-level comma> */
|
||||
skstd::string_view Parser::layoutCode() {
|
||||
if (!this->expect(Token::Kind::TK_EQ, "'='")) {
|
||||
return "";
|
||||
}
|
||||
Token start = this->nextRawToken();
|
||||
this->pushback(start);
|
||||
skstd::string_view code;
|
||||
int level = 1;
|
||||
bool done = false;
|
||||
while (!done) {
|
||||
Token next = this->nextRawToken();
|
||||
switch (next.fKind) {
|
||||
case Token::Kind::TK_LPAREN:
|
||||
++level;
|
||||
break;
|
||||
case Token::Kind::TK_RPAREN:
|
||||
--level;
|
||||
break;
|
||||
case Token::Kind::TK_COMMA:
|
||||
if (level == 1) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
case Token::Kind::TK_END_OF_FILE:
|
||||
this->error(start, "reached end of file while parsing layout");
|
||||
return "";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!level) {
|
||||
done = true;
|
||||
}
|
||||
if (done) {
|
||||
code = skstd::string_view(fText.begin() + start.fOffset, next.fOffset - start.fOffset);
|
||||
this->pushback(std::move(next));
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
Layout::CType Parser::layoutCType() {
|
||||
if (this->expect(Token::Kind::TK_EQ, "'='")) {
|
||||
Token t = this->nextToken();
|
||||
String text(this->text(t));
|
||||
auto found = layoutTokens->find(text);
|
||||
if (found != layoutTokens->end()) {
|
||||
switch (found->second) {
|
||||
case LayoutToken::SKPMCOLOR4F:
|
||||
return Layout::CType::kSkPMColor4f;
|
||||
case LayoutToken::SKV4:
|
||||
return Layout::CType::kSkV4;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->error(t, "unsupported ctype");
|
||||
}
|
||||
return Layout::CType::kDefault;
|
||||
}
|
||||
|
||||
/* LAYOUT LPAREN IDENTIFIER (EQ INT_LITERAL)? (COMMA IDENTIFIER (EQ INT_LITERAL)?)* RPAREN */
|
||||
Layout Parser::layout() {
|
||||
int flags = 0;
|
||||
@ -872,12 +744,10 @@ Layout Parser::layout() {
|
||||
Layout::Primitive primitive = Layout::kUnspecified_Primitive;
|
||||
int maxVertices = -1;
|
||||
int invocations = -1;
|
||||
skstd::string_view when;
|
||||
Layout::CType ctype = Layout::CType::kDefault;
|
||||
if (this->checkNext(Token::Kind::TK_LAYOUT)) {
|
||||
if (!this->expect(Token::Kind::TK_LPAREN, "'('")) {
|
||||
return Layout(flags, location, offset, binding, index, set, builtin,
|
||||
inputAttachmentIndex, primitive, maxVertices, invocations, when, ctype);
|
||||
inputAttachmentIndex, primitive, maxVertices, invocations);
|
||||
}
|
||||
for (;;) {
|
||||
Token t = this->nextToken();
|
||||
@ -911,9 +781,6 @@ Layout Parser::layout() {
|
||||
case LayoutToken::SRGB_UNPREMUL:
|
||||
setFlag(Layout::kSRGBUnpremul_Flag);
|
||||
break;
|
||||
case LayoutToken::KEY:
|
||||
setFlag(Layout::kKey_Flag);
|
||||
break;
|
||||
case LayoutToken::LOCATION:
|
||||
setFlag(Layout::kLocation_Flag);
|
||||
location = this->layoutInt();
|
||||
@ -971,14 +838,6 @@ Layout Parser::layout() {
|
||||
setFlag(Layout::kInvocations_Flag);
|
||||
invocations = this->layoutInt();
|
||||
break;
|
||||
case LayoutToken::WHEN:
|
||||
setFlag(Layout::kWhen_Flag);
|
||||
when = this->layoutCode();
|
||||
break;
|
||||
case LayoutToken::CTYPE:
|
||||
setFlag(Layout::kCType_Flag);
|
||||
ctype = this->layoutCType();
|
||||
break;
|
||||
default:
|
||||
this->error(t, "'" + text + "' is not a valid layout qualifier");
|
||||
break;
|
||||
@ -995,7 +854,7 @@ Layout Parser::layout() {
|
||||
}
|
||||
}
|
||||
return Layout(flags, location, offset, binding, index, set, builtin, inputAttachmentIndex,
|
||||
primitive, maxVertices, invocations, when, ctype);
|
||||
primitive, maxVertices, invocations);
|
||||
}
|
||||
|
||||
/* layout? (UNIFORM | CONST | IN | OUT | INOUT | FLAT | NOPERSPECTIVE | INLINE)* */
|
||||
|
@ -48,12 +48,7 @@ public:
|
||||
TRIANGLES_ADJACENCY,
|
||||
MAX_VERTICES,
|
||||
INVOCATIONS,
|
||||
WHEN,
|
||||
KEY,
|
||||
SRGB_UNPREMUL,
|
||||
CTYPE,
|
||||
SKPMCOLOR4F,
|
||||
SKV4,
|
||||
};
|
||||
|
||||
Parser(skstd::string_view text, SymbolTable& symbols, ErrorReporter& errors);
|
||||
@ -146,8 +141,6 @@ private:
|
||||
|
||||
ASTNode::ID directive();
|
||||
|
||||
ASTNode::ID section();
|
||||
|
||||
ASTNode::ID enumDeclaration();
|
||||
|
||||
ASTNode::ID declaration();
|
||||
@ -178,10 +171,6 @@ private:
|
||||
|
||||
skstd::string_view layoutIdentifier();
|
||||
|
||||
skstd::string_view layoutCode();
|
||||
|
||||
Layout::CType layoutCType();
|
||||
|
||||
Layout layout();
|
||||
|
||||
Modifiers modifiers();
|
||||
|
@ -111,11 +111,9 @@ Layout Rehydrator::layout() {
|
||||
int primitive = this->readS8();
|
||||
int maxVertices = this->readS8();
|
||||
int invocations = this->readS8();
|
||||
skstd::string_view when = this->readString();
|
||||
int ctype = this->readS8();
|
||||
return Layout(flags, location, offset, binding, index, set, builtin,
|
||||
inputAttachmentIndex, (Layout::Primitive)primitive, maxVertices,
|
||||
invocations, when, (Layout::CType)ctype);
|
||||
invocations);
|
||||
}
|
||||
default:
|
||||
SkASSERT(false);
|
||||
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 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/SkSLSectionAndParameterHelper.h"
|
||||
#include "src/sksl/ir/SkSLBinaryExpression.h"
|
||||
#include "src/sksl/ir/SkSLConstructor.h"
|
||||
#include "src/sksl/ir/SkSLDoStatement.h"
|
||||
#include "src/sksl/ir/SkSLExpressionStatement.h"
|
||||
#include "src/sksl/ir/SkSLFieldAccess.h"
|
||||
#include "src/sksl/ir/SkSLForStatement.h"
|
||||
#include "src/sksl/ir/SkSLFunctionCall.h"
|
||||
#include "src/sksl/ir/SkSLIfStatement.h"
|
||||
#include "src/sksl/ir/SkSLIndexExpression.h"
|
||||
#include "src/sksl/ir/SkSLPostfixExpression.h"
|
||||
#include "src/sksl/ir/SkSLPrefixExpression.h"
|
||||
#include "src/sksl/ir/SkSLReturnStatement.h"
|
||||
#include "src/sksl/ir/SkSLSwitchStatement.h"
|
||||
#include "src/sksl/ir/SkSLSwizzle.h"
|
||||
#include "src/sksl/ir/SkSLTernaryExpression.h"
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
SectionAndParameterHelper::SectionAndParameterHelper(const Program* program, ErrorReporter& errors)
|
||||
: fProgram(*program) {
|
||||
for (const ProgramElement* p : fProgram.elements()) {
|
||||
switch (p->kind()) {
|
||||
case ProgramElement::Kind::kGlobalVar: {
|
||||
const VarDeclaration& decl =
|
||||
p->as<GlobalVarDeclaration>().declaration()->as<VarDeclaration>();
|
||||
if (IsParameter(decl.var())) {
|
||||
fParameters.push_back(&decl.var());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProgramElement::Kind::kSection: {
|
||||
const Section& s = p->as<Section>();
|
||||
skstd::string_view name = s.name();
|
||||
skstd::string_view arg = s.argument();
|
||||
if (IsSupportedSection(name)) {
|
||||
if (SectionRequiresArgument(name) && !arg.size()) {
|
||||
errors.error(s.fOffset,
|
||||
("section '@" + name +
|
||||
"' requires one parameter").c_str());
|
||||
}
|
||||
if (!SectionAcceptsArgument(name) && arg.size()) {
|
||||
errors.error(s.fOffset,
|
||||
("section '@" + name + "' has no parameters").c_str());
|
||||
}
|
||||
} else {
|
||||
errors.error(s.fOffset,
|
||||
("unsupported section '@" + name + "'").c_str());
|
||||
}
|
||||
if (fSections.find(name) != fSections.end()) {
|
||||
errors.error(s.fOffset, ("duplicate section '@" + name + "'").c_str());
|
||||
}
|
||||
fSections[name].push_back(&s);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace SkSL
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SKSL_SECTIONANDPARAMETERHELPER
|
||||
#define SKSL_SECTIONANDPARAMETERHELPER
|
||||
|
||||
#include "src/sksl/SkSLErrorReporter.h"
|
||||
#include "src/sksl/ir/SkSLProgram.h"
|
||||
#include "src/sksl/ir/SkSLSection.h"
|
||||
#include "src/sksl/ir/SkSLVarDeclarations.h"
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
inline constexpr char kClassSection[] = "class";
|
||||
inline constexpr char kCloneSection[] = "clone";
|
||||
inline constexpr char kConstructorSection[] = "constructor";
|
||||
inline constexpr char kConstructorCodeSection[] = "constructorCode";
|
||||
inline constexpr char kConstructorParamsSection[] = "constructorParams";
|
||||
inline constexpr char kCppSection[] = "cpp";
|
||||
inline constexpr char kCppEndSection[] = "cppEnd";
|
||||
inline constexpr char kDumpInfoSection[] = "dumpInfo";
|
||||
inline constexpr char kEmitCodeSection[] = "emitCode";
|
||||
inline constexpr char kFieldsSection[] = "fields";
|
||||
inline constexpr char kHeaderSection[] = "header";
|
||||
inline constexpr char kHeaderEndSection[] = "headerEnd";
|
||||
inline constexpr char kInitializersSection[] = "initializers";
|
||||
inline constexpr char kMakeSection[] = "make";
|
||||
inline constexpr char kOptimizationFlagsSection[] = "optimizationFlags";
|
||||
inline constexpr char kSetDataSection[] = "setData";
|
||||
inline constexpr char kTestCodeSection[] = "test";
|
||||
|
||||
class SectionAndParameterHelper {
|
||||
public:
|
||||
SectionAndParameterHelper(const Program* program, ErrorReporter& errors);
|
||||
|
||||
const Section* getSection(skstd::string_view name) {
|
||||
auto found = fSections.find(name);
|
||||
if (found == fSections.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
SkASSERT(found->second.size() == 1);
|
||||
return found->second[0];
|
||||
}
|
||||
|
||||
std::vector<const Section*> getSections(skstd::string_view name) {
|
||||
auto found = fSections.find(name);
|
||||
if (found == fSections.end()) {
|
||||
return std::vector<const Section*>();
|
||||
}
|
||||
return found->second;
|
||||
}
|
||||
|
||||
const std::vector<const Variable*>& getParameters() {
|
||||
return fParameters;
|
||||
}
|
||||
|
||||
static bool IsParameter(const Variable& var) {
|
||||
return (var.modifiers().fFlags & Modifiers::kIn_Flag) &&
|
||||
-1 == var.modifiers().fLayout.fBuiltin;
|
||||
}
|
||||
|
||||
static bool IsSupportedSection(skstd::string_view name) {
|
||||
return name == kClassSection ||
|
||||
name == kCloneSection ||
|
||||
name == kConstructorSection ||
|
||||
name == kConstructorCodeSection ||
|
||||
name == kConstructorParamsSection ||
|
||||
name == kCppSection ||
|
||||
name == kCppEndSection ||
|
||||
name == kDumpInfoSection ||
|
||||
name == kEmitCodeSection ||
|
||||
name == kFieldsSection ||
|
||||
name == kHeaderSection ||
|
||||
name == kHeaderEndSection ||
|
||||
name == kInitializersSection ||
|
||||
name == kMakeSection ||
|
||||
name == kOptimizationFlagsSection ||
|
||||
name == kSetDataSection ||
|
||||
name == kTestCodeSection;
|
||||
}
|
||||
|
||||
static bool SectionAcceptsArgument(skstd::string_view name) {
|
||||
return name == kSetDataSection || name == kTestCodeSection;
|
||||
}
|
||||
|
||||
static bool SectionRequiresArgument(skstd::string_view name) {
|
||||
return name == kSetDataSection || name == kTestCodeSection;
|
||||
}
|
||||
|
||||
private:
|
||||
const Program& fProgram;
|
||||
std::vector<const Variable*> fParameters;
|
||||
std::unordered_map<skstd::string_view, std::vector<const Section*>> fSections;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SKSL_CPPCODEGENERATOR
|
||||
#define SKSL_CPPCODEGENERATOR
|
||||
|
||||
#include "src/sksl/SkSLSectionAndParameterHelper.h"
|
||||
#include "src/sksl/codegen/SkSLGLSLCodeGenerator.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#if defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
class CPPCodeGenerator : public GLSLCodeGenerator {
|
||||
public:
|
||||
CPPCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors,
|
||||
String name, OutputStream* out);
|
||||
|
||||
bool generateCode() override;
|
||||
|
||||
private:
|
||||
using Precedence = Operator::Precedence;
|
||||
|
||||
void writef(const char* s, va_list va) SK_PRINTF_LIKE(2, 0);
|
||||
|
||||
void writef(const char* s, ...) SK_PRINTF_LIKE(2, 3);
|
||||
|
||||
bool writeSection(const char* name, const char* prefix = "");
|
||||
|
||||
void writeHeader() override;
|
||||
|
||||
bool usesPrecisionModifiers() const override;
|
||||
|
||||
String getTypeName(const Type& type) override;
|
||||
|
||||
void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrecedence) override;
|
||||
|
||||
void writeIntLiteral(const IntLiteral& i) override;
|
||||
|
||||
void writeSwizzle(const Swizzle& swizzle) override;
|
||||
|
||||
void writeVariableReference(const VariableReference& ref) override;
|
||||
|
||||
void writeIfStatement(const IfStatement& s) override;
|
||||
|
||||
void writeReturnStatement(const ReturnStatement& s) override;
|
||||
|
||||
void writeSwitchStatement(const SwitchStatement& s) override;
|
||||
|
||||
String getSampleVarName(const char* prefix, int sampleCounter);
|
||||
|
||||
void writeFunctionCall(const FunctionCall& c) override;
|
||||
|
||||
void writeFunction(const FunctionDefinition& f) override;
|
||||
|
||||
void prepareHelperFunction(const FunctionDeclaration& decl);
|
||||
|
||||
void prototypeHelperFunction(const FunctionDeclaration& decl);
|
||||
|
||||
void writeSetting(const Setting& s) override;
|
||||
|
||||
void writeProgramElement(const ProgramElement& p) override;
|
||||
|
||||
void addUniform(const Variable& var);
|
||||
|
||||
// writes a printf escape that will be filled in at runtime by the given C++ expression string
|
||||
void writeRuntimeValue(const Type& type, const Layout& layout, const String& cppCode);
|
||||
String formatRuntimeValue(const Type& type, const Layout& layout, const String& cppCode,
|
||||
std::vector<String>* formatArgs);
|
||||
|
||||
void writeVarInitializer(const Variable& var, const Expression& value) override;
|
||||
|
||||
void writeInputVars() override;
|
||||
|
||||
void writePrivateVars();
|
||||
|
||||
void writePrivateVarValues();
|
||||
|
||||
void writeCodeAppend(const String& code);
|
||||
|
||||
String assembleCodeAndFormatArgPrintf(const String& code);
|
||||
|
||||
bool writeEmitCode(std::vector<const Variable*>& uniforms);
|
||||
|
||||
void writeSetData(std::vector<const Variable*>& uniforms);
|
||||
|
||||
void writeGetKey();
|
||||
|
||||
void writeClone();
|
||||
|
||||
void writeDumpInfo();
|
||||
|
||||
void writeTest();
|
||||
|
||||
// If the returned C++ is included in the generated code, then the variable name stored in
|
||||
// cppVar will refer to a valid SkString that matches the Expression. Successful returns leave
|
||||
// the output buffer (and related state) unmodified.
|
||||
//
|
||||
// In the simplest cases, this will return "SkString {cppVar}(\"{e}\");", while more advanced
|
||||
// cases will properly insert format arguments.
|
||||
String convertSKSLExpressionToCPP(const Expression& e, const String& cppVar);
|
||||
|
||||
// Process accumulated sksl to split it into appended code sections, properly interleaved with
|
||||
// the extra emit code blocks, based on statement/block locations and the inserted tokens
|
||||
// from newExtraEmitCodeBlock(). It is necessary to split the sksl after the program has been
|
||||
// fully walked since many elements redirect fOut to simultaneously build header sections and
|
||||
// bodies that are then concatenated; due to this it is not possible to split the sksl emission
|
||||
// on the fly.
|
||||
void flushEmittedCode();
|
||||
|
||||
// Start a new extra emit code block for accumulating C++ code. This will insert a token into
|
||||
// the sksl stream to mark the fence between previous complete sksl statements and where the
|
||||
// C++ code added to the new block will be added to emitCode(). These tokens are removed by
|
||||
// flushEmittedCode() as it consumes them before passing pure sksl to writeCodeAppend().
|
||||
void newExtraEmitCodeBlock();
|
||||
|
||||
// Append CPP code to the current extra emit code block.
|
||||
void addExtraEmitCodeLine(const String& toAppend);
|
||||
|
||||
int getChildFPIndex(const Variable& var) const;
|
||||
|
||||
String fName;
|
||||
String fFullName;
|
||||
SectionAndParameterHelper fSectionAndParameterHelper;
|
||||
std::vector<String> fExtraEmitCodeBlocks;
|
||||
|
||||
std::vector<String> fFormatArgs;
|
||||
// true if the sksl declared its main() function with a float2 parameter AND referenced that
|
||||
// parameter in its body.
|
||||
bool fAccessSampleCoordsDirectly = false;
|
||||
|
||||
// If true, we are writing a C++ expression instead of a GLSL expression
|
||||
bool fCPPMode = false;
|
||||
|
||||
// True while compiling the main() function of the FP.
|
||||
bool fInMain = false;
|
||||
|
||||
// Gives unique but predictable names to invocations of sample().
|
||||
int fSampleCounter = 0;
|
||||
|
||||
// if not null, we are accumulating SkSL for emitCode into fOut, which
|
||||
// replaced the original buffer with a StringStream. The original buffer is
|
||||
// stored here for restoration.
|
||||
OutputStream* fCPPBuffer = nullptr;
|
||||
|
||||
using INHERITED = GLSLCodeGenerator;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif // defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
#endif // SKSL_CPPCODEGENERATOR
|
File diff suppressed because it is too large
Load Diff
@ -1,146 +0,0 @@
|
||||
/*
|
||||
* 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_DSLCPPCODEGENERATOR
|
||||
#define SKSL_DSLCPPCODEGENERATOR
|
||||
|
||||
#include "src/sksl/SkSLSectionAndParameterHelper.h"
|
||||
#include "src/sksl/codegen/SkSLGLSLCodeGenerator.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#if defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
class DSLCPPCodeGenerator : public GLSLCodeGenerator {
|
||||
public:
|
||||
DSLCPPCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors,
|
||||
String name, OutputStream* out);
|
||||
|
||||
bool generateCode() override;
|
||||
|
||||
private:
|
||||
using Precedence = Operator::Precedence;
|
||||
|
||||
void writeAnyConstructor(const AnyConstructor& c, Precedence parentPrecedence) override;
|
||||
|
||||
void writeBlock(const Block& b);
|
||||
|
||||
void writeCastConstructor(const AnyConstructor& c, Precedence parentPrecedence) override;
|
||||
|
||||
void writeDoStatement(const DoStatement& d);
|
||||
|
||||
void writeFloatLiteral(const FloatLiteral& f) override;
|
||||
|
||||
void writeForStatement(const ForStatement& f);
|
||||
|
||||
void writeFunctionBody(const Block& b);
|
||||
|
||||
void writeIfStatement(const IfStatement& r) override;
|
||||
|
||||
void writeReturnStatement(const ReturnStatement& r) override;
|
||||
|
||||
void writeStatement(const Statement& s);
|
||||
|
||||
void writeSwitchStatement(const SwitchStatement& s) override;
|
||||
|
||||
void writeTernaryExpression(const TernaryExpression& t, Precedence parentPrecedence) override;
|
||||
|
||||
void writeVar(const Variable& var);
|
||||
|
||||
void writeVarCtorExpression(const Variable& var);
|
||||
|
||||
void writeVarDeclaration(const VarDeclaration& var, bool global);
|
||||
|
||||
void writef(const char* s, va_list va) SK_PRINTF_LIKE(2, 0);
|
||||
|
||||
void writef(const char* s, ...) SK_PRINTF_LIKE(2, 3);
|
||||
|
||||
bool writeSection(const char* name, const char* prefix = "");
|
||||
|
||||
void writeHeader() override;
|
||||
|
||||
void writeCppInitialValue(const Variable& var);
|
||||
|
||||
bool usesPrecisionModifiers() const override;
|
||||
|
||||
String getTypeName(const Type& type) override;
|
||||
|
||||
String getDSLType(const Type& type);
|
||||
|
||||
String getDSLModifiers(const Modifiers& type);
|
||||
|
||||
String getDefaultDSLValue(const Variable& var);
|
||||
|
||||
void writeSwizzle(const Swizzle& swizzle) override;
|
||||
|
||||
void writeVariableReference(const VariableReference& ref) override;
|
||||
|
||||
void writeFunctionCall(const FunctionCall& c) override;
|
||||
|
||||
void writeFunction(const FunctionDefinition& f) override;
|
||||
|
||||
void prepareHelperFunction(const FunctionDeclaration& decl);
|
||||
|
||||
void prototypeHelperFunction(const FunctionDeclaration& decl);
|
||||
|
||||
void writeSetting(const Setting& s) override;
|
||||
|
||||
void writeProgramElement(const ProgramElement& p) override;
|
||||
|
||||
void addUniform(const Variable& var);
|
||||
|
||||
// writes a printf escape that will be filled in at runtime by the given C++ expression string
|
||||
String formatRuntimeValue(const Type& type, const Layout& layout, const String& cppCode,
|
||||
std::vector<String>* formatArgs);
|
||||
|
||||
void writeInputVars() override;
|
||||
|
||||
void writePrivateVars();
|
||||
|
||||
void writePrivateVarValues();
|
||||
|
||||
bool writeEmitCode(std::vector<const Variable*>& uniforms);
|
||||
|
||||
void writeSetData(std::vector<const Variable*>& uniforms);
|
||||
|
||||
void writeGetKey();
|
||||
|
||||
void writeClone();
|
||||
|
||||
void writeDumpInfo();
|
||||
|
||||
void writeTest();
|
||||
|
||||
int getChildFPIndex(const Variable& var) const;
|
||||
|
||||
const char* getVariableCppName(const Variable& var);
|
||||
|
||||
String fName;
|
||||
String fFullName;
|
||||
SectionAndParameterHelper fSectionAndParameterHelper;
|
||||
std::unordered_map<const Variable*, String> fVariableCppNames;
|
||||
|
||||
// true if the sksl declared its main() function with a float2 parameter AND referenced that
|
||||
// parameter in its body.
|
||||
bool fAccessSampleCoordsDirectly = false;
|
||||
|
||||
// If true, we are writing a C++ expression instead of a GLSL expression
|
||||
bool fCPPMode = false;
|
||||
|
||||
// True while compiling the main() function of the FP.
|
||||
bool fInMain = false;
|
||||
|
||||
using INHERITED = GLSLCodeGenerator;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif // defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
#endif // SKSL_DSLCPPCODEGENERATOR
|
@ -1,347 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/sksl/codegen/SkSLHCodeGenerator.h"
|
||||
|
||||
#include "include/private/SkSLSampleUsage.h"
|
||||
#include "src/sksl/SkSLAnalysis.h"
|
||||
#include "src/sksl/SkSLParser.h"
|
||||
#include "src/sksl/SkSLUtil.h"
|
||||
#include "src/sksl/ir/SkSLEnum.h"
|
||||
#include "src/sksl/ir/SkSLFunctionDeclaration.h"
|
||||
#include "src/sksl/ir/SkSLFunctionDefinition.h"
|
||||
#include "src/sksl/ir/SkSLSection.h"
|
||||
#include "src/sksl/ir/SkSLVarDeclarations.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#if defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
HCodeGenerator::HCodeGenerator(const Context* context, const Program* program,
|
||||
ErrorReporter* errors, String name, OutputStream* out)
|
||||
: INHERITED(program, errors, out)
|
||||
, fContext(*context)
|
||||
, fName(std::move(name))
|
||||
, fFullName(String::printf("Gr%s", fName.c_str()))
|
||||
, fSectionAndParameterHelper(program, *errors) {}
|
||||
|
||||
String HCodeGenerator::ParameterType(const Context& context, const Type& type,
|
||||
const Layout& layout) {
|
||||
if (type.isArray()) {
|
||||
return String::printf("std::array<%s>", ParameterType(context, type.componentType(),
|
||||
layout).c_str());
|
||||
}
|
||||
Layout::CType ctype = ParameterCType(context, type, layout);
|
||||
if (ctype != Layout::CType::kDefault) {
|
||||
return Layout::CTypeToStr(ctype);
|
||||
}
|
||||
return String(type.name());
|
||||
}
|
||||
|
||||
Layout::CType HCodeGenerator::ParameterCType(const Context& context, const Type& type,
|
||||
const Layout& layout) {
|
||||
SkASSERT(!type.isArray());
|
||||
if (layout.fCType != Layout::CType::kDefault) {
|
||||
return layout.fCType;
|
||||
}
|
||||
if (type == *context.fTypes.fFloat || type == *context.fTypes.fHalf) {
|
||||
return Layout::CType::kFloat;
|
||||
} else if (type == *context.fTypes.fInt || type == *context.fTypes.fShort) {
|
||||
return Layout::CType::kInt32;
|
||||
} else if (type == *context.fTypes.fFloat2 || type == *context.fTypes.fHalf2) {
|
||||
return Layout::CType::kSkPoint;
|
||||
} else if (type == *context.fTypes.fInt2 || type == *context.fTypes.fShort2) {
|
||||
return Layout::CType::kSkIPoint;
|
||||
} else if (type == *context.fTypes.fInt4 || type == *context.fTypes.fShort4) {
|
||||
return Layout::CType::kSkIRect;
|
||||
} else if (type == *context.fTypes.fFloat4 || type == *context.fTypes.fHalf4) {
|
||||
return Layout::CType::kSkRect;
|
||||
} else if (type == *context.fTypes.fFloat3x3 || type == *context.fTypes.fHalf3x3) {
|
||||
return Layout::CType::kSkMatrix;
|
||||
} else if (type == *context.fTypes.fFloat4x4 || type == *context.fTypes.fHalf4x4) {
|
||||
return Layout::CType::kSkM44;
|
||||
} else if (type.isFragmentProcessor()) {
|
||||
return Layout::CType::kGrFragmentProcessor;
|
||||
}
|
||||
return Layout::CType::kDefault;
|
||||
}
|
||||
|
||||
String HCodeGenerator::FieldType(const Context& context, const Type& type,
|
||||
const Layout& layout) {
|
||||
if (type.isFragmentProcessor()) {
|
||||
// we don't store fragment processors in fields, they get registered via
|
||||
// registerChildProcessor instead
|
||||
SkASSERT(false);
|
||||
return "<error>";
|
||||
}
|
||||
return ParameterType(context, type, layout);
|
||||
}
|
||||
|
||||
String HCodeGenerator::AccessType(const Context& context, const Type& type,
|
||||
const Layout& layout) {
|
||||
static const std::set<String> primitiveTypes = { "int32_t", "float", "bool", "SkPMColor" };
|
||||
|
||||
String fieldType = FieldType(context, type, layout);
|
||||
bool isPrimitive = primitiveTypes.find(fieldType) != primitiveTypes.end();
|
||||
if (isPrimitive) {
|
||||
return fieldType;
|
||||
} else {
|
||||
return String::printf("const %s&", fieldType.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void HCodeGenerator::writef(const char* s, va_list va) {
|
||||
static constexpr int BUFFER_SIZE = 1024;
|
||||
va_list copy;
|
||||
va_copy(copy, va);
|
||||
char buffer[BUFFER_SIZE];
|
||||
int length = vsnprintf(buffer, BUFFER_SIZE, s, va);
|
||||
if (length < BUFFER_SIZE) {
|
||||
fOut->write(buffer, length);
|
||||
} else {
|
||||
std::unique_ptr<char[]> heap(new char[length + 1]);
|
||||
vsprintf(heap.get(), s, copy);
|
||||
fOut->write(heap.get(), length);
|
||||
}
|
||||
va_end(copy);
|
||||
}
|
||||
|
||||
void HCodeGenerator::writef(const char* s, ...) {
|
||||
va_list va;
|
||||
va_start(va, s);
|
||||
this->writef(s, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
bool HCodeGenerator::writeSection(const char* name, const char* prefix) {
|
||||
const Section* s = fSectionAndParameterHelper.getSection(name);
|
||||
if (s) {
|
||||
this->writef("%s", prefix);
|
||||
this->writef("%.*s", (int)s->text().length(), s->text().data());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HCodeGenerator::writeExtraConstructorParams(const char* separator) {
|
||||
// super-simple parse, just assume the last token before a comma is the name of a parameter
|
||||
// (which is true as long as there are no multi-parameter template types involved). Will replace
|
||||
// this with something more robust if the need arises.
|
||||
const Section* section = fSectionAndParameterHelper.getSection(kConstructorParamsSection);
|
||||
if (section) {
|
||||
skstd::string_view s = section->text();
|
||||
#define BUFFER_SIZE 64
|
||||
char lastIdentifier[BUFFER_SIZE];
|
||||
int lastIdentifierLength = 0;
|
||||
bool foundBreak = false;
|
||||
for (auto iter = s.begin(); iter != s.end(); ++iter) {
|
||||
char c = *iter;
|
||||
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
|
||||
c == '_') {
|
||||
if (foundBreak) {
|
||||
lastIdentifierLength = 0;
|
||||
foundBreak = false;
|
||||
}
|
||||
SkASSERT(lastIdentifierLength < BUFFER_SIZE);
|
||||
lastIdentifier[lastIdentifierLength] = c;
|
||||
++lastIdentifierLength;
|
||||
} else {
|
||||
foundBreak = true;
|
||||
if (c == ',') {
|
||||
SkASSERT(lastIdentifierLength < BUFFER_SIZE);
|
||||
lastIdentifier[lastIdentifierLength] = 0;
|
||||
this->writef("%s%s", separator, lastIdentifier);
|
||||
separator = ", ";
|
||||
} else if (c != ' ' && c != '\t' && c != '\n' && c != '\r') {
|
||||
lastIdentifierLength = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lastIdentifierLength) {
|
||||
SkASSERT(lastIdentifierLength < BUFFER_SIZE);
|
||||
lastIdentifier[lastIdentifierLength] = 0;
|
||||
this->writef("%s%s", separator, lastIdentifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HCodeGenerator::writeMake() {
|
||||
const char* separator;
|
||||
if (!this->writeSection(kMakeSection)) {
|
||||
this->writef(" static std::unique_ptr<GrFragmentProcessor> Make(");
|
||||
separator = "";
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
this->writef("%s%s %s", separator, ParameterType(fContext, param->type(),
|
||||
param->modifiers().fLayout).c_str(),
|
||||
String(param->name()).c_str());
|
||||
separator = ", ";
|
||||
}
|
||||
this->writeSection(kConstructorParamsSection, separator);
|
||||
this->writef(") {\n"
|
||||
" return std::unique_ptr<GrFragmentProcessor>(new %s(",
|
||||
fFullName.c_str());
|
||||
separator = "";
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (param->type().isFragmentProcessor()) {
|
||||
this->writef("%sstd::move(%s)", separator, String(param->name()).c_str());
|
||||
} else {
|
||||
this->writef("%s%s", separator, String(param->name()).c_str());
|
||||
}
|
||||
separator = ", ";
|
||||
}
|
||||
this->writeExtraConstructorParams(separator);
|
||||
this->writef("));\n"
|
||||
" }\n");
|
||||
}
|
||||
}
|
||||
|
||||
void HCodeGenerator::failOnSection(const char* section, const char* msg) {
|
||||
std::vector<const Section*> s = fSectionAndParameterHelper.getSections(section);
|
||||
if (s.size()) {
|
||||
fErrors.error(s[0]->fOffset, String("@") + section + " " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
void HCodeGenerator::writeConstructor() {
|
||||
if (this->writeSection(kConstructorSection)) {
|
||||
const char* msg = "may not be present when constructor is overridden";
|
||||
this->failOnSection(kConstructorCodeSection, msg);
|
||||
this->failOnSection(kConstructorParamsSection, msg);
|
||||
this->failOnSection(kInitializersSection, msg);
|
||||
this->failOnSection(kOptimizationFlagsSection, msg);
|
||||
return;
|
||||
}
|
||||
this->writef(" %s(", fFullName.c_str());
|
||||
const char* separator = "";
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
this->writef("%s%s %s", separator, ParameterType(fContext, param->type(),
|
||||
param->modifiers().fLayout).c_str(),
|
||||
String(param->name()).c_str());
|
||||
separator = ", ";
|
||||
}
|
||||
this->writeSection(kConstructorParamsSection, separator);
|
||||
this->writef(")\n"
|
||||
" : INHERITED(k%s_ClassID", fFullName.c_str());
|
||||
if (!this->writeSection(kOptimizationFlagsSection, ", (OptimizationFlags) ")) {
|
||||
this->writef(", kNone_OptimizationFlags");
|
||||
}
|
||||
this->writef(")");
|
||||
this->writeSection(kInitializersSection, "\n , ");
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String nameString(param->name());
|
||||
const char* name = nameString.c_str();
|
||||
const Type& type = param->type();
|
||||
if (type.isFragmentProcessor()) {
|
||||
// do nothing
|
||||
} else {
|
||||
this->writef("\n , %s(%s)", FieldName(name).c_str(), name);
|
||||
}
|
||||
}
|
||||
this->writef(" {\n");
|
||||
this->writeSection(kConstructorCodeSection);
|
||||
|
||||
if (Analysis::ReferencesSampleCoords(fProgram)) {
|
||||
this->writef(" this->setUsesSampleCoordsDirectly();\n");
|
||||
}
|
||||
|
||||
for (const Variable* param : fSectionAndParameterHelper.getParameters()) {
|
||||
const Type& paramType = param->type();
|
||||
if (paramType.isFragmentProcessor()) {
|
||||
SampleUsage usage = Analysis::GetSampleUsage(fProgram, *param);
|
||||
std::string usageArg = usage.constructor();
|
||||
|
||||
this->writef(" this->registerChild(std::move(%s), %s);\n",
|
||||
String(param->name()).c_str(),
|
||||
usageArg.c_str());
|
||||
}
|
||||
}
|
||||
this->writef(" }\n");
|
||||
}
|
||||
|
||||
void HCodeGenerator::writeFields() {
|
||||
this->writeSection(kFieldsSection);
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String name = FieldName(String(param->name()).c_str());
|
||||
if (param->type().isFragmentProcessor()) {
|
||||
// Don't need to write any fields, FPs are held as children
|
||||
} else {
|
||||
this->writef(" %s %s;\n", FieldType(fContext, param->type(),
|
||||
param->modifiers().fLayout).c_str(),
|
||||
name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String HCodeGenerator::GetHeader(const Program& program, ErrorReporter& errors) {
|
||||
SymbolTable types(&errors, /*builtin=*/true);
|
||||
Parser parser(*program.fSource, types, errors);
|
||||
for (;;) {
|
||||
Token header = parser.nextRawToken();
|
||||
switch (header.fKind) {
|
||||
case Token::Kind::TK_WHITESPACE:
|
||||
break;
|
||||
case Token::Kind::TK_BLOCK_COMMENT:
|
||||
return String(program.fSource->c_str() + header.fOffset, header.fLength);
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool HCodeGenerator::generateCode() {
|
||||
this->writef("%s\n", GetHeader(fProgram, fErrors).c_str());
|
||||
this->writef(kFragmentProcessorHeader, fFullName.c_str());
|
||||
this->writef("#ifndef %s_DEFINED\n"
|
||||
"#define %s_DEFINED\n"
|
||||
"\n"
|
||||
"#include \"include/core/SkM44.h\"\n"
|
||||
"#include \"include/core/SkTypes.h\"\n"
|
||||
"\n",
|
||||
fFullName.c_str(),
|
||||
fFullName.c_str());
|
||||
this->writeSection(kHeaderSection);
|
||||
this->writef("\n"
|
||||
"#include \"src/gpu/GrFragmentProcessor.h\"\n"
|
||||
"\n"
|
||||
"class %s : public GrFragmentProcessor {\n"
|
||||
"public:\n",
|
||||
fFullName.c_str());
|
||||
for (const ProgramElement* p : fProgram.elements()) {
|
||||
if (p->is<Enum>() && !p->as<Enum>().isSharedWithCpp()) {
|
||||
this->writef("%s\n", p->as<Enum>().code().c_str());
|
||||
}
|
||||
}
|
||||
this->writeSection(kClassSection);
|
||||
this->writeMake();
|
||||
this->writef(" %s(const %s& src);\n"
|
||||
" std::unique_ptr<GrFragmentProcessor> clone() const override;\n"
|
||||
" const char* name() const override { return \"%s\"; }\n",
|
||||
fFullName.c_str(), fFullName.c_str(), fName.c_str());
|
||||
this->writeFields();
|
||||
this->writef("private:\n");
|
||||
this->writeConstructor();
|
||||
this->writef(
|
||||
" std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;\n"
|
||||
" void onGetGLSLProcessorKey(const GrShaderCaps&, "
|
||||
"GrProcessorKeyBuilder*) const override;\n"
|
||||
" bool onIsEqual(const GrFragmentProcessor&) const override;\n");
|
||||
this->writef("#if GR_TEST_UTILS\n"
|
||||
" SkString onDumpInfo() const override;\n"
|
||||
"#endif\n"
|
||||
" GR_DECLARE_FRAGMENT_PROCESSOR_TEST\n"
|
||||
" using INHERITED = GrFragmentProcessor;\n"
|
||||
"};\n");
|
||||
this->writeSection(kHeaderEndSection);
|
||||
this->writef("#endif\n");
|
||||
return 0 == fErrors.errorCount();
|
||||
}
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif // defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SKSL_HCODEGENERATOR
|
||||
#define SKSL_HCODEGENERATOR
|
||||
|
||||
#include "src/sksl/codegen/SkSLCodeGenerator.h"
|
||||
|
||||
#include "src/sksl/SkSLSectionAndParameterHelper.h"
|
||||
#include "src/sksl/ir/SkSLType.h"
|
||||
#include "src/sksl/ir/SkSLVariable.h"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
#if defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
constexpr const char* kFragmentProcessorHeader =
|
||||
R"(
|
||||
/**************************************************************************************************
|
||||
*** This file was autogenerated from %s.fp; do not modify.
|
||||
**************************************************************************************************/
|
||||
)";
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
class HCodeGenerator : public CodeGenerator {
|
||||
public:
|
||||
HCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors,
|
||||
String name, OutputStream* out);
|
||||
|
||||
bool generateCode() override;
|
||||
|
||||
static String ParameterType(const Context& context, const Type& type, const Layout& layout);
|
||||
|
||||
static Layout::CType ParameterCType(const Context& context, const Type& type,
|
||||
const Layout& layout);
|
||||
|
||||
static String FieldType(const Context& context, const Type& type, const Layout& layout);
|
||||
|
||||
// Either the field type, or a const reference of the field type if the field type is complex.
|
||||
static String AccessType(const Context& context, const Type& type, const Layout& layout);
|
||||
|
||||
static String FieldName(const char* varName) {
|
||||
return String(varName);
|
||||
}
|
||||
|
||||
static String CoordTransformName(const String& arg, int index) {
|
||||
if (arg.size()) {
|
||||
return HCodeGenerator::FieldName(arg.c_str()) + "CoordTransform";
|
||||
}
|
||||
return "fCoordTransform" + to_string(index);
|
||||
}
|
||||
|
||||
static String GetHeader(const Program& program, ErrorReporter& errors);
|
||||
|
||||
private:
|
||||
void writef(const char* s, va_list va) SK_PRINTF_LIKE(2, 0);
|
||||
|
||||
void writef(const char* s, ...) SK_PRINTF_LIKE(2, 3);
|
||||
|
||||
bool writeSection(const char* name, const char* prefix = "");
|
||||
|
||||
// given a @constructorParams section of e.g. 'int x, float y', writes out "<separator>x, y".
|
||||
// Writes nothing (not even the separator) if there is no @constructorParams section.
|
||||
void writeExtraConstructorParams(const char* separator);
|
||||
|
||||
void writeMake();
|
||||
|
||||
void writeConstructor();
|
||||
|
||||
void writeFields();
|
||||
|
||||
void failOnSection(const char* section, const char* msg);
|
||||
|
||||
const Context& fContext;
|
||||
String fName;
|
||||
String fFullName;
|
||||
SectionAndParameterHelper fSectionAndParameterHelper;
|
||||
|
||||
using INHERITED = CodeGenerator;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif // defined(SKSL_STANDALONE) || GR_TEST_UTILS
|
||||
|
||||
#endif // SKSL_HCODEGENERATOR
|
@ -361,7 +361,6 @@ void PipelineStageCodeGenerator::writeProgramElement(const ProgramElement& e) {
|
||||
case ProgramElement::Kind::kExtension:
|
||||
case ProgramElement::Kind::kInterfaceBlock:
|
||||
case ProgramElement::Kind::kModifiers:
|
||||
case ProgramElement::Kind::kSection:
|
||||
default:
|
||||
SkDEBUGFAILF("unsupported program element %s\n", e.description().c_str());
|
||||
break;
|
||||
|
@ -3051,9 +3051,7 @@ SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf, bool a
|
||||
/*inputAttachmentIndex=*/-1,
|
||||
Layout::kUnspecified_Primitive,
|
||||
/*maxVertices=*/1,
|
||||
/*invocations=*/-1,
|
||||
/*when=*/"",
|
||||
Layout::CType::kDefault),
|
||||
/*invocations=*/-1),
|
||||
/*flags=*/0),
|
||||
SKSL_RTFLIP_NAME,
|
||||
fContext.fTypes.fFloat2.get());
|
||||
@ -3590,9 +3588,7 @@ void SPIRVCodeGenerator::addRTFlipUniform(int offset) {
|
||||
/*inputAttachmentIndex=*/-1,
|
||||
Layout::kUnspecified_Primitive,
|
||||
/*maxVertices=*/1,
|
||||
/*invocations=*/-1,
|
||||
/*when=*/"",
|
||||
Layout::CType::kDefault),
|
||||
/*invocations=*/-1),
|
||||
/*flags=*/0),
|
||||
SKSL_RTFLIP_NAME,
|
||||
fContext.fTypes.fFloat2.get());
|
||||
@ -3622,9 +3618,7 @@ void SPIRVCodeGenerator::addRTFlipUniform(int offset) {
|
||||
/*inputAttachmentIndex=*/-1,
|
||||
Layout::kUnspecified_Primitive,
|
||||
/*maxVertices=*/-1,
|
||||
/*invocations=*/-1,
|
||||
/*when=*/"",
|
||||
Layout::CType::kDefault),
|
||||
/*invocations=*/-1),
|
||||
Modifiers::kUniform_Flag);
|
||||
const Modifiers* modsPtr = fProgram.fModifiers->add(modifiers);
|
||||
if (fProgram.fPool) {
|
||||
|
@ -47,12 +47,11 @@ void DSLFunction::init(const DSLType& returnType, skstd::string_view name,
|
||||
SkSL::ProgramKind kind = DSLWriter::Context().fConfig->fKind;
|
||||
if (isMain && (kind == ProgramKind::kRuntimeColorFilter ||
|
||||
kind == ProgramKind::kRuntimeShader ||
|
||||
kind == ProgramKind::kRuntimeBlender ||
|
||||
kind == ProgramKind::kFragmentProcessor)) {
|
||||
kind == ProgramKind::kRuntimeBlender)) {
|
||||
const SkSL::Type& type = param->fType.skslType();
|
||||
// We verify that the signature is fully correct later. For now, if this is an .fp
|
||||
// or runtime effect of any flavor, a float2 param is supposed to be the coords, and
|
||||
// a half4/float parameter is supposed to be the input or destination color:
|
||||
// We verify that the signature is fully correct later. For now, if this is a runtime
|
||||
// effect of any flavor, a float2 param is supposed to be the coords, and a half4/float
|
||||
// parameter is supposed to be the input or destination color:
|
||||
if (type == *DSLWriter::Context().fTypes.fFloat2) {
|
||||
param->fModifiers.fModifiers.fLayout.fBuiltin = SK_MAIN_COORDS_BUILTIN;
|
||||
} else if (typeIsValidForColor(type)) {
|
||||
|
@ -123,8 +123,6 @@ const SkSL::Type& DSLType::skslType() const {
|
||||
return *context.fTypes.fFloat3;
|
||||
case kFloat4_Type:
|
||||
return *context.fTypes.fFloat4;
|
||||
case kFragmentProcessor_Type:
|
||||
return *context.fTypes.fFragmentProcessor;
|
||||
case kFloat2x2_Type:
|
||||
return *context.fTypes.fFloat2x2;
|
||||
case kFloat3x2_Type:
|
||||
|
@ -39,8 +39,7 @@ DSLVar::DSLVar(const char* name)
|
||||
/*binding=*/-1, /*index=*/-1, /*set=*/-1,
|
||||
SK_MAIN_COORDS_BUILTIN, /*inputAttachmentIndex=*/-1,
|
||||
Layout::kUnspecified_Primitive, /*maxVertices=*/1,
|
||||
/*invocations=*/-1, /*when=*/"",
|
||||
Layout::CType::kDefault),
|
||||
/*invocations=*/-1),
|
||||
SkSL::Modifiers::kNo_Flag));
|
||||
|
||||
fVar = DSLWriter::SymbolTable()->takeOwnershipOfIRNode(std::make_unique<SkSL::Variable>(
|
||||
|
@ -1,150 +0,0 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_fp[] = {220,0,
|
||||
14,71,114,67,108,105,112,69,100,103,101,84,121,112,101,
|
||||
0,
|
||||
12,115,107,95,70,114,97,103,67,111,111,114,100,
|
||||
6,102,108,111,97,116,52,
|
||||
15,103,108,95,76,97,115,116,70,114,97,103,68,97,116,97,
|
||||
16,103,108,95,76,97,115,116,70,114,97,103,67,111,108,111,114,
|
||||
5,104,97,108,102,52,
|
||||
19,103,108,95,76,97,115,116,70,114,97,103,67,111,108,111,114,65,82,77,
|
||||
24,103,108,95,83,101,99,111,110,100,97,114,121,70,114,97,103,67,111,108,111,114,69,88,84,
|
||||
2,102,112,
|
||||
17,102,114,97,103,109,101,110,116,80,114,111,99,101,115,115,111,114,
|
||||
6,115,97,109,112,108,101,
|
||||
6,99,111,111,114,100,115,
|
||||
6,102,108,111,97,116,50,
|
||||
5,105,110,112,117,116,
|
||||
7,107,70,105,108,108,66,87,
|
||||
7,107,70,105,108,108,65,65,
|
||||
14,107,73,110,118,101,114,115,101,70,105,108,108,66,87,
|
||||
14,107,73,110,118,101,114,115,101,70,105,108,108,65,65,
|
||||
5,107,76,97,115,116,
|
||||
49,22,0,
|
||||
22,1,0,2,0,
|
||||
53,2,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,15,0,255,255,255,255,17,0,0,2,18,0,
|
||||
50,3,0,31,0,0,
|
||||
0,4,0,
|
||||
47,3,0,1,
|
||||
53,5,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,15,39,255,255,255,255,17,0,0,0,38,0,
|
||||
47,4,0,0,
|
||||
53,6,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,15,39,255,255,255,255,17,0,0,0,54,0,
|
||||
50,7,0,71,0,0,
|
||||
53,8,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,15,39,255,255,255,255,17,0,0,0,77,0,
|
||||
47,7,0,0,
|
||||
53,9,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,15,39,255,255,255,255,17,0,0,0,97,0,
|
||||
47,7,0,0,
|
||||
53,10,0,
|
||||
16,122,0,
|
||||
50,11,0,125,0,3,
|
||||
30,12,0,
|
||||
16,143,0,1,10,0,
|
||||
47,7,0,
|
||||
53,13,0,
|
||||
16,122,0,
|
||||
47,11,0,3,
|
||||
53,14,0,
|
||||
16,150,0,
|
||||
50,15,0,157,0,3,
|
||||
52,16,0,2,
|
||||
47,12,0,
|
||||
30,17,0,
|
||||
16,143,0,2,13,0,14,0,
|
||||
47,7,0,
|
||||
47,17,0,
|
||||
53,18,0,
|
||||
16,122,0,
|
||||
47,11,0,3,
|
||||
53,19,0,
|
||||
16,164,0,
|
||||
47,7,0,3,
|
||||
52,20,0,3,
|
||||
47,12,0,
|
||||
47,17,0,
|
||||
30,21,0,
|
||||
16,143,0,2,18,0,19,0,
|
||||
47,7,0,
|
||||
47,21,0,
|
||||
53,22,0,
|
||||
16,122,0,
|
||||
47,11,0,3,
|
||||
53,23,0,
|
||||
16,150,0,
|
||||
47,15,0,3,
|
||||
53,24,0,
|
||||
16,164,0,
|
||||
47,7,0,3,
|
||||
52,25,0,4,
|
||||
47,12,0,
|
||||
47,17,0,
|
||||
47,21,0,
|
||||
30,26,0,
|
||||
16,143,0,3,22,0,23,0,24,0,
|
||||
47,7,0,
|
||||
47,26,0,7,0,
|
||||
0,0,
|
||||
4,0,
|
||||
5,0,
|
||||
3,0,
|
||||
6,0,
|
||||
20,0,
|
||||
1,0,
|
||||
19,
|
||||
21,2,0,
|
||||
49,5,0,
|
||||
53,27,0,
|
||||
37,
|
||||
15,1,170,0,
|
||||
47,1,0,0,
|
||||
53,28,0,
|
||||
37,
|
||||
15,1,178,0,
|
||||
47,1,0,0,
|
||||
53,29,0,
|
||||
37,
|
||||
15,1,186,0,
|
||||
47,1,0,0,
|
||||
53,30,0,
|
||||
37,
|
||||
15,1,201,0,
|
||||
47,1,0,0,
|
||||
53,31,0,
|
||||
37,
|
||||
15,1,216,0,
|
||||
47,1,0,0,5,0,
|
||||
1,0,
|
||||
0,0,
|
||||
3,0,
|
||||
2,0,
|
||||
4,0,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,
|
||||
55,
|
||||
54,2,0,
|
||||
47,3,0,0,
|
||||
57,
|
||||
55,
|
||||
54,5,0,
|
||||
47,3,0,1,
|
||||
57,
|
||||
55,
|
||||
54,6,0,
|
||||
47,7,0,0,
|
||||
57,
|
||||
55,
|
||||
54,8,0,
|
||||
47,7,0,0,
|
||||
57,
|
||||
55,
|
||||
54,9,0,
|
||||
47,7,0,0,
|
||||
57,
|
||||
20,};
|
||||
static constexpr size_t SKSL_INCLUDE_sksl_fp_LENGTH = sizeof(SKSL_INCLUDE_sksl_fp);
|
@ -1,5 +1,4 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_frag[] = {100,0,
|
||||
0,
|
||||
static uint8_t SKSL_INCLUDE_sksl_frag[] = {99,0,
|
||||
12,115,107,95,70,114,97,103,67,111,111,114,100,
|
||||
6,102,108,111,97,116,52,
|
||||
12,115,107,95,67,108,111,99,107,119,105,115,101,
|
||||
@ -11,23 +10,23 @@ static uint8_t SKSL_INCLUDE_sksl_frag[] = {100,0,
|
||||
49,5,0,
|
||||
53,1,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,15,0,255,255,255,255,2,0,0,2,3,0,
|
||||
50,2,0,16,0,0,
|
||||
36,0,2,0,0,255,255,255,255,255,15,0,255,255,255,255,2,2,0,
|
||||
50,2,0,15,0,0,
|
||||
53,3,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,17,0,255,255,255,255,2,0,0,2,23,0,
|
||||
50,4,0,36,0,0,
|
||||
36,0,2,0,0,255,255,255,255,255,17,0,255,255,255,255,2,22,0,
|
||||
50,4,0,35,0,0,
|
||||
53,5,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,15,39,255,255,255,255,2,0,0,4,41,0,
|
||||
50,6,0,66,0,0,
|
||||
36,0,2,0,0,255,255,255,255,255,15,39,255,255,255,255,4,40,0,
|
||||
50,6,0,65,0,0,
|
||||
53,7,0,
|
||||
37,
|
||||
36,32,5,0,0,0,255,255,0,255,17,39,255,255,255,255,2,0,0,4,72,0,
|
||||
36,144,2,0,0,0,255,255,0,255,17,39,255,255,255,255,4,71,0,
|
||||
47,6,0,0,
|
||||
53,8,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,24,39,255,255,255,255,2,0,0,0,85,0,
|
||||
36,0,2,0,0,255,255,255,255,255,24,39,255,255,255,255,0,84,0,
|
||||
47,6,0,0,5,0,
|
||||
2,0,
|
||||
1,0,
|
||||
|
@ -1,6 +1,5 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_geom[] = {134,0,
|
||||
12,115,107,95,80,101,114,86,101,114,116,101,120,
|
||||
0,
|
||||
11,115,107,95,80,111,115,105,116,105,111,110,
|
||||
6,102,108,111,97,116,52,
|
||||
12,115,107,95,80,111,105,110,116,83,105,122,101,
|
||||
@ -13,53 +12,54 @@ static uint8_t SKSL_INCLUDE_sksl_geom[] = {134,0,
|
||||
18,69,110,100,83,116,114,101,97,109,80,114,105,109,105,116,105,118,101,
|
||||
10,69,109,105,116,86,101,114,116,101,120,
|
||||
12,69,110,100,80,114,105,109,105,116,105,118,101,
|
||||
0,
|
||||
49,12,0,
|
||||
44,1,0,2,0,2,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,0,0,255,255,255,255,15,0,0,0,16,0,
|
||||
50,2,0,28,0,
|
||||
36,0,2,0,0,255,255,255,255,255,0,0,255,255,255,255,0,15,0,
|
||||
50,2,0,27,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,1,0,255,255,255,255,15,0,0,0,35,0,
|
||||
50,3,0,48,0,
|
||||
36,0,2,0,0,255,255,255,255,255,1,0,255,255,255,255,0,34,0,
|
||||
50,3,0,47,0,
|
||||
53,4,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,18,39,255,255,255,255,15,0,0,2,54,0,
|
||||
36,0,2,0,0,255,255,255,255,255,18,39,255,255,255,255,2,53,0,
|
||||
0,5,0,
|
||||
47,1,0,255,0,
|
||||
44,6,0,2,0,2,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,0,0,255,255,255,255,15,0,0,0,16,0,
|
||||
36,0,2,0,0,255,255,255,255,255,0,0,255,255,255,255,0,15,0,
|
||||
47,2,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,1,0,255,255,255,255,15,0,0,0,35,0,
|
||||
36,0,2,0,0,255,255,255,255,255,1,0,255,255,255,255,0,34,0,
|
||||
47,3,0,
|
||||
53,7,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,23,39,255,255,255,255,15,0,0,4,2,0,
|
||||
36,0,2,0,0,255,255,255,255,255,23,39,255,255,255,255,4,2,0,
|
||||
47,6,0,0,
|
||||
24,7,0,0,
|
||||
24,7,0,1,
|
||||
53,8,0,
|
||||
16,60,0,
|
||||
50,9,0,67,0,3,
|
||||
16,59,0,
|
||||
50,9,0,66,0,3,
|
||||
30,10,0,
|
||||
37,
|
||||
15,64,71,0,1,8,0,
|
||||
50,11,0,88,0,
|
||||
15,64,70,0,1,8,0,
|
||||
50,11,0,87,0,
|
||||
53,12,0,
|
||||
16,60,0,
|
||||
16,59,0,
|
||||
47,9,0,3,
|
||||
30,13,0,
|
||||
37,
|
||||
15,64,93,0,1,12,0,
|
||||
15,64,92,0,1,12,0,
|
||||
47,11,0,
|
||||
30,14,0,
|
||||
37,
|
||||
15,64,112,0,0,
|
||||
15,64,111,0,0,
|
||||
47,11,0,
|
||||
30,15,0,
|
||||
37,
|
||||
15,64,123,0,0,
|
||||
15,64,122,0,0,
|
||||
47,11,0,7,0,
|
||||
7,0,
|
||||
10,0,
|
||||
@ -70,8 +70,8 @@ static uint8_t SKSL_INCLUDE_sksl_geom[] = {134,0,
|
||||
1,0,
|
||||
19,
|
||||
34,
|
||||
47,4,0,2,0,54,0,255,
|
||||
47,4,0,2,0,53,0,255,
|
||||
34,
|
||||
47,7,0,2,0,15,0,0,
|
||||
47,7,0,2,0,135,0,0,
|
||||
20,};
|
||||
static constexpr size_t SKSL_INCLUDE_sksl_geom_LENGTH = sizeof(SKSL_INCLUDE_sksl_geom);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1327,7 +1327,7 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {4,2,
|
||||
47,139,1,2,
|
||||
1,
|
||||
46,
|
||||
56,138,1,0,3,0,1,2,49,
|
||||
56,138,1,0,3,0,1,2,48,
|
||||
28,
|
||||
47,123,0,155,0,2,
|
||||
46,
|
||||
@ -1344,7 +1344,7 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {4,2,
|
||||
47,142,1,2,
|
||||
1,
|
||||
46,
|
||||
56,141,1,0,3,0,1,2,49,
|
||||
56,141,1,0,3,0,1,2,48,
|
||||
28,
|
||||
47,115,0,147,0,2,
|
||||
46,
|
||||
|
@ -1,5 +1,4 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_rt_shader[] = {77,0,
|
||||
0,
|
||||
static uint8_t SKSL_INCLUDE_sksl_rt_shader[] = {76,0,
|
||||
12,115,107,95,70,114,97,103,67,111,111,114,100,
|
||||
6,102,108,111,97,116,52,
|
||||
1,115,
|
||||
@ -14,27 +13,27 @@ static uint8_t SKSL_INCLUDE_sksl_rt_shader[] = {77,0,
|
||||
49,8,0,
|
||||
53,1,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,15,0,255,255,255,255,2,0,0,0,3,0,
|
||||
50,2,0,16,0,0,
|
||||
36,0,2,0,0,255,255,255,255,255,15,0,255,255,255,255,0,2,0,
|
||||
50,2,0,15,0,0,
|
||||
53,3,0,
|
||||
16,23,0,
|
||||
50,4,0,25,0,3,
|
||||
16,22,0,
|
||||
50,4,0,24,0,3,
|
||||
53,5,0,
|
||||
16,32,0,
|
||||
50,6,0,39,0,3,
|
||||
16,31,0,
|
||||
50,6,0,38,0,3,
|
||||
30,7,0,
|
||||
16,46,0,2,3,0,5,0,
|
||||
50,8,0,53,0,
|
||||
16,45,0,2,3,0,5,0,
|
||||
50,8,0,52,0,
|
||||
53,9,0,
|
||||
16,59,0,
|
||||
50,10,0,61,0,3,
|
||||
16,58,0,
|
||||
50,10,0,60,0,3,
|
||||
53,11,0,
|
||||
16,73,0,
|
||||
16,72,0,
|
||||
47,8,0,3,
|
||||
52,12,0,2,
|
||||
47,7,0,
|
||||
30,13,0,
|
||||
16,46,0,2,9,0,11,0,
|
||||
16,45,0,2,9,0,11,0,
|
||||
47,8,0,
|
||||
47,13,0,2,0,
|
||||
6,0,
|
||||
|
@ -1,6 +1,5 @@
|
||||
static uint8_t SKSL_INCLUDE_sksl_vert[] = {82,0,
|
||||
12,115,107,95,80,101,114,86,101,114,116,101,120,
|
||||
0,
|
||||
11,115,107,95,80,111,115,105,116,105,111,110,
|
||||
6,102,108,111,97,116,52,
|
||||
12,115,107,95,80,111,105,110,116,83,105,122,101,
|
||||
@ -8,14 +7,15 @@ static uint8_t SKSL_INCLUDE_sksl_vert[] = {82,0,
|
||||
11,115,107,95,86,101,114,116,101,120,73,68,
|
||||
3,105,110,116,
|
||||
13,115,107,95,73,110,115,116,97,110,99,101,73,68,
|
||||
0,
|
||||
49,6,0,
|
||||
44,1,0,2,0,2,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,0,0,255,255,255,255,15,0,0,0,16,0,
|
||||
50,2,0,28,0,
|
||||
36,0,2,0,0,255,255,255,255,255,0,0,255,255,255,255,0,15,0,
|
||||
50,2,0,27,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,1,0,255,255,255,255,15,0,0,0,35,0,
|
||||
50,3,0,48,0,
|
||||
36,0,2,0,0,255,255,255,255,255,1,0,255,255,255,255,0,34,0,
|
||||
50,3,0,47,0,
|
||||
53,4,0,
|
||||
37,
|
||||
15,4,2,0,
|
||||
@ -24,11 +24,11 @@ static uint8_t SKSL_INCLUDE_sksl_vert[] = {82,0,
|
||||
24,4,0,1,
|
||||
53,5,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,42,0,255,255,255,255,15,0,0,2,54,0,
|
||||
50,6,0,66,0,0,
|
||||
36,0,2,0,0,255,255,255,255,255,42,0,255,255,255,255,2,53,0,
|
||||
50,6,0,65,0,0,
|
||||
53,7,0,
|
||||
37,
|
||||
36,0,4,0,0,255,255,255,255,255,43,0,255,255,255,255,15,0,0,2,70,0,
|
||||
36,0,2,0,0,255,255,255,255,255,43,0,255,255,255,255,2,69,0,
|
||||
47,6,0,0,4,0,
|
||||
5,0,
|
||||
3,0,
|
||||
@ -36,7 +36,7 @@ static uint8_t SKSL_INCLUDE_sksl_vert[] = {82,0,
|
||||
4,0,
|
||||
19,
|
||||
34,
|
||||
47,4,0,2,0,15,0,0,
|
||||
47,4,0,2,0,83,0,0,
|
||||
55,
|
||||
54,5,0,
|
||||
47,6,0,0,
|
||||
|
@ -82,7 +82,7 @@ static bool check_parameters(const Context& context,
|
||||
// Only the (builtin) declarations of 'sample' are allowed to have shader/colorFilter or FP
|
||||
// parameters. You can pass other opaque types to functions safely; this restriction is
|
||||
// specific to "child" objects.
|
||||
if ((type.isEffectChild() || type.isFragmentProcessor()) && !isBuiltin) {
|
||||
if (type.isEffectChild() && !isBuiltin) {
|
||||
context.fErrors.error(param->fOffset, "parameters of type '" + type.displayName() +
|
||||
"' not allowed");
|
||||
return false;
|
||||
@ -92,11 +92,10 @@ static bool check_parameters(const Context& context,
|
||||
ProgramKind kind = context.fConfig->fKind;
|
||||
if (isMain && (kind == ProgramKind::kRuntimeColorFilter ||
|
||||
kind == ProgramKind::kRuntimeShader ||
|
||||
kind == ProgramKind::kRuntimeBlender ||
|
||||
kind == ProgramKind::kFragmentProcessor)) {
|
||||
// We verify that the signature is fully correct later. For now, if this is an .fp or
|
||||
// runtime effect of any flavor, a float2 param is supposed to be the coords, and
|
||||
// a half4/float parameter is supposed to be the input or destination color:
|
||||
kind == ProgramKind::kRuntimeBlender)) {
|
||||
// We verify that the signature is fully correct later. For now, if this is a runtime
|
||||
// effect of any flavor, a float2 param is supposed to be the coords, and a half4/float
|
||||
// parameter is supposed to be the input or destination color:
|
||||
if (type == *context.fTypes.fFloat2) {
|
||||
m.fLayout.fBuiltin = SK_MAIN_COORDS_BUILTIN;
|
||||
} else if (typeIsValidForColor(type) &&
|
||||
@ -193,19 +192,6 @@ static bool check_main_signature(const Context& context, int offset, const Type&
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProgramKind::kFragmentProcessor: {
|
||||
if (returnType != *context.fTypes.fHalf4) {
|
||||
errors.error(offset, ".fp 'main' must return 'half4'");
|
||||
return false;
|
||||
}
|
||||
bool validParams = (parameters.size() == 0) ||
|
||||
(parameters.size() == 1 && paramIsCoords(0));
|
||||
if (!validParams) {
|
||||
errors.error(offset, ".fp 'main' must be declared main() or main(float2)");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProgramKind::kGeneric:
|
||||
// No rules apply here
|
||||
break;
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* 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_SECTION
|
||||
#define SKSL_SECTION
|
||||
|
||||
#include "include/private/SkSLProgramElement.h"
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
/**
|
||||
* A section declaration (e.g. @body { body code here })..
|
||||
*/
|
||||
class Section final : public ProgramElement {
|
||||
public:
|
||||
static constexpr Kind kProgramElementKind = Kind::kSection;
|
||||
|
||||
Section(int offset, skstd::string_view name, skstd::string_view arg, skstd::string_view text)
|
||||
: INHERITED(offset, kProgramElementKind)
|
||||
, fName(name)
|
||||
, fArgument(arg)
|
||||
, fText(text) {}
|
||||
|
||||
skstd::string_view name() const {
|
||||
return fName;
|
||||
}
|
||||
|
||||
skstd::string_view argument() const {
|
||||
return fArgument;
|
||||
}
|
||||
|
||||
skstd::string_view text() const {
|
||||
return fText;
|
||||
}
|
||||
|
||||
std::unique_ptr<ProgramElement> clone() const override {
|
||||
return std::unique_ptr<ProgramElement>(new Section(fOffset, this->name(), this->argument(),
|
||||
this->text()));
|
||||
}
|
||||
|
||||
String description() const override {
|
||||
String result = "@" + this->name();
|
||||
if (this->argument().size()) {
|
||||
result += "(" + this->argument() + ")";
|
||||
}
|
||||
result += " { " + this->text() + " }";
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
skstd::string_view fName;
|
||||
skstd::string_view fArgument;
|
||||
skstd::string_view fText;
|
||||
|
||||
using INHERITED = ProgramElement;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
|
||||
#endif
|
@ -77,7 +77,6 @@ public:
|
||||
enum class TypeKind : int8_t {
|
||||
kArray,
|
||||
kEnum,
|
||||
kFragmentProcessor,
|
||||
kGeneric,
|
||||
kLiteral,
|
||||
kMatrix,
|
||||
@ -286,7 +285,6 @@ public:
|
||||
bool isOpaque() const {
|
||||
switch (fTypeKind) {
|
||||
case TypeKind::kColorFilter:
|
||||
case TypeKind::kFragmentProcessor:
|
||||
case TypeKind::kOther:
|
||||
case TypeKind::kSampler:
|
||||
case TypeKind::kSeparateSampler:
|
||||
@ -381,7 +379,6 @@ public:
|
||||
size_t slotCount() const {
|
||||
switch (this->typeKind()) {
|
||||
case Type::TypeKind::kColorFilter:
|
||||
case Type::TypeKind::kFragmentProcessor:
|
||||
case Type::TypeKind::kGeneric:
|
||||
case Type::TypeKind::kOther:
|
||||
case Type::TypeKind::kSampler:
|
||||
@ -478,10 +475,6 @@ public:
|
||||
return fTypeKind == TypeKind::kEnum;
|
||||
}
|
||||
|
||||
virtual bool isFragmentProcessor() const {
|
||||
return fTypeKind == TypeKind::kFragmentProcessor;
|
||||
}
|
||||
|
||||
// Is this type something that can be bound & sampled from an SkRuntimeEffect?
|
||||
// Includes types that represent stages of the Skia pipeline (colorFilter and shader).
|
||||
bool isEffectChild() const {
|
||||
|
@ -50,7 +50,6 @@ std::unique_ptr<Statement> VarDeclaration::Convert(const Context& context,
|
||||
}
|
||||
if (value) {
|
||||
if (var->storage() == Variable::Storage::kGlobal &&
|
||||
context.fConfig->fKind != ProgramKind::kFragmentProcessor &&
|
||||
!Analysis::IsConstantExpression(*value)) {
|
||||
context.fErrors.error(value->fOffset,
|
||||
"global variable initializer must be a constant expression");
|
||||
@ -99,7 +98,6 @@ std::unique_ptr<Statement> VarDeclaration::Make(const Context& context,
|
||||
Analysis::IsConstantExpression(*value));
|
||||
// global variable initializer must be a constant expression
|
||||
SkASSERT(!(value && var->storage() == Variable::Storage::kGlobal &&
|
||||
context.fConfig->fKind != ProgramKind::kFragmentProcessor &&
|
||||
!Analysis::IsConstantExpression(*value)));
|
||||
// opaque type cannot use initializer expressions
|
||||
SkASSERT(!(value && var->type().isOpaque()));
|
||||
|
@ -43,7 +43,6 @@ ENUM = "enum"
|
||||
CLASS = "class"
|
||||
IDENTIFIER = [a-zA-Z_$]([0-9]|[a-zA-Z_$])*
|
||||
DIRECTIVE = #[a-zA-Z_$]([0-9]|[a-zA-Z_$])*
|
||||
SECTION = @[a-zA-Z_$]([0-9]|[a-zA-Z_$])*
|
||||
LPAREN = "("
|
||||
RPAREN = ")"
|
||||
LBRACE = "{"
|
||||
|
@ -1,19 +0,0 @@
|
||||
# This is the raw input file that (along with GrSharedEnums.h) is used to generate
|
||||
# sksl_fp.sksl.
|
||||
|
||||
// defines built-in interfaces supported by SkiaSL fragment shaders
|
||||
|
||||
layout(builtin=15) in float4 sk_FragCoord;
|
||||
|
||||
// 9999 is a sentinel value that causes us to ignore these declarations, beyond adding them to the
|
||||
// symbol table.
|
||||
layout(builtin=9999) float4 gl_LastFragData[1];
|
||||
layout(builtin=9999) half4 gl_LastFragColor;
|
||||
layout(builtin=9999) half4 gl_LastFragColorARM;
|
||||
layout(builtin=9999) half4 gl_SecondaryFragColorEXT;
|
||||
|
||||
half4 sample(fragmentProcessor fp);
|
||||
half4 sample(fragmentProcessor fp, float2 coords);
|
||||
|
||||
half4 sample(fragmentProcessor fp, half4 input);
|
||||
half4 sample(fragmentProcessor fp, float2 coords, half4 input);
|
@ -158,7 +158,7 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLFlags, r, ctxInfo) {
|
||||
SkSL::ProgramSettings settings;
|
||||
settings.fOptimize = false;
|
||||
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu(), settings,
|
||||
SkSL::ProgramKind::kFragmentProcessor);
|
||||
SkSL::ProgramKind::kFragment);
|
||||
EXPECT_EQUAL(All(GreaterThan(Float4(1), Float4(0))),
|
||||
"all(greaterThan(float4(1.0), float4(0.0)))");
|
||||
}
|
||||
@ -1880,21 +1880,6 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLLayout, r, ctxInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLSampleFragmentProcessor, r, ctxInfo) {
|
||||
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu(), default_settings(),
|
||||
SkSL::ProgramKind::kFragmentProcessor);
|
||||
DSLVar child(kUniform_Modifier, kFragmentProcessor_Type, "child");
|
||||
EXPECT_EQUAL(Sample(child), "sample(child)");
|
||||
EXPECT_EQUAL(Sample(child, Float2(0, 0)), "sample(child, float2(0.0, 0.0))");
|
||||
EXPECT_EQUAL(Sample(child, Half4(1)), "sample(child, half4(1.0))");
|
||||
EXPECT_EQUAL(Sample(child, Float2(0), Half4(1)), "sample(child, float2(0.0), half4(1.0))");
|
||||
|
||||
{
|
||||
ExpectError error(r, "error: no match for sample(fragmentProcessor, bool)\n");
|
||||
Sample(child, true).release();
|
||||
}
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLSampleShader, r, ctxInfo) {
|
||||
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu(), default_settings(),
|
||||
SkSL::ProgramKind::kRuntimeShader);
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020 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/SkSLCompiler.h"
|
||||
#include "src/sksl/SkSLStringStream.h"
|
||||
|
||||
#include "tests/Test.h"
|
||||
|
||||
static void test(skiatest::Reporter* r, const GrShaderCaps& caps, const char* src) {
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fRemoveDeadFunctions = false;
|
||||
SkSL::Compiler compiler(&caps);
|
||||
SkSL::StringStream output;
|
||||
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(
|
||||
SkSL::ProgramKind::kFragmentProcessor,
|
||||
SkSL::String(src),
|
||||
settings);
|
||||
if (!program) {
|
||||
SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
|
||||
return;
|
||||
}
|
||||
REPORTER_ASSERT(r, program);
|
||||
bool success = compiler.toH(*program, "Test", output);
|
||||
if (!success) {
|
||||
SkDebugf("Unexpected error generating .h file for %s\n%s",
|
||||
src, compiler.errorText().c_str());
|
||||
}
|
||||
REPORTER_ASSERT(r, success);
|
||||
output.reset();
|
||||
success = compiler.toCPP(*program, "Test", output);
|
||||
if (!success) {
|
||||
SkDebugf("Unexpected error generating .cpp file for %s\n%s",
|
||||
src, compiler.errorText().c_str());
|
||||
}
|
||||
REPORTER_ASSERT(r, success);
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLFPTestbed, r) {
|
||||
test(r,
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
R"__SkSL__(
|
||||
half4 main(float2 coord) {
|
||||
return half4(0);
|
||||
}
|
||||
)__SkSL__");
|
||||
}
|
@ -13,7 +13,7 @@ error: 4: 'noperspective' is not permitted here
|
||||
error: 4: 'sk_has_side_effects' is not permitted here
|
||||
error: 4: 'inline' is not permitted here
|
||||
error: 4: 'noinline' is not permitted here
|
||||
error: 6: 'in uniform' variables only permitted within fragment processors
|
||||
error: 6: 'in uniform' variables not permitted
|
||||
error: 6: 'sk_has_side_effects' is not permitted here
|
||||
error: 6: 'inline' is not permitted here
|
||||
error: 6: 'noinline' is not permitted here
|
||||
|
@ -1,35 +1,29 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 18: layout qualifier 'origin_upper_left' is not permitted here
|
||||
error: 18: layout qualifier 'push_constant' is not permitted here
|
||||
error: 18: layout qualifier 'blend_support_all_equations' is not permitted here
|
||||
error: 18: layout qualifier 'srgb_unpremul' is not permitted here
|
||||
error: 18: layout qualifier 'key' is not permitted here
|
||||
error: 18: layout qualifier 'location' is not permitted here
|
||||
error: 18: layout qualifier 'offset' is not permitted here
|
||||
error: 18: layout qualifier 'binding' is not permitted here
|
||||
error: 18: layout qualifier 'index' is not permitted here
|
||||
error: 18: layout qualifier 'set' is not permitted here
|
||||
error: 18: layout qualifier 'builtin' is not permitted here
|
||||
error: 18: layout qualifier 'input_attachment_index' is not permitted here
|
||||
error: 18: layout qualifier 'max_vertices' is not permitted here
|
||||
error: 18: layout qualifier 'invocations' is not permitted here
|
||||
error: 18: layout qualifier 'when' is not permitted here
|
||||
error: 18: layout qualifier 'ctype' is not permitted here
|
||||
error: 37: layout qualifier 'origin_upper_left' is not permitted here
|
||||
error: 37: layout qualifier 'push_constant' is not permitted here
|
||||
error: 37: layout qualifier 'blend_support_all_equations' is not permitted here
|
||||
error: 37: layout qualifier 'srgb_unpremul' is not permitted here
|
||||
error: 37: layout qualifier 'key' is not permitted here
|
||||
error: 37: layout qualifier 'location' is not permitted here
|
||||
error: 37: layout qualifier 'offset' is not permitted here
|
||||
error: 37: layout qualifier 'binding' is not permitted here
|
||||
error: 37: layout qualifier 'index' is not permitted here
|
||||
error: 37: layout qualifier 'set' is not permitted here
|
||||
error: 37: layout qualifier 'builtin' is not permitted here
|
||||
error: 37: layout qualifier 'input_attachment_index' is not permitted here
|
||||
error: 37: layout qualifier 'max_vertices' is not permitted here
|
||||
error: 37: layout qualifier 'invocations' is not permitted here
|
||||
error: 37: layout qualifier 'when' is not permitted here
|
||||
error: 37: layout qualifier 'ctype' is not permitted here
|
||||
32 errors
|
||||
error: 15: layout qualifier 'origin_upper_left' is not permitted here
|
||||
error: 15: layout qualifier 'push_constant' is not permitted here
|
||||
error: 15: layout qualifier 'blend_support_all_equations' is not permitted here
|
||||
error: 15: layout qualifier 'srgb_unpremul' is not permitted here
|
||||
error: 15: layout qualifier 'location' is not permitted here
|
||||
error: 15: layout qualifier 'offset' is not permitted here
|
||||
error: 15: layout qualifier 'binding' is not permitted here
|
||||
error: 15: layout qualifier 'index' is not permitted here
|
||||
error: 15: layout qualifier 'set' is not permitted here
|
||||
error: 15: layout qualifier 'builtin' is not permitted here
|
||||
error: 15: layout qualifier 'input_attachment_index' is not permitted here
|
||||
error: 15: layout qualifier 'max_vertices' is not permitted here
|
||||
error: 15: layout qualifier 'invocations' is not permitted here
|
||||
error: 31: layout qualifier 'origin_upper_left' is not permitted here
|
||||
error: 31: layout qualifier 'push_constant' is not permitted here
|
||||
error: 31: layout qualifier 'blend_support_all_equations' is not permitted here
|
||||
error: 31: layout qualifier 'srgb_unpremul' is not permitted here
|
||||
error: 31: layout qualifier 'location' is not permitted here
|
||||
error: 31: layout qualifier 'offset' is not permitted here
|
||||
error: 31: layout qualifier 'binding' is not permitted here
|
||||
error: 31: layout qualifier 'index' is not permitted here
|
||||
error: 31: layout qualifier 'set' is not permitted here
|
||||
error: 31: layout qualifier 'builtin' is not permitted here
|
||||
error: 31: layout qualifier 'input_attachment_index' is not permitted here
|
||||
error: 31: layout qualifier 'max_vertices' is not permitted here
|
||||
error: 31: layout qualifier 'invocations' is not permitted here
|
||||
26 errors
|
||||
|
@ -1,19 +1,16 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 19: layout qualifier 'origin_upper_left' appears more than once
|
||||
error: 20: layout qualifier 'push_constant' appears more than once
|
||||
error: 21: layout qualifier 'blend_support_all_equations' appears more than once
|
||||
error: 22: layout qualifier 'srgb_unpremul' appears more than once
|
||||
error: 23: layout qualifier 'key' appears more than once
|
||||
error: 24: layout qualifier 'location' appears more than once
|
||||
error: 25: layout qualifier 'offset' appears more than once
|
||||
error: 26: layout qualifier 'binding' appears more than once
|
||||
error: 27: layout qualifier 'index' appears more than once
|
||||
error: 28: layout qualifier 'set' appears more than once
|
||||
error: 29: layout qualifier 'builtin' appears more than once
|
||||
error: 30: layout qualifier 'input_attachment_index' appears more than once
|
||||
error: 31: layout qualifier 'max_vertices' appears more than once
|
||||
error: 32: layout qualifier 'invocations' appears more than once
|
||||
error: 33: layout qualifier 'when' appears more than once
|
||||
error: 34: layout qualifier 'ctype' appears more than once
|
||||
16 errors
|
||||
error: 16: layout qualifier 'origin_upper_left' appears more than once
|
||||
error: 17: layout qualifier 'push_constant' appears more than once
|
||||
error: 18: layout qualifier 'blend_support_all_equations' appears more than once
|
||||
error: 19: layout qualifier 'srgb_unpremul' appears more than once
|
||||
error: 20: layout qualifier 'location' appears more than once
|
||||
error: 21: layout qualifier 'offset' appears more than once
|
||||
error: 22: layout qualifier 'binding' appears more than once
|
||||
error: 23: layout qualifier 'index' appears more than once
|
||||
error: 24: layout qualifier 'set' appears more than once
|
||||
error: 25: layout qualifier 'builtin' appears more than once
|
||||
error: 26: layout qualifier 'input_attachment_index' appears more than once
|
||||
error: 27: layout qualifier 'max_vertices' appears more than once
|
||||
error: 28: layout qualifier 'invocations' appears more than once
|
||||
13 errors
|
||||
|
@ -1,4 +1,4 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 4: expected an identifier, but found type 'fragmentProcessor'
|
||||
error: 4: expected an identifier, but found type 'float'
|
||||
1 error
|
||||
|
@ -83,7 +83,6 @@ for file_path in to_rewrite():
|
||||
file_path.endswith('.m') or
|
||||
file_path.endswith('.mm') or
|
||||
file_path.endswith('.inc') or
|
||||
file_path.endswith('.fp') or
|
||||
file_path.endswith('.cc') or
|
||||
file_path.endswith('.cpp')):
|
||||
# Read the whole file into memory.
|
||||
|
Loading…
Reference in New Issue
Block a user