You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
I think I could create similar method for this library the same way as create_swapchain_for_hwnd was done.
My idea is to do additional method like create_swapchain_with_composition_for_hwnd which could be used to do modern performant transparent windows.
It needs to create necessary resources to bind the swapchain to composition surfaces. It also takes in HWND, but it allocates a few things (namely composition device, target and visual) which needs to live as long as the swapchain or window, not sure yet how would I incorporate that with this library. But this is the gist of my idea.
As a code it looks something like this:
// This behavior is only supported on windows 8 and newer where// composition is availableletmut swap_chain:*mutIDXGISwapChain1 = null_mut();(*factory).CreateSwapChainForComposition(
d3d11_device.raw_ptr()as*mutIUnknown,&desc,null_mut(),&mut swap_chain,)// Following resources are created according to this tutorial:// https://docs.microsoft.com/en-us/archive/msdn-magazine/2014/june/windows-with-c-high-performance-window-layering-using-the-windows-composition-engine// Create IDCompositionDeviceletmut ptr:*mutc_void = null_mut();DCompositionCreateDevice(
d3d11_device.raw_ptr()as*mutIDXGIDevice,&IDCompositionDevice::uuidof(),&mut ptr,);let composition_device = ComPtr::<IDCompositionDevice>::from_raw(ptr as_);// Create IDCompositionTarget for the windowletmut ptr:*mutIDCompositionTarget = null_mut();
composition_device.CreateTargetForHwnd(hwnd as_,1,&mut ptr);// <-- HWND GOES HERE let composition_target = ComPtr::from_raw(ptr);// Create IDCompositionVisual and assign to swap chainletmut ptr:*mutIDCompositionVisual = null_mut();
composition_device.CreateVisual(&mut ptr);let composition_visual = ComPtr::from_raw(ptr);
composition_visual.SetContent(swap_chain as*mutIUnknown);// Set the root as composition target and commit
composition_target.SetRoot(composition_visual.as_raw());
composition_device.Commit();// composition_device, composition_target, composition_visual needs to be stored somewhere and live as long as the swapchain or window.
The text was updated successfully, but these errors were encountered:
Interesting! Wouldn't the client of d3d12-rs want to manage IDCompositionDevice on their own? I.e. would it be feasible for d3d12 to conceal it entirely like you suggest here? I'd think that d3d12 being a low level binding library doesn't need to go as high wrt composition.
I'm still trying to ingest all the frameworks around wgpu to get a sense of this. My bigger plan was to have support in the wgpu for transparent windows.
I just did transparency support to druid which also uses D2D and swapchains and
WS_EX_NOREDIRECTIONBITMAP
, I followed this tutorial to achive that.I think I could create similar method for this library the same way as
create_swapchain_for_hwnd
was done.My idea is to do additional method like
create_swapchain_with_composition_for_hwnd
which could be used to do modern performant transparent windows.It needs to create necessary resources to bind the swapchain to composition surfaces. It also takes in HWND, but it allocates a few things (namely composition device, target and visual) which needs to live as long as the swapchain or window, not sure yet how would I incorporate that with this library. But this is the gist of my idea.
As a code it looks something like this:
The text was updated successfully, but these errors were encountered: