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 "../GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
| 11 #include "gl/GrGLGLSL.h" |
| 12 #include "glsl/GrGLSLCaps.h" |
11 | 13 |
12 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) | 14 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) |
13 #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) |
14 | 16 |
15 const char* GrGLFragmentShaderBuilder::kDstTextureColorName = "_dstColor"; | 17 const char* GrGLFragmentShaderBuilder::kDstTextureColorName = "_dstColor"; |
16 static const char* declared_color_output_name() { return "fsColorOut"; } | 18 static const char* declared_color_output_name() { return "fsColorOut"; } |
17 static const char* dual_source_output_name() { return "dualSourceOut"; } | 19 static const char* dual_source_output_name() { return "dualSourceOut"; } |
18 | 20 |
19 static const char* specific_layout_qualifier_name(GrBlendEquation equation) { | 21 static const char* specific_layout_qualifier_name(GrBlendEquation equation) { |
20 SkASSERT(GrBlendEquationIsAdvanced(equation)); | 22 SkASSERT(GrBlendEquationIsAdvanced(equation)); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 return fHasCustomColorOutput ? declared_color_output_name() : "gl_FragColor"
; | 244 return fHasCustomColorOutput ? declared_color_output_name() : "gl_FragColor"
; |
243 } | 245 } |
244 | 246 |
245 const char* GrGLFragmentShaderBuilder::getSecondaryColorOutputName() const { | 247 const char* GrGLFragmentShaderBuilder::getSecondaryColorOutputName() const { |
246 return dual_source_output_name(); | 248 return dual_source_output_name(); |
247 } | 249 } |
248 | 250 |
249 bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId, | 251 bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId, |
250 SkTDArray<GrGLuint>* sha
derIds) { | 252 SkTDArray<GrGLuint>* sha
derIds) { |
251 GrGLGpu* gpu = fProgramBuilder->gpu(); | 253 GrGLGpu* gpu = fProgramBuilder->gpu(); |
252 this->versionDecl() = GrGetGLSLVersionDecl(gpu->ctxInfo()); | 254 this->versionDecl() = GrGLGetGLSLVersionDecl(gpu->ctxInfo()); |
253 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | 255 GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, |
254 gpu->glStandard(), | 256 gpu->glStandard(), |
255 &this->precisionQualifier()); | 257 &this->precisionQualifier()); |
256 this->compileAndAppendLayoutQualifiers(); | 258 this->compileAndAppendLayoutQualifiers(); |
257 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kFragment_Visibility
, | 259 fProgramBuilder->appendUniformDecls(GrGLProgramBuilder::kFragment_Visibility
, |
258 &this->uniforms()); | 260 &this->uniforms()); |
259 this->appendDecls(fInputs, &this->inputs()); | 261 this->appendDecls(fInputs, &this->inputs()); |
260 // We shouldn't have declared outputs on 1.10 | 262 // We shouldn't have declared outputs on 1.10 |
261 SkASSERT(k110_GrGLSLGeneration != gpu->glslGeneration() || fOutputs.empty())
; | 263 SkASSERT(k110_GrGLSLGeneration != gpu->glslGeneration() || fOutputs.empty())
; |
262 this->appendDecls(fOutputs, &this->outputs()); | 264 this->appendDecls(fOutputs, &this->outputs()); |
263 return this->finalize(programId, GR_GL_FRAGMENT_SHADER, shaderIds); | 265 return this->finalize(programId, GR_GL_FRAGMENT_SHADER, shaderIds); |
264 } | 266 } |
265 | 267 |
266 void GrGLFragmentShaderBuilder::bindFragmentShaderLocations(GrGLuint programID)
{ | 268 void GrGLFragmentShaderBuilder::bindFragmentShaderLocations(GrGLuint programID)
{ |
267 if (fHasCustomColorOutput && fProgramBuilder->gpu()->glCaps().bindFragDataLo
cationSupport()) { | 269 if (fHasCustomColorOutput && fProgramBuilder->gpu()->glCaps().bindFragDataLo
cationSupport()) { |
268 GL_CALL(BindFragDataLocation(programID, 0, declared_color_output_name())
); | 270 GL_CALL(BindFragDataLocation(programID, 0, declared_color_output_name())
); |
269 } | 271 } |
270 if (fHasSecondaryOutput) { | 272 if (fHasSecondaryOutput) { |
271 GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, dual_source_output_
name())); | 273 GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, dual_source_output_
name())); |
272 } | 274 } |
273 } | 275 } |
274 | 276 |
275 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
{ | 277 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
{ |
276 v->fFsIn = v->fVsOut; | 278 v->fFsIn = v->fVsOut; |
277 if (v->fGsOut) { | 279 if (v->fGsOut) { |
278 v->fFsIn = v->fGsOut; | 280 v->fFsIn = v->fGsOut; |
279 } | 281 } |
280 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v-
>fFsIn, fsPrec); | 282 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v-
>fFsIn, fsPrec); |
281 } | 283 } |
OLD | NEW |