#include "state_tracker/st_context.h"
#include "state_tracker/st_format.h"
#include "state_tracker/st_texture.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
#include <stdbool.h>
static bool
};
struct st_context local_st = {
.pipe = &pctx,
+ .has_etc1 = true,
+ .has_etc2 = true,
+ .has_astc_2d_ldr = true,
+ .has_astc_5x5_ldr = true,
};
struct st_context *st = &local_st;
/* test all Mesa formats */
for (i = 1; i < MESA_FORMAT_COUNT; i++) {
+ if (!_mesa_get_format_name(i))
+ continue;
+
enum pipe_format pf;
- if (st_compressed_format_fallback(st, i))
- continue;
+ assert(!st_compressed_format_fallback(st, i));
pf = st_mesa_format_to_pipe_format(st, i);
if (pf != PIPE_FORMAT_NONE) {
- mesa_format MAYBE_UNUSED mf = st_pipe_format_to_mesa_format(pf);
+ mesa_format mf = st_pipe_format_to_mesa_format(pf);
if (mf != i) {
fprintf(stderr, "Round-tripping %s -> %s -> %s failed\n",
_mesa_get_format_name(i), util_format_short_name(pf),
_mesa_get_format_name(mf));
return 1;
}
- }
- }
- /* Test all Gallium formats */
- for (i = 1; i < PIPE_FORMAT_COUNT; i++) {
- mesa_format mf = st_pipe_format_to_mesa_format(i);
- if (st_compressed_format_fallback(st, mf))
- continue;
+ const struct util_format_description *desc = util_format_description(i);
- if (mf != MESA_FORMAT_NONE) {
- enum pipe_format MAYBE_UNUSED pf =
- st_mesa_format_to_pipe_format(st, mf);
- if (pf != i) {
- fprintf(stderr, "Round-tripping %s -> %s -> %s failed\n",
- util_format_short_name(i),
- _mesa_get_format_name(pf),
- util_format_short_name(pf));
- return 1;
+ /* Make sure that gallium and Mesa agree on whether the format is an
+ * array format.
+ */
+ if (desc->nr_channels > 1) {
+ bool mesa_array = (_mesa_get_format_layout(mf) ==
+ MESA_FORMAT_LAYOUT_ARRAY);
+ bool gallium_array = desc->is_array && !desc->is_bitmask;
+ /* We should probably be checking equality here, but we have some
+ * UINT and SINT types that are array formats in Mesa but not in
+ * gallium.
+ */
+ if (gallium_array && !mesa_array) {
+ fprintf(stderr, "%s is %sarray, %s is %sarray\n",
+ util_format_short_name(i),
+ gallium_array ? "" : "not ",
+ _mesa_get_format_name(mf),
+ mesa_array ? "" : "not ");
+ return 1;
+ }
}
}
}