aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/GLInstancedArraysBench.cpp2
-rw-r--r--bench/GLVec4ScalarBench.cpp2
-rw-r--r--bench/GLVertexAttributesBench.cpp2
-rw-r--r--src/gpu/ccpr/GrCCPRCoverageProcessor.cpp2
-rw-r--r--src/gpu/ccpr/GrCCPRCubicProcessor.cpp8
-rw-r--r--src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp6
-rw-r--r--src/gpu/ccpr/GrCCPRTriangleProcessor.cpp6
-rw-r--r--src/gpu/gl/GrGLGpu.cpp10
-rw-r--r--src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp8
-rw-r--r--src/gpu/vk/GrVkCopyManager.cpp4
-rw-r--r--src/sksl/README2
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp9
-rw-r--r--src/sksl/ast/SkSLASTInterfaceBlock.h6
-rw-r--r--src/sksl/ir/SkSLInterfaceBlock.h6
-rw-r--r--src/sksl/sksl_geom.include8
-rw-r--r--src/sksl/sksl_vert.include4
-rw-r--r--tests/SkSLGLSLTest.cpp8
17 files changed, 51 insertions, 42 deletions
diff --git a/bench/GLInstancedArraysBench.cpp b/bench/GLInstancedArraysBench.cpp
index 3a2dac6ac8..8a07002dd7 100644
--- a/bench/GLInstancedArraysBench.cpp
+++ b/bench/GLInstancedArraysBench.cpp
@@ -126,7 +126,7 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
vshaderTxt.append(
"void main()\n"
"{\n"
- "gl_Position = float4(a_position, 0., 1.);\n"
+ "sk_Position = float4(a_position, 0., 1.);\n"
"o_color = a_color;\n"
"}\n");
diff --git a/bench/GLVec4ScalarBench.cpp b/bench/GLVec4ScalarBench.cpp
index 7a677dfa16..2a68381438 100644
--- a/bench/GLVec4ScalarBench.cpp
+++ b/bench/GLVec4ScalarBench.cpp
@@ -119,7 +119,7 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
vshaderTxt.append(
"void main()\n"
"{\n"
- " gl_Position = float4(a_position, 0.0, 1.0);\n"
+ " sk_Position = float4(a_position, 0.0, 1.0);\n"
" o_position = a_position;\n"
" o_color = a_color;\n"
"}\n");
diff --git a/bench/GLVertexAttributesBench.cpp b/bench/GLVertexAttributesBench.cpp
index d83662f778..ea0bbcb535 100644
--- a/bench/GLVertexAttributesBench.cpp
+++ b/bench/GLVertexAttributesBench.cpp
@@ -101,7 +101,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
vshaderTxt.append(
"void main()\n"
"{\n"
- "gl_Position = a_position;\n");
+ "sk_Position = a_position;\n");
for (uint32_t i = 0; i < attribs; i++) {
vshaderTxt.appendf("%s = %s;\n", oVars[i].c_str(), aVars[i].c_str());
diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
index a295f05d47..4a0dd2666a 100644
--- a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
@@ -145,7 +145,7 @@ void PrimitiveProcessor::emitGeometryShader(const GrCCPRCoverageProcessor& proc,
fnBody.appendf("%s = %s * %s;",
fFragCoverageTimesWind.gsOut(), coverage, fGeomWind.c_str());
}
- fnBody.append ("gl_Position = float4(position, 0, 1);");
+ fnBody.append ("sk_Position = float4(position, 0, 1);");
fnBody.append ("EmitVertex();");
return fnBody;
}().c_str(), &emitVertexFn);
diff --git a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
index 6070527401..ac8359b3df 100644
--- a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
@@ -46,10 +46,10 @@ void GrCCPRCubicProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdju
void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const char* emitVertexFn,
const char* wind, const char* rtAdjust) const {
// Prepend bezierpts at the start of the shader.
- g->codePrependf("float4x2 bezierpts = float4x2(sk_in[0].gl_Position.xy, "
- "sk_in[1].gl_Position.xy, "
- "sk_in[2].gl_Position.xy, "
- "sk_in[3].gl_Position.xy);");
+ g->codePrependf("float4x2 bezierpts = float4x2(sk_in[0].sk_Position.xy, "
+ "sk_in[1].sk_Position.xy, "
+ "sk_in[2].sk_Position.xy, "
+ "sk_in[3].sk_Position.xy);");
// Evaluate the cubic at T=.5 for an mid-ish point.
g->codeAppendf("float2 midpoint = bezierpts * float4(.125, .375, .375, .125);");
diff --git a/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp b/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
index 9b85783afd..2a56b22227 100644
--- a/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
@@ -45,9 +45,9 @@ void GrCCPRQuadraticProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
const char* emitVertexFn, const char* wind,
const char* rtAdjust) const {
// Prepend bezierpts at the start of the shader.
- g->codePrependf("float3x2 bezierpts = float3x2(sk_in[0].gl_Position.xy, "
- "sk_in[1].gl_Position.xy, "
- "sk_in[2].gl_Position.xy);");
+ g->codePrependf("float3x2 bezierpts = float3x2(sk_in[0].sk_Position.xy, "
+ "sk_in[1].sk_Position.xy, "
+ "sk_in[2].sk_Position.xy);");
g->declareGlobal(fCanonicalMatrix);
g->codeAppendf("%s = float3x3(0.0, 0, 1, "
diff --git a/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp b/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
index 489138ecbd..1aac0ed9c2 100644
--- a/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
@@ -25,9 +25,9 @@ void GrCCPRTriangleProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
void GrCCPRTriangleProcessor::defineInputVertices(GrGLSLGeometryBuilder* g) const {
// Prepend in_vertices at the start of the shader.
- g->codePrependf("float3x2 in_vertices = float3x2(sk_in[0].gl_Position.xy, "
- "sk_in[1].gl_Position.xy, "
- "sk_in[2].gl_Position.xy);");
+ g->codePrependf("float3x2 in_vertices = float3x2(sk_in[0].sk_Position.xy, "
+ "sk_in[1].sk_Position.xy, "
+ "sk_in[2].sk_Position.xy);");
}
void GrCCPRTriangleProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* /*rtAdjust*/,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index d37befebb2..92eb86d707 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3503,8 +3503,8 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
"// Copy Program VS\n"
"void main() {"
" v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.zw;"
- " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;"
- " gl_Position.zw = half2(0, 1);"
+ " sk_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;"
+ " sk_Position.zw = half2(0, 1);"
"}"
);
@@ -3618,8 +3618,8 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
vshaderTxt.append(
"// Mipmap Program VS\n"
"void main() {"
- " gl_Position.xy = a_vertex * half2(2, 2) - half2(1, 1);"
- " gl_Position.zw = half2(0, 1);"
+ " sk_Position.xy = a_vertex * half2(2, 2) - half2(1, 1);"
+ " sk_Position.zw = half2(0, 1);"
);
// Insert texture coordinate computation:
@@ -3748,7 +3748,7 @@ bool GrGLGpu::createStencilClipClearProgram() {
vshaderTxt.append(
"// Stencil Clip Clear Program VS\n"
"void main() {"
- " gl_Position = float4(a_vertex.x, a_vertex.y, 0, 1);"
+ " sk_Position = float4(a_vertex.x, a_vertex.y, 0, 1);"
"}");
SkString fshaderTxt(version);
diff --git a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
index e540494064..192417cc53 100644
--- a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
@@ -26,24 +26,24 @@ void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
this->codeAppendf("{float2 _posTmp = %s;", posVar.c_str());
}
this->codeAppendf("_posTmp = floor(_posTmp) + half2(0.5, 0.5);"
- "gl_Position = float4(_posTmp.x * %s.x + %s.y,"
+ "sk_Position = float4(_posTmp.x * %s.x + %s.y,"
"_posTmp.y * %s.z + %s.w, 0, 1);}",
rtAdjustName, rtAdjustName, rtAdjustName, rtAdjustName);
} else if (kFloat3_GrSLType == posVar.getType()) {
- this->codeAppendf("gl_Position = float4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
+ this->codeAppendf("sk_Position = float4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
posVar.c_str(), rtAdjustName,
posVar.c_str(), rtAdjustName,
posVar.c_str());
} else {
SkASSERT(kFloat2_GrSLType == posVar.getType());
- this->codeAppendf("gl_Position = float4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
+ this->codeAppendf("sk_Position = float4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
posVar.c_str(), rtAdjustName, rtAdjustName,
posVar.c_str(), rtAdjustName, rtAdjustName);
}
// We could have the GrGeometryProcessor do this, but its just easier to have it performed
// here. If we ever need to set variable pointsize, then we can reinvestigate.
if (this->getProgramBuilder()->desc()->header().fHasPointSize) {
- this->codeAppend("gl_PointSize = 1.0;");
+ this->codeAppend("sk_PointSize = 1.0;");
}
}
diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp
index d27997d9dd..3093c69989 100644
--- a/src/gpu/vk/GrVkCopyManager.cpp
+++ b/src/gpu/vk/GrVkCopyManager.cpp
@@ -53,8 +53,8 @@ bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
"// Copy Program VS\n"
"void main() {"
"vTexCoord = inPosition * uTexCoordXform.xy + uTexCoordXform.zw;"
- "gl_Position.xy = inPosition * uPosXform.xy + uPosXform.zw;"
- "gl_Position.zw = half2(0, 1);"
+ "sk_Position.xy = inPosition * uPosXform.xy + uPosXform.zw;"
+ "sk_Position.zw = half2(0, 1);"
"}"
);
diff --git a/src/sksl/README b/src/sksl/README
index 40bdf1e329..c8fba509c5 100644
--- a/src/sksl/README
+++ b/src/sksl/README
@@ -38,6 +38,8 @@ Differences from GLSL
'do_something_else();', depending on whether that cap is enabled or not.
* no #version statement is required, and it will be ignored if present
* the output color is sk_FragColor (do not declare it)
+* use sk_Position instead of gl_Position
+* use sk_PointSize instead of gl_PointSize
* use sk_VertexID instead of gl_VertexID
* the fragment coordinate is sk_FragCoord, and is always relative to the upper
left.
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 0729ad1e25..389acfb1f5 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -480,7 +480,14 @@ void GLSLCodeGenerator::writeFieldAccess(const FieldAccess& f) {
this->write("gl_ClipDistance");
break;
default:
- this->write(f.fBase->fType.fields()[f.fFieldIndex].fName);
+ StringFragment name = f.fBase->fType.fields()[f.fFieldIndex].fName;
+ if (name == "sk_Position") {
+ this->write("gl_Position");
+ } else if (name == "sk_PointSize") {
+ this->write("gl_PointSize");
+ } else {
+ this->write(f.fBase->fType.fields()[f.fFieldIndex].fName);
+ }
}
}
diff --git a/src/sksl/ast/SkSLASTInterfaceBlock.h b/src/sksl/ast/SkSLASTInterfaceBlock.h
index d445ae0398..17f180a727 100644
--- a/src/sksl/ast/SkSLASTInterfaceBlock.h
+++ b/src/sksl/ast/SkSLASTInterfaceBlock.h
@@ -16,9 +16,9 @@ namespace SkSL {
/**
* An interface block, as in:
*
- * out gl_PerVertex {
- * layout(builtin=0) float4 gl_Position;
- * layout(builtin=1) float gl_PointSize;
+ * out sk_PerVertex {
+ * layout(builtin=0) float4 sk_Position;
+ * layout(builtin=1) float sk_PointSize;
* };
*/
struct ASTInterfaceBlock : public ASTDeclaration {
diff --git a/src/sksl/ir/SkSLInterfaceBlock.h b/src/sksl/ir/SkSLInterfaceBlock.h
index 03986b87cd..f7483da8f2 100644
--- a/src/sksl/ir/SkSLInterfaceBlock.h
+++ b/src/sksl/ir/SkSLInterfaceBlock.h
@@ -17,9 +17,9 @@ namespace SkSL {
/**
* An interface block, as in:
*
- * out gl_PerVertex {
- * layout(builtin=0) float4 gl_Position;
- * layout(builtin=1) float gl_PointSize;
+ * out sk_PerVertex {
+ * layout(builtin=0) float4 sk_Position;
+ * layout(builtin=1) float sk_PointSize;
* };
*
* At the IR level, this is represented by a single variable of struct type.
diff --git a/src/sksl/sksl_geom.include b/src/sksl/sksl_geom.include
index f1b3604357..3e5ffaed37 100644
--- a/src/sksl/sksl_geom.include
+++ b/src/sksl/sksl_geom.include
@@ -3,14 +3,14 @@ STRINGIFY(
// defines built-in interfaces supported by SkiaSL geometry shaders
layout(builtin=10002) in sk_PerVertex {
- layout(builtin=0) float4 gl_Position;
- layout(builtin=1) float gl_PointSize;
+ layout(builtin=0) float4 sk_Position;
+ layout(builtin=1) float sk_PointSize;
layout(builtin=3) float sk_ClipDistance[];
} sk_in[];
out sk_PerVertex {
- layout(builtin=0) float4 gl_Position;
- layout(builtin=1) float gl_PointSize;
+ layout(builtin=0) float4 sk_Position;
+ layout(builtin=1) float sk_PointSize;
layout(builtin=3) float sk_ClipDistance[];
};
diff --git a/src/sksl/sksl_vert.include b/src/sksl/sksl_vert.include
index 976877c6e7..b4dd63a8ce 100644
--- a/src/sksl/sksl_vert.include
+++ b/src/sksl/sksl_vert.include
@@ -3,8 +3,8 @@ STRINGIFY(
// defines built-in interfaces supported by SkiaSL vertex shaders
out sk_PerVertex {
- layout(builtin=0) float4 gl_Position;
- layout(builtin=1) float gl_PointSize;
+ layout(builtin=0) float4 sk_Position;
+ layout(builtin=1) float sk_PointSize;
layout(builtin=3) float sk_ClipDistance[1];
};
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index 6d0e534beb..3845b8b438 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -1076,9 +1076,9 @@ DEF_TEST(SkSLGeometry, r) {
"layout(invocations = 2) in;"
"layout(line_strip, max_vertices = 2) out;"
"void main() {"
- "gl_Position = sk_in[0].gl_Position + float4(-0.5, 0, 0, sk_InvocationID);"
+ "sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
- "gl_Position = sk_in[0].gl_Position + float4(0.5, 0, 0, sk_InvocationID);"
+ "sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"EndPrimitive();"
"}",
@@ -1427,11 +1427,11 @@ DEF_TEST(SkSLInvocations, r) {
"layout(invocations = 2) in;"
"layout(line_strip, max_vertices = 2) out;"
"void test() {"
- "gl_Position = sk_in[0].gl_Position + float4(0.5, 0, 0, sk_InvocationID);"
+ "sk_Position = sk_in[0].sk_Position + float4(0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"}"
"void main() {"
- "gl_Position = sk_in[0].gl_Position + float4(-0.5, 0, 0, sk_InvocationID);"
+ "sk_Position = sk_in[0].sk_Position + float4(-0.5, 0, 0, sk_InvocationID);"
"EmitVertex();"
"}",
*SkSL::ShaderCapsFactory::MustImplementGSInvocationsWithLoop(),