util/format: Add some NEON intrinsics-based u_format_unpack.

In looking at the profile of dEQP, GLES3 was spending 5-10% of its time in
ReadPixels, and almost all of that is b8g8r8a8_unorm8.  It's really slow
because we're getting about 47MB/s by doing uncached reads 32 bits at a
time in the code-generated unpack.  If we use NEON to generate larger bus
transactions, we can speed things up to 136MB/s.  In comparison, raw
ldr/str read/writes with no byte swapping can hit a max of 216MB/sec.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10014>
This commit is contained in:
Eric Anholt
2021-04-05 09:33:21 -07:00
committed by Marge Bot
parent 2b5178ee48
commit 80923e8d58
6 changed files with 123 additions and 2 deletions
+28
View File
@@ -34,6 +34,7 @@
#include "util/format/u_format.h"
#include "util/format/u_format_s3tc.h"
#include "util/u_cpu_detect.h"
#include "util/u_math.h"
#include "pipe/p_defines.h"
@@ -1130,3 +1131,30 @@ util_format_rgb_to_bgr(enum pipe_format format)
return PIPE_FORMAT_NONE;
}
}
static const struct util_format_unpack_description *util_format_unpack_table[PIPE_FORMAT_COUNT];
static void
util_format_unpack_table_init(void)
{
for (enum pipe_format format = PIPE_FORMAT_NONE; format < PIPE_FORMAT_COUNT; format++) {
#if (defined(PIPE_ARCH_AARCH64) || defined(PIPE_ARCH_ARM)) && !defined NO_FORMAT_ASM
const struct util_format_unpack_description *unpack = util_format_unpack_description_neon(format);
if (unpack) {
util_format_unpack_table[format] = unpack;
continue;
}
#endif
util_format_unpack_table[format] = util_format_unpack_description_generic(format);
}
}
const struct util_format_unpack_description *
util_format_unpack_description(enum pipe_format format)
{
static once_flag flag = ONCE_FLAG_INIT;
call_once(&flag, util_format_unpack_table_init);
return util_format_unpack_table[format];
}