Eric Anholt
80923e8d58
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 >
2021-04-19 17:59:44 +00:00
Eric Anholt
2b5178ee48
util: Switch the non-block formats to unpacking rgba rows instead of rects.
...
We have only a few callers of unpack that do rects, so add a helper that
iterates over y adding the strides. This saves us 36kb of generated code
and means that adding cpu-specific variants for RGBA format unpack will be
much simpler.
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10014 >
2021-04-19 17:59:44 +00:00
Simon Ser
6e697b595f
util/format: document block depth field
...
After the pixel block width and height, a third field is used to
store the pixel block depth. Document this field.
Signed-off-by: Simon Ser <contact@emersion.fr >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Leo Liu <leo.liu@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10134 >
2021-04-15 09:43:17 +00:00
Marek Olšák
e3e66e1fab
util: add new helper util_format_rgb_to_bgr
...
We have BGR formats for all RGB formats where it matters except
USCALED/SSCALED. radeonsi will use it.
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9615 >
2021-03-19 16:05:02 +00:00
Marek Olšák
5a29a55aa3
util: fail assertion in util_format_linear if it can't translate SRGB format
...
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9615 >
2021-03-19 16:05:02 +00:00
Marek Olšák
aff4c790ea
util: add most missing formats with reversed RGB channel order
...
This will be used for RGB->BGR enum translation.
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9615 >
2021-03-19 16:05:02 +00:00
Jesse Natalie
69c2a472c2
u_format: Add restrict to fn pointer and manual format pack/unpack/fetch
...
MSVC warns (loudly) about a mismatch between the generated functions in
u_format_table.c and the definition of util_format_[un]pack_description,
specifically having 'restrict' in the function but not in the pointer
type in the struct.
So, add 'restrict' everywhere - to the function types, and to the rest
of the implementations that are assigned to those structs.
v2: util_format_unpack_description is used in gallium/auxiliary/translate
Fixes: 5785fdac ("u_format: Mark the generated pack/unpack src/dst args as restrict.")
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9670 >
2021-03-18 14:53:52 +00:00
Eric Anholt
5785fdac63
u_format: Mark the generated pack/unpack src/dst args as restrict.
...
Calling code to pack/unpack with overlap would be already be undefined.
Cuts 50k of text on x86_64 release builds from the compiler having more
freedom in the src/dst loads knowing that they don't interfere with each
other.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Reviewed-by: Adam Jackson <ajax@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9500 >
2021-03-11 23:26:34 +00:00
Eric Anholt
a46b73ee25
mesa: Move the FXT1 compressor/decompressor to util/
...
softpipe failed at handling FXT1, despite exposing it, because we didn't
have a fetch function for it in the util/ format table.
Fixes : #3968
Reviewed-by: Adam jackson <ajax@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9194 >
2021-02-23 20:38:50 +00:00
Dave Airlie
8258726d90
util/format: add helper to check if a format is scaled.
...
lavapipe/llvmpipe need this to rule out scaled formats for non-vertex
format usage. Note NONE is defined as scaled in u_format, but for
the purposes of this helper I don't want it to be considered scaled.
Reviewed-by: Adam Jackson <ajax@redhat.com >
Reviewed-by: Roland Scheidegger <sroland@vmware.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8907 >
2021-02-16 05:31:11 +00:00
Eric Anholt
8e2e637480
util/format: Simplify the generated unpack code.
...
We were declaring the temps, then in the same order declaring
assignments to those temps. The code is more legible (and shorter)
with the assignments moved in place.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297 >
2021-01-15 18:58:50 +00:00
Eric Anholt
322fa3d9dc
util: Give a reasonable answer when unpacking z32unorm from floats.
...
We weren't clamping the float Z value, just multiplying it by a big
float and casting that to int. This makes util/format's z unpacking
match Mesa's.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297 >
2021-01-15 18:58:50 +00:00
Eric Anholt
b938b488f6
util: Fix rounding of unpack_unorm8 from small unorm formats.
...
The code was doing the bit-shift trick, but not accounting for the
rounding necessary which the Mesa unpack code was previously doing.
Using the helpers prevents a regression in
KHR-GL46.copy_image.smoke_test on iris as we consolidate the
pack/unpack code.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297 >
2021-01-15 18:58:50 +00:00
Eric Anholt
0565270380
util: Fix UBSan failure on _mesa_unorm_to_unorm.
...
It complains about shifting 1<<31 being undefined, so make it a 1u.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297 >
2021-01-15 18:58:50 +00:00
Eric Anholt
8d9826f014
util: Move most of src/mesa/main/format_utils.h to util/format/
...
This is a set of very nice, complete helpers for moving around bits in
various formats, and we want to retain its behavior when deduplicating
Mesa's format pack/unpack and gallium's.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297 >
2021-01-15 18:58:50 +00:00
Eric Anholt
e5e75b714d
util/format: Fix pack/unpack of A1R5G5B5_UINT.
...
Avoids regressing KHR-GL33.packed_pixels.pbo_rectangle.* when
transitioning from mesa/main pack/unpack codegen to util/format's.
Fixes: b28eb044cd ("gallium: Add equivalents of packed MESA_FORMAT_*UINT formats.")
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297 >
2021-01-15 18:58:50 +00:00
Adam Jackson
dd05cbf5e0
mesa: Implement GL_EXT_texture_sRGB_RG8 for softpipe and llvmpipe
...
sRGB_RG8 is not registered for big-GL yet, see this Khronos issue
for updates on that:
https://github.com/KhronosGroup/OpenGL-Registry/issues/450
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8060 >
2021-01-04 21:19:35 +00:00
Juan A. Suarez Romero
b243ccb060
util: function to check for rgbX format
...
Function that checks if the format has its alpha component forced to 1.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com >
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7816 >
2020-12-09 12:25:31 +00:00
Rob Clark
53f7d539cd
util: Add helgrind support for simple_mtx
...
Annoyingly mtypes.h pulls in simple_mtx, which means we end up needing
to sprinkle a lot of idep_mesautil around.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3773
Signed-off-by: Rob Clark <robdclark@chromium.org >
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7644 >
2020-11-24 21:03:34 +00:00
Erik Faye-Lund
ff3b4f6683
util: fix unknown pragma warning on msvc
...
MSVC has no idea about these pragmas, and spews warnings about them,
making it hard to spot real problems. So let's only use these macros on
GCC.
Fixes: 2ec290cd92 ("util: Fix/silence variable shadowing warnings")
Reviewed-by: Tony Wasserka <tony.wasserka@gmx.de >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7633 >
2020-11-16 11:09:57 +00:00
Tony Wasserka
2ec290cd92
util: Fix/silence variable shadowing warnings
...
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7552 >
2020-11-16 08:49:18 +00:00
Gert Wollny
e60df9fe16
util/format_zs: Add C++ include handling
...
Signed-off-by: Gert Wollny <gert.wollny@collabora.com >
Reviewed-by: Emil Velikov <emil.velikov@collabora.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7477 >
2020-11-10 15:37:07 +00:00
Jason Ekstrand
d44c76be85
util,gallium: Add new 64-bit integer formats
...
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7509 >
2020-11-09 17:17:39 +00:00
Vinson Lee
fdb1997ab5
Fix VMware capitalization.
...
Signed-off-by: Vinson Lee <vlee@freedesktop.org >
Reviewed-by: Brian Paul <brianp@vmware.com >
Reviewed-by: Neha Bhende <bhenden@vmware.com >
Reviewed-by: Jose Fonseca <jfonseca@vmware.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7260 >
2020-10-27 15:33:40 -07:00
Kristian H. Kristensen
e23bcb69c3
util/formats: Add PIPE_FORMAT_R8_G8B8_420_UNORM
...
This is a planar, subsampled format. It's basically NV12, but without
colorspace conversion.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6693 >
2020-10-08 09:37:14 +00:00
Marek Olšák
f5f0c012ad
gallium/util: remove empty file u_half.h
...
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Reviewed-by: Matt Turner <mattst88@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6987 >
2020-10-06 21:07:11 -04:00
Marek Olšák
71697953ec
gallium/util: remove redundant util_float_to_half_rtz
...
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Reviewed-by: Matt Turner <mattst88@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6987 >
2020-10-06 21:07:09 -04:00
Marek Olšák
b42c6ff6f6
util: remove util_float_to_half and util_half_to_float wrappers
...
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Reviewed-by: Matt Turner <mattst88@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6987 >
2020-10-06 21:07:07 -04:00
Matt Turner
1aac47db69
Revert F16C series (MR 6774)
...
This reverts commit 4fb2eddfdf .
This reverts commit 7a1deb16f8 .
This reverts commit 2b6a172343 .
This reverts commit 5af81393e4 .
This reverts commit 87900afe5b .
A couple of problems were discovered after this series was merged that
cause breakage in different configurations:
(1) It seems that using -mf16c also enables AVX, leading to SIGILL on
platforms that do not support AVX.
(2) Since clang only warns about unknown flags, and as I understand
it Meson's handling in cc.has_argument() is broken, the F16C code is
wrongly enabled when clang is used, even for example on ARM, leading
to a compilation error.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3583
Reviewed-by: Eric Anholt <eric@anholt.net >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6969 >
2020-10-01 21:08:12 +00:00
Marek Olšák
4fb2eddfdf
gallium/util: remove empty file u_half.h
...
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6774 >
2020-09-30 16:28:24 +00:00
Marek Olšák
7a1deb16f8
gallium/util: remove redundant util_float_to_half_rtz
...
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6774 >
2020-09-30 16:28:24 +00:00
Marek Olšák
2b6a172343
util: remove util_float_to_half and util_half_to_float wrappers
...
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6774 >
2020-09-30 16:28:24 +00:00
Nanley Chery
c3c99f4571
st/mesa: Don't map all P01X DRM formats to P016
...
Allow gallium drivers to distinguish between the P010, P012, and P016
DRM formats.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6486 >
2020-09-09 20:02:03 +00:00
Eric Anholt
8d38b25788
util: Explicitly call the unpack functions from inside bptc pack/unpack.
...
We were calling the table-based unpack functions from inside the pack and
unpack table's methods, so if anything included these pack functions (such
as a call to a table-based pack function), you'd pull in all of unpack as
well.
By calling them explicitly, we save some overhead in these functions
(switch statement, address math on the zero x,y arguments) anyway.
Reviewed-by: Jonathan Marek <jonathan@marek.ca >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6307 >
2020-08-20 05:03:16 +00:00
Eric Anholt
edf0aeb3cd
util: Expose rgba unpack/fetch functions as external functions as well.
...
Like we just did for pack functions for freedreno, it will be useful to be
able to pick out a specific rgba unpack function instead of going through
the table.
Reviewed-by: Jonathan Marek <jonathan@marek.ca >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6307 >
2020-08-20 05:03:16 +00:00
Dave Airlie
5a9eba4acd
util/format: add some ZS helpers for vallium
...
The vallium layer has a requirement to insert and extra the 24-bit
unorm value as a unorm value (not as a float etc). Add helpers
to facilitate that.
Reviewed-by: Roland Scheidegger <sroland@vmware.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6082 >
2020-08-17 14:30:50 +10:00
Eric Anholt
5b8d67cb64
util: Move fetch_rgba to a separate function table.
...
Only llvmpipe and translate_generic use it, and only in fallbacks, so if
you're not building that then let's not bloat our binaries with it.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6305 >
2020-08-16 21:25:14 +00:00
Eric Anholt
9cc84369b7
util: Mark the format description getter functions as const.
...
This lets the compiler CSE calls to them on the same format. This is
particularly relevant for the description table lookup calls, which other
inlines might do internally.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6305 >
2020-08-16 21:25:14 +00:00
Eric Anholt
35b22b5da0
util: Make all 3 fetch_rgba functions occupy the same function slot.
...
A single format either had the float, the sint, or the uint version.
Making the dst be void * lets us store them in the same slot and not have
logic in the callers to call the right one.
-6kb on gallium drivers
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6305 >
2020-08-16 21:25:14 +00:00
Eric Anholt
80babbbf7e
uitl: Add R1_UNORM to the list of noaccess (no pack/unpack) formats.
...
The functions were just stubs, if you called them you would be terribly
disappointed.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6305 >
2020-08-16 21:25:14 +00:00
Jonathan Marek
84ed2d0980
util/format: expose generated format packing functions through a header
...
Some of the generated functions can be useful without going through the
format table (filling border color struct in turnip). By not calling these
functions through the format table, we should eventually be able to garbage
collect the unused packing functions, and also allows LTOs to happen.
Signed-off-by: Jonathan Marek <jonathan@marek.ca >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6093 >
2020-08-13 16:54:06 +00:00
Eric Anholt
33e69203d2
util: Fix up indentation in the generated format tables code.
...
I did this as a separate commit to make the previous one more reviewable.
Acked-by: Matt Turner <mattst88@gmail.com >
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5826 >
2020-08-12 14:22:24 -07:00
Eric Anholt
9fd0f455af
util: Change a codegenned switch statement to a nice little table.
...
This saves us 13 to 35kb on release drivers in my builds.
Acked-by: Matt Turner <mattst88@gmail.com >
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5826 >
2020-08-12 14:22:24 -07:00
Eric Anholt
4064a6cd20
util: Split the pack/unpack functions out of the format desc.
...
This gives the compiler a chance to GC pack/unpack functions separate from
the format descriptions. For drivers that use everything, this is
+10-20kb, while for libvulkan_intel it's -1.3MB.
Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1048434
Acked-by: Matt Turner <mattst88@gmail.com >
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5826 >
2020-08-12 13:13:39 -07:00
Marcin Ślusarz
28f2585365
util/format: initialize non-important components to 0
...
Avoids copying random garbage from the stack.
Found by Coverity.
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6067 >
2020-07-30 10:41:00 +00:00
Eric Anholt
b7418270c3
util: Share a single function pointer for the 4-byte rgba unpack function.
...
Everyone wants the same behavior, and this helps shrink the size of our
format description tables.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5728 >
2020-07-07 18:19:23 +00:00
Eric Anholt
a8e7004dc5
util: Remove the stub pack/unpack functions for YUV formats.
...
If we can't pack/unpack them, the field is supposed to be NULL.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5728 >
2020-07-07 18:19:23 +00:00
Eric Anholt
2da4badfe3
util: Use designated initializers to clean up the format tables' pack/unpack.
...
The generated .c had a bunch of NULLs and notes for what kind of function
was being skipped, when we can just skip them by filling in the fields
with names.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5728 >
2020-07-07 18:19:23 +00:00
Eric Anholt
e7010eeff0
util: Merge util_format_read_4* functions.
...
Everyone wants the same thing: unpack 4-bytes-per-channel data based on the
base type of the format.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5728 >
2020-07-07 18:19:23 +00:00
Eric Anholt
2f4d557a56
util: Merge util_format_write_4* functions.
...
Everyone wants the same thing: pack 4-bytes-per-channel data based on the
base type of the format.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5728 >
2020-07-07 18:19:23 +00:00