diff options
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | main.py | 15 | ||||
| -rwxr-xr-x | src/index.tsx | 45 |
3 files changed, 44 insertions, 19 deletions
@@ -18,6 +18,7 @@ This plugin automates the installation of lsfg-vk, a compatibility layer that al - Set FPS multiplier (2-4) - Adjust flow scale (0.25-1.0) - Toggle HDR mode + - Toggle immediate mode (disable vsync) 6. **Apply launch commands** to the game you want to use frame generation with: - **Option 1 (Recommended)**: `~/lsfg && %COMMAND%` - Uses your plugin configuration - **Option 2**: Manual environment variables like `ENABLE_LSFG=1 LSFG_MULTIPLIER=2 %COMMAND%` @@ -28,7 +29,7 @@ The plugin: - Extracts the lsfg-vk library to `~/.local/lib/` - Installs the Vulkan layer configuration to `~/.local/share/vulkan/implicit_layer.d/` - Creates an executable `lsfg` script in the home directory with configurable settings -- Provides a user-friendly interface to configure LSFG settings (enable/disable, multiplier, flow scale, HDR) +- Provides a user-friendly interface to configure LSFG settings (enable/disable, multiplier, flow scale, HDR, immediate mode) - Automatically updates the `lsfg` script when settings are changed - Provides easy uninstallation by removing these files when no longer needed @@ -63,6 +63,7 @@ export ENABLE_LSFG=1 export LSFG_MULTIPLIER=2 export LSFG_FLOW_SCALE=1.0 # export LSFG_HDR=1 +# export MESA_VK_WSI_PRESENT_MODE=immediate # - disable vsync """ with open(lsfg_script_path, 'w') as script_file: @@ -216,7 +217,8 @@ export LSFG_FLOW_SCALE=1.0 "enable_lsfg": False, "multiplier": 2, "flow_scale": 1.0, - "hdr": False + "hdr": False, + "immediate_mode": False } lines = content.split('\n') @@ -236,6 +238,8 @@ export LSFG_FLOW_SCALE=1.0 config["flow_scale"] = 1.0 elif line.startswith('export LSFG_HDR='): config["hdr"] = line.split('=')[1] == '1' + elif line.startswith('export MESA_VK_WSI_PRESENT_MODE='): + config["immediate_mode"] = line.split('=')[1].strip() == 'immediate' return { "success": True, @@ -249,7 +253,7 @@ export LSFG_FLOW_SCALE=1.0 "error": str(e) } - async def update_lsfg_config(self, enable_lsfg: bool, multiplier: int, flow_scale: float, hdr: bool) -> dict: + async def update_lsfg_config(self, enable_lsfg: bool, multiplier: int, flow_scale: float, hdr: bool, immediate_mode: bool) -> dict: """Update lsfg script configuration""" try: user_home = os.path.expanduser("~") @@ -271,6 +275,11 @@ export LSFG_FLOW_SCALE=1.0 else: script_content += "# export LSFG_HDR=1\n" + if immediate_mode: + script_content += "export MESA_VK_WSI_PRESENT_MODE=immediate # - disable vsync\n" + else: + script_content += "# export MESA_VK_WSI_PRESENT_MODE=immediate # - disable vsync\n" + # Write the updated script with open(lsfg_script_path, 'w') as f: f.write(script_content) @@ -278,7 +287,7 @@ export LSFG_FLOW_SCALE=1.0 # Make sure it's executable os.chmod(lsfg_script_path, 0o755) - decky.logger.info(f"Updated lsfg script configuration: enable={enable_lsfg}, multiplier={multiplier}, flow_scale={flow_scale}, hdr={hdr}") + decky.logger.info(f"Updated lsfg script configuration: enable={enable_lsfg}, multiplier={multiplier}, flow_scale={flow_scale}, hdr={hdr}, immediate_mode={immediate_mode}") return { "success": True, diff --git a/src/index.tsx b/src/index.tsx index bddedf9..0c706d8 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -28,10 +28,10 @@ const checkLsfgVkInstalled = callable<[], { installed: boolean; lib_exists: bool const checkLosslessScalingDll = callable<[], { detected: boolean; path?: string; source?: string; message?: string; error?: string }>("check_lossless_scaling_dll"); // Function to get lsfg configuration -const getLsfgConfig = callable<[], { success: boolean; config?: { enable_lsfg: boolean; multiplier: number; flow_scale: number; hdr: boolean }; error?: string }>("get_lsfg_config"); +const getLsfgConfig = callable<[], { success: boolean; config?: { enable_lsfg: boolean; multiplier: number; flow_scale: number; hdr: boolean; immediate_mode: boolean }; error?: string }>("get_lsfg_config"); // Function to update lsfg configuration -const updateLsfgConfig = callable<[boolean, number, number, boolean], { success: boolean; message?: string; error?: string }>("update_lsfg_config"); +const updateLsfgConfig = callable<[boolean, number, number, boolean, boolean], { success: boolean; message?: string; error?: string }>("update_lsfg_config"); function Content() { const [isInstalled, setIsInstalled] = useState<boolean>(false); @@ -46,6 +46,7 @@ function Content() { const [multiplier, setMultiplier] = useState<number>(2); const [flowScale, setFlowScale] = useState<number>(1.0); const [hdr, setHdr] = useState<boolean>(false); + const [immediateMode, setImmediateMode] = useState<boolean>(false); // Check installation status on component mount useEffect(() => { @@ -85,6 +86,7 @@ function Content() { setMultiplier(result.config.multiplier); setFlowScale(result.config.flow_scale); setHdr(result.config.hdr); + setImmediateMode(result.config.immediate_mode); } } catch (error) { console.error("Error loading lsfg config:", error); @@ -116,6 +118,7 @@ function Content() { setMultiplier(configResult.config.multiplier); setFlowScale(configResult.config.flow_scale); setHdr(configResult.config.hdr); + setImmediateMode(configResult.config.immediate_mode); } } catch (error) { console.error("Error reloading config after install:", error); @@ -169,20 +172,16 @@ function Content() { } }; - const updateConfig = async (newEnableLsfg: boolean, newMultiplier: number, newFlowScale: number, newHdr: boolean) => { + const updateConfig = async (newEnableLsfg: boolean, newMultiplier: number, newFlowScale: number, newHdr: boolean, newImmediateMode: boolean) => { try { - const result = await updateLsfgConfig(newEnableLsfg, newMultiplier, newFlowScale, newHdr); - if (result.success) { - toaster.toast({ - title: "Configuration Updated", - body: "lsfg script configuration has been updated" - }); - } else { + const result = await updateLsfgConfig(newEnableLsfg, newMultiplier, newFlowScale, newHdr, newImmediateMode); + if (!result.success) { toaster.toast({ title: "Update Failed", body: result.error || "Failed to update configuration" }); } + // Only show error notifications, not success notifications to avoid spam } catch (error) { toaster.toast({ title: "Update Failed", @@ -193,22 +192,27 @@ function Content() { const handleEnableLsfgChange = async (value: boolean) => { setEnableLsfg(value); - await updateConfig(value, multiplier, flowScale, hdr); + await updateConfig(value, multiplier, flowScale, hdr, immediateMode); }; const handleMultiplierChange = async (value: number) => { setMultiplier(value); - await updateConfig(enableLsfg, value, flowScale, hdr); + await updateConfig(enableLsfg, value, flowScale, hdr, immediateMode); }; const handleFlowScaleChange = async (value: number) => { setFlowScale(value); - await updateConfig(enableLsfg, multiplier, value, hdr); + await updateConfig(enableLsfg, multiplier, value, hdr, immediateMode); }; const handleHdrChange = async (value: boolean) => { setHdr(value); - await updateConfig(enableLsfg, multiplier, flowScale, value); + await updateConfig(enableLsfg, multiplier, flowScale, value, immediateMode); + }; + + const handleImmediateModeChange = async (value: boolean) => { + setImmediateMode(value); + await updateConfig(enableLsfg, multiplier, flowScale, hdr, value); }; return ( @@ -303,7 +307,7 @@ function Content() { <PanelSectionRow> <SliderField - label="Flow Scale" + label={`Flow Scale ${Math.round(flowScale * 100)}%`} description="Lowers the flow scale for performance (0.25-1.0)" value={flowScale} min={0.25} @@ -321,6 +325,15 @@ function Content() { onChange={handleHdrChange} /> </PanelSectionRow> + + <PanelSectionRow> + <ToggleField + label="Immediate Mode" + description="Disable vsync for reduced input lag" + checked={immediateMode} + onChange={handleImmediateModeChange} + /> + </PanelSectionRow> </> )} @@ -371,6 +384,8 @@ function Content() { • LSFG_FLOW_SCALE=0.25-1.0 - Flow scale (for performance) <br /> • LSFG_HDR=1 - HDR mode (only if using HDR) + <br /> + • MESA_VK_WSI_PRESENT_MODE=immediate - Disable vsync </div> </div> </PanelSectionRow> |
