#include "lp_test.h"
-#define USE_TEXTURE_CACHE 1
-
static struct lp_build_format_cache *cache_ptr;
void
static LLVMValueRef
add_fetch_rgba_test(struct gallivm_state *gallivm, unsigned verbose,
const struct util_format_description *desc,
- struct lp_type type)
+ struct lp_type type,
+ unsigned use_cache)
{
char name[256];
LLVMContextRef context = gallivm->context;
LLVMValueRef rgba;
LLVMValueRef cache = NULL;
- util_snprintf(name, sizeof name, "fetch_%s_%s", desc->short_name,
- type.floating ? "float" : "unorm8");
+ snprintf(name, sizeof name, "fetch_%s_%s", desc->short_name,
+ type.floating ? "float" : "unorm8");
args[0] = LLVMPointerType(lp_build_vec_type(gallivm, type), 0);
args[1] = LLVMPointerType(LLVMInt8TypeInContext(context), 0);
i = LLVMGetParam(func, 2);
j = LLVMGetParam(func, 3);
- if (cache_ptr) {
+ if (use_cache) {
cache = LLVMGetParam(func, 4);
}
PIPE_ALIGN_STACK
static boolean
test_format_float(unsigned verbose, FILE *fp,
- const struct util_format_description *desc)
+ const struct util_format_description *desc,
+ unsigned use_cache)
{
LLVMContextRef context;
struct gallivm_state *gallivm;
context = LLVMContextCreate();
gallivm = gallivm_create("test_module_float", context);
- fetch = add_fetch_rgba_test(gallivm, verbose, desc, lp_float32_vec4_type());
+ fetch = add_fetch_rgba_test(gallivm, verbose, desc,
+ lp_float32_vec4_type(), use_cache);
gallivm_compile_module(gallivm);
memset(unpacked, 0, sizeof unpacked);
- fetch_ptr(unpacked, packed, j, i, cache_ptr);
+ fetch_ptr(unpacked, packed, j, i, use_cache ? cache_ptr : NULL);
for(k = 0; k < 4; ++k) {
if (util_double_inf_sign(test->unpacked[i][j][k]) != util_inf_sign(unpacked[k])) {
PIPE_ALIGN_STACK
static boolean
test_format_unorm8(unsigned verbose, FILE *fp,
- const struct util_format_description *desc)
+ const struct util_format_description *desc,
+ unsigned use_cache)
{
LLVMContextRef context;
struct gallivm_state *gallivm;
context = LLVMContextCreate();
gallivm = gallivm_create("test_module_unorm8", context);
- fetch = add_fetch_rgba_test(gallivm, verbose, desc, lp_unorm8_vec4_type());
+ fetch = add_fetch_rgba_test(gallivm, verbose, desc,
+ lp_unorm8_vec4_type(), use_cache);
gallivm_compile_module(gallivm);
memset(unpacked, 0, sizeof unpacked);
- fetch_ptr(unpacked, packed, j, i, cache_ptr);
+ fetch_ptr(unpacked, packed, j, i, use_cache ? cache_ptr : NULL);
match = TRUE;
for(k = 0; k < 4; ++k) {
static boolean
test_one(unsigned verbose, FILE *fp,
- const struct util_format_description *format_desc)
+ const struct util_format_description *format_desc,
+ unsigned use_cache)
{
boolean success = TRUE;
- if (!test_format_float(verbose, fp, format_desc)) {
+ if (!test_format_float(verbose, fp, format_desc, use_cache)) {
success = FALSE;
}
- if (!test_format_unorm8(verbose, fp, format_desc)) {
+ if (!test_format_unorm8(verbose, fp, format_desc, use_cache)) {
success = FALSE;
}
{
enum pipe_format format;
boolean success = TRUE;
+ unsigned use_cache;
- util_format_s3tc_init();
-
-#if USE_TEXTURE_CACHE
cache_ptr = align_malloc(sizeof(struct lp_build_format_cache), 16);
-#endif
- for (format = 1; format < PIPE_FORMAT_COUNT; ++format) {
- const struct util_format_description *format_desc;
+ for (use_cache = 0; use_cache < 2; use_cache++) {
+ for (format = 1; format < PIPE_FORMAT_COUNT; ++format) {
+ const struct util_format_description *format_desc;
- format_desc = util_format_description(format);
- if (!format_desc) {
- continue;
- }
+ format_desc = util_format_description(format);
+ if (!format_desc) {
+ continue;
+ }
+ /*
+ * TODO: test more
+ */
- /*
- * TODO: test more
- */
+ if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
+ continue;
+ }
- if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
- continue;
- }
+ if (util_format_is_pure_integer(format))
+ continue;
- if (util_format_is_pure_integer(format))
- continue;
+ /* only have util fetch func for etc1 */
+ if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
+ format != PIPE_FORMAT_ETC1_RGB8) {
+ continue;
+ }
- /* only have util fetch func for etc1 */
- if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
- format != PIPE_FORMAT_ETC1_RGB8) {
- continue;
- }
+ /* missing fetch funcs */
+ if (format_desc->layout == UTIL_FORMAT_LAYOUT_ASTC ||
+ format_desc->layout == UTIL_FORMAT_LAYOUT_ATC) {
+ continue;
+ }
- /* missing fetch funcs */
- if (format_desc->layout == UTIL_FORMAT_LAYOUT_BPTC ||
- format_desc->layout == UTIL_FORMAT_LAYOUT_ASTC) {
- continue;
- }
+ /* only test twice with formats which can use cache */
+ if (format_desc->layout != UTIL_FORMAT_LAYOUT_S3TC && use_cache) {
+ continue;
+ }
- if (!test_one(verbose, fp, format_desc)) {
- success = FALSE;
+ if (!test_one(verbose, fp, format_desc, use_cache)) {
+ success = FALSE;
+ }
}
}
-#if USE_TEXTURE_CACHE
align_free(cache_ptr);
-#endif
return success;
}