Browse Source

Merge pull request #10154 from workgroupengineering/fixes/Warnings/CS0618/GpuInterop

fix(GpuInterop): CS0618 member is obsolete, due to the renaming of some members of the Silk.NET.Vulkan enums
pull/10160/head
Max Katz 4 years ago
committed by GitHub
parent
commit
f587fae4d6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      samples/GpuInterop/VulkanDemo/VulkanBufferHelper.cs
  2. 7
      samples/GpuInterop/VulkanDemo/VulkanCommandBufferPool.cs
  3. 50
      samples/GpuInterop/VulkanDemo/VulkanContent.cs
  4. 12
      samples/GpuInterop/VulkanDemo/VulkanContext.cs
  5. 18
      samples/GpuInterop/VulkanDemo/VulkanImage.cs
  6. 8
      samples/GpuInterop/VulkanDemo/VulkanMemoryHelper.cs
  7. 5
      samples/GpuInterop/VulkanDemo/VulkanSwapchain.cs

6
samples/GpuInterop/VulkanDemo/VulkanBufferHelper.cs

@ -38,8 +38,8 @@ static class VulkanBufferHelper
MemoryTypeIndex = (uint)FindSuitableMemoryTypeIndex(api, MemoryTypeIndex = (uint)FindSuitableMemoryTypeIndex(api,
physicalDevice, physicalDevice,
memoryRequirements.MemoryTypeBits, memoryRequirements.MemoryTypeBits,
MemoryPropertyFlags.MemoryPropertyHostCoherentBit | MemoryPropertyFlags.HostCoherentBit |
MemoryPropertyFlags.MemoryPropertyHostVisibleBit) MemoryPropertyFlags.HostVisibleBit)
}; };
api.AllocateMemory(device, memoryAllocateInfo, null, out memory).ThrowOnError(); api.AllocateMemory(device, memoryAllocateInfo, null, out memory).ThrowOnError();
@ -77,4 +77,4 @@ static class VulkanBufferHelper
return -1; return -1;
} }
} }

7
samples/GpuInterop/VulkanDemo/VulkanCommandBufferPool.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Avalonia.Input;
using Silk.NET.Vulkan; using Silk.NET.Vulkan;
using SilkNetDemo; using SilkNetDemo;
@ -25,7 +24,7 @@ namespace Avalonia.Vulkan
var commandPoolCreateInfo = new CommandPoolCreateInfo var commandPoolCreateInfo = new CommandPoolCreateInfo
{ {
SType = StructureType.CommandPoolCreateInfo, SType = StructureType.CommandPoolCreateInfo,
Flags = CommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit, Flags = CommandPoolCreateFlags.ResetCommandBufferBit,
QueueFamilyIndex = queueFamilyIndex QueueFamilyIndex = queueFamilyIndex
}; };
@ -109,7 +108,7 @@ namespace Avalonia.Vulkan
var fenceCreateInfo = new FenceCreateInfo() var fenceCreateInfo = new FenceCreateInfo()
{ {
SType = StructureType.FenceCreateInfo, SType = StructureType.FenceCreateInfo,
Flags = FenceCreateFlags.FenceCreateSignaledBit Flags = FenceCreateFlags.SignaledBit
}; };
api.CreateFence(device, fenceCreateInfo, null, out _fence); api.CreateFence(device, fenceCreateInfo, null, out _fence);
@ -134,7 +133,7 @@ namespace Avalonia.Vulkan
var beginInfo = new CommandBufferBeginInfo var beginInfo = new CommandBufferBeginInfo
{ {
SType = StructureType.CommandBufferBeginInfo, SType = StructureType.CommandBufferBeginInfo,
Flags = CommandBufferUsageFlags.CommandBufferUsageOneTimeSubmitBit Flags = CommandBufferUsageFlags.OneTimeSubmitBit
}; };
_api.BeginCommandBuffer(InternalHandle, beginInfo); _api.BeginCommandBuffer(InternalHandle, beginInfo);

50
samples/GpuInterop/VulkanDemo/VulkanContent.cs

