aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sksl/SkSLCompiler.h7
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp11
-rw-r--r--src/sksl/sksl_frag.include1
-rw-r--r--src/sksl/sksl_vert.include3
4 files changed, 17 insertions, 5 deletions
diff --git a/src/sksl/SkSLCompiler.h b/src/sksl/SkSLCompiler.h
index 167f042d52..f7dcf2b5b9 100644
--- a/src/sksl/SkSLCompiler.h
+++ b/src/sksl/SkSLCompiler.h
@@ -17,9 +17,10 @@
#include "SkSLErrorReporter.h"
#include "SkSLIRGenerator.h"
-#define SK_FRAGCOLOR_BUILTIN 10001
-#define SK_FRAGCOORD_BUILTIN 15
-#define SK_VERTEXID_BUILTIN 5
+#define SK_FRAGCOLOR_BUILTIN 10001
+#define SK_FRAGCOORD_BUILTIN 15
+#define SK_VERTEXID_BUILTIN 5
+#define SK_CLIPDISTANCE_BUILTIN 3
namespace SkSL {
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 70e2e7761c..4b1eea3451 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -329,6 +329,9 @@ void GLSLCodeGenerator::writeVariableReference(const VariableReference& ref) {
case SK_VERTEXID_BUILTIN:
this->write("gl_VertexID");
break;
+ case SK_CLIPDISTANCE_BUILTIN:
+ this->write("gl_ClipDistance");
+ break;
default:
this->write(ref.fVariable.fName);
}
@@ -346,7 +349,13 @@ void GLSLCodeGenerator::writeFieldAccess(const FieldAccess& f) {
this->writeExpression(*f.fBase, kPostfix_Precedence);
this->write(".");
}
- this->write(f.fBase->fType.fields()[f.fFieldIndex].fName);
+ switch (f.fBase->fType.fields()[f.fFieldIndex].fModifiers.fLayout.fBuiltin) {
+ case SK_CLIPDISTANCE_BUILTIN:
+ this->write("gl_ClipDistance");
+ break;
+ default:
+ this->write(f.fBase->fType.fields()[f.fFieldIndex].fName);
+ }
}
void GLSLCodeGenerator::writeSwizzle(const Swizzle& swizzle) {
diff --git a/src/sksl/sksl_frag.include b/src/sksl/sksl_frag.include
index 21849866df..d0e30f2574 100644
--- a/src/sksl/sksl_frag.include
+++ b/src/sksl/sksl_frag.include
@@ -3,6 +3,7 @@ STRINGIFY(
// defines built-in interfaces supported by SkiaSL fragment shaders
layout(builtin=15) in vec4 sk_FragCoord;
+layout(builtin=3) float sk_ClipDistance[];
// 9999 is a temporary value that causes us to ignore these declarations beyond
// adding them to the symbol table. This works fine in GLSL (where they do not
diff --git a/src/sksl/sksl_vert.include b/src/sksl/sksl_vert.include
index af74c0c54c..8e14c388a7 100644
--- a/src/sksl/sksl_vert.include
+++ b/src/sksl/sksl_vert.include
@@ -4,7 +4,8 @@ STRINGIFY(
out gl_PerVertex {
layout(builtin=0) vec4 gl_Position;
- layout(builtin=1) float gl_PointSize;
+ layout(builtin=1) float gl_PointSize;
+ layout(builtin=3) float sk_ClipDistance[];
};
layout(builtin=5) int sk_VertexID;