Add back door support for GLSL tessellation shaders
Implements tessellation support at the Ganesh level, and adds back
door methods for supplying raw GLSL strings directly to the OpenGL
driver. Adds a new gm to verify tessellation is works in GL.
Change-Id: Idfc285b955cbe5e8e6bf0475be8b518b0cc6ed2c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261196
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h
index 4a0bd72..8f5ca9c 100644
--- a/src/gpu/GrPrimitiveProcessor.h
+++ b/src/gpu/GrPrimitiveProcessor.h
@@ -164,9 +164,13 @@
size_t vertexStride() const { return fVertexAttributes.fStride; }
size_t instanceStride() const { return fInstanceAttributes.fStride; }
- // Only the GrGeometryProcessor subclass actually has a geo shader or vertex attributes, but
- // we put these calls on the base class to prevent having to cast
- virtual bool willUseGeoShader() const = 0;
+ bool willUseTessellationShaders() const {
+ return fShaders & (kTessControl_GrShaderFlag | kTessEvaluation_GrShaderFlag);
+ }
+
+ bool willUseGeoShader() const {
+ return fShaders & kGeometry_GrShaderFlag;
+ }
/**
* Computes a key for the transforms owned by an FP based on the shader code that will be
@@ -206,6 +210,17 @@
virtual bool isPathRendering() const { return false; }
+ // We use these methods as a temporary back door to inject OpenGL tessellation code. Once
+ // tessellation is supported by SkSL we can remove these.
+ virtual SkString getTessControlShaderGLSL(const char* versionAndExtensionDecls,
+ const GrShaderCaps&) const {
+ SK_ABORT("Not implemented.");
+ }
+ virtual SkString getTessEvaluationShaderGLSL(const char* versionAndExtensionDecls,
+ const GrShaderCaps&) const {
+ SK_ABORT("Not implemented.");
+ }
+
protected:
void setVertexAttributes(const Attribute* attrs, int attrCount) {
fVertexAttributes.init(attrs, attrCount);
@@ -214,6 +229,10 @@
SkASSERT(attrCount >= 0);
fInstanceAttributes.init(attrs, attrCount);
}
+ void setWillUseTessellationShaders() {
+ fShaders |= kTessControl_GrShaderFlag | kTessEvaluation_GrShaderFlag;
+ }
+ void setWillUseGeoShader() { fShaders |= kGeometry_GrShaderFlag; }
void setTextureSamplerCnt(int cnt) {
SkASSERT(cnt >= 0);
fTextureSamplerCnt = cnt;
@@ -233,6 +252,8 @@
private:
virtual const TextureSampler& onTextureSampler(int) const { return IthTextureSampler(0); }
+ GrShaderFlags fShaders = kVertex_GrShaderFlag | kFragment_GrShaderFlag;
+
AttributeSet fVertexAttributes;
AttributeSet fInstanceAttributes;