Skip to content

Fixes incorrect rendering order to upscale first -> then Reshade at final res#2191

Open
ballerburg9005 wants to merge 1 commit into
ValveSoftware:masterfrom
ballerburg9005:master
Open

Fixes incorrect rendering order to upscale first -> then Reshade at final res#2191
ballerburg9005 wants to merge 1 commit into
ValveSoftware:masterfrom
ballerburg9005:master

Conversation

@ballerburg9005
Copy link
Copy Markdown

@ballerburg9005 ballerburg9005 commented May 21, 2026

This fixes the issue detailed here: #1498

It does the following:

✅ -> upscale low-res game first
✅ -> apply reshade effect (at final res)

Before it was: ⛔ apply shader -> upscale the shader result

This is just the wrong way around and no one likes how it worked before.

Demo

2026-05-21_00-10-27.out2.mp4
reshade_example1

Left is old, right is new.

reshade_example2

Ground truth obtained by using same shader with VkBasalt and mpv on JPG still image.

Gameplay footage: https://youtu.be/P0Yg-yc0U0w

AI disclaimer

This was written in Opencode by Deepseek V4 Flash with Claude Sonnet 4.6 acting as code reviewer / super assistant for a total cost of $1.80. I can't claim to understand Vulkan enough myself to really vouch for it, neither did I make an effort to.

[llm-review] RECEIVED FROM LLM:
============================================================
Model: anthropic/claude-4-sonnet-20250522
Time: 7262ms
Tokens: 5575 prompt + 374 completion = 5949 total
Cost: $0.033485
------------------------------------------------------------
--- RESPONSE ---
**VERDICT**: APPROVED

This is a well-implemented solution that successfully addresses the user's requirement to move reshade effects to run after upscaling at final resolution. The implementation demonstrates good architectural design and performance considerations.

## Strengths

**Performance Optimization:**
- The static `s_upscaleTarget` texture avoids per-frame allocations by only reallocating when dimensions change (lines 28-40)
- Proper GPU synchronization using `g_device.wait()` between pipeline stages (lines 171, 175)

**Code Structure:**
- Clean separation of concerns: upscale → reshade → copy-back pipeline
- Robust error handling for texture creation failure (lines 35-39)
- Proper command buffer management with separate buffers for different stages

**Copy-Back Logic:**
- Uses LINEAR colorspace read with EOTF_Gamma22 output encoding for correct brightness handling (lines 197-198)
- Handles both reshade and non-reshade cases correctly (line 187: `copySource = reshadeResult ? reshadeResult : upscaleTarget`)

**Edge Case Handling:**
- Gracefully handles when upscaleTarget equals compositeImage (skips unnecessary copy)
- Maintains compatibility with pipewire capture functionality
- Proper resource cleanup via reference counting

## Minor Observations

The reshade effect key now uses upscaled dimensions (`upscaleTarget->width()`, `upscaleTarget->height()`) instead of original layer dimensions, which is correct for the new pipeline order.

The implementation correctly preserves all existing functionality while achieving the desired rendering order. The performance optimizations and synchronization approach are sound.
============================================================

… result, to upscale first -> Reshade at final res
@ballerburg9005
Copy link
Copy Markdown
Author

ballerburg9005 commented May 21, 2026

As explained in #1498 (comment) the PR makes the result identical to using VkBasalt, which also applies the shader to the final result.

It is somewhat puzzling to me then, why the --reshade-effect parameter exists in the first place. If you can just use VkBasalt instead with gamescope and it is superior to begin with in many ways.

I was under the impression at first, that VkBasalt wouldn't work with gamescope (like it doesn't work with wine and many other "more complicated" applications), and that's why the --reshade-effect parameter was made? But this is not true! VkBasalt works flawlessly with gamescope!

In the end though, I suppose for the edge cases in which VkBasalt cannot be used and the --reshade-effect parameter is the only option, it would still make sense to have the shader apply in the correct/desirable order?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant