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

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

Issue 25846002: Use vertexless shaders when NVpr is available (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix mac build Created 7 years, 2 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/GrGpuGL.cpp ('k') | tests/GLProgramsTest.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"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void GrGpuGL::abandonResources(){ 203 void GrGpuGL::abandonResources(){
204 INHERITED::abandonResources(); 204 INHERITED::abandonResources();
205 fProgramCache->abandon(); 205 fProgramCache->abandon();
206 fHWProgramID = 0; 206 fHWProgramID = 0;
207 } 207 }
208 208
209 //////////////////////////////////////////////////////////////////////////////// 209 ////////////////////////////////////////////////////////////////////////////////
210 210
211 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) 211 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
212 212
213 void GrGpuGL::flushPathStencilMatrix() {
214 const SkMatrix& viewMatrix = this->getDrawState().getViewMatrix();
215 const GrRenderTarget* rt = this->getDrawState().getRenderTarget();
216 SkISize size;
217 size.set(rt->width(), rt->height());
218 const SkMatrix& vm = this->getDrawState().getViewMatrix();
219
220 if (fHWProjectionMatrixState.fRenderTargetOrigin != rt->origin() ||
221 !fHWProjectionMatrixState.fViewMatrix.cheapEqualTo(viewMatrix) ||
222 fHWProjectionMatrixState.fRenderTargetSize!= size) {
223
224 fHWProjectionMatrixState.fViewMatrix = vm;
225 fHWProjectionMatrixState.fRenderTargetSize = size;
226 fHWProjectionMatrixState.fRenderTargetOrigin = rt->origin();
227
228 GrGLfloat projectionMatrix[4 * 4];
229 fHWProjectionMatrixState.getGLMatrix<4>(projectionMatrix);
230 GL_CALL(MatrixMode(GR_GL_PROJECTION));
231 GL_CALL(LoadMatrixf(projectionMatrix));
232 }
233 }
234
235 bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC opy) { 213 bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC opy) {
236 const GrDrawState& drawState = this->getDrawState(); 214 const GrDrawState& drawState = this->getDrawState();
237 215
238 // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true. 216 // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true.
239 SkASSERT(NULL != drawState.getRenderTarget()); 217 SkASSERT(NULL != drawState.getRenderTarget());
240 218
241 if (kStencilPath_DrawType == type) { 219 if (kStencilPath_DrawType == type) {
242 this->flushPathStencilMatrix(); 220 const GrRenderTarget* rt = this->getDrawState().getRenderTarget();
221 SkISize size;
222 size.set(rt->width(), rt->height());
223 this->setProjectionMatrix(drawState.getViewMatrix(), size, rt->origin()) ;
243 } else { 224 } else {
244 this->flushMiscFixedFunctionState(); 225 this->flushMiscFixedFunctionState();
245 226
246 GrBlendCoeff srcCoeff; 227 GrBlendCoeff srcCoeff;
247 GrBlendCoeff dstCoeff; 228 GrBlendCoeff dstCoeff;
248 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr cCoeff, &dstCoeff); 229 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr cCoeff, &dstCoeff);
249 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) { 230 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) {
250 return false; 231 return false;
251 } 232 }
252 233
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 GrCrash("Unknown geometry src type!"); 334 GrCrash("Unknown geometry src type!");
354 } 335 }
355 336
356 SkASSERT(NULL != ibuf); 337 SkASSERT(NULL != ibuf);
357 SkASSERT(!ibuf->isLocked()); 338 SkASSERT(!ibuf->isLocked());
358 *indexOffsetInBytes += ibuf->baseOffset(); 339 *indexOffsetInBytes += ibuf->baseOffset();
359 } 340 }
360 GrGLAttribArrayState* attribState = 341 GrGLAttribArrayState* attribState =
361 fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf); 342 fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf);
362 343
363 uint32_t usedAttribArraysMask = 0; 344 if (!fCurrentProgram->hasVertexShader()) {
364 const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs() ; 345 int posIdx = this->getDrawState().positionAttributeIndex();
365 int vertexAttribCount = this->getDrawState().getVertexAttribCount(); 346 const GrVertexAttrib* vertexArray = this->getDrawState().getVertexAttrib s() + posIdx;
366 for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount; 347 GrVertexAttribType vertexArrayType = vertexArray->fType;
367 ++vertexAttribIndex, ++vertexAttrib) { 348 SkASSERT(!GrGLAttribTypeToLayout(vertexArrayType).fNormalized);
349 SkASSERT(GrGLAttribTypeToLayout(vertexArrayType).fCount == 2);
350 attribState->setFixedFunctionVertexArray(this,
351 vbuf,
352 2,
353 GrGLAttribTypeToLayout(vertexAr rayType).fType,
354 stride,
355 reinterpret_cast<GrGLvoid*>(
356 vertexOffsetInBytes + vertexArr ay->fOffset));
357 attribState->disableUnusedArrays(this, 0, true);
358 } else {
359 uint32_t usedAttribArraysMask = 0;
360 const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttri bs();
361 int vertexAttribCount = this->getDrawState().getVertexAttribCount();
362 for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount;
363 ++vertexAttribIndex, ++vertexAttrib) {
368 364
369 usedAttribArraysMask |= (1 << vertexAttribIndex); 365 usedAttribArraysMask |= (1 << vertexAttribIndex);
370 GrVertexAttribType attribType = vertexAttrib->fType; 366 GrVertexAttribType attribType = vertexAttrib->fType;
371 attribState->set(this, 367 attribState->set(this,
372 vertexAttribIndex, 368 vertexAttribIndex,
373 vbuf, 369 vbuf,
374 GrGLAttribTypeToLayout(attribType).fCount, 370 GrGLAttribTypeToLayout(attribType).fCount,
375 GrGLAttribTypeToLayout(attribType).fType, 371 GrGLAttribTypeToLayout(attribType).fType,
376 GrGLAttribTypeToLayout(attribType).fNormalized, 372 GrGLAttribTypeToLayout(attribType).fNormalized,
377 stride, 373 stride,
378 reinterpret_cast<GrGLvoid*>( 374 reinterpret_cast<GrGLvoid*>(
379 vertexOffsetInBytes + vertexAttrib->fOffset)); 375 vertexOffsetInBytes + vertexAttrib->fOffset));
376 }
377
378 attribState->disableUnusedArrays(this, usedAttribArraysMask, false);
380 } 379 }
381
382 attribState->disableUnusedArrays(this, usedAttribArraysMask, false);
383 } 380 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698