mame: use absolute path to bgfx data directory

Currently if you try to use the `bgfx` renderer, MAME outputs an error:

```
Unable to find the BGFX path bgfx, please install it or fix the bgfx_path setting to use the BGFX renderer.
Initializing video module bgfx failed, falling back to opengl
```

because it's looking for the `bgfx` directory inside the working
directory. To fix this, you have to explicitly set `bgfx_path` to
`/nix/store/whatever1234hash567890-mame-0.277/opt/mame/bgfx`.

This commit changes the default `bgfx_path` to be an absolute path to
the right place, similarly to what's already being done for `artpath`,
`ctrlrpath`, etc. However, unlike those options, `bgfx_path` can only
take a single directory - so this is technically a breaking change if
you actually _wanted_ MAME to use `./bgfx`.
This commit is contained in:
Rhys-T
2025-07-01 20:09:28 -04:00
parent 376a91ea05
commit 08e498ee47
2 changed files with 19 additions and 4 deletions
@@ -1,8 +1,8 @@
diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp
index 3defd33d0bb..33daacc4fc8 100644
index 834710c9eb0..6394ad8a7bc 100644
--- a/src/emu/emuopts.cpp
+++ b/src/emu/emuopts.cpp
@@ -39,16 +39,16 @@ const options_entry emu_options::s_option_entries[] =
@@ -42,16 +42,16 @@ const options_entry emu_options::s_option_entries[] =
{ nullptr, nullptr, core_options::option_type::HEADER, "CORE SEARCH PATH OPTIONS" },
{ OPTION_PLUGINDATAPATH, ".", core_options::option_type::PATH, "path to base folder for plugin data (read/write)" },
{ OPTION_MEDIAPATH ";rp;biospath;bp", "roms", core_options::option_type::MULTIPATH, "path to ROM sets and hard disk images" },
@@ -27,3 +27,16 @@ index 3defd33d0bb..33daacc4fc8 100644
{ OPTION_SWPATH, "software", core_options::option_type::MULTIPATH, "path to loose software" },
// output directory options
diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp
index 82fabfdc0ba..eefdaba7fbe 100644
--- a/src/osd/modules/lib/osdobj_common.cpp
+++ b/src/osd/modules/lib/osdobj_common.cpp
@@ -158,7 +158,7 @@ const options_entry osd_options::s_option_entries[] =
{ OSDOPTION_NETWORK_PROVIDER, OSDOPTVAL_AUTO, core_options::option_type::STRING, "Emulated networking provider: " },
{ nullptr, nullptr, core_options::option_type::HEADER, "BGFX POST-PROCESSING OPTIONS" },
- { OSDOPTION_BGFX_PATH, "bgfx", core_options::option_type::PATH, "path to BGFX-related files" },
+ { OSDOPTION_BGFX_PATH, "@mamePath@/bgfx", core_options::option_type::PATH, "path to BGFX-related files" },
{ OSDOPTION_BGFX_BACKEND, "auto", core_options::option_type::STRING, "BGFX backend to use (d3d9, d3d11, d3d12, metal, opengl, gles, vulkan)" },
{ OSDOPTION_BGFX_DEBUG, "0", core_options::option_type::BOOLEAN, "enable BGFX debugging statistics" },
{ OSDOPTION_BGFX_SCREEN_CHAINS, "", core_options::option_type::STRING, "comma-delimited list of screen chain JSON names, colon-delimited per-window" },
+4 -2
View File
@@ -123,8 +123,10 @@ stdenv.mkDerivation rec {
# it is not possible to use substituteAll
postPatch =
''
substituteInPlace src/emu/emuopts.cpp \
--subst-var-by mamePath "$out/opt/mame"
for file in src/emu/emuopts.cpp src/osd/modules/lib/osdobj_common.cpp; do
substituteInPlace "$file" \
--subst-var-by mamePath "$out/opt/mame"
done
''
# MAME's build system uses `sw_vers` to test whether it needs to link with
# the Metal framework or not. However: