feat: add GPU acceleration JVM parameters support#140
Merged
HsiangNianian merged 3 commits intomainfrom Apr 1, 2026
Merged
Conversation
- Add Prism rendering pipeline parameters when enable_gpu_acceleration is enabled - Windows: -Dprism.order=d3d,es2,sw (Direct3D priority) - Linux/macOS: -Dprism.order=es2,sw (OpenGL ES priority) - Add -Dprism.forcegpu=true to force hardware acceleration
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR adds optional JavaFX Prism GPU acceleration JVM arguments to the Tauri game startup flow, enabling platform-specific hardware-accelerated rendering when the configuration flag is set. Sequence diagram for game start with optional GPU-accelerated JVM parameterssequenceDiagram
actor User
participant TauriApp
participant Config
participant JVM
User->>TauriApp: click Play
TauriApp->>Config: read enable_gpu_acceleration
Config-->>TauriApp: enable_gpu_acceleration (bool)
TauriApp->>TauriApp: build JVM args
TauriApp->>TauriApp: add java.library.path
alt enable_gpu_acceleration == true
TauriApp->>TauriApp: detect target_os
alt target_os == windows
TauriApp->>TauriApp: args += -Dprism.order=d3d,es2,sw
else target_os == linux or macos
TauriApp->>TauriApp: args += -Dprism.order=es2,sw
end
TauriApp->>TauriApp: args += -Dprism.forcegpu=true
else enable_gpu_acceleration == false
TauriApp->>TauriApp: no Prism GPU args added
end
TauriApp->>JVM: start with args
JVM-->>TauriApp: JavaFX game running (Prism pipeline configured)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
Workspace change through: 551aab61 changesets found Planned changes to release
|
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- Consider only appending
-Dprism.order=...and-Dprism.forcegpu=truewhen they are not already present inargs, so user- or config-specified JVM options aren’t silently overridden or duplicated. - Instead of using a bare
elsefor non-Windows platforms, make the platform conditions explicit (e.g.,cfg!(any(target_os = "linux", target_os = "macos"))) to avoid unintentionally applying the Linux/macOS settings to other targets in the future.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider only appending `-Dprism.order=...` and `-Dprism.forcegpu=true` when they are not already present in `args`, so user- or config-specified JVM options aren’t silently overridden or duplicated.
- Instead of using a bare `else` for non-Windows platforms, make the platform conditions explicit (e.g., `cfg!(any(target_os = "linux", target_os = "macos"))`) to avoid unintentionally applying the Linux/macOS settings to other targets in the future.
## Individual Comments
### Comment 1
<location path="src-tauri/src/main.rs" line_range="665-674" />
<code_context>
+ // Add GPU acceleration parameters if enabled
+ // JavaFX Prism rendering pipeline settings for hardware acceleration
+ if config.enable_gpu_acceleration {
+ // Platform-specific rendering order:
+ // - Windows: d3d (Direct3D) > es2 (OpenGL ES 2) > sw (software)
+ // - Linux/macOS: es2 > sw (no Direct3D available)
+ if cfg!(target_os = "windows") {
+ args.push("-Dprism.order=d3d,es2,sw".to_string());
+ } else {
+ args.push("-Dprism.order=es2,sw".to_string());
+ }
+ // Force GPU usage instead of software fallback
+ args.push("-Dprism.forcegpu=true".to_string());
+ }
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider not unconditionally forcing GPU usage to avoid crashes on problematic or missing GPU drivers.
`-Dprism.forcegpu=true` can cause startup failures on systems with buggy or unsupported GPU drivers (e.g., some Intel or virtualized setups). Since `enable_gpu_acceleration` already controls the pipeline order, consider either making `forcegpu` a separate config flag or only setting `prism.order` and letting JavaFX fall back to software if hardware acceleration fails.
Suggested implementation:
```rust
// Add GPU acceleration parameters if enabled
// JavaFX Prism rendering pipeline settings for hardware acceleration.
// We configure the preferred pipeline order but do not force GPU usage,
// so JavaFX can fall back to software rendering on problematic drivers.
if config.enable_gpu_acceleration {
// Platform-specific rendering order:
// - Windows: d3d (Direct3D) > es2 (OpenGL ES 2) > sw (software)
// - Linux/macOS: es2 > sw (no Direct3D available)
if cfg!(target_os = "windows") {
args.push("-Dprism.order=d3d,es2,sw".to_string());
} else {
args.push("-Dprism.order=es2,sw".to_string());
}
```
If you later want an explicit `force_gpu` option, you can:
1. Add a boolean field like `force_gpu: bool` to your config struct.
2. Extend this block with:
```rust
if config.force_gpu {
args.push("-Dprism.forcegpu=true".to_string());
}
```
This keeps the current safe default while allowing advanced users to opt-in to forcing GPU usage.
</issue_to_address>
### Comment 2
<location path="src-tauri/src/main.rs" line_range="670-672" />
<code_context>
+ // - Windows: d3d (Direct3D) > es2 (OpenGL ES 2) > sw (software)
+ // - Linux/macOS: es2 > sw (no Direct3D available)
+ if cfg!(target_os = "windows") {
+ args.push("-Dprism.order=d3d,es2,sw".to_string());
+ } else {
+ args.push("-Dprism.order=es2,sw".to_string());
+ }
+ // Force GPU usage instead of software fallback
</code_context>
<issue_to_address>
**suggestion:** Allow overriding the prism pipeline order when users need custom rendering preferences or debugging.
Hard-coding `prism.order` removes flexibility for users who need to force software rendering (e.g., for driver workarounds) or test different pipelines. Please only set this default when no `-Dprism.order` is already provided in `config.jvm_args` / equivalent, or expose a config option that can override this order while still defaulting to GPU acceleration.
Suggested implementation:
```rust
// Add GPU acceleration parameters if enabled
// JavaFX Prism rendering pipeline settings for hardware acceleration
if config.enable_gpu_acceleration {
// Only set a default prism.order if the user hasn't already provided one
// via JVM args (e.g., in config.jvm_args). This allows overriding
// the pipeline order for debugging or driver workarounds.
let has_prism_order = args.iter().any(|a| a.starts_with("-Dprism.order="));
if !has_prism_order {
// Platform-specific rendering order:
// - Windows: d3d (Direct3D) > es2 (OpenGL ES 2) > sw (software)
// - Linux/macOS: es2 > sw (no Direct3D available)
if cfg!(target_os = "windows") {
args.push("-Dprism.order=d3d,es2,sw".to_string());
} else {
args.push("-Dprism.order=es2,sw".to_string());
}
}
// Force GPU usage instead of software fallback
args.push("-Dprism.forcegpu=true".to_string());
}
```
If `config.jvm_args` (or similar) is not yet merged into `args` before this block, you should:
1. Ensure any user-provided JVM args (including `-Dprism.order=...`) are appended to `args` *before* this GPU-acceleration section.
2. Document for users (e.g., in config docs) that they can override the default Prism pipeline by adding a `-Dprism.order=...` entry to their JVM args.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
HsiangNianian
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Add optional GPU-accelerated JavaFX rendering configuration when launching the game JVM.
New Features: