Skip to content

Commit

Permalink
Fix IID for 'ISwapChainPanelNative' on UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Sep 29, 2024
1 parent 93ac8ef commit da98a03
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ComputeSharp.UI/ComputeSharp.UI.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Extensions\IDXGIAdapterExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\SemaphoreSlimExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\DynamicResolutionManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\SwapChainManager.IID.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\SwapChainManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\SwapChainManager.Rendering.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IFrameRequestQueue.cs" />
Expand Down
54 changes: 54 additions & 0 deletions src/ComputeSharp.UI/Helpers/SwapChainManager.IID.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

#if WINDOWS_UWP
namespace ComputeSharp.Uwp.Helpers;
#else
namespace ComputeSharp.WinUI.Helpers;
#endif

/// <inheritdoc/>
partial class SwapChainManager<TOwner>
{
/// <summary>
/// Gets the IID of <see cref="Win32.ISwapChainPanelNative"/>.
/// </summary>
private static unsafe Guid* IID_ISwapChainPanelNative
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
ReadOnlySpan<byte> data =
[
#if WINDOWS_UWP
0xD2, 0x19, 0x2F, 0xF9,
0xDE, 0x3A,
0xA6, 0x45,
0xA2,
0x0C,
0xF6,
0xF1,
0xEA,
0x90,
0x55,
0x4B
#else
0xB8, 0xD0, 0xAA, 0x63,
0x24, 0x7C,
0xFF, 0x40,
0x85,
0xA8,
0x64,
0x0D,
0x94,
0x4C,
0xC3,
0x25
#endif
];

return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data));
}
}
}
4 changes: 1 addition & 3 deletions src/ComputeSharp.UI/Helpers/SwapChainManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ public SwapChainManager(TOwner owner, GraphicsDevice device)
// IDXGISwapChain reference just created and set that as the swap chain panel to use.
fixed (ISwapChainPanelNative** swapChainPanelNative = this.swapChainPanelNative)
{
Guid guid = new(0x63AAD0B8, 0x7C24, 0x40FF, 0x85, 0xA8, 0x64, 0x0D, 0x94, 0x4C, 0xC3, 0x25);

((IWinRTObject)owner).NativeObject.TryAs(guid, out *(nint*)swapChainPanelNative).Assert();
((IWinRTObject)owner).NativeObject.TryAs(*IID_ISwapChainPanelNative, out *(nint*)swapChainPanelNative).Assert();
}

// Get the underlying ID3D12Device in use
Expand Down

0 comments on commit da98a03

Please sign in to comment.