// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include "gcn_test_runner.hpp" #include "translator.hpp" class GcnTest : public ::testing::Test { protected: void SetUp() override {} void TearDown() override {} }; struct F32x2 { float a; float b; }; // Example // TEST_F(GcnTest, test_name) { // // Runner sets the vulkan context // auto runner = gcn_test::Runner::instance().value(); // // // v_add_f32 v0, v0, v1 // auto spirv = TranslateToSpirv(0x06000300); // // // run tells how to interpret the result (only 32bit as of now) // // the second argument is templated, it can be at most 4 u32s // // the data is accessible by the instruction in v0-4 and s0-4 (mirrored) // // the result has to be placed in v0 // auto result = runner->run(spirv, F32x2{1.5f, 6.0f}); // // EXPECT_TRUE(result.has_value()); // EXPECT_EQ(*result, 7.5f); // } TEST_F(GcnTest, add_f32) { auto runner = gcn_test::Runner::instance().value(); // v_add_f32 v0, v0, v1 auto spirv = TranslateToSpirv(0x06000300); auto result = runner->run(spirv, F32x2{1.5f, 6.0f}); EXPECT_TRUE(result.has_value()); EXPECT_EQ(*result, 7.5f); } TEST_F(GcnTest, add_nan) { auto runner = gcn_test::Runner::instance().value(); // v_add_f32 v0, v0, v1 auto spirv = TranslateToSpirv(0x06000300); auto result = runner->run(spirv, F32x2{1.0f, std::numeric_limits::quiet_NaN()}); EXPECT_TRUE(result.has_value()); EXPECT_TRUE(std::isnan(*result)); }