| 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 "../GrGLGpu.h" |
| 11 | 11 |
| 12 #define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X) | 12 #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) | 13 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(),
R, X) |
| 14 | 14 |
| 15 const char* GrGLFragmentShaderBuilder::kDstCopyColorName = "_dstColor"; | 15 const char* GrGLFragmentShaderBuilder::kDstTextureColorName = "_dstColor"; |
| 16 static const char* declared_color_output_name() { return "fsColorOut"; } | 16 static const char* declared_color_output_name() { return "fsColorOut"; } |
| 17 static const char* dual_source_output_name() { return "dualSourceOut"; } | 17 static const char* dual_source_output_name() { return "dualSourceOut"; } |
| 18 | 18 |
| 19 static const char* specific_layout_qualifier_name(GrBlendEquation equation) { | 19 static const char* specific_layout_qualifier_name(GrBlendEquation equation) { |
| 20 SkASSERT(GrBlendEquationIsAdvanced(equation)); | 20 SkASSERT(GrBlendEquationIsAdvanced(equation)); |
| 21 | 21 |
| 22 static const char* kLayoutQualifierNames[] = { | 22 static const char* kLayoutQualifierNames[] = { |
| 23 "blend_support_screen", | 23 "blend_support_screen", |
| 24 "blend_support_overlay", | 24 "blend_support_overlay", |
| 25 "blend_support_darken", | 25 "blend_support_darken", |
| (...skipping 25 matching lines...) Expand all Loading... |
| 51 GR_STATIC_ASSERT(10 == kMultiply_GrBlendEquation - kFirstAdvancedGrBlendEqua
tion); | 51 GR_STATIC_ASSERT(10 == kMultiply_GrBlendEquation - kFirstAdvancedGrBlendEqua
tion); |
| 52 GR_STATIC_ASSERT(11 == kHSLHue_GrBlendEquation - kFirstAdvancedGrBlendEquati
on); | 52 GR_STATIC_ASSERT(11 == kHSLHue_GrBlendEquation - kFirstAdvancedGrBlendEquati
on); |
| 53 GR_STATIC_ASSERT(12 == kHSLSaturation_GrBlendEquation - kFirstAdvancedGrBlen
dEquation); | 53 GR_STATIC_ASSERT(12 == kHSLSaturation_GrBlendEquation - kFirstAdvancedGrBlen
dEquation); |
| 54 GR_STATIC_ASSERT(13 == kHSLColor_GrBlendEquation - kFirstAdvancedGrBlendEqua
tion); | 54 GR_STATIC_ASSERT(13 == kHSLColor_GrBlendEquation - kFirstAdvancedGrBlendEqua
tion); |
| 55 GR_STATIC_ASSERT(14 == kHSLLuminosity_GrBlendEquation - kFirstAdvancedGrBlen
dEquation); | 55 GR_STATIC_ASSERT(14 == kHSLLuminosity_GrBlendEquation - kFirstAdvancedGrBlen
dEquation); |
| 56 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayoutQualifierNames) == | 56 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayoutQualifierNames) == |
| 57 kGrBlendEquationCnt - kFirstAdvancedGrBlendEquation); | 57 kGrBlendEquationCnt - kFirstAdvancedGrBlendEquation); |
| 58 } | 58 } |
| 59 | 59 |
| 60 GrGLFragmentShaderBuilder::DstReadKey | 60 GrGLFragmentShaderBuilder::DstReadKey |
| 61 GrGLFragmentShaderBuilder::KeyForDstRead(const GrTexture* dstCopy, const GrGLCap
s& caps) { | 61 GrGLFragmentShaderBuilder::KeyForDstRead(const GrTexture* dstTexture, const GrGL
Caps& caps) { |
| 62 uint32_t key = kYesDstRead_DstReadKeyBit; | 62 uint32_t key = kYesDstRead_DstReadKeyBit; |
| 63 if (caps.glslCaps()->fbFetchSupport()) { | 63 if (caps.glslCaps()->fbFetchSupport()) { |
| 64 return key; | 64 return key; |
| 65 } | 65 } |
| 66 SkASSERT(dstCopy); | 66 SkASSERT(dstTexture); |
| 67 if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstCopy->confi
g())) { | 67 if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstTexture->co
nfig())) { |
| 68 // The fact that the config is alpha-only must be considered when genera
ting code. | 68 // The fact that the config is alpha-only must be considered when genera
ting code. |
| 69 key |= kUseAlphaConfig_DstReadKeyBit; | 69 key |= kUseAlphaConfig_DstReadKeyBit; |
| 70 } | 70 } |
| 71 if (kTopLeft_GrSurfaceOrigin == dstCopy->origin()) { | 71 if (kTopLeft_GrSurfaceOrigin == dstTexture->origin()) { |
| 72 key |= kTopLeftOrigin_DstReadKeyBit; | 72 key |= kTopLeftOrigin_DstReadKeyBit; |
| 73 } | 73 } |
| 74 SkASSERT(static_cast<DstReadKey>(key) == key); | 74 SkASSERT(static_cast<DstReadKey>(key) == key); |
| 75 return static_cast<DstReadKey>(key); | 75 return static_cast<DstReadKey>(key); |
| 76 } | 76 } |
| 77 | 77 |
| 78 GrGLFragmentShaderBuilder::FragPosKey | 78 GrGLFragmentShaderBuilder::FragPosKey |
| 79 GrGLFragmentShaderBuilder::KeyForFragmentPosition(const GrRenderTarget* dst, con
st GrGLCaps&) { | 79 GrGLFragmentShaderBuilder::KeyForFragmentPosition(const GrRenderTarget* dst, con
st GrGLCaps&) { |
| 80 if (kTopLeft_GrSurfaceOrigin == dst->origin()) { | 80 if (kTopLeft_GrSurfaceOrigin == dst->origin()) { |
| 81 return kTopLeftFragPosRead_FragPosKey; | 81 return kTopLeftFragPosRead_FragPosKey; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 // Some versions of this extension string require declaring custom color
output on ES 3.0+ | 194 // Some versions of this extension string require declaring custom color
output on ES 3.0+ |
| 195 const char* fbFetchColorName = gpu->glCaps().glslCaps()->fbFetchColorNam
e(); | 195 const char* fbFetchColorName = gpu->glCaps().glslCaps()->fbFetchColorNam
e(); |
| 196 if (gpu->glCaps().glslCaps()->fbFetchNeedsCustomOutput()) { | 196 if (gpu->glCaps().glslCaps()->fbFetchNeedsCustomOutput()) { |
| 197 this->enableCustomOutput(); | 197 this->enableCustomOutput(); |
| 198 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu
t_TypeModifier); | 198 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu
t_TypeModifier); |
| 199 fbFetchColorName = declared_color_output_name(); | 199 fbFetchColorName = declared_color_output_name(); |
| 200 } | 200 } |
| 201 return fbFetchColorName; | 201 return fbFetchColorName; |
| 202 } else { | 202 } else { |
| 203 return kDstCopyColorName; | 203 return kDstTextureColorName; |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 void GrGLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEquat
ion equation) { | 207 void GrGLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEquat
ion equation) { |
| 208 SkASSERT(GrBlendEquationIsAdvanced(equation)); | 208 SkASSERT(GrBlendEquationIsAdvanced(equation)); |
| 209 | 209 |
| 210 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps(); | 210 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps(); |
| 211 if (!caps.mustEnableAdvBlendEqs()) { | 211 if (!caps.mustEnableAdvBlendEqs()) { |
| 212 return; | 212 return; |
| 213 } | 213 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
{ | 277 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
{ |
| 278 v->fFsIn = v->fVsOut; | 278 v->fFsIn = v->fVsOut; |
| 279 if (v->fGsOut) { | 279 if (v->fGsOut) { |
| 280 v->fFsIn = v->fGsOut; | 280 v->fFsIn = v->fGsOut; |
| 281 } | 281 } |
| 282 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); |
| 283 } | 283 } |
| OLD | NEW |