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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 394213002: Revert of Makes GrGLProgramDesc's key store the lengths as well as offsets of the effect keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@key
Patch Set: Created 6 years, 5 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/GrGLProgramEffects.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
(...skipping 17 matching lines...) Expand all
28 const GrTexture* dstCopyTexture, 28 const GrTexture* dstCopyTexture,
29 const GrEffectStage* stages[], 29 const GrEffectStage* stages[],
30 int numColorStages, 30 int numColorStages,
31 int numCoverageStages, 31 int numCoverageStages,
32 int currAttribIndex) { 32 int currAttribIndex) {
33 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k MaxVertexAttribCnt; 33 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k MaxVertexAttribCnt;
34 34
35 int numStages = numColorStages + numCoverageStages; 35 int numStages = numColorStages + numCoverageStages;
36 fKey.reset(); 36 fKey.reset();
37 37
38 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); 38 GR_STATIC_ASSERT(0 == kEffectKeyLengthsOffset % sizeof(uint32_t));
39 39
40 // Make room for everything up to and including the array of offsets to effe ct keys. 40 // Make room for everything up to and including the array of offsets to effe ct keys.
41 fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * n umStages); 41 fKey.push_back_n(kEffectKeyLengthsOffset + sizeof(uint32_t) * numStages);
42
43 size_t offset = fKey.count();
44 int offsetIndex = 0;
42 45
43 bool dstRead = false; 46 bool dstRead = false;
44 bool fragPos = false; 47 bool fragPos = false;
45 bool vertexCode = false; 48 bool vertexCode = false;
46 for (int s = 0; s < numStages; ++s) { 49 for (int s = 0; s < numStages; ++s) {
47 uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() + 50 uint32_t* offsetLocation = reinterpret_cast<uint32_t*>(fKey.begin() +
48 kEffectKeyOffsetsA ndLengthOffset + 51 kEffectKeyLengths Offset +
49 s * 2 * sizeof(uin t16_t)); 52 offsetIndex * siz eof(uint32_t));
50 uint32_t effectKeyOffset = fKey.count(); 53 *offsetLocation = offset;
51 if (effectKeyOffset > SK_MaxU16) { 54 ++offsetIndex;
55
56 const GrBackendEffectFactory& factory = stages[s]->getEffect()->getFacto ry();
57 GrDrawEffect drawEffect(*stages[s], useLocalCoords);
58 GrEffectKeyBuilder b(&fKey);
59 if (!factory.getGLEffectKey(drawEffect, gpu->glCaps(), &b)) {
52 fKey.reset(); 60 fKey.reset();
53 return false; 61 return false;
54 } 62 }
55 GrDrawEffect drawEffect(*stages[s], useLocalCoords); 63 if (stages[s]->getEffect()->willReadDstColor()) {
56 GrEffectKeyBuilder b(&fKey); 64 dstRead = true;
57 uint16_t effectKeySize;
58 if (!GetEffectKeyAndUpdateStats(*stages[s], gpu->glCaps(), useLocalCoord s, &b,
59 &effectKeySize, &dstRead, &fragPos, &ver texCode)) {
60 fKey.reset();
61 return false;
62 } 65 }
63 offsetAndSize[0] = effectKeyOffset; 66 if (stages[s]->getEffect()->willReadFragmentPosition()) {
64 offsetAndSize[1] = effectKeySize; 67 fragPos = true;
68 }
69 if (stages[s]->getEffect()->hasVertexCode()) {
70 vertexCode = true;
71 }
72
73 offset += b.size();
65 } 74 }
66 75
67 KeyHeader* header = this->header(); 76 KeyHeader* header = this->header();
68 memset(header, 0, kHeaderSize); 77 memset(header, 0, kHeaderSize);
69 header->fEmitsPointSize = random->nextBool(); 78 header->fEmitsPointSize = random->nextBool();
70 79
71 header->fPositionAttributeIndex = 0; 80 header->fPositionAttributeIndex = 0;
72 81
73 // if the effects have used up all off the available attributes, 82 // if the effects have used up all off the available attributes,
74 // don't try to use color or coverage attributes as input 83 // don't try to use color or coverage attributes as input
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); 282 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1));
274 GrConfigConversionEffect::Create(NULL, 283 GrConfigConversionEffect::Create(NULL,
275 false, 284 false,
276 GrConfigConversionEffect::kNone_PMConversio n, 285 GrConfigConversionEffect::kNone_PMConversio n,
277 SkMatrix::I()); 286 SkMatrix::I());
278 SkScalar matrix[20]; 287 SkScalar matrix[20];
279 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); 288 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix));
280 } 289 }
281 290
282 #endif 291 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramEffects.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698