diff options
author | Mike Klein <mtklein@google.com> | 2018-06-19 01:40:57 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-19 01:41:10 +0000 |
commit | 5045e501d2aec23e5f1e4b46346033ac3202c6b0 (patch) | |
tree | b0179c300d6bc1822b0d945be812fff267bb414a /src/gpu/ccpr/GrCCPathProcessor.cpp | |
parent | 63b3bfb711d7e3d4f9ad75681d77a69a3c454ab0 (diff) |
Revert "Change how vertex/instance attributes are handled in geometry processors."
This reverts commit 19c1233c447f625c2522e7ecd0a0adecc629bb2f.
Reason for revert: want to make sure Google3 can roll
Original change's description:
> 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>
TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com
Change-Id: I4800632515e14fbf54af52826928ac915657b59f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/135661
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/gpu/ccpr/GrCCPathProcessor.cpp')
-rw-r--r-- | src/gpu/ccpr/GrCCPathProcessor.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp index e180724f8a..b8ebb44059 100644 --- a/src/gpu/ccpr/GrCCPathProcessor.cpp +++ b/src/gpu/ccpr/GrCCPathProcessor.cpp @@ -65,9 +65,6 @@ 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()) { @@ -85,19 +82,24 @@ GrCCPathProcessor::GrCCPathProcessor(GrResourceProvider* resourceProvider, : INHERITED(kGrCCPathProcessor_ClassID) , fAtlasAccess(std::move(atlas), GrSamplerState::Filter::kNearest, GrSamplerState::WrapMode::kClamp, kFragment_GrShaderFlag) { - 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); + 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); fAtlasAccess.instantiate(resourceProvider); this->addTextureSampler(&fAtlasAccess); @@ -168,7 +170,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 |