mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-30 06:26:25 +02:00
misc: chore: Use explicit types in Vulkan project
This commit is contained in:
parent
e6b393e420
commit
2d1a4c3ce5
58 changed files with 682 additions and 667 deletions
|
@ -63,20 +63,20 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample();
|
||||
|
||||
var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported);
|
||||
var usage = TextureStorage.GetImageUsage(info.Format, gd.Capabilities, isMsImageStorageSupported, false);
|
||||
VkFormat format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported);
|
||||
ImageUsageFlags usage = TextureStorage.GetImageUsage(info.Format, gd.Capabilities, isMsImageStorageSupported, false);
|
||||
|
||||
var levels = (uint)info.Levels;
|
||||
var layers = (uint)info.GetLayers();
|
||||
uint levels = (uint)info.Levels;
|
||||
uint layers = (uint)info.GetLayers();
|
||||
|
||||
VkFormat = format;
|
||||
|
||||
var type = info.Target.ConvertView();
|
||||
ImageViewType type = info.Target.ConvertView();
|
||||
|
||||
var swizzleR = info.SwizzleR.Convert();
|
||||
var swizzleG = info.SwizzleG.Convert();
|
||||
var swizzleB = info.SwizzleB.Convert();
|
||||
var swizzleA = info.SwizzleA.Convert();
|
||||
ComponentSwizzle swizzleR = info.SwizzleR.Convert();
|
||||
ComponentSwizzle swizzleG = info.SwizzleG.Convert();
|
||||
ComponentSwizzle swizzleB = info.SwizzleB.Convert();
|
||||
ComponentSwizzle swizzleA = info.SwizzleA.Convert();
|
||||
|
||||
if (info.Format == Format.R5G5B5A1Unorm ||
|
||||
info.Format == Format.R5G5B5X1Unorm ||
|
||||
|
@ -86,8 +86,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
}
|
||||
else if (VkFormat == VkFormat.R4G4B4A4UnormPack16 || info.Format == Format.A1B5G5R5Unorm)
|
||||
{
|
||||
var tempB = swizzleB;
|
||||
var tempA = swizzleA;
|
||||
ComponentSwizzle tempB = swizzleB;
|
||||
ComponentSwizzle tempA = swizzleA;
|
||||
|
||||
swizzleB = swizzleG;
|
||||
swizzleA = swizzleR;
|
||||
|
@ -95,23 +95,23 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
swizzleG = tempB;
|
||||
}
|
||||
|
||||
var componentMapping = new ComponentMapping(swizzleR, swizzleG, swizzleB, swizzleA);
|
||||
ComponentMapping componentMapping = new ComponentMapping(swizzleR, swizzleG, swizzleB, swizzleA);
|
||||
|
||||
var aspectFlags = info.Format.ConvertAspectFlags(info.DepthStencilMode);
|
||||
var aspectFlagsDepth = info.Format.ConvertAspectFlags();
|
||||
ImageAspectFlags aspectFlags = info.Format.ConvertAspectFlags(info.DepthStencilMode);
|
||||
ImageAspectFlags aspectFlagsDepth = info.Format.ConvertAspectFlags();
|
||||
|
||||
var subresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, levels, (uint)firstLayer, layers);
|
||||
var subresourceRangeDepth = new ImageSubresourceRange(aspectFlagsDepth, (uint)firstLevel, levels, (uint)firstLayer, layers);
|
||||
ImageSubresourceRange subresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, levels, (uint)firstLayer, layers);
|
||||
ImageSubresourceRange subresourceRangeDepth = new ImageSubresourceRange(aspectFlagsDepth, (uint)firstLevel, levels, (uint)firstLayer, layers);
|
||||
|
||||
unsafe Auto<DisposableImageView> CreateImageView(ComponentMapping cm, ImageSubresourceRange sr, ImageViewType viewType, ImageUsageFlags usageFlags)
|
||||
{
|
||||
var imageViewUsage = new ImageViewUsageCreateInfo
|
||||
ImageViewUsageCreateInfo imageViewUsage = new ImageViewUsageCreateInfo
|
||||
{
|
||||
SType = StructureType.ImageViewUsageCreateInfo,
|
||||
Usage = usageFlags,
|
||||
};
|
||||
|
||||
var imageCreateInfo = new ImageViewCreateInfo
|
||||
ImageViewCreateInfo imageCreateInfo = new ImageViewCreateInfo
|
||||
{
|
||||
SType = StructureType.ImageViewCreateInfo,
|
||||
Image = storage.GetImageForViewCreation(),
|
||||
|
@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
PNext = &imageViewUsage,
|
||||
};
|
||||
|
||||
gd.Api.CreateImageView(device, in imageCreateInfo, null, out var imageView).ThrowOnError();
|
||||
gd.Api.CreateImageView(device, in imageCreateInfo, null, out ImageView imageView).ThrowOnError();
|
||||
return new Auto<DisposableImageView>(new DisposableImageView(gd.Api, device, imageView), null, storage.GetImage());
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
_imageView = CreateImageView(componentMapping, subresourceRange, type, shaderUsage);
|
||||
|
||||
// Framebuffer attachments and storage images requires a identity component mapping.
|
||||
var identityComponentMapping = new ComponentMapping(
|
||||
ComponentMapping identityComponentMapping = new ComponentMapping(
|
||||
ComponentSwizzle.R,
|
||||
ComponentSwizzle.G,
|
||||
ComponentSwizzle.B,
|
||||
|
@ -210,8 +210,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
public void CopyTo(ITexture destination, int firstLayer, int firstLevel)
|
||||
{
|
||||
var src = this;
|
||||
var dst = (TextureView)destination;
|
||||
TextureView src = this;
|
||||
TextureView dst = (TextureView)destination;
|
||||
|
||||
if (!Valid || !dst.Valid)
|
||||
{
|
||||
|
@ -220,10 +220,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
_gd.PipelineInternal.EndRenderPass();
|
||||
|
||||
var cbs = _gd.PipelineInternal.CurrentCommandBuffer;
|
||||
CommandBufferScoped cbs = _gd.PipelineInternal.CurrentCommandBuffer;
|
||||
|
||||
var srcImage = src.GetImage().Get(cbs).Value;
|
||||
var dstImage = dst.GetImage().Get(cbs).Value;
|
||||
Image srcImage = src.GetImage().Get(cbs).Value;
|
||||
Image dstImage = dst.GetImage().Get(cbs).Value;
|
||||
|
||||
if (!dst.Info.Target.IsMultisample() && Info.Target.IsMultisample())
|
||||
{
|
||||
|
@ -270,8 +270,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
public void CopyTo(ITexture destination, int srcLayer, int dstLayer, int srcLevel, int dstLevel)
|
||||
{
|
||||
var src = this;
|
||||
var dst = (TextureView)destination;
|
||||
TextureView src = this;
|
||||
TextureView dst = (TextureView)destination;
|
||||
|
||||
if (!Valid || !dst.Valid)
|
||||
{
|
||||
|
@ -280,10 +280,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
_gd.PipelineInternal.EndRenderPass();
|
||||
|
||||
var cbs = _gd.PipelineInternal.CurrentCommandBuffer;
|
||||
CommandBufferScoped cbs = _gd.PipelineInternal.CurrentCommandBuffer;
|
||||
|
||||
var srcImage = src.GetImage().Get(cbs).Value;
|
||||
var dstImage = dst.GetImage().Get(cbs).Value;
|
||||
Image srcImage = src.GetImage().Get(cbs).Value;
|
||||
Image dstImage = dst.GetImage().Get(cbs).Value;
|
||||
|
||||
if (!dst.Info.Target.IsMultisample() && Info.Target.IsMultisample())
|
||||
{
|
||||
|
@ -325,21 +325,21 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
public void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter)
|
||||
{
|
||||
var dst = (TextureView)destination;
|
||||
TextureView dst = (TextureView)destination;
|
||||
|
||||
if (_gd.CommandBufferPool.OwnedByCurrentThread)
|
||||
{
|
||||
_gd.PipelineInternal.EndRenderPass();
|
||||
|
||||
var cbs = _gd.PipelineInternal.CurrentCommandBuffer;
|
||||
CommandBufferScoped cbs = _gd.PipelineInternal.CurrentCommandBuffer;
|
||||
|
||||
CopyToImpl(cbs, dst, srcRegion, dstRegion, linearFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cbp = _gd.BackgroundResources.Get().GetPool();
|
||||
CommandBufferPool cbp = _gd.BackgroundResources.Get().GetPool();
|
||||
|
||||
using var cbs = cbp.Rent();
|
||||
using CommandBufferScoped cbs = cbp.Rent();
|
||||
|
||||
CopyToImpl(cbs, dst, srcRegion, dstRegion, linearFilter);
|
||||
}
|
||||
|
@ -347,10 +347,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
private void CopyToImpl(CommandBufferScoped cbs, TextureView dst, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter)
|
||||
{
|
||||
var src = this;
|
||||
TextureView src = this;
|
||||
|
||||
var srcFormat = GetCompatibleGalFormat(src.Info.Format);
|
||||
var dstFormat = GetCompatibleGalFormat(dst.Info.Format);
|
||||
Format srcFormat = GetCompatibleGalFormat(src.Info.Format);
|
||||
Format dstFormat = GetCompatibleGalFormat(dst.Info.Format);
|
||||
|
||||
bool srcUsesStorageFormat = src.VkFormat == src.Storage.VkFormat;
|
||||
bool dstUsesStorageFormat = dst.VkFormat == dst.Storage.VkFormat;
|
||||
|
@ -572,7 +572,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
return this;
|
||||
}
|
||||
|
||||
if (_selfManagedViews != null && _selfManagedViews.TryGetValue(format, out var view))
|
||||
if (_selfManagedViews != null && _selfManagedViews.TryGetValue(format, out TextureView view))
|
||||
{
|
||||
return view;
|
||||
}
|
||||
|
@ -612,12 +612,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
public byte[] GetData(int x, int y, int width, int height)
|
||||
{
|
||||
int size = width * height * Info.BytesPerPixel;
|
||||
using var bufferHolder = _gd.BufferManager.Create(_gd, size);
|
||||
using BufferHolder bufferHolder = _gd.BufferManager.Create(_gd, size);
|
||||
|
||||
using (var cbs = _gd.CommandBufferPool.Rent())
|
||||
using (CommandBufferScoped cbs = _gd.CommandBufferPool.Rent())
|
||||
{
|
||||
var buffer = bufferHolder.GetBuffer(cbs.CommandBuffer).Get(cbs).Value;
|
||||
var image = GetImage().Get(cbs).Value;
|
||||
VkBuffer buffer = bufferHolder.GetBuffer(cbs.CommandBuffer).Get(cbs).Value;
|
||||
Image image = GetImage().Get(cbs).Value;
|
||||
|
||||
CopyFromOrToBuffer(cbs.CommandBuffer, buffer, image, size, true, 0, 0, x, y, width, height);
|
||||
}
|
||||
|
@ -659,12 +659,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
public void CopyTo(BufferRange range, int layer, int level, int stride)
|
||||
{
|
||||
_gd.PipelineInternal.EndRenderPass();
|
||||
var cbs = _gd.PipelineInternal.CurrentCommandBuffer;
|
||||
CommandBufferScoped cbs = _gd.PipelineInternal.CurrentCommandBuffer;
|
||||
|
||||
int outSize = Info.GetMipSize(level);
|
||||
int hostSize = GetBufferDataLength(outSize);
|
||||
|
||||
var image = GetImage().Get(cbs).Value;
|
||||
Image image = GetImage().Get(cbs).Value;
|
||||
int offset = range.Offset;
|
||||
|
||||
Auto<DisposableBuffer> autoBuffer = _gd.BufferManager.GetBuffer(cbs.CommandBuffer, range.Handle, true);
|
||||
|
@ -773,7 +773,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
{
|
||||
int bufferDataLength = GetBufferDataLength(data.Length);
|
||||
|
||||
using var bufferHolder = _gd.BufferManager.Create(_gd, bufferDataLength);
|
||||
using BufferHolder bufferHolder = _gd.BufferManager.Create(_gd, bufferDataLength);
|
||||
|
||||
Auto<DisposableImage> imageAuto = GetImage();
|
||||
|
||||
|
@ -781,7 +781,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
bool loadInline = Storage.HasCommandBufferDependency(_gd.PipelineInternal.CurrentCommandBuffer);
|
||||
|
||||
var cbs = loadInline ? _gd.PipelineInternal.CurrentCommandBuffer : _gd.PipelineInternal.GetPreloadCommandBuffer();
|
||||
CommandBufferScoped cbs = loadInline ? _gd.PipelineInternal.CurrentCommandBuffer : _gd.PipelineInternal.GetPreloadCommandBuffer();
|
||||
|
||||
if (loadInline)
|
||||
{
|
||||
|
@ -790,8 +790,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
CopyDataToBuffer(bufferHolder.GetDataStorage(0, bufferDataLength), data);
|
||||
|
||||
var buffer = bufferHolder.GetBuffer(cbs.CommandBuffer).Get(cbs).Value;
|
||||
var image = imageAuto.Get(cbs).Value;
|
||||
VkBuffer buffer = bufferHolder.GetBuffer(cbs.CommandBuffer).Get(cbs).Value;
|
||||
Image image = imageAuto.Get(cbs).Value;
|
||||
|
||||
if (region.HasValue)
|
||||
{
|
||||
|
@ -927,24 +927,24 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
int rowLength = ((stride == 0 ? Info.GetMipStride(dstLevel + level) : stride) / Info.BytesPerPixel) * Info.BlockWidth;
|
||||
|
||||
var aspectFlags = Info.Format.ConvertAspectFlags();
|
||||
ImageAspectFlags aspectFlags = Info.Format.ConvertAspectFlags();
|
||||
|
||||
if (aspectFlags == (ImageAspectFlags.DepthBit | ImageAspectFlags.StencilBit))
|
||||
{
|
||||
aspectFlags = ImageAspectFlags.DepthBit;
|
||||
}
|
||||
|
||||
var sl = new ImageSubresourceLayers(
|
||||
ImageSubresourceLayers sl = new ImageSubresourceLayers(
|
||||
aspectFlags,
|
||||
(uint)(FirstLevel + dstLevel + level),
|
||||
(uint)(FirstLayer + layer),
|
||||
(uint)layers);
|
||||
|
||||
var extent = new Extent3D((uint)width, (uint)height, (uint)depth);
|
||||
Extent3D extent = new Extent3D((uint)width, (uint)height, (uint)depth);
|
||||
|
||||
int z = is3D ? dstLayer : 0;
|
||||
|
||||
var region = new BufferImageCopy(
|
||||
BufferImageCopy region = new BufferImageCopy(
|
||||
(ulong)offset,
|
||||
(uint)AlignUpNpot(rowLength, Info.BlockWidth),
|
||||
(uint)AlignUpNpot(height, Info.BlockHeight),
|
||||
|
@ -986,16 +986,16 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
int width,
|
||||
int height)
|
||||
{
|
||||
var aspectFlags = Info.Format.ConvertAspectFlags();
|
||||
ImageAspectFlags aspectFlags = Info.Format.ConvertAspectFlags();
|
||||
|
||||
if (aspectFlags == (ImageAspectFlags.DepthBit | ImageAspectFlags.StencilBit))
|
||||
{
|
||||
aspectFlags = ImageAspectFlags.DepthBit;
|
||||
}
|
||||
|
||||
var sl = new ImageSubresourceLayers(aspectFlags, (uint)(FirstLevel + dstLevel), (uint)(FirstLayer + dstLayer), 1);
|
||||
ImageSubresourceLayers sl = new ImageSubresourceLayers(aspectFlags, (uint)(FirstLevel + dstLevel), (uint)(FirstLayer + dstLayer), 1);
|
||||
|
||||
var extent = new Extent3D((uint)width, (uint)height, 1);
|
||||
Extent3D extent = new Extent3D((uint)width, (uint)height, 1);
|
||||
|
||||
int rowLengthAlignment = Info.BlockWidth;
|
||||
|
||||
|
@ -1005,7 +1005,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
rowLengthAlignment = 4 / Info.BytesPerPixel;
|
||||
}
|
||||
|
||||
var region = new BufferImageCopy(
|
||||
BufferImageCopy region = new BufferImageCopy(
|
||||
0,
|
||||
(uint)AlignUpNpot(width, rowLengthAlignment),
|
||||
(uint)AlignUpNpot(height, Info.BlockHeight),
|
||||
|
@ -1073,7 +1073,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
CommandBufferScoped cbs,
|
||||
FramebufferParams fb)
|
||||
{
|
||||
var key = fb.GetRenderPassCacheKey();
|
||||
RenderPassCacheKey key = fb.GetRenderPassCacheKey();
|
||||
|
||||
if (_renderPasses == null || !_renderPasses.TryGetValue(ref key, out RenderPassHolder rpHolder))
|
||||
{
|
||||
|
@ -1121,9 +1121,9 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
if (_renderPasses != null)
|
||||
{
|
||||
var renderPasses = _renderPasses.Values.ToArray();
|
||||
RenderPassHolder[] renderPasses = _renderPasses.Values.ToArray();
|
||||
|
||||
foreach (var pass in renderPasses)
|
||||
foreach (RenderPassHolder pass in renderPasses)
|
||||
{
|
||||
pass.Dispose();
|
||||
}
|
||||
|
@ -1131,7 +1131,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
if (_selfManagedViews != null)
|
||||
{
|
||||
foreach (var view in _selfManagedViews.Values)
|
||||
foreach (TextureView view in _selfManagedViews.Values)
|
||||
{
|
||||
view.Dispose();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue