OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SKSL_LAYOUT | 8 #ifndef SKSL_LAYOUT |
9 #define SKSL_LAYOUT | 9 #define SKSL_LAYOUT |
10 | 10 |
11 namespace SkSL { | 11 namespace SkSL { |
12 | 12 |
13 /** | 13 /** |
14 * Represents a layout block appearing before a variable declaration, as in: | 14 * Represents a layout block appearing before a variable declaration, as in: |
15 * | 15 * |
16 * layout (location = 0) int x; | 16 * layout (location = 0) int x; |
17 */ | 17 */ |
18 struct Layout { | 18 struct Layout { |
19 Layout(const ASTLayout& layout) | 19 Layout(const ASTLayout& layout) |
20 : fLocation(layout.fLocation) | 20 : fLocation(layout.fLocation) |
21 , fBinding(layout.fBinding) | 21 , fBinding(layout.fBinding) |
22 , fIndex(layout.fIndex) | 22 , fIndex(layout.fIndex) |
23 , fSet(layout.fSet) | 23 , fSet(layout.fSet) |
24 , fBuiltin(layout.fBuiltin) | 24 , fBuiltin(layout.fBuiltin) |
25 , fOriginUpperLeft(layout.fOriginUpperLeft) {} | 25 , fOriginUpperLeft(layout.fOriginUpperLeft) |
| 26 , fOverrideCoverage(layout.fOverrideCoverage) |
| 27 , fBlendSupportAllEquations(layout.fBlendSupportAllEquations) {} |
26 | 28 |
27 Layout(int location, int binding, int index, int set, int builtin, bool orig
inUpperLeft) | 29 Layout(int location, int binding, int index, int set, int builtin, bool orig
inUpperLeft, |
| 30 bool overrideCoverage, bool blendSupportAllEquations) |
28 : fLocation(location) | 31 : fLocation(location) |
29 , fBinding(binding) | 32 , fBinding(binding) |
30 , fIndex(index) | 33 , fIndex(index) |
31 , fSet(set) | 34 , fSet(set) |
32 , fBuiltin(builtin) | 35 , fBuiltin(builtin) |
33 , fOriginUpperLeft(originUpperLeft) {} | 36 , fOriginUpperLeft(originUpperLeft) |
| 37 , fOverrideCoverage(overrideCoverage) |
| 38 , fBlendSupportAllEquations(blendSupportAllEquations) {} |
34 | 39 |
35 std::string description() const { | 40 std::string description() const { |
36 std::string result; | 41 std::string result; |
37 std::string separator; | 42 std::string separator; |
38 if (fLocation >= 0) { | 43 if (fLocation >= 0) { |
39 result += separator + "location = " + to_string(fLocation); | 44 result += separator + "location = " + to_string(fLocation); |
40 separator = ", "; | 45 separator = ", "; |
41 } | 46 } |
42 if (fBinding >= 0) { | 47 if (fBinding >= 0) { |
43 result += separator + "binding = " + to_string(fBinding); | 48 result += separator + "binding = " + to_string(fBinding); |
44 separator = ", "; | 49 separator = ", "; |
45 } | 50 } |
46 if (fIndex >= 0) { | 51 if (fIndex >= 0) { |
47 result += separator + "index = " + to_string(fIndex); | 52 result += separator + "index = " + to_string(fIndex); |
48 separator = ", "; | 53 separator = ", "; |
49 } | 54 } |
50 if (fSet >= 0) { | 55 if (fSet >= 0) { |
51 result += separator + "set = " + to_string(fSet); | 56 result += separator + "set = " + to_string(fSet); |
52 separator = ", "; | 57 separator = ", "; |
53 } | 58 } |
54 if (fBuiltin >= 0) { | 59 if (fBuiltin >= 0) { |
55 result += separator + "builtin = " + to_string(fBuiltin); | 60 result += separator + "builtin = " + to_string(fBuiltin); |
56 separator = ", "; | 61 separator = ", "; |
57 } | 62 } |
58 if (fOriginUpperLeft) { | 63 if (fOriginUpperLeft) { |
59 result += separator + "origin_upper_left"; | 64 result += separator + "origin_upper_left"; |
60 separator = ", "; | 65 separator = ", "; |
61 } | 66 } |
| 67 if (fOverrideCoverage) { |
| 68 result += separator + "override_coverage"; |
| 69 separator = ", "; |
| 70 } |
| 71 if (fBlendSupportAllEquations) { |
| 72 result += separator + "blend_support_all_equations"; |
| 73 separator = ", "; |
| 74 } |
62 if (result.length() > 0) { | 75 if (result.length() > 0) { |
63 result = "layout (" + result + ")"; | 76 result = "layout (" + result + ")"; |
64 } | 77 } |
65 return result; | 78 return result; |
66 } | 79 } |
67 | 80 |
68 bool operator==(const Layout& other) const { | 81 bool operator==(const Layout& other) const { |
69 return fLocation == other.fLocation && | 82 return fLocation == other.fLocation && |
70 fBinding == other.fBinding && | 83 fBinding == other.fBinding && |
71 fIndex == other.fIndex && | 84 fIndex == other.fIndex && |
72 fSet == other.fSet && | 85 fSet == other.fSet && |
73 fBuiltin == other.fBuiltin; | 86 fBuiltin == other.fBuiltin && |
| 87 fOriginUpperLeft == other.fOriginUpperLeft && |
| 88 fOverrideCoverage == other.fOverrideCoverage && |
| 89 fBlendSupportAllEquations == other.fBlendSupportAllEquations; |
74 } | 90 } |
75 | 91 |
76 bool operator!=(const Layout& other) const { | 92 bool operator!=(const Layout& other) const { |
77 return !(*this == other); | 93 return !(*this == other); |
78 } | 94 } |
79 | 95 |
80 // everything but builtin is in the GLSL spec; builtin comes from SPIR-V and
identifies which | 96 // everything but builtin is in the GLSL spec; builtin comes from SPIR-V and
identifies which |
81 // particular builtin value this object represents. | 97 // particular builtin value this object represents. |
82 int fLocation; | 98 int fLocation; |
83 int fBinding; | 99 int fBinding; |
84 int fIndex; | 100 int fIndex; |
85 int fSet; | 101 int fSet; |
86 int fBuiltin; | 102 int fBuiltin; |
87 bool fOriginUpperLeft; | 103 bool fOriginUpperLeft; |
| 104 bool fOverrideCoverage; |
| 105 bool fBlendSupportAllEquations; |
88 }; | 106 }; |
89 | 107 |
90 } // namespace | 108 } // namespace |
91 | 109 |
92 #endif | 110 #endif |
OLD | NEW |