diff --git a/src/ARMeilleure/Decoders/DecoderHelper.cs b/src/ARMeilleure/Decoders/DecoderHelper.cs index 35e573955..c39a8a88b 100644 --- a/src/ARMeilleure/Decoders/DecoderHelper.cs +++ b/src/ARMeilleure/Decoders/DecoderHelper.cs @@ -1,4 +1,5 @@ using ARMeilleure.Common; +using System; namespace ARMeilleure.Decoders { @@ -149,7 +150,7 @@ namespace ARMeilleure.Decoders return (((long)opCode << 45) >> 48) & ~3; } - public static bool VectorArgumentsInvalid(bool q, params int[] args) + public static bool VectorArgumentsInvalid(bool q, params ReadOnlySpan args) { if (q) { diff --git a/src/ARMeilleure/Instructions/SoftFallback.cs b/src/ARMeilleure/Instructions/SoftFallback.cs index c4fe677bf..899326c4b 100644 --- a/src/ARMeilleure/Instructions/SoftFallback.cs +++ b/src/ARMeilleure/Instructions/SoftFallback.cs @@ -264,7 +264,7 @@ namespace ARMeilleure.Instructions return TblOrTbx(dest, vector, bytes, tb0, tb1, tb2, tb3); } - private static V128 TblOrTbx(V128 dest, V128 vector, int bytes, params V128[] tb) + private static V128 TblOrTbx(V128 dest, V128 vector, int bytes, params ReadOnlySpan tb) { byte[] res = new byte[16]; diff --git a/src/ARMeilleure/IntermediateRepresentation/Operation.cs b/src/ARMeilleure/IntermediateRepresentation/Operation.cs index b0dc173af..4bc3a2e09 100644 --- a/src/ARMeilleure/IntermediateRepresentation/Operation.cs +++ b/src/ARMeilleure/IntermediateRepresentation/Operation.cs @@ -337,7 +337,7 @@ namespace ARMeilleure.IntermediateRepresentation return result; } - public static Operation Operation(Intrinsic intrin, Operand dest, params Operand[] srcs) + public static Operation Operation(Intrinsic intrin, Operand dest, params ReadOnlySpan srcs) { Operation result = Make(Instruction.Extended, 0, srcs.Length); diff --git a/src/ARMeilleure/Translation/EmitterContext.cs b/src/ARMeilleure/Translation/EmitterContext.cs index e2d860f82..22b6b9842 100644 --- a/src/ARMeilleure/Translation/EmitterContext.cs +++ b/src/ARMeilleure/Translation/EmitterContext.cs @@ -559,27 +559,27 @@ namespace ARMeilleure.Translation return dest; } - public Operand AddIntrinsic(Intrinsic intrin, params Operand[] args) + public Operand AddIntrinsic(Intrinsic intrin, params ReadOnlySpan args) { return Add(intrin, Local(OperandType.V128), args); } - public Operand AddIntrinsicInt(Intrinsic intrin, params Operand[] args) + public Operand AddIntrinsicInt(Intrinsic intrin, params ReadOnlySpan args) { return Add(intrin, Local(OperandType.I32), args); } - public Operand AddIntrinsicLong(Intrinsic intrin, params Operand[] args) + public Operand AddIntrinsicLong(Intrinsic intrin, params ReadOnlySpan args) { return Add(intrin, Local(OperandType.I64), args); } - public void AddIntrinsicNoRet(Intrinsic intrin, params Operand[] args) + public void AddIntrinsicNoRet(Intrinsic intrin, params ReadOnlySpan args) { Add(intrin, default, args); } - private Operand Add(Intrinsic intrin, Operand dest, params Operand[] sources) + private Operand Add(Intrinsic intrin, Operand dest, params ReadOnlySpan sources) { NewNextBlockIfNeeded(); diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitSystem.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitSystem.cs index 4d97a2264..21e40b6aa 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitSystem.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitSystem.cs @@ -478,7 +478,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 bool skipContext, int spillBaseOffset, int? resultRegister, - params ulong[] callArgs) + params ReadOnlySpan callArgs) { uint resultMask = 0u; diff --git a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs index f534e8b6e..bf9338400 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs @@ -307,7 +307,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 int tempRegister; int tempGuestAddress = -1; - bool inlineLookup = guestAddress.Kind != OperandKind.Constant && + bool inlineLookup = guestAddress.Kind != OperandKind.Constant && funcTable is { Sparse: true }; if (guestAddress.Kind == OperandKind.Constant) @@ -417,7 +417,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 nint funcPtr, int spillBaseOffset, int? resultRegister, - params ulong[] callArgs) + params ReadOnlySpan callArgs) { uint resultMask = 0u; diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index be7cb0b89..3bf122412 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs @@ -721,7 +721,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The format of the texture /// The texture swizzle components /// The depth-stencil mode - private static DepthStencilMode GetDepthStencilMode(Format format, params SwizzleComponent[] components) + private static DepthStencilMode GetDepthStencilMode(Format format, params ReadOnlySpan components) { // R = Depth, G = Stencil. // On 24-bits depth formats, this is inverted (Stencil is R etc). diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs index 9ea8cec4b..5a3bd61bd 100644 --- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs @@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Vulkan _optimalTable = new FormatFeatureFlags[totalFormats]; } - public bool BufferFormatsSupport(FormatFeatureFlags flags, params Format[] formats) + public bool BufferFormatsSupport(FormatFeatureFlags flags, params ReadOnlySpan formats) { foreach (Format format in formats) { @@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Vulkan return true; } - public bool OptimalFormatsSupport(FormatFeatureFlags flags, params Format[] formats) + public bool OptimalFormatsSupport(FormatFeatureFlags flags, params ReadOnlySpan formats) { foreach (Format format in formats) { diff --git a/src/Ryujinx.HLE/HOS/ModLoader.cs b/src/Ryujinx.HLE/HOS/ModLoader.cs index cd12619ec..a41ef0816 100644 --- a/src/Ryujinx.HLE/HOS/ModLoader.cs +++ b/src/Ryujinx.HLE/HOS/ModLoader.cs @@ -403,7 +403,7 @@ namespace Ryujinx.HLE.HOS } // Assumes searchDirPaths don't overlap - private static void CollectMods(Dictionary modCaches, PatchCache patches, params string[] searchDirPaths) + private static void CollectMods(Dictionary modCaches, PatchCache patches, params ReadOnlySpan searchDirPaths) { static bool IsPatchesDir(string name) => StrEquals(AmsNsoPatchDir, name) || StrEquals(AmsNroPatchDir, name) || @@ -453,7 +453,7 @@ namespace Ryujinx.HLE.HOS patches.Initialized = true; } - public void CollectMods(IEnumerable applications, params string[] searchDirPaths) + public void CollectMods(IEnumerable applications, params ReadOnlySpan searchDirPaths) { Clear(); @@ -755,12 +755,18 @@ namespace Ryujinx.HLE.HOS patches[i] = new MemPatch(); } - var buildIds = programs.Select(p => p switch + var buildIds = new List(programs.Length); + + foreach (IExecutable p in programs) { - NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()).TrimEnd('0'), - NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'), - _ => string.Empty, - }).ToList(); + var buildId = p switch + { + NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()).TrimEnd('0'), + NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'), + _ => string.Empty, + }; + buildIds.Add(buildId); + } int GetIndex(string buildId) => buildIds.FindIndex(id => id == buildId); // O(n) but list is small diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs index 86c6a825f..834bee6f0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs @@ -123,7 +123,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid return true; } - public void Configure(params ControllerConfig[] configs) + public void Configure(params ReadOnlySpan configs) { _configuredTypes = new ControllerType[MaxControllers]; diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs index 35ac1a16f..e8a56933b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs @@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid { public TouchDevice(Switch device, bool active) : base(device, active) { } - public void Update(params TouchPoint[] points) + public void Update(params ReadOnlySpan points) { ref RingLifo lifo = ref _device.Hid.SharedMemory.TouchScreen; diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs index 33aee1c4c..6cb6dfefe 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs @@ -251,12 +251,17 @@ namespace Ryujinx.HLE.Loaders.Processes ulong codeStart = ((meta.Flags & 1) != 0 ? 0x8000000UL : 0x200000UL) + CodeStartOffset; uint codeSize = 0; - var buildIds = executables.Select(e => (e switch + var buildIds = new string[executables.Length]; + + for (int i = 0; i < executables.Length; i++) { - NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()), - NroExecutable nro => Convert.ToHexString(nro.Header.BuildId), - _ => string.Empty - }).ToUpper()); + buildIds[i] = (executables[i] switch + { + NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()), + NroExecutable nro => Convert.ToHexString(nro.Header.BuildId), + _ => string.Empty + }).ToUpper(); + } ulong[] nsoBase = new ulong[executables.Length]; diff --git a/src/Spv.Generator/Autogenerated/CoreGrammar.cs b/src/Spv.Generator/Autogenerated/CoreGrammar.cs index 37936b8ef..9982fdfa8 100644 --- a/src/Spv.Generator/Autogenerated/CoreGrammar.cs +++ b/src/Spv.Generator/Autogenerated/CoreGrammar.cs @@ -26,6 +26,7 @@ // IN THE MATERIALS. #endregion +using System; using static Spv.Specification; namespace Spv.Generator @@ -192,7 +193,7 @@ namespace Spv.Generator return result; } - public Instruction Decorate(Instruction target, Decoration decoration, params IOperand[] parameters) + public Instruction Decorate(Instruction target, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpDecorate); @@ -229,7 +230,7 @@ namespace Spv.Generator return result; } - public Instruction MemberDecorate(Instruction structureType, LiteralInteger member, Decoration decoration, params IOperand[] parameters) + public Instruction MemberDecorate(Instruction structureType, LiteralInteger member, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpMemberDecorate); @@ -251,7 +252,7 @@ namespace Spv.Generator return result; } - public Instruction GroupDecorate(Instruction decorationGroup, params Instruction[] targets) + public Instruction GroupDecorate(Instruction decorationGroup, params ReadOnlySpan targets) { Instruction result = NewInstruction(Op.OpGroupDecorate); @@ -262,7 +263,7 @@ namespace Spv.Generator return result; } - public Instruction GroupMemberDecorate(Instruction decorationGroup, params IOperand[] targets) + public Instruction GroupMemberDecorate(Instruction decorationGroup, params ReadOnlySpan targets) { Instruction result = NewInstruction(Op.OpGroupMemberDecorate); @@ -273,7 +274,7 @@ namespace Spv.Generator return result; } - public Instruction DecorateId(Instruction target, Decoration decoration, params IOperand[] parameters) + public Instruction DecorateId(Instruction target, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpDecorateId); @@ -285,7 +286,7 @@ namespace Spv.Generator return result; } - public Instruction DecorateString(Instruction target, Decoration decoration, params IOperand[] parameters) + public Instruction DecorateString(Instruction target, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpDecorateString); @@ -297,7 +298,7 @@ namespace Spv.Generator return result; } - public Instruction DecorateStringGOOGLE(Instruction target, Decoration decoration, params IOperand[] parameters) + public Instruction DecorateStringGOOGLE(Instruction target, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpDecorateStringGOOGLE); @@ -309,7 +310,7 @@ namespace Spv.Generator return result; } - public Instruction MemberDecorateString(Instruction structType, LiteralInteger member, Decoration decoration, params IOperand[] parameters) + public Instruction MemberDecorateString(Instruction structType, LiteralInteger member, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpMemberDecorateString); @@ -322,7 +323,7 @@ namespace Spv.Generator return result; } - public Instruction MemberDecorateStringGOOGLE(Instruction structType, LiteralInteger member, Decoration decoration, params IOperand[] parameters) + public Instruction MemberDecorateStringGOOGLE(Instruction structType, LiteralInteger member, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpMemberDecorateStringGOOGLE); @@ -458,7 +459,7 @@ namespace Spv.Generator return result; } - public Instruction TypeStruct(bool forceIdAllocation, params Instruction[] parameters) + public Instruction TypeStruct(bool forceIdAllocation, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpTypeStruct); @@ -489,7 +490,7 @@ namespace Spv.Generator return result; } - public Instruction TypeFunction(Instruction returnType, bool forceIdAllocation, params Instruction[] parameters) + public Instruction TypeFunction(Instruction returnType, bool forceIdAllocation, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpTypeFunction); @@ -605,7 +606,7 @@ namespace Spv.Generator return result; } - public Instruction ConstantComposite(Instruction resultType, params Instruction[] constituents) + public Instruction ConstantComposite(Instruction resultType, params ReadOnlySpan constituents) { Instruction result = NewInstruction(Op.OpConstantComposite, Instruction.InvalidId, resultType); @@ -664,7 +665,7 @@ namespace Spv.Generator return result; } - public Instruction SpecConstantComposite(Instruction resultType, params Instruction[] constituents) + public Instruction SpecConstantComposite(Instruction resultType, params ReadOnlySpan constituents) { Instruction result = NewInstruction(Op.OpSpecConstantComposite, GetNewId(), resultType); @@ -814,7 +815,7 @@ namespace Spv.Generator return result; } - public Instruction AccessChain(Instruction resultType, Instruction baseObj, params Instruction[] indexes) + public Instruction AccessChain(Instruction resultType, Instruction baseObj, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpAccessChain, GetNewId(), resultType); @@ -825,7 +826,7 @@ namespace Spv.Generator return result; } - public Instruction InBoundsAccessChain(Instruction resultType, Instruction baseObj, params Instruction[] indexes) + public Instruction InBoundsAccessChain(Instruction resultType, Instruction baseObj, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpInBoundsAccessChain, GetNewId(), resultType); @@ -836,7 +837,7 @@ namespace Spv.Generator return result; } - public Instruction PtrAccessChain(Instruction resultType, Instruction baseObj, Instruction element, params Instruction[] indexes) + public Instruction PtrAccessChain(Instruction resultType, Instruction baseObj, Instruction element, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpPtrAccessChain, GetNewId(), resultType); @@ -869,7 +870,7 @@ namespace Spv.Generator return result; } - public Instruction InBoundsPtrAccessChain(Instruction resultType, Instruction baseObj, Instruction element, params Instruction[] indexes) + public Instruction InBoundsPtrAccessChain(Instruction resultType, Instruction baseObj, Instruction element, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpInBoundsPtrAccessChain, GetNewId(), resultType); @@ -949,7 +950,7 @@ namespace Spv.Generator return result; } - public Instruction FunctionCall(Instruction resultType, Instruction function, params Instruction[] parameters) + public Instruction FunctionCall(Instruction resultType, Instruction function, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpFunctionCall, GetNewId(), resultType); @@ -973,7 +974,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleImplicitLod, GetNewId(), resultType); @@ -992,7 +993,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleExplicitLod, GetNewId(), resultType); @@ -1008,7 +1009,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleDrefImplicitLod, GetNewId(), resultType); @@ -1028,7 +1029,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleDrefExplicitLod, GetNewId(), resultType); @@ -1045,7 +1046,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleProjImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleProjImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleProjImplicitLod, GetNewId(), resultType); @@ -1064,7 +1065,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleProjExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleProjExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleProjExplicitLod, GetNewId(), resultType); @@ -1080,7 +1081,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleProjDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleProjDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleProjDrefImplicitLod, GetNewId(), resultType); @@ -1100,7 +1101,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleProjDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleProjDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleProjDrefExplicitLod, GetNewId(), resultType); @@ -1117,7 +1118,7 @@ namespace Spv.Generator return result; } - public Instruction ImageFetch(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageFetch(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageFetch, GetNewId(), resultType); @@ -1136,7 +1137,7 @@ namespace Spv.Generator return result; } - public Instruction ImageGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction component, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction component, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageGather, GetNewId(), resultType); @@ -1156,7 +1157,7 @@ namespace Spv.Generator return result; } - public Instruction ImageDrefGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageDrefGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageDrefGather, GetNewId(), resultType); @@ -1176,7 +1177,7 @@ namespace Spv.Generator return result; } - public Instruction ImageRead(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageRead(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageRead, GetNewId(), resultType); @@ -1195,7 +1196,7 @@ namespace Spv.Generator return result; } - public Instruction ImageWrite(Instruction image, Instruction coordinate, Instruction texel, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageWrite(Instruction image, Instruction coordinate, Instruction texel, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageWrite); @@ -1297,7 +1298,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleImplicitLod, GetNewId(), resultType); @@ -1316,7 +1317,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleExplicitLod, GetNewId(), resultType); @@ -1332,7 +1333,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleDrefImplicitLod, GetNewId(), resultType); @@ -1352,7 +1353,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleDrefExplicitLod, GetNewId(), resultType); @@ -1369,7 +1370,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleProjImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleProjImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleProjImplicitLod, GetNewId(), resultType); @@ -1388,7 +1389,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleProjExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleProjExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleProjExplicitLod, GetNewId(), resultType); @@ -1404,7 +1405,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleProjDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleProjDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleProjDrefImplicitLod, GetNewId(), resultType); @@ -1424,7 +1425,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleProjDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleProjDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleProjDrefExplicitLod, GetNewId(), resultType); @@ -1441,7 +1442,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseFetch(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseFetch(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseFetch, GetNewId(), resultType); @@ -1460,7 +1461,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction component, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction component, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseGather, GetNewId(), resultType); @@ -1480,7 +1481,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseDrefGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseDrefGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseDrefGather, GetNewId(), resultType); @@ -1510,7 +1511,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseRead(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseRead(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseRead, GetNewId(), resultType); @@ -1529,7 +1530,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleFootprintNV(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction granularity, Instruction coarse, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleFootprintNV(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction granularity, Instruction coarse, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleFootprintNV, GetNewId(), resultType); @@ -1738,7 +1739,7 @@ namespace Spv.Generator return result; } - public Instruction VectorShuffle(Instruction resultType, Instruction vector1, Instruction vector2, params LiteralInteger[] components) + public Instruction VectorShuffle(Instruction resultType, Instruction vector1, Instruction vector2, params ReadOnlySpan components) { Instruction result = NewInstruction(Op.OpVectorShuffle, GetNewId(), resultType); @@ -1750,7 +1751,7 @@ namespace Spv.Generator return result; } - public Instruction CompositeConstruct(Instruction resultType, params Instruction[] constituents) + public Instruction CompositeConstruct(Instruction resultType, params ReadOnlySpan constituents) { Instruction result = NewInstruction(Op.OpCompositeConstruct, GetNewId(), resultType); @@ -1760,7 +1761,7 @@ namespace Spv.Generator return result; } - public Instruction CompositeExtract(Instruction resultType, Instruction composite, params LiteralInteger[] indexes) + public Instruction CompositeExtract(Instruction resultType, Instruction composite, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpCompositeExtract, GetNewId(), resultType); @@ -1771,7 +1772,7 @@ namespace Spv.Generator return result; } - public Instruction CompositeInsert(Instruction resultType, Instruction obj, Instruction composite, params LiteralInteger[] indexes) + public Instruction CompositeInsert(Instruction resultType, Instruction obj, Instruction composite, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpCompositeInsert, GetNewId(), resultType); @@ -2752,7 +2753,7 @@ namespace Spv.Generator // Control-Flow - public Instruction Phi(Instruction resultType, params Instruction[] parameters) + public Instruction Phi(Instruction resultType, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpPhi, GetNewId(), resultType); @@ -2802,7 +2803,7 @@ namespace Spv.Generator return result; } - public Instruction BranchConditional(Instruction condition, Instruction trueLabel, Instruction falseLabel, params LiteralInteger[] branchweights) + public Instruction BranchConditional(Instruction condition, Instruction trueLabel, Instruction falseLabel, params ReadOnlySpan branchweights) { Instruction result = NewInstruction(Op.OpBranchConditional); @@ -2815,7 +2816,7 @@ namespace Spv.Generator return result; } - public Instruction Switch(Instruction selector, Instruction defaultObj, params IOperand[] target) + public Instruction Switch(Instruction selector, Instruction defaultObj, params ReadOnlySpan target) { Instruction result = NewInstruction(Op.OpSwitch); @@ -3678,7 +3679,7 @@ namespace Spv.Generator return result; } - public Instruction EnqueueKernel(Instruction resultType, Instruction queue, Instruction flags, Instruction nDRange, Instruction numEvents, Instruction waitEvents, Instruction retEvent, Instruction invoke, Instruction param, Instruction paramSize, Instruction paramAlign, params Instruction[] localSize) + public Instruction EnqueueKernel(Instruction resultType, Instruction queue, Instruction flags, Instruction nDRange, Instruction numEvents, Instruction waitEvents, Instruction retEvent, Instruction invoke, Instruction param, Instruction paramSize, Instruction paramAlign, params ReadOnlySpan localSize) { Instruction result = NewInstruction(Op.OpEnqueueKernel, GetNewId(), resultType); @@ -5108,7 +5109,7 @@ namespace Spv.Generator return result; } - public Instruction LoopControlINTEL(params LiteralInteger[] loopControlParameters) + public Instruction LoopControlINTEL(params ReadOnlySpan loopControlParameters) { Instruction result = NewInstruction(Op.OpLoopControlINTEL); diff --git a/src/Spv.Generator/Instruction.cs b/src/Spv.Generator/Instruction.cs index 45492033f..741b30d6d 100644 --- a/src/Spv.Generator/Instruction.cs +++ b/src/Spv.Generator/Instruction.cs @@ -64,7 +64,7 @@ namespace Spv.Generator _operands.Add(value); } - public void AddOperand(IOperand[] value) + public void AddOperand(ReadOnlySpan value) { foreach (IOperand instruction in value) { @@ -72,7 +72,7 @@ namespace Spv.Generator } } - public void AddOperand(LiteralInteger[] value) + public void AddOperand(ReadOnlySpan value) { foreach (LiteralInteger instruction in value) { @@ -85,7 +85,7 @@ namespace Spv.Generator AddOperand((IOperand)value); } - public void AddOperand(Instruction[] value) + public void AddOperand(ReadOnlySpan value) { foreach (Instruction instruction in value) { diff --git a/src/Spv.Generator/Module.cs b/src/Spv.Generator/Module.cs index fb02cc966..fdcd62752 100644 --- a/src/Spv.Generator/Module.cs +++ b/src/Spv.Generator/Module.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -132,7 +133,7 @@ namespace Spv.Generator _typeDeclarationsList.Add(instruction); } - public void AddEntryPoint(ExecutionModel executionModel, Instruction function, string name, params Instruction[] interfaces) + public void AddEntryPoint(ExecutionModel executionModel, Instruction function, string name, params ReadOnlySpan interfaces) { Debug.Assert(function.Opcode == Op.OpFunction); @@ -146,7 +147,7 @@ namespace Spv.Generator _entrypoints.Add(entryPoint); } - public void AddExecutionMode(Instruction function, ExecutionMode mode, params IOperand[] parameters) + public void AddExecutionMode(Instruction function, ExecutionMode mode, params ReadOnlySpan parameters) { Debug.Assert(function.Opcode == Op.OpFunction); @@ -228,7 +229,7 @@ namespace Spv.Generator _constants.Add(key, constant); } - public Instruction ExtInst(Instruction resultType, Instruction set, LiteralInteger instruction, params IOperand[] parameters) + public Instruction ExtInst(Instruction resultType, Instruction set, LiteralInteger instruction, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType); @@ -247,7 +248,7 @@ namespace Spv.Generator } // TODO: Find a way to make the auto generate one used. - public Instruction OpenClPrintf(Instruction resultType, Instruction format, params Instruction[] additionalarguments) + public Instruction OpenClPrintf(Instruction resultType, Instruction format, params ReadOnlySpan additionalarguments) { Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType);