Replace the swapchain in an addon
- MajorPainTheCactus
- Topic Author
Less
More
1 year 10 months 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.
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.
- crosire
Less
More
1 year 10 months ago - 1 year 10 months 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.: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
).
IDXGISwapChain *orig = (IDXGISwapChain *)swapchain->get_native()
Last edit: 1 year 10 months ago by crosire.
Please Log in or Create an account to join the conversation.
- MajorPainTheCactus
- Topic Author
Less
More
1 year 10 months 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.
- crosire
Less
More
1 year 10 months ago - 1 year 10 months 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").
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").
Last edit: 1 year 10 months ago by crosire.
Please Log in or Create an account to join the conversation.
- MajorPainTheCactus
- Topic Author
Less
More
1 year 10 months 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
- Topic Author
Less
More
1 year 10 months ago - 1 year 10 months 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: 1 year 10 months ago by MajorPainTheCactus.
The following user(s) said Thank You: Wicked Sick
Please Log in or Create an account to join the conversation.