Compare commits

...

2 Commits

5 changed files with 39 additions and 19 deletions

View File

@@ -981,6 +981,7 @@ namespace Ryujinx.Graphics.Vulkan
_bindingBarriersDirty = true; _bindingBarriersDirty = true;
_newState.PipelineLayout = internalProgram.PipelineLayout; _newState.PipelineLayout = internalProgram.PipelineLayout;
_newState.HasTessellationControlShader = internalProgram.HasTessellationControlShader;
_newState.StagesCount = (uint)stages.Length; _newState.StagesCount = (uint)stages.Length;
stages.CopyTo(_newState.Stages.AsSpan()[..stages.Length]); stages.CopyTo(_newState.Stages.AsSpan()[..stages.Length]);

View File

@@ -311,6 +311,7 @@ namespace Ryujinx.Graphics.Vulkan
set => Internal.Id9 = (Internal.Id9 & 0xFFFFFFFFFFFFFFBF) | ((value ? 1UL : 0UL) << 6); set => Internal.Id9 = (Internal.Id9 & 0xFFFFFFFFFFFFFFBF) | ((value ? 1UL : 0UL) << 6);
} }
public bool HasTessellationControlShader;
public NativeArray<PipelineShaderStageCreateInfo> Stages; public NativeArray<PipelineShaderStageCreateInfo> Stages;
public PipelineLayout PipelineLayout; public PipelineLayout PipelineLayout;
public SpecData SpecializationData; public SpecData SpecializationData;
@@ -319,6 +320,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Initialize() public void Initialize()
{ {
HasTessellationControlShader = false;
Stages = new NativeArray<PipelineShaderStageCreateInfo>(Constants.MaxShaderStages); Stages = new NativeArray<PipelineShaderStageCreateInfo>(Constants.MaxShaderStages);
AdvancedBlendSrcPreMultiplied = true; AdvancedBlendSrcPreMultiplied = true;
@@ -419,6 +421,15 @@ namespace Ryujinx.Graphics.Vulkan
PVertexBindingDescriptions = pVertexBindingDescriptions, PVertexBindingDescriptions = pVertexBindingDescriptions,
}; };
// Using patches topology without a tessellation shader is invalid.
// If we find such a case, return null pipeline to skip the draw.
if (Topology == PrimitiveTopology.PatchList && !HasTessellationControlShader)
{
program.AddGraphicsPipeline(ref Internal, null);
return null;
}
bool primitiveRestartEnable = PrimitiveRestartEnable; bool primitiveRestartEnable = PrimitiveRestartEnable;
bool topologySupportsRestart; bool topologySupportsRestart;

View File

@@ -122,7 +122,6 @@ namespace Ryujinx.Graphics.Vulkan
gd.Api.CreateRenderPass(device, renderPassCreateInfo, null, out var renderPass).ThrowOnError(); gd.Api.CreateRenderPass(device, renderPassCreateInfo, null, out var renderPass).ThrowOnError();
_renderPass?.Dispose();
_renderPass = new Auto<DisposableRenderPass>(new DisposableRenderPass(gd.Api, device, renderPass)); _renderPass = new Auto<DisposableRenderPass>(new DisposableRenderPass(gd.Api, device, renderPass));
} }
@@ -162,7 +161,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose() public void Dispose()
{ {
// Dispose all framebuffers // Dispose all framebuffers.
foreach (var fb in _framebuffers.Values) foreach (var fb in _framebuffers.Values)
{ {
@@ -175,6 +174,10 @@ namespace Ryujinx.Graphics.Vulkan
{ {
texture.RemoveRenderPass(_key); texture.RemoveRenderPass(_key);
} }
// Dispose render pass.
_renderPass.Dispose();
} }
} }
} }

View File

@@ -21,6 +21,7 @@ namespace Ryujinx.Graphics.Vulkan
public bool HasMinimalLayout { get; } public bool HasMinimalLayout { get; }
public bool UsePushDescriptors { get; } public bool UsePushDescriptors { get; }
public bool IsCompute { get; } public bool IsCompute { get; }
public bool HasTessellationControlShader => (Stages & (1u << 3)) != 0;
public uint Stages { get; } public uint Stages { get; }
@@ -461,6 +462,7 @@ namespace Ryujinx.Graphics.Vulkan
stages[i] = _shaders[i].GetInfo(); stages[i] = _shaders[i].GetInfo();
} }
pipeline.HasTessellationControlShader = HasTessellationControlShader;
pipeline.StagesCount = (uint)_shaders.Length; pipeline.StagesCount = (uint)_shaders.Length;
pipeline.PipelineLayout = PipelineLayout; pipeline.PipelineLayout = PipelineLayout;

View File

@@ -4,6 +4,7 @@ using Silk.NET.Vulkan;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading;
using Format = Ryujinx.Graphics.GAL.Format; using Format = Ryujinx.Graphics.GAL.Format;
using VkBuffer = Silk.NET.Vulkan.Buffer; using VkBuffer = Silk.NET.Vulkan.Buffer;
using VkFormat = Silk.NET.Vulkan.Format; using VkFormat = Silk.NET.Vulkan.Format;
@@ -36,7 +37,8 @@ namespace Ryujinx.Graphics.Vulkan
public int FirstLayer { get; } public int FirstLayer { get; }
public int FirstLevel { get; } public int FirstLevel { get; }
public VkFormat VkFormat { get; } public VkFormat VkFormat { get; }
public bool Valid { get; private set; } private int _isValid;
public bool Valid => Volatile.Read(ref _isValid) != 0;
public TextureView( public TextureView(
VulkanRenderer gd, VulkanRenderer gd,
@@ -158,7 +160,7 @@ namespace Ryujinx.Graphics.Vulkan
} }
} }
Valid = true; _isValid = 1;
} }
/// <summary> /// <summary>
@@ -178,7 +180,7 @@ namespace Ryujinx.Graphics.Vulkan
VkFormat = format; VkFormat = format;
Valid = true; _isValid = 1;
} }
public Auto<DisposableImage> GetImage() public Auto<DisposableImage> GetImage()
@@ -1017,10 +1019,11 @@ namespace Ryujinx.Graphics.Vulkan
{ {
if (disposing) if (disposing)
{ {
Valid = false; bool wasValid = Interlocked.Exchange(ref _isValid, 0) != 0;
if (wasValid)
if (_gd.Textures.Remove(this))
{ {
_gd.Textures.Remove(this);
_imageView.Dispose(); _imageView.Dispose();
_imageView2dArray?.Dispose(); _imageView2dArray?.Dispose();
@@ -1034,7 +1037,7 @@ namespace Ryujinx.Graphics.Vulkan
_imageViewDraw.Dispose(); _imageViewDraw.Dispose();
} }
Storage.DecrementViewsCount(); Storage?.DecrementViewsCount();
if (_renderPasses != null) if (_renderPasses != null)
{ {
@@ -1045,22 +1048,22 @@ namespace Ryujinx.Graphics.Vulkan
pass.Dispose(); pass.Dispose();
} }
} }
if (_selfManagedViews != null)
{
foreach (var view in _selfManagedViews.Values)
{
view.Dispose();
}
_selfManagedViews = null;
}
} }
} }
} }
public void Dispose() public void Dispose()
{ {
if (_selfManagedViews != null)
{
foreach (var view in _selfManagedViews.Values)
{
view.Dispose();
}
_selfManagedViews = null;
}
Dispose(true); Dispose(true);
} }