diff --git a/shell/windows/LayersShell/MainWindow.xaml.cs b/shell/windows/LayersShell/MainWindow.xaml.cs index 3b27cea..8cf4bb0 100644 --- a/shell/windows/LayersShell/MainWindow.xaml.cs +++ b/shell/windows/LayersShell/MainWindow.xaml.cs @@ -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 { diff --git a/shell/windows/LayersShell/Program.cs b/shell/windows/LayersShell/Program.cs index 2954758..a7c73b5 100644 --- a/shell/windows/LayersShell/Program.cs +++ b/shell/windows/LayersShell/Program.cs @@ -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"); }