Skip to content

HereticWay/DXVKStateCacheBank

Repository files navigation

Read this in other languages: English, Hungarian.

About

This project aims to solve the problem of storing and automatically merging dxvk pipeline state cache files to a single "incremental" cache file per application that can be distributed later across multiple devices. One example of manually doing this work can be read here.

The idea is that users can register to the api and contribute state cache files that their application generated and my backend would store it and automatically merge it using the dxvk-cache-tool to the latest "incremental" cache of the application, no manual work needed. The latest incremental cache can be downloaded by anybody, user account is not required.

Note: that there's no UI for this program, it only exposes REST endpoints

What's completed

  • Use of DTOs
  • Validating DTOs
  • Store/Update/Delete Games
  • Store/Update/Delete Users
  • Store/Delete Cache files
  • Automatically merge together cache files game by game (incremental caches)
  • Streaming binary files from/to database
  • Drop invalid cache files
  • Drop cache files that don't introduce new entries
  • Integration and Unit tests
  • Running asynchronously
  • Some basic logging
  • Use of PostgreSQL backend
  • Swagger documentation
  • Flyway migrations
    • One .sql file migration (V1)
    • And one Java migration (V2)
  • Dockerization

What's not completed

Because of time constraints I couldn't finish every planned functions:

  • HTTP Basic Authentication. Currently, users have to specify a password, but it will be stored in plain text and never gets used later. The program doesn't authenticate any endpoints.
  • Automatic Newman black-box tests
  • Validate User profile pictures
  • Validate cache files properly in byte level. Currently, the program pipes all cache files through dxvk-cache-tool for validation. If it returns an error code, then the cache file is sure not valid. This is not the best practice in my opinion, but was a fast solution.

Endpoints

See the endpoints at the Wiki page or at the Swagger documentation while the program is running.

ER Diagram of database tables

Cannot load the picture

Running the program

Currently the program can only run under Docker or Linux. Windows is not supported, because the dxvk-cache-tool does not have a native Windows build.

Running with Docker

Requirements:

  • docker
  • docker compose plugin (usually bundled together with docker installation)
# Navigate to the project's directory and run the following command:
$ docker compose up

Running under Linux

Requirements:

  • docker
  • docker compose plugin (usually bundled together with docker installation)
  • dxvk-cache-tool with run permissions:
    • in any PATH directory (recommended)
    • or any custom directory (needs more configuration, more about that later)
  • a PostgreSQL database server (can be started with docker, see: Starting the PostgreSQL server)
  • choosing an active run profile.

Starting the PostgreSQL server

The database will be available from the outside at:
url: //localhost:5430/dxvk-cache-bank-db
user: postgres
password: pass

$ docker run \
    -it \
    --rm \
    -p "5430:5432" \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=pass \
    -e POSTGRES_DB=dxvk-cache-bank-db \
    postgres:14.3-alpine3.16

Run the program using Maven

# If dxvk-cache-tool is located in a PATH directory:
$ ./mvnw spring-boot:run -Dspring-boot.run.profiles=dev

# If dxvk-cache-tool is located elsewhere, then you must specify the location as a PATH directory for the appliaction and run it like this:
$ env PATH=$PATH:/path/to/dxvk-cache-tool-directory ./mvnw spring-boot:run -Dspring-boot.run.profiles=dev

Run the program using Intellij IDEA

  • Start the PostgreSQL server (see: Starting the PostgreSQL server)
  • Load the project as a Maven project
  • Set the "Run/Debug Configurations" like below:
    Cannot load the picture
  • If dxvk-cache-tool is not in a PATH directory, then in the "Run/DebugConfigurations"->"Environment Variables" field you must set the path of dxvk-cache-tool, for example: "PATH=$PATH:/path/to/dxvk-cache-tool-directory"
  • Now you can run the program as usual with IDEA.

Running tests with Intellij IDEA

  • Start the PostgreSQL server (see: Starting the PostgreSQL server)
  • Load the project as a Maven project
  • Add a new test run configuration: **"Run/DebugConfigurations"->"Add new configuration"->"JUnit"
  • Set it up like this:
    Setting profile is not required here!
    Cannot load the picture
  • If dxvk-cache-tool is not in a PATH directory, then in the "Environment Variables" field you must set it to the path of dxvk-cache-tool's directory, for example: "PATH=$PATH:/path/to/dxvk-cache-tool-directory"
  • Sometimes the test/resources directory doesn't get marked as a test resources folder. To correct that, you must mark it as test resources root like this:
    "right click on test/resources"->"Mark directory as"->"Resources root"
    Cannot load the picture Cannot load the picture
  • Now you can run the tests as usual with IDEA

Run under Windows

Running under Windows is only supported through Docker/WSL.
See: Running the program, Running with Docker

Black-box testing with Postman

  • Unfortunately I had no time left to make Newman tests so the project can only be tested manually from outside (black-box testing)
  • Start the program in Docker (See: Running with Docker)
  • Use the following Postman Workspace for testing
  • You can find example profile pictures and cache files in the project's resources/sample directory
  • One example of testing, to better understand how the program works:
    1. Post a Game
    2. Post a User
    3. Post r5apex-barely-populated.dxvk-cache CacheFile as the created User for the created Game - It should store the cache file and return 200OK. Incremental cache should be created too.
    4. Post r5apex-highly-populated.dxvk-cache CacheFile as the created User for the created Game - It should store the cache file and return 200OK. Incremental cache should be the merge of the two caches.
    5. Post r5apex-barely-populated.dxvk-cache CacheFile again as the created User for the created Game - It should not store the cache file and return 422 UNPROCESSABLE_ENTITY because the uploaded cache does not introduce any new cache entries. Incremental cache should not change.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages