mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-09-20 09:41:14 +02:00
Fix errors in 88cef7e8: misc: chore: Use explicit types & fix object creation
This commit is contained in:
@@ -560,7 +560,7 @@ namespace LibKenjinx
|
||||
_surfacePtr = Interop.GetSurfacePtr();
|
||||
_window = Interop.GetWindowsHandle();
|
||||
|
||||
Vk? api = VulkanLoader?.GetApi() ?? Vk.GetApi();
|
||||
Vk api = VulkanLoader?.GetApi() ?? Vk.GetApi();
|
||||
if (api.TryGetInstanceExtension(new Instance(instance), out KhrAndroidSurface surfaceExtension))
|
||||
{
|
||||
AndroidSurfaceCreateInfoKHR createInfo = new()
|
||||
@@ -569,7 +569,7 @@ namespace LibKenjinx
|
||||
Window = (nint*)_surfacePtr,
|
||||
};
|
||||
|
||||
Result result = surfaceExtension.CreateAndroidSurface(new Instance(instance), in createInfo, null, out SurfaceKHR* surface);
|
||||
Result result = surfaceExtension.CreateAndroidSurface(new Instance(instance), in createInfo, null, out SurfaceKHR surface);
|
||||
|
||||
// If a rotation was applied before the surface was created → apply it now
|
||||
if (_window != 0 && _pendingRotationDegrees != -1)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// State class for the library
|
||||
using Gommon;
|
||||
using LibHac;
|
||||
using LibHac.Account;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Ns;
|
||||
using LibHac.Tools.Fs;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
@@ -42,6 +42,7 @@ using System.Text;
|
||||
using System.Text.Json;
|
||||
using ApplicationId = LibHac.Ncm.ApplicationId;
|
||||
using Path = System.IO.Path;
|
||||
using Result = LibHac.Result;
|
||||
using VSyncMode = Ryujinx.Common.Configuration.VSyncMode;
|
||||
|
||||
namespace LibKenjinx
|
||||
@@ -109,7 +110,7 @@ namespace LibKenjinx
|
||||
{
|
||||
return new GameStats();
|
||||
}
|
||||
Switch? context = SwitchDevice.EmulationContext;
|
||||
Switch context = SwitchDevice.EmulationContext;
|
||||
|
||||
return new GameStats
|
||||
{
|
||||
@@ -362,7 +363,7 @@ namespace LibKenjinx
|
||||
|
||||
if (string.IsNullOrWhiteSpace(titleName))
|
||||
{
|
||||
foreach (ref readonly var controlTitle in controlData.Title)
|
||||
foreach (ref readonly ApplicationControlProperty.ApplicationTitle controlTitle in controlData.Title)
|
||||
{
|
||||
if (!controlTitle.NameString.IsEmpty())
|
||||
{
|
||||
@@ -375,7 +376,7 @@ namespace LibKenjinx
|
||||
|
||||
if (string.IsNullOrWhiteSpace(publisher))
|
||||
{
|
||||
foreach (ref readonly var controlTitle in controlData.Title)
|
||||
foreach (ref readonly ApplicationControlProperty.ApplicationTitle controlTitle in controlData.Title)
|
||||
{
|
||||
if (!controlTitle.PublisherString.IsEmpty())
|
||||
{
|
||||
@@ -1203,14 +1204,14 @@ namespace LibKenjinx
|
||||
int idx = (int)Language.AmericanEnglish;
|
||||
if (control.Title.Length > idx)
|
||||
{
|
||||
string? s = control.Title[idx].NameString.ToString();
|
||||
string s = control.Title[idx].NameString.ToString();
|
||||
if (!string.IsNullOrWhiteSpace(s)) return s;
|
||||
}
|
||||
|
||||
// Fallback: first non-empty localization
|
||||
foreach (ref readonly var t in control.Title)
|
||||
foreach (ref readonly ApplicationControlProperty.ApplicationTitle t in control.Title)
|
||||
{
|
||||
var s = t.NameString.ToString();
|
||||
string s = t.NameString.ToString();
|
||||
if (!string.IsNullOrWhiteSpace(s)) return s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Range = (uint)size,
|
||||
};
|
||||
|
||||
_gd.Api.CreateBufferView(_device, in bufferViewCreateInfo, null, out BufferView* bufferView).ThrowOnError();
|
||||
_gd.Api.CreateBufferView(_device, in bufferViewCreateInfo, null, out BufferView bufferView).ThrowOnError();
|
||||
|
||||
return new Auto<DisposableBufferView>(new DisposableBufferView(_gd.Api, _device, bufferView), this, _waitable, _buffer);
|
||||
}
|
||||
|
||||
@@ -118,13 +118,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
PNext = &externalMemoryBuffer,
|
||||
};
|
||||
|
||||
gd.Api.CreateBuffer(_device, in bufferCreateInfo, null, out VkBuffer* buffer).ThrowOnError();
|
||||
gd.Api.CreateBuffer(_device, in bufferCreateInfo, null, out VkBuffer buffer).ThrowOnError();
|
||||
|
||||
(Auto<MemoryAllocation> allocation, ulong offset) = gd.HostMemoryAllocator.GetExistingAllocation(pointer, (ulong)size);
|
||||
|
||||
gd.Api.BindBufferMemory(_device, buffer, allocation.GetUnsafe().Memory, allocation.GetUnsafe().Offset + offset);
|
||||
|
||||
BufferHolder holder = new BufferHolder(gd, _device, buffer, allocation, size, BufferAllocationType.HostMapped, BufferAllocationType.HostMapped, (int)offset);
|
||||
BufferHolder holder = new(gd, _device, buffer, allocation, size, BufferAllocationType.HostMapped, BufferAllocationType.HostMapped, (int)offset);
|
||||
|
||||
BufferCount++;
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Flags = BufferCreateFlags.SparseBindingBit | BufferCreateFlags.SparseAliasedBit
|
||||
};
|
||||
|
||||
gd.Api.CreateBuffer(_device, in bufferCreateInfo, null, out VkBuffer* buffer).ThrowOnError();
|
||||
gd.Api.CreateBuffer(_device, in bufferCreateInfo, null, out VkBuffer buffer).ThrowOnError();
|
||||
|
||||
SparseMemoryBind[] memoryBinds = new SparseMemoryBind[storageBuffers.Length];
|
||||
Auto<MemoryAllocation>[] storageAllocations = new Auto<MemoryAllocation>[storageBuffers.Length];
|
||||
@@ -224,7 +224,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
gd.Api.QueueBindSparse(gd.Queue, 1, in bindSparseInfo, default).ThrowOnError();
|
||||
}
|
||||
|
||||
BufferHolder holder = new BufferHolder(gd, _device, buffer, (int)size, storageAllocations);
|
||||
BufferHolder holder = new(gd, _device, buffer, (int)size, storageAllocations);
|
||||
|
||||
BufferCount++;
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
SharingMode = SharingMode.Exclusive,
|
||||
};
|
||||
|
||||
gd.Api.CreateBuffer(_device, in bufferCreateInfo, null, out VkBuffer* buffer).ThrowOnError();
|
||||
gd.Api.CreateBuffer(_device, in bufferCreateInfo, null, out VkBuffer buffer).ThrowOnError();
|
||||
|
||||
gd.Api.GetBufferMemoryRequirements(_device, buffer, out MemoryRequirements requirements);
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
SharingMode = SharingMode.Exclusive,
|
||||
};
|
||||
|
||||
gd.Api.CreateBuffer(_device, in bufferCreateInfo, null, out VkBuffer* buffer).ThrowOnError();
|
||||
gd.Api.CreateBuffer(_device, in bufferCreateInfo, null, out VkBuffer buffer).ThrowOnError();
|
||||
gd.Api.GetBufferMemoryRequirements(_device, buffer, out MemoryRequirements requirements);
|
||||
|
||||
if (sparseCompatible)
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Layers = Layers,
|
||||
};
|
||||
|
||||
api.CreateFramebuffer(_device, in framebufferCreateInfo, null, out Framebuffer* framebuffer).ThrowOnError();
|
||||
api.CreateFramebuffer(_device, in framebufferCreateInfo, null, out Framebuffer framebuffer).ThrowOnError();
|
||||
return new Auto<DisposableFramebuffer>(new DisposableFramebuffer(api, _device, framebuffer), null, _attachments[..AttachmentsCount]);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
PNext = &priorityInfo,
|
||||
};
|
||||
|
||||
Result result = _api.AllocateMemory(_device, in memoryAllocateInfo, null, out DeviceMemory* deviceMemory);
|
||||
Result result = _api.AllocateMemory(_device, in memoryAllocateInfo, null, out DeviceMemory deviceMemory);
|
||||
|
||||
if (result < Result.Success)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return false;
|
||||
}
|
||||
|
||||
MemoryAllocation allocation = new MemoryAllocation(this, deviceMemory, pageAlignedPointer, 0, pageAlignedSize);
|
||||
MemoryAllocation allocation = new(this, deviceMemory, pageAlignedPointer, 0, pageAlignedSize);
|
||||
Auto<MemoryAllocation> allocAuto = new(allocation);
|
||||
HostMemoryAllocation hostAlloc = new(allocAuto, pageAlignedPointer, pageAlignedSize);
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
MemoryTypeIndex = (uint)MemoryTypeIndex,
|
||||
};
|
||||
|
||||
_api.AllocateMemory(_device, in memoryAllocateInfo, null, out DeviceMemory* deviceMemory).ThrowOnError();
|
||||
_api.AllocateMemory(_device, in memoryAllocateInfo, null, out DeviceMemory deviceMemory).ThrowOnError();
|
||||
|
||||
nint hostPointer = nint.Zero;
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
hostPointer = (nint)pointer;
|
||||
}
|
||||
|
||||
Block newBlock = new Block(deviceMemory, hostPointer, blockAlignedSize);
|
||||
Block newBlock = new(deviceMemory, hostPointer, blockAlignedSize);
|
||||
|
||||
InsertBlock(newBlock);
|
||||
|
||||
|
||||
@@ -233,8 +233,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return;
|
||||
}
|
||||
|
||||
ClearValue clearValue = new ClearValue(null, new ClearDepthStencilValue(depthValue, (uint)stencilValue));
|
||||
int flags = depthMask ? ImageAspectFlags.DepthBit : 0;
|
||||
ClearValue clearValue = new(null, new ClearDepthStencilValue(depthValue, (uint)stencilValue));
|
||||
ImageAspectFlags flags = depthMask ? ImageAspectFlags.DepthBit : 0;
|
||||
|
||||
if (stencilMask)
|
||||
{
|
||||
@@ -257,7 +257,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
BeginRenderPass();
|
||||
|
||||
ClearAttachment attachment = new ClearAttachment(flags, 0, clearValue);
|
||||
ClearAttachment attachment = new(flags, 0, clearValue);
|
||||
ClearRect clearRect = FramebufferParams.GetClearRect(ClearScissor, layer, layerCount);
|
||||
|
||||
Gd.Api.CmdClearAttachments(CommandBuffer, 1, &attachment, 1, &clearRect);
|
||||
@@ -1722,7 +1722,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
FramebufferParams.InsertLoadOpBarriers(Gd, Cbs);
|
||||
|
||||
Rect2D renderArea = new Rect2D(null, new Extent2D(FramebufferParams.Width, FramebufferParams.Height));
|
||||
Rect2D renderArea = new(null, new Extent2D(FramebufferParams.Width, FramebufferParams.Height));
|
||||
ClearValue clearValue = new();
|
||||
|
||||
RenderPassBeginInfo renderPassBeginInfo = new()
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
DependencyCount = 1,
|
||||
};
|
||||
|
||||
gd.Api.CreateRenderPass(device, in renderPassCreateInfo, null, out RenderPass* renderPass).ThrowOnError();
|
||||
gd.Api.CreateRenderPass(device, in renderPassCreateInfo, null, out RenderPass renderPass).ThrowOnError();
|
||||
|
||||
return new DisposableRenderPass(gd.Api, device, renderPass);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
DependencyCount = 1,
|
||||
};
|
||||
|
||||
gd.Api.CreateRenderPass(device, in renderPassCreateInfo, null, out RenderPass* renderPass).ThrowOnError();
|
||||
gd.Api.CreateRenderPass(device, in renderPassCreateInfo, null, out RenderPass renderPass).ThrowOnError();
|
||||
|
||||
_renderPass = new Auto<DisposableRenderPass>(new DisposableRenderPass(gd.Api, device, renderPass));
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
samplerCreateInfo.BorderColor = BorderColor.FloatCustomExt;
|
||||
}
|
||||
|
||||
gd.Api.CreateSampler(device, in samplerCreateInfo, null, out Sampler* sampler).ThrowOnError();
|
||||
gd.Api.CreateSampler(device, in samplerCreateInfo, null, out Sampler sampler).ThrowOnError();
|
||||
|
||||
_sampler = new Auto<DisposableSampler>(new DisposableSampler(gd.Api, device, sampler));
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
dstAspectFlags = dstInfo.Format.ConvertAspectFlags();
|
||||
}
|
||||
|
||||
var srcOffsets = new ImageBlit.SrcOffsetsBuffer();
|
||||
var dstOffsets = new ImageBlit.DstOffsetsBuffer();
|
||||
ImageBlit.SrcOffsetsBuffer srcOffsets = new();
|
||||
ImageBlit.DstOffsetsBuffer dstOffsets = new();
|
||||
|
||||
Filter filter = linearFilter && !dstInfo.Format.IsDepthOrStencil() ? Filter.Linear : Filter.Nearest;
|
||||
|
||||
@@ -453,7 +453,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
DependencyCount = 1,
|
||||
};
|
||||
|
||||
gd.Api.CreateRenderPass2(device, in renderPassCreateInfo, null, out RenderPass* renderPass).ThrowOnError();
|
||||
gd.Api.CreateRenderPass2(device, in renderPassCreateInfo, null, out RenderPass renderPass).ThrowOnError();
|
||||
|
||||
using Auto<DisposableRenderPass> rp = new(new DisposableRenderPass(gd.Api, device, renderPass));
|
||||
|
||||
@@ -476,10 +476,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Layers = (uint)src.Layers,
|
||||
};
|
||||
|
||||
gd.Api.CreateFramebuffer(device, in framebufferCreateInfo, null, out Framebuffer* framebuffer).ThrowOnError();
|
||||
gd.Api.CreateFramebuffer(device, in framebufferCreateInfo, null, out Framebuffer framebuffer).ThrowOnError();
|
||||
using Auto<DisposableFramebuffer> fb = new(new DisposableFramebuffer(gd.Api, device, framebuffer), null, srcView, dstView);
|
||||
|
||||
Rect2D renderArea = new Rect2D(null, new Extent2D((uint)src.Info.Width, (uint)src.Info.Height));
|
||||
Rect2D renderArea = new(null, new Extent2D((uint)src.Info.Width, (uint)src.Info.Height));
|
||||
ClearValue clearValue = new();
|
||||
|
||||
RenderPassBeginInfo renderPassBeginInfo = new()
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
PNext = &imageViewUsage,
|
||||
};
|
||||
|
||||
gd.Api.CreateImageView(device, in imageCreateInfo, null, out ImageView* 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());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Silk.NET.Core;
|
||||
using Silk.NET.Vulkan;
|
||||
using Silk.NET.Vulkan.Extensions.EXT;
|
||||
using Silk.NET.Vulkan.Extensions.KHR;
|
||||
@@ -249,7 +250,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
const QueueFlags RequiredFlags = QueueFlags.GraphicsBit | QueueFlags.ComputeBit;
|
||||
|
||||
KhrSurface khrSurface = new KhrSurface(api.Context);
|
||||
KhrSurface khrSurface = new(api.Context);
|
||||
|
||||
for (uint index = 0; index < physicalDevice.QueueFamilyProperties.Length; index++)
|
||||
{
|
||||
@@ -566,7 +567,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
pExtendedFeatures = &featuresVertexInputDynamicState;
|
||||
}
|
||||
|
||||
var featuresExtendedDynamicState = new PhysicalDeviceExtendedDynamicStateFeaturesEXT
|
||||
PhysicalDeviceExtendedDynamicStateFeaturesEXT featuresExtendedDynamicState = new()
|
||||
{
|
||||
SType = StructureType.PhysicalDeviceExtendedDynamicStateFeaturesExt,
|
||||
PNext = pExtendedFeatures,
|
||||
@@ -704,7 +705,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
PEnabledFeatures = &features,
|
||||
};
|
||||
|
||||
api.CreateDevice(physicalDevice.PhysicalDevice, in deviceCreateInfo, null, out Device* device).ThrowOnError();
|
||||
api.CreateDevice(physicalDevice.PhysicalDevice, in deviceCreateInfo, null, out Device device).ThrowOnError();
|
||||
|
||||
for (int i = 0; i < enabledExtensions.Length; i++)
|
||||
{
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
CurrentTransform = capabilities.CurrentTransform;
|
||||
|
||||
var usage = ImageUsageFlags.ColorAttachmentBit | ImageUsageFlags.TransferDstBit;
|
||||
ImageUsageFlags usage = ImageUsageFlags.ColorAttachmentBit | ImageUsageFlags.TransferDstBit;
|
||||
if (!PlatformInfo.IsBionic)
|
||||
{
|
||||
usage |= ImageUsageFlags.StorageBit; // Only desktop allows storage for swapchain
|
||||
@@ -328,7 +328,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
ComponentSwizzle.B,
|
||||
ComponentSwizzle.A);
|
||||
|
||||
var aspectFlags = ImageAspectFlags.ColorBit;
|
||||
ImageAspectFlags aspectFlags = ImageAspectFlags.ColorBit;
|
||||
|
||||
ImageSubresourceRange subresourceRange = new(aspectFlags, 0, 1, 0, 1);
|
||||
|
||||
@@ -342,7 +342,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
SubresourceRange = subresourceRange,
|
||||
};
|
||||
|
||||
_gd.Api.CreateImageView(_device, in imageCreateInfo, null, out ImageView* imageView).ThrowOnError();
|
||||
_gd.Api.CreateImageView(_device, in imageCreateInfo, null, out ImageView imageView).ThrowOnError();
|
||||
|
||||
return new TextureView(_gd, _device, new DisposableImageView(_gd.Api, _device, imageView), info, format);
|
||||
}
|
||||
@@ -561,7 +561,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
_gd.FlushAllCommands();
|
||||
Semaphore[] emptySems = Array.Empty<Semaphore>();
|
||||
var waitStagesCO = new[] { PipelineStageFlags.ColorAttachmentOutputBit };
|
||||
PipelineStageFlags[] waitStagesCO = new[] { PipelineStageFlags.ColorAttachmentOutputBit };
|
||||
_gd.CommandBufferPool.Return(
|
||||
cbs,
|
||||
emptySems,
|
||||
@@ -643,7 +643,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
Semaphore[] waitSems = new[] { _imageAvailableSemaphores[semaphoreIndex] };
|
||||
var waitStages = new[] { PipelineStageFlags.ColorAttachmentOutputBit }; // Important on Android
|
||||
PipelineStageFlags[] waitStages = new[] { PipelineStageFlags.ColorAttachmentOutputBit }; // Important on Android
|
||||
Semaphore[] signalSems = new[] { _renderFinishedSemaphores[semaphoreIndex] };
|
||||
_gd.CommandBufferPool.Return(cbs, waitSems, waitStages, signalSems);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user