From 32451cf9bc3475b527b0a4228da9a16f303ea26f Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Thu, 11 Nov 2021 18:54:21 -0700 Subject: [PATCH] Fix PatchAttribs issues with explicit curve type - PathTessellator was accidentally not updating its own attribs when kExplicitCurveType was needed. - GrPathTessellationShader was asserting too broadly surrounding kExplicitCurveType. Bug: skia:12524 Change-Id: Iafe543cbc65c2225a9a99f14d7172182033e92c9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/470518 Commit-Queue: Chris Dalton Commit-Queue: Jorge Betancourt Auto-Submit: Chris Dalton Reviewed-by: Jorge Betancourt --- src/gpu/tessellate/PathTessellator.h | 2 +- .../tessellate/shaders/GrPathTessellationShader.cpp | 6 ------ .../shaders/GrPathTessellationShader_Hardware.cpp | 1 + .../shaders/GrPathTessellationShader_MiddleOut.cpp | 10 ++++++++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gpu/tessellate/PathTessellator.h b/src/gpu/tessellate/PathTessellator.h index 7ffcec5ed8..a512431c77 100644 --- a/src/gpu/tessellate/PathTessellator.h +++ b/src/gpu/tessellate/PathTessellator.h @@ -118,7 +118,7 @@ protected: PathTessellator(bool infinitySupport, PatchAttribs attribs) : fAttribs(attribs) { if (!infinitySupport) { - attribs |= PatchAttribs::kExplicitCurveType; + fAttribs |= PatchAttribs::kExplicitCurveType; } } diff --git a/src/gpu/tessellate/shaders/GrPathTessellationShader.cpp b/src/gpu/tessellate/shaders/GrPathTessellationShader.cpp index e5a41316fc..439cf439e1 100644 --- a/src/gpu/tessellate/shaders/GrPathTessellationShader.cpp +++ b/src/gpu/tessellate/shaders/GrPathTessellationShader.cpp @@ -115,12 +115,6 @@ float2 eval_rational_cubic(float4x3 P, float T) { void GrPathTessellationShader::Impl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { const auto& shader = args.fGeomProc.cast(); - - // We should use explicit curve type when, and only when, there isn't infinity support. - // Otherwise the GPU can infer curve type based on infinity. - SkASSERT(args.fShaderCaps->infinitySupport() != - (shader.fAttribs & PatchAttribs::kExplicitCurveType)); - args.fVaryingHandler->emitAttributes(shader); // Vertex shader. diff --git a/src/gpu/tessellate/shaders/GrPathTessellationShader_Hardware.cpp b/src/gpu/tessellate/shaders/GrPathTessellationShader_Hardware.cpp index 0e34e970c7..76a177c47d 100644 --- a/src/gpu/tessellate/shaders/GrPathTessellationShader_Hardware.cpp +++ b/src/gpu/tessellate/shaders/GrPathTessellationShader_Hardware.cpp @@ -343,6 +343,7 @@ GrPathTessellationShader* GrPathTessellationShader::MakeHardwareTessellationShad SkArenaAlloc* arena, const SkMatrix& viewMatrix, const SkPMColor4f& color, PatchAttribs attribs) { SkASSERT(!(attribs & PatchAttribs::kColor)); // Not yet implemented. + SkASSERT(!(attribs & PatchAttribs::kExplicitCurveType)); // Not yet implemented. if (attribs & PatchAttribs::kFanPoint) { return arena->make(viewMatrix, color, attribs); } else { diff --git a/src/gpu/tessellate/shaders/GrPathTessellationShader_MiddleOut.cpp b/src/gpu/tessellate/shaders/GrPathTessellationShader_MiddleOut.cpp index cf36732d47..df1afce6a0 100644 --- a/src/gpu/tessellate/shaders/GrPathTessellationShader_MiddleOut.cpp +++ b/src/gpu/tessellate/shaders/GrPathTessellationShader_MiddleOut.cpp @@ -210,7 +210,13 @@ std::unique_ptr MiddleOutShader::makeProgramIm } // namespace GrPathTessellationShader* GrPathTessellationShader::MakeMiddleOutFixedCountShader( - const GrShaderCaps& shaderCaps, SkArenaAlloc* arena, const SkMatrix& viewMatrix, - const SkPMColor4f& color, PatchAttribs attribs) { + const GrShaderCaps& shaderCaps, + SkArenaAlloc* arena, + const SkMatrix& viewMatrix, + const SkPMColor4f& color, + PatchAttribs attribs) { + // We should use explicit curve type when, and only when, there isn't infinity support. + // Otherwise the GPU can infer curve type based on infinity. + SkASSERT(shaderCaps.infinitySupport() != (attribs & PatchAttribs::kExplicitCurveType)); return arena->make(shaderCaps, viewMatrix, color, attribs); }