BizHawk icon indicating copy to clipboard operation
BizHawk copied to clipboard

Waterbox & LLVMpipe

Open vadosnaprimer opened this issue 2 years ago • 8 comments

Since @nattthebear is non-trivial to catch on irc while I remember about this, I guess we need a ticket.

libTAS uses LLVMpipe to simulate hardware graphics stuff in software and make savestates of that.

Force software rendering

This option forces the OpenGL device driver Mesa 3D to use its software implementation of OpenGL (llvmpipe) to run the game. While this makes the game much slower, it is usually required to be able to use savestates. Indeed, the state of the GPU cannot be easily accessed and stored into savestates by the tool, thus savestates are incomplete and may crash the game. When using Mesa's software implementation, all of the graphics pipeline is done by the CPU and can be stored in the savestate.

You must be using Mesa 3D to be able to use this option, which usually means that you must be using the free driver for your GPU (e.g. nouveau for nvidia GPUs or radeon for ATI/AMD CPUs)

We know that waterbox can't snapshot GPU state, but would it be feasible to incorporate llvmpipe into waterboxhost so cores that require GPU (like Ruffle) could be ported?

vadosnaprimer avatar May 18 '22 17:05 vadosnaprimer

Yes, this is a good idea. I've thought a bit about Mesa based rendering. LLVMPipe may be too advanced to support in the waterbox, but Mesa has other choices as well. I was always worried about speed; if it's glacial, then is it worth it?

nattthebear avatar May 18 '22 18:05 nattthebear

I'd love to see speed as the only problem for some things that are otherwise outright impossible to get into hawk.

vadosnaprimer avatar May 18 '22 20:05 vadosnaprimer

From a tas perspective, speed is of no concern as we tend to slow the game down anyways.

If it was like 1 frame every minute then it would be impractical.

InfamousKnight avatar May 18 '22 20:05 InfamousKnight

If we're talking about arbitrary 3d cores like dolphin or citra, the speed very well may be that low. We can't assume anything about orders of magnitude here without research.

nattthebear avatar May 18 '22 20:05 nattthebear

Both Dolphin and Citra have software renderers anyways. They would probably be faster than Mesa based rendering (assuming said renderers are optimized, which Dolphin definitely isn't anyways)

Ruffle (as mentioned) is the main thing that would greatly benefit from something like this, given it has no savestates but it doesn't have any true software renderer (although there is a separate question of can Rust code be waterboxed, but I imagine that is probably a yes with some work).

CasualPokePlayer avatar May 19 '22 07:05 CasualPokePlayer

Rust is in principle waterboxable. How fast is regular ruffle with mesa?

nattthebear avatar May 19 '22 10:05 nattthebear

Ruffle's speed is game dependent, but in libTAS with forced software rendering, I get about 0.5x-1x speed with Meat Boy and Super Mario Flash can get up to around 2x speed. Both Vulkan and GL run at around the same speed. This is not on a great computer either; I have Ubuntu running natively on an old laptop, it has these specs:

CPU: Intel® Core™ i5-4210M CPU @ 2.60GHz × 4 GPU: Intel® HD Graphics 4600 (HSW GT2)

slamotas avatar May 19 '22 15:05 slamotas

LLVMpipe could be used for BlastEm core if you don't want to disable OpenGL?

getCursorsExe avatar Aug 08 '22 13:08 getCursorsExe

Something to consider here (from LLVMpipe's page):

Also, the driver is multithreaded to take advantage of multiple CPU cores (up to 32 at this time).

Threads are junk in the box, so whatever speed measures you end up finding with libTAS + forced software rendering is likely going to be way better than what the box will give you.

CasualPokePlayer avatar Jan 25 '23 11:01 CasualPokePlayer