Make appending default precision be controled by GLSL
BUG=skia:
Review URL: https://codereview.chromium.org/1403373012
diff --git a/bench/GLInstancedArraysBench.cpp b/bench/GLInstancedArraysBench.cpp
index ea780f4..4ef813c 100644
--- a/bench/GLInstancedArraysBench.cpp
+++ b/bench/GLInstancedArraysBench.cpp
@@ -12,9 +12,9 @@
#if SK_SUPPORT_GPU
#include "GLBench.h"
#include "gl/GrGLContext.h"
-#include "gl/GrGLGLSL.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLUtil.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLShaderVar.h"
@@ -107,7 +107,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
- const char* version = ctx->caps()->glslCaps()->versionDeclString();
+ const GrGLSLCaps* glslCaps = ctx->caps()->glslCaps();
+ const char* version = glslCaps->versionDeclString();
// setup vertex shader
GrGLSLShaderVar aPosition("a_position", kVec2f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
@@ -115,11 +116,11 @@
GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
SkString vshaderTxt(version);
- aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ aPosition.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
- aColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ aColor.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
- oColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ oColor.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
vshaderTxt.append(
@@ -134,15 +135,14 @@
// setup fragment shader
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
- GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->fStandard,
- &fshaderTxt);
+ GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
- oColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
+ oColor.appendDecl(glslCaps, &fshaderTxt);
fshaderTxt.append(";\n");
const char* fsOutName;
- if (ctx->caps()->glslCaps()->mustDeclareFragmentShaderOutput()) {
- oFragColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
+ if (glslCaps->mustDeclareFragmentShaderOutput()) {
+ oFragColor.appendDecl(glslCaps, &fshaderTxt);
fshaderTxt.append(";\n");
fsOutName = oFragColor.c_str();
} else {
diff --git a/bench/GLVec4ScalarBench.cpp b/bench/GLVec4ScalarBench.cpp
index 490b55a..e3837a7 100644
--- a/bench/GLVec4ScalarBench.cpp
+++ b/bench/GLVec4ScalarBench.cpp
@@ -12,9 +12,9 @@
#if SK_SUPPORT_GPU
#include "GLBench.h"
#include "gl/GrGLContext.h"
-#include "gl/GrGLGLSL.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLUtil.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLShaderVar.h"
@@ -93,7 +93,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
- const char* version = ctx->caps()->glslCaps()->versionDeclString();
+ const GrGLSLCaps* glslCaps = ctx->caps()->glslCaps();
+ const char* version = glslCaps->versionDeclString();
// this shader draws fNumStages overlapping circles of increasing opacity (coverage) and
// decreasing size, with the center of each subsequent circle closer to the bottom-right
@@ -106,13 +107,13 @@
GrGLSLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
SkString vshaderTxt(version);
- aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ aPosition.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
- aColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ aColor.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
- oPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ oPosition.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
- oColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ oColor.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
vshaderTxt.append(
@@ -132,18 +133,17 @@
// next stage.
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
- GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->fStandard,
- &fshaderTxt);
+ GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
oPosition.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
- oPosition.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
+ oPosition.appendDecl(glslCaps, &fshaderTxt);
fshaderTxt.append(";\n");
oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
- oColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
+ oColor.appendDecl(glslCaps, &fshaderTxt);
fshaderTxt.append(";\n");
const char* fsOutName;
- if (ctx->caps()->glslCaps()->mustDeclareFragmentShaderOutput()) {
- oFragColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
+ if (glslCaps->mustDeclareFragmentShaderOutput()) {
+ oFragColor.appendDecl(glslCaps, &fshaderTxt);
fshaderTxt.append(";\n");
fsOutName = oFragColor.c_str();
} else {
diff --git a/bench/GLVertexAttributesBench.cpp b/bench/GLVertexAttributesBench.cpp
index 1051c31..040ca18 100644
--- a/bench/GLVertexAttributesBench.cpp
+++ b/bench/GLVertexAttributesBench.cpp
@@ -12,9 +12,9 @@
#if SK_SUPPORT_GPU
#include "GLBench.h"
#include "gl/GrGLContext.h"
-#include "gl/GrGLGLSL.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLUtil.h"
+#include "glsl/GrGLSL.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLShaderVar.h"
#include <stdio.h>
@@ -65,7 +65,8 @@
GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t attribs,
uint32_t maxAttribs) {
- const char* version = ctx->caps()->glslCaps()->versionDeclString();
+ const GrGLSLCaps* glslCaps = ctx->caps()->glslCaps();
+ const char* version = glslCaps->versionDeclString();
// setup vertex shader
GrGLSLShaderVar aPosition("a_position", kVec4f_GrSLType, GrShaderVar::kAttribute_TypeModifier);
@@ -73,7 +74,7 @@
SkTArray<GrGLSLShaderVar> oVars;
SkString vshaderTxt(version);
- aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ aPosition.appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
for (uint32_t i = 0; i < attribs; i++) {
@@ -82,7 +83,7 @@
aVars.push_back(GrGLSLShaderVar(aname.c_str(),
kVec4f_GrSLType,
GrShaderVar::kAttribute_TypeModifier));
- aVars.back().appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ aVars.back().appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
}
@@ -93,7 +94,7 @@
oVars.push_back(GrGLSLShaderVar(oname.c_str(),
kVec4f_GrSLType,
GrShaderVar::kVaryingOut_TypeModifier));
- oVars.back().appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
+ oVars.back().appendDecl(glslCaps, &vshaderTxt);
vshaderTxt.append(";\n");
}
@@ -118,12 +119,11 @@
// setup fragment shader
GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
SkString fshaderTxt(version);
- GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->fStandard,
- &fshaderTxt);
+ GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, *glslCaps, &fshaderTxt);
const char* fsOutName;
- if (ctx->caps()->glslCaps()->mustDeclareFragmentShaderOutput()) {
- oFragColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
+ if (glslCaps->mustDeclareFragmentShaderOutput()) {
+ oFragColor.appendDecl(glslCaps, &fshaderTxt);
fshaderTxt.append(";\n");
fsOutName = oFragColor.c_str();
} else {
@@ -132,7 +132,7 @@
for (uint32_t i = 0; i < maxAttribs; i++) {
oVars[i].setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
- oVars[i].appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
+ oVars[i].appendDecl(glslCaps, &fshaderTxt);
fshaderTxt.append(";\n");
}