mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-01 11:02:55 +00:00
feature: .NET 10 (ryubing/ryujinx!214)
See merge request ryubing/ryujinx!214
This commit is contained in:
@@ -368,10 +368,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
public BufferHandle GetHandle()
|
||||
public BufferHandle Handle
|
||||
{
|
||||
ulong handle = _bufferHandle;
|
||||
return Unsafe.As<ulong, BufferHandle>(ref handle);
|
||||
get
|
||||
{
|
||||
ulong handle = _bufferHandle;
|
||||
return Unsafe.As<ulong, BufferHandle>(ref handle);
|
||||
}
|
||||
}
|
||||
|
||||
public nint Map(int offset, int mappingSize)
|
||||
|
||||
@@ -158,16 +158,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
FormatFeatureFlags.TransferSrcBit |
|
||||
FormatFeatureFlags.TransferDstBit;
|
||||
|
||||
if (srcFormat.IsDepthOrStencil())
|
||||
if (srcFormat.IsDepthOrStencil)
|
||||
{
|
||||
requiredFeatures |= FormatFeatureFlags.DepthStencilAttachmentBit;
|
||||
}
|
||||
else if (srcFormat.IsRtColorCompatible())
|
||||
else if (srcFormat.IsRtColorCompatible)
|
||||
{
|
||||
requiredFeatures |= FormatFeatureFlags.ColorAttachmentBit;
|
||||
}
|
||||
|
||||
if (srcFormat.IsImageCompatible() && storageFeatureFlagRequired)
|
||||
if (srcFormat.IsImageCompatible && storageFeatureFlagRequired)
|
||||
{
|
||||
requiredFeatures |= FormatFeatureFlags.StorageImageBit;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
Format format = view.Info.Format;
|
||||
|
||||
bool isDepthStencil = format.IsDepthOrStencil();
|
||||
bool isDepthStencil = format.IsDepthOrStencil;
|
||||
|
||||
_device = device;
|
||||
_attachments = [view.GetImageViewForAttachment()];
|
||||
@@ -62,8 +62,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
AttachmentSamples = [(uint)view.Info.Samples];
|
||||
AttachmentFormats = [view.VkFormat];
|
||||
AttachmentIndices = isDepthStencil ? [] : [0];
|
||||
AttachmentIntegerFormatMask = format.IsInteger() ? 1u : 0u;
|
||||
LogicOpsAllowed = !format.IsFloatOrSrgb();
|
||||
AttachmentIntegerFormatMask = format.IsInt ? 1u : 0u;
|
||||
LogicOpsAllowed = !format.IsFloatOrSrgb;
|
||||
|
||||
AttachmentsCount = 1;
|
||||
_totalCount = 1;
|
||||
@@ -113,12 +113,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
Format format = texture.Info.Format;
|
||||
|
||||
if (format.IsInteger())
|
||||
if (format.IsInt)
|
||||
{
|
||||
attachmentIntegerFormatMask |= 1u << bindIndex;
|
||||
}
|
||||
|
||||
allFormatsFloatOrSrgb &= format.IsFloatOrSrgb();
|
||||
allFormatsFloatOrSrgb &= format.IsFloatOrSrgb;
|
||||
|
||||
width = Math.Min(width, (uint)texture.Width);
|
||||
height = Math.Min(height, (uint)texture.Height);
|
||||
@@ -250,12 +250,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
Format format = texture.Info.Format;
|
||||
|
||||
if (format.IsInteger())
|
||||
if (format.IsInt)
|
||||
{
|
||||
attachmentIntegerFormatMask |= 1u << bindIndex;
|
||||
}
|
||||
|
||||
allFormatsFloatOrSrgb &= format.IsFloatOrSrgb();
|
||||
allFormatsFloatOrSrgb &= format.IsFloatOrSrgb;
|
||||
|
||||
width = Math.Min(width, (uint)texture.Width);
|
||||
height = Math.Min(height, (uint)texture.Height);
|
||||
@@ -330,12 +330,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
Format format = _colors[index].Info.Format;
|
||||
|
||||
if (format.IsSint())
|
||||
if (format.IsSignedInt)
|
||||
{
|
||||
return ComponentType.SignedInteger;
|
||||
}
|
||||
|
||||
if (format.IsUint())
|
||||
if (format.IsUnsignedInt)
|
||||
{
|
||||
return ComponentType.UnsignedInteger;
|
||||
}
|
||||
|
||||
@@ -402,14 +402,14 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
0f,
|
||||
1f);
|
||||
|
||||
bool dstIsDepthOrStencil = dst.Info.Format.IsDepthOrStencil();
|
||||
bool dstIsDepthOrStencil = dst.Info.Format.IsDepthOrStencil;
|
||||
|
||||
if (dstIsDepthOrStencil)
|
||||
{
|
||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit);
|
||||
_pipeline.SetProgram(src.Info.Target.IsMultisample ? _programDepthBlitMs : _programDepthBlit);
|
||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
||||
}
|
||||
else if (src.Info.Target.IsMultisample())
|
||||
else if (src.Info.Target.IsMultisample)
|
||||
{
|
||||
_pipeline.SetProgram(_programColorBlitMs);
|
||||
}
|
||||
@@ -566,12 +566,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (isDepth)
|
||||
{
|
||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit);
|
||||
_pipeline.SetProgram(src.Info.Target.IsMultisample ? _programDepthBlitMs : _programDepthBlit);
|
||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
||||
}
|
||||
else
|
||||
{
|
||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programStencilBlitMs : _programStencilBlit);
|
||||
_pipeline.SetProgram(src.Info.Target.IsMultisample ? _programStencilBlitMs : _programStencilBlit);
|
||||
_pipeline.SetStencilTest(CreateStencilTestDescriptor(true));
|
||||
}
|
||||
|
||||
@@ -1047,7 +1047,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Span<int> shaderParams = stackalloc int[ParamsBufferSize / sizeof(int)];
|
||||
|
||||
int samples = src.Info.Samples;
|
||||
bool isDepthOrStencil = src.Info.Format.IsDepthOrStencil();
|
||||
bool isDepthOrStencil = src.Info.Format.IsDepthOrStencil;
|
||||
ImageAspectFlags aspectFlags = src.Info.Format.ConvertAspectFlags();
|
||||
|
||||
// X and Y are the expected texture samples.
|
||||
@@ -1173,7 +1173,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Span<int> shaderParams = stackalloc int[ParamsBufferSize / sizeof(int)];
|
||||
|
||||
int samples = dst.Info.Samples;
|
||||
bool isDepthOrStencil = src.Info.Format.IsDepthOrStencil();
|
||||
bool isDepthOrStencil = src.Info.Format.IsDepthOrStencil;
|
||||
ImageAspectFlags aspectFlags = src.Info.Format.ConvertAspectFlags();
|
||||
|
||||
// X and Y are the expected texture samples.
|
||||
|
||||
@@ -1181,7 +1181,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (!attribute.IsZero)
|
||||
{
|
||||
newVbScalarSizes[rawIndex] = Math.Max(newVbScalarSizes[rawIndex], attribute.Format.GetScalarSize());
|
||||
newVbScalarSizes[rawIndex] = Math.Max(newVbScalarSizes[rawIndex], attribute.Format.ScalarSize);
|
||||
dirtyVbSizes |= 1u << rawIndex;
|
||||
}
|
||||
|
||||
@@ -1575,7 +1575,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
// May need to enforce feedback loop layout here in the future.
|
||||
// Though technically, it should always work with the general layout.
|
||||
|
||||
if (view.Info.Format.IsDepthOrStencil())
|
||||
if (view.Info.Format.IsDepthOrStencil)
|
||||
{
|
||||
if (_passWritesDepthStencil)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
int maxColorAttachmentIndex = -1;
|
||||
|
||||
bool isNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample ||
|
||||
!state.DepthStencilFormat.IsImageCompatible();
|
||||
!state.DepthStencilFormat.IsImageCompatible;
|
||||
|
||||
Span<bool> attachmentEnableSpan = state.AttachmentEnable.AsSpan();
|
||||
Span<GALFormat> attachmentFormatsSpan = state.AttachmentFormats.AsSpan();
|
||||
@@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
if (attachmentEnableSpan[i])
|
||||
{
|
||||
bool isNotMsOrSupportsStorageAttachments = gd.Capabilities.SupportsShaderStorageImageMultisample ||
|
||||
!attachmentFormatsSpan[i].IsImageCompatible();
|
||||
!attachmentFormatsSpan[i].IsImageCompatible;
|
||||
|
||||
attachmentFormats[attachmentCount] = gd.FormatCapabilities.ConvertToVkFormat(attachmentFormatsSpan[i], isNotMsOrSupportsStorageAttachments);
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
for (int i = 0; i < attachmentCount; i++)
|
||||
{
|
||||
int bindIndex = attachmentIndices[i];
|
||||
//int bindIndex = attachmentIndices[i];
|
||||
|
||||
attachmentDescs[i] = new AttachmentDescription(
|
||||
0,
|
||||
@@ -242,7 +242,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (!attribute.IsZero && bufferIndex < vbCount)
|
||||
{
|
||||
vbScalarSizes[bufferIndex - 1] = Math.Max(attribute.Format.GetScalarSize(), vbScalarSizes[bufferIndex - 1]);
|
||||
vbScalarSizes[bufferIndex - 1] = Math.Max(attribute.Format.ScalarSize, vbScalarSizes[bufferIndex - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,23 +320,23 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
if (attachmentEnableSpan[i])
|
||||
{
|
||||
bool isNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample ||
|
||||
!attachmentFormatsSpan[i].IsImageCompatible();
|
||||
!attachmentFormatsSpan[i].IsImageCompatible;
|
||||
|
||||
pAttachmentFormatsSpan[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(attachmentFormatsSpan[i], isNotMsOrSupportsStorage);
|
||||
maxColorAttachmentIndex = i;
|
||||
|
||||
if (attachmentFormatsSpan[i].IsInteger())
|
||||
if (attachmentFormatsSpan[i].IsInt)
|
||||
{
|
||||
attachmentIntegerFormatMask |= 1u << i;
|
||||
}
|
||||
|
||||
allFormatsFloatOrSrgb &= attachmentFormatsSpan[i].IsFloatOrSrgb();
|
||||
allFormatsFloatOrSrgb &= attachmentFormatsSpan[i].IsFloatOrSrgb;
|
||||
}
|
||||
}
|
||||
|
||||
if (state.DepthStencilEnable)
|
||||
{
|
||||
bool isNotMsOrSupportsStorage = !state.DepthStencilFormat.IsImageCompatible() ||
|
||||
bool isNotMsOrSupportsStorage = !state.DepthStencilFormat.IsImageCompatible ||
|
||||
gd.Capabilities.SupportsShaderStorageImageMultisample;
|
||||
|
||||
pAttachmentFormatsSpan[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, isNotMsOrSupportsStorage);
|
||||
|
||||
@@ -647,7 +647,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
result.ThrowOnError();
|
||||
}
|
||||
else if (result.IsError())
|
||||
else if (result.IsError)
|
||||
{
|
||||
program.AddGraphicsPipeline(ref Internal, null);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
ImageBlit.SrcOffsetsBuffer srcOffsets = new();
|
||||
ImageBlit.DstOffsetsBuffer dstOffsets = new();
|
||||
|
||||
Filter filter = linearFilter && !dstInfo.Format.IsDepthOrStencil() ? Filter.Linear : Filter.Nearest;
|
||||
Filter filter = linearFilter && !dstInfo.Format.IsDepthOrStencil ? Filter.Linear : Filter.Nearest;
|
||||
|
||||
TextureView.InsertImageBarrier(
|
||||
api,
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_device = device;
|
||||
_info = info;
|
||||
|
||||
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample();
|
||||
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample;
|
||||
|
||||
VkFormat format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported);
|
||||
uint levels = (uint)info.Levels;
|
||||
@@ -311,16 +311,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
ImageUsageFlags usage = DefaultUsageFlags;
|
||||
|
||||
if (format.IsDepthOrStencil())
|
||||
if (format.IsDepthOrStencil)
|
||||
{
|
||||
usage |= ImageUsageFlags.DepthStencilAttachmentBit;
|
||||
}
|
||||
else if (format.IsRtColorCompatible())
|
||||
else if (format.IsRtColorCompatible)
|
||||
{
|
||||
usage |= ImageUsageFlags.ColorAttachmentBit;
|
||||
}
|
||||
|
||||
if ((format.IsImageCompatible() && isMsImageStorageSupported) || extendedUsage)
|
||||
if ((format.IsImageCompatible && isMsImageStorageSupported) || extendedUsage)
|
||||
{
|
||||
usage |= ImageUsageFlags.StorageBit;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
gd.Textures.Add(this);
|
||||
|
||||
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample();
|
||||
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample;
|
||||
|
||||
VkFormat format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported);
|
||||
ImageUsageFlags usage = TextureStorage.GetImageUsage(info.Format, gd.Capabilities, isMsImageStorageSupported, false);
|
||||
@@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
ImageUsageFlags shaderUsage = ImageUsageFlags.SampledBit;
|
||||
|
||||
if (info.Format.IsImageCompatible() && (_gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample()))
|
||||
if (info.Format.IsImageCompatible && (_gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample))
|
||||
{
|
||||
shaderUsage |= ImageUsageFlags.StorageBit;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
if (gd.Capabilities.PortabilitySubset.HasFlag(PortabilitySubsetFlags.No3DImageView))
|
||||
{
|
||||
if (levels == 1 && (info.Format.IsRtColorCompatible() || info.Format.IsDepthOrStencil()))
|
||||
if (levels == 1 && (info.Format.IsRtColorCompatible || info.Format.IsDepthOrStencil))
|
||||
{
|
||||
subresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, levels, (uint)firstLayer, 1);
|
||||
|
||||
@@ -225,12 +225,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Image srcImage = src.GetImage().Get(cbs).Value;
|
||||
Image dstImage = dst.GetImage().Get(cbs).Value;
|
||||
|
||||
if (!dst.Info.Target.IsMultisample() && Info.Target.IsMultisample())
|
||||
if (!dst.Info.Target.IsMultisample && Info.Target.IsMultisample)
|
||||
{
|
||||
int layers = Math.Min(Info.GetLayers(), dst.Info.GetLayers() - firstLayer);
|
||||
_gd.HelperShader.CopyMSToNonMS(_gd, cbs, src, dst, 0, firstLayer, layers);
|
||||
}
|
||||
else if (dst.Info.Target.IsMultisample() && !Info.Target.IsMultisample())
|
||||
else if (dst.Info.Target.IsMultisample && !Info.Target.IsMultisample)
|
||||
{
|
||||
int layers = Math.Min(Info.GetLayers(), dst.Info.GetLayers() - firstLayer);
|
||||
_gd.HelperShader.CopyNonMSToMS(_gd, cbs, src, dst, 0, firstLayer, layers);
|
||||
@@ -241,7 +241,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
int levels = Math.Min(Info.Levels, dst.Info.Levels - firstLevel);
|
||||
_gd.HelperShader.CopyIncompatibleFormats(_gd, cbs, src, dst, 0, firstLayer, 0, firstLevel, layers, levels);
|
||||
}
|
||||
else if (src.Info.Format.IsDepthOrStencil() != dst.Info.Format.IsDepthOrStencil())
|
||||
else if (src.Info.Format.IsDepthOrStencil != dst.Info.Format.IsDepthOrStencil)
|
||||
{
|
||||
int layers = Math.Min(Info.GetLayers(), dst.Info.GetLayers() - firstLayer);
|
||||
int levels = Math.Min(Info.Levels, dst.Info.Levels - firstLevel);
|
||||
@@ -285,11 +285,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Image srcImage = src.GetImage().Get(cbs).Value;
|
||||
Image dstImage = dst.GetImage().Get(cbs).Value;
|
||||
|
||||
if (!dst.Info.Target.IsMultisample() && Info.Target.IsMultisample())
|
||||
if (!dst.Info.Target.IsMultisample && Info.Target.IsMultisample)
|
||||
{
|
||||
_gd.HelperShader.CopyMSToNonMS(_gd, cbs, src, dst, srcLayer, dstLayer, 1);
|
||||
}
|
||||
else if (dst.Info.Target.IsMultisample() && !Info.Target.IsMultisample())
|
||||
else if (dst.Info.Target.IsMultisample && !Info.Target.IsMultisample)
|
||||
{
|
||||
_gd.HelperShader.CopyNonMSToMS(_gd, cbs, src, dst, srcLayer, dstLayer, 1);
|
||||
}
|
||||
@@ -297,7 +297,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
_gd.HelperShader.CopyIncompatibleFormats(_gd, cbs, src, dst, srcLayer, dstLayer, srcLevel, dstLevel, 1, 1);
|
||||
}
|
||||
else if (src.Info.Format.IsDepthOrStencil() != dst.Info.Format.IsDepthOrStencil())
|
||||
else if (src.Info.Format.IsDepthOrStencil != dst.Info.Format.IsDepthOrStencil)
|
||||
{
|
||||
_gd.HelperShader.CopyColor(_gd, cbs, src, dst, srcLayer, dstLayer, srcLevel, dstLevel, 1, 1);
|
||||
}
|
||||
@@ -370,7 +370,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
src.Height == dst.Height &&
|
||||
src.VkFormat == dst.VkFormat)
|
||||
{
|
||||
if (src.Info.Samples > 1 && src.Info.Samples != dst.Info.Samples && src.Info.Format.IsDepthOrStencil())
|
||||
if (src.Info.Samples > 1 && src.Info.Samples != dst.Info.Samples && src.Info.Format.IsDepthOrStencil)
|
||||
{
|
||||
// CmdResolveImage does not support depth-stencil resolve, so we need to use an alternative path
|
||||
// for those textures.
|
||||
@@ -424,7 +424,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
bool isDepthOrStencil = dst.Info.Format.IsDepthOrStencil();
|
||||
bool isDepthOrStencil = dst.Info.Format.IsDepthOrStencil;
|
||||
|
||||
if (!VulkanConfiguration.UseUnsafeBlit || (_gd.Vendor != Vendor.Nvidia && _gd.Vendor != Vendor.Intel))
|
||||
{
|
||||
|
||||
@@ -5,18 +5,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
static class ResultExtensions
|
||||
{
|
||||
public static bool IsError(this Result result)
|
||||
extension(Result result)
|
||||
{
|
||||
// Only negative result codes are errors.
|
||||
return result < Result.Success;
|
||||
}
|
||||
public bool IsError => result < Result.Success;
|
||||
|
||||
public static void ThrowOnError(this Result result)
|
||||
{
|
||||
// Only negative result codes are errors.
|
||||
if (result.IsError())
|
||||
public void ThrowOnError()
|
||||
{
|
||||
throw new VulkanException(result);
|
||||
// Only negative result codes are errors.
|
||||
if (result.IsError)
|
||||
{
|
||||
throw new VulkanException(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
cbs = _gd.CommandBufferPool.Rent();
|
||||
}
|
||||
|
||||
CaptureFrame(view, srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0, view.Info.Format.IsBgr(), crop.FlipX, crop.FlipY);
|
||||
CaptureFrame(view, srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0, view.Info.Format.IsBgr, crop.FlipX, crop.FlipY);
|
||||
|
||||
ScreenCaptureRequested = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user