Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/sksl/ir/SkSLLayout.h

Issue 2187433003: added support for push_constant layout (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: rebased Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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) {}
39 41
40 std::string description() const { 42 std::string description() const {
41 std::string result; 43 std::string result;
42 std::string separator; 44 std::string separator;
43 if (fLocation >= 0) { 45 if (fLocation >= 0) {
44 result += separator + "location = " + to_string(fLocation); 46 result += separator + "location = " + to_string(fLocation);
45 separator = ", "; 47 separator = ", ";
46 } 48 }
47 if (fBinding >= 0) { 49 if (fBinding >= 0) {
48 result += separator + "binding = " + to_string(fBinding); 50 result += separator + "binding = " + to_string(fBinding);
(...skipping 16 matching lines...) Expand all
65 separator = ", "; 67 separator = ", ";
66 } 68 }
67 if (fOverrideCoverage) { 69 if (fOverrideCoverage) {
68 result += separator + "override_coverage"; 70 result += separator + "override_coverage";
69 separator = ", "; 71 separator = ", ";
70 } 72 }
71 if (fBlendSupportAllEquations) { 73 if (fBlendSupportAllEquations) {
72 result += separator + "blend_support_all_equations"; 74 result += separator + "blend_support_all_equations";
73 separator = ", "; 75 separator = ", ";
74 } 76 }
77 if (fBlendSupportAllEquations) {
egdaniel 2016/11/14 18:48:35 dupe of the line above?
78 result += separator + "blend_support_all_equations";
79 separator = ", ";
80 }
81 if (fPushConstant) {
82 result += separator + "push_constant";
83 separator = ", ";
84 }
75 if (result.length() > 0) { 85 if (result.length() > 0) {
76 result = "layout (" + result + ")"; 86 result = "layout (" + result + ")";
77 } 87 }
78 return result; 88 return result;
79 } 89 }
80 90
81 bool operator==(const Layout& other) const { 91 bool operator==(const Layout& other) const {
82 return fLocation == other.fLocation && 92 return fLocation == other.fLocation &&
83 fBinding == other.fBinding && 93 fBinding == other.fBinding &&
84 fIndex == other.fIndex && 94 fIndex == other.fIndex &&
85 fSet == other.fSet && 95 fSet == other.fSet &&
86 fBuiltin == other.fBuiltin && 96 fBuiltin == other.fBuiltin &&
87 fOriginUpperLeft == other.fOriginUpperLeft && 97 fOriginUpperLeft == other.fOriginUpperLeft &&
88 fOverrideCoverage == other.fOverrideCoverage && 98 fOverrideCoverage == other.fOverrideCoverage &&
89 fBlendSupportAllEquations == other.fBlendSupportAllEquations; 99 fBlendSupportAllEquations == other.fBlendSupportAllEquations;
90 } 100 }
91 101
92 bool operator!=(const Layout& other) const { 102 bool operator!=(const Layout& other) const {
93 return !(*this == other); 103 return !(*this == other);
94 } 104 }
95 105
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; 106 int fLocation;
99 int fBinding; 107 int fBinding;
100 int fIndex; 108 int fIndex;
101 int fSet; 109 int fSet;
102 int fBuiltin; 110 int fBuiltin;
111 int fOffset;
103 bool fOriginUpperLeft; 112 bool fOriginUpperLeft;
104 bool fOverrideCoverage; 113 bool fOverrideCoverage;
105 bool fBlendSupportAllEquations; 114 bool fBlendSupportAllEquations;
115 bool fPushConstant;
106 }; 116 };
107 117
108 } // namespace 118 } // namespace
109 119
110 #endif 120 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698