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

Support for dummy output (no-op APIs) mode? #318

Open
cher-nov opened this issue Nov 11, 2024 · 9 comments
Open

Support for dummy output (no-op APIs) mode? #318

cher-nov opened this issue Nov 11, 2024 · 9 comments

Comments

@cher-nov
Copy link

cher-nov commented Nov 11, 2024

Many older games used engines like GameMaker, which did not allow the developer to opt-out of graphics and/or audio output, but was also extensible. This led to cute situations where entire full-fledged tools were built on such engines using only system APIs, because this allowed the main game code to be reused and shared. However, such programs were still forced to waste resources on running subsystems they didn't need. One obvious example here is dedicated servers.

What would be nice to see is the ability to turn off actual output (activity imitation) in the following different ways:

  1. Report successes, but do not perform any output to the device and discard the input where appropriate.
  2. Force D3DDEVTYPE_NULLREF and its associated semantics in all corresponding functions instead of actual values.
  3. Force reporting that a suitable device or driver is missing.
  4. Always return status codes indicating failure on all relevant operations.

This would make it possible to obtain greater performance in such applications, as well as make them independent of real hardware configurations and contexts unfriendly to DirectX (for example, running in Wine).

@cher-nov cher-nov changed the title Support for null output (no-op APIs) mode? Support for dummy output (no-op APIs) mode? Nov 11, 2024
@elishacloud
Copy link
Owner

Interesting idea. Though I am not sure how much performance improvement this would actually give you. If the game engine loads DirectSound, for example, but does nothing with it because the game is using XAudio then I doubt there wold be much saved by simply giving the game engine an empty stub instead of the DirectSound APIs.

@cher-nov
Copy link
Author

cher-nov commented Nov 16, 2024

It's not just about performance, but also about decoupling from unnecessary dependencies. For example, GameMaker has a bad habit of showing a warning messagebox if it fails to initialize DirectSound, which blocks further loading and requires user interaction. As you can imagine, this complicates the automation of restarts, which is critical in the case of dedicated servers.

@elishacloud
Copy link
Owner

For example, GameMaker has a bad habit of showing a warning messagebox if it fails to initialize DirectSound, which blocks further loading and requires user interaction.

I see. And what would cause it to fail? If there a no sound cards in the device? I could consider making an option for creating an empty DirectSound wrapper option, because that is a real problem with dedicated servers.

@cher-nov
Copy link
Author

cher-nov commented Nov 18, 2024

And what would cause it to fail? If there a no sound cards in the device?

Yes, that's literally one of the reasons.
But in general, such a window appears on any DirectSound initialization error in GameMaker runner, so there also may be others.

@elishacloud
Copy link
Owner

GameMaker has a bad habit of showing a warning messagebox if it fails to initialize DirectSound

Understood. Adding a dummy wrapper for DirectSound, for these cases makes sense. However, I am not sure it has much value to make a dummy wrapper for all DirectX interfaces (DirectInput, DirectDraw, Direct3D7, Direct3D8, Direct3D9, Direct3D10, etc.).

@cher-nov
Copy link
Author

cher-nov commented Nov 18, 2024

However, I am not sure it has much value to make a dummy wrapper for all DirectX interfaces (DirectInput, DirectDraw, Direct3D7, Direct3D8, Direct3D9, Direct3D10, etc.).

It does IMO, because in GameMaker, for example, if something goes wrong on the initialization of Direct3D or DirectInput, then not only the same thing happens as with DirectSound (a modal window is displayed), but also the application aborts itself, even if input and display are in fact provided by other means (for example, WinAPI). This is why I originally proposed the ability of having four different methods of stubs in the request - GameMaker is just one example that I'm aware of, while others may employ more or less strict error handling semantics.

@polybluez
Copy link

Though I am not sure how much performance improvement this would actually give you.

Another benefit is that it would allow running games you previously couldn't without having an active Mesa and an Xorg server installed for the sole purpose of running the said game.

@polybluez
Copy link

GameMaker has a bad habit of showing a warning messagebox if it fails to initialize DirectSound

Understood. Adding a dummy wrapper for DirectSound, for these cases makes sense. However, I am not sure it has much value to make a dummy wrapper for all DirectX interfaces (DirectInput, DirectDraw, Direct3D7, Direct3D8, Direct3D9, Direct3D10, etc.).

Actually, in cher-nov's case DirectSound failing doesn't make a huge
difference as you can easily close the nagging window with xdotool (or
ydotool, in case you've decided to use a headless Wayland compositor).

As for the Direct3D, you can obviously close the window too, but the
game wouldn't budge and start. So all that's left for you is to
install Mesa, the "llvmpipe" software driver, and an Xorg server with
GLX enabled. There is, unfortunately, no other facilities to run such
apps in Wine without having to pollute your server with those
packages. The performance is really not the issue, but space wasted
is, as in some distros Wine installs can take severals of GBs, and
Xorg w/ Mesa is not lighweight either.

@cher-nov
Copy link
Author

Today I've came upon another use case for this feature: to avoid D3D device losses. For example, in the case of GameMaker they require considerable time to overcome, and versions from 8.1.141 to 8.1.218 could even crash on this (see this patch:
https://github.com/skyfloogle/gm8x_fix/tree/be7fa448?tab=readme-ov-file#the-display-reset-patch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants