Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
38a79e9
InstantiatableFrom concept and tests
KStocky Jun 10, 2024
8e1e03f
Newable concept and tests
KStocky Jun 10, 2024
a31dbbf
Scoped object with some compile time tests. Runtime tests coming when…
KStocky Jun 12, 2024
38f581d
Forgot the cmakelists.txt change for scoped object
KStocky Jun 12, 2024
8a6fe68
Noisy class for testing how many of each special member function is c…
KStocky Jun 13, 2024
b0a435e
Added perfect forwarding and dedection guide for Scoped Object. Also …
KStocky Jun 14, 2024
6db4b5a
Remaining tests for scoped object
KStocky Jun 15, 2024
57ad290
Time utilities and stat system stub
KStocky Jun 15, 2024
66e9a76
Beginnings of a stat system with some tests
KStocky Jun 16, 2024
731042a
More stat system tests
KStocky Jun 16, 2024
d36b709
Fixing stat system timing resolution issue in tests
KStocky Jun 16, 2024
1c3b760
Scoped CPU Duration Stat compile tests and also removing the global s…
KStocky Jun 17, 2024
29c070d
Add profiling support to ShaderTestFixture and tests for the profiling
KStocky Jun 17, 2024
5dfa326
Attempt to get report of test run by running the test project directly
KStocky Jun 23, 2024
0ca82a0
Add cmake action back
KStocky Jun 23, 2024
a908e96
Try uploading test report
KStocky Jun 23, 2024
e6d6d54
Output test run logs
KStocky Jun 23, 2024
5a740ae
See if a fail is logged
KStocky Jun 23, 2024
451b8bc
Using a github action test reporter with ctest
KStocky Jun 24, 2024
5f25b70
Fix catch_discover_tests typo
KStocky Jun 24, 2024
354b72a
Giving PAT to Publish Test Results action
KStocky Jun 24, 2024
3ca4c63
Using GITHUB_TOKEN permissions
KStocky Jun 24, 2024
69f3f2e
Trying out https://github.com/marketplace/actions/junit-report-action
KStocky Jun 25, 2024
17d3a79
Remove second test reporter
KStocky Jun 25, 2024
38a1617
Use both test reporters
KStocky Jun 26, 2024
8f2721e
Removing parameter from test results
KStocky Jun 26, 2024
9c0da4c
Fix tests
KStocky Jun 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions .github/workflows/BuildAndRunTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,43 @@ on:
- '**.cmake'
- '**BuildAndRunTests.yml'
jobs:
Build-And-Test:
runs-on: windows-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
Build-And-Test:

- name: Setup CMake
uses: threeal/cmake-action@v1.3.0
permissions:
checks: write
pull-requests: write

- name: Build the project
run: cmake --build build
runs-on: windows-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4

- name: Test
run: ctest --test-dir build -C Debug --output-on-failure
- name: Print CMake version
shell: cmake -P {0}
run: |
message(STATUS "Host CMake version: ${CMAKE_VERSION}")

- name: Setup CMake
uses: threeal/cmake-action@v1.3.0

- name: Build the project
run: cmake --build build

- name: Test
run: ctest --test-dir build -C Debug --output-on-failure

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
build\test\Debug\Reports\*.xml

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4.3.1
if: always()
with:
report_paths: build\test\Debug\Reports\*.xml
detailed_summary: true


8 changes: 7 additions & 1 deletion cmake/ExternalProjects.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ function(add_catch2 IN_TARGET)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)

include(Catch)
catch_discover_tests(${IN_TARGET} WORKING_DIRECTORY "$<TARGET_FILE_DIR:${IN_TARGET}>")
catch_discover_tests(${IN_TARGET}
EXTRA_ARGS "--durations yes"
WORKING_DIRECTORY "$<TARGET_FILE_DIR:${IN_TARGET}>"
REPORTER junit
OUTPUT_DIR Reports
OUTPUT_SUFFIX ".xml"
)
return()
endfunction()