@ -208,7 +208,7 @@ unsafe class VulkanContent : IDisposable
api.CmdBindDescriptorSets(commandBufferHandle, PipelineBindPoint.Graphics, api.CmdBindDescriptorSets(commandBufferHandle, PipelineBindPoint.Graphics,
_pipelineLayout,0,1, &dset, null); _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<VertextPushConstant>(), &vertexConstant); (uint)Marshal.SizeOf<VertextPushConstant>(), &vertexConstant);
api.CmdBindVertexBuffers(commandBufferHandle, 0, 1, _vertexBuffer, 0); api.CmdBindVertexBuffers(commandBufferHandle, 0, 1, _vertexBuffer, 0);
api.CmdBindIndexBuffer(commandBufferHandle, _indexBuffer, 0, IndexType.Uint16); api.CmdBindIndexBuffer(commandBufferHandle, _indexBuffer, 0, IndexType.Uint16);
@ -237,14 +237,14 @@ unsafe class VulkanContent : IDisposable
SrcSubresource = SrcSubresource =
new ImageSubresourceLayers new ImageSubresourceLayers
{ {
AspectMask = ImageAspectFlags.ImageAspectColorBit, AspectMask = ImageAspectFlags.ColorBit,
BaseArrayLayer = 0, BaseArrayLayer = 0,
LayerCount = 1, LayerCount = 1,
MipLevel = 0 MipLevel = 0
}, },
DstSubresource = new ImageSubresourceLayers DstSubresource = new ImageSubresourceLayers
{ {
AspectMask = ImageAspectFlags.ImageAspectColorBit, AspectMask = ImageAspectFlags.ColorBit,
BaseArrayLayer = 0, BaseArrayLayer = 0,
LayerCount = 1, LayerCount = 1,
MipLevel = 0 MipLevel = 0
@ -326,19 +326,19 @@ unsafe class VulkanContent : IDisposable
var imageCreateInfo = new ImageCreateInfo var imageCreateInfo = new ImageCreateInfo
{ {
SType = StructureType.ImageCreateInfo, SType = StructureType.ImageCreateInfo,
ImageType = ImageType.ImageType2D, ImageType = ImageType.Type2D,
Format = Format.D32Sfloat, Format = Format.D32Sfloat,
Extent = Extent =
new Extent3D((uint?)size.Width, new Extent3D((uint?)size.Width,
(uint?)size.Height, 1), (uint?)size.Height, 1),
MipLevels = 1, MipLevels = 1,
ArrayLayers = 1, ArrayLayers = 1,
Samples = SampleCountFlags.SampleCount1Bit, Samples = SampleCountFlags.Count1Bit,
Tiling = ImageTiling.Optimal, Tiling = ImageTiling.Optimal,
Usage = ImageUsageFlags.ImageUsageDepthStencilAttachmentBit, Usage = ImageUsageFlags.DepthStencilAttachmentBit,
SharingMode = SharingMode.Exclusive, SharingMode = SharingMode.Exclusive,
InitialLayout = ImageLayout.Undefined, InitialLayout = ImageLayout.Undefined,
Flags = ImageCreateFlags.ImageCreateMutableFormatBit Flags = ImageCreateFlags.CreateMutableFormatBit
}; };
var api = _context.Api; var api = _context.Api;
@ -355,7 +355,7 @@ unsafe class VulkanContent : IDisposable
AllocationSize = memoryRequirements.Size, AllocationSize = memoryRequirements.Size,
MemoryTypeIndex = (uint)FindSuitableMemoryTypeIndex(api, MemoryTypeIndex = (uint)FindSuitableMemoryTypeIndex(api,
_context.PhysicalDevice, _context.PhysicalDevice,
memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.MemoryPropertyDeviceLocalBit) memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.DeviceLocalBit)
}; };
api.AllocateMemory(device, memoryAllocateInfo, null, api.AllocateMemory(device, memoryAllocateInfo, null,
@ -369,14 +369,14 @@ unsafe class VulkanContent : IDisposable
ComponentSwizzle.B, ComponentSwizzle.B,
ComponentSwizzle.A); ComponentSwizzle.A);
var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectDepthBit, var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.DepthBit,
0, 1, 0, 1); 0, 1, 0, 1);
var imageViewCreateInfo = new ImageViewCreateInfo var imageViewCreateInfo = new ImageViewCreateInfo
{ {
SType = StructureType.ImageViewCreateInfo, SType = StructureType.ImageViewCreateInfo,
Image = _depthImage, Image = _depthImage,
ViewType = ImageViewType.ImageViewType2D, ViewType = ImageViewType.Type2D,
Format = Format.D32Sfloat, Format = Format.D32Sfloat,
Components = componentMapping, Components = componentMapping,
SubresourceRange = subresourceRange SubresourceRange = subresourceRange
@ -406,7 +406,7 @@ unsafe class VulkanContent : IDisposable
var colorAttachment = new AttachmentDescription() var colorAttachment = new AttachmentDescription()
{ {
Format = Format.R8G8B8A8Unorm, Format = Format.R8G8B8A8Unorm,
Samples = SampleCountFlags.SampleCount1Bit, Samples = SampleCountFlags.Count1Bit,
LoadOp = AttachmentLoadOp.Clear, LoadOp = AttachmentLoadOp.Clear,
StoreOp = AttachmentStoreOp.Store, StoreOp = AttachmentStoreOp.Store,
InitialLayout = ImageLayout.Undefined, InitialLayout = ImageLayout.Undefined,
@ -418,7 +418,7 @@ unsafe class VulkanContent : IDisposable
var depthAttachment = new AttachmentDescription() var depthAttachment = new AttachmentDescription()
{ {
Format = Format.D32Sfloat, Format = Format.D32Sfloat,
Samples = SampleCountFlags.SampleCount1Bit, Samples = SampleCountFlags.Count1Bit,
LoadOp = AttachmentLoadOp.Clear, LoadOp = AttachmentLoadOp.Clear,
StoreOp = AttachmentStoreOp.DontCare, StoreOp = AttachmentStoreOp.DontCare,
InitialLayout = ImageLayout.Undefined, InitialLayout = ImageLayout.Undefined,
@ -431,10 +431,10 @@ unsafe class VulkanContent : IDisposable
{ {
SrcSubpass = Vk.SubpassExternal, SrcSubpass = Vk.SubpassExternal,
DstSubpass = 0, DstSubpass = 0,
SrcStageMask = PipelineStageFlags.PipelineStageColorAttachmentOutputBit, SrcStageMask = PipelineStageFlags.ColorAttachmentOutputBit,
SrcAccessMask = 0, SrcAccessMask = 0,
DstStageMask = PipelineStageFlags.PipelineStageColorAttachmentOutputBit, DstStageMask = PipelineStageFlags.ColorAttachmentOutputBit,
DstAccessMask = AccessFlags.AccessColorAttachmentWriteBit DstAccessMask = AccessFlags.ColorAttachmentWriteBit
}; };
var colorAttachmentReference = new AttachmentReference() var colorAttachmentReference = new AttachmentReference()
@ -498,14 +498,14 @@ unsafe class VulkanContent : IDisposable
var vertShaderStageInfo = new PipelineShaderStageCreateInfo() var vertShaderStageInfo = new PipelineShaderStageCreateInfo()
{ {
SType = StructureType.PipelineShaderStageCreateInfo, SType = StructureType.PipelineShaderStageCreateInfo,
Stage = ShaderStageFlags.ShaderStageVertexBit, Stage = ShaderStageFlags.VertexBit,
Module = _vertShader, Module = _vertShader,
PName = (byte*)pname, PName = (byte*)pname,
}; };
var fragShaderStageInfo = new PipelineShaderStageCreateInfo() var fragShaderStageInfo = new PipelineShaderStageCreateInfo()
{ {
SType = StructureType.PipelineShaderStageCreateInfo, SType = StructureType.PipelineShaderStageCreateInfo,
Stage = ShaderStageFlags.ShaderStageFragmentBit, Stage = ShaderStageFlags.FragmentBit,
Module = _fragShader, Module = _fragShader,
PName = (byte*)pname, PName = (byte*)pname,
}; };
@ -564,7 +564,7 @@ unsafe class VulkanContent : IDisposable
RasterizerDiscardEnable = false, RasterizerDiscardEnable = false,
PolygonMode = PolygonMode.Fill, PolygonMode = PolygonMode.Fill,
LineWidth = 1, LineWidth = 1,
CullMode = CullModeFlags.CullModeNone, CullMode = CullModeFlags.None,
DepthBiasEnable = false DepthBiasEnable = false
}; };
@ -572,7 +572,7 @@ unsafe class VulkanContent : IDisposable
{ {
SType = StructureType.PipelineMultisampleStateCreateInfo, SType = StructureType.PipelineMultisampleStateCreateInfo,
SampleShadingEnable = false, SampleShadingEnable = false,
RasterizationSamples = SampleCountFlags.SampleCount1Bit RasterizationSamples = SampleCountFlags.Count1Bit
}; };
var depthStencilCreateInfo = new PipelineDepthStencilStateCreateInfo() var depthStencilCreateInfo = new PipelineDepthStencilStateCreateInfo()
@ -587,10 +587,10 @@ unsafe class VulkanContent : IDisposable
var colorBlendAttachmentState = new PipelineColorBlendAttachmentState() var colorBlendAttachmentState = new PipelineColorBlendAttachmentState()
{ {
ColorWriteMask = ColorComponentFlags.ColorComponentABit | ColorWriteMask = ColorComponentFlags.ABit |
ColorComponentFlags.ColorComponentRBit | ColorComponentFlags.RBit |
ColorComponentFlags.ColorComponentGBit | ColorComponentFlags.GBit |
ColorComponentFlags.ColorComponentBBit, ColorComponentFlags.BBit,
BlendEnable = false BlendEnable = false
}; };
@ -617,14 +617,14 @@ unsafe class VulkanContent : IDisposable
{ {
Offset = 0, Offset = 0,
Size = (uint)Marshal.SizeOf<VertextPushConstant>(), Size = (uint)Marshal.SizeOf<VertextPushConstant>(),
StageFlags = ShaderStageFlags.ShaderStageVertexBit StageFlags = ShaderStageFlags.VertexBit
}; };
var fragPushConstantRange = new PushConstantRange() var fragPushConstantRange = new PushConstantRange()
{ {
//Offset = vertexPushConstantRange.Size, //Offset = vertexPushConstantRange.Size,
Size = (uint)Marshal.SizeOf<VertextPushConstant>(), Size = (uint)Marshal.SizeOf<VertextPushConstant>(),
StageFlags = ShaderStageFlags.ShaderStageFragmentBit StageFlags = ShaderStageFlags.FragmentBit
}; };
var layoutBindingInfo = new DescriptorSetLayoutBinding var layoutBindingInfo = new DescriptorSetLayoutBinding

12
samples/GpuInterop/VulkanDemo/VulkanContext.cs

@ -86,12 +86,12 @@ public unsafe class VulkanContext : IDisposable
var debugCreateInfo = new DebugUtilsMessengerCreateInfoEXT var debugCreateInfo = new DebugUtilsMessengerCreateInfoEXT
{ {
SType = StructureType.DebugUtilsMessengerCreateInfoExt, SType = StructureType.DebugUtilsMessengerCreateInfoExt,
MessageSeverity = DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityVerboseBitExt | MessageSeverity = DebugUtilsMessageSeverityFlagsEXT.VerboseBitExt |
DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityWarningBitExt | DebugUtilsMessageSeverityFlagsEXT.WarningBitExt |
DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityErrorBitExt, DebugUtilsMessageSeverityFlagsEXT.ErrorBitExt,
MessageType = DebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypeGeneralBitExt | MessageType = DebugUtilsMessageTypeFlagsEXT.GeneralBitExt |
DebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypeValidationBitExt | DebugUtilsMessageTypeFlagsEXT.ValidationBitExt |
DebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypePerformanceBitExt, DebugUtilsMessageTypeFlagsEXT.PerformanceBitExt,
PfnUserCallback = new PfnDebugUtilsMessengerCallbackEXT(LogCallback), PfnUserCallback = new PfnDebugUtilsMessengerCallbackEXT(LogCallback),
}; };

18
samples/GpuInterop/VulkanDemo/VulkanImage.cs

@ -54,8 +54,8 @@ public unsafe class VulkanImage : IDisposable
Size = size; Size = size;
MipLevels = 1;//mipLevels; MipLevels = 1;//mipLevels;
_imageUsageFlags = _imageUsageFlags =
ImageUsageFlags.ImageUsageColorAttachmentBit | ImageUsageFlags.ImageUsageTransferDstBit | ImageUsageFlags.ColorAttachmentBit | ImageUsageFlags.TransferDstBit |
ImageUsageFlags.ImageUsageTransferSrcBit | ImageUsageFlags.ImageUsageSampledBit; ImageUsageFlags.TransferSrcBit | ImageUsageFlags.SampledBit;
//MipLevels = MipLevels != 0 ? MipLevels : (uint)Math.Floor(Math.Log(Math.Max(Size.Width, Size.Height), 2)); //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, PNext = exportable ? &externalMemoryCreateInfo : null,
SType = StructureType.ImageCreateInfo, SType = StructureType.ImageCreateInfo,
ImageType = ImageType.ImageType2D, ImageType = ImageType.Type2D,
Format = Format, Format = Format,
Extent = Extent =
new Extent3D((uint?)Size.Width, new Extent3D((uint?)Size.Width,
(uint?)Size.Height, 1), (uint?)Size.Height, 1),
MipLevels = MipLevels, MipLevels = MipLevels,
ArrayLayers = 1, ArrayLayers = 1,
Samples = SampleCountFlags.SampleCount1Bit, Samples = SampleCountFlags.Count1Bit,
Tiling = Tiling, Tiling = Tiling,
Usage = _imageUsageFlags, Usage = _imageUsageFlags,
SharingMode = SharingMode.Exclusive, SharingMode = SharingMode.Exclusive,
InitialLayout = ImageLayout.Undefined, InitialLayout = ImageLayout.Undefined,
Flags = ImageCreateFlags.ImageCreateMutableFormatBit Flags = ImageCreateFlags.CreateMutableFormatBit
}; };
Api Api
@ -128,7 +128,7 @@ public unsafe class VulkanImage : IDisposable
MemoryTypeIndex = (uint)VulkanMemoryHelper.FindSuitableMemoryTypeIndex( MemoryTypeIndex = (uint)VulkanMemoryHelper.FindSuitableMemoryTypeIndex(
Api, Api,
_physicalDevice, _physicalDevice,
memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.MemoryPropertyDeviceLocalBit) memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.DeviceLocalBit)
}; };
Api.AllocateMemory(_device, memoryAllocateInfo, null, Api.AllocateMemory(_device, memoryAllocateInfo, null,
@ -146,7 +146,7 @@ public unsafe class VulkanImage : IDisposable
ComponentSwizzle.Identity, ComponentSwizzle.Identity,
ComponentSwizzle.Identity); ComponentSwizzle.Identity);
AspectFlags = ImageAspectFlags.ImageAspectColorBit; AspectFlags = ImageAspectFlags.ColorBit;
var subresourceRange = new ImageSubresourceRange(AspectFlags, 0, MipLevels, 0, 1); var subresourceRange = new ImageSubresourceRange(AspectFlags, 0, MipLevels, 0, 1);
@ -154,7 +154,7 @@ public unsafe class VulkanImage : IDisposable
{ {
SType = StructureType.ImageViewCreateInfo, SType = StructureType.ImageViewCreateInfo,
Image = InternalHandle.Value, Image = InternalHandle.Value,
ViewType = ImageViewType.ImageViewType2D, ViewType = ImageViewType.Type2D,
Format = Format, Format = Format,
Components = componentMapping, Components = componentMapping,
SubresourceRange = subresourceRange SubresourceRange = subresourceRange
@ -168,7 +168,7 @@ public unsafe class VulkanImage : IDisposable
_currentLayout = ImageLayout.Undefined; _currentLayout = ImageLayout.Undefined;
TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessNoneKhr); TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.NoneKhr);
} }
public int ExportFd() public int ExportFd()

