Skip to content

Fix filter chain rendering#1343

Merged
Trouffman merged 6 commits into
DistroAV:masterfrom
Lordmau5:feat/fix-filter-chain
Aug 29, 2025
Merged

Fix filter chain rendering#1343
Trouffman merged 6 commits into
DistroAV:masterfrom
Lordmau5:feat/fix-filter-chain

Conversation

@Lordmau5

Copy link
Copy Markdown
Contributor

We now check if both the target (filter above our own, OR parent if we're in first place) and the actual filter parent are valid instead of just the target.

Additionally, we get the source width and height for the filter, which if it's in first place will give the original source width and height (otherwise it would've picked the parent's and that will be with all filters afterwards applied, such as Crop or Aspect Ratio)

Also, I moved the known width and height check / update before the texrender logic.

Inside the render call we check if the target is the parent and if so, we render the filter via. obs_source_skip_video_filter, otherwise we just use obs_source_video_render on the target.

We now check if both the target (filter above our own, OR parent if we're in first place) and the actual filter parent are valid instead of just the target.

Additionally, we get the source width and height for the filter, which if it's in first place will give the original source width and height (otherwise it would've picked the parent's and that will be with all filters *afterwards* applied, such as Crop or Aspect Ratio)

Also, I moved the known width and height check / update before the texrender logic.

Inside the render call we check if the target is the parent and if so, we render the filter via. `obs_source_skip_video_filter`, otherwise we just use `obs_source_video_render` on the target.
@Lordmau5
Lordmau5 marked this pull request as draft August 18, 2025 16:10
@Lordmau5

Copy link
Copy Markdown
Contributor Author

Change to draft because I've not done enough tests yet. Causes some issues with one of my setups so I need to see if I can get those sorted

Offscreen isn't really necessary - sync also works for async sources.

This fixes an issue with e.g. Color Correction (and potentially other filters) being above the Dedicated NDI Output filter and rendering everything black.

Additionally, the `video_output_lock_frame` method was put in an inner `gs_stagesurface_map` call, as it returns a boolean on whether or not it was able to map it.

Performance seems to be on-par with the offscreen method, though with the stagesurface_map change I was getting slightly better performance (at least when I last tested it a few weeks ago for the other PR)
@Lordmau5
Lordmau5 marked this pull request as ready for review August 18, 2025 16:24
@Lordmau5

Copy link
Copy Markdown
Contributor Author

There we go.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the rendering pipeline for NDI filters by improving the filter chain validation and render target logic. The changes ensure proper video filtering when the NDI filter is first in the chain versus when it has other filters before it.

  • Updates filter validation to check both target and parent sources
  • Changes width/height calculation to use the filter's source dimensions instead of target dimensions
  • Moves the render callback from a main render callback to the video render function for better integration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/ndi-filter.cpp
Comment thread src/ndi-filter.cpp
Lordmau5 and others added 2 commits August 21, 2025 19:07
Since we can just use `get_width` and `height` on our own source (the filter) and get proper dimensions of either the filter above us or the parent source before any other filters are applied (first position) we'll just use that for simplicity and to keep things in line with the other code changes.

@Trouffman Trouffman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified this, found some outdated parameters while at it.

Comment thread src/ndi-filter.cpp Outdated
@Trouffman
Trouffman merged commit 804ad81 into DistroAV:master Aug 29, 2025
6 checks passed
@Lordmau5
Lordmau5 deleted the feat/fix-filter-chain branch August 29, 2025 15:35
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.

3 participants