mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-16 00:40:59 +00:00
Emit Gen5 packed-integer and bit-count ops (#135)
Co-authored-by: Dafenx <196083014+Dafenxz0@users.noreply.github.com>
This commit is contained in:
@@ -396,6 +396,14 @@ internal static partial class Gen5SpirvTranslator
|
|||||||
_module.Constant64(_ulongType, 32)));
|
_module.Constant64(_ulongType, 32)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "VBcntU32B32":
|
||||||
|
result = IAdd(
|
||||||
|
_module.AddInstruction(
|
||||||
|
SpirvOp.BitCount,
|
||||||
|
_uintType,
|
||||||
|
GetRawSource(instruction, 0)),
|
||||||
|
GetRawSource(instruction, 1));
|
||||||
|
break;
|
||||||
case "VMadU32U24":
|
case "VMadU32U24":
|
||||||
{
|
{
|
||||||
var left = BitwiseAnd(
|
var left = BitwiseAnd(
|
||||||
@@ -702,6 +710,14 @@ internal static partial class Gen5SpirvTranslator
|
|||||||
result = Ext(58, _uintType, vector);
|
result = Ext(58, _uintType, vector);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "VCvtPkU16U32":
|
||||||
|
case "VCvtPkI16I32":
|
||||||
|
result = BitwiseOr(
|
||||||
|
BitwiseAnd(GetRawSource(instruction, 0), UInt(0xFFFF)),
|
||||||
|
ShiftLeftLogical(
|
||||||
|
BitwiseAnd(GetRawSource(instruction, 1), UInt(0xFFFF)),
|
||||||
|
UInt(16)));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
error = $"unsupported vector opcode {instruction.Opcode}";
|
error = $"unsupported vector opcode {instruction.Opcode}";
|
||||||
return false;
|
return false;
|
||||||
@@ -1303,6 +1319,43 @@ internal static partial class Gen5SpirvTranslator
|
|||||||
Store(_scc, IsNotZero(result));
|
Store(_scc, IsNotZero(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "SAbsdiffI32":
|
||||||
|
{
|
||||||
|
var wideLeft = _module.AddInstruction(
|
||||||
|
SpirvOp.SConvert,
|
||||||
|
_longType,
|
||||||
|
Bitcast(_intType, left));
|
||||||
|
var wideRight = _module.AddInstruction(
|
||||||
|
SpirvOp.SConvert,
|
||||||
|
_longType,
|
||||||
|
Bitcast(_intType, right));
|
||||||
|
var difference = _module.AddInstruction(
|
||||||
|
SpirvOp.ISub,
|
||||||
|
_longType,
|
||||||
|
wideLeft,
|
||||||
|
wideRight);
|
||||||
|
result = _module.AddInstruction(
|
||||||
|
SpirvOp.UConvert,
|
||||||
|
_uintType,
|
||||||
|
Ext(5, _longType, difference));
|
||||||
|
Store(_scc, IsNotZero(result));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "SPackLlB32B16":
|
||||||
|
result = BitwiseOr(
|
||||||
|
BitwiseAnd(left, UInt(0xFFFF)),
|
||||||
|
ShiftLeftLogical(right, UInt(16)));
|
||||||
|
break;
|
||||||
|
case "SPackLhB32B16":
|
||||||
|
result = BitwiseOr(
|
||||||
|
BitwiseAnd(left, UInt(0xFFFF)),
|
||||||
|
BitwiseAnd(right, UInt(0xFFFF0000)));
|
||||||
|
break;
|
||||||
|
case "SPackHhB32B16":
|
||||||
|
result = BitwiseOr(
|
||||||
|
ShiftRightLogical(left, UInt(16)),
|
||||||
|
BitwiseAnd(right, UInt(0xFFFF0000)));
|
||||||
|
break;
|
||||||
case "SCselectB32":
|
case "SCselectB32":
|
||||||
result = _module.AddInstruction(
|
result = _module.AddInstruction(
|
||||||
SpirvOp.Select,
|
SpirvOp.Select,
|
||||||
|
|||||||
Reference in New Issue
Block a user