8
samples/GpuInterop/VulkanDemo/VulkanMemoryHelper.cs

@ -29,7 +29,7 @@ internal static class VulkanMemoryHelper
AccessFlags destinationAccessMask, AccessFlags destinationAccessMask,
uint mipLevels) 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 var barrier = new ImageMemoryBarrier
{ {
@ -46,8 +46,8 @@ internal static class VulkanMemoryHelper
api.CmdPipelineBarrier( api.CmdPipelineBarrier(
commandBuffer, commandBuffer,
PipelineStageFlags.PipelineStageAllCommandsBit, PipelineStageFlags.AllCommandsBit,
PipelineStageFlags.PipelineStageAllCommandsBit, PipelineStageFlags.AllCommandsBit,
0, 0,
0, 0,
null, null,
@ -56,4 +56,4 @@ internal static class VulkanMemoryHelper
1, 1,
barrier); barrier);
} }
} }

5
samples/GpuInterop/VulkanDemo/VulkanSwapchain.cs

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia; using Avalonia;
@ -7,9 +6,7 @@ using Avalonia.Platform;
using Avalonia.Rendering; using Avalonia.Rendering;
using Avalonia.Rendering.Composition; using Avalonia.Rendering.Composition;
using Avalonia.Vulkan; using Avalonia.Vulkan;
using Metsys.Bson;
using Silk.NET.Vulkan; using Silk.NET.Vulkan;
using SkiaSharp;
namespace GpuInterop.VulkanDemo; namespace GpuInterop.VulkanDemo;
@ -84,7 +81,7 @@ class VulkanSwapchainImage : ISwapchainImage
_image.TransitionLayout(buffer.InternalHandle, _image.TransitionLayout(buffer.InternalHandle,
ImageLayout.Undefined, AccessFlags.None, ImageLayout.Undefined, AccessFlags.None,
ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessColorAttachmentReadBit); ImageLayout.ColorAttachmentOptimal, AccessFlags.ColorAttachmentReadBit);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
buffer.Submit(null,null,null, null, new VulkanCommandBufferPool.VulkanCommandBuffer.KeyedMutexSubmitInfo buffer.Submit(null,null,null, null, new VulkanCommandBufferPool.VulkanCommandBuffer.KeyedMutexSubmitInfo

Loading…
Cancel
Save