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/ops/GrTextureOp.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/ops/GrTextureOp.cpp')
-rw-r--r-- | src/gpu/ops/GrTextureOp.cpp | 112 |
1 files changed, 46 insertions, 66 deletions
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index 95378ac969..80174bcb7d 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -163,14 +163,16 @@ public: args.fUniformHandler, textureGP.fTextureCoords.asShaderVar(), args.fFPCoordTransformHandler); - args.fVaryingHandler->addPassThroughAttribute( - textureGP.fColors, args.fOutputColor, Interpolation::kCanBeFlat); + args.fVaryingHandler->addPassThroughAttribute(&textureGP.fColors, + args.fOutputColor, + Interpolation::kCanBeFlat); args.fFragBuilder->codeAppend("float2 texCoord;"); - args.fVaryingHandler->addPassThroughAttribute(textureGP.fTextureCoords, "texCoord"); + args.fVaryingHandler->addPassThroughAttribute(&textureGP.fTextureCoords, + "texCoord"); if (textureGP.fDomain.isInitialized()) { args.fFragBuilder->codeAppend("float4 domain;"); args.fVaryingHandler->addPassThroughAttribute( - textureGP.fDomain, "domain", + &textureGP.fDomain, "domain", GrGLSLVaryingHandler::Interpolation::kCanBeFlat); args.fFragBuilder->codeAppend( "texCoord = clamp(texCoord, domain.xy, domain.zw);"); @@ -180,7 +182,7 @@ public: SkASSERT(kInt_GrVertexAttribType == textureGP.fTextureIdx.type()); SkASSERT(args.fShaderCaps->integerSupport()); args.fFragBuilder->codeAppend("int texIdx;"); - args.fVaryingHandler->addPassThroughAttribute(textureGP.fTextureIdx, "texIdx", + args.fVaryingHandler->addPassThroughAttribute(&textureGP.fTextureIdx, "texIdx", Interpolation::kMustBeFlat); args.fFragBuilder->codeAppend("switch (texIdx) {"); for (int i = 0; i < textureGP.numTextureSamplers(); ++i) { @@ -314,13 +316,12 @@ private: } if (perspective) { - fPositions = {"position", kFloat3_GrVertexAttribType}; + fPositions = this->addVertexAttrib("position", kFloat3_GrVertexAttribType); } else { - fPositions = {"position", kFloat2_GrVertexAttribType}; + fPositions = this->addVertexAttrib("position", kFloat2_GrVertexAttribType); } - fColors = {"color", kUByte4_norm_GrVertexAttribType}; - fTextureCoords = {"textureCoords", kFloat2_GrVertexAttribType}; - int vertexAttributeCnt = 3; + fColors = this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType); + fTextureCoords = this->addVertexAttrib("textureCoords", kFloat2_GrVertexAttribType); if (samplerCnt > 1) { // Here we initialize any extra samplers by repeating the last one samplerCnt - proxyCnt @@ -331,26 +332,17 @@ private: this->addTextureSampler(&fSamplers[i]); } SkASSERT(caps.integerSupport()); - fTextureIdx = {"textureIdx", kInt_GrVertexAttribType}; - ++vertexAttributeCnt; + fTextureIdx = this->addVertexAttrib("textureIdx", kInt_GrVertexAttribType); } if (domain == Domain::kYes) { - fDomain = {"domain", kFloat4_GrVertexAttribType}; - ++vertexAttributeCnt; + fDomain = this->addVertexAttrib("domain", kFloat4_GrVertexAttribType); } if (coverageAA) { - fAAEdges[0] = {"aaEdge0", kFloat3_GrVertexAttribType}; - fAAEdges[1] = {"aaEdge1", kFloat3_GrVertexAttribType}; - fAAEdges[2] = {"aaEdge2", kFloat3_GrVertexAttribType}; - fAAEdges[3] = {"aaEdge3", kFloat3_GrVertexAttribType}; - vertexAttributeCnt += 4; + fAAEdges[0] = this->addVertexAttrib("aaEdge0", kFloat3_GrVertexAttribType); + fAAEdges[1] = this->addVertexAttrib("aaEdge1", kFloat3_GrVertexAttribType); + fAAEdges[2] = this->addVertexAttrib("aaEdge2", kFloat3_GrVertexAttribType); + fAAEdges[3] = this->addVertexAttrib("aaEdge3", kFloat3_GrVertexAttribType); } - this->setVertexAttributeCnt(vertexAttributeCnt); - } - - const Attribute& onVertexAttribute(int i) const override { - return IthInitializedAttribute(i, fPositions, fColors, fTextureCoords, fTextureIdx, fDomain, - fAAEdges[0], fAAEdges[1], fAAEdges[2], fAAEdges[3]); } Attribute fPositions; @@ -752,7 +744,7 @@ __attribute__((no_sanitize("float-cast-overflow"))) template <typename Pos, MultiTexture MT, Domain D, GrAA AA> void tess(void* v, const float iw[], const float ih[], const GrGeometryProcessor* gp) { using Vertex = TextureGeometryProcessor::Vertex<Pos, MT, D, AA>; - SkASSERT(gp->debugOnly_vertexStride() == sizeof(Vertex)); + SkASSERT(gp->getVertexStride() == sizeof(Vertex)); auto vertices = static_cast<Vertex*>(v); auto proxies = this->proxies(); auto filters = this->filters(); @@ -793,47 +785,10 @@ __attribute__((no_sanitize("float-cast-overflow"))) const GrPipeline* pipeline = target->allocPipeline(args, GrProcessorSet::MakeEmptySet(), target->detachAppliedClip()); - using TessFn = - decltype(&TextureOp::tess<SkPoint, MultiTexture::kNo, Domain::kNo, GrAA::kNo>); -#define TESS_FN_AND_VERTEX_SIZE(Point, MT, Domain, AA) \ - { \ - &TextureOp::tess<Point, MT, Domain, AA>, \ - sizeof(TextureGeometryProcessor::Vertex<Point, MT, Domain, AA>) \ - } - static constexpr struct { - TessFn fTessFn; - size_t fVertexSize; - } kTessFnsAndVertexSizes[] = { - TESS_FN_AND_VERTEX_SIZE(SkPoint, MultiTexture::kNo, Domain::kNo, GrAA::kNo), - TESS_FN_AND_VERTEX_SIZE(SkPoint, MultiTexture::kNo, Domain::kNo, GrAA::kYes), - TESS_FN_AND_VERTEX_SIZE(SkPoint, MultiTexture::kNo, Domain::kYes, GrAA::kNo), - TESS_FN_AND_VERTEX_SIZE(SkPoint, MultiTexture::kNo, Domain::kYes, GrAA::kYes), - TESS_FN_AND_VERTEX_SIZE(SkPoint, MultiTexture::kYes, Domain::kNo, GrAA::kNo), - TESS_FN_AND_VERTEX_SIZE(SkPoint, MultiTexture::kYes, Domain::kNo, GrAA::kYes), - TESS_FN_AND_VERTEX_SIZE(SkPoint, MultiTexture::kYes, Domain::kYes, GrAA::kNo), - TESS_FN_AND_VERTEX_SIZE(SkPoint, MultiTexture::kYes, Domain::kYes, GrAA::kYes), - TESS_FN_AND_VERTEX_SIZE(SkPoint3, MultiTexture::kNo, Domain::kNo, GrAA::kNo), - TESS_FN_AND_VERTEX_SIZE(SkPoint3, MultiTexture::kNo, Domain::kNo, GrAA::kYes), - TESS_FN_AND_VERTEX_SIZE(SkPoint3, MultiTexture::kNo, Domain::kYes, GrAA::kNo), - TESS_FN_AND_VERTEX_SIZE(SkPoint3, MultiTexture::kNo, Domain::kYes, GrAA::kYes), - TESS_FN_AND_VERTEX_SIZE(SkPoint3, MultiTexture::kYes, Domain::kNo, GrAA::kNo), - TESS_FN_AND_VERTEX_SIZE(SkPoint3, MultiTexture::kYes, Domain::kNo, GrAA::kYes), - TESS_FN_AND_VERTEX_SIZE(SkPoint3, MultiTexture::kYes, Domain::kYes, GrAA::kNo), - TESS_FN_AND_VERTEX_SIZE(SkPoint3, MultiTexture::kYes, Domain::kYes, GrAA::kYes), - }; -#undef TESS_FN_AND_VERTEX_SIZE - int tessFnIdx = 0; - tessFnIdx |= coverageAA ? 0x1 : 0x0; - tessFnIdx |= fDomain ? 0x2 : 0x0; - tessFnIdx |= (fProxyCnt > 1) ? 0x4 : 0x0; - tessFnIdx |= fPerspective ? 0x8 : 0x0; - - SkASSERT(kTessFnsAndVertexSizes[tessFnIdx].fVertexSize == gp->debugOnly_vertexStride()); - int vstart; const GrBuffer* vbuffer; - void* vdata = target->makeVertexSpace(kTessFnsAndVertexSizes[tessFnIdx].fVertexSize, - 4 * fDraws.count(), &vbuffer, &vstart); + void* vdata = target->makeVertexSpace(gp->getVertexStride(), 4 * fDraws.count(), &vbuffer, + &vstart); if (!vdata) { SkDebugf("Could not allocate vertices\n"); return; @@ -847,7 +802,32 @@ __attribute__((no_sanitize("float-cast-overflow"))) ih[t] = 1.f / texture->height(); } - (this->*(kTessFnsAndVertexSizes[tessFnIdx].fTessFn))(vdata, iw, ih, gp.get()); + using TessFn = + decltype(&TextureOp::tess<SkPoint, MultiTexture::kNo, Domain::kNo, GrAA::kNo>); + static constexpr TessFn kTessFns[] = { + &TextureOp::tess<SkPoint, MultiTexture::kNo, Domain::kNo, GrAA::kNo>, + &TextureOp::tess<SkPoint, MultiTexture::kNo, Domain::kNo, GrAA::kYes>, + &TextureOp::tess<SkPoint, MultiTexture::kNo, Domain::kYes, GrAA::kNo>, + &TextureOp::tess<SkPoint, MultiTexture::kNo, Domain::kYes, GrAA::kYes>, + &TextureOp::tess<SkPoint, MultiTexture::kYes, Domain::kNo, GrAA::kNo>, + &TextureOp::tess<SkPoint, MultiTexture::kYes, Domain::kNo, GrAA::kYes>, + &TextureOp::tess<SkPoint, MultiTexture::kYes, Domain::kYes, GrAA::kNo>, + &TextureOp::tess<SkPoint, MultiTexture::kYes, Domain::kYes, GrAA::kYes>, + &TextureOp::tess<SkPoint3, MultiTexture::kNo, Domain::kNo, GrAA::kNo>, + &TextureOp::tess<SkPoint3, MultiTexture::kNo, Domain::kNo, GrAA::kYes>, + &TextureOp::tess<SkPoint3, MultiTexture::kNo, Domain::kYes, GrAA::kNo>, + &TextureOp::tess<SkPoint3, MultiTexture::kNo, Domain::kYes, GrAA::kYes>, + &TextureOp::tess<SkPoint3, MultiTexture::kYes, Domain::kNo, GrAA::kNo>, + &TextureOp::tess<SkPoint3, MultiTexture::kYes, Domain::kNo, GrAA::kYes>, + &TextureOp::tess<SkPoint3, MultiTexture::kYes, Domain::kYes, GrAA::kNo>, + &TextureOp::tess<SkPoint3, MultiTexture::kYes, Domain::kYes, GrAA::kYes>, + }; + int tessFnIdx = 0; + tessFnIdx |= coverageAA ? 0x1 : 0x0; + tessFnIdx |= fDomain ? 0x2 : 0x0; + tessFnIdx |= (fProxyCnt > 1) ? 0x4 : 0x0; + tessFnIdx |= fPerspective ? 0x8 : 0x0; + (this->*(kTessFns[tessFnIdx]))(vdata, iw, ih, gp.get()); GrPrimitiveType primitiveType = fDraws.count() > 1 ? GrPrimitiveType::kTriangles : GrPrimitiveType::kTriangleStrip; |