summaryrefslogtreecommitdiffstats
path: root/chrome/gpu
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 19:48:58 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 19:48:58 +0000
commit8bb174c2d00c18fb682ab9bcbfa1f5f3f0ed2281 (patch)
treef0d2c4d61064c53b46ac82e69cf09842027dc5a9 /chrome/gpu
parentf14a342e752e219704ad67f2960fb2da6a59d72f (diff)
downloadchromium_src-8bb174c2d00c18fb682ab9bcbfa1f5f3f0ed2281.zip
chromium_src-8bb174c2d00c18fb682ab9bcbfa1f5f3f0ed2281.tar.gz
chromium_src-8bb174c2d00c18fb682ab9bcbfa1f5f3f0ed2281.tar.bz2
Workaround for I915 graphics cards which have horrible GL shader support.
Summary: - GLEW doesn't load the GL shader functions, so we have to load them ourselves - Replace our varying vec2 with glTexCoord[0].st - Replace our uniform mat3 with manual matrix multiplication BUG=33329 TEST=try it out on anything with an I915 Review URL: http://codereview.chromium.org/1219006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42659 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu')
-rw-r--r--chrome/gpu/gpu_backing_store_glx_context.cc1
-rw-r--r--chrome/gpu/gpu_video_layer_glx.cc18
2 files changed, 19 insertions, 0 deletions
diff --git a/chrome/gpu/gpu_backing_store_glx_context.cc b/chrome/gpu/gpu_backing_store_glx_context.cc
index eeeb9fb..96c6917 100644
--- a/chrome/gpu/gpu_backing_store_glx_context.cc
+++ b/chrome/gpu/gpu_backing_store_glx_context.cc
@@ -63,6 +63,7 @@ GLXContext GpuBackingStoreGLXContext::BindContext(XID window_id) {
bool success = ::glXMakeCurrent(gpu_thread_->display(), window_id, context_);
DCHECK(success);
glewInit();
+ glewInitGL2Hack(); // Work around for I915. See gpu_video_layer_glx.cc.
return context_;
}
diff --git a/chrome/gpu/gpu_video_layer_glx.cc b/chrome/gpu/gpu_video_layer_glx.cc
index b0b9cec..7416237 100644
--- a/chrome/gpu/gpu_video_layer_glx.cc
+++ b/chrome/gpu/gpu_video_layer_glx.cc
@@ -34,6 +34,8 @@ static const float kTextureCoords[8] = {
1, 1,
};
+#define I915_WORKAROUND
+
// Pass-through vertex shader.
static const char kVertexShader[] =
"varying vec2 interp_tc;\n"
@@ -42,7 +44,11 @@ static const char kVertexShader[] =
"attribute vec2 in_tc;\n"
"\n"
"void main() {\n"
+#if defined(I915_WORKAROUND)
+ " gl_TexCoord[0].st = in_tc;\n"
+#else
" interp_tc = in_tc;\n"
+#endif
" gl_Position = in_pos;\n"
"}\n";
@@ -57,11 +63,21 @@ static const char kFragmentShader[] =
"uniform mat3 yuv2rgb;\n"
"\n"
"void main() {\n"
+#if defined(I915_WORKAROUND)
+ " float y = texture2D(y_tex, gl_TexCoord[0].st).x;\n"
+ " float u = texture2D(u_tex, gl_TexCoord[0].st).r - .5;\n"
+ " float v = texture2D(v_tex, gl_TexCoord[0].st).r - .5;\n"
+ " float r = y + v * 1.403;\n"
+ " float g = y - u * 0.344 - v * 0.714;\n"
+ " float b = y + u * 1.772;\n"
+ " gl_FragColor = vec4(r, g, b, 1);\n"
+#else
" float y = texture2D(y_tex, interp_tc).x;\n"
" float u = texture2D(u_tex, interp_tc).r - .5;\n"
" float v = texture2D(v_tex, interp_tc).r - .5;\n"
" vec3 rgb = yuv2rgb * vec3(y, u, v);\n"
" gl_FragColor = vec4(rgb, 1);\n"
+#endif
"}\n";
GpuVideoLayerGLX::GpuVideoLayerGLX(GpuViewX* view,
@@ -185,8 +201,10 @@ void GpuVideoLayerGLX::Render(const gfx::Size& viewport_size) {
glUniform1i(glGetUniformLocation(program_, "u_tex"), 1);
glUniform1i(glGetUniformLocation(program_, "v_tex"), 2);
+#if !defined(I915_WORKAROUND)
int yuv2rgb_location = glGetUniformLocation(program_, "yuv2rgb");
glUniformMatrix3fv(yuv2rgb_location, 1, GL_TRUE, kYUV2RGB);
+#endif
// TODO(scherkus): instead of calculating and loading a geometry each time,
// we should store a constant geometry in a VBO and use a vertex shader.