]> O.S.I.I.S - jp/vke.net.git/commitdiff
linux support
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 1 Mar 2021 19:54:31 +0000 (20:54 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 1 Mar 2021 19:54:31 +0000 (20:54 +0100)
.gitignore
samples/Directory.Build.props
samples/Textured/main.cs
samples/TexturedCube/main.cs
samples/Triangle/README.md
samples/Triangle/main.cs
samples/common/CrowWin.cs
samples/common/SampleBase.cs [new file with mode: 0644]
samples/deferred/main.cs
samples/pbr/main.cs

index 8c080572e143af66afac07caaf0f7125bc38f726..727a6000177b8d670c580b5d1fd02a324a5fcffd 100644 (file)
@@ -1,4 +1,5 @@
 .vs
+.vscode
 build/
 packages/
 datas
index 131cba2c90df87642c9d50ac706e209bd4ff344f..994e2c6f86dee59ff85aa3d95443959533d76dc0 100644 (file)
@@ -32,7 +32,7 @@
        </ItemGroup>    
 
        <ItemGroup>
-               <Compile Include="$(MSBuildThisFileDirectory)common\Utils.cs"/>
+               <Compile Include="$(MSBuildThisFileDirectory)common\Utils.cs;$(MSBuildThisFileDirectory)common\SampleBase.cs"/>
                <GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom">
                        <LogicalName>shaders.%(Filename)%(Extension).spv</LogicalName>
                </GLSLShader>           
index 3964cfce567b81cbe169a33d7c9e77186c9facff..b9a86623db2001eef17f30d51b985f3d5488a6e8 100644 (file)
@@ -10,7 +10,7 @@ namespace Textured {
        /// <summary>
        /// Simple textured quad sample
        /// </summary>
-       class Program : VkWindow {
+       class Program : SampleBase {
                static void Main (string[] args) {
 #if DEBUG
                        Instance.VALIDATION = true;
index 6c848d0955e2b0675636af207ee28abe55ec33cc..0346914af79cf28f4faf4db3e22ba2e1bf0e9eee 100644 (file)
@@ -14,7 +14,7 @@ namespace TextureCube {
        /// <summary>
        /// Simple textured cube sampled.
        /// </summary>
-       class Program : VkWindow {
+       class Program : SampleBase {
 
                static void Main (string[] args) {
 #if DEBUG
index f65858d94a1c1c2b01045bfc7911d6d8630b0b46..27f9eb3ab1f6a47430aa18720bc166bb28801b80 100644 (file)
@@ -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
index 46a5c6f8ab86daaa7526a7d9dc04b56f398120ac..1d6e97d9ef69ec4f4cca39f3634d846c2df0db95 100644 (file)
@@ -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;
index ee7b2ac53a11da2b0371026e6005bb20fb343ef1..539cf0c8b21c1d93870763dbb858e00fc20959ae 100644 (file)
@@ -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<ValueChangeEventArgs> 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 (file)
index 0000000..32120d9
--- /dev/null
@@ -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){}
+       }
+}
index bc524200f45ae431f0b48ff2c07df7cf3d474958..da19bfe7cae75b2ee3b9453f1220117db5a4d682 100644 (file)
@@ -14,7 +14,7 @@ namespace deferred {
        /// <summary>
        /// Deferred PBR rendering.
        /// </summary>
-       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;
 
index 7a5d01a79c503d9a12ece7fab1a10b4392a80bda..80eb0aa591219b60a77cb55a459ecae4e0e0c0a5 100644 (file)
@@ -13,7 +13,7 @@ using Vulkan;
 using vke;
 
 namespace pbrSample {
-       class Program : VkWindow {
+       class Program : SampleBase {
 
                static void Main (string[] args) {
 #if DEBUG