[Piglit] [PATCH 5/5] fbo-drawbuffers: Port to ES2 w/NV_draw_buffers and NV_fbo_color_attachments
Ian Romanick
idr at freedesktop.org
Fri Oct 7 15:23:59 PDT 2011
From: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
tests/fbo/CMakeLists.gles2.txt | 11 ++++++++++
tests/fbo/fbo-drawbuffers.c | 42 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 tests/fbo/CMakeLists.gles2.txt
diff --git a/tests/fbo/CMakeLists.gles2.txt b/tests/fbo/CMakeLists.gles2.txt
new file mode 100644
index 0000000..b7e52d1
--- /dev/null
+++ b/tests/fbo/CMakeLists.gles2.txt
@@ -0,0 +1,11 @@
+include_directories(
+ ${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries(
+ glut_egl
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gles1_LIBRARY}
+ )
+
+add_executable (fbo-drawbuffers-gles2 fbo-drawbuffers.c)
diff --git a/tests/fbo/fbo-drawbuffers.c b/tests/fbo/fbo-drawbuffers.c
index 921a9af..3ab342c 100644
--- a/tests/fbo/fbo-drawbuffers.c
+++ b/tests/fbo/fbo-drawbuffers.c
@@ -34,14 +34,31 @@
#include "piglit-util.h"
#include "piglit-fbo.h"
+#if defined (USE_OPENGL_ES2)
+#include <EGL/egl.h>
+
+typedef void (*PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
int piglit_width = 128;
int piglit_height = 128;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+#ifndef GL_MAX_DRAW_BUFFERS_ARB
+#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
+#endif
+
const char *vs_text =
+#if defined(USE_OPENGL_ES2)
+ "attribute vec4 vertex;\n"
+#else
+ /* This works around a stupid bug in Mesa.
+ */
+ "#define vertex gl_Vertex\n"
+#endif
"attribute vec2 texcoord;\n"
"varying vec2 tc;\n"
- "void main() { gl_Position = gl_Vertex; tc = texcoord; }"
+ "void main() { gl_Position = vertex; tc = texcoord; }"
;
const char *fs1_text =
@@ -61,6 +78,8 @@ const char *fs2_text =
static GLint prog_mrt;
static GLint prog;
+PFNGLDRAWBUFFERSPROC DrawBuffers = NULL;
+
static GLuint
attach_texture(int i)
{
@@ -103,7 +122,7 @@ piglit_display(void)
tex0 = attach_texture(0);
tex1 = attach_texture(1);
- glDrawBuffersARB(2, attachments);
+ DrawBuffers(2, attachments);
status = piglit_CheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -146,8 +165,18 @@ piglit_init(int argc, char **argv)
piglit_require_GLSL();
piglit_require_fbo();
+#if defined(USE_OPENGL)
piglit_require_extension("GL_ARB_draw_buffers");
+ DrawBuffers = glDrawBuffers;
+#elif defined(USE_OPENGL_ES2)
+ piglit_require_extension("GL_NV_draw_buffers");
+ piglit_require_extension("GL_NV_fbo_color_attachments");
+
+ DrawBuffers = (PFNGLDRAWBUFFERSPROC)
+ eglGetProcAddress("glDrawBuffersNV");
+#endif
+
glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &num);
if (num < 2)
piglit_report_result(PIGLIT_SKIP);
@@ -156,10 +185,19 @@ piglit_init(int argc, char **argv)
fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs2_text);
prog = piglit_link_simple_program(vs, fs);
+#if defined(USE_OPENGL_ES2)
+ piglit_BindAttribLocation(prog, PIGLIT_ATTRIB_POS, "vertex");
+#endif
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);
+
+#if defined(USE_OPENGL_ES2)
+ piglit_BindAttribLocation(prog_mrt, PIGLIT_ATTRIB_POS, "vertex");
+ piglit_LinkProgram(prog_mrt);
+ piglit_link_check_status(prog_mrt);
+#endif
}
--
1.7.6
More information about the Piglit
mailing list