Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: src/gpu/gl/GrGLProgramDesc.cpp

Issue 23653059: Mark when effects and programs have vertex code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include "GrGLProgramDesc.h" 8 #include "GrGLProgramDesc.h"
9 #include "GrBackendEffectFactory.h" 9 #include "GrBackendEffectFactory.h"
10 #include "GrDrawEffect.h" 10 #include "GrDrawEffect.h"
11 #include "GrEffect.h" 11 #include "GrEffect.h"
12 #include "GrGLShaderBuilder.h" 12 #include "GrGLShaderBuilder.h"
13 #include "GrGpuGL.h" 13 #include "GrGpuGL.h"
14 14
15 #include "SkChecksum.h" 15 #include "SkChecksum.h"
16 16
17 namespace { 17 namespace {
18 inline GrGLEffect::EffectKey get_key_and_update_stats(const GrEffectStage& stage , 18 inline GrGLEffect::EffectKey get_key_and_update_stats(const GrEffectStage& stage ,
19 const GrGLCaps& caps, 19 const GrGLCaps& caps,
20 bool useExplicitLocalCoord s, 20 bool useExplicitLocalCoord s,
21 bool* setTrueIfReadsDst, 21 bool* setTrueIfReadsDst,
22 bool* setTrueIfReadsPos) { 22 bool* setTrueIfReadsPos,
23 bool* setTrueIfHasVertexCo de) {
23 const GrEffectRef& effect = *stage.getEffect(); 24 const GrEffectRef& effect = *stage.getEffect();
24 const GrBackendEffectFactory& factory = effect->getFactory(); 25 const GrBackendEffectFactory& factory = effect->getFactory();
25 GrDrawEffect drawEffect(stage, useExplicitLocalCoords); 26 GrDrawEffect drawEffect(stage, useExplicitLocalCoords);
26 if (effect->willReadDstColor()) { 27 if (effect->willReadDstColor()) {
27 *setTrueIfReadsDst = true; 28 *setTrueIfReadsDst = true;
28 } 29 }
29 if (effect->willReadFragmentPosition()) { 30 if (effect->willReadFragmentPosition()) {
30 *setTrueIfReadsPos = true; 31 *setTrueIfReadsPos = true;
31 } 32 }
33 if (effect->hasVertexCode()) {
34 *setTrueIfHasVertexCode = true;
35 }
32 return factory.glEffectKey(drawEffect, caps); 36 return factory.glEffectKey(drawEffect, caps);
33 } 37 }
34 } 38 }
35 void GrGLProgramDesc::Build(const GrDrawState& drawState, 39 void GrGLProgramDesc::Build(const GrDrawState& drawState,
36 bool isPoints, 40 bool isPoints,
37 GrDrawState::BlendOptFlags blendOpts, 41 GrDrawState::BlendOptFlags blendOpts,
38 GrBlendCoeff srcCoeff, 42 GrBlendCoeff srcCoeff,
39 GrBlendCoeff dstCoeff, 43 GrBlendCoeff dstCoeff,
40 const GrGpuGL* gpu, 44 const GrGpuGL* gpu,
41 const GrDeviceCoordTexture* dstCopy, 45 const GrDeviceCoordTexture* dstCopy,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 84 }
81 // write the key length 85 // write the key length
82 *desc->atOffset<uint32_t, kLengthOffset>() = newKeyLength; 86 *desc->atOffset<uint32_t, kLengthOffset>() = newKeyLength;
83 87
84 KeyHeader* header = desc->header(); 88 KeyHeader* header = desc->header();
85 EffectKey* effectKeys = desc->effectKeys(); 89 EffectKey* effectKeys = desc->effectKeys();
86 90
87 int currEffectKey = 0; 91 int currEffectKey = 0;
88 bool readsDst = false; 92 bool readsDst = false;
89 bool readFragPosition = false; 93 bool readFragPosition = false;
94 bool hasVertexCode = false;
90 if (!skipColor) { 95 if (!skipColor) {
91 for (int s = 0; s < drawState.numColorStages(); ++s) { 96 for (int s = 0; s < drawState.numColorStages(); ++s) {
92 effectKeys[currEffectKey++] = 97 effectKeys[currEffectKey++] =
93 get_key_and_update_stats(drawState.getColorStage(s), gpu->glCaps (), 98 get_key_and_update_stats(drawState.getColorStage(s), gpu->glCaps (),
94 requiresLocalCoordAttrib, &readsDst, &r eadFragPosition); 99 requiresLocalCoordAttrib, &readsDst, &r eadFragPosition,
100 &hasVertexCode);
95 } 101 }
96 } 102 }
97 if (!skipCoverage) { 103 if (!skipCoverage) {
98 for (int s = 0; s < drawState.numCoverageStages(); ++s) { 104 for (int s = 0; s < drawState.numCoverageStages(); ++s) {
99 effectKeys[currEffectKey++] = 105 effectKeys[currEffectKey++] =
100 get_key_and_update_stats(drawState.getCoverageStage(s), gpu->glC aps(), 106 get_key_and_update_stats(drawState.getCoverageStage(s), gpu->glC aps(),
101 requiresLocalCoordAttrib, &readsDst, &r eadFragPosition); 107 requiresLocalCoordAttrib, &readsDst, &r eadFragPosition,
108 &hasVertexCode);
102 } 109 }
103 } 110 }
104 111
112 header->fHasVertexCode = hasVertexCode || requiresLocalCoordAttrib;
105 header->fEmitsPointSize = isPoints; 113 header->fEmitsPointSize = isPoints;
106 header->fColorFilterXfermode = skipColor ? SkXfermode::kDst_Mode : drawState .getColorFilterMode(); 114 header->fColorFilterXfermode = skipColor ? SkXfermode::kDst_Mode : drawState .getColorFilterMode();
107 115
108 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything 116 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything
109 // other than pass through values from the VS to the FS anyway). 117 // other than pass through values from the VS to the FS anyway).
110 #if GR_GL_EXPERIMENTAL_GS 118 #if GR_GL_EXPERIMENTAL_GS
111 #if 0 119 #if 0
112 header->fExperimentalGS = gpu->caps().geometryShaderSupport(); 120 header->fExperimentalGS = gpu->caps().geometryShaderSupport();
113 #else 121 #else
114 header->fExperimentalGS = false; 122 header->fExperimentalGS = false;
115 #endif 123 #endif
116 #endif 124 #endif
117 if (colorIsTransBlack) { 125 if (colorIsTransBlack) {
118 header->fColorInput = kTransBlack_ColorInput; 126 header->fColorInput = kTransBlack_ColorInput;
119 } else if (colorIsSolidWhite) { 127 } else if (colorIsSolidWhite) {
120 header->fColorInput = kSolidWhite_ColorInput; 128 header->fColorInput = kSolidWhite_ColorInput;
121 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresColorAttrib) { 129 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresColorAttrib) {
122 header->fColorInput = kUniform_ColorInput; 130 header->fColorInput = kUniform_ColorInput;
123 } else { 131 } else {
124 header->fColorInput = kAttribute_ColorInput; 132 header->fColorInput = kAttribute_ColorInput;
133 header->fHasVertexCode = true;
125 } 134 }
126 135
127 bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == drawState.ge tCoverage(); 136 bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == drawState.ge tCoverage();
128 137
129 if (skipCoverage) { 138 if (skipCoverage) {
130 header->fCoverageInput = kTransBlack_ColorInput; 139 header->fCoverageInput = kTransBlack_ColorInput;
131 } else if (covIsSolidWhite) { 140 } else if (covIsSolidWhite) {
132 header->fCoverageInput = kSolidWhite_ColorInput; 141 header->fCoverageInput = kSolidWhite_ColorInput;
133 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresCoverageAttrib) { 142 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresCoverageAttrib) {
134 header->fCoverageInput = kUniform_ColorInput; 143 header->fCoverageInput = kUniform_ColorInput;
135 } else { 144 } else {
136 header->fCoverageInput = kAttribute_ColorInput; 145 header->fCoverageInput = kAttribute_ColorInput;
146 header->fHasVertexCode = true;
137 } 147 }
138 148
139 if (readsDst) { 149 if (readsDst) {
140 SkASSERT(NULL != dstCopy || gpu->caps()->dstReadInShaderSupport()); 150 SkASSERT(NULL != dstCopy || gpu->caps()->dstReadInShaderSupport());
141 const GrTexture* dstCopyTexture = NULL; 151 const GrTexture* dstCopyTexture = NULL;
142 if (NULL != dstCopy) { 152 if (NULL != dstCopy) {
143 dstCopyTexture = dstCopy->texture(); 153 dstCopyTexture = dstCopy->texture();
144 } 154 }
145 header->fDstReadKey = GrGLShaderBuilder::KeyForDstRead(dstCopyTexture, g pu->glCaps()); 155 header->fDstReadKey = GrGLShaderBuilder::KeyForDstRead(dstCopyTexture, g pu->glCaps());
146 SkASSERT(0 != header->fDstReadKey); 156 SkASSERT(0 != header->fDstReadKey);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 262
253 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { 263 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) {
254 fInitialized = other.fInitialized; 264 fInitialized = other.fInitialized;
255 if (fInitialized) { 265 if (fInitialized) {
256 size_t keyLength = other.keyLength(); 266 size_t keyLength = other.keyLength();
257 fKey.reset(keyLength); 267 fKey.reset(keyLength);
258 memcpy(fKey.get(), other.fKey.get(), keyLength); 268 memcpy(fKey.get(), other.fKey.get(), keyLength);
259 } 269 }
260 return *this; 270 return *this;
261 } 271 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698