From ffcec80f80cd705b9300cdd7783937a89f312cf9 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Wed, 1 Feb 2023 16:31:26 +0100 Subject: [PATCH] fix(GpuInterop): CS0618 member is obsolete, due to the renaming of some members of the Silk.NET.Vulkan enums --- .../VulkanDemo/VulkanBufferHelper.cs | 6 +-- .../VulkanDemo/VulkanCommandBufferPool.cs | 7 ++- .../GpuInterop/VulkanDemo/VulkanContent.cs | 50 +++++++++---------- .../GpuInterop/VulkanDemo/VulkanContext.cs | 12 ++--- samples/GpuInterop/VulkanDemo/VulkanImage.cs | 18 +++---- .../VulkanDemo/VulkanMemoryHelper.cs | 8 +-- .../GpuInterop/VulkanDemo/VulkanSwapchain.cs | 5 +- 7 files changed, 51 insertions(+), 55 deletions(-) diff --git a/samples/GpuInterop/VulkanDemo/VulkanBufferHelper.cs b/samples/GpuInterop/VulkanDemo/VulkanBufferHelper.cs index 949a951a36..290eb06b1e 100644 --- a/samples/GpuInterop/VulkanDemo/VulkanBufferHelper.cs +++ b/samples/GpuInterop/VulkanDemo/VulkanBufferHelper.cs @@ -38,8 +38,8 @@ static class VulkanBufferHelper MemoryTypeIndex = (uint)FindSuitableMemoryTypeIndex(api, physicalDevice, memoryRequirements.MemoryTypeBits, - MemoryPropertyFlags.MemoryPropertyHostCoherentBit | - MemoryPropertyFlags.MemoryPropertyHostVisibleBit) + MemoryPropertyFlags.HostCoherentBit | + MemoryPropertyFlags.HostVisibleBit) }; api.AllocateMemory(device, memoryAllocateInfo, null, out memory).ThrowOnError(); @@ -77,4 +77,4 @@ static class VulkanBufferHelper return -1; } -} \ No newline at end of file +} diff --git a/samples/GpuInterop/VulkanDemo/VulkanCommandBufferPool.cs b/samples/GpuInterop/VulkanDemo/VulkanCommandBufferPool.cs index 65a05c5226..2f018171dc 100644 --- a/samples/GpuInterop/VulkanDemo/VulkanCommandBufferPool.cs +++ b/samples/GpuInterop/VulkanDemo/VulkanCommandBufferPool.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Avalonia.Input; using Silk.NET.Vulkan; using SilkNetDemo; @@ -25,7 +24,7 @@ namespace Avalonia.Vulkan var commandPoolCreateInfo = new CommandPoolCreateInfo { SType = StructureType.CommandPoolCreateInfo, - Flags = CommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit, + Flags = CommandPoolCreateFlags.ResetCommandBufferBit, QueueFamilyIndex = queueFamilyIndex }; @@ -109,7 +108,7 @@ namespace Avalonia.Vulkan var fenceCreateInfo = new FenceCreateInfo() { SType = StructureType.FenceCreateInfo, - Flags = FenceCreateFlags.FenceCreateSignaledBit + Flags = FenceCreateFlags.SignaledBit }; api.CreateFence(device, fenceCreateInfo, null, out _fence); @@ -134,7 +133,7 @@ namespace Avalonia.Vulkan var beginInfo = new CommandBufferBeginInfo { SType = StructureType.CommandBufferBeginInfo, - Flags = CommandBufferUsageFlags.CommandBufferUsageOneTimeSubmitBit + Flags = CommandBufferUsageFlags.OneTimeSubmitBit }; _api.BeginCommandBuffer(InternalHandle, beginInfo); diff --git a/samples/GpuInterop/VulkanDemo/VulkanContent.cs b/samples/GpuInterop/VulkanDemo/VulkanContent.cs index b16343190a..5805604f1b 100644 --- a/samples/GpuInterop/VulkanDemo/VulkanContent.cs +++ b/samples/GpuInterop/VulkanDemo/VulkanContent.cs @@ -208,7 +208,7 @@ unsafe class VulkanContent : IDisposable api.CmdBindDescriptorSets(commandBufferHandle, PipelineBindPoint.Graphics, _pipelineLayout,0,1, &dset, null); - api.CmdPushConstants(commandBufferHandle, _pipelineLayout, ShaderStageFlags.ShaderStageVertexBit | ShaderStageFlags.FragmentBit, 0, + api.CmdPushConstants(commandBufferHandle, _pipelineLayout, ShaderStageFlags.VertexBit | ShaderStageFlags.FragmentBit, 0, (uint)Marshal.SizeOf(), &vertexConstant); api.CmdBindVertexBuffers(commandBufferHandle, 0, 1, _vertexBuffer, 0); api.CmdBindIndexBuffer(commandBufferHandle, _indexBuffer, 0, IndexType.Uint16); @@ -237,14 +237,14 @@ unsafe class VulkanContent : IDisposable SrcSubresource = new ImageSubresourceLayers { - AspectMask = ImageAspectFlags.ImageAspectColorBit, + AspectMask = ImageAspectFlags.ColorBit, BaseArrayLayer = 0, LayerCount = 1, MipLevel = 0 }, DstSubresource = new ImageSubresourceLayers { - AspectMask = ImageAspectFlags.ImageAspectColorBit, + AspectMask = ImageAspectFlags.ColorBit, BaseArrayLayer = 0, LayerCount = 1, MipLevel = 0 @@ -326,19 +326,19 @@ unsafe class VulkanContent : IDisposable var imageCreateInfo = new ImageCreateInfo { SType = StructureType.ImageCreateInfo, - ImageType = ImageType.ImageType2D, + ImageType = ImageType.Type2D, Format = Format.D32Sfloat, Extent = new Extent3D((uint?)size.Width, (uint?)size.Height, 1), MipLevels = 1, ArrayLayers = 1, - Samples = SampleCountFlags.SampleCount1Bit, + Samples = SampleCountFlags.Count1Bit, Tiling = ImageTiling.Optimal, - Usage = ImageUsageFlags.ImageUsageDepthStencilAttachmentBit, + Usage = ImageUsageFlags.DepthStencilAttachmentBit, SharingMode = SharingMode.Exclusive, InitialLayout = ImageLayout.Undefined, - Flags = ImageCreateFlags.ImageCreateMutableFormatBit + Flags = ImageCreateFlags.CreateMutableFormatBit }; var api = _context.Api; @@ -355,7 +355,7 @@ unsafe class VulkanContent : IDisposable AllocationSize = memoryRequirements.Size, MemoryTypeIndex = (uint)FindSuitableMemoryTypeIndex(api, _context.PhysicalDevice, - memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.MemoryPropertyDeviceLocalBit) + memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.DeviceLocalBit) }; api.AllocateMemory(device, memoryAllocateInfo, null, @@ -369,14 +369,14 @@ unsafe class VulkanContent : IDisposable ComponentSwizzle.B, ComponentSwizzle.A); - var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectDepthBit, + var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.DepthBit, 0, 1, 0, 1); var imageViewCreateInfo = new ImageViewCreateInfo { SType = StructureType.ImageViewCreateInfo, Image = _depthImage, - ViewType = ImageViewType.ImageViewType2D, + ViewType = ImageViewType.Type2D, Format = Format.D32Sfloat, Components = componentMapping, SubresourceRange = subresourceRange @@ -406,7 +406,7 @@ unsafe class VulkanContent : IDisposable var colorAttachment = new AttachmentDescription() { Format = Format.R8G8B8A8Unorm, - Samples = SampleCountFlags.SampleCount1Bit, + Samples = SampleCountFlags.Count1Bit, LoadOp = AttachmentLoadOp.Clear, StoreOp = AttachmentStoreOp.Store, InitialLayout = ImageLayout.Undefined, @@ -418,7 +418,7 @@ unsafe class VulkanContent : IDisposable var depthAttachment = new AttachmentDescription() { Format = Format.D32Sfloat, - Samples = SampleCountFlags.SampleCount1Bit, + Samples = SampleCountFlags.Count1Bit, LoadOp = AttachmentLoadOp.Clear, StoreOp = AttachmentStoreOp.DontCare, InitialLayout = ImageLayout.Undefined, @@ -431,10 +431,10 @@ unsafe class VulkanContent : IDisposable { SrcSubpass = Vk.SubpassExternal, DstSubpass = 0, - SrcStageMask = PipelineStageFlags.PipelineStageColorAttachmentOutputBit, + SrcStageMask = PipelineStageFlags.ColorAttachmentOutputBit, SrcAccessMask = 0, - DstStageMask = PipelineStageFlags.PipelineStageColorAttachmentOutputBit, - DstAccessMask = AccessFlags.AccessColorAttachmentWriteBit + DstStageMask = PipelineStageFlags.ColorAttachmentOutputBit, + DstAccessMask = AccessFlags.ColorAttachmentWriteBit }; var colorAttachmentReference = new AttachmentReference() @@ -498,14 +498,14 @@ unsafe class VulkanContent : IDisposable var vertShaderStageInfo = new PipelineShaderStageCreateInfo() { SType = StructureType.PipelineShaderStageCreateInfo, - Stage = ShaderStageFlags.ShaderStageVertexBit, + Stage = ShaderStageFlags.VertexBit, Module = _vertShader, PName = (byte*)pname, }; var fragShaderStageInfo = new PipelineShaderStageCreateInfo() { SType = StructureType.PipelineShaderStageCreateInfo, - Stage = ShaderStageFlags.ShaderStageFragmentBit, + Stage = ShaderStageFlags.FragmentBit, Module = _fragShader, PName = (byte*)pname, }; @@ -564,7 +564,7 @@ unsafe class VulkanContent : IDisposable RasterizerDiscardEnable = false, PolygonMode = PolygonMode.Fill, LineWidth = 1, - CullMode = CullModeFlags.CullModeNone, + CullMode = CullModeFlags.None, DepthBiasEnable = false }; @@ -572,7 +572,7 @@ unsafe class VulkanContent : IDisposable { SType = StructureType.PipelineMultisampleStateCreateInfo, SampleShadingEnable = false, - RasterizationSamples = SampleCountFlags.SampleCount1Bit + RasterizationSamples = SampleCountFlags.Count1Bit }; var depthStencilCreateInfo = new PipelineDepthStencilStateCreateInfo() @@ -587,10 +587,10 @@ unsafe class VulkanContent : IDisposable var colorBlendAttachmentState = new PipelineColorBlendAttachmentState() { - ColorWriteMask = ColorComponentFlags.ColorComponentABit | - ColorComponentFlags.ColorComponentRBit | - ColorComponentFlags.ColorComponentGBit | - ColorComponentFlags.ColorComponentBBit, + ColorWriteMask = ColorComponentFlags.ABit | + ColorComponentFlags.RBit | + ColorComponentFlags.GBit | + ColorComponentFlags.BBit, BlendEnable = false }; @@ -617,14 +617,14 @@ unsafe class VulkanContent : IDisposable { Offset = 0, Size = (uint)Marshal.SizeOf(), - StageFlags = ShaderStageFlags.ShaderStageVertexBit + StageFlags = ShaderStageFlags.VertexBit }; var fragPushConstantRange = new PushConstantRange() { //Offset = vertexPushConstantRange.Size, Size = (uint)Marshal.SizeOf(), - StageFlags = ShaderStageFlags.ShaderStageFragmentBit + StageFlags = ShaderStageFlags.FragmentBit }; var layoutBindingInfo = new DescriptorSetLayoutBinding diff --git a/samples/GpuInterop/VulkanDemo/VulkanContext.cs b/samples/GpuInterop/VulkanDemo/VulkanContext.cs index 56041d6965..3fdd9695f2 100644 --- a/samples/GpuInterop/VulkanDemo/VulkanContext.cs +++ b/samples/GpuInterop/VulkanDemo/VulkanContext.cs @@ -86,12 +86,12 @@ public unsafe class VulkanContext : IDisposable var debugCreateInfo = new DebugUtilsMessengerCreateInfoEXT { SType = StructureType.DebugUtilsMessengerCreateInfoExt, - MessageSeverity = DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityVerboseBitExt | - DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityWarningBitExt | - DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityErrorBitExt, - MessageType = DebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypeGeneralBitExt | - DebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypeValidationBitExt | - DebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypePerformanceBitExt, + MessageSeverity = DebugUtilsMessageSeverityFlagsEXT.VerboseBitExt | + DebugUtilsMessageSeverityFlagsEXT.WarningBitExt | + DebugUtilsMessageSeverityFlagsEXT.ErrorBitExt, + MessageType = DebugUtilsMessageTypeFlagsEXT.GeneralBitExt | + DebugUtilsMessageTypeFlagsEXT.ValidationBitExt | + DebugUtilsMessageTypeFlagsEXT.PerformanceBitExt, PfnUserCallback = new PfnDebugUtilsMessengerCallbackEXT(LogCallback), }; diff --git a/samples/GpuInterop/VulkanDemo/VulkanImage.cs b/samples/GpuInterop/VulkanDemo/VulkanImage.cs index e8854bfeb2..59b2ef7e30 100644 --- a/samples/GpuInterop/VulkanDemo/VulkanImage.cs +++ b/samples/GpuInterop/VulkanDemo/VulkanImage.cs @@ -54,8 +54,8 @@ public unsafe class VulkanImage : IDisposable Size = size; MipLevels = 1;//mipLevels; _imageUsageFlags = - ImageUsageFlags.ImageUsageColorAttachmentBit | ImageUsageFlags.ImageUsageTransferDstBit | - ImageUsageFlags.ImageUsageTransferSrcBit | ImageUsageFlags.ImageUsageSampledBit; + ImageUsageFlags.ColorAttachmentBit | ImageUsageFlags.TransferDstBit | + ImageUsageFlags.TransferSrcBit | ImageUsageFlags.SampledBit; //MipLevels = MipLevels != 0 ? MipLevels : (uint)Math.Floor(Math.Log(Math.Max(Size.Width, Size.Height), 2)); @@ -72,19 +72,19 @@ public unsafe class VulkanImage : IDisposable { PNext = exportable ? &externalMemoryCreateInfo : null, SType = StructureType.ImageCreateInfo, - ImageType = ImageType.ImageType2D, + ImageType = ImageType.Type2D, Format = Format, Extent = new Extent3D((uint?)Size.Width, (uint?)Size.Height, 1), MipLevels = MipLevels, ArrayLayers = 1, - Samples = SampleCountFlags.SampleCount1Bit, + Samples = SampleCountFlags.Count1Bit, Tiling = Tiling, Usage = _imageUsageFlags, SharingMode = SharingMode.Exclusive, InitialLayout = ImageLayout.Undefined, - Flags = ImageCreateFlags.ImageCreateMutableFormatBit + Flags = ImageCreateFlags.CreateMutableFormatBit }; Api @@ -128,7 +128,7 @@ public unsafe class VulkanImage : IDisposable MemoryTypeIndex = (uint)VulkanMemoryHelper.FindSuitableMemoryTypeIndex( Api, _physicalDevice, - memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.MemoryPropertyDeviceLocalBit) + memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.DeviceLocalBit) }; Api.AllocateMemory(_device, memoryAllocateInfo, null, @@ -146,7 +146,7 @@ public unsafe class VulkanImage : IDisposable ComponentSwizzle.Identity, ComponentSwizzle.Identity); - AspectFlags = ImageAspectFlags.ImageAspectColorBit; + AspectFlags = ImageAspectFlags.ColorBit; var subresourceRange = new ImageSubresourceRange(AspectFlags, 0, MipLevels, 0, 1); @@ -154,7 +154,7 @@ public unsafe class VulkanImage : IDisposable { SType = StructureType.ImageViewCreateInfo, Image = InternalHandle.Value, - ViewType = ImageViewType.ImageViewType2D, + ViewType = ImageViewType.Type2D, Format = Format, Components = componentMapping, SubresourceRange = subresourceRange @@ -168,7 +168,7 @@ public unsafe class VulkanImage : IDisposable _currentLayout = ImageLayout.Undefined; - TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessNoneKhr); + TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.NoneKhr); } public int ExportFd() diff --git a/samples/GpuInterop/VulkanDemo/VulkanMemoryHelper.cs b/samples/GpuInterop/VulkanDemo/VulkanMemoryHelper.cs index f6778610dc..b7c7b9cf44 100644 --- a/samples/GpuInterop/VulkanDemo/VulkanMemoryHelper.cs +++ b/samples/GpuInterop/VulkanDemo/VulkanMemoryHelper.cs @@ -29,7 +29,7 @@ internal static class VulkanMemoryHelper AccessFlags destinationAccessMask, uint mipLevels) { - var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectColorBit, 0, mipLevels, 0, 1); + var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ColorBit, 0, mipLevels, 0, 1); var barrier = new ImageMemoryBarrier { @@ -46,8 +46,8 @@ internal static class VulkanMemoryHelper api.CmdPipelineBarrier( commandBuffer, - PipelineStageFlags.PipelineStageAllCommandsBit, - PipelineStageFlags.PipelineStageAllCommandsBit, + PipelineStageFlags.AllCommandsBit, + PipelineStageFlags.AllCommandsBit, 0, 0, null, @@ -56,4 +56,4 @@ internal static class VulkanMemoryHelper 1, barrier); } -} \ No newline at end of file +} diff --git a/samples/GpuInterop/VulkanDemo/VulkanSwapchain.cs b/samples/GpuInterop/VulkanDemo/VulkanSwapchain.cs index 325c815ccb..fc0e98b3e0 100644 --- a/samples/GpuInterop/VulkanDemo/VulkanSwapchain.cs +++ b/samples/GpuInterop/VulkanDemo/VulkanSwapchain.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Runtime.InteropServices; using System.Threading.Tasks; using Avalonia; @@ -7,9 +6,7 @@ using Avalonia.Platform; using Avalonia.Rendering; using Avalonia.Rendering.Composition; using Avalonia.Vulkan; -using Metsys.Bson; using Silk.NET.Vulkan; -using SkiaSharp; namespace GpuInterop.VulkanDemo; @@ -84,7 +81,7 @@ class VulkanSwapchainImage : ISwapchainImage _image.TransitionLayout(buffer.InternalHandle, ImageLayout.Undefined, AccessFlags.None, - ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessColorAttachmentReadBit); + ImageLayout.ColorAttachmentOptimal, AccessFlags.ColorAttachmentReadBit); if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) buffer.Submit(null,null,null, null, new VulkanCommandBufferPool.VulkanCommandBuffer.KeyedMutexSubmitInfo