shader: add compact f16 arithmetic and compare lowering (#840)

Co-authored-by: Foued Attar <attar.foued@gmail.com>
This commit is contained in:
frangametv
2026-08-24 13:59:51 +02:00
committed by GitHub
parent f8a826ec1b
commit 2b8ef7d8fa
7 changed files with 790 additions and 14 deletions
@@ -0,0 +1,34 @@
// Copyright (C) 2026 SharpEmu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
using Xunit;
namespace SharpEmu.ShaderCompiler.Metal.Tests;
public sealed class MslFloat16ArithmeticTests
{
[Fact]
public void CompactFloat16ArithmeticUsesHalfOperandsAndPreservesRegisterShape()
{
var fixture = new Gen5ComputeFixture(
"compact-f16-arithmetic",
[
0x64000501,
0x66060B04,
0x680C1107,
0x6A12170A,
0x72181D0D,
0x741E2310,
0xBF810000,
],
StoreScalarResourceBase: 0,
StoreBackingBytes: 0);
var shader = Gen5ComputeFixtures.CompileOrThrow(fixture);
Assert.Contains("as_type<half>", shader.Source, StringComparison.Ordinal);
Assert.Contains("fmin(", shader.Source, StringComparison.Ordinal);
Assert.Contains("fmax(", shader.Source, StringComparison.Ordinal);
Assert.Contains("& 0xFFFF0000u", shader.Source, StringComparison.Ordinal);
}
}