enum piglit_result piglit_display(void) { bool pass = true; float green[4] = {0.0, 1.0, 0.0, 0.0}; float *buf; int i; GLuint q; glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); buf = malloc(sizeof(float) * 4 * piglit_width * piglit_height); glGenQueries(1, &q); /* Generate query pass: draw top half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); glBeginQuery(GL_SAMPLES_PASSED, q); piglit_draw_rect(-1, 0, 2, 1); glEndQuery(GL_SAMPLES_PASSED); /* Conditional render that should draw bottom half of screen. */ for (i = 0; i < piglit_width * piglit_height / 2; i++) { buf[i * 4 + 0] = 0.0; buf[i * 4 + 1] = 1.0; buf[i * 4 + 2] = 0.0; buf[i * 4 + 3] = 0.0; } glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); glRasterPos2i(-1, -1); glDrawPixels(piglit_width, piglit_height / 2, GL_RGBA, GL_FLOAT, buf); glEndConditionalRenderNV(); /* Generate query fail */ glBeginQuery(GL_SAMPLES_PASSED, q); glEndQuery(GL_SAMPLES_PASSED); /* Conditional render that should not draw full screen. */ for (i = 0; i < piglit_width * piglit_height; i++) { buf[i * 4 + 0] = 1.0; buf[i * 4 + 1] = 0.0; buf[i * 4 + 2] = 0.0; buf[i * 4 + 3] = 0.0; } glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); glRasterPos2i(-1, -1); glDrawPixels(piglit_width, piglit_height, GL_RGBA, GL_FLOAT, buf); glEndConditionalRenderNV(); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); glutSwapBuffers(); glDeleteQueries(1, &q); free(buf); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
PIGLIT_GL_TEST_CONFIG_END enum piglit_result piglit_display(void) { bool pass = true; float green[4] = {0.0, 1.0, 0.0, 0.0}; GLuint q; GLuint list; list = glGenLists(1); glNewList(list, GL_COMPILE); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); glGenQueries(1, &q); /* Generate query pass: draw bottom half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); glBeginQuery(GL_SAMPLES_PASSED, q); piglit_draw_rect(-1, -1, 2, 1); glEndQuery(GL_SAMPLES_PASSED); /* Conditional render that should draw top half of screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); piglit_draw_rect(-1, 0, 2, 1); glEndConditionalRenderNV(); /* Generate query fail */ glBeginQuery(GL_SAMPLES_PASSED, q); glEndQuery(GL_SAMPLES_PASSED); /* Conditional render that should not draw full screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); glColor4f(1.0, 0.0, 0.0, 0.0); piglit_draw_rect(-1, -1, 2, 2); glEndConditionalRenderNV(); glEndList(); glCallList(list); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); glDeleteQueries(1, &q); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
EXTERN_C_ENTER JNIEXPORT void JNICALL Java_org_lwjgl_opengl_NVConditionalRender_glBeginConditionalRenderNV(JNIEnv *__env, jclass clazz, jint id, jint mode) { glBeginConditionalRenderNVPROC glBeginConditionalRenderNV = (glBeginConditionalRenderNVPROC)tlsGetFunction(1900); UNUSED_PARAM(clazz) glBeginConditionalRenderNV(id, mode); }
enum piglit_result piglit_display(void) { bool pass = true; float green[4] = {0.0, 1.0, 0.0, 0.0}; GLuint qpass, qfail; glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glGenQueries(1, &qpass); glGenQueries(1, &qfail); /* Generate query pass: draw top half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); glBeginQuery(GL_SAMPLES_PASSED, qpass); piglit_draw_rect(-1, 0, 2, 1); glEndQuery(GL_SAMPLES_PASSED); /* Generate query fail */ glBeginQuery(GL_SAMPLES_PASSED, qfail); glEndQuery(GL_SAMPLES_PASSED); /* Conditional render that should not copy red over the green. */ glBeginConditionalRenderNV(qfail, GL_QUERY_WAIT_NV); glRasterPos2i(-1, 0); glCopyPixels(0, 0, piglit_width, piglit_height / 2, GL_COLOR); glEndConditionalRenderNV(); /* Conditional render that should copy green over remaining red. */ glBeginConditionalRenderNV(qpass, GL_QUERY_WAIT_NV); glRasterPos2i(-1, -1); glCopyPixels(0, piglit_height / 2, piglit_width, piglit_height / 2, GL_COLOR); glEndConditionalRenderNV(); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); glutSwapBuffers(); glDeleteQueries(1, &qfail); glDeleteQueries(1, &qpass); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; float red[4] = {1.0, 0.0, 0.0, 0.0}; float green[4] = {0.0, 1.0, 0.0, 0.0}; GLuint q, texture; int tex_size = 64; int i; glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); /* Set up a texture object with green at level 0, red elsewhere */ glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); for (i = 0; tex_size / (1 << i) > 0; i++) fill_level(i, tex_size / (1 << i), i == 0 ? green : red); glGenQueries(1, &q); /* Generate query fail. */ glBeginQuery(GL_SAMPLES_PASSED, q); glEndQuery(GL_SAMPLES_PASSED); /* Mipmap generation should not be affected by conditional rendering. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); glGenerateMipmapEXT(GL_TEXTURE_2D); glEndConditionalRenderNV(); /* This should draw level 1, since starting window size is 32 * and texture is 64. */ glEnable(GL_TEXTURE_2D); piglit_draw_rect_tex(-1, -1, 2, 2, 0, 0, 1, 1); glDisable(GL_TEXTURE_2D); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); glutSwapBuffers(); glDeleteQueries(1, &q); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; float red[4] = {1.0, 0.0, 0.0, 0.0}; float green[4] = {0.0, 1.0, 0.0, 0.0}; GLuint q, texture; glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); /* Draw bottom half of window to green. */ glColor4fv(green); piglit_draw_rect(-1, -1, 2, 1); glColor4f(1, 1, 1, 1); /* Set up a red texture. */ glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); fill_tex(0, piglit_width*2, piglit_height / 2, red); glGenQueries(1, &q); /* Generate query fail. */ glBeginQuery(GL_SAMPLES_PASSED, q); glEndQuery(GL_SAMPLES_PASSED); /* This should not be affected by conditional rendering. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, piglit_width, 0, 0, 0, piglit_width, piglit_height / 2); glEndConditionalRenderNV(); /* Draw the right half of the texture. */ glEnable(GL_TEXTURE_2D); piglit_draw_rect_tex(-1, 0, 2, 1, 0.5, 0, 1, 1); glDisable(GL_TEXTURE_2D); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); glutSwapBuffers(); glDeleteQueries(1, &q); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
void piglit_init(int argc, char **argv) { if (piglit_get_gl_version() < 20) { printf("Requires OpenGL 2.0\n"); piglit_report_result(PIGLIT_SKIP); } piglit_require_extension("GL_NV_conditional_render"); glBeginConditionalRenderNV(0, GL_QUERY_WAIT_NV); if (!piglit_check_gl_error(GL_INVALID_OPERATION)) piglit_report_result(PIGLIT_FAIL); piglit_report_result(PIGLIT_PASS); }
void OGLConditionalRender::BeginConditionalRender() { OGLRenderEngine& re = *checked_cast<OGLRenderEngine*>(&Context::Instance().RenderFactoryInstance().RenderEngineInstance()); if (!re.HackForAMD()) { if (glloader_GL_VERSION_3_0()) { glBeginConditionalRender(query_, GL_QUERY_WAIT); } else { if (glloader_GL_NV_conditional_render()) { glBeginConditionalRenderNV(query_, GL_QUERY_WAIT_NV); } } } }
void piglit_init(int argc, char **argv) { GLuint q; piglit_require_gl_version(20); piglit_require_extension("GL_NV_conditional_render"); glGenQueries(1, &q); glBeginQuery(GL_SAMPLES_PASSED, q); glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); if (!piglit_check_gl_error(GL_INVALID_OPERATION)) piglit_report_result(PIGLIT_FAIL); glEndQuery(GL_SAMPLES_PASSED); glDeleteQueries(1, &q); piglit_report_result(PIGLIT_PASS); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_NVConditionalRender_nglBeginConditionalRenderNV(JNIEnv *env, jclass clazz, jint id, jint mode, jlong function_pointer) { glBeginConditionalRenderNVPROC glBeginConditionalRenderNV = (glBeginConditionalRenderNVPROC)((intptr_t)function_pointer); glBeginConditionalRenderNV(id, mode); }