Skip to content

Conversation

cgutman
Copy link
Collaborator

@cgutman cgutman commented Jan 1, 2023

Description

This PR introduces the required use of the ID3D10Multithread interface and enables PARALLEL_ENCODING for NVENC and AMF encoders to hopefully improve performance for capturing Vulkan applications.

This works fine for me (no warnings with the debug runtime using NVENC), but I'd like a test from @psyke83 on AMD to verify that it works fine there and see if it improves performance for Gravity Mark in Vulkan mode.

Screenshot

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

@cgutman cgutman marked this pull request as draft January 1, 2023 02:50
@Isalight
Copy link

Isalight commented Jan 1, 2023

There doesn't seem to be any performance impact in my case (#553 (comment)).
Sometimes, after stopping the benchmark, the picture on the stream freezes (input work). No any error in sunshine. But after exit it is not possible to connect to the host. And the host closes only after 10 seconds.

[2023:01:01:11:42:30]: Info: Interrupt handler called
[2023:01:01:11:42:40]: Fatal: 10 seconds passed, yet Sunshine's still running: Forcing shutdown

@psyke83
Copy link
Contributor

psyke83 commented Jan 1, 2023

Apologies for the delay, I haven't had much time to test due to my laptop's keyboard developing a hardware fault that needed addressing.

This change has mixed results. Focusing on GravityMark, normalizing all tests to run at 1440p/60 on host and client, using amdvce encoder. GravityMark benchmarks to ~110fps on the host via all API types.

Vulkan fullscreen: capture averages ~50fps (noticeable dips to 40).
D3D12 fullscreen: capture averages ~50fps (same dips).
D3D11 fullscreen: capture averages 60fps (no noticeable dips).

So far so good (as the Vulkan results, if not perfect, are still better than before), but a new problem arises when the host renders at a framerate below the target FPS.

If I cap GravityMark to 30fps (using AMD Radeon Chill, but RTSS will probably work the same), the benchmark will look OK with Moonlight's statistics showing 30fps, but once you move the mouse, the capture statistics will increase beyond 40, and the video will show a kind of judder or temporal distortion, where frames look to be played in the wrong order. This happens only with the Vulkan API, suggesting a problem related to DXGI_FORMAT_R8G8B8A8_UNORM only.

Screencast.from.2023-01-01.16-26-05.webm

This problem also seems to affect the software encoder to a certain degree (it's harder to reach the target FPS at higher resolutions).

There doesn't seem to be any performance impact in my case (#553 (comment)). Sometimes, after stopping the benchmark, the picture on the stream freezes (input work). No any error in sunshine. But after exit it is not possible to connect to the host. And the host closes only after 10 seconds.

[2023:01:01:11:42:30]: Info: Interrupt handler called
[2023:01:01:11:42:40]: Fatal: 10 seconds passed, yet Sunshine's still running: Forcing shutdown

I haven't been able to reproduce this problem yet.

@psyke83
Copy link
Contributor

psyke83 commented Jan 1, 2023

There doesn't seem to be any performance impact in my case (#553 (comment)). Sometimes, after stopping the benchmark, the picture on the stream freezes (input work). No any error in sunshine. But after exit it is not possible to connect to the host. And the host closes only after 10 seconds.

[2023:01:01:11:42:30]: Info: Interrupt handler called
[2023:01:01:11:42:40]: Fatal: 10 seconds passed, yet Sunshine's still running: Forcing shutdown

I was able to reproduce this. Additionally, this PR is causing low framerate content (e.g. typing in notepad) to exhibit the same kind of delay that was present before this fix was committed: LizardByte/build-deps#18

@cgutman
Copy link
Collaborator Author

cgutman commented Jan 1, 2023

I'm going to take a different approach and try using 2 separate ID3D11Device(Context) objects (one for capture and one for encode) then pass textures between them using D3D11_RESOURCE_MISC_SHARED_NTHANDLE and ID3D11Device1::OpenSharedResource1().

That should avoid the synchronization performance overhead and hopefully address the other issues mentioned.

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