aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Backend/Vulkan/Surfaces/VulkanSurfaceRenderTarget.cs
diff options
context:
space:
mode:
authorEmmanuel Hansen <emmausssss@gmail.com>2022-09-19 18:05:26 +0000
committerGitHub <noreply@github.com>2022-09-19 15:05:26 -0300
commit6f0395538b8e8af3bba7536b44780d57e51e8697 (patch)
tree4d3f4f620dd287fc1ca38ea9ea722b6e022301dd /Ryujinx.Ava/Ui/Backend/Vulkan/Surfaces/VulkanSurfaceRenderTarget.cs
parentb9f1ff3c7748c6a2665e76d17e86c3b7228f44fe (diff)
Avalonia - Use embedded window for avalonia (#3674)1.1.274
* wip * use embedded window * fix race condition on opengl Windows * fix glx issues on prime nvidia * fix mouse support win32 * clean up * addressed review * addressed review * fix warnings * fix sotware keyboard dialog * Update Ryujinx.Ava/Ui/Applet/SwkbdAppletDialog.axaml.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> * remove double semi Co-authored-by: gdkchan <gab.dark.100@gmail.com>
Diffstat (limited to 'Ryujinx.Ava/Ui/Backend/Vulkan/Surfaces/VulkanSurfaceRenderTarget.cs')
-rw-r--r--Ryujinx.Ava/Ui/Backend/Vulkan/Surfaces/VulkanSurfaceRenderTarget.cs134
1 files changed, 0 insertions, 134 deletions
diff --git a/Ryujinx.Ava/Ui/Backend/Vulkan/Surfaces/VulkanSurfaceRenderTarget.cs b/Ryujinx.Ava/Ui/Backend/Vulkan/Surfaces/VulkanSurfaceRenderTarget.cs
deleted file mode 100644
index 510e6724..00000000
--- a/Ryujinx.Ava/Ui/Backend/Vulkan/Surfaces/VulkanSurfaceRenderTarget.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using Avalonia;
-using Ryujinx.Graphics.Vulkan;
-using Silk.NET.Vulkan;
-
-namespace Ryujinx.Ava.Ui.Vulkan.Surfaces
-{
- internal class VulkanSurfaceRenderTarget : IDisposable
- {
- private readonly VulkanPlatformInterface _platformInterface;
- private readonly Format _format;
-
- private VulkanCommandBufferPool.VulkanCommandBuffer _commandBuffer;
- private VulkanImage Image { get; set; }
- private object _lock = new object();
-
- public uint MipLevels => Image.MipLevels;
- public VulkanDevice Device { get; }
-
- public VulkanSurfaceRenderTarget(VulkanPlatformInterface platformInterface, VulkanSurface surface)
- {
- _platformInterface = platformInterface;
-
- var device = VulkanInitialization.CreateDevice(platformInterface.Api,
- platformInterface.PhysicalDevice.InternalHandle,
- platformInterface.PhysicalDevice.QueueFamilyIndex,
- VulkanInitialization.GetSupportedExtensions(platformInterface.Api, platformInterface.PhysicalDevice.InternalHandle),
- platformInterface.PhysicalDevice.QueueCount);
-
- Device = new VulkanDevice(device, platformInterface.PhysicalDevice, platformInterface.Api);
-
- Display = VulkanDisplay.CreateDisplay(
- platformInterface.Instance,
- Device,
- platformInterface.PhysicalDevice,
- surface);
- Surface = surface;
-
- // Skia seems to only create surfaces from images with unorm format
- IsRgba = Display.SurfaceFormat.Format >= Format.R8G8B8A8Unorm &&
- Display.SurfaceFormat.Format <= Format.R8G8B8A8Srgb;
-
- _format = IsRgba ? Format.R8G8B8A8Unorm : Format.B8G8R8A8Unorm;
- }
-
- public bool IsRgba { get; }
-
- public uint ImageFormat => (uint)_format;
-
- public ulong MemorySize => Image.MemorySize;
-
- public VulkanDisplay Display { get; private set; }
-
- public VulkanSurface Surface { get; private set; }
-
- public uint UsageFlags => Image.UsageFlags;
-
- public PixelSize Size { get; private set; }
-
- public void Dispose()
- {
- lock (_lock)
- {
- DestroyImage();
- Display?.Dispose();
- Surface?.Dispose();
- Device?.Dispose();
-
- Display = null;
- Surface = null;
- }
- }
-
- public VulkanSurfaceRenderingSession BeginDraw(float scaling)
- {
- if (Image == null)
- {
- RecreateImage();
- }
-
- _commandBuffer?.WaitForFence();
- _commandBuffer = null;
-
- var session = new VulkanSurfaceRenderingSession(Display, Device, this, scaling);
-
- Image.TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessNoneKhr);
-
- return session;
- }
-
- public void RecreateImage()
- {
- DestroyImage();
- CreateImage();
- }
-
- private void CreateImage()
- {
- Size = Display.Size;
-
- Image = new VulkanImage(Device, _platformInterface.PhysicalDevice, Display.CommandBufferPool, ImageFormat, Size);
- }
-
- private void DestroyImage()
- {
- _commandBuffer?.WaitForFence();
- _commandBuffer = null;
- Image?.Dispose();
- Image = null;
- }
-
- public VulkanImage GetImage()
- {
- return Image;
- }
-
- public void EndDraw()
- {
- lock (_lock)
- {
- if (Display == null)
- {
- return;
- }
-
- _commandBuffer = Display.StartPresentation();
-
- Display.BlitImageToCurrentImage(this, _commandBuffer.InternalHandle);
-
- Display.EndPresentation(_commandBuffer);
- }
- }
- }
-}