| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "GrGLProgramDesc.h" | 7 #include "GrGLProgramDesc.h" |
| 8 | 8 |
| 9 #include "GrProcessor.h" | 9 #include "GrProcessor.h" |
| 10 #include "GrPipeline.h" | 10 #include "GrPipeline.h" |
| 11 #include "GrRenderTargetPriv.h" | 11 #include "GrRenderTargetPriv.h" |
| 12 #include "SkChecksum.h" | 12 #include "SkChecksum.h" |
| 13 #include "gl/GrGLDefines.h" | 13 #include "gl/GrGLDefines.h" |
| 14 #include "gl/GrGLTexture.h" | 14 #include "gl/GrGLTexture.h" |
| 15 #include "gl/GrGLTypes.h" | 15 #include "gl/GrGLTypes.h" |
| 16 #include "glsl/GrGLSLFragmentProcessor.h" | 16 #include "glsl/GrGLSLFragmentProcessor.h" |
| 17 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 17 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 18 #include "glsl/GrGLSLCaps.h" | 18 #include "glsl/GrGLSLCaps.h" |
| 19 | 19 |
| 20 static uint16_t sampler_key(GrSLType samplerType, GrPixelConfig config, GrShader
Flags visibility, | 20 static uint16_t sampler_key(GrSLType samplerType, GrPixelConfig config, GrShader
Flags visibility, |
| 21 const GrGLSLCaps& caps) { | 21 const GrGLSLCaps& caps) { |
| 22 enum { | 22 enum { |
| 23 kFirstSamplerType = kSampler2D_GrSLType, | 23 kFirstSamplerType = kTexture2DSampler_GrSLType, |
| 24 kLastSamplerType = kSamplerBuffer_GrSLType, | 24 kLastSamplerType = kTextureBufferSampler_GrSLType, |
| 25 kSamplerTypeKeyBits = 4 | 25 kSamplerTypeKeyBits = 4 |
| 26 }; | 26 }; |
| 27 GR_STATIC_ASSERT(kLastSamplerType - kFirstSamplerType < (1 << kSamplerTypeKe
yBits)); | 27 GR_STATIC_ASSERT(kLastSamplerType - kFirstSamplerType < (1 << kSamplerTypeKe
yBits)); |
| 28 | 28 |
| 29 SkASSERT((int)samplerType >= kFirstSamplerType && (int)samplerType <= kLastS
amplerType); | 29 SkASSERT((int)samplerType >= kFirstSamplerType && (int)samplerType <= kLastS
amplerType); |
| 30 int samplerTypeKey = samplerType - kFirstSamplerType; | 30 int samplerTypeKey = samplerType - kFirstSamplerType; |
| 31 | 31 |
| 32 return SkToU16(caps.configTextureSwizzle(config).asKey() | | 32 return SkToU16(caps.configTextureSwizzle(config).asKey() | |
| 33 (samplerTypeKey << 8) | | 33 (samplerTypeKey << 8) | |
| 34 (caps.samplerPrecision(config, visibility) << (8 + kSamplerTy
peKeyBits))); | 34 (caps.samplerPrecision(config, visibility) << (8 + kSamplerTy
peKeyBits))); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 } | 45 } |
| 46 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); | 46 uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count)); |
| 47 int i = 0; | 47 int i = 0; |
| 48 for (; i < numTextures; ++i) { | 48 for (; i < numTextures; ++i) { |
| 49 const GrTextureAccess& access = proc.textureAccess(i); | 49 const GrTextureAccess& access = proc.textureAccess(i); |
| 50 const GrTexture* tex = access.getTexture(); | 50 const GrTexture* tex = access.getTexture(); |
| 51 k16[i] = sampler_key(tex->samplerType(), tex->config(), access.getVisibi
lity(), caps); | 51 k16[i] = sampler_key(tex->samplerType(), tex->config(), access.getVisibi
lity(), caps); |
| 52 } | 52 } |
| 53 for (; i < numSamplers; ++i) { | 53 for (; i < numSamplers; ++i) { |
| 54 const GrBufferAccess& access = proc.bufferAccess(i - numTextures); | 54 const GrBufferAccess& access = proc.bufferAccess(i - numTextures); |
| 55 k16[i] = sampler_key(kSamplerBuffer_GrSLType, access.texelConfig(), acce
ss.visibility(), | 55 k16[i] = sampler_key(kTextureBufferSampler_GrSLType, access.texelConfig(
), |
| 56 caps); | 56 access.visibility(), caps); |
| 57 } | 57 } |
| 58 // zero the last 16 bits if the number of samplers is odd. | 58 // zero the last 16 bits if the number of samplers is odd. |
| 59 if (numSamplers & 0x1) { | 59 if (numSamplers & 0x1) { |
| 60 k16[numSamplers] = 0; | 60 k16[numSamplers] = 0; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * A function which emits a meta key into the key builder. This is required bec
ause shader code may | 65 * A function which emits a meta key into the key builder. This is required bec
ause shader code may |
| 66 * be dependent on properties of the effect that the effect itself doesn't use | 66 * be dependent on properties of the effect that the effect itself doesn't use |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } else { | 181 } else { |
| 182 header->fIgnoresCoverage = 0; | 182 header->fIgnoresCoverage = 0; |
| 183 } | 183 } |
| 184 | 184 |
| 185 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); | 185 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); |
| 186 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); | 186 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); |
| 187 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); | 187 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); |
| 188 glDesc->finalize(); | 188 glDesc->finalize(); |
| 189 return true; | 189 return true; |
| 190 } | 190 } |
| OLD | NEW |