aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-11-26 08:50:50 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-26 08:50:50 -0800
commitc67870cfc1e854f1b8a4142bcbc52414beb4207d (patch)
tree844cf8513b13eb00be035bc82313adf9eb7b9f75 /src/gpu/gl
parent986ca61cf7be3ec590f8820e9b7ba042ac2948fe (diff)
Update effect key for descriptor to not record offsets.
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp97
-rw-r--r--src/gpu/gl/GrGLProgramDesc.h18
2 files changed, 24 insertions, 91 deletions
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 954a482f3a..6a2d388692 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -122,16 +122,11 @@ static bool get_meta_key(const GrProcessor& proc,
const GrGLCaps& caps,
uint32_t transformKey,
uint32_t attribKey,
- GrProcessorKeyBuilder* b,
- uint16_t* processorKeySize) {
+ GrProcessorKeyBuilder* b) {
const GrBackendProcessorFactory& factory = proc.getFactory();
factory.getGLProcessorKey(proc, caps, b);
- size_t size = b->size();
- if (size > SK_MaxU16) {
- *processorKeySize = 0; // suppresses a warning.
- return false;
- }
- *processorKeySize = SkToU16(size);
+
+ size_t processorKeySize = b->size();
uint32_t textureKey = gen_texture_key(proc, caps);
uint32_t classID = proc.getFactory().classID();
@@ -141,62 +136,13 @@ static bool get_meta_key(const GrProcessor& proc,
if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) {
return false;
}
-
- uint32_t* key = b->add32n(2);
- key[0] = (textureKey << 16 | transformKey);
- key[1] = (classID << 16);
- return true;
-}
-
-struct GeometryProcessorKeyBuilder {
- typedef GrGeometryProcessor StagedProcessor;
- static bool GetProcessorKey(const GrGeometryProcessor& gp,
- const GrGLCaps& caps,
- bool,
- GrProcessorKeyBuilder* b,
- uint16_t* keySize) {
- /* 0 because no transforms on a GP */
- return get_meta_key(gp, caps, 0, gen_attrib_key(gp), b, keySize);
- }
-};
-
-struct FragmentProcessorKeyBuilder {
- typedef GrPendingFragmentStage StagedProcessor;
- static bool GetProcessorKey(const GrPendingFragmentStage& fps,
- const GrGLCaps& caps,
- bool useLocalCoords,
- GrProcessorKeyBuilder* b,
- uint16_t* keySize) {
- /* 0 because no attribs on a fP */
- return get_meta_key(*fps.getProcessor(), caps, gen_transform_key(fps, useLocalCoords), 0,
- b, keySize);
- }
-};
-
-
-template <class ProcessorKeyBuilder>
-bool GrGLProgramDescBuilder::BuildStagedProcessorKey(
- const typename ProcessorKeyBuilder::StagedProcessor& stage,
- const GrGLCaps& caps,
- bool requiresLocalCoordAttrib,
- GrProgramDesc* desc,
- int* offsetAndSizeIndex) {
- GrProcessorKeyBuilder b(&desc->fKey);
- uint16_t processorKeySize;
- uint32_t processorOffset = desc->fKey.count();
- if (processorOffset > SK_MaxU16 ||
- !ProcessorKeyBuilder::GetProcessorKey(stage, caps, requiresLocalCoordAttrib, &b,
- &processorKeySize)){
- desc->fKey.reset();
+ if (processorKeySize > SK_MaxU16) {
return false;
}
- uint16_t* offsetAndSize =
- reinterpret_cast<uint16_t*>(desc->fKey.begin() + kProcessorKeyOffsetsAndLengthOffset +
- *offsetAndSizeIndex * 2 * sizeof(uint16_t));
- offsetAndSize[0] = SkToU16(processorOffset);
- offsetAndSize[1] = processorKeySize;
- ++(*offsetAndSizeIndex);
+ uint32_t* key = b->add32n(2);
+ key[0] = (textureKey << 16 | transformKey);
+ key[1] = (classID << 16 | SkToU16(processorKeySize));
return true;
}
@@ -215,32 +161,27 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
bool requiresLocalCoordAttrib = descInfo.fRequiresLocalCoordAttrib;
- int numStages = optState.numTotalStages();
-
- GR_STATIC_ASSERT(0 == kProcessorKeyOffsetsAndLengthOffset % sizeof(uint32_t));
- // Make room for everything up to and including the array of offsets to effect keys.
+ GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t));
+ // Make room for everything up to the effect keys.
desc->fKey.reset();
- desc->fKey.push_back_n(kProcessorKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * numStages);
-
- int offsetAndSizeIndex = 0;
+ desc->fKey.push_back_n(kProcessorKeysOffset);
// We can only have one effect which touches the vertex shader
if (optState.hasGeometryProcessor()) {
- if (!BuildStagedProcessorKey<GeometryProcessorKeyBuilder>(*optState.getGeometryProcessor(),
- gpu->glCaps(),
- false,
- desc,
- &offsetAndSizeIndex)) {
+ const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
+ GrProcessorKeyBuilder b(&desc->fKey);
+ if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) {
+ desc->fKey.reset();
return false;
}
}
for (int s = 0; s < optState.numFragmentStages(); ++s) {
- if (!BuildStagedProcessorKey<FragmentProcessorKeyBuilder>(optState.getFragmentStage(s),
- gpu->glCaps(),
- requiresLocalCoordAttrib,
- desc,
- &offsetAndSizeIndex)) {
+ const GrPendingFragmentStage& fps = optState.getFragmentStage(s);
+ GrProcessorKeyBuilder b(&desc->fKey);
+ if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(),
+ gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b)) {
+ desc->fKey.reset();
return false;
}
}
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h
index 8b032e099c..b53daeb444 100644
--- a/src/gpu/gl/GrGLProgramDesc.h
+++ b/src/gpu/gl/GrGLProgramDesc.h
@@ -29,16 +29,16 @@ public:
// 1. uint32_t for total key length.
// 2. uint32_t for a checksum.
// 3. Header struct defined above.
- // 4. An array of offsets to effect keys and their sizes (see 5). uint16_t for each
- // offset and size.
- // 5. per-effect keys. Each effect's key is a variable length array of uint32_t.
+ // 4. Backend-specific information including per-processor keys and their key lengths.
+ // Each processor's key is a variable length array of uint32_t.
enum {
// Part 3.
kHeaderOffset = GrProgramDesc::kHeaderOffset,
kHeaderSize = SkAlign4(sizeof(GLKeyHeader)),
// Part 4.
- // This is the offset in the overall key to the array of per-effect offset,length pairs.
- kProcessorKeyOffsetsAndLengthOffset = kHeaderOffset + kHeaderSize,
+ // This is the offset into the backenend specific part of the key, which includes
+ // per-processor keys.
+ kProcessorKeysOffset = kHeaderOffset + kHeaderSize,
};
/**
@@ -67,14 +67,6 @@ public:
static const GLKeyHeader& GetHeader(const GrProgramDesc& desc) {
return *desc.atOffset<GLKeyHeader, kHeaderOffset>();
}
-
-private:
- template <class ProcessorKeyBuilder>
- static bool BuildStagedProcessorKey(const typename ProcessorKeyBuilder::StagedProcessor& stage,
- const GrGLCaps& caps,
- bool requiresLocalCoordAttrib,
- GrProgramDesc* desc,
- int* offsetAndSizeIndex);
};
#endif