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

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

Issue 637003003: Opt state takes a GP instead of a GeometryStage (Closed) Base URL: https://skia.googlesource.com/skia.git@builder_cleanup
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGLProgramDesc.cpp
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 0c85c99a8a4725659760dd60c92eba7ebeb154a9..7e44612c63d50239dfc7eaba8847527fb1a42f5d 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -73,7 +73,7 @@ static uint32_t gen_attrib_key(const GrGeometryProcessor* effect) {
return key;
}
-static uint32_t gen_transform_key(const GrProcessorStage& effectStage,
+static uint32_t gen_transform_key(const GrFragmentStage& effectStage,
bool useExplicitLocalCoords) {
uint32_t totalKey = 0;
int numTransforms = effectStage.getProcessor()->numTransforms();
@@ -117,30 +117,7 @@ static uint32_t gen_texture_key(const GrProcessor* effect, const GrGLCaps& caps)
* which must be different for every GrProcessor subclass. It can fail if an effect uses too many
* textures, transforms, etc, for the space allotted in the meta-key.
*/
-
-static uint32_t* get_processor_meta_key(const GrProcessorStage& processorStage,
- bool useExplicitLocalCoords,
- const GrGLCaps& caps,
- GrProcessorKeyBuilder* b) {
-
- uint32_t textureKey = gen_texture_key(processorStage.getProcessor(), caps);
- uint32_t transformKey = gen_transform_key(processorStage,useExplicitLocalCoords);
- uint32_t classID = processorStage.getProcessor()->getFactory().effectClassID();
-
- // Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
- // don't fit.
- static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16);
- if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) {
- return NULL;
- }
-
- uint32_t* key = b->add32n(2);
- key[0] = (textureKey << 16 | transformKey);
- key[1] = (classID << 16);
- return key;
-}
-
-static bool get_fp_key(const GrProcessorStage& stage,
+static bool get_fp_key(const GrFragmentStage& stage,
const GrGLCaps& caps,
bool useExplicitLocalCoords,
GrProcessorKeyBuilder* b,
@@ -154,46 +131,56 @@ static bool get_fp_key(const GrProcessorStage& stage,
return false;
}
*processorKeySize = SkToU16(size);
- if (NULL == get_processor_meta_key(stage, useExplicitLocalCoords, caps, b)) {
+ uint32_t textureKey = gen_texture_key(stage.getProcessor(), caps);
+ uint32_t transformKey = gen_transform_key(stage, useExplicitLocalCoords);
+ uint32_t classID = stage.getProcessor()->getFactory().effectClassID();
+
+ // Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
+ // don't fit.
+ static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16);
+ if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) {
return false;
}
+
+ uint32_t* key = b->add32n(2);
+ key[0] = (textureKey << 16 | transformKey);
+ key[1] = (classID << 16);
return true;
}
-static bool get_gp_key(const GrGeometryStage& stage,
+static bool get_gp_key(const GrGeometryProcessor& gp,
const GrGLCaps& caps,
bool useExplicitLocalCoords,
GrProcessorKeyBuilder* b,
uint16_t* processorKeySize) {
- const GrProcessor& effect = *stage.getProcessor();
- const GrBackendProcessorFactory& factory = effect.getFactory();
- factory.getGLProcessorKey(effect, caps, b);
+ const GrBackendProcessorFactory& factory = gp.getFactory();
+ factory.getGLProcessorKey(gp, caps, b);
size_t size = b->size();
if (size > SK_MaxU16) {
*processorKeySize = 0; // suppresses a warning.
return false;
}
*processorKeySize = SkToU16(size);
- uint32_t* key = get_processor_meta_key(stage, useExplicitLocalCoords, caps, b);
- if (NULL == key) {
- return false;
- }
- uint32_t attribKey = gen_attrib_key(stage.getProcessor());
+ uint32_t textureKey = gen_texture_key(&gp, caps);
+ uint32_t attribKey = gen_attrib_key(&gp);
+ uint32_t classID = gp.getFactory().effectClassID();
// Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
// don't fit.
static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16);
- if ((attribKey) & kMetaKeyInvalidMask) {
- return false;
+ if ((textureKey | attribKey | classID) & kMetaKeyInvalidMask) {
+ return false;
}
- key[1] |= attribKey;
+ uint32_t* key = b->add32n(2);
+ key[0] = (textureKey << 16);
+ key[1] = (classID << 16 | attribKey);
return true;
}
struct GeometryProcessorKeyBuilder {
- typedef GrGeometryStage StagedProcessor;
- static bool GetProcessorKey(const GrGeometryStage& gpStage,
+ typedef GrGeometryProcessor StagedProcessor;
+ static bool GetProcessorKey(const GrGeometryProcessor& gpStage,
const GrGLCaps& caps,
bool requiresLocalCoordAttrib,
GrProcessorKeyBuilder* b,
@@ -242,17 +229,9 @@ GrGLProgramDesc::BuildStagedProcessorKey(const typename ProcessorKeyBuilder::Sta
bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
GrGpu::DrawType drawType,
- GrBlendCoeff srcCoeff,
- GrBlendCoeff dstCoeff,
GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
- const GrGeometryStage** geometryProcessor,
- SkTArray<const GrFragmentStage*, true>* colorStages,
- SkTArray<const GrFragmentStage*, true>* coverageStages,
GrGLProgramDesc* desc) {
- colorStages->reset();
- coverageStages->reset();
-
bool inputColorIsUsed = optState.inputColorIsUsed();
bool inputCoverageIsUsed = optState.inputCoverageIsUsed();
@@ -274,15 +253,13 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
// We can only have one effect which touches the vertex shader
if (optState.hasGeometryProcessor()) {
- const GrGeometryStage& gpStage = *optState.getGeometryProcessor();
- if (!BuildStagedProcessorKey<GeometryProcessorKeyBuilder>(gpStage,
+ if (!BuildStagedProcessorKey<GeometryProcessorKeyBuilder>(*optState.getGeometryProcessor(),
gpu->glCaps(),
requiresLocalCoordAttrib,
desc,
&offsetAndSizeIndex)) {
return false;
}
- *geometryProcessor = &gpStage;
}
for (int s = 0; s < optState.numColorStages(); ++s) {
@@ -399,15 +376,8 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
header->fPrimaryOutputType = optState.getPrimaryOutputType();
header->fSecondaryOutputType = optState.getSecondaryOutputType();
- for (int s = 0; s < optState.numColorStages(); ++s) {
- colorStages->push_back(&optState.getColorStage(s));
- }
- for (int s = 0; s < optState.numCoverageStages(); ++s) {
- coverageStages->push_back(&optState.getCoverageStage(s));
- }
-
- header->fColorEffectCnt = colorStages->count();
- header->fCoverageEffectCnt = coverageStages->count();
+ header->fColorEffectCnt = optState.numColorStages();
+ header->fCoverageEffectCnt = optState.numCoverageStages();
desc->finalize();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698