| 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 "GrGLProgramBuilder.h" | 9 #include "GrGLProgramBuilder.h" |
| 10 #include "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
| 11 #include "gl/GrGLGLSL.h" | 11 #include "glsl/GrGLSL.h" |
| 12 #include "glsl/GrGLSLCaps.h" | 12 #include "glsl/GrGLSLCaps.h" |
| 13 | 13 |
| 14 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) | 14 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) |
| 15 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(),
R, X) | 15 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(),
R, X) |
| 16 | 16 |
| 17 const char* GrGLFragmentShaderBuilder::kDstTextureColorName = "_dstColor"; | 17 const char* GrGLFragmentShaderBuilder::kDstTextureColorName = "_dstColor"; |
| 18 static const char* declared_color_output_name() { return "fsColorOut"; } | 18 static const char* declared_color_output_name() { return "fsColorOut"; } |
| 19 static const char* declared_secondary_color_output_name() { return "fsSecondaryC
olorOut"; } | 19 static const char* declared_secondary_color_output_name() { return "fsSecondaryC
olorOut"; } |
| 20 | 20 |
| 21 static const char* specific_layout_qualifier_name(GrBlendEquation equation) { | 21 static const char* specific_layout_qualifier_name(GrBlendEquation equation) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 260 } |
| 261 | 261 |
| 262 const char* GrGLFragmentShaderBuilder::getSecondaryColorOutputName() const { | 262 const char* GrGLFragmentShaderBuilder::getSecondaryColorOutputName() const { |
| 263 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps(); | 263 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps(); |
| 264 return caps.mustDeclareFragmentShaderOutput() ? declared_secondary_color_out
put_name() | 264 return caps.mustDeclareFragmentShaderOutput() ? declared_secondary_color_out
put_name() |
| 265 : "gl_SecondaryFragColorEXT"; | 265 : "gl_SecondaryFragColorEXT"; |
| 266 } | 266 } |
| 267 | 267 |
| 268 bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId, | 268 bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId, |
| 269 SkTDArray<GrGLuint>* sha
derIds) { | 269 SkTDArray<GrGLuint>* sha
derIds) { |
| 270 GrGLGpu* gpu = fProgramBuilder->gpu(); | |
| 271 this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString(); | 270 this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString(); |
| 272 GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | 271 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, |
| 273 gpu->glStandard(), | 272 *fProgramBuilder->glslCaps(), |
| 274 &this->precisionQualifier()); | 273 &this->precisionQualifier()); |
| 275 this->compileAndAppendLayoutQualifiers(); | 274 this->compileAndAppendLayoutQualifiers(); |
| 276 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kFragment_Visibility
, | 275 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kFragment_Visibility
, |
| 277 &this->uniforms()); | 276 &this->uniforms()); |
| 278 this->appendDecls(fInputs, &this->inputs()); | 277 this->appendDecls(fInputs, &this->inputs()); |
| 279 // We shouldn't have declared outputs on 1.10 | 278 // We shouldn't have declared outputs on 1.10 |
| 280 SkASSERT(k110_GrGLSLGeneration != gpu->glslGeneration() || fOutputs.empty())
; | 279 SkASSERT(k110_GrGLSLGeneration != fProgramBuilder->gpu()->glslGeneration() |
| fOutputs.empty()); |
| 281 this->appendDecls(fOutputs, &this->outputs()); | 280 this->appendDecls(fOutputs, &this->outputs()); |
| 282 return this->finalize(programId, GR_GL_FRAGMENT_SHADER, shaderIds); | 281 return this->finalize(programId, GR_GL_FRAGMENT_SHADER, shaderIds); |
| 283 } | 282 } |
| 284 | 283 |
| 285 void GrGLFragmentShaderBuilder::bindFragmentShaderLocations(GrGLuint programID)
{ | 284 void GrGLFragmentShaderBuilder::bindFragmentShaderLocations(GrGLuint programID)
{ |
| 286 const GrGLCaps& caps = fProgramBuilder->gpu()->glCaps(); | 285 const GrGLCaps& caps = fProgramBuilder->gpu()->glCaps(); |
| 287 if (fHasCustomColorOutput && caps.bindFragDataLocationSupport()) { | 286 if (fHasCustomColorOutput && caps.bindFragDataLocationSupport()) { |
| 288 GL_CALL(BindFragDataLocation(programID, 0, declared_color_output_name())
); | 287 GL_CALL(BindFragDataLocation(programID, 0, declared_color_output_name())
); |
| 289 } | 288 } |
| 290 if (fHasSecondaryOutput && caps.glslCaps()->mustDeclareFragmentShaderOutput(
)) { | 289 if (fHasSecondaryOutput && caps.glslCaps()->mustDeclareFragmentShaderOutput(
)) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 309 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]
); | 308 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]
); |
| 310 } | 309 } |
| 311 | 310 |
| 312 void GrGLFragmentBuilder::onAfterChildProcEmitCode() { | 311 void GrGLFragmentBuilder::onAfterChildProcEmitCode() { |
| 313 SkASSERT(fSubstageIndices.count() >= 2); | 312 SkASSERT(fSubstageIndices.count() >= 2); |
| 314 fSubstageIndices.pop_back(); | 313 fSubstageIndices.pop_back(); |
| 315 fSubstageIndices.back()++; | 314 fSubstageIndices.back()++; |
| 316 int removeAt = fMangleString.findLastOf('_'); | 315 int removeAt = fMangleString.findLastOf('_'); |
| 317 fMangleString.remove(removeAt, fMangleString.size() - removeAt); | 316 fMangleString.remove(removeAt, fMangleString.size() - removeAt); |
| 318 } | 317 } |
| OLD | NEW |