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

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

Issue 560443004: Revert of Attach GrOptDrawState into shader building pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@opt2
Patch Set: Created 6 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
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp » ('j') | 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 2011 Google Inc. 2 * Copyright 2011 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 "GrGpuGL.h" 8 #include "GrGpuGL.h"
9 9
10 #include "GrEffect.h" 10 #include "GrEffect.h"
11 #include "GrGLEffect.h" 11 #include "GrGLEffect.h"
12 #include "SkRTConf.h"
12 #include "GrGLPathRendering.h" 13 #include "GrGLPathRendering.h"
13 #include "GrOptDrawState.h"
14 #include "SkRTConf.h"
15 #include "SkTSearch.h" 14 #include "SkTSearch.h"
16 15
17 #ifdef PROGRAM_CACHE_STATS 16 #ifdef PROGRAM_CACHE_STATS
18 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, 17 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false,
19 "Display program cache usage."); 18 "Display program cache usage.");
20 #endif 19 #endif
21 20
22 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 21 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
23 22
24 struct GrGpuGL::ProgramCache::Entry { 23 struct GrGpuGL::ProgramCache::Entry {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 197 }
199 ++fCurrLRUStamp; 198 ++fCurrLRUStamp;
200 return entry->fProgram; 199 return entry->fProgram;
201 } 200 }
202 201
203 //////////////////////////////////////////////////////////////////////////////// 202 ////////////////////////////////////////////////////////////////////////////////
204 203
205 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) 204 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
206 205
207 bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC opy) { 206 bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC opy) {
208 SkAutoTUnref<GrOptDrawState> optState(this->getDrawState().createOptState()) ; 207 const GrDrawState& drawState = this->getDrawState();
209 208
210 // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true. 209 // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true.
211 SkASSERT(optState->getRenderTarget()); 210 SkASSERT(drawState.getRenderTarget());
212 211
213 if (kStencilPath_DrawType == type) { 212 if (kStencilPath_DrawType == type) {
214 const GrRenderTarget* rt = optState->getRenderTarget(); 213 const GrRenderTarget* rt = this->getDrawState().getRenderTarget();
215 SkISize size; 214 SkISize size;
216 size.set(rt->width(), rt->height()); 215 size.set(rt->width(), rt->height());
217 this->glPathRendering()->setProjectionMatrix(optState->getViewMatrix(), size, rt->origin()); 216 this->glPathRendering()->setProjectionMatrix(drawState.getViewMatrix(), size, rt->origin());
218 } else { 217 } else {
219 this->flushMiscFixedFunctionState(); 218 this->flushMiscFixedFunctionState();
220 219
221 GrBlendCoeff srcCoeff = optState->getSrcBlendCoeff(); 220 GrBlendCoeff srcCoeff;
222 GrBlendCoeff dstCoeff = optState->getDstBlendCoeff(); 221 GrBlendCoeff dstCoeff;
223 222 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr cCoeff, &dstCoeff);
224 // In these blend coeff's we end up drawing nothing so we can skip draw all together 223 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) {
225 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff &&
226 !optState->getStencil().doesWrite()) {
227 return false; 224 return false;
228 } 225 }
229 226
230 const GrEffectStage* geometryProcessor = NULL; 227 const GrEffectStage* geometryProcessor = NULL;
231 SkSTArray<8, const GrEffectStage*, true> colorStages; 228 SkSTArray<8, const GrEffectStage*, true> colorStages;
232 SkSTArray<8, const GrEffectStage*, true> coverageStages; 229 SkSTArray<8, const GrEffectStage*, true> coverageStages;
233 GrGLProgramDesc desc; 230 GrGLProgramDesc desc;
234 if (!GrGLProgramDesc::Build(*optState.get(), 231 if (!GrGLProgramDesc::Build(this->getDrawState(),
235 type, 232 type,
233 blendOpts,
236 srcCoeff, 234 srcCoeff,
237 dstCoeff, 235 dstCoeff,
238 this, 236 this,
239 dstCopy, 237 dstCopy,
240 &geometryProcessor, 238 &geometryProcessor,
241 &colorStages, 239 &colorStages,
242 &coverageStages, 240 &coverageStages,
243 &desc)) { 241 &desc)) {
244 SkDEBUGFAIL("Failed to generate GL program descriptor"); 242 SkDEBUGFAIL("Failed to generate GL program descriptor");
245 return false; 243 return false;
(...skipping 12 matching lines...) Expand all
258 256
259 GrGLuint programID = fCurrentProgram->programID(); 257 GrGLuint programID = fCurrentProgram->programID();
260 if (fHWProgramID != programID) { 258 if (fHWProgramID != programID) {
261 GL_CALL(UseProgram(programID)); 259 GL_CALL(UseProgram(programID));
262 fHWProgramID = programID; 260 fHWProgramID = programID;
263 } 261 }
264 262
265 fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff); 263 fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff);
266 this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff); 264 this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff);
267 265
268 fCurrentProgram->setData(*optState.get(), 266 fCurrentProgram->setData(type,
269 type, 267 blendOpts,
270 geometryProcessor, 268 geometryProcessor,
271 colorStages.begin(), 269 colorStages.begin(),
272 coverageStages.begin(), 270 coverageStages.begin(),
273 dstCopy, 271 dstCopy,
274 &fSharedGLProgramState); 272 &fSharedGLProgramState);
275 } 273 }
276 274
277 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState->getRenderT arget()); 275 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(drawState.getRenderT arget());
278 this->flushStencil(type); 276 this->flushStencil(type);
279 this->flushScissor(glRT->getViewport(), glRT->origin()); 277 this->flushScissor(glRT->getViewport(), glRT->origin());
280 this->flushAAState(type); 278 this->flushAAState(type);
281 279
282 SkIRect* devRect = NULL; 280 SkIRect* devRect = NULL;
283 SkIRect devClipBounds; 281 SkIRect devClipBounds;
284 if (optState->isClipState()) { 282 if (drawState.isClipState()) {
285 this->getClip()->getConservativeBounds(optState->getRenderTarget(), &dev ClipBounds); 283 this->getClip()->getConservativeBounds(drawState.getRenderTarget(), &dev ClipBounds);
286 devRect = &devClipBounds; 284 devRect = &devClipBounds;
287 } 285 }
288 // This must come after textures are flushed because a texture may need 286 // This must come after textures are flushed because a texture may need
289 // to be msaa-resolved (which will modify bound FBO state). 287 // to be msaa-resolved (which will modify bound FBO state).
290 this->flushRenderTarget(glRT, devRect); 288 this->flushRenderTarget(glRT, devRect);
291 289
292 return true; 290 return true;
293 } 291 }
294 292
295 void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { 293 void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) {
296 SkAutoTUnref<GrOptDrawState> optState(this->getDrawState().createOptState()) ;
297 294
298 GrGLsizei stride = static_cast<GrGLsizei>(optState->getVertexStride()); 295 GrGLsizei stride = static_cast<GrGLsizei>(this->getDrawState().getVertexStri de());
299 296
300 size_t vertexOffsetInBytes = stride * info.startVertex(); 297 size_t vertexOffsetInBytes = stride * info.startVertex();
301 298
302 const GeometryPoolState& geoPoolState = this->getGeomPoolState(); 299 const GeometryPoolState& geoPoolState = this->getGeomPoolState();
303 300
304 GrGLVertexBuffer* vbuf; 301 GrGLVertexBuffer* vbuf;
305 switch (this->getGeomSrc().fVertexSrc) { 302 switch (this->getGeomSrc().fVertexSrc) {
306 case kBuffer_GeometrySrcType: 303 case kBuffer_GeometrySrcType:
307 vbuf = (GrGLVertexBuffer*) this->getGeomSrc().fVertexBuffer; 304 vbuf = (GrGLVertexBuffer*) this->getGeomSrc().fVertexBuffer;
308 break; 305 break;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 339 }
343 340
344 SkASSERT(ibuf); 341 SkASSERT(ibuf);
345 SkASSERT(!ibuf->isMapped()); 342 SkASSERT(!ibuf->isMapped());
346 *indexOffsetInBytes += ibuf->baseOffset(); 343 *indexOffsetInBytes += ibuf->baseOffset();
347 } 344 }
348 GrGLAttribArrayState* attribState = 345 GrGLAttribArrayState* attribState =
349 fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf); 346 fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf);
350 347
351 if (fCurrentProgram->hasVertexShader()) { 348 if (fCurrentProgram->hasVertexShader()) {
352 int vertexAttribCount = optState->getVertexAttribCount(); 349 int vertexAttribCount = this->getDrawState().getVertexAttribCount();
353 uint32_t usedAttribArraysMask = 0; 350 uint32_t usedAttribArraysMask = 0;
354 const GrVertexAttrib* vertexAttrib = optState->getVertexAttribs(); 351 const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttri bs();
352
353 bool canIgnoreColorAttrib = this->getDrawState().canIgnoreColorAttribute ();
355 354
356 for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount; 355 for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount;
357 ++vertexAttribIndex, ++vertexAttrib) { 356 ++vertexAttribIndex, ++vertexAttrib) {
357
358 if (kColor_GrVertexAttribBinding != vertexAttrib->fBinding || !canIg noreColorAttrib) {
358 usedAttribArraysMask |= (1 << vertexAttribIndex); 359 usedAttribArraysMask |= (1 << vertexAttribIndex);
359 GrVertexAttribType attribType = vertexAttrib->fType; 360 GrVertexAttribType attribType = vertexAttrib->fType;
360 attribState->set(this, 361 attribState->set(this,
361 vertexAttribIndex, 362 vertexAttribIndex,
362 vbuf, 363 vbuf,
363 GrGLAttribTypeToLayout(attribType).fCount, 364 GrGLAttribTypeToLayout(attribType).fCount,
364 GrGLAttribTypeToLayout(attribType).fType, 365 GrGLAttribTypeToLayout(attribType).fType,
365 GrGLAttribTypeToLayout(attribType).fNormalized, 366 GrGLAttribTypeToLayout(attribType).fNormalized,
366 stride, 367 stride,
367 reinterpret_cast<GrGLvoid*>( 368 reinterpret_cast<GrGLvoid*>(
368 vertexOffsetInBytes + vertexAttrib->fOffset)); 369 vertexOffsetInBytes + vertexAttrib->fOffset));
370 }
369 } 371 }
370 attribState->disableUnusedArrays(this, usedAttribArraysMask); 372 attribState->disableUnusedArrays(this, usedAttribArraysMask);
371 } 373 }
372 } 374 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698