static void test_rgba(EGLDisplay dpy, EGLContext ctx) { const float color1[4] = { 0.0, 1.0, 0.0, 1.0 }; const float color2[4] = { 0.0, 0.0, 1.0, 1.0 }; bool pass = true; GLuint fb1, fb2; create_framebuffers(dpy, ctx, &fb1, &fb2, GL_RGBA); /* Clear rb1 to color1. Check that rb2 has color1. */ glBindFramebuffer(GL_FRAMEBUFFER, fb1); glClearBufferfv(GL_COLOR, 0, color1); glBindFramebuffer(GL_FRAMEBUFFER, fb2); pass &= piglit_probe_rect_rgba(0, 0, width, height, color1); pass &= piglit_check_gl_error(GL_NO_ERROR); /* Clear rb2 to color2. Check that rb1 has color2. */ glBindFramebuffer(GL_FRAMEBUFFER, fb2); glClearBufferfv(GL_COLOR, 0, color2); glBindFramebuffer(GL_FRAMEBUFFER, fb1); pass &= piglit_probe_rect_rgba(0, 0, width, height, color2); pass &= piglit_check_gl_error(GL_NO_ERROR); piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; static const float green[] = {0.0, 1.0, 0.0, 0.0}; static const float blue[] = {0.0, 0.0, 1.0, 0.0}; glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glFogfv(GL_FOG_COLOR, green); piglit_draw_rect(-1, -1, 1, 2); glFogfv(GL_FOG_COLOR, blue); piglit_draw_rect(0, -1, 1, 2); pass &= piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height, green); pass &= piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2, piglit_height, blue); glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLsync fence; bool pass = true; glViewport(0, 0, piglit_width, piglit_height); glClearColor(0.2, 0.2, 0.2, 0.2); glClear(GL_COLOR_BUFFER_BIT); memcpy(map, red, sizeof(red)); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); /* Wait for any previous rendering to finish before updating * the texture buffer */ fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); memcpy(map, green, sizeof(green)); glDrawArrays(GL_TRIANGLE_FAN, 4, 4); pass = piglit_probe_rect_rgba( 0, 0, piglit_width / 2, piglit_height, red) && pass; pass = piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2, piglit_height, green) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
PIGLIT_GL_TEST_CONFIG_END enum piglit_result piglit_display(void) { static const char *vs_source = "#version 140\n" "in vec4 piglit_vertex;\n" "void main()\n" "{\n" " gl_Position = piglit_vertex;\n" "}\n"; static const char *fs_source = "#version 140\n" "uniform samplerBuffer s;\n" "void main()\n" "{\n" " gl_FragColor = texelFetch(s, 0);\n" "}\n"; bool pass = true; GLuint tex, bo; GLuint prog; float green[] = {0, 1, 0, 0}; float blue[] = {0, 0, 1, 0}; uint8_t g_rgba8[] = {0x00, 0xff, 0x00, 0x00}; uint8_t b_rgba8[] = {0x00, 0x00, 0xff, 0x00}; prog = piglit_build_simple_program(vs_source, fs_source); glUseProgram(prog); glGenBuffers(1, &bo); glBindBuffer(GL_TEXTURE_BUFFER, bo); /* Make the buffer bigger than the data to trigger the driver * code path we want. */ glBufferData(GL_TEXTURE_BUFFER, 4096, NULL, GL_STREAM_DRAW); glBufferSubData(GL_TEXTURE_BUFFER, 0, sizeof(g_rgba8), g_rgba8); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_BUFFER, tex); glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, bo); piglit_draw_rect(-1, -1, 1, 2); glBufferSubData(GL_TEXTURE_BUFFER, 0, sizeof(b_rgba8), b_rgba8); piglit_draw_rect(0, -1, 1, 2); pass = pass && piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height, green); pass = pass && piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2, piglit_height, blue); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result draw(Display *dpy) { GLboolean pass = GL_TRUE; float green[] = {0.0, 1.0, 0.0, 1.0}; float blue[] = {0.0, 0.0, 1.0, 1.0}; float gray[] = {0.5, 0.5, 0.5, 1.0}; pthread_t thread1, thread2; void *retval; int ret; int x1 = 10, x2 = 30; ctx = piglit_get_glx_context(dpy, visinfo); glXMakeCurrent(dpy, win, ctx); glewInit(); piglit_require_glx_extension(dpy, "MESA_multithread_makecurrent"); /* Clear background to gray */ glClearColor(0.5, 0.5, 0.5, 1.0); glClear(GL_COLOR_BUFFER_BIT); piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); pthread_mutex_init(&mutex, NULL); /* Now, spawn some threads that do some drawing, both with this * context */ pthread_create(&thread1, NULL, thread1_func, &x1); pthread_create(&thread2, NULL, thread2_func, &x2); ret = pthread_join(thread1, &retval); assert(ret == 0); ret = pthread_join(thread2, &retval); assert(ret == 0); pthread_mutex_destroy(&mutex); glColor4f(0.0, 1.0, 0.0, 0.0); piglit_draw_rect(50, 10, 10, 10); pass &= piglit_probe_rect_rgba( 0, 10, 10, 10, gray); pass &= piglit_probe_rect_rgba(10, 10, 10, 10, green); pass &= piglit_probe_rect_rgba(20, 10, 10, 10, gray); pass &= piglit_probe_rect_rgba(30, 10, 10, 10, blue); pass &= piglit_probe_rect_rgba(40, 10, 10, 10, gray); pass &= piglit_probe_rect_rgba(50, 10, 10, 10, green); pass &= piglit_probe_rect_rgba(60, 10, 10, 10, gray); pass &= piglit_probe_rect_rgba(0, 0, piglit_width, 10, gray); pass &= piglit_probe_rect_rgba(0, 20, piglit_width, 10, gray); glXSwapBuffers(dpy, win); glXMakeCurrent(dpy, None, None); glXDestroyContext(dpy, ctx); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { float color[4][4] = { {1, 0, 0, 1}, {0, 1, 0, 1}, {0, 0, 1, 1}, {1, 1, 1, 1}, }; bool pass = true; glViewport(0, 0, piglit_width, piglit_height); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); glVertexAttrib1fv(attr, color[0]); glViewport(0, 0, piglit_width/2, piglit_height/2); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glVertexAttrib2fv(attr, color[1]); glViewport(0, piglit_height/2, piglit_width/2, piglit_height/2); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glVertexAttrib3fv(attr, color[2]); glViewport(piglit_width/2, 0, piglit_width/2, piglit_height/2); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glVertexAttrib4fv(attr, color[3]); glViewport(piglit_width/2, piglit_height/2, piglit_width/2, piglit_height/2); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); pass &= piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height / 2, color[0]); pass &= piglit_probe_rect_rgba(0, piglit_height / 2, piglit_width / 2, piglit_height / 2, color[1]); pass &= piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2, piglit_height / 2, color[2]); pass &= piglit_probe_rect_rgba(piglit_width / 2, piglit_height / 2, piglit_width / 2, piglit_height / 2, color[3]); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
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; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; float white[] = {1.0, 1.0, 1.0, 1.0}; int i; glClear(GL_COLOR_BUFFER_BIT); glBindVertexArray(vao); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); for (i = 0; i < NUM_QUADS; ++i) glDrawElementsBaseVertexOES(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL, i * 4); for (i = 0; i < NUM_QUADS; ++i) { GLfloat xoffset[2], yoffset[2]; xoffset[0] = inc_amount * i / 2.0 * window_width; xoffset[1] = inc_amount * (i + 1) / 2.0 * window_width; yoffset[0] = (i % 2 ? 0.0 : 0.5) * window_height; yoffset[1] = yoffset[0] + window_height / 2; pass = piglit_probe_rect_rgba(xoffset[0], yoffset[0], xoffset[1] - xoffset[0], yoffset[1] - yoffset[0], white) && pass; } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { bool pass = true; int layer; glClear(GL_COLOR_BUFFER_BIT); piglit_ortho_projection(piglit_width, piglit_height, false); for (layer = 0; layer < max_layers; layer++) { int x = layer % piglit_width; int y = layer / piglit_width; glUniform1i(layer_loc, layer); piglit_draw_rect(x, y, 1, 1); } for (layer = 0; layer < max_layers; layer++) { int x = layer % piglit_width; int y = layer / piglit_width; float *color = colors[layer % ARRAY_SIZE(colors)]; pass = pass && piglit_probe_rect_rgba(x, y, 1, 1, color); } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display() { bool pass; float vertex_array[] = { -1, -1, 1, -1, 1, 1, -1, 1, }; float color_array[] = { 0.5, 0.0, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.5, 2.0, 0.5, 0.5, 0.5, 3.0, 0.5, 0.5, }; float green[] = {0, 1, 0, 0}; glVertexPointer(2, GL_FLOAT, 0, vertex_array); glEnableClientState(GL_VERTEX_ARRAY); glColorPointer(4, GL_FLOAT, 0, color_array); glEnableClientState(GL_COLOR_ARRAY); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); 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}; /* Clear red. */ glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /* Draw top half of screen green. */ glColor4f(0.0, 1.0, 0.0, 0.0); piglit_draw_rect(-1, 0, 2, 1); /* Discard a copy over the bottom red over the top green. */ glEnable(GL_RASTERIZER_DISCARD); glRasterPos2i(-1, 0); glCopyPixels(0, 0, piglit_width, piglit_height / 2, GL_COLOR); /* Don't discard a copy of the green over the remaining red. */ glDisable(GL_RASTERIZER_DISCARD); glRasterPos2i(-1, -1); glCopyPixels(0, piglit_height / 2, piglit_width, piglit_height / 2, GL_COLOR); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display() { int i; bool pass = true; float expected[3][4] = { {0.0, 1.0, 0.0, 1.0}, /* green */ {0.0, 0.0, 1.0, 1.0}, /* blue */ {1.0, 1.0, 0.0, 1.0}}; /* yellow */ glUseProgram(prog); for(i = 0; i < 3; i++) { glUniform1i(glGetUniformLocation(prog, "x"), i); /* Setup VertexAttribPointer for location=1. There should be * only one active attribute pointer set to the shared location * '1' at a time. */ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 11*sizeof(float), (void *) ((2 + 3*i) * sizeof(float))); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, (void *) 0); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, expected[i]) && pass; piglit_present_results(); } return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result draw(Display *dpy) { bool pass = true; float green[] = {0.0, 1.0, 0.0, 0.0}; GLXContext ctx; ctx = piglit_get_glx_context(dpy, visinfo); glXMakeCurrent(dpy, win, ctx); piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); /* Clear to green */ glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /* Noop */ glXSwapBuffers(dpy, win); /* We want to actually catch any X error that leaks through as * a result of glXSwapBuffers() before we go saying "pass" or * "fail". */ XSync(dpy, False); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { int i; int chunk_size = 24 * sizeof(float); bool pass = true; glClearColor(0.2, 0.2, 0.2, 0.2); glClear(GL_COLOR_BUFFER_BIT); for (i = 0; i < sizeof(data) / chunk_size; i++) { glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, tbo, i * chunk_size, chunk_size); glDrawArrays(GL_TRIANGLES, 0, 6); } for (i = 0; i < sizeof(data) / chunk_size; i++) { float c[4] = { data[i * 24 + 2], data[i * 24 + 3], 0, 1 }; pass = piglit_probe_rect_rgba( piglit_width * 0.5 * (1 + data[i * 24 + 0]), piglit_height * 0.5 * (1 + data[i * 24 + 1]), piglit_width/2, piglit_height/2, c) && pass; } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
/** * Helper function to draw a quad and check the results for divX*divY areas * on the screen. */ static bool draw_check_pixels(void) { bool pass = true; int i, j; GLfloat w = (GLfloat) piglit_width / (GLfloat) divX; GLfloat h = (GLfloat) piglit_height / (GLfloat) divY; /* draw single quad, expanded to divX*divY quads via geometry shader */ piglit_draw_rect(-1, -1, 2, 2); piglit_present_results(); /* check rendering results: greyscale RGB == 1.0 / (index +1)*/ for (i = 0; i < divX; i++) { for (j = 0; j < divY; j++) { GLfloat expected[4]; int p; expected[0] = expected[1] = expected[2] = 1.0 / (GLfloat) (1 + j + i*divY); expected[3] = 1.0; p = piglit_probe_rect_rgba(i * w + 1, j * h + 1, w-2, h-2, expected); if (!p) { printf("Wrong color for viewport i,j %d %d\n", i, j); pass = false; } } } return pass; }
void piglit_init(int argc, char **argv) { enum piglit_result result; GLuint render_program; int i; float green[4] = { 0.0, 1.0, 0.0, 1.0 }; cs_ids_common_init(); cs_ids_set_local_id_test(); cs_ids_set_local_size(4, 4, 4); cs_ids_set_global_size(4, 4, 4); render_program = piglit_build_simple_program(passthrough_vs_src, green_fs_src); glClearColor(0.0, 0.0, 0.0, 0.0); for (i = 0; i < 2; i++) { result = cs_ids_run_test(); if (result != PIGLIT_PASS) piglit_report_result(result); glUseProgram(render_program); glClear(GL_COLOR_BUFFER_BIT); piglit_draw_rect(-1, -1, 2, 2); result = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green) ? PIGLIT_PASS : PIGLIT_FAIL; } cs_ids_common_destroy(); piglit_report_result(result); }
enum piglit_result piglit_display() { bool pass; float green[] = {0, 1, 0, 0}; glBegin(GL_TRIANGLE_FAN); glColor4f(0.5, 0.0, 0.5, 0.5); glVertex2f(-1, -1); glColor4f(0.5, 1.0, 0.5, 0.5); glVertex2f(1, -1); glColor4f(0.5, 2.0, 0.5, 0.5); glVertex2f(1, 1); glColor4f(0.5, 3.0, 0.5, 0.5); glVertex2f(-1, 1); glEnd(); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLfloat expected[4] = { 0.0, 0.0, 1.0, 1.0 }; glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, piglit_width, piglit_height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor4f(0.0f, 0.0f, 1.0f, 1.0); glBegin(GL_QUADS); glVertex2f(-1.0f, -1.0f); glVertex2f( 1.0f, -1.0f); glVertex2f( 1.0f, 1.0f); glVertex2f(-1.0f, 1.0f); glEnd(); glFlush(); /* The test checks that the fill face of the quad is all blue without * noise artifacts */ if (piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, expected)) return PIGLIT_PASS; else return 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}; float vertex_data[] = { -0.5, -0.5, 0.5, -0.5, 0.0, 0.5, 0.0, 0.0 }; glDisable(GL_RASTERIZER_DISCARD); glColor4f(0.0, 1.0, 0.0, 0.0); piglit_draw_rect(-1, -1, 2, 2); glEnable(GL_RASTERIZER_DISCARD); glColor4f(1.0, 0.0, 0.0, 0.0); piglit_draw_rect(-1, -1, 2, 2); glVertexPointer(2, GL_FLOAT, 0, vertex_data); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(GL_LINE_LOOP, 0, 3); glDrawArrays(GL_POINTS, 3, 1); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { int l, q; bool pass = true; float red[4] = {1.0, 0.0, 0.0, 1.0}; float green[4] = {0.0, 1.0, 0.0, 1.0}; float blue[4] = {0.0, 0.0, 1.0, 1.0}; float white[4] = {1.0, 1.0, 1.0, 1.0}; float undefined[4] = {0.0, 0.0, 0.0, 0.0}; piglit_ortho_projection(piglit_width, piglit_height, false); glClearColor(0.5, 0.5, 0.5, 1.0); glClear(GL_COLOR_BUFFER_BIT); /* TODO: test other wrap modes */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); for (l = 0; (tex_size >> l) > 0; l++) { const int width = tex_size >> l; const int height = max(width / 2, 1); const int y = 10 + 20 * l; glUniform1f(lod_location, (float)l); /* Draw 4 squares with a color sample for each quad */ for (q = 0; q < 4; q++) { const float tex_x = (q / 2) * 0.5f + 0.25f; const float tex_y = (q % 2) * 0.5f + 0.25f; float *c = undefined; const int x = 10+20*q; if (((q / 2) * 0.5f + 0.25f) * width + (-2.0f) < 0.5f * width) { if (((q % 2) * 0.5f + 0.25f) * height + (+2.0f) < 0.5f * height) c = red; else c = blue; } else { if (((q % 2) * 0.5f + 0.25f) * height + (+2.0f) < 0.5f * height) c = green; else c = white; } glUniform2f(pos_location, tex_x, tex_y); piglit_draw_rect(x, y, 10, 10); if (width > 2 && c != undefined) /* below 1 wide no test */ pass &= piglit_probe_rect_rgba(x, y, 10, 10, c); } } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static bool test_nearest(int x) { int i; /* Set default tolerance for nearest filtering. */ for (i = 0; i < 4; i++) piglit_tolerance[i] = nearest_tolerance[i]; return (piglit_probe_rect_rgba(x, 0, texrect_w, texrect_h, r) && piglit_probe_rect_rgba(x + texrect_w, 0, texrect_w, texrect_h, g) && piglit_probe_rect_rgba(x, texrect_h, texrect_w, texrect_h, b) && piglit_probe_rect_rgba(x + texrect_w, texrect_h, texrect_w, texrect_h, w)); }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; GLuint tex; float red[4] = {1.0, 0.0, 0.0, 1.0}; float green[4] = {0.0, 1.0, 0.0, 1.0}; float blue[4] = {0.0, 0.0, 1.0, 1.0}; float white[4] = {1.0, 1.0, 1.0, 1.0}; tex = piglit_rgbw_texture(GL_RGBA, TEXSIZE, TEXSIZE, GL_FALSE, GL_FALSE, GL_UNSIGNED_NORMALIZED); glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex); draw_rect_tex(-1, -1, 2, 2, 0, 0, 1, 1); pass = pass && piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height / 2, red); pass = pass && piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2, piglit_height / 2, green); pass = pass && piglit_probe_rect_rgba(0, piglit_height / 2, piglit_width / 2, piglit_height / 2, blue); pass = pass && piglit_probe_rect_rgba(piglit_width / 2, piglit_height / 2, piglit_width / 2, piglit_height / 2, white); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; float black[] = {0, 0, 0, 0}; float white[] = {1, 1, 1, 1}; GLuint tex; glClearColor(0.0, 1.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); create_fbo(&tex); glBindTexture(GL_TEXTURE_2D, tex); glViewport(0, 0, piglit_width, piglit_height); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 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_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); piglit_draw_rect_tex(-1, -1, 2, 2, 0, 0, 1, 1); glDisable(GL_TEXTURE_2D); pass = pass && piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height, black); pass = pass && piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2, piglit_height, white); glDeleteTextures(1, &tex); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLuint vs, fs; bool pass = true; GLuint prog; float green[] = {0.0, 1.0, 0.0, 0.0}; GLint status; /* Initial buffer clear. */ glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source); prog = piglit_link_simple_program(vs, fs); if (!vs || !fs || !prog) piglit_report_result(PIGLIT_FAIL); piglit_DeleteShader(vs); piglit_DeleteShader(fs); piglit_UseProgram(prog); piglit_DeleteProgram(prog); /* Try to blow out the refcount */ piglit_DeleteProgram(prog); piglit_DeleteProgram(prog); piglit_DeleteProgram(prog); /* Sanity check: deleting didn't already unbind our shader program. */ piglit_draw_rect(-1, -1, 2, 2); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green) && pass; /* The program should still report being deleted. */ piglit_GetProgramiv(prog, GL_DELETE_STATUS, &status); if (!piglit_check_gl_error(0)) piglit_report_result(PIGLIT_FAIL); if (status != GL_TRUE) { fprintf(stderr, "GL_DELETE_STATUS after a clear reported non-true %d\n", status); pass = false; } /* Now, disable the program and it should be finally deleted. */ piglit_UseProgram(0); piglit_GetProgramiv(prog, GL_DELETE_STATUS, &status); pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result draw(Display *dpy) { GLXContext ctx; bool pass = true; unsigned int age; int i; static GLfloat colors[5][4] = { {1.0, 0.0, 0.0, 1.0}, {0.0, 1.0, 0.0, 1.0}, {0.0, 0.0, 1.0, 1.0}, {1.0, 0.0, 1.0, 1.0}, {0.0, 1.0, 1.0, 1.0} }; ctx = piglit_get_glx_context(dpy, visinfo); glXMakeCurrent(dpy, window, ctx); piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); glXQueryDrawable(dpy, window, GLX_BACK_BUFFER_AGE_EXT, &age); if (age != 0) { fprintf(stderr, "Initial age was %d, should be 0\n", age); pass = false; } for (i = 0; i < 5; i++) { glClearColor(colors[i][0], colors[i][1], colors[i][2], colors[i][3]); glClear(GL_COLOR_BUFFER_BIT); glXSwapBuffers(dpy, window); glXQueryDrawable(dpy, window, GLX_BACK_BUFFER_AGE_EXT, &age); printf("Frame %d: age %d\n", i + 1, age); if (age > 0) { int color_i = i - (age - 1); if (color_i < 0) { fprintf(stderr, "too old\n"); pass = false; } else { pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, colors[color_i]) && pass; } } } glXMakeCurrent(dpy, None, NULL); glXDestroyContext(dpy, ctx); 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) { GLuint tex, fb; GLenum status; float green[4] = {0.0, 1.0, 0.0, 0.0}; piglit_require_extension("GL_EXT_framebuffer_object"); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, BUF_WIDTH, BUF_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glGenFramebuffersEXT(1, &fb); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); assert(glGetError() == 0); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { fprintf(stderr, "framebuffer incomplete (status = 0x%04x)\n", status); piglit_report_result(PIGLIT_SKIP); } /* Draw something to get the driver's state all set up * pointing at our buffer. */ glColor4f(0.0, 1.0, 0.0, 0.0); piglit_draw_rect(-1, -1, 2, 2); piglit_probe_rect_rgba(0, 0, BUF_WIDTH, BUF_HEIGHT, green); /* This glFinish() should work. */ glFinish(); glDeleteTextures(1, &tex); /* This is the one that crashed. */ glFinish(); glDeleteFramebuffersEXT(1, &fb); piglit_report_result(PIGLIT_PASS); }
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 green[] = {0.0, 1.0, 0.0, 0.0}; float vertex_data[] = { /* quad position */ -1.0, -1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 0.0, 1.0, }; uint32_t index_data[] = { 0, 1, 2, 3 }; uintptr_t index_offset = sizeof(vertex_data); GLuint prog; glClearColor(1.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /* Use a vertex shader. Otherwise mesa turns our immediate * color data into a uniform in the fixed function vertex * shader. */ prog = piglit_build_simple_program(vs_source, NULL); glUseProgram(prog); glGenBuffersARB(1, &vbo); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo); glBufferDataARB(GL_ARRAY_BUFFER_ARB, index_offset + sizeof(index_data), NULL, GL_DYNAMIC_DRAW); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(vertex_data), vertex_data); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, index_offset, sizeof(index_data), index_data); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(4, GL_FLOAT, 0, (void *)0); glColor4f(0.0, 1.0, 0.0, 0.0); glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_INT, (void *)index_offset); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green); piglit_present_results(); glDisableClientState(GL_VERTEX_ARRAY); glDeleteBuffersARB(1, &vbo); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static bool test_single_layer(const Params* p, int layer) { int l; GLuint tex_src, tex_view; GLboolean pass; GLubyte *image; assert(layer < p->num_layers); glGenTextures(1, &tex_src); glBindTexture(GL_TEXTURE_2D_ARRAY, tex_src); glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, p->width, p->height, p->num_layers); /* load each array layer with red */ image = makesolidimage(p->width, p->height, red); for (l = 0; l < p->num_layers; l++) { glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, l, p->width, p->height, 1, GL_RGBA, GL_UNSIGNED_BYTE, image); } /* make layer to check red, but green for pixel at (0,0) which should be the only one sampled */ memcpy(image, green, sizeof(green)); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, layer, p->width, p->height, 1, GL_RGBA, GL_UNSIGNED_BYTE, image); free(image); glGenTextures(1, &tex_view); /* checked layer is supposed to be green */ glTextureView(tex_view, GL_TEXTURE_2D, tex_src, GL_RGBA8, 0, 1, layer, 1); 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_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, tex_view); /* draw it! */ piglit_draw_rect(-1, -1, 2, 2); pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, greenf); if (!pass) { printf("layer %d failed\n", layer); } glDeleteTextures(1, &tex_view); glDeleteTextures(1, &tex_src); return pass; }