enum piglit_result piglit_display(void) { GLuint tex; GLboolean pass = GL_TRUE; glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); tex = piglit_rgbw_texture(GL_COMPRESSED_RGB_FXT1_3DFX, SIZE, SIZE, GL_TRUE, GL_FALSE, GL_UNSIGNED_NORMALIZED); display_mipmaps(10, 10 + (10 + SIZE) * 0); glDeleteTextures(1, &tex); tex = piglit_rgbw_texture(GL_COMPRESSED_RGBA_FXT1_3DFX, SIZE, SIZE, GL_TRUE, GL_FALSE, GL_UNSIGNED_NORMALIZED); display_mipmaps(10, 10 + (10 + SIZE) * 1); glDeleteTextures(1, &tex); pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 0); pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 1); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static enum piglit_result call_CopyTexSubImage_when_texture_is_referenced(void *data) { GLuint tex; tex = piglit_rgbw_texture(GL_RGBA8, 16, 16, GL_FALSE, GL_FALSE, GL_UNSIGNED_BYTE); glGetTextureHandleARB(tex); if (!piglit_check_gl_error(GL_NO_ERROR)) return PIGLIT_FAIL; /* The ARB_bindless_texture spec says: * * "The contents of the images in a texture object may still be * updated via commands such as TexSubImage*, CopyTexSubImage*, and * CompressedTexSubImage*, and by rendering to a framebuffer object, * even if the texture object is referenced by one or more texture * handles." */ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 16, 16); if (!piglit_check_gl_error(GL_NO_ERROR)) return PIGLIT_FAIL; return PIGLIT_PASS; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; GLuint tex; tex = piglit_rgbw_texture(GL_RGBA8, 64, 64, GL_FALSE, GL_TRUE, GL_UNSIGNED_NORMALIZED); glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); pass = piglit_probe_pixel_rgb(1 * piglit_width / 3, 1 * piglit_width / 3, blue); pass = piglit_probe_pixel_rgb(2 * piglit_width / 3, 1 * piglit_width / 3, red) && pass; pass = piglit_probe_pixel_rgb(1 * piglit_width / 3, 2 * piglit_width / 3, green) && pass; pass = piglit_probe_pixel_rgb(2 * piglit_width / 3, 2 * piglit_width / 3, white) && pass; piglit_present_results(); glDeleteTextures(1, &tex); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
void piglit_init(int argc, char **argv) { int vs, fs, prog; int tex_location; piglit_require_GLSL_version(130); glActiveTexture(GL_TEXTURE0); piglit_rgbw_texture(GL_RGBA, tex_size, tex_size / 2, true, false, GL_UNSIGNED_NORMALIZED); piglit_ortho_projection(piglit_width, piglit_height, false); vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert); fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag); prog = piglit_link_simple_program(vs, fs); tex_location = piglit_GetUniformLocation(prog, "tex"); lod_location = piglit_GetUniformLocation(prog, "lod"); pos_location = piglit_GetUniformLocation(prog, "pos"); piglit_UseProgram(prog); piglit_Uniform1i(tex_location, 0); }
enum piglit_result piglit_display(void) { static const char *fp_source = "!!ARBfp1.0\n" "TEX result.color, fragment.texcoord[0], texture[1], 2D;\n" "END\n"; bool pass = true; GLuint tex; GLuint prog; texrect_w = piglit_width / 4 / 2; texrect_h = piglit_height / 2; glGenProgramsARB(1, &prog); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog); glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(fp_source), (const GLubyte *) fp_source); glEnable(GL_FRAGMENT_PROGRAM_ARB); glActiveTexture(GL_TEXTURE1); tex = piglit_rgbw_texture(GL_RGBA, 2, 2, false, false, GL_UNSIGNED_NORMALIZED); /* Given that the failure mode we had that led to this test * being written was that the sampler state read was * pseudo-random, go through several statechanges on the * sampler to make sure we're reliably getting our sampler * state. */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); piglit_draw_rect_tex(-1, -1, 0.5, 2, 0, 0, 1, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); piglit_draw_rect_tex(-0.5, -1, 0.5, 2, 0, 0, 1, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); piglit_draw_rect_tex(0, -1, 0.5, 2, 0, 0, 1, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); piglit_draw_rect_tex(0.5, -1, 0.5, 2, 0, 0, 1, 1); pass = pass && test_nearest(piglit_width * 0 / 4); pass = pass && test_linear(piglit_width * 1 / 4); pass = pass && test_nearest(piglit_width * 2 / 4); pass = pass && test_linear(piglit_width * 3 / 4); piglit_present_results(); glDeleteTextures(1, &tex); glDisable(GL_FRAGMENT_PROGRAM_ARB); glDeleteProgramsARB(1, &prog); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static GLboolean run_test(const TestCase &test) { describe(test); GLboolean pass; GLuint tex; GLuint fbo; GLenum status; glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); #if CHECKERBOARD const float color1[4] = {1.0f, 0.0f, 0.0f, 1.0f}; const float color2[4] = {0.0f, 1.0f, 0.0f, 1.0f}; tex = piglit_checkerboard_texture(0, 0, test.srcW, test.srcH, 1, 1, color1, color2); #else tex = piglit_rgbw_texture(GL_RGBA, test.srcW, test.srcH, GL_FALSE, GL_TRUE, GL_UNSIGNED_NORMALIZED); #endif glBindTexture(GL_TEXTURE_2D, tex); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0); assert(glGetError() == 0); status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { pass = GL_TRUE; } else { glViewport(0, 0, piglit_width, piglit_height); piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); blit(test); pass = verify(test, fbo, 0, 3); if (!piglit_automatic) { piglit_present_results(); if (!pass) { //getchar(); } } } glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo); glDeleteFramebuffers(1, &fbo); glDeleteTextures(1, &tex); return pass; }
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; }
void piglit_init(int argc, char **argv) { GLuint tex; piglit_require_extension("GL_OES_draw_texture"); piglit_glDrawTexiOES = (PFNGLDRAWTEXIOESPROC) eglGetProcAddress("glDrawTexiOES"); if (!piglit_glDrawTexiOES) piglit_report_result(PIGLIT_FAIL); piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); tex = piglit_rgbw_texture(GL_RGBA, TEXTURE_SIZE, TEXTURE_SIZE, GL_FALSE, GL_TRUE, 0); glBindTexture(GL_TEXTURE_2D, tex); glEnable(GL_TEXTURE_2D); }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; static const float red[] = {1.0, 0.0, 0.0, 1.0}; static const float green[] = {0.0, 1.0, 0.0, 1.0}; static const float blue[] = {0.0, 0.0, 1.0, 1.0}; static const float white[] = {1.0, 1.0, 1.0, 1.0}; GLuint tex; glActiveTexture(GL_TEXTURE1); tex = piglit_rgbw_texture(GL_RGBA, 8, 8, GL_FALSE, GL_FALSE, GL_UNSIGNED_NORMALIZED); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glRotatef(90, 0, 0, 1); piglit_draw_rect(-1, -1, 2, 2); pass = piglit_probe_pixel_rgba(piglit_width * 1 / 4, piglit_height * 1 / 4, blue) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 3 / 4, piglit_height * 1 / 4, red) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 1 / 4, piglit_height * 3 / 4, white) && pass; pass = piglit_probe_pixel_rgba(piglit_width * 3 / 4, piglit_height * 3 / 4, green) && pass; piglit_present_results(); glDeleteTextures(1, &tex); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
void piglit_init(int argc, char **argv) { int prog; piglit_require_GLSL_version(130); glActiveTexture(GL_TEXTURE0); /* TODO: test npot sizes, other samplers, ... */ piglit_rgbw_texture(GL_RGBA, tex_size, tex_size / 2, true, false, GL_UNSIGNED_NORMALIZED); /* TODO: test other texture instructions */ prog = piglit_build_simple_program(vert, fragtexlodoffset); lod_location = glGetUniformLocation(prog, "lod"); pos_location = glGetUniformLocation(prog, "pos"); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glUseProgram(prog); }
void piglit_init(int argc, char **argv) { int prog; int tex_location; piglit_require_GLSL_version(130); glActiveTexture(GL_TEXTURE0); piglit_rgbw_texture(GL_RGBA, tex_size, tex_size / 2, true, false, GL_UNSIGNED_NORMALIZED); piglit_ortho_projection(piglit_width, piglit_height, false); prog = piglit_build_simple_program(vert, frag); tex_location = glGetUniformLocation(prog, "tex"); lod_location = glGetUniformLocation(prog, "lod"); pos_location = glGetUniformLocation(prog, "pos"); glUseProgram(prog); glUniform1i(tex_location, 0); }
static enum piglit_result call_CompressedTexSubImage_when_texture_is_referenced(void *data) { void *compressed; GLuint tex; GLint size; tex = piglit_rgbw_texture(GL_COMPRESSED_RGBA_BPTC_UNORM, 16, 16, GL_FALSE, GL_FALSE, GL_UNSIGNED_NORMALIZED); glGetTextureHandleARB(tex); if (!piglit_check_gl_error(GL_NO_ERROR)) return PIGLIT_FAIL; glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size); compressed = malloc(size); glGetCompressedTexImage(GL_TEXTURE_2D, 0, compressed); /* The ARB_bindless_texture spec says: * * "The contents of the images in a texture object may still be * updated via commands such as TexSubImage*, CopyTexSubImage*, and * CompressedTexSubImage*, and by rendering to a framebuffer object, * even if the texture object is referenced by one or more texture * handles." */ glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_COMPRESSED_RGBA_BPTC_UNORM, size, compressed); free(compressed); if (!piglit_check_gl_error(GL_NO_ERROR)) return PIGLIT_FAIL; return PIGLIT_PASS; }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; GLuint tex, bump; int x, y; float bump_matrix[4] = {1.0, 0.0, 0.0, 1.0}; 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 bumpdata[TEXSIZE][TEXSIZE][2]; /* First: the base texture. */ tex = piglit_rgbw_texture(GL_RGBA, TEXSIZE, TEXSIZE, GL_FALSE, GL_FALSE, GL_UNSIGNED_NORMALIZED); glActiveTexture(tex_unit); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE); /* Second: the bumpmap. */ glGenTextures(1, &bump); glActiveTexture(bump_unit); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, bump); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_BUMP_ENVMAP_ATI); glTexEnvf(GL_TEXTURE_ENV, GL_BUMP_TARGET_ATI, tex_unit); /* The bump map we use is going to end up rotating texels CCW. */ for (y = 0; y < TEXSIZE; y++) { for (x = 0; x < TEXSIZE; x++) { if (y < TEXSIZE / 2) { if (x < TEXSIZE / 2) { bumpdata[y][x][0] = 0.0; bumpdata[y][x][1] = 0.5; } else { bumpdata[y][x][0] = -0.5; bumpdata[y][x][1] = 0.0; } } else { if (x < TEXSIZE / 2) { bumpdata[y][x][0] = 0.5; bumpdata[y][x][1] = 0.0; } else { bumpdata[y][x][0] = 0.0; bumpdata[y][x][1] = -0.5; } } } } glTexImage2D(GL_TEXTURE_2D, 0, GL_DU8DV8_ATI, TEXSIZE, TEXSIZE, 0, GL_DUDV_ATI, GL_FLOAT, bumpdata); glTexBumpParameterfvATI(GL_BUMP_ROT_MATRIX_ATI, bump_matrix); draw_rect_multitex(-1, -1, 2, 2, 0, 0, 1, 1); pass = pass && piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height / 2, blue); pass = pass && piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2, piglit_height / 2, red); pass = pass && piglit_probe_rect_rgba(0, piglit_height / 2, piglit_width / 2, piglit_height / 2, white); pass = pass && piglit_probe_rect_rgba(piglit_width / 2, piglit_height / 2, piglit_width / 2, piglit_height / 2, green); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
static int create_texture(void) { GLuint tex; float *ptr; /* Generate mipmap level 0 */ tex = piglit_rgbw_texture(GL_RGBA, TEX_WIDTH, TEX_WIDTH, GL_FALSE, GL_TRUE, GL_FLOAT); glBindTexture(GL_TEXTURE_2D, tex); if (!piglit_check_gl_error(GL_NO_ERROR)) piglit_report_result(PIGLIT_FAIL); /* Go into appropriate transform feedback or discard state */ if (discard) glEnable(GL_RASTERIZER_DISCARD); if (buffer || prims_written) { float buffer[4096]; buffer[0] = 12345.0; glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf); glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, sizeof(buffer), buffer, GL_STREAM_READ); glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, xfb_buf); glUseProgram(xfb_prog); glBeginTransformFeedback(GL_POINTS); } if (prims_written) { glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, prims_written_query); } if (prims_generated) { glBeginQuery(GL_PRIMITIVES_GENERATED, prims_generated_query); } /* Ask the implementation to generate the remaining mipmap levels. */ glGenerateMipmapEXT(GL_TEXTURE_2D); if (!piglit_check_gl_error(0)) piglit_report_result(PIGLIT_FAIL); /* Check state */ if (discard) { if (!glIsEnabled(GL_RASTERIZER_DISCARD)) { printf("GL_RASTERIZER_DISCARD state not restored " "after glGenerateMipmapEXT\n"); piglit_report_result(PIGLIT_FAIL); } glDisable(GL_RASTERIZER_DISCARD); } if (buffer || prims_written) { glEndTransformFeedback(); glUseProgram(0); } if (buffer) { ptr = glMapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, GL_READ_ONLY); if (ptr[0] != 12345.0) { printf("Transform feedback buffer was overwritten " "during glGenerateMipmapEXT\n"); piglit_report_result(PIGLIT_FAIL); } } if (prims_written) { GLuint result; glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); glGetQueryObjectuiv(prims_written_query, GL_QUERY_RESULT, &result); if (result != 0) { printf("PRIMITIVES_WRITTEN counter was incremented " "during glGenerateMipmapEXT\n"); piglit_report_result(PIGLIT_FAIL); } } if (prims_generated) { GLuint result; glEndQuery(GL_PRIMITIVES_GENERATED); glGetQueryObjectuiv(prims_generated_query, GL_QUERY_RESULT, &result); if (result != 0) { printf("PRIMITIVES_GENERATED counter was incremented " "during glGenerateMipmapEXT\n"); piglit_report_result(PIGLIT_FAIL); } } return tex; }
enum piglit_result piglit_display(void) { GLuint tex, tex_src; bool pass; int level; unsigned bw, bh, bs; piglit_get_compressed_block_size(format->token, &bw, &bh, &bs); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); tex_src = piglit_rgbw_texture(format->token, SIZE, SIZE, true, false, GL_UNSIGNED_NORMALIZED); glCreateTextures(GL_TEXTURE_2D, 1, &tex); for (level = 0; (SIZE >> level) > 0; level++) { int w, h; int expected_size, size; void *compressed; w = SIZE >> level; h = SIZE >> level; expected_size = piglit_compressed_image_size(format->token, w, h); glBindTexture(GL_TEXTURE_2D, tex_src); glGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size); if (size != expected_size) { fprintf(stderr, "Format %s level %d (%dx%d) size %d " "doesn't match expected size %d\n", piglit_get_gl_enum_name(format->token), level, w, h, size, expected_size); piglit_report_result(PIGLIT_FAIL); } compressed = malloc(size); glGetCompressedTextureImage(tex_src, level, size, compressed); glBindTexture(GL_TEXTURE_2D, tex); glCompressedTexImage2D(GL_TEXTURE_2D, level, format->token, w, h, 0, size, compressed); if (!piglit_check_gl_error(GL_NO_ERROR)) piglit_report_result(PIGLIT_FAIL); free(compressed); } glDeleteTextures(1, &tex_src); glBindTextureUnit(tex, 0); display_mipmaps(10, 10); pass = check_resulting_mipmaps(10, 10); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }