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 , fInputAttachmentIndex(layout.fInputAttachmentIndex) | 25 , fInputAttachmentIndex(layout.fInputAttachmentIndex) |
26 , fOriginUpperLeft(layout.fOriginUpperLeft) | 26 , fOriginUpperLeft(layout.fOriginUpperLeft) |
27 , fOverrideCoverage(layout.fOverrideCoverage) | 27 , fOverrideCoverage(layout.fOverrideCoverage) |
28 , fBlendSupportAllEquations(layout.fBlendSupportAllEquations) | 28 , fBlendSupportAllEquations(layout.fBlendSupportAllEquations) |
29 , fFormat(layout.fFormat) {} | 29 , fFormat(layout.fFormat) |
| 30 , fPushConstant(layout.fPushConstant) {} |
30 | 31 |
31 Layout(int location, int binding, int index, int set, int builtin, int input
AttachmentIndex, | 32 Layout(int location, int binding, int index, int set, int builtin, int input
AttachmentIndex, |
32 bool originUpperLeft, bool overrideCoverage, bool blendSupportAllEqua
tions, | 33 bool originUpperLeft, bool overrideCoverage, bool blendSupportAllEqua
tions, |
33 ASTLayout::Format format) | 34 ASTLayout::Format format, bool pushconstant) |
34 : fLocation(location) | 35 : fLocation(location) |
35 , fBinding(binding) | 36 , fBinding(binding) |
36 , fIndex(index) | 37 , fIndex(index) |
37 , fSet(set) | 38 , fSet(set) |
38 , fBuiltin(builtin) | 39 , fBuiltin(builtin) |
39 , fInputAttachmentIndex(inputAttachmentIndex) | 40 , fInputAttachmentIndex(inputAttachmentIndex) |
40 , fOriginUpperLeft(originUpperLeft) | 41 , fOriginUpperLeft(originUpperLeft) |
41 , fOverrideCoverage(overrideCoverage) | 42 , fOverrideCoverage(overrideCoverage) |
42 , fBlendSupportAllEquations(blendSupportAllEquations) | 43 , fBlendSupportAllEquations(blendSupportAllEquations) |
43 , fFormat(format) {} | 44 , fFormat(format) |
| 45 , fPushConstant(pushconstant) {} |
44 | 46 |
45 Layout() | 47 Layout() |
46 : fLocation(-1) | 48 : fLocation(-1) |
47 , fBinding(-1) | 49 , fBinding(-1) |
48 , fIndex(-1) | 50 , fIndex(-1) |
49 , fSet(-1) | 51 , fSet(-1) |
50 , fBuiltin(-1) | 52 , fBuiltin(-1) |
51 , fInputAttachmentIndex(-1) | 53 , fInputAttachmentIndex(-1) |
52 , fOriginUpperLeft(false) | 54 , fOriginUpperLeft(false) |
53 , fOverrideCoverage(false) | 55 , fOverrideCoverage(false) |
54 , fBlendSupportAllEquations(false) | 56 , fBlendSupportAllEquations(false) |
55 , fFormat(ASTLayout::Format::kUnspecified) {} | 57 , fFormat(ASTLayout::Format::kUnspecified) |
| 58 , fPushConstant(false) {} |
56 | 59 |
57 SkString description() const { | 60 SkString description() const { |
58 SkString result; | 61 SkString result; |
59 SkString separator; | 62 SkString separator; |
60 if (fLocation >= 0) { | 63 if (fLocation >= 0) { |
61 result += separator + "location = " + to_string(fLocation); | 64 result += separator + "location = " + to_string(fLocation); |
62 separator = ", "; | 65 separator = ", "; |
63 } | 66 } |
64 if (fBinding >= 0) { | 67 if (fBinding >= 0) { |
65 result += separator + "binding = " + to_string(fBinding); | 68 result += separator + "binding = " + to_string(fBinding); |
(...skipping 24 matching lines...) Expand all Loading... |
90 separator = ", "; | 93 separator = ", "; |
91 } | 94 } |
92 if (fBlendSupportAllEquations) { | 95 if (fBlendSupportAllEquations) { |
93 result += separator + "blend_support_all_equations"; | 96 result += separator + "blend_support_all_equations"; |
94 separator = ", "; | 97 separator = ", "; |
95 } | 98 } |
96 if (ASTLayout::Format::kUnspecified != fFormat) { | 99 if (ASTLayout::Format::kUnspecified != fFormat) { |
97 result += separator + ASTLayout::FormatToStr(fFormat); | 100 result += separator + ASTLayout::FormatToStr(fFormat); |
98 separator = ", "; | 101 separator = ", "; |
99 } | 102 } |
| 103 if (fPushConstant) { |
| 104 result += separator + "push_constant"; |
| 105 separator = ", "; |
| 106 } |
100 if (result.size() > 0) { | 107 if (result.size() > 0) { |
101 result = "layout (" + result + ")"; | 108 result = "layout (" + result + ")"; |
102 } | 109 } |
103 return result; | 110 return result; |
104 } | 111 } |
105 | 112 |
106 bool operator==(const Layout& other) const { | 113 bool operator==(const Layout& other) const { |
107 return fLocation == other.fLocation && | 114 return fLocation == other.fLocation && |
108 fBinding == other.fBinding && | 115 fBinding == other.fBinding && |
109 fIndex == other.fIndex && | 116 fIndex == other.fIndex && |
(...skipping 17 matching lines...) Expand all Loading... |
127 // builtin comes from SPIR-V and identifies which particular builtin value t
his object | 134 // builtin comes from SPIR-V and identifies which particular builtin value t
his object |
128 // represents. | 135 // represents. |
129 int fBuiltin; | 136 int fBuiltin; |
130 // input_attachment_index comes from Vulkan/SPIR-V to connect a shader varia
ble to the a | 137 // input_attachment_index comes from Vulkan/SPIR-V to connect a shader varia
ble to the a |
131 // corresponding attachment on the subpass in which the shader is being used
. | 138 // corresponding attachment on the subpass in which the shader is being used
. |
132 int fInputAttachmentIndex; | 139 int fInputAttachmentIndex; |
133 bool fOriginUpperLeft; | 140 bool fOriginUpperLeft; |
134 bool fOverrideCoverage; | 141 bool fOverrideCoverage; |
135 bool fBlendSupportAllEquations; | 142 bool fBlendSupportAllEquations; |
136 ASTLayout::Format fFormat; | 143 ASTLayout::Format fFormat; |
| 144 bool fPushConstant; |
137 }; | 145 }; |
138 | 146 |
139 } // namespace | 147 } // namespace |
140 | 148 |
141 #endif | 149 #endif |
OLD | NEW |