This is called compute dispatching and is super common. I have done a whole bunch of DSP implementations where you use a CUDA or AVX kernel depending on availability. Or you dispatch to standard library or even Python kernel otherwise.
It’s good to know when Reddit moderators see the light and help transition their communities over before Reddit interferes. !piracy is another example of that.
On modern CPUs it doesn’t matter that much. And any optimization would have to be updated for each CPU type (Zen/4, Alder lake, etc.) Modern CPUs have insane out of order execution that makes compiler generated code nearly as fast as the most optimized handwritten ones. On older CPUs you’d see more of a performance bump.
I would argue that if your games are already performant on the platforms you care about that you would get diminishing returns. The only reason to experiment with specialist asm would be for your own experience and enrichment which is a perfectly reasonable reason to pursue it.
It’s probably not worth comparing to an OS where even shaving a few cycles off of code that runs all the time on millions of computers across the world would end up with significant impact.
Does your game crawl? Have you identified this code as the bottleneck? Are you certain that asm will give you a meaningful performance increase, and that your issue doesn’t lie with your approach to the problem? Sure, I guess. You said your game runs fine though, so this probably doesn’t apply.
Is your game fast already? If you don’t want to do it, don’t.
Writing asm by hand is almost always a waste of time. There are only a few times where it’s actually necessary, and unless you’re writing a bootloader and running your game on bare metal, I can’t imagine why it’d be necessary. But you know your code better than anyone else here, so you should know whether it’s needed or not more than any of us do.
To begin with, you’re apparently targeting the Z80, which I haven’t seen used for games in the wild… probably in my entire life? Maybe an arcade machine I played on once used it, but I can’t think of any other times. If your targets need custom assembly, then you should already know that. We don’t know your targets.
I was just using a feature of the z80 as an example and thank you for your help and if anyone wants to add that functionality in their game to increase performance they can.
bin.pol.social
Aktywne