pygfx / pyshader

Write modern GPU shaders in Python!
BSD 2-Clause "Simplified" License
73 stars 1 forks source link

Control flow #35

Closed almarklein closed 4 years ago

almarklein commented 4 years ago

From a high pov:

Implementation:

Korijn commented 4 years ago

Just wanted to show my support: this is really impressive :)

almarklein commented 4 years ago

Almost there ...

almarklein commented 4 years ago

sigh in Python 3.8 there have been some changes to the bytecode: The interpreter loop has been simplified by moving the logic of unrolling the stack of blocks into the compiler. The compiler emits now explicit instructions for adjusting the stack of values and calling the cleaning-up code for break, continue and return.

Removed opcodes BREAK_LOOP, CONTINUE_LOOP, SETUP_LOOP [...]

That SETUP_LOOP was really useful for us to tell that a loop was coming, but that info is now gone :'(

Korijn commented 4 years ago

Yeah... it's a risk of relying on internals :(

ivoflipse commented 4 years ago

It may help to ask support from core devs on what opcodes would be best to use, since they may keep changing this even further

almarklein commented 4 years ago

I don't think that's necessary. The loop structure can still be derived from the jumps, and is actually not that much different from what the code does now. It's mostly that the SETUP_LOOP and POP_BLOCK gave us a nice signal, and now we have to evaluate the bytecode a bit harder. I've made a start, and I have a good feeling about it.

almarklein commented 4 years ago

🥳