wheremyfoodat / Panda3DS

HLE 3DS emulator
https://panda3ds.com/
GNU General Public License v3.0
908 stars 62 forks source link

Add shader-jit unit-tests #458

Closed Wunkolo closed 6 months ago

Wunkolo commented 6 months ago

Using Catch2's TEMPLATE_TEST_CASE, both the shader-interpreter and the shader-jit can be tested with the same unit-tests and with diagnostic messaging for if either fails. JIT-tests use ShaderJITTest, interpreter-tests use ShaderInterpreterTest. In the case that the host supports the shader-jit(PANDA3DS_SHADER_JIT_SUPPORTED), the shader-jit will be conditionally tested.

This is the current output on my x86 host:

% ./AlberTests
Randomness seeded to: 2335885988

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AlberTests is a Catch2 v3.5.2 host application.
Run with -? for options

-------------------------------------------------------------------------------
MUL - ShaderJITTest
-------------------------------------------------------------------------------
./Panda3DS/tests/shader.cpp:96
...............................................................................

./Panda3DS/tests/shader.cpp:104: FAILED:
  REQUIRE( shader->runScalar({(__builtin_inff ()), 0.0f}) == 0.0f )
with expansion:
  nanf == 0.0f

-------------------------------------------------------------------------------
RSQ - ShaderInterpreterTest
-------------------------------------------------------------------------------
./Panda3DS/tests/shader.cpp:132
...............................................................................

./Panda3DS/tests/shader.cpp:138: FAILED:
  REQUIRE( shader->runScalar({-0.0f}) == (__builtin_inff ()) )
with expansion:
  -inff == inff

-------------------------------------------------------------------------------
RSQ - ShaderJITTest
-------------------------------------------------------------------------------
./Panda3DS/tests/shader.cpp:132
...............................................................................

./Panda3DS/tests/shader.cpp:138: FAILED:
  REQUIRE( shader->runScalar({-0.0f}) == (__builtin_inff ()) )
with expansion:
  -inff == inff

-------------------------------------------------------------------------------
MAX - ShaderInterpreterTest
-------------------------------------------------------------------------------
./Panda3DS/tests/shader.cpp:183
...............................................................................

./Panda3DS/tests/shader.cpp:192: FAILED:
  REQUIRE( shader->runScalar({0.0f, -(__builtin_inff ())}) == -(__builtin_inff ()) )
with expansion:
  0.0f == -inff

-------------------------------------------------------------------------------
MAX - ShaderJITTest
-------------------------------------------------------------------------------
./Panda3DS/tests/shader.cpp:183
...............................................................................

./Panda3DS/tests/shader.cpp:192: FAILED:
  REQUIRE( shader->runScalar({0.0f, -(__builtin_inff ())}) == -(__builtin_inff ()) )
with expansion:
  0.0f == -inff

-------------------------------------------------------------------------------
FLR - ShaderInterpreterTest
-------------------------------------------------------------------------------
./Panda3DS/tests/shader.cpp:247
...............................................................................

./Panda3DS/tests/shader.cpp:254: FAILED:
  REQUIRE( shader->runScalar({-0.5}) == -1.0f )
with expansion:
  0.0f == -1.0f

===============================================================================
test cases:  22 |  16 passed | 6 failed
assertions: 137 | 131 passed | 6 failed
wheremyfoodat commented 6 months ago

o image

Wunkolo commented 6 months ago

Weird if true