electronicarts / gigi

A framework for rapid prototyping and development of real-time rendering techniques.
Other
597 stars 28 forks source link

Viewer, Interpreter: added shader asserts #4

Closed Rewlion closed 1 month ago

Rewlion commented 1 month ago

[CONTEXT]

New token is introduced: /$(Assert: condition [,fmt] [...])/

whenever condition is failed an error is printed to the interpreter log

It's mostly useful for the compute shaders to catch OOB access.

There are up to 6 formatting arguments supported. They are expected to be a type of 'float'. If assert has condition expression only then it becomes the message itself.

Right now there is only one assert fired per node-shader. It's done to exclude errors spamming. It means that an assert has identifier related to the shader and only the new unseen asserts are printed to the log.

This assert identifier is node name related. But it can be improved to be 'line' related this way each we can distinguish each /$(Assert)/ even if it has the same format string.

Asserts are available for the Interpreter backend only. It would be nice to have a toggle in the 'settings' that enables\disables asserts processing. To exclude addition of the nodes resources and processing when it's not required.

Supported action nodes: [X] DrawCall [X] ComputeShader

[IMPLEMENTATION] Preparations:

New logic: Idea is simple.

Atrix256 commented 1 month ago

Thanks for this! Internal folks at EA that use Gigi are excited about this feature going in. I've skimmed over the changes, and they look good at first blush. I'll take a deeper look today or tomorrow and should get this merged in and cut a new version of Gigi to include it.

Atrix256 commented 1 month ago

Code flows from the internal repo to external, so I put your changes in the internal repo before merging them into this public one. This work is changelist e5b5fc449eefb49807881bd3c1393cd64b5ff6a2 and is part of release and tag v0.99.2.

I was impressed by your attention to detail. Thanks for this feature!