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

Unified Diff: src/gpu/gl/GrGLProgramDesc.cpp

Issue 379113004: 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: Fix sizeof(uint32_t) bug 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | src/gpu/gl/GrGLProgramEffects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgramDesc.cpp
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 2c260cda52b16e3808fc03534b76e6d640ef49fc..27a1fab1e0e1a3e892c1f8866aa38077c64493b7 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -14,13 +14,14 @@
#include "SkChecksum.h"
-static inline bool get_key_and_update_stats(const GrEffectStage& stage,
- const GrGLCaps& caps,
- bool useExplicitLocalCoords,
- GrEffectKeyBuilder* b,
- bool* setTrueIfReadsDst,
- bool* setTrueIfReadsPos,
- bool* setTrueIfHasVertexCode) {
+bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage,
+ const GrGLCaps& caps,
+ bool useExplicitLocalCoords,
+ GrEffectKeyBuilder* b,
+ uint16_t* effectKeySize,
+ bool* setTrueIfReadsDst,
+ bool* setTrueIfReadsPos,
+ bool* setTrueIfHasVertexCode) {
const GrBackendEffectFactory& factory = stage.getEffect()->getFactory();
GrDrawEffect drawEffect(stage, useExplicitLocalCoords);
if (stage.getEffect()->willReadDstColor()) {
@@ -32,7 +33,17 @@ static inline bool get_key_and_update_stats(const GrEffectStage& stage,
if (stage.getEffect()->hasVertexCode()) {
*setTrueIfHasVertexCode = true;
}
- return factory.getGLEffectKey(drawEffect, caps, b);
+ factory.getGLEffectKey(drawEffect, caps, b);
+ size_t size = b->size();
+ if (size > SK_MaxU16) {
+ *effectKeySize = 0; // suppresses a warning.
+ return false;
+ }
+ *effectKeySize = SkToU16(size);
+ if (!GrGLProgramEffects::GenEffectMetaKey(drawEffect, caps, b)) {
+ return false;
+ }
+ return true;
}
bool GrGLProgramDesc::Build(const GrDrawState& drawState,
@@ -105,43 +116,54 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
if (!skipCoverage) {
numStages += drawState.numCoverageStages() - firstEffectiveCoverageStage;
}
- GR_STATIC_ASSERT(0 == kEffectKeyLengthsOffset % sizeof(uint32_t));
+ GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t));
// Make room for everything up to and including the array of offsets to effect keys.
desc->fKey.reset();
- desc->fKey.push_back_n(kEffectKeyLengthsOffset + sizeof(uint32_t) * numStages);
+ desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * numStages);
- size_t offset = desc->fKey.count();
- int offsetIndex = 0;
+ int offsetAndSizeIndex = 0;
bool effectKeySuccess = true;
if (!skipColor) {
for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); ++s) {
- uint32_t* offsetLocation = reinterpret_cast<uint32_t*>(desc->fKey.begin() +
- kEffectKeyLengthsOffset +
- offsetIndex * sizeof(uint32_t));
- *offsetLocation = offset;
- ++offsetIndex;
+ uint16_t* offsetAndSize =
+ reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
+ offsetAndSizeIndex * 2 * sizeof(uint16_t));
GrEffectKeyBuilder b(&desc->fKey);
- effectKeySuccess |= get_key_and_update_stats(drawState.getColorStage(s), gpu->glCaps(),
- requiresLocalCoordAttrib, &b, &readsDst,
- &readFragPosition, &hasVertexCode);
- offset += b.size();
+ uint16_t effectKeySize;
+ uint32_t effectOffset = desc->fKey.count();
+ effectKeySuccess |= GetEffectKeyAndUpdateStats(
+ drawState.getColorStage(s), gpu->glCaps(),
+ requiresLocalCoordAttrib, &b,
+ &effectKeySize, &readsDst,
+ &readFragPosition, &hasVertexCode);
+ effectKeySuccess |= (effectOffset <= SK_MaxU16);
+
+ offsetAndSize[0] = SkToU16(effectOffset);
+ offsetAndSize[1] = effectKeySize;
+ ++offsetAndSizeIndex;
}
}
if (!skipCoverage) {
for (int s = firstEffectiveCoverageStage; s < drawState.numCoverageStages(); ++s) {
- uint32_t* offsetLocation = reinterpret_cast<uint32_t*>(desc->fKey.begin() +
- kEffectKeyLengthsOffset +
- offsetIndex * sizeof(uint32_t));
- *offsetLocation = offset;
- ++offsetIndex;
+ uint16_t* offsetAndSize =
+ reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
+ offsetAndSizeIndex * 2 * sizeof(uint16_t));
+
GrEffectKeyBuilder b(&desc->fKey);
- effectKeySuccess |= get_key_and_update_stats(drawState.getCoverageStage(s),
- gpu->glCaps(), requiresLocalCoordAttrib,
- &b, &readsDst, &readFragPosition,
- &hasVertexCode);
- offset += b.size();
+ uint16_t effectKeySize;
+ uint32_t effectOffset = desc->fKey.count();
+ effectKeySuccess |= GetEffectKeyAndUpdateStats(
+ drawState.getCoverageStage(s), gpu->glCaps(),
+ requiresLocalCoordAttrib, &b,
+ &effectKeySize, &readsDst,
+ &readFragPosition, &hasVertexCode);
+ effectKeySuccess |= (effectOffset <= SK_MaxU16);
+
+ offsetAndSize[0] = SkToU16(effectOffset);
+ offsetAndSize[1] = effectKeySize;
+ ++offsetAndSizeIndex;
}
}
if (!effectKeySuccess) {
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | src/gpu/gl/GrGLProgramEffects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698