From 76a08ae06f20bbc87d70ab821ce1a0fc4f7aed07 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Mon, 7 Nov 2022 16:40:19 +0800 Subject: [PATCH] Add support for reflection-free mode --- .../Backend/Win32ApplicationRunner.cs | 16 ++++++++++++++-- samples/ComputeSharp.SwapChain/Program.cs | 2 +- src/ComputeSharp/ComputeSharp.csproj | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs index 6856b27f..03b2b226 100644 --- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs +++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs @@ -45,12 +45,24 @@ internal static unsafe class Win32ApplicationRunner /// The input application instance to run. /// The exit code for the application. public static int Run(Win32Application application) + { + return Run(application, Assembly.GetExecutingAssembly().FullName ?? "ComputeSharp"); + } + + /// + /// Runs a specified application and starts the main loop to update its state. This is the entry point for a given application, + /// and it should be called as soon as the process is launched, excluding any other additional initialization needed. + /// + /// The input application instance to run. + /// Name of the input application instance to run. + /// The exit code for the application. + public static int Run(Win32Application application, string applicatioName) { Win32ApplicationRunner.application = application; HMODULE hInstance = Windows.GetModuleHandleW(null); - fixed (char* name = Assembly.GetExecutingAssembly().FullName) + fixed (char* name = applicatioName) fixed (char* windowTitle = application.GetType().ToString()) { // Initialize the window class @@ -162,7 +174,7 @@ internal static unsafe class Win32ApplicationRunner } /// - /// Processes incoming messages for a window. + /// Processes incoming messages for a window. /// /// A handle to the window. /// The message. diff --git a/samples/ComputeSharp.SwapChain/Program.cs b/samples/ComputeSharp.SwapChain/Program.cs index d1606b2a..feae0e7d 100644 --- a/samples/ComputeSharp.SwapChain/Program.cs +++ b/samples/ComputeSharp.SwapChain/Program.cs @@ -61,7 +61,7 @@ class Program Console.WriteLine(); Console.WriteLine($"Starting {Samples[index].ShaderName}..."); - _ = Win32ApplicationRunner.Run(Samples[index].Application); + _ = Win32ApplicationRunner.Run(Samples[index].Application, "ComputeSharp.SwapChain"); } } while (index >= 0 && index < Samples.Length); diff --git a/src/ComputeSharp/ComputeSharp.csproj b/src/ComputeSharp/ComputeSharp.csproj index 3f6df968..cdcb576b 100644 --- a/src/ComputeSharp/ComputeSharp.csproj +++ b/src/ComputeSharp/ComputeSharp.csproj @@ -41,7 +41,7 @@ - +