gagaddji2

This commit is contained in:
jess 2026-04-23 07:40:49 -07:00
parent 378b018d82
commit c96ce10ec2
2 changed files with 16 additions and 5 deletions

View File

@ -124,17 +124,28 @@ public sealed partial class MainWindow : Window
var scale = (float)RenderSurface.CompositionScaleX;
var width = (float)RenderSurface.ActualWidth;
var height = (float)RenderSurface.ActualHeight;
if (width <= 0 || height <= 0 || scale <= 0) return;
App.Log($"CreateNativeHandle: w={width} h={height} scale={scale}");
if (width <= 0 || height <= 0 || scale <= 0)
{
App.Log("CreateNativeHandle: skipped (panel not laid out yet)");
return;
}
// wgpu's dx12 backend wants an ISwapChainPanelNative*, not the raw IUnknown.
var iid = typeof(ISwapChainPanelNative).GUID;
var unknown = Marshal.GetIUnknownForObject(RenderSurface);
IntPtr native = IntPtr.Zero;
try
{
int hr = Marshal.QueryInterface(unknown, in iid, out native);
App.Log($"QueryInterface hr=0x{hr:X} native=0x{native.ToInt64():X}");
if (hr < 0 || native == IntPtr.Zero) return;
_handle = LayersNative.layers_create_from_swap_chain_panel(native, width, height, scale);
App.Log($"layers_create_from_swap_chain_panel -> 0x{_handle.ToInt64():X}");
}
catch (Exception ex)
{
App.Log($"CreateNativeHandle threw: {ex}");
throw;
}
finally
{

View File

@ -15,14 +15,14 @@ public static class Program
{
WinRT.ComWrappersSupport.InitializeComWrappers();
App.Log("ComWrappers initialised");
Application.Start(_ =>
Application.Start(p =>
{
App.Log("Application.Start callback enter");
var ctx = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread());
SynchronizationContext.SetSynchronizationContext(ctx);
App.Log("SyncContext set — creating App");
_ = new App();
App.Log("App instance created");
var app = new App();
App.Log($"App instance created ({app.GetType().Name})");
});
App.Log("Application.Start returned");
}