Raising MAX_MEMORY_ALLOCATION_SIZE limit past 2gb?

8 views
Skip to first unread message

Richard Kuo

unread,
May 13, 2021, 4:25:30 AM5/13/21
to swiftshader
Hi,

Are there any plans in the works to enable raising this variable past the 2GB limit?  We are processing some occasionally large images with shaders and ran into this limitation rather quickly.

- Richard

Nicolas Capens

unread,
May 13, 2021, 12:08:43 PM5/13/21
to Richard Kuo, swiftshader
Hi Richard,

Thanks for your interest in SwiftShader! It should definitely be feasible to raise the allocation limit, but we have to be a bit careful about it because we use a lot of 32-bit signed arithmetic for index calculations, which could overflow and produce negative values and thus cause out-of-bounds accesses. See https://issuetracker.google.com/144988972 for some related notes that led us to limit the maximum allocation to 1 GiB for now. We don't have specific plans for increasing it yet.

Have you tried setting MAX_MEMORY_ALLOCATION_SIZE to 4 GiB and encountered any issues, or did it happen to work? Off the top of my head I believe image sampling should work, but image read/write operations in compute shaders might not.

Cheers,
Nicolas

--
You received this message because you are subscribed to the Google Groups "swiftshader" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swiftshader...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swiftshader/a31b11eb-3c7d-4eed-b468-e77bd0359eafn%40googlegroups.com.

Richard Kuo

unread,
May 13, 2021, 3:55:57 PM5/13/21
to Nicolas Capens, swiftshader
Thanks Nicolas.  We actually use compute shaders almost exclusively so it sounds like going to 4GB wouldn't work.  In fact, we hit a static_assert with a slightly smaller value than 2GB deeper in the code (0x7fffffffull - 16), so the main assertion and comments probably should be updated to match?  Very tiny detail there.

The other thought we had was to try out sparse residency to work around this, but that feature isn't currently supported by swiftshader.

- Richard
Reply all
Reply to author
Forward
0 new messages