static bool test_format(const struct fmt_test *test) { bool pass = true; glUseProgram(prog); glUniform1i(0 /* explicit loc */, 0); /* Test glRenderbufferStorage. */ GLuint rbo = create_and_bind_rbo(test); if (!rbo || !piglit_check_gl_error(GL_NO_ERROR)) { piglit_report_subtest_result(PIGLIT_FAIL, "format 0x%x RBO test", test->iformat); pass &= false; } else { piglit_report_subtest_result(PIGLIT_PASS, "format 0x%x RBO test", test->iformat); } glDeleteRenderbuffers(1, &rbo); /* Create framebuffer object. */ GLuint fbo_tex; const GLuint fbo = create_and_bind_fbo(test, &fbo_tex); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { piglit_report_subtest_result(PIGLIT_FAIL, "format 0x%x fbo fail", test->iformat); pass &= false; } /* Create a texture, upload data */ const GLuint texture = create_and_bind_texture(test); render_texture(texture, GL_TEXTURE_2D, fbo); glDeleteTextures(1, &texture); /* Test glCopyTexImage2D by copying current fbo content to * a texture, rendering copy back to fbo and verifying fbo contents. */ GLuint tmp_tex = create_and_bind_empty_texture(); glCopyTexImage2D(GL_TEXTURE_2D, 0, test->iformat, 0, 0, piglit_width, piglit_height, 0); render_texture(tmp_tex, GL_TEXTURE_2D, fbo); glDeleteTextures(1, &tmp_tex); /* Verify contents. */ pass &= verify_contents(test); glDeleteFramebuffers(1, &fbo); /* Render fbo contents to window. */ render_texture(fbo_tex, GL_TEXTURE_2D, 0); piglit_present_results(); glDeleteTextures(1, &fbo_tex); return pass; }
void piglit_init(int argc, char **argv) { bool pass = true; int i, max_draw_bufs; if (argc != 2) { printf("Expected one parameter, got %i.\n", argc-1); piglit_report_result(PIGLIT_FAIL); } test_name = argv[1]; piglit_require_gl_version(21); piglit_require_extension("GL_ARB_framebuffer_object"); glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &max_draw_bufs); if (max_draw_bufs < 4) { puts("At least 4 draw buffers are required."); piglit_report_result(PIGLIT_SKIP); } printf("Testing %s.\n", test_name); /* Begin testing. */ create_shaders(); create_and_bind_fbo(); for (i = 0; i < ARRAY_SIZE(drawbuf_config); i++) { clear_all_attachments_to_initial_value(); glDrawBuffers(4, drawbuf_config[i]); if (strcmp(test_name, "glClear") == 0) { pass = test_glClear(drawbuf_config[i]) && pass; } else if (strcmp(test_name, "glClearBuffer") == 0) { piglit_require_gl_version(30); pass = test_glClearBuffer(drawbuf_config[i]) && pass; } else if (strcmp(test_name, "gl_FragColor") == 0) { pass = test_fragcolor(drawbuf_config[i]) && pass; } else if (strcmp(test_name, "gl_FragData") == 0) { pass = test_fragdata(drawbuf_config[i]) && pass; } else if (strcmp(test_name, "glColorMaskIndexed") == 0) { piglit_require_extension("GL_EXT_draw_buffers2"); pass = test_glColorMaskIndexed(drawbuf_config[i]) && pass; } else if (strcmp(test_name, "glBlendFunci") == 0) { piglit_require_extension("GL_ARB_draw_buffers_blend"); pass = test_glBlendFunci(drawbuf_config[i]) && pass; } else if (strcmp(test_name, "glDrawPixels") == 0) { pass = test_glDrawPixels(drawbuf_config[i]) && pass; } else if (strcmp(test_name, "glBlitFramebuffer") == 0) { pass = test_glBlitFramebuffer(drawbuf_config[i]) && pass; } else { printf("Unknown subtest: %s\n", test_name); piglit_report_result(PIGLIT_FAIL); } } pass = piglit_check_gl_error(GL_NO_ERROR) && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }