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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 545693004: Calculate stage stats in GrOptDrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@connectOpt2
Patch Set: Nit 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/GrGLProgramDesc.cpp ('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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This is a GPU-backend specific test. It relies on static intializers to work 9 // This is a GPU-backend specific test. It relies on static intializers to work
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 12
13 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 13 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
14 14
15 #include "GrBackendEffectFactory.h" 15 #include "GrBackendEffectFactory.h"
16 #include "GrContextFactory.h" 16 #include "GrContextFactory.h"
17 #include "effects/GrConfigConversionEffect.h" 17 #include "effects/GrConfigConversionEffect.h"
18 #include "gl/GrGLPathRendering.h" 18 #include "gl/GrGLPathRendering.h"
19 #include "gl/GrGpuGL.h" 19 #include "gl/GrGpuGL.h"
20 #include "SkChecksum.h" 20 #include "SkChecksum.h"
21 #include "SkRandom.h" 21 #include "SkRandom.h"
22 #include "Test.h" 22 #include "Test.h"
23 23
24 static void get_stage_stats(const GrEffectStage stage, bool* readsDst,
25 bool* readsFragPosition, bool* requiresVertexShader) {
26 if (stage.getEffect()->willReadDstColor()) {
27 *readsDst = true;
28 }
29 if (stage.getEffect()->willReadFragmentPosition()) {
30 *readsFragPosition = true;
31 }
32 if (stage.getEffect()->requiresVertexShader()) {
33 *requiresVertexShader = true;
34 }
35 }
36
24 bool GrGLProgramDesc::setRandom(SkRandom* random, 37 bool GrGLProgramDesc::setRandom(SkRandom* random,
25 const GrGpuGL* gpu, 38 const GrGpuGL* gpu,
26 const GrRenderTarget* dstRenderTarget, 39 const GrRenderTarget* dstRenderTarget,
27 const GrTexture* dstCopyTexture, 40 const GrTexture* dstCopyTexture,
28 const GrEffectStage* geometryProcessor, 41 const GrEffectStage* geometryProcessor,
29 const GrEffectStage* stages[], 42 const GrEffectStage* stages[],
30 int numColorStages, 43 int numColorStages,
31 int numCoverageStages, 44 int numCoverageStages,
32 int currAttribIndex) { 45 int currAttribIndex) {
33 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k MaxVertexAttribCnt; 46 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k MaxVertexAttribCnt;
(...skipping 16 matching lines...) Expand all
50 uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() + 63 uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
51 kEffectKeyOffsetsA ndLengthOffset + 64 kEffectKeyOffsetsA ndLengthOffset +
52 offset * 2 * sizeo f(uint16_t)); 65 offset * 2 * sizeo f(uint16_t));
53 uint32_t effectKeyOffset = fKey.count(); 66 uint32_t effectKeyOffset = fKey.count();
54 if (effectKeyOffset > SK_MaxU16) { 67 if (effectKeyOffset > SK_MaxU16) {
55 fKey.reset(); 68 fKey.reset();
56 return false; 69 return false;
57 } 70 }
58 GrEffectKeyBuilder b(&fKey); 71 GrEffectKeyBuilder b(&fKey);
59 uint16_t effectKeySize; 72 uint16_t effectKeySize;
60 if (!GetEffectKeyAndUpdateStats(*stage, gpu->glCaps(), useLocalCoords, & b, 73 if (!GetEffectKey(*stage, gpu->glCaps(), useLocalCoords, &b, &effectKeyS ize)) {
61 &effectKeySize, &dstRead, &fragPos, &ver texShader)) {
62 fKey.reset(); 74 fKey.reset();
63 return false; 75 return false;
64 } 76 }
77 get_stage_stats(*stage, &dstRead, &fragPos, &vertexShader);
65 offsetAndSize[0] = effectKeyOffset; 78 offsetAndSize[0] = effectKeyOffset;
66 offsetAndSize[1] = effectKeySize; 79 offsetAndSize[1] = effectKeySize;
67 offset++; 80 offset++;
68 } 81 }
69 82
70 for (int s = 0; s < numStages; ++s, ++offset) { 83 for (int s = 0; s < numStages; ++s, ++offset) {
71 const GrEffectStage* stage = stages[s]; 84 const GrEffectStage* stage = stages[s];
72 uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() + 85 uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
73 kEffectKeyOffsetsA ndLengthOffset + 86 kEffectKeyOffsetsA ndLengthOffset +
74 offset * 2 * sizeo f(uint16_t)); 87 offset * 2 * sizeo f(uint16_t));
75 uint32_t effectKeyOffset = fKey.count(); 88 uint32_t effectKeyOffset = fKey.count();
76 if (effectKeyOffset > SK_MaxU16) { 89 if (effectKeyOffset > SK_MaxU16) {
77 fKey.reset(); 90 fKey.reset();
78 return false; 91 return false;
79 } 92 }
80 GrEffectKeyBuilder b(&fKey); 93 GrEffectKeyBuilder b(&fKey);
81 uint16_t effectKeySize; 94 uint16_t effectKeySize;
82 if (!GetEffectKeyAndUpdateStats(*stage, gpu->glCaps(), useLocalCoords, & b, 95 if (!GetEffectKey(*stages[s], gpu->glCaps(), useLocalCoords, &b, &effect KeySize)) {
83 &effectKeySize, &dstRead, &fragPos, &ver texShader)) {
84 fKey.reset(); 96 fKey.reset();
85 return false; 97 return false;
86 } 98 }
99 get_stage_stats(*stage, &dstRead, &fragPos, &vertexShader);
87 offsetAndSize[0] = effectKeyOffset; 100 offsetAndSize[0] = effectKeyOffset;
88 offsetAndSize[1] = effectKeySize; 101 offsetAndSize[1] = effectKeySize;
89 } 102 }
90 103
91 KeyHeader* header = this->header(); 104 KeyHeader* header = this->header();
92 memset(header, 0, kHeaderSize); 105 memset(header, 0, kHeaderSize);
93 header->fEmitsPointSize = random->nextBool(); 106 header->fEmitsPointSize = random->nextBool();
94 107
95 header->fPositionAttributeIndex = 0; 108 header->fPositionAttributeIndex = 0;
96 109
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); 383 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1));
371 GrConfigConversionEffect::Create(NULL, 384 GrConfigConversionEffect::Create(NULL,
372 false, 385 false,
373 GrConfigConversionEffect::kNone_PMConversio n, 386 GrConfigConversionEffect::kNone_PMConversio n,
374 SkMatrix::I()); 387 SkMatrix::I());
375 SkScalar matrix[20]; 388 SkScalar matrix[20];
376 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); 389 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix));
377 } 390 }
378 391
379 #endif 392 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698