From: Jean-Philippe Bruyère Date: Mon, 1 Mar 2021 19:54:31 +0000 (+0100) Subject: linux support X-Git-Tag: v0.2.1-beta~3 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0d2872f7c5791dcc6860227dbb34299f2da4340a;p=jp%2Fvke.net.git linux support --- diff --git a/.gitignore b/.gitignore index 8c08057..727a600 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vs +.vscode build/ packages/ datas diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props index 131cba2..994e2c6 100644 --- a/samples/Directory.Build.props +++ b/samples/Directory.Build.props @@ -32,7 +32,7 @@ - + shaders.%(Filename)%(Extension).spv diff --git a/samples/Textured/main.cs b/samples/Textured/main.cs index 3964cfc..b9a8662 100644 --- a/samples/Textured/main.cs +++ b/samples/Textured/main.cs @@ -10,7 +10,7 @@ namespace Textured { /// /// Simple textured quad sample /// - class Program : VkWindow { + class Program : SampleBase { static void Main (string[] args) { #if DEBUG Instance.VALIDATION = true; diff --git a/samples/TexturedCube/main.cs b/samples/TexturedCube/main.cs index 6c848d0..0346914 100644 --- a/samples/TexturedCube/main.cs +++ b/samples/TexturedCube/main.cs @@ -14,7 +14,7 @@ namespace TextureCube { /// /// Simple textured cube sampled. /// - class Program : VkWindow { + class Program : SampleBase { static void Main (string[] args) { #if DEBUG diff --git a/samples/Triangle/README.md b/samples/Triangle/README.md index f65858d..27f9eb3 100644 --- a/samples/Triangle/README.md +++ b/samples/Triangle/README.md @@ -38,8 +38,8 @@ cfg.AddVertexAttributes (0, VkFormat.R32g32b32Sfloat, //position ``` shader are automatically compiled by [`SpirVTasks`](../../SpirVTasks/README.md) if added to the project. The resulting shaders are automatically embedded in the assembly. To specifiy that the shader path is a resource name, put the **'#'** prefix. Else the path will be search on disk. ```csharp -cfg.AddShader (VkShaderStageFlags.Vertex, "#shaders.main.vert.spv"); -cfg.AddShader (VkShaderStageFlags.Fragment, "#shaders.main.frag.spv"); +cfg.AddShader (dev, VkShaderStageFlags.Vertex, "#shaders.main.vert.spv"); +cfg.AddShader (dev, VkShaderStageFlags.Fragment, "#shaders.main.frag.spv"); ``` Once the pipeline configuration is complete, we use it to effectively create and activate a graphic pipeline. Activables used by the pipeline (like the RenderPass, or the PipelineLayout) are referenced in the newly created managed pipeline. So the Configuration object doesn't need cleanup. ```csharp diff --git a/samples/Triangle/main.cs b/samples/Triangle/main.cs index 46a5c6f..1d6e97d 100644 --- a/samples/Triangle/main.cs +++ b/samples/Triangle/main.cs @@ -10,7 +10,7 @@ using Glfw; //the traditional triangle sample namespace Triangle { - class Program : VkWindow { + class Program : SampleBase { static void Main (string[] args) { #if DEBUG Instance.VALIDATION = true; diff --git a/samples/common/CrowWin.cs b/samples/common/CrowWin.cs index ee7b2ac..539cf0c 100644 --- a/samples/common/CrowWin.cs +++ b/samples/common/CrowWin.cs @@ -5,6 +5,24 @@ using System.Threading; namespace Crow { public class CrowWin : vke.VkWindow, IValueChange { +#if NETCOREAPP + static IntPtr resolveUnmanaged (Assembly assembly, String libraryName) { + + switch (libraryName) + { + case "glfw3": + return NativeLibrary.Load("glfw", assembly, null); + case "rsvg-2.40": + return NativeLibrary.Load("rsvg-2", assembly, null); + } + Console.WriteLine ($"[UNRESOLVE] {assembly} {libraryName}"); + return IntPtr.Zero; + } + + static CrowWin () { + System.Runtime.Loader.AssemblyLoadContext.Default.ResolvingUnmanagedDll+=resolveUnmanaged; + } +#endif #region IValueChange implementation public event EventHandler ValueChanged; public virtual void NotifyValueChanged (string MemberName, object _value) { diff --git a/samples/common/SampleBase.cs b/samples/common/SampleBase.cs new file mode 100644 index 0000000..32120d9 --- /dev/null +++ b/samples/common/SampleBase.cs @@ -0,0 +1,31 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; + + +namespace vke { + public abstract class SampleBase : VkWindow { +#if NETCOREAPP + static IntPtr resolveUnmanaged (Assembly assembly, String libraryName) { + + switch (libraryName) + { + case "glfw3": + return NativeLibrary.Load("glfw", assembly, null); + case "rsvg-2.40": + return NativeLibrary.Load("rsvg-2", assembly, null); + } + Console.WriteLine ($"[UNRESOLVE] {assembly} {libraryName}"); + return IntPtr.Zero; + } + + static SampleBase () { + System.Runtime.Loader.AssemblyLoadContext.Default.ResolvingUnmanagedDll+=resolveUnmanaged; + } +#endif + public SampleBase (string name = "VkWindow", uint _width = 800, uint _height = 600, bool vSync = true) : + base (name, _width, _height, vSync){} + } +} diff --git a/samples/deferred/main.cs b/samples/deferred/main.cs index bc52420..da19bfe 100644 --- a/samples/deferred/main.cs +++ b/samples/deferred/main.cs @@ -14,7 +14,7 @@ namespace deferred { /// /// Deferred PBR rendering. /// - class Deferred : VkWindow { + class Deferred : SampleBase { static void Main (string[] args) { #if DEBUG Instance.VALIDATION = true; @@ -25,7 +25,6 @@ namespace deferred { DeferredPbrRenderer.NUM_SAMPLES = VkSampleCountFlags.SampleCount4; DeferredPbrRenderer.HDR_FORMAT = VkFormat.R32g32b32a32Sfloat; DeferredPbrRenderer.MRT_FORMAT = VkFormat.R32g32b32a32Sfloat; - PbrModelTexArray.TEXTURE_DIM = 1024; using (Deferred vke = new Deferred ()) { @@ -56,7 +55,7 @@ namespace deferred { computeQ = new Queue (dev, VkQueueFlags.Compute); } - int curModelIndex = 13; + int curModelIndex = 1; bool reloadModel; bool rebuildBuffers; diff --git a/samples/pbr/main.cs b/samples/pbr/main.cs index 7a5d01a..80eb0aa 100644 --- a/samples/pbr/main.cs +++ b/samples/pbr/main.cs @@ -13,7 +13,7 @@ using Vulkan; using vke; namespace pbrSample { - class Program : VkWindow { + class Program : SampleBase { static void Main (string[] args) { #if DEBUG