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

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

Issue 2185393003: added initial GLSL support to skslc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixed gn build Created 4 years, 4 months 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
« no previous file with comments | « src/sksl/ir/SkSLIntLiteral.h ('k') | src/sksl/ir/SkSLModifiers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 26
26 Layout(int location, int binding, int index, int set, int builtin) 27 Layout(int location, int binding, int index, int set, int builtin, bool orig inUpperLeft)
27 : fLocation(location) 28 : fLocation(location)
28 , fBinding(binding) 29 , fBinding(binding)
29 , fIndex(index) 30 , fIndex(index)
30 , fSet(set) 31 , fSet(set)
31 , fBuiltin(builtin) {} 32 , fBuiltin(builtin)
33 , fOriginUpperLeft(originUpperLeft) {}
32 34
33 std::string description() const { 35 std::string description() const {
34 std::string result; 36 std::string result;
35 std::string separator; 37 std::string separator;
36 if (fLocation >= 0) { 38 if (fLocation >= 0) {
37 result += separator + "location = " + to_string(fLocation); 39 result += separator + "location = " + to_string(fLocation);
38 separator = ", "; 40 separator = ", ";
39 } 41 }
40 if (fBinding >= 0) { 42 if (fBinding >= 0) {
41 result += separator + "binding = " + to_string(fBinding); 43 result += separator + "binding = " + to_string(fBinding);
42 separator = ", "; 44 separator = ", ";
43 } 45 }
44 if (fIndex >= 0) { 46 if (fIndex >= 0) {
45 result += separator + "index = " + to_string(fIndex); 47 result += separator + "index = " + to_string(fIndex);
46 separator = ", "; 48 separator = ", ";
47 } 49 }
48 if (fSet >= 0) { 50 if (fSet >= 0) {
49 result += separator + "set = " + to_string(fSet); 51 result += separator + "set = " + to_string(fSet);
50 separator = ", "; 52 separator = ", ";
51 } 53 }
52 if (fBuiltin >= 0) { 54 if (fBuiltin >= 0) {
53 result += separator + "builtin = " + to_string(fBuiltin); 55 result += separator + "builtin = " + to_string(fBuiltin);
54 separator = ", "; 56 separator = ", ";
55 } 57 }
58 if (fOriginUpperLeft) {
59 result += separator + "origin_upper_left";
60 separator = ", ";
61 }
56 if (result.length() > 0) { 62 if (result.length() > 0) {
57 result = "layout (" + result + ")"; 63 result = "layout (" + result + ")";
58 } 64 }
59 return result; 65 return result;
60 } 66 }
61 67
62 bool operator==(const Layout& other) const { 68 bool operator==(const Layout& other) const {
63 return fLocation == other.fLocation && 69 return fLocation == other.fLocation &&
64 fBinding == other.fBinding && 70 fBinding == other.fBinding &&
65 fIndex == other.fIndex && 71 fIndex == other.fIndex &&
66 fSet == other.fSet && 72 fSet == other.fSet &&
67 fBuiltin == other.fBuiltin; 73 fBuiltin == other.fBuiltin;
68 } 74 }
69 75
70 bool operator!=(const Layout& other) const { 76 bool operator!=(const Layout& other) const {
71 return !(*this == other); 77 return !(*this == other);
72 } 78 }
73 79
74 const int fLocation; 80 // everything but builtin is in the GLSL spec; builtin comes from SPIR-V and identifies which
75 const int fBinding; 81 // particular builtin value this object represents.
76 const int fIndex; 82 int fLocation;
77 const int fSet; 83 int fBinding;
78 const int fBuiltin; 84 int fIndex;
85 int fSet;
86 int fBuiltin;
87 bool fOriginUpperLeft;
79 }; 88 };
80 89
81 } // namespace 90 } // namespace
82 91
83 #endif 92 #endif
OLDNEW
« no previous file with comments | « src/sksl/ir/SkSLIntLiteral.h ('k') | src/sksl/ir/SkSLModifiers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698