diff options
author | Brian Salomon <bsalomon@google.com> | 2018-06-19 14:33:47 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-19 20:01:29 +0000 |
commit | 92be2f74db81f0ed480b55c58cbde39270f9b772 (patch) | |
tree | d2b7135f511a318f10c5c86f2537c07051c922bd /src/gpu/ccpr/GrCCPathProcessor.cpp | |
parent | f5ac906476cd26f2967a48340940e6af580fa71f (diff) |
Revert "Revert "Change how vertex/instance attributes are handled in geometry processors.""
This reverts commit 5045e501d2aec23e5f1e4b46346033ac3202c6b0.
TBR=csmartdalton@google.com
Change-Id: Ifbf5f1d8f8ef340fdc69653e931b6d68d4bf0854
Reviewed-on: https://skia-review.googlesource.com/135862
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/ccpr/GrCCPathProcessor.cpp')
-rw-r--r-- | src/gpu/ccpr/GrCCPathProcessor.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp index b8ebb44059..e180724f8a 100644 --- a/src/gpu/ccpr/GrCCPathProcessor.cpp +++ b/src/gpu/ccpr/GrCCPathProcessor.cpp @@ -65,6 +65,9 @@ static constexpr uint16_t kOctoIndicesAsTris[] = { GR_DECLARE_STATIC_UNIQUE_KEY(gIndexBufferKey); +constexpr GrPrimitiveProcessor::Attribute GrCCPathProcessor::kInstanceAttribs[]; +constexpr GrPrimitiveProcessor::Attribute GrCCPathProcessor::kEdgeNormsAttrib; + sk_sp<const GrBuffer> GrCCPathProcessor::FindIndexBuffer(GrOnFlushResourceProvider* onFlushRP) { GR_DEFINE_STATIC_UNIQUE_KEY(gIndexBufferKey); if (onFlushRP->caps()->usePrimitiveRestart()) { @@ -82,24 +85,19 @@ GrCCPathProcessor::GrCCPathProcessor(GrResourceProvider* resourceProvider, : INHERITED(kGrCCPathProcessor_ClassID) , fAtlasAccess(std::move(atlas), GrSamplerState::Filter::kNearest, GrSamplerState::WrapMode::kClamp, kFragment_GrShaderFlag) { - this->addInstanceAttrib("devbounds", kFloat4_GrVertexAttribType); - this->addInstanceAttrib("devbounds45", kFloat4_GrVertexAttribType); - this->addInstanceAttrib("dev_to_atlas_offset", kInt2_GrVertexAttribType); - this->addInstanceAttrib("color", kUByte4_norm_GrVertexAttribType); - - SkASSERT(offsetof(Instance, fDevBounds) == - this->getInstanceAttrib(InstanceAttribs::kDevBounds).offsetInRecord()); - SkASSERT(offsetof(Instance, fDevBounds45) == - this->getInstanceAttrib(InstanceAttribs::kDevBounds45).offsetInRecord()); - SkASSERT(offsetof(Instance, fDevToAtlasOffset) == - this->getInstanceAttrib(InstanceAttribs::kDevToAtlasOffset).offsetInRecord()); - SkASSERT(offsetof(Instance, fColor) == - this->getInstanceAttrib(InstanceAttribs::kColor).offsetInRecord()); - SkASSERT(sizeof(Instance) == this->getInstanceStride()); - - GR_STATIC_ASSERT(4 == kNumInstanceAttribs); - - this->addVertexAttrib("edge_norms", kFloat4_GrVertexAttribType); + this->setInstanceAttributeCnt(kNumInstanceAttribs); + // Check that instance attributes exactly match Instance struct layout. + SkASSERT(!strcmp(this->instanceAttribute(0).name(), "devbounds")); + SkASSERT(!strcmp(this->instanceAttribute(1).name(), "devbounds45")); + SkASSERT(!strcmp(this->instanceAttribute(2).name(), "dev_to_atlas_offset")); + SkASSERT(!strcmp(this->instanceAttribute(3).name(), "color")); + SkASSERT(this->debugOnly_instanceAttributeOffset(0) == offsetof(Instance, fDevBounds)); + SkASSERT(this->debugOnly_instanceAttributeOffset(1) == offsetof(Instance, fDevBounds45)); + SkASSERT(this->debugOnly_instanceAttributeOffset(2) == offsetof(Instance, fDevToAtlasOffset)); + SkASSERT(this->debugOnly_instanceAttributeOffset(3) == offsetof(Instance, fColor)); + SkASSERT(this->debugOnly_instanceStride() == sizeof(Instance)); + + this->setVertexAttributeCnt(1); fAtlasAccess.instantiate(resourceProvider); this->addTextureSampler(&fAtlasAccess); @@ -170,7 +168,7 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { GrGLSLVarying texcoord(kFloat3_GrSLType); GrGLSLVarying color(kHalf4_GrSLType); varyingHandler->addVarying("texcoord", &texcoord); - varyingHandler->addPassThroughAttribute(&proc.getInstanceAttrib(InstanceAttribs::kColor), + varyingHandler->addPassThroughAttribute(proc.getInstanceAttrib(InstanceAttribs::kColor), args.fOutputColor, Interpolation::kCanBeFlat); // The vertex shader bloats and intersects the devBounds and devBounds45 rectangles, in order to |