mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 09:18:04 +02:00
u_format: Use memcpy to avoid unaligned accesses
These functions are used by gl[Get]TexImage, which imposes no
alignment restructions on the void *pixels parameter.
This fixes an unaligned access in GTK's "gtk:gdk / memorytexture" unit
test on SPARC, which causes the test to fail.
Fixes: 45ae4434b5 ("util: Use bitshift arithmetic to unpack pixels.")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23482>
This commit is contained in:
parent
96cf4531e1
commit
19092576ce
1 changed files with 3 additions and 2 deletions
|
|
@ -441,7 +441,8 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
|
|||
|
||||
def unpack_from_bitmask(channels, swizzles):
|
||||
depth = format.block_size()
|
||||
print(' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth))
|
||||
print(' uint%u_t value;' % (depth))
|
||||
print(' memcpy(&value, src, sizeof value);')
|
||||
|
||||
# Compute the intermediate unshifted values
|
||||
for i in range(format.nr_channels()):
|
||||
|
|
@ -567,7 +568,7 @@ def generate_pack_kernel(format, src_channel, src_native_type):
|
|||
if value is not None:
|
||||
print(' value |= %s;' % (value))
|
||||
|
||||
print(' *(uint%u_t *)dst = value;' % depth)
|
||||
print(' memcpy(dst, &value, sizeof value);')
|
||||
|
||||
def pack_into_struct(channels, swizzles):
|
||||
inv_swizzle = inv_swizzles(swizzles)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue