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

Side by Side Diff: src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp

Issue 1490283004: Create GLSLUniformHandler class for gpu backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up public api of uniformhandler Created 5 years 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/GrGLSLFragmentProcessor.cpp ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.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 2014 Google Inc. 2 * Copyright 2014 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 #include "GrGLSLFragmentShaderBuilder.h" 8 #include "GrGLSLFragmentShaderBuilder.h"
9 #include "GrRenderTarget.h" 9 #include "GrRenderTarget.h"
10 #include "glsl/GrGLSL.h" 10 #include "glsl/GrGLSL.h"
11 #include "glsl/GrGLSLCaps.h" 11 #include "glsl/GrGLSLCaps.h"
12 #include "glsl/GrGLSLProgramBuilder.h" 12 #include "glsl/GrGLSLProgramBuilder.h"
13 #include "glsl/GrGLSLUniformHandler.h"
13 #include "glsl/GrGLSLVarying.h" 14 #include "glsl/GrGLSLVarying.h"
14 15
15 const char* GrGLSLFragmentShaderBuilder::kDstTextureColorName = "_dstColor"; 16 const char* GrGLSLFragmentShaderBuilder::kDstTextureColorName = "_dstColor";
16 17
17 static const char* specific_layout_qualifier_name(GrBlendEquation equation) { 18 static const char* specific_layout_qualifier_name(GrBlendEquation equation) {
18 SkASSERT(GrBlendEquationIsAdvanced(equation)); 19 SkASSERT(GrBlendEquationIsAdvanced(equation));
19 20
20 static const char* kLayoutQualifierNames[] = { 21 static const char* kLayoutQualifierNames[] = {
21 "blend_support_screen", 22 "blend_support_screen",
22 "blend_support_overlay", 23 "blend_support_overlay",
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 "gl_FragCoord", 130 "gl_FragCoord",
130 kDefault_GrSLPrecision, 131 kDefault_GrSLPrecision,
131 GrGLSLShaderVar::kUpperLeft_Origin); 132 GrGLSLShaderVar::kUpperLeft_Origin);
132 fSetupFragPosition = true; 133 fSetupFragPosition = true;
133 } 134 }
134 return "gl_FragCoord"; 135 return "gl_FragCoord";
135 } else { 136 } else {
136 static const char* kTempName = "tmpXYFragCoord"; 137 static const char* kTempName = "tmpXYFragCoord";
137 static const char* kCoordName = "fragCoordYDown"; 138 static const char* kCoordName = "fragCoordYDown";
138 if (!fSetupFragPosition) { 139 if (!fSetupFragPosition) {
139 SkASSERT(!fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
140 const char* rtHeightName; 140 const char* rtHeightName;
141 141
142 fProgramBuilder->fUniformHandles.fRTHeightUni = 142 fProgramBuilder->addRTHeightUniform("RTHeight", &rtHeightName);
143 fProgramBuilder->addFragPosUniform(GrGLSLProgramBuilder::kFr agment_Visibility,
144 kFloat_GrSLType,
145 kDefault_GrSLPrecision,
146 "RTHeight",
147 &rtHeightName);
148 143
149 // The Adreno compiler seems to be very touchy about access to "gl_F ragCoord". 144 // The Adreno compiler seems to be very touchy about access to "gl_F ragCoord".
150 // Accessing glFragCoord.zw can cause a program to fail to link. Add itionally, 145 // Accessing glFragCoord.zw can cause a program to fail to link. Add itionally,
151 // depending on the surrounding code, accessing .xy with a uniform i nvolved can 146 // depending on the surrounding code, accessing .xy with a uniform i nvolved can
152 // do the same thing. Copying gl_FragCoord.xy into a temp vec2 befor ehand 147 // do the same thing. Copying gl_FragCoord.xy into a temp vec2 befor ehand
153 // (and only accessing .xy) seems to "fix" things. 148 // (and only accessing .xy) seems to "fix" things.
154 this->codePrependf("\tvec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n", 149 this->codePrependf("\tvec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n",
155 kCoordName, kTempName, rtHeightName, kTempName); 150 kCoordName, kTempName, rtHeightName, kTempName);
156 this->codePrependf("vec2 %s = gl_FragCoord.xy;", kTempName); 151 this->codePrependf("vec2 %s = gl_FragCoord.xy;", kTempName);
157 fSetupFragPosition = true; 152 fSetupFragPosition = true;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 248 }
254 249
255 void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() { 250 void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() {
256 SkASSERT(fSubstageIndices.count() >= 2); 251 SkASSERT(fSubstageIndices.count() >= 2);
257 fSubstageIndices.pop_back(); 252 fSubstageIndices.pop_back();
258 fSubstageIndices.back()++; 253 fSubstageIndices.back()++;
259 int removeAt = fMangleString.findLastOf('_'); 254 int removeAt = fMangleString.findLastOf('_');
260 fMangleString.remove(removeAt, fMangleString.size() - removeAt); 255 fMangleString.remove(removeAt, fMangleString.size() - removeAt);
261 } 256 }
262 257
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentProcessor.cpp ('k') | src/gpu/glsl/GrGLSLGeometryProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698