[Piglit] [PATCH 4/5] fbo-drawbuffers: Port to use shaders instead of fixed-function

Marek Olšák maraeo at gmail.com
Mon Oct 10 11:27:17 PDT 2011


It would be more useful to keep the fixed-function test unchanged and
either add a completely new test or add a command-line parameter to
turn shaders on.

Thanks.

Marek

On Sat, Oct 8, 2011 at 12:23 AM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  tests/fbo/fbo-drawbuffers.c |   42 ++++++++++++++++++++++++++++++++++++++----
>  1 files changed, 38 insertions(+), 4 deletions(-)
>
> diff --git a/tests/fbo/fbo-drawbuffers.c b/tests/fbo/fbo-drawbuffers.c
> index 36e057c..921a9af 100644
> --- a/tests/fbo/fbo-drawbuffers.c
> +++ b/tests/fbo/fbo-drawbuffers.c
> @@ -38,6 +38,29 @@ int piglit_width = 128;
>  int piglit_height = 128;
>  int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
>
> +const char *vs_text =
> +       "attribute vec2 texcoord;\n"
> +       "varying vec2 tc;\n"
> +       "void main() { gl_Position = gl_Vertex; tc = texcoord; }"
> +       ;
> +
> +const char *fs1_text =
> +       "void main()\n"
> +       "{\n"
> +       "    gl_FragData[0] = vec4(0.0, 1.0, 0.0, 1.0);\n"
> +       "    gl_FragData[1] = vec4(0.0, 1.0, 0.0, 1.0);\n"
> +       "}\n"
> +       ;
> +
> +const char *fs2_text =
> +       "uniform sampler2D tex;\n"
> +       "varying vec2 tc;\n"
> +       "void main() { gl_FragColor = texture2D(tex, tc); }"
> +       ;
> +
> +static GLint prog_mrt;
> +static GLint prog;
> +
>  static GLuint
>  attach_texture(int i)
>  {
> @@ -92,19 +115,17 @@ piglit_display(void)
>        glClearColor(1.0, 0.0, 0.0, 0.0);
>        glClear(GL_COLOR_BUFFER_BIT);
>
> -       glColor4fv(green);
> +       piglit_UseProgram(prog_mrt);
>        piglit_draw_rect(-1, -1, 2, 2);
>
>        piglit_BindFramebuffer(GL_FRAMEBUFFER, 0);
>
>        /* Draw the two green textures to halves of the window. */
> -       glEnable(GL_TEXTURE_2D);
> -       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
> +       piglit_UseProgram(prog);
>        glBindTexture(GL_TEXTURE_2D, tex0);
>        piglit_draw_rect_tex(-1, -1, 1, 2,  0, 0, 1, 1);
>        glBindTexture(GL_TEXTURE_2D, tex1);
>        piglit_draw_rect_tex(0, -1, 1, 2, 0, 0, 1, 1);
> -       glDisable(GL_TEXTURE_2D);
>        glDeleteTextures(1, &tex0);
>        glDeleteTextures(1, &tex1);
>        piglit_DeleteFramebuffers(1, &fb);
> @@ -121,11 +142,24 @@ void
>  piglit_init(int argc, char **argv)
>  {
>        GLint num;
> +       GLuint vs, fs;
>
> +       piglit_require_GLSL();
>        piglit_require_fbo();
>        piglit_require_extension("GL_ARB_draw_buffers");
>
>        glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &num);
>        if (num < 2)
>                piglit_report_result(PIGLIT_SKIP);
> +
> +       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
> +       fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs2_text);
> +       prog = piglit_link_simple_program(vs, fs);
> +
> +       piglit_BindAttribLocation(prog, PIGLIT_ATTRIB_TEX, "texcoord");
> +       piglit_LinkProgram(prog);
> +       piglit_link_check_status(prog);
> +
> +       fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs1_text);
> +       prog_mrt = piglit_link_simple_program(vs, fs);
>  }
> --
> 1.7.6
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>


More information about the Piglit mailing list