diff options
author | 2017-02-13 15:45:35 -0700 | |
---|---|---|
committer | 2017-02-13 23:21:35 +0000 | |
commit | 936f81b95882be2e171a623b3116cc2ff408c813 (patch) | |
tree | 339761c23c6bbed0d495212a5854c2c22ab374d2 /src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp | |
parent | ed4984bf53b90e50acad606aeb4b35340db802a3 (diff) |
Move the rt adjust uniform into GP EmitArgs
The GP will likely require this value when dealing with a geometry
shader. In the future we may wish to either switch to device-space
geometry shaders, or else put this value in an "sk_" builtin.
BUG=skia:
Change-Id: I8dff88fc219feef84d39fb7bbd08f3b5686f53d2
Reviewed-on: https://skia-review.googlesource.com/8362
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp')
-rw-r--r-- | src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp index 2aded892d4..627b11d685 100644 --- a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp +++ b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp @@ -11,17 +11,12 @@ #include "glsl/GrGLSLVarying.h" GrGLSLVertexBuilder::GrGLSLVertexBuilder(GrGLSLProgramBuilder* program) - : INHERITED(program) - , fRtAdjustName(nullptr) { + : INHERITED(program) { } -void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posVar) { - SkASSERT(!fRtAdjustName); - +void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posVar, + const char* rtAdjustName) { // setup RT Uniform - fProgramBuilder->addRTAdjustmentUniform(kHigh_GrSLPrecision, - fProgramBuilder->rtAdjustment(), - &fRtAdjustName); if (this->getProgramBuilder()->desc()->header().fSnapVerticesToPixelCenters) { if (kVec3f_GrSLType == posVar.getType()) { const char* p = posVar.c_str(); @@ -33,17 +28,17 @@ void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);" "gl_Position = vec4(_posTmp.x * %s.x + %s.y," "_posTmp.y * %s.z + %s.w, 0, 1);}", - fRtAdjustName, fRtAdjustName, fRtAdjustName, fRtAdjustName); + rtAdjustName, rtAdjustName, rtAdjustName, rtAdjustName); } else if (kVec3f_GrSLType == posVar.getType()) { this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);", - posVar.c_str(), fRtAdjustName, - posVar.c_str(), fRtAdjustName, + posVar.c_str(), rtAdjustName, + posVar.c_str(), rtAdjustName, posVar.c_str()); } else { SkASSERT(kVec2f_GrSLType == posVar.getType()); this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);", - posVar.c_str(), fRtAdjustName, fRtAdjustName, - posVar.c_str(), fRtAdjustName, fRtAdjustName); + 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. |