Compare commits

...

2 commits

Author SHA1 Message Date
Marco Carvalho
5cec76e03b from "params T[]" to "params ReadOnlySpan<T>" 2024-12-17 15:07:42 -03:00
Marco Carvalho
2ff1c107d3 from "params T[]" to "params ReadOnlySpan<T>" 2024-12-17 14:17:24 -03:00
15 changed files with 105 additions and 91 deletions

View file

@ -1,4 +1,5 @@
using ARMeilleure.Common; using ARMeilleure.Common;
using System;
namespace ARMeilleure.Decoders namespace ARMeilleure.Decoders
{ {
@ -149,7 +150,7 @@ namespace ARMeilleure.Decoders
return (((long)opCode << 45) >> 48) & ~3; return (((long)opCode << 45) >> 48) & ~3;
} }
public static bool VectorArgumentsInvalid(bool q, params int[] args) public static bool VectorArgumentsInvalid(bool q, params ReadOnlySpan<int> args)
{ {
if (q) if (q)
{ {

View file

@ -264,7 +264,7 @@ namespace ARMeilleure.Instructions
return TblOrTbx(dest, vector, bytes, tb0, tb1, tb2, tb3); 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<V128> tb)
{ {
byte[] res = new byte[16]; byte[] res = new byte[16];

View file

@ -337,7 +337,7 @@ namespace ARMeilleure.IntermediateRepresentation
return result; return result;
} }
public static Operation Operation(Intrinsic intrin, Operand dest, params Operand[] srcs) public static Operation Operation(Intrinsic intrin, Operand dest, params ReadOnlySpan<Operand> srcs)
{ {
Operation result = Make(Instruction.Extended, 0, srcs.Length); Operation result = Make(Instruction.Extended, 0, srcs.Length);

View file

@ -559,27 +559,27 @@ namespace ARMeilleure.Translation
return dest; return dest;
} }
public Operand AddIntrinsic(Intrinsic intrin, params Operand[] args) public Operand AddIntrinsic(Intrinsic intrin, params ReadOnlySpan<Operand> args)
{ {
return Add(intrin, Local(OperandType.V128), args); return Add(intrin, Local(OperandType.V128), args);
} }
public Operand AddIntrinsicInt(Intrinsic intrin, params Operand[] args) public Operand AddIntrinsicInt(Intrinsic intrin, params ReadOnlySpan<Operand> args)
{ {
return Add(intrin, Local(OperandType.I32), args); return Add(intrin, Local(OperandType.I32), args);
} }
public Operand AddIntrinsicLong(Intrinsic intrin, params Operand[] args) public Operand AddIntrinsicLong(Intrinsic intrin, params ReadOnlySpan<Operand> args)
{ {
return Add(intrin, Local(OperandType.I64), args); return Add(intrin, Local(OperandType.I64), args);
} }
public void AddIntrinsicNoRet(Intrinsic intrin, params Operand[] args) public void AddIntrinsicNoRet(Intrinsic intrin, params ReadOnlySpan<Operand> args)
{ {
Add(intrin, default, args); Add(intrin, default, args);
} }
private Operand Add(Intrinsic intrin, Operand dest, params Operand[] sources) private Operand Add(Intrinsic intrin, Operand dest, params ReadOnlySpan<Operand> sources)
{ {
NewNextBlockIfNeeded(); NewNextBlockIfNeeded();

View file

@ -478,7 +478,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
bool skipContext, bool skipContext,
int spillBaseOffset, int spillBaseOffset,
int? resultRegister, int? resultRegister,
params ulong[] callArgs) params ReadOnlySpan<ulong> callArgs)
{ {
uint resultMask = 0u; uint resultMask = 0u;

View file

@ -417,7 +417,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
nint funcPtr, nint funcPtr,
int spillBaseOffset, int spillBaseOffset,
int? resultRegister, int? resultRegister,
params ulong[] callArgs) params ReadOnlySpan<ulong> callArgs)
{ {
uint resultMask = 0u; uint resultMask = 0u;

View file

@ -721,7 +721,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="format">The format of the texture</param> /// <param name="format">The format of the texture</param>
/// <param name="components">The texture swizzle components</param> /// <param name="components">The texture swizzle components</param>
/// <returns>The depth-stencil mode</returns> /// <returns>The depth-stencil mode</returns>
private static DepthStencilMode GetDepthStencilMode(Format format, params SwizzleComponent[] components) private static DepthStencilMode GetDepthStencilMode(Format format, params ReadOnlySpan<SwizzleComponent> components)
{ {
// R = Depth, G = Stencil. // R = Depth, G = Stencil.
// On 24-bits depth formats, this is inverted (Stencil is R etc). // On 24-bits depth formats, this is inverted (Stencil is R etc).

View file

@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Vulkan
_optimalTable = new FormatFeatureFlags[totalFormats]; _optimalTable = new FormatFeatureFlags[totalFormats];
} }
public bool BufferFormatsSupport(FormatFeatureFlags flags, params Format[] formats) public bool BufferFormatsSupport(FormatFeatureFlags flags, params ReadOnlySpan<Format> formats)
{ {
foreach (Format format in formats) foreach (Format format in formats)
{ {
@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Vulkan
return true; return true;
} }
public bool OptimalFormatsSupport(FormatFeatureFlags flags, params Format[] formats) public bool OptimalFormatsSupport(FormatFeatureFlags flags, params ReadOnlySpan<Format> formats)
{ {
foreach (Format format in formats) foreach (Format format in formats)
{ {

View file

@ -403,7 +403,7 @@ namespace Ryujinx.HLE.HOS
} }
// Assumes searchDirPaths don't overlap // Assumes searchDirPaths don't overlap
private static void CollectMods(Dictionary<ulong, ModCache> modCaches, PatchCache patches, params string[] searchDirPaths) private static void CollectMods(Dictionary<ulong, ModCache> modCaches, PatchCache patches, params ReadOnlySpan<string> searchDirPaths)
{ {
static bool IsPatchesDir(string name) => StrEquals(AmsNsoPatchDir, name) || static bool IsPatchesDir(string name) => StrEquals(AmsNsoPatchDir, name) ||
StrEquals(AmsNroPatchDir, name) || StrEquals(AmsNroPatchDir, name) ||
@ -453,7 +453,7 @@ namespace Ryujinx.HLE.HOS
patches.Initialized = true; patches.Initialized = true;
} }
public void CollectMods(IEnumerable<ulong> applications, params string[] searchDirPaths) public void CollectMods(IEnumerable<ulong> applications, params ReadOnlySpan<string> searchDirPaths)
{ {
Clear(); Clear();
@ -680,7 +680,7 @@ namespace Ryujinx.HLE.HOS
ApplyProgramPatches(nroPatches, 0, nro); ApplyProgramPatches(nroPatches, 0, nro);
} }
internal bool ApplyNsoPatches(ulong applicationId, params IExecutable[] programs) internal bool ApplyNsoPatches(ulong applicationId, params ReadOnlySpan<IExecutable> programs)
{ {
IEnumerable<Mod<DirectoryInfo>> nsoMods = _patches.NsoPatches; IEnumerable<Mod<DirectoryInfo>> nsoMods = _patches.NsoPatches;
@ -744,7 +744,7 @@ namespace Ryujinx.HLE.HOS
} }
} }
private static bool ApplyProgramPatches(IEnumerable<Mod<DirectoryInfo>> mods, int protectedOffset, params IExecutable[] programs) private static bool ApplyProgramPatches(IEnumerable<Mod<DirectoryInfo>> mods, int protectedOffset, params ReadOnlySpan<IExecutable> programs)
{ {
int count = 0; int count = 0;
@ -755,12 +755,18 @@ namespace Ryujinx.HLE.HOS
patches[i] = new MemPatch(); patches[i] = new MemPatch();
} }
var buildIds = programs.Select(p => p switch var buildIds = new List<string>(programs.Length);
foreach (IExecutable p in programs)
{
var buildId = p switch
{ {
NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()).TrimEnd('0'), NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()).TrimEnd('0'),
NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'), NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'),
_ => string.Empty, _ => string.Empty,
}).ToList(); };
buildIds.Add(buildId);
}
int GetIndex(string buildId) => buildIds.FindIndex(id => id == buildId); // O(n) but list is small int GetIndex(string buildId) => buildIds.FindIndex(id => id == buildId); // O(n) but list is small

View file

@ -123,7 +123,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return true; return true;
} }
public void Configure(params ControllerConfig[] configs) public void Configure(params ReadOnlySpan<ControllerConfig> configs)
{ {
_configuredTypes = new ControllerType[MaxControllers]; _configuredTypes = new ControllerType[MaxControllers];

View file

@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{ {
public TouchDevice(Switch device, bool active) : base(device, active) { } public TouchDevice(Switch device, bool active) : base(device, active) { }
public void Update(params TouchPoint[] points) public void Update(params ReadOnlySpan<TouchPoint> points)
{ {
ref RingLifo<TouchScreenState> lifo = ref _device.Hid.SharedMemory.TouchScreen; ref RingLifo<TouchScreenState> lifo = ref _device.Hid.SharedMemory.TouchScreen;

View file

@ -231,7 +231,7 @@ namespace Ryujinx.HLE.Loaders.Processes
ulong programId, ulong programId,
byte programIndex, byte programIndex,
byte[] arguments = null, byte[] arguments = null,
params IExecutable[] executables) params ReadOnlySpan<IExecutable> executables)
{ {
context.Device.System.ServiceTable.WaitServicesReady(); context.Device.System.ServiceTable.WaitServicesReady();
@ -251,12 +251,17 @@ namespace Ryujinx.HLE.Loaders.Processes
ulong codeStart = ((meta.Flags & 1) != 0 ? 0x8000000UL : 0x200000UL) + CodeStartOffset; ulong codeStart = ((meta.Flags & 1) != 0 ? 0x8000000UL : 0x200000UL) + CodeStartOffset;
uint codeSize = 0; uint codeSize = 0;
var buildIds = executables.Select(e => (e switch var buildIds = new string[executables.Length];
for (int i = 0; i < executables.Length; i++)
{
buildIds[i] = (executables[i] switch
{ {
NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()), NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()),
NroExecutable nro => Convert.ToHexString(nro.Header.BuildId), NroExecutable nro => Convert.ToHexString(nro.Header.BuildId),
_ => string.Empty _ => string.Empty
}).ToUpper()); }).ToUpper();
}
ulong[] nsoBase = new ulong[executables.Length]; ulong[] nsoBase = new ulong[executables.Length];

View file

@ -26,6 +26,7 @@
// IN THE MATERIALS. // IN THE MATERIALS.
#endregion #endregion
using System;
using static Spv.Specification; using static Spv.Specification;
namespace Spv.Generator namespace Spv.Generator
@ -192,7 +193,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction Decorate(Instruction target, Decoration decoration, params IOperand[] parameters) public Instruction Decorate(Instruction target, Decoration decoration, params ReadOnlySpan<IOperand> parameters)
{ {
Instruction result = NewInstruction(Op.OpDecorate); Instruction result = NewInstruction(Op.OpDecorate);
@ -229,7 +230,7 @@ namespace Spv.Generator
return result; 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<IOperand> parameters)
{ {
Instruction result = NewInstruction(Op.OpMemberDecorate); Instruction result = NewInstruction(Op.OpMemberDecorate);
@ -251,7 +252,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction GroupDecorate(Instruction decorationGroup, params Instruction[] targets) public Instruction GroupDecorate(Instruction decorationGroup, params ReadOnlySpan<Instruction> targets)
{ {
Instruction result = NewInstruction(Op.OpGroupDecorate); Instruction result = NewInstruction(Op.OpGroupDecorate);
@ -262,7 +263,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction GroupMemberDecorate(Instruction decorationGroup, params IOperand[] targets) public Instruction GroupMemberDecorate(Instruction decorationGroup, params ReadOnlySpan<IOperand> targets)
{ {
Instruction result = NewInstruction(Op.OpGroupMemberDecorate); Instruction result = NewInstruction(Op.OpGroupMemberDecorate);
@ -273,7 +274,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction DecorateId(Instruction target, Decoration decoration, params IOperand[] parameters) public Instruction DecorateId(Instruction target, Decoration decoration, params ReadOnlySpan<IOperand> parameters)
{ {
Instruction result = NewInstruction(Op.OpDecorateId); Instruction result = NewInstruction(Op.OpDecorateId);
@ -285,7 +286,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction DecorateString(Instruction target, Decoration decoration, params IOperand[] parameters) public Instruction DecorateString(Instruction target, Decoration decoration, params ReadOnlySpan<IOperand> parameters)
{ {
Instruction result = NewInstruction(Op.OpDecorateString); Instruction result = NewInstruction(Op.OpDecorateString);
@ -297,7 +298,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction DecorateStringGOOGLE(Instruction target, Decoration decoration, params IOperand[] parameters) public Instruction DecorateStringGOOGLE(Instruction target, Decoration decoration, params ReadOnlySpan<IOperand> parameters)
{ {
Instruction result = NewInstruction(Op.OpDecorateStringGOOGLE); Instruction result = NewInstruction(Op.OpDecorateStringGOOGLE);
@ -309,7 +310,7 @@ namespace Spv.Generator
return result; 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<IOperand> parameters)
{ {
Instruction result = NewInstruction(Op.OpMemberDecorateString); Instruction result = NewInstruction(Op.OpMemberDecorateString);
@ -322,7 +323,7 @@ namespace Spv.Generator
return result; 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<IOperand> parameters)
{ {
Instruction result = NewInstruction(Op.OpMemberDecorateStringGOOGLE); Instruction result = NewInstruction(Op.OpMemberDecorateStringGOOGLE);
@ -458,7 +459,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction TypeStruct(bool forceIdAllocation, params Instruction[] parameters) public Instruction TypeStruct(bool forceIdAllocation, params ReadOnlySpan<Instruction> parameters)
{ {
Instruction result = NewInstruction(Op.OpTypeStruct); Instruction result = NewInstruction(Op.OpTypeStruct);
@ -489,7 +490,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction TypeFunction(Instruction returnType, bool forceIdAllocation, params Instruction[] parameters) public Instruction TypeFunction(Instruction returnType, bool forceIdAllocation, params ReadOnlySpan<Instruction> parameters)
{ {
Instruction result = NewInstruction(Op.OpTypeFunction); Instruction result = NewInstruction(Op.OpTypeFunction);
@ -605,7 +606,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction ConstantComposite(Instruction resultType, params Instruction[] constituents) public Instruction ConstantComposite(Instruction resultType, params ReadOnlySpan<Instruction> constituents)
{ {
Instruction result = NewInstruction(Op.OpConstantComposite, Instruction.InvalidId, resultType); Instruction result = NewInstruction(Op.OpConstantComposite, Instruction.InvalidId, resultType);
@ -664,7 +665,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction SpecConstantComposite(Instruction resultType, params Instruction[] constituents) public Instruction SpecConstantComposite(Instruction resultType, params ReadOnlySpan<Instruction> constituents)
{ {
Instruction result = NewInstruction(Op.OpSpecConstantComposite, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpSpecConstantComposite, GetNewId(), resultType);
@ -814,7 +815,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction AccessChain(Instruction resultType, Instruction baseObj, params Instruction[] indexes) public Instruction AccessChain(Instruction resultType, Instruction baseObj, params ReadOnlySpan<Instruction> indexes)
{ {
Instruction result = NewInstruction(Op.OpAccessChain, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpAccessChain, GetNewId(), resultType);
@ -825,7 +826,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction InBoundsAccessChain(Instruction resultType, Instruction baseObj, params Instruction[] indexes) public Instruction InBoundsAccessChain(Instruction resultType, Instruction baseObj, params ReadOnlySpan<Instruction> indexes)
{ {
Instruction result = NewInstruction(Op.OpInBoundsAccessChain, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpInBoundsAccessChain, GetNewId(), resultType);
@ -836,7 +837,7 @@ namespace Spv.Generator
return result; 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<Instruction> indexes)
{ {
Instruction result = NewInstruction(Op.OpPtrAccessChain, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpPtrAccessChain, GetNewId(), resultType);
@ -869,7 +870,7 @@ namespace Spv.Generator
return result; 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<Instruction> indexes)
{ {
Instruction result = NewInstruction(Op.OpInBoundsPtrAccessChain, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpInBoundsPtrAccessChain, GetNewId(), resultType);
@ -949,7 +950,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction FunctionCall(Instruction resultType, Instruction function, params Instruction[] parameters) public Instruction FunctionCall(Instruction resultType, Instruction function, params ReadOnlySpan<Instruction> parameters)
{ {
Instruction result = NewInstruction(Op.OpFunctionCall, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpFunctionCall, GetNewId(), resultType);
@ -973,7 +974,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleImplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleImplicitLod, GetNewId(), resultType);
@ -992,7 +993,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleExplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleExplicitLod, GetNewId(), resultType);
@ -1008,7 +1009,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleDrefImplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleDrefImplicitLod, GetNewId(), resultType);
@ -1028,7 +1029,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleDrefExplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleDrefExplicitLod, GetNewId(), resultType);
@ -1045,7 +1046,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleProjImplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleProjImplicitLod, GetNewId(), resultType);
@ -1064,7 +1065,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleProjExplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleProjExplicitLod, GetNewId(), resultType);
@ -1080,7 +1081,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleProjDrefImplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleProjDrefImplicitLod, GetNewId(), resultType);
@ -1100,7 +1101,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleProjDrefExplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleProjDrefExplicitLod, GetNewId(), resultType);
@ -1117,7 +1118,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageFetch, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageFetch, GetNewId(), resultType);
@ -1136,7 +1137,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageGather, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageGather, GetNewId(), resultType);
@ -1156,7 +1157,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageDrefGather, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageDrefGather, GetNewId(), resultType);
@ -1176,7 +1177,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageRead, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageRead, GetNewId(), resultType);
@ -1195,7 +1196,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageWrite); Instruction result = NewInstruction(Op.OpImageWrite);
@ -1297,7 +1298,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseSampleImplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseSampleImplicitLod, GetNewId(), resultType);
@ -1316,7 +1317,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseSampleExplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseSampleExplicitLod, GetNewId(), resultType);
@ -1332,7 +1333,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseSampleDrefImplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseSampleDrefImplicitLod, GetNewId(), resultType);
@ -1352,7 +1353,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseSampleDrefExplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseSampleDrefExplicitLod, GetNewId(), resultType);
@ -1369,7 +1370,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseSampleProjImplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseSampleProjImplicitLod, GetNewId(), resultType);
@ -1388,7 +1389,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseSampleProjExplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseSampleProjExplicitLod, GetNewId(), resultType);
@ -1404,7 +1405,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseSampleProjDrefImplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseSampleProjDrefImplicitLod, GetNewId(), resultType);
@ -1424,7 +1425,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseSampleProjDrefExplicitLod, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseSampleProjDrefExplicitLod, GetNewId(), resultType);
@ -1441,7 +1442,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseFetch, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseFetch, GetNewId(), resultType);
@ -1460,7 +1461,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseGather, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseGather, GetNewId(), resultType);
@ -1480,7 +1481,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseDrefGather, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseDrefGather, GetNewId(), resultType);
@ -1510,7 +1511,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSparseRead, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSparseRead, GetNewId(), resultType);
@ -1529,7 +1530,7 @@ namespace Spv.Generator
return result; 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<Instruction> imageOperandIds)
{ {
Instruction result = NewInstruction(Op.OpImageSampleFootprintNV, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpImageSampleFootprintNV, GetNewId(), resultType);
@ -1738,7 +1739,7 @@ namespace Spv.Generator
return result; 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<LiteralInteger> components)
{ {
Instruction result = NewInstruction(Op.OpVectorShuffle, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpVectorShuffle, GetNewId(), resultType);
@ -1750,7 +1751,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction CompositeConstruct(Instruction resultType, params Instruction[] constituents) public Instruction CompositeConstruct(Instruction resultType, params ReadOnlySpan<Instruction> constituents)
{ {
Instruction result = NewInstruction(Op.OpCompositeConstruct, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpCompositeConstruct, GetNewId(), resultType);
@ -1760,7 +1761,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction CompositeExtract(Instruction resultType, Instruction composite, params LiteralInteger[] indexes) public Instruction CompositeExtract(Instruction resultType, Instruction composite, params ReadOnlySpan<LiteralInteger> indexes)
{ {
Instruction result = NewInstruction(Op.OpCompositeExtract, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpCompositeExtract, GetNewId(), resultType);
@ -1771,7 +1772,7 @@ namespace Spv.Generator
return result; 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<LiteralInteger> indexes)
{ {
Instruction result = NewInstruction(Op.OpCompositeInsert, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpCompositeInsert, GetNewId(), resultType);
@ -2752,7 +2753,7 @@ namespace Spv.Generator
// Control-Flow // Control-Flow
public Instruction Phi(Instruction resultType, params Instruction[] parameters) public Instruction Phi(Instruction resultType, params ReadOnlySpan<Instruction> parameters)
{ {
Instruction result = NewInstruction(Op.OpPhi, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpPhi, GetNewId(), resultType);
@ -2802,7 +2803,7 @@ namespace Spv.Generator
return result; 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<LiteralInteger> branchweights)
{ {
Instruction result = NewInstruction(Op.OpBranchConditional); Instruction result = NewInstruction(Op.OpBranchConditional);
@ -2815,7 +2816,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction Switch(Instruction selector, Instruction defaultObj, params IOperand[] target) public Instruction Switch(Instruction selector, Instruction defaultObj, params ReadOnlySpan<IOperand> target)
{ {
Instruction result = NewInstruction(Op.OpSwitch); Instruction result = NewInstruction(Op.OpSwitch);
@ -3678,7 +3679,7 @@ namespace Spv.Generator
return result; 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<Instruction> localSize)
{ {
Instruction result = NewInstruction(Op.OpEnqueueKernel, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpEnqueueKernel, GetNewId(), resultType);
@ -5108,7 +5109,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction LoopControlINTEL(params LiteralInteger[] loopControlParameters) public Instruction LoopControlINTEL(params ReadOnlySpan<LiteralInteger> loopControlParameters)
{ {
Instruction result = NewInstruction(Op.OpLoopControlINTEL); Instruction result = NewInstruction(Op.OpLoopControlINTEL);

View file

@ -64,7 +64,7 @@ namespace Spv.Generator
_operands.Add(value); _operands.Add(value);
} }
public void AddOperand(IOperand[] value) public void AddOperand(ReadOnlySpan<IOperand> value)
{ {
foreach (IOperand instruction in value) foreach (IOperand instruction in value)
{ {
@ -72,7 +72,7 @@ namespace Spv.Generator
} }
} }
public void AddOperand(LiteralInteger[] value) public void AddOperand(ReadOnlySpan<LiteralInteger> value)
{ {
foreach (LiteralInteger instruction in value) foreach (LiteralInteger instruction in value)
{ {
@ -85,7 +85,7 @@ namespace Spv.Generator
AddOperand((IOperand)value); AddOperand((IOperand)value);
} }
public void AddOperand(Instruction[] value) public void AddOperand(ReadOnlySpan<Instruction> value)
{ {
foreach (Instruction instruction in value) foreach (Instruction instruction in value)
{ {

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@ -132,7 +133,7 @@ namespace Spv.Generator
_typeDeclarationsList.Add(instruction); _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<Instruction> interfaces)
{ {
Debug.Assert(function.Opcode == Op.OpFunction); Debug.Assert(function.Opcode == Op.OpFunction);
@ -146,7 +147,7 @@ namespace Spv.Generator
_entrypoints.Add(entryPoint); _entrypoints.Add(entryPoint);
} }
public void AddExecutionMode(Instruction function, ExecutionMode mode, params IOperand[] parameters) public void AddExecutionMode(Instruction function, ExecutionMode mode, params ReadOnlySpan<IOperand> parameters)
{ {
Debug.Assert(function.Opcode == Op.OpFunction); Debug.Assert(function.Opcode == Op.OpFunction);
@ -228,7 +229,7 @@ namespace Spv.Generator
_constants.Add(key, constant); _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<IOperand> parameters)
{ {
Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType); 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. // 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<Instruction> additionalarguments)
{ {
Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType);