Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VLA fallback solution #19

Open
Dawoodoz opened this issue Aug 3, 2020 · 2 comments
Open

VLA fallback solution #19

Dawoodoz opened this issue Aug 3, 2020 · 2 comments
Labels
Future proofing Aiming to work around year 2200 A.C.

Comments

@Dawoodoz
Copy link
Owner

Dawoodoz commented Aug 3, 2020

Triangle rasterization uses small but dynamic arrays for storing pixel intervals for each row without having to fetch memory far away on the heap.

In case that the VLA C extension can suddenly no longer be used in the distant future (new CPU architecture with new conflicting feature, et cetera), it would be good to have a fallback implementation for simulating or replacing VLA when not available (just like the SIMD abstraction runs with zero overhead when not having the extensions).

A global stack on the heap would not work when called from multiple threads breaking the call order.

Carrying thread contexts would be a horribly entangled spaghetti design.

Allocating on the heap per triangle would be compact, but also horribly slow if ending up with cache misses from another thread stealing the address space. Pre-allocating the height of the target's section with even padding would have enough room for the worst case triangle height and have no allocation overhead per triangle, but this would not be easily reusable for other problems needing VLA.

@Dawoodoz Dawoodoz added the Future proofing Aiming to work around year 2200 A.C. label Aug 3, 2020
@Dawoodoz
Copy link
Owner Author

Dawoodoz commented Aug 6, 2020

Using alloca instead of VLA would make the code more standard, while still getting the speed of stack memory.

@Dawoodoz
Copy link
Owner Author

Maybe just restructure rasterization, so that the pixel intervals are sent directly to the pixel shader using a function pointer for filling two rows of pixels. Then no need for VLA when rendering triangles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Future proofing Aiming to work around year 2200 A.C.
Projects
None yet
Development

No branches or pull requests

1 participant