Cleanup NumberFormater
This commit is contained in:
parent
90ef8bf4b2
commit
7ba110252d
1 changed files with 19 additions and 29 deletions
|
@ -10,25 +10,21 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
|
|
||||||
public static bool TryFormat(int value, AggregateType dstType, out string formatted)
|
public static bool TryFormat(int value, AggregateType dstType, out string formatted)
|
||||||
{
|
{
|
||||||
if (dstType == AggregateType.FP32)
|
switch (dstType)
|
||||||
{
|
{
|
||||||
return TryFormatFloat(BitConverter.Int32BitsToSingle(value), out formatted);
|
case AggregateType.FP32:
|
||||||
}
|
return TryFormatFloat(BitConverter.Int32BitsToSingle(value), out formatted);
|
||||||
else if (dstType == AggregateType.S32)
|
case AggregateType.S32:
|
||||||
{
|
formatted = FormatInt(value);
|
||||||
formatted = FormatInt(value);
|
break;
|
||||||
}
|
case AggregateType.U32:
|
||||||
else if (dstType == AggregateType.U32)
|
formatted = FormatUint((uint)value);
|
||||||
{
|
break;
|
||||||
formatted = FormatUint((uint)value);
|
case AggregateType.Bool:
|
||||||
}
|
formatted = value != 0 ? "true" : "false";
|
||||||
else if (dstType == AggregateType.Bool)
|
break;
|
||||||
{
|
default:
|
||||||
formatted = value != 0 ? "true" : "false";
|
throw new ArgumentException($"Invalid variable type \"{dstType}\".");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"Invalid variable type \"{dstType}\".");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -65,18 +61,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
|
|
||||||
public static string FormatInt(int value, AggregateType dstType)
|
public static string FormatInt(int value, AggregateType dstType)
|
||||||
{
|
{
|
||||||
if (dstType == AggregateType.S32)
|
return dstType switch
|
||||||
{
|
{
|
||||||
return FormatInt(value);
|
AggregateType.S32 => FormatInt(value),
|
||||||
}
|
AggregateType.U32 => FormatUint((uint)value),
|
||||||
else if (dstType == AggregateType.U32)
|
_ => throw new ArgumentException($"Invalid variable type \"{dstType}\".")
|
||||||
{
|
};
|
||||||
return FormatUint((uint)value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"Invalid variable type \"{dstType}\".");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatInt(int value)
|
public static string FormatInt(int value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue