Shader Test Framework
Links
Summary
Shader Test Framework is a unit testing library for shader code, heavily inspired by Catch2. It is intended to be an exploration into how we can better test our shader code.
It is written with C++23, using DirectX 12 Ultimate as the graphics API.
Features
Write tests in HLSL
Remove the need to compare screenshots to test graphics code
int GetNum()
{
return 42;
}
[numthreads(1, 1, 1)]
void Example()
{
ASSERT(AreEqual, GetNum(), 42);
}Write Catch2 style tests
Use SCENARIO and SECTIONs to write complex test suites
SCENARIO("GIVEN An Optional that is reset")
{
Optional<int> opt;
SECTION("value is set")
{
opt.Set(42);
SECTION("IsValid returns true")
{
ASSERT(IsTrue, opt.IsValid);
}
}
}Formatted test results
Quickly find the thread and assert that failed
There were 127 successful asserts
and 1 failed assertions
Assert 0:
SCENARIO: GIVEN Optional that is reset
SECTION: THEN IsValid returns false
Data 1: false
=======================================
test cases: 3 | 2 passed | 1 failed
assertions: 3 | 2 passed | 1 failedAuto generate PIX capture on failure
Easily debug shader test failures using the PIX captures generated
