protonscr

Make DXVK_STATE_CACHE_PATH directory if it does not exist

dxvkclosed
doitsujin/dxvk#907 · opened 2019-02-09 by TheTumultuousUnicornOfDarkness · updated 2019-03-03 · 6 comments · github
TTheTumultuousUnicornOfDarkness 2019-02-09 github

When I set DXVK_STATE_CACHE_PATH environment variable, the DXVK_STATE_CACHE_PATH directory is not created, so DXVK state cache is disabled.
After creating DXVK_STATE_CACHE_PATH directory manually, DXVK state cache works as expected.

DXVK should check if DXVK_STATE_CACHE_PATH directory exists and make it if it does not exist.

System information

  • DXVK version: 0.96
Ddoitsujin maintainer 2019-02-09 github

Is there a valid use case for setting the env var to a directory which doesn't exist?

I don't really like messing around with file system functions for no good reason, especially since the C++ standard library does not provide any such functions, and using Win32 functions correctly is hard. In other words, the current behaviour is intended.

TTheTumultuousUnicornOfDarkness 2019-02-09 github

Is there a valid use case for setting the env var to a directory which doesn't exist?

Yes, I want to put DXVK state cache in ~/.cache directory (like mesa_shader_cache does). I'm using that:

export DXVK_STATE_CACHE_PATH="$HOME/.cache/dxvk"

Generally, others software put things in cache directory without that I need to create a subdirectory manually.

I don't really like messing around with file system functions for no good reason, especially since the C++ standard library does not provide any such functions [...]. In other words, the current behaviour is intended.

I understand.
However, C++17 provides such functions, like std::filesystem::exists and std::filesystem::create_directory. What do you thing about using C++17?

Ddoitsujin maintainer 2019-02-09 github

Yes, I want to put DXVK state cache in ~/.cache directory

I guess that's convincing enough, will probably implement it then.

What do you thing about using C++17?

I'm already using C++17 language features, but using the standard library features is currently not an option since DXVK has to support a bunch of old compilers, unfortunately.

Edit: Also, <filesystem> appears to be broken in MinGW 6.0.

Mmisyltoad 2019-02-10 github

If you were to use Win32 funcs:

CreateDirectory[A/W] is usually good enough, but it functions like mkdir and not mkdir -p

You'd also have to try and make every directory (or check before making) along the way to that dir in order for it to work properly.

Shlwapi has some nice helper functions for this (and its what I see a few games use), but its another dependency and a bit of a hacky solution. Using std string find and going through may be a better solution.

Ddoitsujin maintainer 2019-02-11 github

The thing that bothers me about CreateDirectoryW is that we need to convert char sets again, which wouldn't be necessary if <filesystem> worked (honestly I can't wait for it to become usable), and that can potentially go wrong if not done correctly.

But yeah, that will have to do. mkdir -p behaviour shouldn't be necessary and might be too invasive anyway.

TTheTumultuousUnicornOfDarkness 2019-03-03 github

Thank you, it works as expected since v1.0. :ok_hand: