Skip to content

Commit 7cd5d33

Browse files
authored
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
1 parent f16fcab commit 7cd5d33

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,16 @@ public void Render()
149149

150150
try
151151
{
152-
if (_renderTarget == null && !_compositor.IsReadyToCreateRenderTarget(_surfaces()))
152+
if (_renderTarget == null)
153153
{
154-
IsWaitingForReadyRenderTarget = IsEnabled;
155-
return;
154+
if (!_compositor.IsReadyToCreateRenderTarget(_surfaces()))
155+
{
156+
IsWaitingForReadyRenderTarget = IsEnabled;
157+
return;
158+
}
159+
160+
_renderTarget = _compositor.CreateRenderTarget(_surfaces());
156161
}
157-
_renderTarget ??= _compositor.CreateRenderTarget(_surfaces());
158162
}
159163
catch (RenderTargetNotReadyException)
160164
{

src/Avalonia.Vulkan/VulkanContext.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public void Dispose()
4141
{
4242
if (featureType == typeof(IVulkanContextExternalObjectsFeature))
4343
return _externalObjectsFeature;
44+
45+
if (featureType == typeof(IVulkanKhrSurfacePlatformSurfaceFactory))
46+
return _surfaceFactory;
47+
4448
return null;
4549
}
4650

@@ -71,4 +75,4 @@ public IVulkanRenderTarget CreateRenderTarget(IEnumerable<IPlatformRenderSurface
7175

7276
throw new VulkanException("Unable to find a suitable platform surface");
7377
}
74-
}
78+
}

0 commit comments

Comments
 (0)