Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1288)

Unified Diff: cc/output/shader.cc

Issue 12665005: cc: Use highp precision for texture coords if available and needed (Closed) Base URL: http://git.chromium.org/chromium/src.git@highp2
Patch Set: Be conservative on Android Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/shader.h ('k') | cc/output/texture_copier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/shader.cc
diff --git a/cc/output/shader.cc b/cc/output/shader.cc
index c4d3636284fedfcf34bc22cebd4f0785817e5bf3..dd9450c72cf8edfcf922e1205b162cc1c7d7dd99 100644
--- a/cc/output/shader.cc
+++ b/cc/output/shader.cc
@@ -6,10 +6,13 @@
#include "base/basictypes.h"
#include "base/logging.h"
+#include "cc/output/gl_renderer.h" // For the GLC() macro.
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
+#include "third_party/khronos/GLES2/gl2.h"
#define SHADER0(Src) #Src
-#define SHADER(Src) SHADER0(Src)
+#define VERTEX_SHADER(Src) setVertexTexCoordPrecision(SHADER0(Src))
+#define FRAGMENT_SHADER(Src) setFragTexCoordPrecision(precision, SHADER0(Src))
using WebKit::WebGraphicsContext3D;
@@ -30,6 +33,67 @@ static void getProgramUniformLocations(WebGraphicsContext3D* context, unsigned p
}
}
+static std::string setFragTexCoordPrecision(TexCoordPrecision requestedPrecision,
+ const char* shaderString)
+{
+ std::string shaderStdString(shaderString);
+
+ switch (requestedPrecision) {
+ case TexCoordPrecisionHigh:
+ DCHECK_NE(shaderStdString.find("TexCoordPrecision"), std::string::npos);
+ return "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
+ " #define TexCoordPrecision highp\n"
+ "#else\n"
+ " #define TexCoordPrecision mediump\n"
+ "#endif\n" +
+ shaderStdString;
+ case TexCoordPrecisionMedium:
+ DCHECK_NE(shaderStdString.find("TexCoordPrecision"), std::string::npos);
+ return "#define TexCoordPrecision mediump\n" +
+ shaderStdString;
+ case TexCoordPrecisionNA:
+ DCHECK_EQ(shaderStdString.find("TexCoordPrecision"), std::string::npos);
+ return shaderStdString;
+ default:
+ NOTREACHED();
+ }
+}
+
+static std::string setVertexTexCoordPrecision(const char* shaderString)
+{
+ // We unconditionally use highp in the vertex shader since
+ // we are unlikely to be vertex shader bound when drawing large quads.
+ // Also, some vertex shaders mutate the texture coordinate in such a
+ // way that the effective precision might be lower than expected.
+ return "#define TexCoordPrecision highp\n" +
+ std::string(shaderString);
+}
+
+}
+
+int TexCoordHighpThreshold(WebKit::WebGraphicsContext3D* context) {
+ GLint range[2];
+ GLint precision = 0;
+ GLC(context, context->getShaderPrecisionFormat(GL_FRAGMENT_SHADER,
+ GL_MEDIUM_FLOAT,
+ range, &precision));
+#if defined(OS_ANDROID)
+ // We bias the threshold on Android to be more conservative, so as to avoid
+ // performance regressions. There has been obvious corruption with 2560 pixel
+ // displays, but none has been reported with lower resolution displays.
+ return std::max(1 << precision, 2048);
brianderson 2013/03/22 22:57:07 Alex, what do you think of this way of being conse
+#else
+ return 1 << precision;
+#endif
+}
+
+TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
+ const gfx::Point& max_coordinate) {
+ int highp_threshold = TexCoordHighpThreshold(context);
+ if (max_coordinate.x() > highp_threshold ||
+ max_coordinate.y() > highp_threshold)
+ return TexCoordPrecisionHigh;
+ return TexCoordPrecisionMedium;
}
VertexShaderPosTex::VertexShaderPosTex()
@@ -52,11 +116,11 @@ void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program, b
std::string VertexShaderPosTex::getShaderString() const
{
- return SHADER(
+ return VERTEX_SHADER(
attribute vec4 a_position;
- attribute vec2 a_texCoord;
+ attribute TexCoordPrecision vec2 a_texCoord;
uniform mat4 matrix;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
void main()
{
gl_Position = matrix * a_position;
@@ -88,13 +152,13 @@ void VertexShaderPosTexYUVStretch::init(WebGraphicsContext3D* context, unsigned
std::string VertexShaderPosTexYUVStretch::getShaderString() const
{
- return SHADER(
+ return VERTEX_SHADER(
precision mediump float;
attribute vec4 a_position;
- attribute vec2 a_texCoord;
+ attribute TexCoordPrecision vec2 a_texCoord;
uniform mat4 matrix;
- varying vec2 v_texCoord;
- uniform vec2 texScale;
+ varying TexCoordPrecision vec2 v_texCoord;
+ uniform TexCoordPrecision vec2 texScale;
void main()
{
gl_Position = matrix * a_position;
@@ -123,7 +187,7 @@ void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program, bool
std::string VertexShaderPos::getShaderString() const
{
- return SHADER(
+ return VERTEX_SHADER(
attribute vec4 a_position;
uniform mat4 matrix;
void main()
@@ -159,19 +223,19 @@ void VertexShaderPosTexTransform::init(WebGraphicsContext3D* context, unsigned p
std::string VertexShaderPosTexTransform::getShaderString() const
{
- return SHADER(
+ return VERTEX_SHADER(
attribute vec4 a_position;
- attribute vec2 a_texCoord;
+ attribute TexCoordPrecision vec2 a_texCoord;
attribute float a_index;
uniform mat4 matrix[8];
- uniform vec4 texTransform[8];
+ uniform TexCoordPrecision vec4 texTransform[8];
uniform float opacity[32];
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
varying float v_alpha;
void main()
{
gl_Position = matrix[int(a_index * 0.25)] * a_position;
- vec4 texTrans = texTransform[int(a_index * 0.25)];
+ TexCoordPrecision vec4 texTrans = texTransform[int(a_index * 0.25)];
v_texCoord = a_texCoord * texTrans.zw + texTrans.xy;
v_alpha = opacity[int(a_index)];
}
@@ -180,19 +244,19 @@ std::string VertexShaderPosTexTransform::getShaderString() const
std::string VertexShaderPosTexTransformFlip::getShaderString() const
{
- return SHADER(
+ return VERTEX_SHADER(
attribute vec4 a_position;
- attribute vec2 a_texCoord;
+ attribute TexCoordPrecision vec2 a_texCoord;
attribute float a_index;
uniform mat4 matrix[8];
- uniform vec4 texTransform[8];
+ uniform TexCoordPrecision vec4 texTransform[8];
uniform float opacity[32];
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
varying float v_alpha;
void main()
{
gl_Position = matrix[int(a_index * 0.25)] * a_position;
- vec4 texTrans = texTransform[int(a_index * 0.25)];
+ TexCoordPrecision vec4 texTrans = texTransform[int(a_index * 0.25)];
v_texCoord = a_texCoord * texTrans.zw + texTrans.xy;
v_texCoord.y = 1.0 - v_texCoord.y;
v_alpha = opacity[int(a_index)];
@@ -202,9 +266,9 @@ std::string VertexShaderPosTexTransformFlip::getShaderString() const
std::string VertexShaderPosTexIdentity::getShaderString() const
{
- return SHADER(
+ return VERTEX_SHADER(
attribute vec4 a_position;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
void main()
{
gl_Position = a_position;
@@ -243,17 +307,18 @@ void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program, boo
std::string VertexShaderQuad::getShaderString() const
{
- return SHADER(
- attribute vec4 a_position;
- attribute vec2 a_texCoord;
+ return VERTEX_SHADER(
+ attribute TexCoordPrecision vec4 a_position;
+ attribute TexCoordPrecision vec2 a_texCoord;
uniform mat4 matrix;
- uniform vec2 point_bug223014[4];
- uniform vec2 texScale;
- varying vec2 v_texCoord;
+ uniform TexCoordPrecision vec2 point_bug223014[4];
+ uniform TexCoordPrecision vec2 texScale;
+ varying TexCoordPrecision vec2 v_texCoord;
void main()
{
- vec2 complement = abs(a_texCoord - 1.0);
- vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w);
+ TexCoordPrecision vec2 complement = abs(a_texCoord - 1.0);
+ TexCoordPrecision vec4 pos =
+ vec4(0.0, 0.0, a_position.z, a_position.w);
pos.xy += (complement.x * complement.y) * point_bug223014[0];
pos.xy += (a_texCoord.x * complement.y) * point_bug223014[1];
pos.xy += (a_texCoord.x * a_texCoord.y) * point_bug223014[2];
@@ -290,13 +355,13 @@ void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program, boo
std::string VertexShaderTile::getShaderString() const
{
- return SHADER(
- attribute vec4 a_position;
- attribute vec2 a_texCoord;
+ return VERTEX_SHADER(
+ attribute TexCoordPrecision vec4 a_position;
+ attribute TexCoordPrecision vec2 a_texCoord;
uniform mat4 matrix;
- uniform vec2 point_bug223014[4];
- uniform vec4 vertexTexTransform;
- varying vec2 v_texCoord;
+ uniform TexCoordPrecision vec2 point_bug223014[4];
+ uniform TexCoordPrecision vec4 vertexTexTransform;
+ varying TexCoordPrecision vec2 v_texCoord;
void main()
{
vec2 complement = abs(a_texCoord - 1.0);
@@ -334,12 +399,12 @@ bool VertexShaderVideoTransform::init(WebGraphicsContext3D* context, unsigned pr
std::string VertexShaderVideoTransform::getShaderString() const
{
- return SHADER(
+ return VERTEX_SHADER(
attribute vec4 a_position;
- attribute vec2 a_texCoord;
+ attribute TexCoordPrecision vec2 a_texCoord;
uniform mat4 matrix;
- uniform mat4 texMatrix;
- varying vec2 v_texCoord;
+ uniform TexCoordPrecision mat4 texMatrix;
+ varying TexCoordPrecision vec2 v_texCoord;
void main()
{
gl_Position = matrix * a_position;
@@ -400,25 +465,28 @@ bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigne
return m_samplerLocation != -1;
}
-std::string FragmentShaderOESImageExternal::getShaderString() const
+std::string FragmentShaderOESImageExternal::getShaderString(
+ TexCoordPrecision precision) const
{
- // Cannot use the SHADER() macro because of the '#' char
- return "#extension GL_OES_EGL_image_external : require \n"
+ // Cannot use the FRAGMENT_SHADER() macro because of the '#' char
+ return setFragTexCoordPrecision(precision,
+ "#extension GL_OES_EGL_image_external : require \n"
"precision mediump float;\n"
- "varying vec2 v_texCoord;\n"
+ "varying TexCoordPrecision vec2 v_texCoord;\n"
"uniform samplerExternalOES s_texture;\n"
"void main()\n"
"{\n"
" vec4 texColor = texture2D(s_texture, v_texCoord);\n"
" gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w);\n"
- "}\n";
+ "}\n");
}
-std::string FragmentShaderRGBATexAlpha::getShaderString() const
+std::string FragmentShaderRGBATexAlpha::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
uniform float alpha;
void main()
@@ -429,11 +497,12 @@ std::string FragmentShaderRGBATexAlpha::getShaderString() const
);
}
-std::string FragmentShaderRGBATexVaryingAlpha::getShaderString() const
+std::string FragmentShaderRGBATexVaryingAlpha::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
varying float v_alpha;
uniform sampler2D s_texture;
void main()
@@ -444,25 +513,28 @@ std::string FragmentShaderRGBATexVaryingAlpha::getShaderString() const
);
}
-std::string FragmentShaderRGBATexRectVaryingAlpha::getShaderString() const
+std::string FragmentShaderRGBATexRectVaryingAlpha::getShaderString(
+ TexCoordPrecision precision) const
{
- return "#extension GL_ARB_texture_rectangle : require\n"
+ return setFragTexCoordPrecision(precision,
+ "#extension GL_ARB_texture_rectangle : require\n"
"precision mediump float;\n"
- "varying vec2 v_texCoord;\n"
+ "varying TexCoordPrecision vec2 v_texCoord;\n"
"varying float v_alpha;\n"
"uniform sampler2DRect s_texture;\n"
"void main()\n"
"{\n"
" vec4 texColor = texture2DRect(s_texture, v_texCoord);\n"
" gl_FragColor = texColor * v_alpha;\n"
- "}\n";
+ "}\n");
}
-std::string FragmentShaderRGBATexOpaque::getShaderString() const
+std::string FragmentShaderRGBATexOpaque::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
@@ -472,11 +544,12 @@ std::string FragmentShaderRGBATexOpaque::getShaderString() const
);
}
-std::string FragmentShaderRGBATex::getShaderString() const
+std::string FragmentShaderRGBATex::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
@@ -485,11 +558,12 @@ std::string FragmentShaderRGBATex::getShaderString() const
);
}
-std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString() const
+std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
uniform float alpha;
void main()
@@ -500,11 +574,12 @@ std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString() const
);
}
-std::string FragmentShaderRGBATexSwizzleOpaque::getShaderString() const
+std::string FragmentShaderRGBATexSwizzleOpaque::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
void main()
{
@@ -538,11 +613,12 @@ void FragmentShaderRGBATexAlphaAA::init(WebGraphicsContext3D* context, unsigned
DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1);
}
-std::string FragmentShaderRGBATexAlphaAA::getShaderString() const
+std::string FragmentShaderRGBATexAlphaAA::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
uniform float alpha;
uniform vec3 edge[8];
@@ -590,18 +666,19 @@ void FragmentTexClampAlphaAABinding::init(WebGraphicsContext3D* context, unsigne
DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_fragmentTexTransformLocation != -1 && m_edgeLocation != -1);
}
-std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const
+std::string FragmentShaderRGBATexClampAlphaAA::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
uniform float alpha;
- uniform vec4 fragmentTexTransform;
+ uniform TexCoordPrecision vec4 fragmentTexTransform;
uniform vec3 edge[8];
void main()
{
- vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw + fragmentTexTransform.xy;
+ TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw + fragmentTexTransform.xy;
vec4 texColor = texture2D(s_texture, texCoord);
vec3 pos = vec3(gl_FragCoord.xy, 1);
float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
@@ -617,18 +694,19 @@ std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const
);
}
-std::string FragmentShaderRGBATexClampSwizzleAlphaAA::getShaderString() const
+std::string FragmentShaderRGBATexClampSwizzleAlphaAA::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
uniform float alpha;
- uniform vec4 fragmentTexTransform;
+ uniform TexCoordPrecision vec4 fragmentTexTransform;
uniform vec3 edge[8];
void main()
{
- vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw + fragmentTexTransform.xy;
+ TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw + fragmentTexTransform.xy;
vec4 texColor = texture2D(s_texture, texCoord);
vec3 pos = vec3(gl_FragCoord.xy, 1);
float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
@@ -673,20 +751,21 @@ void FragmentShaderRGBATexAlphaMask::init(WebGraphicsContext3D* context, unsigne
DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLocation != -1);
}
-std::string FragmentShaderRGBATexAlphaMask::getShaderString() const
+std::string FragmentShaderRGBATexAlphaMask::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
uniform sampler2D s_mask;
- uniform vec2 maskTexCoordScale;
- uniform vec2 maskTexCoordOffset;
+ uniform TexCoordPrecision vec2 maskTexCoordScale;
+ uniform TexCoordPrecision vec2 maskTexCoordOffset;
uniform float alpha;
void main()
{
vec4 texColor = texture2D(s_texture, v_texCoord);
- vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y);
+ TexCoordPrecision vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y);
vec4 maskColor = texture2D(s_mask, maskTexCoord);
gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha * maskColor.w;
}
@@ -725,21 +804,22 @@ void FragmentShaderRGBATexAlphaMaskAA::init(WebGraphicsContext3D* context, unsig
DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1);
}
-std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString() const
+std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D s_texture;
uniform sampler2D s_mask;
- uniform vec2 maskTexCoordScale;
- uniform vec2 maskTexCoordOffset;
+ uniform TexCoordPrecision vec2 maskTexCoordScale;
+ uniform TexCoordPrecision vec2 maskTexCoordOffset;
uniform float alpha;
uniform vec3 edge[8];
void main()
{
vec4 texColor = texture2D(s_texture, v_texCoord);
- vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y);
+ TexCoordPrecision vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y);
vec4 maskColor = texture2D(s_mask, maskTexCoord);
vec3 pos = vec3(gl_FragCoord.xy, 1);
float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
@@ -790,12 +870,13 @@ void FragmentShaderYUVVideo::init(WebGraphicsContext3D* context, unsigned progra
&& m_alphaLocation != -1 && m_yuvMatrixLocation != -1 && m_yuvAdjLocation != -1);
}
-std::string FragmentShaderYUVVideo::getShaderString() const
+std::string FragmentShaderYUVVideo::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
precision mediump int;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform sampler2D y_texture;
uniform sampler2D u_texture;
uniform sampler2D v_texture;
@@ -832,9 +913,10 @@ void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program,
DCHECK(m_colorLocation != -1);
}
-std::string FragmentShaderColor::getShaderString() const
+std::string FragmentShaderColor::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
uniform vec4 color;
void main()
@@ -865,9 +947,10 @@ void FragmentShaderColorAA::init(WebGraphicsContext3D* context, unsigned program
DCHECK(m_edgeLocation != -1 && m_colorLocation != -1);
}
-std::string FragmentShaderColorAA::getShaderString() const
+std::string FragmentShaderColorAA::getShaderString(
+ TexCoordPrecision precision) const
{
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
uniform vec4 color;
uniform vec3 edge[8];
@@ -913,14 +996,15 @@ void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned pr
DCHECK(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyLocation != -1 && m_colorLocation != -1);
}
-std::string FragmentShaderCheckerboard::getShaderString() const
+std::string FragmentShaderCheckerboard::getShaderString(
+ TexCoordPrecision precision) const
{
// Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide"
// by Munshi, Ginsburg, Shreiner.
- return SHADER(
+ return FRAGMENT_SHADER(
precision mediump float;
precision mediump int;
- varying vec2 v_texCoord;
+ varying TexCoordPrecision vec2 v_texCoord;
uniform float alpha;
uniform float frequency;
uniform vec4 texTransform;
@@ -929,7 +1013,7 @@ std::string FragmentShaderCheckerboard::getShaderString() const
{
vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0);
vec4 color2 = color;
- vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy;
+ TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy;
vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0);
float picker = abs(coord.x - coord.y);
gl_FragColor = mix(color1, color2, picker) * alpha;
« no previous file with comments | « cc/output/shader.h ('k') | cc/output/texture_copier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698