diff options
author | Brian Salomon <bsalomon@google.com> | 2018-06-18 12:52:47 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-18 17:13:58 +0000 |
commit | 19c1233c447f625c2522e7ecd0a0adecc629bb2f (patch) | |
tree | 891e06143986ade3aae8d4176ec8b426f70b896f /src/gpu/ccpr/GrCCPathProcessor.cpp | |
parent | 146cf3ce7935019ecc63ce9e93450a8c122880d8 (diff) |
Change how vertex/instance attributes are handled in geometry processors.
* No longer register vertex/instance attributes on base class, just counts
* Separate instance and vertex attributes and remove InputRate and offset
* Make attributes constexpr where possible
Change-Id: I1f1d5e772fa177a96d2aeb805aab7b69f35bfae6
Reviewed-on: https://skia-review.googlesource.com/132405
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Chris Dalton <csmartdalton@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 |