Expand Down
4 changes: 4 additions & 0 deletions src/ShaderTestFramework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ set(SOURCES
Public/Framework/TestDataBufferProcessor.h
Public/Framework/TestDataBufferStructs.h
Public/Platform.h
Public/Stats/ScopedObject.h
Public/Stats/StatSystem.h
Public/Utility/Algorithm.h
Public/Utility/Concepts.h
Public/Utility/EnumReflection.h
Expand All @@ -64,6 +66,7 @@ set(SOURCES
Public/Utility/MoveOnly.h
Public/Utility/OverloadSet.h
Public/Utility/Pointer.h
Public/Utility/Time.h
Public/Utility/Tuple.h
Public/Utility/Type.h
Public/Utility/TypeList.h
Expand All @@ -89,6 +92,7 @@ set(SOURCES
Private/Framework/TestDataBufferLayout.cpp
Private/Framework/TestDataBufferProcessor.cpp
Private/Framework/TestDataBufferStructs.cpp
Private/Stats/StatSystem.cpp
)

set(SHADER_SOURCES
Expand Down
25 changes: 24 additions & 1 deletion src/ShaderTestFramework/Private/Framework/ShaderTestFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace
}
}

StatSystem ShaderTestFixture::statSystem;
std::vector<TimedStat> ShaderTestFixture::cachedStats;

ShaderTestFixture::ShaderTestFixture(Desc InParams)
: m_Device()
, m_Compiler()
Expand All @@ -36,6 +39,9 @@ ShaderTestFixture::ShaderTestFixture(Desc InParams)
, m_TestDataLayout(InParams.TestDataLayout)
, m_IsWarp(InParams.GPUDeviceParams.DeviceType == GPUDevice::EDeviceType::Software)
{
ScopedDuration scope("Shader Test Fixture construction");
cachedStats.clear();

fs::path shaderDir = std::filesystem::current_path();
shaderDir += "/";
shaderDir += SHADER_SRC;
Expand All @@ -47,13 +53,19 @@ ShaderTestFixture::ShaderTestFixture(Desc InParams)
PopulateDefaultByteReaders();
}

ShaderTestFixture::~ShaderTestFixture() noexcept
{
cachedStats = statSystem.FlushTimedStats();
}

void ShaderTestFixture::TakeCapture()
{
m_CaptureRequested = true;
}

STF::Results ShaderTestFixture::RunTest(const std::string_view InName, u32 InX, u32 InY, u32 InZ)
{
ScopedDuration fullTest(std::format("ShaderTestFixture::RunTest: {}", InName));
const auto compileResult = CompileShader(InName, EShaderType::Compute);

if (!compileResult.has_value())
Expand Down Expand Up @@ -90,6 +102,7 @@ STF::Results ShaderTestFixture::RunTest(const std::string_view InName, u32 InX,
const auto allocationUAV = CreateAssertBufferUAV(allocationBuffer, resourceHeap, 1);

{
ScopedDuration testExecution("ShaderTestFixture::RunTest Test Execution");
const auto capturer = PIXCapturer(InName, ShouldTakeCapture());

engine.Execute(InName,
Expand Down Expand Up @@ -149,11 +162,15 @@ STF::Results ShaderTestFixture::RunTest(const std::string_view InName, u32 InX,
engine.Flush();
}

return ReadbackResults(readBackAllocationBuffer, readBackBuffer, uint3(dimX, dimY, dimZ));
{
ScopedDuration readbackScope(std::format("ShaderTestFixture::ReadbackResults: {}", InName));
return ReadbackResults(readBackAllocationBuffer, readBackBuffer, uint3(dimX, dimY, dimZ));
}
}

STF::Results ShaderTestFixture::RunCompileTimeTest()
{
ScopedDuration scope("ShaderTestFixture::RunCompileTimeTest");
const auto compileResult = CompileShader("", EShaderType::Lib);

if (!compileResult.has_value())
Expand All @@ -179,8 +196,14 @@ bool ShaderTestFixture::IsUsingAgilitySDK() const
return m_Device.GetHardwareInfo().FeatureInfo.EnhancedBarriersSupport;
}

std::vector<TimedStat> ShaderTestFixture::GetTestStats()
{
return cachedStats;
}

CompilationResult ShaderTestFixture::CompileShader(const std::string_view InName, const EShaderType InType) const
{
ScopedDuration scope(std::format("ShaderTestFixture::CompileShader: {}", InName));
ShaderCompilationJobDesc job;
job.AdditionalFlags = m_CompilationFlags;
job.AdditionalFlags.emplace_back(L"-enable-16bit-types");
Expand Down
45 changes: 45 additions & 0 deletions src/ShaderTestFramework/Private/Stats/StatSystem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "Stats/StatSystem.h"
#include <ranges>

StatSystem::Handle StatSystem::BeginStat(std::string InName)
{
if (m_RawTimedStats.size() > Handle::MaxIds)
{
return Handle{ 0u, 0u, false };
}
const u32 id = static_cast<u32>(m_RawTimedStats.size());

m_RawTimedStats.push_back(RawTimedStat{ std::move(InName), Clock::now() });

return Handle{id, m_CurrentGen, true};
}

void StatSystem::EndStat(const Handle InHandle)
{
if (InHandle && InHandle.GetGeneration() == m_CurrentGen && InHandle.GetId() < m_RawTimedStats.size())
{
auto& rawStat = m_RawTimedStats[InHandle.GetId()];
rawStat.EndTime = Clock::now();
}
}

std::vector<TimedStat> StatSystem::FlushTimedStats()
{
std::vector<TimedStat> ret;

for (auto&& completed : std::views::all(m_RawTimedStats)
| std::views::filter(
[](const RawTimedStat& In)
{
return In.EndTime.time_since_epoch().count() != 0;
}))
{
ret.push_back(TimedStat{ std::move(completed.Name), completed.EndTime - completed.StartTime });
}

m_RawTimedStats.clear();
m_CurrentGen = (m_CurrentGen + 1) % Handle::MaxGens;

return ret;
}

9 changes: 9 additions & 0 deletions src/ShaderTestFramework/Public/Framework/ShaderTestFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Framework/HLSLTypes.h"
#include "Framework/TestDataBufferLayout.h"
#include "Framework/TestDataBufferProcessor.h"
#include "Stats/StatSystem.h"
#include <optional>
#include <vector>

Expand All @@ -30,6 +31,7 @@ class ShaderTestFixture
};

ShaderTestFixture(Desc InParams);
~ShaderTestFixture() noexcept;

void TakeCapture();
STF::Results RunTest(const std::string_view InName, u32 InX, u32 InY, u32 InZ);
Expand All @@ -41,8 +43,15 @@ class ShaderTestFixture

bool IsUsingAgilitySDK() const;

static std::vector<TimedStat> GetTestStats();

private:

static StatSystem statSystem;
static constexpr auto StatSystemGetter = []() -> StatSystem& { return statSystem; };
using ScopedDuration = ScopedCPUDurationStat<StatSystemGetter>;
static std::vector<TimedStat> cachedStats;

CompilationResult CompileShader(const std::string_view InName, const EShaderType InType) const;
CommandEngine CreateCommandEngine() const;
DescriptorHeap CreateDescriptorHeap() const;
Expand Down
37 changes: 37 additions & 0 deletions src/ShaderTestFramework/Public/Stats/ScopedObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

#include "Utility/Concepts.h"

template<CallableType CallOnDestruction>
class ScopedObject
{
public:
template<CallableType CallOnConstruction, CallableType OtherCallOnDestruction>
ScopedObject(CallOnConstruction&& OnConstruction, OtherCallOnDestruction&& OnDestruction)
: m_OnDestruction(std::forward<OtherCallOnDestruction>(OnDestruction))
{
OnConstruction();
}

~ScopedObject() noexcept
{
m_OnDestruction();
}

ScopedObject(const ScopedObject&) = delete;
ScopedObject(ScopedObject&&) = delete;
ScopedObject& operator=(const ScopedObject&) = delete;
ScopedObject& operator=(ScopedObject&&) = delete;

template<typename... Ts>
static void* operator new(std::size_t, Ts&&...) = delete;

template<typename... Ts>
static void* operator new[](std::size_t, Ts&&...) = delete;

private:

CallOnDestruction m_OnDestruction;
};

template<typename OnConstruct, typename OnDestruct>
ScopedObject(OnConstruct, OnDestruct) -> ScopedObject<OnDestruct>;
Loading