mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-01-06 15:02:25 +00:00
switching to an implicit layer
This commit is contained in:
parent
48c773574a
commit
2fbdacc9fa
7 changed files with 11 additions and 77 deletions
|
|
@ -60,4 +60,4 @@ target_compile_options(lsfg-vk PRIVATE
|
|||
install(FILES "${CMAKE_BINARY_DIR}/liblsfg-vk.so"
|
||||
DESTINATION lib)
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/VkLayer_LS_frame_generation.json"
|
||||
DESTINATION share/vulkan/explicit_layer.d)
|
||||
DESTINATION share/vulkan/implicit_layer.d)
|
||||
|
|
|
|||
42
README.md
42
README.md
|
|
@ -1,45 +1,7 @@
|
|||
# lsfg-vk
|
||||
This project brings [Lossless Scaling's Frame Generation](https://store.steampowered.com/app/993090/Lossless_Scaling/) to Linux!
|
||||
>[!NOTE]
|
||||
> This is a work-in-progress. While frame generation has worked in a few games, there's still a long way to go. Please review the wiki for support (the wiki is not written yet)
|
||||
|
||||
## Building, Installing and Running
|
||||
|
||||
>[!CAUTION]
|
||||
> The build instructions have recently changed. Please review them.
|
||||
> This is a work-in-progress. While frame generation has worked in quite a few games, there's still a long way to go.
|
||||
|
||||
In order to compile LSFG, make sure you have the following components installed on your system:
|
||||
- Traditional build tools (+ sed, git)
|
||||
- Clang compiler (this project does NOT compile easily with GCC)
|
||||
- Vulkan header files
|
||||
- CMake build system
|
||||
- Meson build system (for DXVK)
|
||||
- Ninja build system (backend for CMake)
|
||||
|
||||
Compiling lsfg-vk is relatively straight forward, as everything is neatly integrated into CMake:
|
||||
```bash
|
||||
$ cmake -B build -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=~/.local \
|
||||
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
|
||||
-DCMAKE_CXX_CLANG_TIDY=""
|
||||
$ cmake --build build
|
||||
$ cmake --install build
|
||||
```
|
||||
This will install lsfg-vk to ~/.local/lib and ~/.local/share/vulkan.
|
||||
|
||||
Next, you'll need to download Lossless Scaling from Steam. Switch to the `legacy_2.13` branch or download the corresponding depot.
|
||||
Copy or note down the path of "Lossless.dll" from the game files.
|
||||
|
||||
Finally, let's actually start a program with frame generation enabled. I'm going to be using `vkcube` for this example:
|
||||
```bash
|
||||
VK_INSTANCE_LAYERS="VK_LAYER_LS_frame_generation" LSFG_DLL_PATH="/home/pancake/games/Lossless Scaling/Lossless.dll" LSFG_MULTIPLIER=4 vkcube
|
||||
```
|
||||
Make sure you adjust the paths. Let's examine each one:
|
||||
- `LVK_INSTANCE_LAYERS`: Specify `VK_LAYER_LS_frame_generation` here. This forces any Vulkan app to load the lsfg-vk layer.
|
||||
- `LSFG_DLL_PATH`: Here you specify the Lossless.dll you downloaded from Steam. lsfg-vk will extract and translate the shaders from here.
|
||||
- `LSFG_MULTIPLIER`: This is the multiplier you should be familiar with. Specify `2` for doubling the framerate, etc.
|
||||
- `VK_LAYER_PATH`: If you did not install to `~/.local` or `/usr`, you have to specify the `explicit_layer.d` folder here.
|
||||
|
||||
>[!WARNING]
|
||||
> Unlike on Windows, LSFG_MULTIPLIER is heavily limited here (at the moment!). If your hardware can create 8 swapchain images, then setting LSFG_MULTIPLIER to 4 occupies 4 of those, leaving only 4 to the game. If the game requested 5 or more, it will crash.
|
||||
Please see the [Wiki](https://github.com/PancakeTAS/lsfg-vk/wiki) for install instructions
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@
|
|||
"functions": {
|
||||
"vkGetInstanceProcAddr": "layer_vkGetInstanceProcAddr",
|
||||
"vkGetDeviceProcAddr": "layer_vkGetDeviceProcAddr"
|
||||
},
|
||||
"enable_environment": {
|
||||
"ENABLE_LSFG": "1"
|
||||
},
|
||||
"disable_environment": {
|
||||
"DISABLE_LSFG": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,16 +58,6 @@ namespace Utils {
|
|||
VkPipelineStageFlags pre, VkPipelineStageFlags post,
|
||||
bool makeSrcPresentable, bool makeDstPresentable);
|
||||
|
||||
///
|
||||
/// Store the current layer environment.
|
||||
///
|
||||
void storeLayerEnv();
|
||||
|
||||
///
|
||||
/// Restore the layer environment to the previously stored value.
|
||||
///
|
||||
void restoreLayerEnv();
|
||||
|
||||
}
|
||||
|
||||
#endif // UTILS_HPP
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@
|
|||
#include "utils/log.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <lsfg.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
LsContext::LsContext(const Hooks::DeviceInfo& info, VkSwapchainKHR swapchain,
|
||||
VkExtent2D extent, const std::vector<VkImage>& swapchainImages)
|
||||
|
|
@ -51,9 +50,7 @@ LsContext::LsContext(const Hooks::DeviceInfo& info, VkSwapchainKHR swapchain,
|
|||
setenv("LSFG_DEVICE_UUID", std::to_string(deviceUUID).c_str(), 1);
|
||||
|
||||
Log::debug("context", "(entering LSFG initialization)");
|
||||
Utils::storeLayerEnv();
|
||||
LSFG::initialize();
|
||||
Utils::restoreLayerEnv();
|
||||
Log::debug("context", "(exiting LSFG initialization)");
|
||||
|
||||
Log::debug("context", "(entering LSFG context creation)");
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ namespace {
|
|||
const VkAllocationCallbacks* pAllocator,
|
||||
VkInstance* pInstance) {
|
||||
Log::debug("layer", "Initializing lsfg-vk instance layer...");
|
||||
setenv("DISABLE_LSFG", "1", 1); // mustn't load further
|
||||
|
||||
// find layer creation info
|
||||
auto* layerDesc = const_cast<VkLayerInstanceCreateInfo*>(
|
||||
|
|
|
|||
|
|
@ -161,25 +161,3 @@ void Utils::copyImage(VkCommandBuffer buf,
|
|||
1, &presentBarrier);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::optional<std::string> layersEnvironment;
|
||||
}
|
||||
|
||||
// TODO: more environment variables? what about explicit disable?
|
||||
|
||||
void Utils::storeLayerEnv() {
|
||||
const char* env = std::getenv("VK_INSTANCE_LAYERS");
|
||||
if (env)
|
||||
layersEnvironment = env;
|
||||
else
|
||||
layersEnvironment.reset();
|
||||
unsetenv("VK_INSTANCE_LAYERS");
|
||||
}
|
||||
|
||||
void Utils::restoreLayerEnv() {
|
||||
if (layersEnvironment.has_value())
|
||||
setenv("VK_INSTANCE_LAYERS", layersEnvironment->c_str(), 1);
|
||||
else
|
||||
unsetenv("VK_INSTANCE_LAYERS");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue