For a frag proc, its key will be a concatenation of all its descendant procs' keys in postorder traversal.
BUG=skia:4182 Review URL: https://codereview.chromium.org/1297503007
This commit is contained in:
parent
87e4752fc1
commit
a7f4c435bc
@ -37,9 +37,10 @@ enum MatrixType {
|
||||
};
|
||||
|
||||
uint32_t
|
||||
GrPrimitiveProcessor::getTransformKey(const SkTArray<const GrCoordTransform*, true>& coords) const {
|
||||
GrPrimitiveProcessor::getTransformKey(const SkTArray<const GrCoordTransform*, true>& coords,
|
||||
int numCoords) const {
|
||||
uint32_t totalKey = 0;
|
||||
for (int t = 0; t < coords.count(); ++t) {
|
||||
for (int t = 0; t < numCoords; ++t) {
|
||||
uint32_t key = 0;
|
||||
const GrCoordTransform* coordTransform = coords[t];
|
||||
if (coordTransform->getMatrix().hasPerspective()) {
|
||||
|
@ -220,13 +220,19 @@ public:
|
||||
size_t getVertexStride() const { return fVertexStride; }
|
||||
|
||||
/**
|
||||
* Gets a transformKey from an array of coord transforms
|
||||
* Computes a transformKey from an array of coord transforms. Will only look at the first
|
||||
* <numCoords> transforms in the array.
|
||||
*
|
||||
* TODO: A better name for this function would be "compute" instead of "get".
|
||||
*/
|
||||
uint32_t getTransformKey(const SkTArray<const GrCoordTransform*, true>&) const;
|
||||
uint32_t getTransformKey(const SkTArray<const GrCoordTransform*, true>& coords,
|
||||
int numCoords) const;
|
||||
|
||||
/**
|
||||
* Sets a unique key on the GrProcessorKeyBuilder that is directly associated with this geometry
|
||||
* processor's GL backend implementation.
|
||||
*
|
||||
* TODO: A better name for this function would be "compute" instead of "get".
|
||||
*/
|
||||
virtual void getGLProcessorKey(const GrBatchTracker& bt,
|
||||
const GrGLSLCaps& caps,
|
||||
|
@ -61,6 +61,8 @@ static uint32_t gen_texture_key(const GrProcessor& proc, 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. NOTE, both FPs and GPs share
|
||||
* this function because it is hairy, though FPs do not have attribs, and GPs do not have transforms
|
||||
*
|
||||
* TODO: A better name for this function would be "compute" instead of "get".
|
||||
*/
|
||||
static bool get_meta_key(const GrProcessor& proc,
|
||||
const GrGLCaps& caps,
|
||||
@ -86,6 +88,26 @@ static bool get_meta_key(const GrProcessor& proc,
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: A better name for this function would be "compute" instead of "get".
|
||||
*/
|
||||
static bool get_frag_proc_and_meta_keys(const GrPrimitiveProcessor& primProc,
|
||||
const GrFragmentProcessor& fp,
|
||||
const GrGLCaps& caps,
|
||||
GrProcessorKeyBuilder* b) {
|
||||
for (int i = 0; i < fp.numChildProcessors(); ++i) {
|
||||
if (!get_frag_proc_and_meta_keys(primProc, fp.childProcessor(i), caps, b)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fp.getGLProcessorKey(*caps.glslCaps(), b);
|
||||
|
||||
//**** use glslCaps here?
|
||||
return get_meta_key(fp, caps, primProc.getTransformKey(fp.coordTransforms(),
|
||||
fp.numTransformsExclChildren()), b);
|
||||
}
|
||||
|
||||
bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
|
||||
const GrPrimitiveProcessor& primProc,
|
||||
const GrPipeline& pipeline,
|
||||
@ -115,11 +137,7 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
|
||||
for (int s = 0; s < pipeline.numFragmentStages(); ++s) {
|
||||
const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s);
|
||||
const GrFragmentProcessor& fp = *fps.processor();
|
||||
|
||||
fp.getGLProcessorKey(*gpu->glCaps().glslCaps(), &b);
|
||||
|
||||
//**** use glslCaps here?
|
||||
if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTransforms()), &b)) {
|
||||
if (!get_frag_proc_and_meta_keys(primProc, fp, gpu->glCaps(), &b)) {
|
||||
glDesc->key().reset();
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user