25 May 2016

BGFX Shaders - Finally Working :-) :-) :-)

Since MAME 0.172, the BGFX shaders are the new kids on the block, and they are very promising. In particular, they are cross-platform, so they produce identical results under Windows, Linux and Mac. Today I finally found out how I get them working.

In this later post, I show you how to tweak BGFX so that your individual settings are there every time.

And in this new post, you find instructions on how to tweak BGFX in mame.ini - which is actually the preferred choice (you stay independent of frontend - and even platforms).

Here is a step-by step configuration of BGFX under QMC2 - which actually should work on all platforms offering QMC2.

1. Read the official MAME documentation for BGFX on BGFX:
    http://docs.mamedev.org/advanced/bgfx.html
    my task is to translate this into the QMC2 environment

2. QMC2: Tools/Options/Emulator/Global Configuration/Video/video bgfx

3. QMC2: BGFX Post-Processing Options - see this screenshot:


These options are identical with what MAME officially recommends - some comments:
  • bgfx_backend: I activated the Metal backend, which requires MacOSX El Capitan. Here it works, and I just could not resist.
  • bgfx_path: If you have SDL MAME without changes, the MAME executable directory should contain a bgfx subdirectory with all the files. No changes then needed here.
  • bgfx_screen_chains: must be changed manually to hlsl - this is the second key to the shaders
  • bgfx_shadow_mask: Can be left as is, but here was my stupid mistake - be absolutely sure that all artwork files, which are now delivered with SDLMame, are in the artwork directory defined in QMC2. If MAME cannot find this new new BGFX artwork, then you do not get the new options within MAME
4. Start a MAME Game from QMC2 - and you will be surprised that there are no effects whatsoever

What the .... - click to enlarge
The MAME Dev Team states appropriately: Warning: Currently BGFX HLSL settings are not saved or loaded from any configuration files. This is expected to change in the future.

Then go into the in-game options by pressing the TAB key - then move to Slider Controls and press RETURN:

It's the Slider Controls!!!! - click to enlarge
Only if you have configured everything correctly, you suddenly find a huge amount of new options here. The most important one - you must Enable the Adjustments, because they are turned Off by default.
The most important option - turn it to On (cursor left-right) - click to enlarge
You can see that MAME has properly identified your hlsl and shadow mask configuration. The result is a very very impressive retro screen:
Click to Enlarge
The screenshot cannot honor all the effects that are here. Even a typical monitor flickering is in. All effects are far too extreme for regular gaming, but you can see the full capabilities of this solution. I should post a video file here, because it is so awesome. But for sure, a game such as Elevator Action is nearly unplayable with these extreme effects.

A reminder once again: In this post, I explain how to tweak BGFX with your individual settings.



14 comments:

  1. On my 2011 iMac, using BGFX absolutely kills the framerate using HLSL. Even a "simple" game like pacman needs massive frameskipping to be playable.

    Getting what to my untrained eye, looks like the same or similar effects just using GLSL shaders runs great.

    I don't know if this is do to BGFX being new an unoptimized or something I'm doing wrong.



    ReplyDelete
    Replies
    1. Thanks for the feedback, much appreciated. Specs of my iMac are in the very first post. Are you really experiencing frameskipping? I also thought about performance hits, but in the end, it was just the settings.

      In my case, it was just far too extreme shader settings that caused the playing experience to be bad. Later on I will upload my hlsl configuration file so that you can try without tweaking around.

      Delete
  2. I tried changing some of the settings and I didn't see much of an appreciable difference. It could be my 2011 iMac (with downgraded GPU) just isn't up to snuff at this point with BGFX.

    I read in the other thread that you used the Metal backend, do you see a difference if you you the OpenGL backend? Unfortunately I can test Metal on this model.

    ReplyDelete
    Replies
    1. Sorry to hear that. You are right that GLSL produces very similar results. In my configuration, there is no difference between the Metal and the OpenGL backend under BGFX. So it is probably easier for you to stay with GLSL.

      Delete
    2. And my modified hlsl.json file is now ready for download in the second posing.

      Delete
    3. estefan, if you enable bgfx_debug can you tell me the version of OpenGL and GLSL it is using on your machine (should display that info on screen).

      Delete
    4. Headrush69 - your issues inspire me; will do further testing on different Mac machines, will also post my debug data, will keep you posted!

      Delete
  3. I did some testing of the various video drivers and options.
    I used Elevator Action for the test and ran unthrottled to see differences in average speed. (My iMac has a downgraded 6770M so results are just for evaluating differences between options)

    Video Driver - Avg Speed

    BGFX (using CRT-geom) - 46%
    software - 95%
    GLSL (glsl bilinear filtering + CRT-geom shader) - 231%
    GLSL (no filtering + CRT-geom shader) - 256%
    accel - 415%
    OpenGL (bilinear filter) - 648%
    OpenGL (no filter) - 948%


    ReplyDelete
    Replies
    1. I did some preliminary testing on a Mac mini (Mid 2011) running an AMD Radeon HD 630M under Yosemite. Even CRT-Geom-Halation under GLSL is too much for this machine to handle. So it seems that the new shaders are really for new Mac machines. I will try to collect more conclusive benchmark results in a dedicated post.

      Delete
    2. I think you meant a Radeon HD 6630M.

      I know these mobile GPU options in Apple computers aren't the greatest, but I find it still remarkable how poor the BGFX performance is. I can play a 2560x1600 3D first person game no problem but a simple filter with BGFX grinds performance to alarming levels. I wonder if there's a specific API method or OpenGL extension being used by BGFX that these mobile GPUs don't handle in hardware.

      I have a MacPro coming that will have a desktop level GPU soon, It'll be interesting to see the performance with it.

      Delete
    3. Headrush69, last question for today: How do you configure QMC2 in order to run the performance tests? I deactivated Throttle in the individual config of Elevator Action, but it still runs at 100% only. Is there anything else to change so that the game runs at full speed? Thanks indeed!

      Delete
    4. In the performance section, throttle off, seconds to run set to something, and make sure you have no video sync options set in the video section.

      That should be enough, unless you have some other defaults set that are affecting it.

      Delete
    5. Many thanks, now working. On top of your recommendations, since I run QMC2 and MAME internal MEWUI in parallel, I had to change settings in MEWUI as well. First results are very interesting, will hopefully post them soon. Another learning: Running QMC2 and MEWUI in parallel is no good idea.

      Delete
  4. This comment has been removed by the author.

    ReplyDelete

Any comments are welcome!