Browse Source

Fixed creating RenderTarget when using Vulkan backend (#20952)

* Updated VulkanContext.TryGetFeature to also provide IVulkanKhrSurfacePlatformSurfaceFactory
This also fixed creating new RenderTarget when using Vulkan backend, see issue #20824

* Prevent duplicate check if _renderTarget is null
pull/20549/merge
Andrej Benedik 3 days ago
committed by GitHub
parent
commit
7cd5d339e5
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs
  2. 6
      src/Avalonia.Vulkan/VulkanContext.cs

12
src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs

@ -149,12 +149,16 @@ namespace Avalonia.Rendering.Composition.Server
try try
{ {
if (_renderTarget == null && !_compositor.IsReadyToCreateRenderTarget(_surfaces())) if (_renderTarget == null)
{ {
IsWaitingForReadyRenderTarget = IsEnabled; if (!_compositor.IsReadyToCreateRenderTarget(_surfaces()))
return; {
IsWaitingForReadyRenderTarget = IsEnabled;
return;
}
_renderTarget = _compositor.CreateRenderTarget(_surfaces());
} }
_renderTarget ??= _compositor.CreateRenderTarget(_surfaces());
} }
catch (RenderTargetNotReadyException) catch (RenderTargetNotReadyException)
{ {

6
src/Avalonia.Vulkan/VulkanContext.cs

@ -41,6 +41,10 @@ internal class VulkanContext : IVulkanPlatformGraphicsContext
{ {
if (featureType == typeof(IVulkanContextExternalObjectsFeature)) if (featureType == typeof(IVulkanContextExternalObjectsFeature))
return _externalObjectsFeature; return _externalObjectsFeature;
if (featureType == typeof(IVulkanKhrSurfacePlatformSurfaceFactory))
return _surfaceFactory;
return null; return null;
} }
@ -71,4 +75,4 @@ internal class VulkanContext : IVulkanPlatformGraphicsContext
throw new VulkanException("Unable to find a suitable platform surface"); throw new VulkanException("Unable to find a suitable platform surface");
} }
} }

Loading…
Cancel
Save