From: Jean-Philippe Bruyère Date: Sun, 5 Dec 2021 06:48:36 +0000 (+0100) Subject: clearscreen and triangle ok with ptrProxies in vk.net 0.4.0-beta X-Git-Tag: v0.2.4-beta~4 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=93f8698ff803ea0c8770978a32ca1711bd341e24;p=jp%2Fvke.net.git clearscreen and triangle ok with ptrProxies in vk.net 0.4.0-beta --- diff --git a/.vscode/launch.json b/.vscode/launch.json index 25a58aa..dfc6833 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,10 @@ "args": [], "cwd": "${workspaceFolder}/build/Debug/netcoreapp3.1/", "stopAtEntry": false, - "console": "internalConsole" + "console": "internalConsole", + "env": { + "VK_INSTANCE_LAYERS": "VK_LAYER_KHRONOS_validation" + } }, { "name": ".NET Core Launch (Triangle)", diff --git a/vke/src/ShaderInfo.cs b/vke/src/ShaderInfo.cs index 10291a1..9e12500 100644 --- a/vke/src/ShaderInfo.cs +++ b/vke/src/ShaderInfo.cs @@ -9,8 +9,6 @@ namespace vke { /// This class is a helper class for VkPipelineShaderStageCreateInfo creation. /// public class ShaderInfo : IDisposable { - readonly FixedUtf8String EntryPoint; - protected VkPipelineShaderStageCreateInfo info = VkPipelineShaderStageCreateInfo.New (); protected Device dev; @@ -70,9 +68,7 @@ namespace vke { protected virtual void Dispose (bool disposing) { if (!disposedValue) { - if (disposing) - EntryPoint.Dispose (); - else + if (!disposing) System.Diagnostics.Debug.WriteLine ("VKE ShaderInfo disposed by finalizer"); dev?.DestroyShaderModule (info.module); diff --git a/vke/src/base/DescriptorSetWrites.cs b/vke/src/base/DescriptorSetWrites.cs index 59d7a40..b6fdeca 100644 --- a/vke/src/base/DescriptorSetWrites.cs +++ b/vke/src/base/DescriptorSetWrites.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using Vulkan; using static Vulkan.Vk; +using System.Linq; namespace vke { /// @@ -108,28 +109,19 @@ namespace vke { VkWriteDescriptorSet wds = WriteDescriptorSets[wdsPtr]; if (dstSetOverride != null) wds.dstSet = dstSetOverride.Value.Handle; - IntPtr pDescriptors = IntPtr.Zero; - if (wds.descriptorCount > 1) { - List descPtrArray = new List (); - for (int d = 0; d < wds.descriptorCount; d++) { - descPtrArray.Add (descriptors[i].Pin (pinCtx)); - i++; - } - } else { - pDescriptors = descriptors[i].Pin (pinCtx); - i++; - } - /*if (descriptors[firstDescriptor] is VkDescriptorBufferInfo) - wds.pBufferInfo = pDescriptors; + if (descriptors[i] is VkDescriptorBufferInfo) + wds.pBufferInfo = descriptors.SubArray (i,(int)wds.descriptorCount).Cast().ToArray(); else if (descriptors[firstDescriptor] is VkDescriptorImageInfo) - wds.pImageInfo = pDescriptors;*/ - + wds.pImageInfo = descriptors.SubArray (i,(int)wds.descriptorCount).Cast().ToArray(); + i+=(int)wds.descriptorCount; WriteDescriptorSets[wdsPtr] = wds; wdsPtr++; } vkUpdateDescriptorSets (dev.Handle, (uint)WriteDescriptorSets.Count, WriteDescriptorSets.Pin (pinCtx), 0, IntPtr.Zero); } + foreach (VkWriteDescriptorSet wds in WriteDescriptorSets) + wds.Dispose(); } /// /// execute the descriptors writes targeting descriptorSets setted on AddWriteInfo call diff --git a/vke/src/base/Instance.cs b/vke/src/base/Instance.cs index 420aca4..57611e5 100644 --- a/vke/src/base/Instance.cs +++ b/vke/src/base/Instance.cs @@ -81,8 +81,8 @@ namespace vke { VkApplicationInfo appInfo = new VkApplicationInfo () { sType = VkStructureType.ApplicationInfo, apiVersion = new Vulkan.Version (VK_MAJOR, VK_MINOR, 0), - pApplicationName = ENGINE_NAME.Pin (pctx), - pEngineName = APPLICATION_NAME.Pin (pctx), + pApplicationName = ENGINE_NAME, + pEngineName = APPLICATION_NAME, }; VkInstanceCreateInfo instanceCreateInfo = VkInstanceCreateInfo.New (); diff --git a/vke/src/base/Queue.cs b/vke/src/base/Queue.cs index fd4bbaa..3de9713 100644 --- a/vke/src/base/Queue.cs +++ b/vke/src/base/Queue.cs @@ -44,6 +44,7 @@ namespace vke { uint idx = swapChain.currentImageIndex; VkSwapchainKHR sc = swapChain.Handle; present.pSwapchains = sc; + present.pImageIndices = idx.Pin(); present.pWaitSemaphores = wait; vkQueuePresentKHR (handle, ref present);