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) | 26 , fOverrideCoverage(layout.fOverrideCoverage) |
27 , fBlendSupportAllEquations(layout.fBlendSupportAllEquations) {} | 27 , fBlendSupportAllEquations(layout.fBlendSupportAllEquations) |
| 28 , fPushConstant(layout.fPushConstant) {} |
28 | 29 |
29 Layout(int location, int binding, int index, int set, int builtin, bool orig
inUpperLeft, | 30 Layout(int location, int binding, int index, int set, int builtin, bool orig
inUpperLeft, |
30 bool overrideCoverage, bool blendSupportAllEquations) | 31 bool overrideCoverage, bool blendSupportAllEquations, bool pushconsta
nt) |
31 : fLocation(location) | 32 : fLocation(location) |
32 , fBinding(binding) | 33 , fBinding(binding) |
33 , fIndex(index) | 34 , fIndex(index) |
34 , fSet(set) | 35 , fSet(set) |
35 , fBuiltin(builtin) | 36 , fBuiltin(builtin) |
36 , fOriginUpperLeft(originUpperLeft) | 37 , fOriginUpperLeft(originUpperLeft) |
37 , fOverrideCoverage(overrideCoverage) | 38 , fOverrideCoverage(overrideCoverage) |
38 , fBlendSupportAllEquations(blendSupportAllEquations) {} | 39 , fBlendSupportAllEquations(blendSupportAllEquations) |
| 40 , fPushConstant(pushconstant) {} |
| 41 |
| 42 Layout() |
| 43 : fLocation(-1) |
| 44 , fBinding(-1) |
| 45 , fIndex(-1) |
| 46 , fSet(-1) |
| 47 , fBuiltin(-1) |
| 48 , fOriginUpperLeft(false) |
| 49 , fOverrideCoverage(false) |
| 50 , fBlendSupportAllEquations(false) |
| 51 , fPushConstant(false) {} |
39 | 52 |
40 std::string description() const { | 53 std::string description() const { |
41 std::string result; | 54 std::string result; |
42 std::string separator; | 55 std::string separator; |
43 if (fLocation >= 0) { | 56 if (fLocation >= 0) { |
44 result += separator + "location = " + to_string(fLocation); | 57 result += separator + "location = " + to_string(fLocation); |
45 separator = ", "; | 58 separator = ", "; |
46 } | 59 } |
47 if (fBinding >= 0) { | 60 if (fBinding >= 0) { |
48 result += separator + "binding = " + to_string(fBinding); | 61 result += separator + "binding = " + to_string(fBinding); |
(...skipping 16 matching lines...) Expand all Loading... |
65 separator = ", "; | 78 separator = ", "; |
66 } | 79 } |
67 if (fOverrideCoverage) { | 80 if (fOverrideCoverage) { |
68 result += separator + "override_coverage"; | 81 result += separator + "override_coverage"; |
69 separator = ", "; | 82 separator = ", "; |
70 } | 83 } |
71 if (fBlendSupportAllEquations) { | 84 if (fBlendSupportAllEquations) { |
72 result += separator + "blend_support_all_equations"; | 85 result += separator + "blend_support_all_equations"; |
73 separator = ", "; | 86 separator = ", "; |
74 } | 87 } |
| 88 if (fPushConstant) { |
| 89 result += separator + "push_constant"; |
| 90 separator = ", "; |
| 91 } |
75 if (result.length() > 0) { | 92 if (result.length() > 0) { |
76 result = "layout (" + result + ")"; | 93 result = "layout (" + result + ")"; |
77 } | 94 } |
78 return result; | 95 return result; |
79 } | 96 } |
80 | 97 |
81 bool operator==(const Layout& other) const { | 98 bool operator==(const Layout& other) const { |
82 return fLocation == other.fLocation && | 99 return fLocation == other.fLocation && |
83 fBinding == other.fBinding && | 100 fBinding == other.fBinding && |
84 fIndex == other.fIndex && | 101 fIndex == other.fIndex && |
85 fSet == other.fSet && | 102 fSet == other.fSet && |
86 fBuiltin == other.fBuiltin && | 103 fBuiltin == other.fBuiltin && |
87 fOriginUpperLeft == other.fOriginUpperLeft && | 104 fOriginUpperLeft == other.fOriginUpperLeft && |
88 fOverrideCoverage == other.fOverrideCoverage && | 105 fOverrideCoverage == other.fOverrideCoverage && |
89 fBlendSupportAllEquations == other.fBlendSupportAllEquations; | 106 fBlendSupportAllEquations == other.fBlendSupportAllEquations; |
90 } | 107 } |
91 | 108 |
92 bool operator!=(const Layout& other) const { | 109 bool operator!=(const Layout& other) const { |
93 return !(*this == other); | 110 return !(*this == other); |
94 } | 111 } |
95 | 112 |
96 // everything but builtin is in the GLSL spec; builtin comes from SPIR-V and
identifies which | |
97 // particular builtin value this object represents. | |
98 int fLocation; | 113 int fLocation; |
99 int fBinding; | 114 int fBinding; |
100 int fIndex; | 115 int fIndex; |
101 int fSet; | 116 int fSet; |
102 int fBuiltin; | 117 int fBuiltin; |
| 118 int fOffset; |
103 bool fOriginUpperLeft; | 119 bool fOriginUpperLeft; |
104 bool fOverrideCoverage; | 120 bool fOverrideCoverage; |
105 bool fBlendSupportAllEquations; | 121 bool fBlendSupportAllEquations; |
| 122 bool fPushConstant; |
106 }; | 123 }; |
107 | 124 |
108 } // namespace | 125 } // namespace |
109 | 126 |
110 #endif | 127 #endif |
OLD | NEW |