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 /tests/GrMeshTest.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 'tests/GrMeshTest.cpp')
-rw-r--r-- | tests/GrMeshTest.cpp | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp index 4ca0e1d10a..4535f13975 100644 --- a/tests/GrMeshTest.cpp +++ b/tests/GrMeshTest.cpp @@ -292,46 +292,35 @@ private: class GrMeshTestProcessor : public GrGeometryProcessor { public: GrMeshTestProcessor(bool instanced, bool hasVertexBuffer) - : INHERITED(kGrMeshTestProcessor_ClassID) { + : INHERITED(kGrMeshTestProcessor_ClassID) + , fInstanceLocation(nullptr) + , fVertex(nullptr) + , fColor(nullptr) { if (instanced) { - fInstanceLocation = {"location", kHalf2_GrVertexAttribType}; - fColor = {"color", kUByte4_norm_GrVertexAttribType}; - this->setInstanceAttributeCnt(2); + fInstanceLocation = &this->addInstanceAttrib("location", kHalf2_GrVertexAttribType); if (hasVertexBuffer) { - fVertex = {"vertex", kHalf2_GrVertexAttribType}; - this->setVertexAttributeCnt(1); + fVertex = &this->addVertexAttrib("vertex", kHalf2_GrVertexAttribType); } + fColor = &this->addInstanceAttrib("color", kUByte4_norm_GrVertexAttribType); } else { - fVertex = {"vertex", kHalf2_GrVertexAttribType}; - fColor = {"color", kUByte4_norm_GrVertexAttribType}; - this->setVertexAttributeCnt(2); + fVertex = &this->addVertexAttrib("vertex", kHalf2_GrVertexAttribType); + fColor = &this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType); } } const char* name() const override { return "GrMeshTest Processor"; } void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const final { - b->add32(fInstanceLocation.isInitialized()); - b->add32(fVertex.isInitialized()); + b->add32(SkToBool(fInstanceLocation)); + b->add32(SkToBool(fVertex)); } GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const final; -private: - const Attribute& onVertexAttribute(int i) const override { - if (fInstanceLocation.isInitialized()) { - return fVertex; - } - return IthAttribute(i, fVertex, fColor); - } - - const Attribute& onInstanceAttribute(int i) const override { - return IthAttribute(i, fInstanceLocation, fColor); - } - - Attribute fInstanceLocation; - Attribute fVertex; - Attribute fColor; +protected: + const Attribute* fInstanceLocation; + const Attribute* fVertex; + const Attribute* fColor; friend class GLSLMeshTestProcessor; typedef GrGeometryProcessor INHERITED; @@ -349,15 +338,15 @@ class GLSLMeshTestProcessor : public GrGLSLGeometryProcessor { varyingHandler->addPassThroughAttribute(mp.fColor, args.fOutputColor); GrGLSLVertexBuilder* v = args.fVertBuilder; - if (!mp.fInstanceLocation.isInitialized()) { - v->codeAppendf("float2 vertex = %s;", mp.fVertex.name()); + if (!mp.fInstanceLocation) { + v->codeAppendf("float2 vertex = %s;", mp.fVertex->name()); } else { - if (mp.fVertex.isInitialized()) { - v->codeAppendf("float2 offset = %s;", mp.fVertex.name()); + if (mp.fVertex) { + v->codeAppendf("float2 offset = %s;", mp.fVertex->name()); } else { v->codeAppend ("float2 offset = float2(sk_VertexID / 2, sk_VertexID % 2);"); } - v->codeAppendf("float2 vertex = %s + offset * %i;", mp.fInstanceLocation.name(), + v->codeAppendf("float2 vertex = %s + offset * %i;", mp.fInstanceLocation->name(), kBoxSize); } gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertex"); |