From 2994de63ef94bc38e2ba897f2283cafc026b9b26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Thu, 7 Feb 2008 16:52:12 +0000 Subject: [PATCH] * tests/test-shader.c: (button_release_cb): added simplified implementation of a box-blur shader from Gwenole Beauchesne that should work on GLSL implementing low-end IGPs not implementing dynamic branching. The original code used crashed some of these due to bugs in drivers or similar. Resolves bug #710. --- ChangeLog | 8 ++++++++ tests/test-shader.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3d02b8e..7ee1259 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-02-07 Øyvind Kolås + + * tests/test-shader.c: (button_release_cb): added simplified + implementation of a box-blur shader from Gwenole Beauchesne that + should work on GLSL implementing low-end IGPs not implementing + dynamic branching. The original code used crashed some of these + due to bugs in drivers or similar. Resolves bug #710. + 2008-02-07 Tomas Frydrych * clutter/clutter-actor.c: diff --git a/tests/test-shader.c b/tests/test-shader.c index 68f2bde..5f290ff 100644 --- a/tests/test-shader.c +++ b/tests/test-shader.c @@ -6,6 +6,11 @@ #include #include +/* Dynamic branching appeared in "Shader Model 3.0" that low-end IGPs + * don't support. + */ +#define GPU_SUPPORTS_DYNAMIC_BRANCHING 0 + typedef struct { gchar *name; @@ -32,7 +37,7 @@ static ShaderSource shaders[]= "}", }, {"box-blur", - +#if GPU_SUPPORTS_DYNAMIC_BRANCHING "uniform float radius ;" "uniform sampler2DRect rectTexture;" "" @@ -52,6 +57,33 @@ static ShaderSource shaders[]= " gl_FragColor = color / float(count);" " gl_FragColor = gl_FragColor * gl_Color;" "}" +#else + "uniform sampler2DRect rectTexture;" + "vec4 tex_load(const vec2 coord)" + "{" + " return texture2DRect (rectTexture, gl_TexCoord[0].st + coord * 2.0);" + "}" + "" + "void main()" + "{" + " vec4 color;" + " float count = 1.0;" + "" + " color = texture2DRect (rectTexture, gl_TexCoord[0].st);" + " color += tex_load (vec2 (-1.0, -1.0)); count++;" + " color += tex_load (vec2 (-1.0, 0.0)); count++;" + " color += tex_load (vec2 (-1.0, 1.0)); count++;" + " color += tex_load (vec2 ( 0.0, -1.0)); count++;" + " color += tex_load (vec2 ( 0.0, 0.0)); count++;" + " color += tex_load (vec2 ( 0.0, 1.0)); count++;" + " color += tex_load (vec2 ( 1.0, -1.0)); count++;" + " color += tex_load (vec2 ( 1.0, 0.0)); count++;" + " color += tex_load (vec2 ( 1.0, 1.0)); count++;" + "" + " gl_FragColor = color / count;" + " gl_FragColor = gl_FragColor * gl_Color;" + "}" +#endif }, {"invert", @@ -163,6 +195,8 @@ button_release_cb (ClutterActor *actor, clutter_actor_set_shader (actor, NULL); clutter_actor_set_shader (actor, shader); clutter_actor_set_shader_param (actor, "radius", 3.0); + clutter_actor_set_shader_param (actor, "brightness", 0.4); + clutter_actor_set_shader_param (actor, "contrast", -1.9); } } return FALSE; -- 2.7.4