Skip to content

Palette problems in MAME #3700

Description

@vanfanel

Describe the bug
MAME shows palette problems when used in conjunction with BGFX and shaders.
This is a well known problem, caused by the loss of precision on the shaders, documented as an issue on the MAME issues here:
mamedev/mame#14022 (comment)

To Reproduce
Steps to reproduce the behavior:

  1. Configure MAME to use the BGFX Video Mode
  2. Start cninja with mame cninja
  3. Play and observe the game.

Expected behavior
The game should not have palette problems.

Screenshots

MAME running Caveman Ninja with BGFX shaders, showing palette problems:

Image Image

MAME running Caveman Ninja without BGFX shaders, showing correct colors:

Image Image

Additional context
The problem comes from how BGFX handles precision. MESA does the right thing.
From the MESA developers:

If the application depends on high precision it should set high precision. Saying "but it works on other implementations and so should work on mesa" completely misses the point.
Optimisations are done on shaders based on the information provided by the shader, if the shader says its safe to lose precision then compilers will take advantage of that fact. Just because Mesa results in less precision for this shader and other drivers don't doesn't mean there aren't shaders where the opposite happens i.e. mesa retains precision and other drivers don't. Each compiler has different optimisations and different ordering of optimisations. Trying to match the behaviour of other drivers optimisations is a fool's errand.
And just in case I'm not completely clear here. Let's say we were able to force mesa to behave the same as other drivers here, there is nothing stopping all those other drivers to change their behaviour as their optimisations are updated in future. Which means now mesa is again out of sync and Mame now fails on those drivers also.

Here's the thread on the MESA repository where this was discussed:
https://gitlab.freedesktop.org/mesa/mesa/-/work_items/13555#note_3057209

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions