-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVirtualShaderPaths.cpp
More file actions
34 lines (31 loc) · 1.45 KB
/
VirtualShaderPaths.cpp
File metadata and controls
34 lines (31 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <Framework/ShaderTestFixture.h>
#include <catch2/catch_test_macros.hpp>
SCENARIO("Example2Tests")
{
// We can add virtual shader directory mappings to our shader test environment
// Here we are saying that if a file path begins with "/Shader" then it is a virtual file directory
// and should be replaced with the path that evaluates from current_path()/SHADER_SRC
// std::filesystem::current_path() returns the current working directory
// We set both the current working directory and the SHADER_SRC macro in our cmake script.
stf::ShaderTestFixture fixture(
stf::ShaderTestFixture::FixtureDesc
{
.Mappings{ stf::VirtualShaderDirectoryMapping{"/Shader", std::filesystem::current_path() / SHADER_SRC} }
}
);
// RunTest takes a desc that describes the test setup
// In this case we give the HLSL source code, entry function name and thread group count.
REQUIRE(fixture.RunTest(
stf::ShaderTestFixture::RuntimeTestDesc
{
.CompilationEnv
{
// Instead of just giving a string that has HLSL code in it we provide a path to our HLSL source file
// Here we use our virtual shader directory mapping rather than the relative path
.Source = std::filesystem::path{ "/Shader/MyShaderTests.hlsl" }
},
.TestName = "Example2Test",
.ThreadGroupCount{ 1, 1, 1}
})
);
}