Replace the swapchain in an addon

  • MajorPainTheCactus
  • MajorPainTheCactus's Avatar Topic Author
  • Offline
More
2 weeks 1 day ago #1 by MajorPainTheCactus
Replace the swapchain in an addon was created by MajorPainTheCactus
Hi so I'm wanting to replace the swapchain an app uses with another one. Is this possible? I seem to have only interfaces to objects and the native object (_orig) is hidden from me.

I suppose I could cast the pointer to the reshade swapchain object but I suppose then the question is does Reshade wrap this object so that the calling app doesn't realise it's holding on to a wrapper rather than the proper D3D11/D3D12 native object.

Please Log in or Create an account to join the conversation.

More
1 week 6 days ago - 1 week 6 days ago #2 by crosire
Replied by crosire on topic Replace the swapchain in an addon
You can get to the native object via the "reshade::api::swapchain::get_native()" method (crosire.github.io/reshade-docs/structres...f16dc6729858e42175a7), e.g.:
IDXGISwapChain *orig = (IDXGISwapChain *)swapchain->get_native()
You can not replace that with something else however (that would cause problems for ReShade). Though if you only want to change how the swapchain is created (e.g. change resolution, ...) you can register for the "reshade::addon_event::create_swapchain" event and modify the swapchain description accordingly in the callback (crosire.github.io/reshade-docs/namespace...e8fce9d5deafaff9b641).
Last edit: 1 week 6 days ago by crosire.

Please Log in or Create an account to join the conversation.

  • MajorPainTheCactus
  • MajorPainTheCactus's Avatar Topic Author
  • Offline
More
1 week 3 days ago #3 by MajorPainTheCactus
Replied by MajorPainTheCactus on topic Replace the swapchain in an addon
Thanks Crosire! All done as you're aware - thanks for merging it. For everybody else I added a swapchain_desc to the above "reshade::addon_event::create_swapchain" event that allows you more control over the creation of the swap chain.
The following user(s) said Thank You: crosire

Please Log in or Create an account to join the conversation.

More
1 week 3 days ago - 1 week 3 days ago #4 by crosire
Replied by crosire on topic Replace the swapchain in an addon
Do note the small adjustment I made to it though, as per github.com/crosire/reshade/pull/233#issuecomment-1120425196 (since I didn't see that reflected in your AutoHDR-ReShade repository yet).

Oh, and "QueryInterface()" and "GetParent()" increase the reference count on the returned object, so need to be careful to call "Release()" on them again, or else things will leak (currently missing for "swapchain4" and "factory" in "on_present"). =P
Last edit: 1 week 3 days ago by crosire.

Please Log in or Create an account to join the conversation.

  • MajorPainTheCactus
  • MajorPainTheCactus's Avatar Topic Author
  • Offline
More
10 hours 56 minutes ago #5 by MajorPainTheCactus
Replied by MajorPainTheCactus on topic Replace the swapchain in an addon
Ah brilliant I did miss that and I'll update it. Thanks!

Please Log in or Create an account to join the conversation.

  • MajorPainTheCactus
  • MajorPainTheCactus's Avatar Topic Author
  • Offline
More
10 hours 12 minutes ago - 10 hours 12 minutes ago #6 by MajorPainTheCactus
Replied by MajorPainTheCactus on topic Replace the swapchain in an addon
Thanks @Crosire fixed the leaks and updated to latest ReShade in GitHub
Last edit: 10 hours 12 minutes ago by MajorPainTheCactus.
The following user(s) said Thank You: Wicked Sick

Please Log in or Create an account to join the conversation.