-
Notifications
You must be signed in to change notification settings - Fork 369
Open
Description
As explained in the title I am generating extremely detailed high resolution textures that I need to save to disk for later use and validation, but reading them causes crashes due to signed integers and integer overflow. Compression in most use cases would be the solution, but is not viable for my niche application. (I have solved it by using 2^14 - 2 sized textures) This is an issue with a ctypes function using a 32-bit signed integer, and I'm unsure if we can do anything about it but warn users.
Minimal Example:
from arcade import Window
win = Window()
# Case 1: Two's Compliment Strikes again
# 2^14 * 2^14 is 2^28 pixels. Each pixel is made of 2 32-bit floats
# that's 2^28 * 2 * 2^2 or 2^31 bytes of data.
# in Two's compliment that's -2147483648
try:
a = win.ctx.texture((2**14, 2**14), components=2, dtype="f4")
data = a.read()
except SystemError as e:
print("Issue with case 1!")
print(e) # Doing this so both cases run
else:
print("No Issue for case 1!")
print(f"here is the data! {data}")
# Case 2: Integer Overflow :D
# 2^14 * 2^14 is 2^28 pixels. Each pixel is made of 4 32-bit floats
# That's 2^28 * 4 * 2^2 or 2^32 bytes of data.
# That requires 33 bits to represent as a number causing the 32-bit integer to overflow
# raising no exception, but reading no data
try:
a = win.ctx.texture((2**14, 2**14), components=4, dtype="f4")
data = a.read()
except SystemError as e:
print("Issue with case 2!")
print(e) # Doing this so both cases run
else:
print("No Issue for case 2!")
print(f"here is the data! {data}")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels