void piglit_init(int argc, char **argv) { GLint num_compressed_formats; GLenum *compressed_formats = NULL; unsigned i; bool pass = true; piglit_require_extension("GL_ARB_texture_compression"); glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num_compressed_formats); if (num_compressed_formats == 0) { printf("No compressed formats supported.\n"); } else if (num_compressed_formats < 0) { fprintf(stderr, "Invalid number of compressed formats (%d) reported\n", num_compressed_formats); piglit_report_result(PIGLIT_FAIL); } else { compressed_formats = calloc(num_compressed_formats, sizeof(GLenum)); glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, (GLint *) compressed_formats); printf("Driver reported the following compressed formats:\n"); for (i = 0; i < num_compressed_formats; i++) { printf(" 0x%04x %s\n", compressed_formats[i], piglit_get_gl_enum_name(compressed_formats[i])); } printf("\n"); fflush(stdout); } /* There are some specific formats that are valid for certain generic * formats that are not returned by the GL_COMRPESSED_TEXTURE_FORMATS * query. That query only returns formats that have no restrictions or * caveats for RGB or RGBA base formats. We have to add these formats * to the list of possible formats by hand. */ if (piglit_is_extension_supported("GL_EXT_texture_compression_latc")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 4, GL_COMPRESSED_LUMINANCE_LATC1_EXT, GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT, GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT); } if (piglit_is_extension_supported("GL_ATI_texture_compression_3dc")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 1, 0x8837); } pass = try_formats(arb_texture_compression_formats, ARRAY_SIZE(arb_texture_compression_formats), compressed_formats, num_compressed_formats); /* Remove the various luminance and luminance-alpha formats from the * list since they cannot be used for the later tests. */ if (piglit_is_extension_supported("GL_ATI_texture_compression_3dc")) { num_compressed_formats--; } if (piglit_is_extension_supported("GL_EXT_texture_compression_latc")) { num_compressed_formats -= 4; } /* Add the RGTC formats, then check them. */ if (piglit_is_extension_supported("GL_ARB_texture_rg")) { if (piglit_is_extension_supported("GL_ARB_texture_compression_rgtc") || piglit_is_extension_supported("GL_EXT_texture_compression_rgtc")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 4, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2); } pass = try_formats(arb_texture_rg_formats, ARRAY_SIZE(arb_texture_rg_formats), compressed_formats, num_compressed_formats) && pass; /* Remove the RGTC formats from the list since they cannot be * used for the later tests. */ if (piglit_is_extension_supported("GL_ARB_texture_compression_rgtc") || piglit_is_extension_supported("GL_EXT_texture_compression_rgtc")) { num_compressed_formats -= 4; } } /* Add the sRGB formats, then check them. */ if (piglit_is_extension_supported("GL_EXT_texture_sRGB")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 4, GL_COMPRESSED_SRGB, GL_COMPRESSED_SRGB_ALPHA, GL_COMPRESSED_SLUMINANCE, GL_COMPRESSED_SLUMINANCE_ALPHA); if (piglit_is_extension_supported("GL_EXT_texture_compression_s3tc")) { compressed_formats = add_formats(compressed_formats, &num_compressed_formats, 4, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT); } pass = try_formats(ext_texture_srgb_formats, ARRAY_SIZE(ext_texture_srgb_formats), compressed_formats, num_compressed_formats) && pass; /* Remove the sRGB formats from the list since they cannot be * used for the later tests. */ num_compressed_formats -= 4; if (piglit_is_extension_supported("GL_EXT_texture_compression_s3tc")) { num_compressed_formats -= 4; } } piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void piglit_init(int argc, char **argv) { GLint num_compressed_formats; GLenum *compressed_formats = NULL; unsigned i; bool pass = true; bool log_header = true; bool do_all = false; bool check_errors = true; piglit_require_extension("GL_ARB_texture_compression"); glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num_compressed_formats); if (num_compressed_formats == 0) { printf("No compressed formats supported.\n"); } else { compressed_formats = calloc(num_compressed_formats, sizeof(GLenum)); glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, (GLint *) compressed_formats); printf("Driver reported the following compressed formats:\n"); for (i = 0; i < num_compressed_formats; i++) { printf(" 0x%04x: %s\n", compressed_formats[i], piglit_get_gl_enum_name(compressed_formats[i])); } printf("\n"); fflush(stdout); } /* First scan the list of formats looking for zeros. We use that as * magic flag later in the test. */ for (i = 0; i < num_compressed_formats; i++) { if (compressed_formats[i] == 0) { fprintf(stderr, "Invalid value 0x0000 in format list.\n"); piglit_report_result(PIGLIT_FAIL); } } /* The "unknown" flag instructs the test to just check for values that * don't belong to any compression extension supported by this * implementation. */ if (argc > 1 && strcmp("unknown", argv[1]) == 0) { check_errors = false; argv++; argc--; } if (argc == 1) { argv = (char **) all_formats; /* cast away const */ argc = ARRAY_SIZE(all_formats); do_all = true; } for (i = 1; i < argc; i++) { if (strcmp(argv[i], "bptc") == 0) { pass = try_formats(&bptc_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_ARB_texture_compression_bptc"), true) && pass; } else if (strcmp(argv[i], "s3tc") == 0) { pass = try_formats(&s3tc_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_EXT_texture_compression_s3tc"), false) && pass; } else if (strcmp(argv[i], "fxt1") == 0) { pass = try_formats(&fxt1_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_3DFX_texture_compression_FXT1"), false) && pass; } else if (strcmp(argv[i], "latc") == 0) { pass = try_formats(&latc_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_EXT_texture_compression_latc"), false) && pass; } else if (strcmp(argv[i], "3dc") == 0) { pass = try_formats(&ati_3dc_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_ATI_texture_compression_3dc"), false) && pass; } else if (strcmp(argv[i], "rgtc") == 0) { pass = try_formats(&rgtc_formats, compressed_formats, num_compressed_formats, check_errors, (piglit_is_extension_supported("GL_ARB_texture_compression_rgtc") || piglit_is_extension_supported("GL_EXT_texture_compression_rgtc")), false) && pass; } else if (strcmp(argv[i], "srgb") == 0) { pass = try_formats(&srgb_formats, compressed_formats, num_compressed_formats, check_errors, (piglit_is_extension_supported("GL_EXT_texture_sRGB") && piglit_is_extension_supported("GL_EXT_texture_compression_s3tc")), false) && pass; } else if (strcmp(argv[i], "paletted") == 0) { pass = try_formats(&paletted_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_OES_compressed_paletted_texture"), false) && pass; } else if (strcmp(argv[i], "etc1") == 0) { pass = try_formats(&etc1_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_OES_compressed_ETC1_RGB8_texture"), false) && pass; } else if (strcmp(argv[i], "etc2") == 0) { pass = try_formats(&etc2_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_ARB_ES3_compatibility"), true) && pass; } else if (strcmp(argv[i], "astc") == 0) { pass = try_formats(&astc_formats, compressed_formats, num_compressed_formats, check_errors, piglit_is_extension_supported("GL_KHR_texture_compression_astc_ldr"), false) && pass; } else { fprintf(stderr, "Unrecognized selection `%s'\n", argv[i]); piglit_report_result(PIGLIT_FAIL); } } /* After all of the known formats have been processed, the entire * format array should be zeroed out. Any non-zero values are either * errors or formats from unknown extensions... meaning that the test * may need to be updated. */ if (do_all) { for (i = 0; i < num_compressed_formats; i++) { if (compressed_formats[i] != 0) { if (log_header) { fprintf(stderr, "Unrecognized compressed " "texture formats:\n"); log_header = false; } fprintf(stderr, " 0x%04x: %s\n", compressed_formats[i], piglit_get_gl_enum_name(compressed_formats[i])); pass = false; } } } pass = test_hint() && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }