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 "GrGLProcessor.h" | 9 #include "GrGLProcessor.h" |
10 #include "GrProcessor.h" | 10 #include "GrProcessor.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 uint32_t* key = b->add32n(2); | 83 uint32_t* key = b->add32n(2); |
84 key[0] = (textureKey << 16 | transformKey); | 84 key[0] = (textureKey << 16 | transformKey); |
85 key[1] = (classID << 16 | SkToU16(processorKeySize)); | 85 key[1] = (classID << 16 | SkToU16(processorKeySize)); |
86 return true; | 86 return true; |
87 } | 87 } |
88 | 88 |
89 bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc, | 89 bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc, |
90 const GrPrimitiveProcessor& primProc, | 90 const GrPrimitiveProcessor& primProc, |
91 const GrPipeline& pipeline, | 91 const GrPipeline& pipeline, |
| 92 const GrProgramDesc::DescInfo& descInfo, |
92 const GrGLGpu* gpu, | 93 const GrGLGpu* gpu, |
93 const GrBatchTracker& batchTracker) { | 94 const GrBatchTracker& batchTracker) { |
94 // The descriptor is used as a cache key. Thus when a field of the | 95 // The descriptor is used as a cache key. Thus when a field of the |
95 // descriptor will not affect program generation (because of the attribute | 96 // descriptor will not affect program generation (because of the attribute |
96 // bindings in use or other descriptor field settings) it should be set | 97 // bindings in use or other descriptor field settings) it should be set |
97 // to a canonical value to avoid duplicate programs with different keys. | 98 // to a canonical value to avoid duplicate programs with different keys. |
98 | 99 |
99 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); | 100 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); |
100 // Make room for everything up to the effect keys. | 101 // Make room for everything up to the effect keys. |
101 desc->fKey.reset(); | 102 desc->fKey.reset(); |
(...skipping 25 matching lines...) Expand all Loading... |
127 } | 128 } |
128 | 129 |
129 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- | 130 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- |
130 // Because header is a pointer into the dynamic array, we can't push any new
data into the key | 131 // Because header is a pointer into the dynamic array, we can't push any new
data into the key |
131 // below here. | 132 // below here. |
132 KeyHeader* header = desc->atOffset<KeyHeader, kHeaderOffset>(); | 133 KeyHeader* header = desc->atOffset<KeyHeader, kHeaderOffset>(); |
133 | 134 |
134 // make sure any padding in the header is zeroed. | 135 // make sure any padding in the header is zeroed. |
135 memset(header, 0, kHeaderSize); | 136 memset(header, 0, kHeaderSize); |
136 | 137 |
137 if (pipeline.readsFragPosition()) { | 138 if (descInfo.fReadsDst) { |
| 139 const GrDeviceCoordTexture* dstCopy = pipeline.getDstCopy(); |
| 140 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); |
| 141 const GrTexture* dstCopyTexture = NULL; |
| 142 if (dstCopy) { |
| 143 dstCopyTexture = dstCopy->texture(); |
| 144 } |
| 145 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe
xture, |
| 146 gpu->glCa
ps()); |
| 147 SkASSERT(0 != header->fDstReadKey); |
| 148 } else { |
| 149 header->fDstReadKey = 0; |
| 150 } |
| 151 |
| 152 if (descInfo.fReadsFragPosition) { |
138 header->fFragPosKey = | 153 header->fFragPosKey = |
139 GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRe
nderTarget(), | 154 GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRe
nderTarget(), |
140 gpu->glCaps())
; | 155 gpu->glCaps())
; |
141 } else { | 156 } else { |
142 header->fFragPosKey = 0; | 157 header->fFragPosKey = 0; |
143 } | 158 } |
144 | 159 |
145 header->fColorEffectCnt = pipeline.numColorStages(); | 160 header->fColorEffectCnt = pipeline.numColorStages(); |
146 header->fCoverageEffectCnt = pipeline.numCoverageStages(); | 161 header->fCoverageEffectCnt = pipeline.numCoverageStages(); |
147 desc->finalize(); | 162 desc->finalize(); |
148 return true; | 163 return true; |
149 } | 164 } |
OLD | NEW |