diff options
Diffstat (limited to 'src/gpu/glsl')
-rw-r--r-- | src/gpu/glsl/GrGLSLProgramBuilder.cpp | 14 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLUniformHandler.h | 9 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp | 12 |
3 files changed, 21 insertions, 14 deletions
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp index 118b904540..04ebc6ad8e 100644 --- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp +++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp @@ -15,6 +15,7 @@ #include "glsl/GrGLSLGeometryProcessor.h" #include "glsl/GrGLSLVarying.h" #include "glsl/GrGLSLXferProcessor.h" +#include "SkSLCompiler.h" const int GrGLSLProgramBuilder::kVarsPerBlock = 8; @@ -74,13 +75,16 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr this->nameExpression(outputCoverage, "outputCoverage"); SkASSERT(!fUniformHandles.fRTAdjustmentUni.isValid()); - GrShaderFlags rtAdjustVisibility = kVertex_GrShaderFlag; + GrShaderFlags rtAdjustVisibility; if (proc.willUseGeoShader()) { - rtAdjustVisibility |= kGeometry_GrShaderFlag; + rtAdjustVisibility = kGeometry_GrShaderFlag; + } else { + rtAdjustVisibility = kVertex_GrShaderFlag; } - fUniformHandles.fRTAdjustmentUni = this->uniformHandler()->addUniform(rtAdjustVisibility, - kFloat4_GrSLType, - "rtAdjustment"); + fUniformHandles.fRTAdjustmentUni = this->uniformHandler()->addUniform( + rtAdjustVisibility, + kFloat4_GrSLType, + SkSL::Compiler::RTADJUST_NAME); const char* rtAdjustName = this->uniformHandler()->getUniformCStr(fUniformHandles.fRTAdjustmentUni); diff --git a/src/gpu/glsl/GrGLSLUniformHandler.h b/src/gpu/glsl/GrGLSLUniformHandler.h index e1511c2578..662486eebe 100644 --- a/src/gpu/glsl/GrGLSLUniformHandler.h +++ b/src/gpu/glsl/GrGLSLUniformHandler.h @@ -12,6 +12,9 @@ #include "GrShaderVar.h" #include "GrSwizzle.h" +// variable names beginning with this prefix will not be mangled +#define GR_NO_MANGLE_PREFIX "sk_" + class GrGLSLProgramBuilder; class GrGLSLUniformHandler { @@ -51,7 +54,8 @@ public: int arrayCount, const char** outName = nullptr) { SkASSERT(!GrSLTypeIsCombinedSamplerType(type)); - return this->internalAddUniformArray(visibility, type, precision, name, true, arrayCount, + bool mangle = strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX)); + return this->internalAddUniformArray(visibility, type, precision, name, mangle, arrayCount, outName); } @@ -61,7 +65,8 @@ public: int arrayCount, const char** outName = nullptr) { SkASSERT(!GrSLTypeIsCombinedSamplerType(type)); - return this->internalAddUniformArray(visibility, type, kDefault_GrSLPrecision, name, true, + bool mangle = strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX)); + return this->internalAddUniformArray(visibility, type, kDefault_GrSLPrecision, name, mangle, arrayCount, outName); } diff --git a/src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp b/src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp index 1cf85f7249..dba57bb8a5 100644 --- a/src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp +++ b/src/gpu/glsl/GrGLSLVertexGeoBuilder.cpp @@ -23,16 +23,14 @@ void GrGLSLVertexGeoBuilder::emitNormalizedSkPosition(SkString* out, const char* out->appendf("{float2 _posTmp = %s;", devPos); } out->appendf("_posTmp = floor(_posTmp) + half2(0.5, 0.5);" - "sk_Position = float4(_posTmp.x * %s.x + %s.y," - "_posTmp.y * %s.z + %s.w, 0, 1);}", - rtAdjustName, rtAdjustName, rtAdjustName, rtAdjustName); + "sk_Position = float4(_posTmp, 0, 1);}"); } else if (kFloat3_GrSLType == devPosType) { - out->appendf("sk_Position = float4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);", - devPos, rtAdjustName, devPos, rtAdjustName, devPos); + out->appendf("sk_Position = float4(%s.x , %s.y, 0, %s.z);", + devPos, devPos, devPos); } else { SkASSERT(kFloat2_GrSLType == devPosType); - out->appendf("sk_Position = float4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);", - devPos, rtAdjustName, rtAdjustName, devPos, rtAdjustName, rtAdjustName); + out->appendf("sk_Position = float4(%s.x , %s.y, 0, 1);", + devPos, devPos); } } |