]> O.S.I.I.S - jp/vke.net.git/commitdiff
EnabledLayers[] overridable property in VkWindow, instance ctor with layers, phy...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 20 Nov 2021 03:01:45 +0000 (04:01 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 20 Nov 2021 03:01:45 +0000 (04:01 +0100)
Directory.Build.props
vke/src/VkWindow.cs
vke/src/base/Instance.cs
vke/src/base/PhysicalDevice.cs

index 8d90c98d899e18d5e84fb2f7f01d59bcc5377d7d..a4f0fb412899aee46b2e737f0b2fe22f9726d171 100644 (file)
@@ -4,7 +4,7 @@
                <RestoreAdditionalProjectSources Condition="Exists('$(SolutionDir)build\$(Configuration)\')">$(SolutionDir)build\$(Configuration)\</RestoreAdditionalProjectSources>
                <SpirVTasksReleaseVersion>0.1.45</SpirVTasksReleaseVersion>
                <SpirVTasksPackageVersion>$(SpirVTasksReleaseVersion)</SpirVTasksPackageVersion>
-               <VkeReleaseVersion>0.2.3</VkeReleaseVersion>
+               <VkeReleaseVersion>0.2.4</VkeReleaseVersion>
                <VkePackageVersion>$(VkeReleaseVersion)-beta</VkePackageVersion>
                <UseStbSharp>true</UseStbSharp>
                <UseMemoryPools>false</UseMemoryPools>
index 2db417d8163d889dfcd993e347d86ed6417fe4b6..65dd3dd04753eab31dddbc9274fd8211afdb0ba8 100644 (file)
@@ -52,6 +52,11 @@ namespace vke {
                uint frameCount;
                Stopwatch frameChrono;
 
+               /// <summary>
+               /// Override this property to change the list of enabled instance extensions
+               /// </summary>
+               public virtual string[] EnabledLayers => null;
+
                /// <summary>
                /// Override this property to change the list of enabled instance extensions
                /// </summary>
@@ -142,7 +147,7 @@ namespace vke {
                        if (EnabledInstanceExtensions != null)
                                instExts.AddRange (EnabledInstanceExtensions);
 
-                       instance = new Instance (instExts.ToArray());
+                       instance = new Instance (EnabledLayers, instExts.ToArray());
 
                        hSurf = instance.CreateSurface (hWin);
 
index b4fdc70bd9d1e0ae651af9fe1453971d179e57c3..ec372b0780d0851a9969315dfd6e87c0bbdf62c6 100644 (file)
@@ -14,8 +14,10 @@ namespace vke {
        /// </summary>
        public class Instance : IDisposable {
                /// <summary>If true, the VK_LAYER_KHRONOS_validation layer is loaded at startup; </summary>
+               [Obsolete("use constructor with layers as 1st argument, vkWindow implement overridable `EnabledLayers`")]
                public static bool VALIDATION;
                /// <summary>If true, the VK_LAYER_RENDERDOC_Capture layer is loaded at startup; </summary>
+               [Obsolete("use constructor with layers as 1st argument, vkWindow implement overridable `EnabledLayers`")]
                public static bool RENDER_DOC_CAPTURE;
 
                public static uint VK_MAJOR = 1;
@@ -42,7 +44,15 @@ namespace vke {
                /// Create a new vulkan instance with enabled extensions given as argument.
                /// </summary>
                /// <param name="extensions">List of extension to enable if supported</param>
-               public Instance (params string[] extensions) {
+               public Instance (params string[] extensions) : this (null, extensions) {}
+
+               /// <summary>
+               /// Create a new vulkan instance with enabled layers and extensions given as arguments.
+               /// </summary>
+               /// <param name="layers">if not null, load layers in order, else use `VALIDATION` and `RENDER_DOC_CAPTURE`
+               /// static variables to enable corresponding extensions</param>
+               /// <param name="extensions">List of extension to enable if supported</param>
+               public Instance (string[] layers, params string[] extensions) {
                        List<IntPtr> instanceExtensions = new List<IntPtr> ();
                        List<IntPtr> enabledLayerNames = new List<IntPtr> ();
 
@@ -58,12 +68,15 @@ namespace vke {
                                                Console.WriteLine ($"Vulkan initialisation: Unsupported extension: {extensions [i]}");
                                }
 
-
-                               if (VALIDATION) 
-                                       enabledLayerNames.Add (strValidationLayer.Pin (pctx));
-                               if (RENDER_DOC_CAPTURE)
-                                       enabledLayerNames.Add (strRenderDocLayer.Pin (pctx));
-
+                               if (layers != null) {
+                                       for (int i = 0; i < layers.Length; i++)
+                                               enabledLayerNames.Add (layers[i].Pin (pctx));
+                               } else {
+                                       if (VALIDATION)
+                                               enabledLayerNames.Add (strValidationLayer.Pin (pctx));
+                                       if (RENDER_DOC_CAPTURE)
+                                               enabledLayerNames.Add (strRenderDocLayer.Pin (pctx));
+                               }
 
                                VkApplicationInfo appInfo = new VkApplicationInfo () {
                                        sType = VkStructureType.ApplicationInfo,
index 91645b43b0f7db3d2ae7d0b0ee7108e54309b482..aaf3ff2b693cdd91844dd82411e1078c6ce65c17 100644 (file)
@@ -157,5 +157,21 @@ namespace vke {
                        vkGetPhysicalDeviceFormatProperties (phy, format, out VkFormatProperties properties);
                        return properties;
                }
+               public VkPhysicalDeviceToolPropertiesEXT[] GetToolProperties () {
+                       Utils.CheckResult (vkGetPhysicalDeviceToolPropertiesEXT (phy , out uint count, IntPtr.Zero));
+                       int sizeStruct = Marshal.SizeOf<VkPhysicalDeviceToolPropertiesEXT> ();
+                       IntPtr ptrTools = Marshal.AllocHGlobal (sizeStruct * (int)count);
+                       Utils.CheckResult (vkGetPhysicalDeviceToolPropertiesEXT (phy , out count, ptrTools));
+
+                       VkPhysicalDeviceToolPropertiesEXT[] result = new VkPhysicalDeviceToolPropertiesEXT[count];
+                       IntPtr tmp = ptrTools;
+                       for (int i = 0; i < count; i++) {
+                               result[i] = Marshal.PtrToStructure<VkPhysicalDeviceToolPropertiesEXT> (tmp);
+                               tmp += sizeStruct;
+                       }
+
+                       Marshal.FreeHGlobal (ptrTools);
+                       return result;
+               }
        }
 }