OLD | NEW |
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 "GrGLFragmentShaderBuilder.h" | 8 #include "GrGLFragmentShaderBuilder.h" |
9 #include "GrGLShaderStringBuilder.h" | 9 #include "GrGLShaderStringBuilder.h" |
10 #include "GrGLProgramBuilder.h" | 10 #include "GrGLProgramBuilder.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // We shouldn't have declared outputs on 1.10 | 269 // We shouldn't have declared outputs on 1.10 |
270 SkASSERT(k110_GrGLSLGeneration != gpu->glslGeneration() || fOutputs.empty())
; | 270 SkASSERT(k110_GrGLSLGeneration != gpu->glslGeneration() || fOutputs.empty())
; |
271 this->appendDecls(fOutputs, &fragShaderSrc); | 271 this->appendDecls(fOutputs, &fragShaderSrc); |
272 fragShaderSrc.append(fFunctions); | 272 fragShaderSrc.append(fFunctions); |
273 fragShaderSrc.append("void main() {\n"); | 273 fragShaderSrc.append("void main() {\n"); |
274 fragShaderSrc.append(fCode); | 274 fragShaderSrc.append(fCode); |
275 fragShaderSrc.append("}\n"); | 275 fragShaderSrc.append("}\n"); |
276 | 276 |
277 GrGLuint fragShaderId = GrGLCompileAndAttachShader(gpu->glContext(), program
Id, | 277 GrGLuint fragShaderId = GrGLCompileAndAttachShader(gpu->glContext(), program
Id, |
278 GR_GL_FRAGMENT_SHADER, fr
agShaderSrc, | 278 GR_GL_FRAGMENT_SHADER, fr
agShaderSrc, |
279 gpu->gpuStats()); | 279 gpu->stats()); |
280 if (!fragShaderId) { | 280 if (!fragShaderId) { |
281 return false; | 281 return false; |
282 } | 282 } |
283 | 283 |
284 *shaderIds->append() = fragShaderId; | 284 *shaderIds->append() = fragShaderId; |
285 | 285 |
286 return true; | 286 return true; |
287 } | 287 } |
288 | 288 |
289 void GrGLFragmentShaderBuilder::bindFragmentShaderLocations(GrGLuint programID)
{ | 289 void GrGLFragmentShaderBuilder::bindFragmentShaderLocations(GrGLuint programID)
{ |
290 // ES 3.00 requires custom color output but doesn't support bindFragDataLoca
tion | 290 // ES 3.00 requires custom color output but doesn't support bindFragDataLoca
tion |
291 if (fHasCustomColorOutput && | 291 if (fHasCustomColorOutput && |
292 kGLES_GrGLStandard != fProgramBuilder->gpu()->ctxInfo().standard()) { | 292 kGLES_GrGLStandard != fProgramBuilder->gpu()->ctxInfo().standard()) { |
293 GL_CALL(BindFragDataLocation(programID, 0, declared_color_output_name())
); | 293 GL_CALL(BindFragDataLocation(programID, 0, declared_color_output_name())
); |
294 } | 294 } |
295 if (fHasSecondaryOutput) { | 295 if (fHasSecondaryOutput) { |
296 GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, dual_source_output_
name())); | 296 GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, dual_source_output_
name())); |
297 } | 297 } |
298 } | 298 } |
299 | 299 |
300 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
{ | 300 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
{ |
301 v->fFsIn = v->fVsOut; | 301 v->fFsIn = v->fVsOut; |
302 if (v->fGsOut) { | 302 if (v->fGsOut) { |
303 v->fFsIn = v->fGsOut; | 303 v->fFsIn = v->fGsOut; |
304 } | 304 } |
305 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v-
>fFsIn, fsPrec); | 305 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v-
>fFsIn, fsPrec); |
306 } | 306 } |
OLD | NEW |