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

Side by Side Diff: src/gpu/glsl/GrGLSLShaderVar.h

Issue 1784023002: Add sampler precision to GrTextureAccess (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_verttex
Patch Set: rebase Created 4 years, 9 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/gpu/glsl/GrGLSLProgramBuilder.cpp ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 GrGLSLShaderVar_DEFINED 8 #ifndef GrGLSLShaderVar_DEFINED
9 #define GrGLSLShaderVar_DEFINED 9 #define GrGLSLShaderVar_DEFINED
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 * Sets as a non-array. 69 * Sets as a non-array.
70 */ 70 */
71 void set(GrSLType type, 71 void set(GrSLType type,
72 TypeModifier typeModifier, 72 TypeModifier typeModifier,
73 const SkString& name, 73 const SkString& name,
74 GrSLPrecision precision = kDefault_GrSLPrecision, 74 GrSLPrecision precision = kDefault_GrSLPrecision,
75 const char* layoutQualifier = nullptr, 75 const char* layoutQualifier = nullptr,
76 const char* extraModifiers = nullptr, 76 const char* extraModifiers = nullptr,
77 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { 77 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
78 SkASSERT(kVoid_GrSLType != type); 78 SkASSERT(kVoid_GrSLType != type);
79 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type)) ; 79 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision (type));
80 INHERITED::set(type, name, typeModifier, precision); 80 INHERITED::set(type, name, typeModifier, precision);
81 fLayoutQualifier = layoutQualifier; 81 fLayoutQualifier = layoutQualifier;
82 if (extraModifiers) { 82 if (extraModifiers) {
83 fExtraModifiers.printf("%s ", extraModifiers); 83 fExtraModifiers.printf("%s ", extraModifiers);
84 } 84 }
85 fUseUniformFloatArrays = useUniformFloatArrays; 85 fUseUniformFloatArrays = useUniformFloatArrays;
86 } 86 }
87 87
88 /** 88 /**
89 * Sets as a non-array. 89 * Sets as a non-array.
90 */ 90 */
91 void set(GrSLType type, 91 void set(GrSLType type,
92 TypeModifier typeModifier, 92 TypeModifier typeModifier,
93 const char* name, 93 const char* name,
94 GrSLPrecision precision = kDefault_GrSLPrecision, 94 GrSLPrecision precision = kDefault_GrSLPrecision,
95 const char* layoutQualifier = nullptr, 95 const char* layoutQualifier = nullptr,
96 const char* extraModifiers = nullptr, 96 const char* extraModifiers = nullptr,
97 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { 97 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
98 SkASSERT(kVoid_GrSLType != type); 98 SkASSERT(kVoid_GrSLType != type);
99 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type)) ; 99 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision (type));
100 INHERITED::set(type, name, typeModifier, precision); 100 INHERITED::set(type, name, typeModifier, precision);
101 fLayoutQualifier = layoutQualifier; 101 fLayoutQualifier = layoutQualifier;
102 if (extraModifiers) { 102 if (extraModifiers) {
103 fExtraModifiers.printf("%s ", extraModifiers); 103 fExtraModifiers.printf("%s ", extraModifiers);
104 } 104 }
105 fUseUniformFloatArrays = useUniformFloatArrays; 105 fUseUniformFloatArrays = useUniformFloatArrays;
106 } 106 }
107 107
108 /** 108 /**
109 * Set all var options 109 * Set all var options
110 */ 110 */
111 void set(GrSLType type, 111 void set(GrSLType type,
112 TypeModifier typeModifier, 112 TypeModifier typeModifier,
113 const SkString& name, 113 const SkString& name,
114 int count, 114 int count,
115 GrSLPrecision precision = kDefault_GrSLPrecision, 115 GrSLPrecision precision = kDefault_GrSLPrecision,
116 const char* layoutQualifier = nullptr, 116 const char* layoutQualifier = nullptr,
117 const char* extraModifiers = nullptr, 117 const char* extraModifiers = nullptr,
118 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { 118 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
119 SkASSERT(kVoid_GrSLType != type); 119 SkASSERT(kVoid_GrSLType != type);
120 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type)) ; 120 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision (type));
121 INHERITED::set(type, name, typeModifier, precision, count); 121 INHERITED::set(type, name, typeModifier, precision, count);
122 fLayoutQualifier = layoutQualifier; 122 fLayoutQualifier = layoutQualifier;
123 if (extraModifiers) { 123 if (extraModifiers) {
124 fExtraModifiers.printf("%s ", extraModifiers); 124 fExtraModifiers.printf("%s ", extraModifiers);
125 } 125 }
126 fUseUniformFloatArrays = useUniformFloatArrays; 126 fUseUniformFloatArrays = useUniformFloatArrays;
127 } 127 }
128 128
129 /** 129 /**
130 * Set all var options 130 * Set all var options
131 */ 131 */
132 void set(GrSLType type, 132 void set(GrSLType type,
133 TypeModifier typeModifier, 133 TypeModifier typeModifier,
134 const char* name, 134 const char* name,
135 int count, 135 int count,
136 GrSLPrecision precision = kDefault_GrSLPrecision, 136 GrSLPrecision precision = kDefault_GrSLPrecision,
137 const char* layoutQualifier = nullptr, 137 const char* layoutQualifier = nullptr,
138 const char* extraModifiers = nullptr, 138 const char* extraModifiers = nullptr,
139 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) { 139 bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
140 SkASSERT(kVoid_GrSLType != type); 140 SkASSERT(kVoid_GrSLType != type);
141 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type)) ; 141 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision (type));
142 INHERITED::set(type, name, typeModifier, precision, count); 142 INHERITED::set(type, name, typeModifier, precision, count);
143 fLayoutQualifier = layoutQualifier; 143 fLayoutQualifier = layoutQualifier;
144 if (extraModifiers) { 144 if (extraModifiers) {
145 fExtraModifiers.printf("%s ", extraModifiers); 145 fExtraModifiers.printf("%s ", extraModifiers);
146 } 146 }
147 fUseUniformFloatArrays = useUniformFloatArrays; 147 fUseUniformFloatArrays = useUniformFloatArrays;
148 } 148 }
149 149
150 /** 150 /**
151 * Set the layout qualifier 151 * Set the layout qualifier
152 */ 152 */
153 void setLayoutQualifier(const char* layoutQualifier) { 153 void setLayoutQualifier(const char* layoutQualifier) {
154 fLayoutQualifier = layoutQualifier; 154 fLayoutQualifier = layoutQualifier;
155 } 155 }
156 156
157 void addModifier(const char* modifier) { 157 void addModifier(const char* modifier) {
158 if (modifier) { 158 if (modifier) {
159 fExtraModifiers.appendf("%s ", modifier); 159 fExtraModifiers.appendf("%s ", modifier);
160 } 160 }
161 } 161 }
162 162
163 /** 163 /**
164 * Write a declaration of this variable to out. 164 * Write a declaration of this variable to out.
165 */ 165 */
166 void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const { 166 void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
167 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsNumeric(fType )); 167 SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecisio n(fType));
168 if (!fLayoutQualifier.isEmpty()) { 168 if (!fLayoutQualifier.isEmpty()) {
169 out->appendf("layout(%s) ", fLayoutQualifier.c_str()); 169 out->appendf("layout(%s) ", fLayoutQualifier.c_str());
170 } 170 }
171 out->append(fExtraModifiers); 171 out->append(fExtraModifiers);
172 if (this->getTypeModifier() != kNone_TypeModifier) { 172 if (this->getTypeModifier() != kNone_TypeModifier) {
173 out->append(TypeModifierString(glslCaps, this->getTypeModifier())); 173 out->append(TypeModifierString(glslCaps, this->getTypeModifier()));
174 out->append(" "); 174 out->append(" ");
175 } 175 }
176 GrSLType effectiveType = this->getType(); 176 GrSLType effectiveType = this->getType();
177 if (effectiveType != kBool_GrSLType) { 177 if (GrSLTypeAcceptsPrecision(effectiveType)) {
178 out->append(PrecisionString(glslCaps, fPrecision)); 178 out->append(PrecisionString(glslCaps, fPrecision));
179 } 179 }
180 if (this->isArray()) { 180 if (this->isArray()) {
181 if (this->isUnsizedArray()) { 181 if (this->isUnsizedArray()) {
182 out->appendf("%s %s[]", 182 out->appendf("%s %s[]",
183 GrGLSLTypeString(effectiveType), 183 GrGLSLTypeString(effectiveType),
184 this->getName().c_str()); 184 this->getName().c_str());
185 } else { 185 } else {
186 SkASSERT(this->getArrayCount() > 0); 186 SkASSERT(this->getArrayCount() > 0);
187 out->appendf("%s %s[%d]", 187 out->appendf("%s %s[%d]",
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 /// support uniform float [] 257 /// support uniform float []
258 bool fUseUniformFloatArrays; 258 bool fUseUniformFloatArrays;
259 259
260 SkString fLayoutQualifier; 260 SkString fLayoutQualifier;
261 SkString fExtraModifiers; 261 SkString fExtraModifiers;
262 262
263 typedef GrShaderVar INHERITED; 263 typedef GrShaderVar INHERITED;
264 }; 264 };
265 265
266 #endif 266 #endif
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLProgramBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698