Skip to content

Commit

Permalink
Merge pull request #121 from MethanePowered/develop
Browse files Browse the repository at this point in the history
Methane Kit v0.7.2: add initial compute pipeline support and RHI unit tests
  • Loading branch information
egorodet committed May 30, 2023
2 parents 499d420 + 0afb15f commit 4299e05
Show file tree
Hide file tree
Showing 285 changed files with 9,042 additions and 1,345 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ coverage:
informational: true
only_pulls: true

ignore:
- "Tests"
- "Apps"

component_management:
individual_components:
- component_id: common-primitives
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ on:
env:
product_ver_major: 0
product_ver_minor: 7
product_ver_patch: 1
product_ver_patch: 2
product_ver_build: ${{ github.run_number }}
tracy_release_version: "0.9"
tracy_release_version: "0.9.1"
# TSC Invariant check is disabled to allow running Catch test executables only for tests list query by CTest
TRACY_NO_INVARIANT_CHECK: 1

Expand Down Expand Up @@ -215,13 +215,20 @@ jobs:
working-directory: ${{ env.INSTALL_DIR }}/Tests
shell: bash
run: |
set +e
result_ext='_result.xml'
result_error_level=0
echo Running all unit-tests in directory $PWD
for test_exe in *Test
do
./$test_exe -r junit -o "$test_exe$result_ext"
echo - $test_exe - completed with $? exit code
last_error_level=$?
echo - $test_exe - completed with $last_error_level exit code
if [ $last_error_level != 0 ]; then
result_error_level=$last_error_level
fi
done
exit $result_error_level
- name: Run Unit-Tests on Windows
if: ${{ matrix.run_tests && matrix.os_name == 'Windows' }}
Expand All @@ -230,11 +237,15 @@ jobs:
run: |
setlocal enabledelayedexpansion
echo Running unit-tests in directory "%cd%"
set /A result_error_level=0
for /r "." %%a in (*Test.exe) do (
"%%~fa" -r junit -o "%%~fa_result.xml"
echo - %%~na - completed with !errorlevel! exit status
if not !errorlevel!==0 (
set /A result_error_level=!errorlevel!
)
)
exit 0
exit !result_error_level!
- name: Upload Test Results Artifact
uses: actions/upload-artifact@v3
Expand All @@ -243,11 +254,12 @@ jobs:
name: MethaneKit_${{ matrix.name }}_TestResults_${{ env.product_ver_major }}.${{ env.product_ver_minor }}.${{ env.product_ver_patch }}.${{ env.product_ver_build }}
path: ${{ env.INSTALL_DIR }}/Tests/*_result.xml

- name: Upload Build Log and Test Tesults to Testspace server
- name: Upload Test Results and Build Log to Testspace server
if: ${{ matrix.run_tests && (success() || failure()) }}
run: testspace "[ ${{ matrix.name }} ]${{ env.INSTALL_DIR }}/Tests/*_result.xml" "[ ${{ matrix.name }} ]${{ env.BUILD_LOG_FILE }}"

- name: Add README and BUILD files
if: ${{ success() || failure() }}
shell: bash
run: |
cp README.md $INSTALL_DIR/README.md
Expand All @@ -259,26 +271,28 @@ jobs:
echo - Builder agent ${{ matrix.os }} system information: >> $INSTALL_DIR/Build-Info.txt
- name: Add Windows System Information to BUILD file
if: ${{ matrix.os_name == 'Windows' }}
if: ${{ matrix.os_name == 'Windows' && (success() || failure()) }}
run: systeminfo >> Build\Output\${{ matrix.config_preset }}\Install\Build-Info.txt

- name: Add Unix System Information to BUILD file
if: ${{ matrix.os_name != 'Windows' }}
if: ${{ matrix.os_name != 'Windows' && (success() || failure()) }}
run: uname -a >>$INSTALL_DIR/Build-Info.txt

- name: Download Tracy release
if: ${{ matrix.add_tracy_app }}
if: ${{ matrix.add_tracy_app && (success() || failure()) }}
shell: bash
run: |
curl -sSLo Tracy.7z https://github.com/MethanePowered/Tracy/releases/download/v${{ env.tracy_release_version }}/Tracy-${{ matrix.os_name }}-v${{ env.tracy_release_version }}.7z
7z x Tracy.7z -o$INSTALL_DIR/Apps
- name: Archive Build Artifacts
if: ${{ success() || failure() }}
shell: bash
working-directory: ${{ env.INSTALL_DIR }}
run: 7z a -t7z -mx=9 MethaneKit_${{ matrix.name }}.7z *

- name: Upload Archived Build Artifacts
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: MethaneKit_${{ matrix.name }}_${{ env.product_ver_major }}.${{ env.product_ver_minor }}.${{ env.product_ver_patch }}.${{ env.product_ver_build }}
Expand Down
61 changes: 50 additions & 11 deletions .github/workflows/ci-sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ on:
env:
product_ver_major: 0
product_ver_minor: 7
product_ver_patch: 1
product_ver_patch: 2
product_ver_build: ${{ github.run_number }}
sonar_server_url: "https://sonarcloud.io"
sonar_organization: methane-powered
Expand Down Expand Up @@ -159,13 +159,15 @@ jobs:
throw 'OpenCppCoverage/OpenCppCoverage.exe executable was not found in unpacked content!'
}
- name: Run all unit-tests from install directory with code coverage using OpenCppCoverage on Windows
- name: Run all unit-tests with OpenCppCoverage code coverage on Windows
if: ${{ matrix.os_name == 'windows' }}
shell: cmd
working-directory: 'Build\Output\${{ matrix.config_preset }}\Install\Tests'
run: |
chcp 65001 #set code page to utf-8
setlocal enabledelayedexpansion
set open_cpp_coverage_exe=OpenCppCoverage\OpenCppCoverage.exe
set test_results=
if not exist "%open_cpp_coverage_exe%" (
echo File path "%open_cpp_coverage_exe%" does not exist!
exit 101
Expand All @@ -181,43 +183,73 @@ jobs:
if not !errorlevel!==0 (
set /A result_error_level=!errorlevel!
)
if .!test_results!==. (
set test_results=Build/Output/${{ matrix.config_preset }}/Install/Tests/Results/%%~na.xml
) else (
set test_results=!test_results!,Build/Output/${{ matrix.config_preset }}/Install/Tests/Results/%%~na.xml
)
)
echo Test Result Files: %test_results%
echo test_results=%test_results%>> %GITHUB_ENV%
exit !result_error_level!
- name: Run unit-tests from install directory on Linux
- name: Run all unit-tests with GCov code coverage on Linux
if: ${{ matrix.os_name == 'linux' }}
working-directory: 'Build/Output/${{ matrix.config_preset }}/Install/Tests'
run: |
set +e
result_ext='.xml'
test_results=''
result_error_level=0
echo Running unit-tests in directory $PWD
mkdir Results
for test_exe in *Test
do
./$test_exe -r sonarqube -o "Results/$test_exe$result_ext"
echo - $test_exe - completed with $? exit status
last_error_level=$?
echo - $test_exe - completed with $last_error_level exit status
if [ $last_error_level != 0 ]; then
result_error_level=$last_error_level
fi
if [ -f "$PWD/Results/$test_exe$result_ext" ]; then
test_results+="$PWD/Results/$test_exe$result_ext,"
fi
done
echo "Test Result Files: $test_results"
echo "test_results=$test_results" >> $GITHUB_ENV
exit $result_error_level
- name: Collect tests code coverage using ctest and gcov/lcov on Linux
if: ${{ matrix.os_name == 'linux' }}
if: ${{ matrix.os_name == 'linux' && (success() || failure()) }}
run: |
set -o pipefail
cmake --build --preset ${{ matrix.build_preset }} --target MethaneTestCoverage 2>&1 | tee $COVERAGE_LOG_FILE
- name: Run all unit-tests from install directory with LCov code coverage on MacOS
- name: Run all unit-tests with LCov code coverage on MacOS
if: ${{ matrix.os_name == 'macosx' }}
working-directory: 'Build/Output/${{ matrix.config_preset }}/Install/Tests'
run: |
set +e
result_error_level=0
result_ext='.xml'
prof_data_ext='.profdata'
prof_raw_ext='.profraw'
lcov_ext='.lcov'
test_results=''
echo Running unit-tests and Converting LLVM code coverage data to lcov text format in directory $PWD
mkdir Results
mkdir Coverage
for test_exe in *Test
do
./$test_exe -r sonarqube -o "Results/$test_exe$result_ext"
echo - $test_exe - completed with $? exit status
last_error_level=$?
echo - $test_exe - completed with $last_error_level exit status
if [ $last_error_level != 0 ]; then
result_error_level=$last_error_level
fi
if [ -f "$PWD/Results/$test_exe$result_ext" ]; then
test_results+="$PWD/Results/$test_exe$result_ext,"
fi
if [ ! -f default.profraw ]; then
continue
fi
Expand All @@ -226,10 +258,14 @@ jobs:
xcrun llvm-cov export -format lcov -instr-profile="$test_exe$prof_data_ext" -arch=x86_64 ./$test_exe > "./Coverage/$test_exe$lcov_ext"
echo - Converted code coverage from "$test_exe$prof_raw_ext" to lcov text format "./Coverage/$test_exe$lcov_ext", $? exit status
done
echo "Test Result Files: $test_results"
echo "test_results=$test_results" >> $GITHUB_ENV
echo List of generated coverage files in directory $PWD/Coverage
ls -la ./Coverage
exit $result_error_level
- name: Generate Code Coverage Reports
if: ${{ success() || failure() }}
uses: danielpalme/ReportGenerator-GitHub-Action@5.1.13
with:
reports: ${{ matrix.tests_coverage_reports }}
Expand All @@ -239,23 +275,26 @@ jobs:
tag: '${{ env.product_ver_major }}.${{ env.product_ver_minor }}.${{ env.product_ver_patch }}.${{ env.product_ver_build }}'

- name: Upload Code Coverage Cobertura Report
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: MethaneKit_${{ matrix.name }}_CoverageResults
path: Build/Output/${{ matrix.config_preset }}/Install/Tests/Coverage/Report/Cobertura.xml

- name: Upload Build Log and Code Coverage to Testspace server
if: ${{ always() }}
if: ${{ success() || failure() }}
run: testspace "[ ${{ matrix.name }} ]Build/Output/${{ matrix.config_preset }}/Install/Tests/Coverage/Report/Cobertura.xml" "[ ${{ matrix.name }} ]${{ env.BUILD_LOG_FILE }}"

- name: Upload Code Coverage to CodeCov server
if: ${{ success() || failure() }}
uses: codecov/codecov-action@v3
with:
files: Build/Output/${{ matrix.config_preset }}/Install/Tests/Coverage/Report/Cobertura.xml
flags: unittests,${{ matrix.os_name }}
name: ${{ matrix.name }}

- name: Run Sonar Scanner
if: ${{ success() || failure() }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -273,7 +312,7 @@ jobs:
SONAR_SCAN_CMD="$SONAR_SCAN_CMD --define sonar.projectKey=${{ matrix.sonar_project_key }}"
SONAR_SCAN_CMD="$SONAR_SCAN_CMD --define sonar.projectVersion=${{ env.product_ver_major }}.${{ env.product_ver_minor }}.${{ env.product_ver_patch }}.${{ env.product_ver_build }}"
SONAR_SCAN_CMD="$SONAR_SCAN_CMD --define sonar.cfamily.compile-commands=Build/Output/${{ matrix.config_preset }}/Build/compile_commands.json"
SONAR_SCAN_CMD="$SONAR_SCAN_CMD --define sonar.testExecutionReportPaths=$TESTS_DIR/Results/MethaneDataTypesTest.xml,$TESTS_DIR/Results/MethaneDataEventsTest.xml,$TESTS_DIR/Results/MethaneDataRangeSetTest.xml,$TESTS_DIR/Results/MethanePlatformInputTest.xml,$TESTS_DIR/Results/MethaneGraphicsTypesTest.xml,$TESTS_DIR/Results/MethaneGraphicsCameraTest.xml,$TESTS_DIR/Results/MethaneUserInterfaceTypesTest.xml"
SONAR_SCAN_CMD="$SONAR_SCAN_CMD --define sonar.testExecutionReportPaths=${{ env.test_results }}"
SONAR_SCAN_CMD="$SONAR_SCAN_CMD --define sonar.coverageReportPaths=$TESTS_DIR/Coverage/Report/SonarQube.xml"
SONAR_SCAN_CMD="$SONAR_SCAN_CMD --define sonar.scm.revision=${{ github.sha }}"
if [ "${{ github.event_name }}" == "pull_request" ]; then
Expand All @@ -293,13 +332,13 @@ jobs:
done
- name: Archive Scan Artifacts
if: ${{ always() }}
if: ${{ success() || failure() }}
shell: bash
working-directory: Build/Output/${{ matrix.config_preset }}/Install
run: 7z a -t7z -mx=9 MethaneKit_${{ matrix.name }}.7z *

- name: Upload Archived Scan Artifacts
if: ${{ always() }}
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: MethaneKit_${{ matrix.name }}_${{ env.product_ver_major }}.${{ env.product_ver_minor }}.${{ env.product_ver_patch }}.${{ env.product_ver_build }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-tests-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Add PR Comment with Test Results
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event.workflow_run.event == 'pull_request' && steps.test-reporter.outputs.conclusion == 'success' }}
if: ${{ github.event.workflow_run.event == 'pull_request' && steps.test-reporter.outputs.conclusion == 'success' && (success() || failure()) }}
with:
number: ${{ github.event.workflow_run.pull_requests[0].number }}
header: ${{ matrix.name }} Test Results
Expand All @@ -53,7 +53,7 @@ jobs:
- :stopwatch: ${{ steps.test-reporter.outputs.time }} ms. run duration
- name: Add Commit Comment with Test Results
if: ${{ github.event.workflow_run.event == 'push' && steps.test-reporter.outputs.conclusion == 'success' }}
if: ${{ github.event.workflow_run.event == 'push' && steps.test-reporter.outputs.conclusion == 'success' && (success() || failure()) }}
uses: peter-evans/commit-comment@v2
with:
sha: ${{ github.event.workflow_run.head_sha }}
Expand Down
7 changes: 7 additions & 0 deletions .idea/runConfigurations/08_ConsoleCompute.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/runConfigurations/Graphics_RHI_Test.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 17 additions & 16 deletions Apps/02-HelloCube/HelloCubeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ class HelloCubeApp final // NOSONAR - destructor required
Camera m_camera;

#ifdef UNIFORMS_BUFFER_ENABLED
hlslpp::Uniforms m_shader_uniforms { };
const Rhi::SubResources m_shader_uniforms_subresources{
{ reinterpret_cast<Data::ConstRawPtr>(&m_shader_uniforms), sizeof(hlslpp::Uniforms) } // NOSONAR
hlslpp::Uniforms m_shader_uniforms { };
const Rhi::SubResource m_shader_uniforms_subresource{
reinterpret_cast<Data::ConstRawPtr>(&m_shader_uniforms), // NOSONAR
sizeof(hlslpp::Uniforms)
};
Rhi::BufferSet m_vertex_buffer_set;
#else
Expand Down Expand Up @@ -179,19 +180,19 @@ class HelloCubeApp final // NOSONAR - destructor required
// Create index buffer for cube mesh
m_index_buffer = GetRenderContext().CreateBuffer(Rhi::BufferSettings::ForIndexBuffer(m_cube_mesh.GetIndexDataSize(), GetIndexFormat(m_cube_mesh.GetIndex(0))));
m_index_buffer.SetName("Cube Index Buffer");
m_index_buffer.SetData(
{ { reinterpret_cast<Data::ConstRawPtr>(m_cube_mesh.GetIndices().data()), m_cube_mesh.GetIndexDataSize() } }, // NOSONAR
m_render_cmd_queue
);
m_index_buffer.SetData(m_render_cmd_queue, {
reinterpret_cast<Data::ConstRawPtr>(m_cube_mesh.GetIndices().data()), // NOSONAR
m_cube_mesh.GetIndexDataSize()
});

#ifdef UNIFORMS_BUFFER_ENABLED
// Create constant vertex buffer
Rhi::Buffer vertex_buffer = GetRenderContext().CreateBuffer(Rhi::BufferSettings::ForVertexBuffer(m_cube_mesh.GetVertexDataSize(), m_cube_mesh.GetVertexSize()));
vertex_buffer.SetName("Cube Vertex Buffer");
vertex_buffer.SetData(
{ { reinterpret_cast<Data::ConstRawPtr>(m_cube_mesh.GetVertices().data()), m_cube_mesh.GetVertexDataSize() } }, // NOSONAR
m_render_cmd_queue
);
vertex_buffer.SetData(m_render_cmd_queue, {
reinterpret_cast<Data::ConstRawPtr>(m_cube_mesh.GetVertices().data()), // NOSONAR
m_cube_mesh.GetVertexDataSize()
});
m_vertex_buffer_set = Rhi::BufferSet(Rhi::BufferType::Vertex, { vertex_buffer });

const auto uniforms_data_size = static_cast<Data::Size>(sizeof(m_shader_uniforms));
Expand Down Expand Up @@ -268,13 +269,13 @@ class HelloCubeApp final // NOSONAR - destructor required

#ifdef UNIFORMS_BUFFER_ENABLED
// Update uniforms buffer on GPU and apply model-view-projection transformation in vertex shader on GPU
frame.uniforms_buffer.SetData(m_shader_uniforms_subresources, m_render_cmd_queue);
frame.uniforms_buffer.SetData(m_render_cmd_queue, m_shader_uniforms_subresource);
#else
// Update vertex buffer with vertices in camera's projection view
frame.vertex_buffer_set[0].SetData(
{ { reinterpret_cast<Data::ConstRawPtr>(m_proj_vertices.data()), m_cube_mesh.GetVertexDataSize() } }, // NOSONAR
m_render_cmd_queue
);
frame.vertex_buffer_set[0].SetData(m_render_cmd_queue, {
reinterpret_cast<Data::ConstRawPtr>(m_proj_vertices.data()), // NOSONAR
m_cube_mesh.GetVertexDataSize()
});
#endif

// Issue commands for cube rendering
Expand Down

9 comments on commit 4299e05

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacOS_MTL_Release Test Results

  • ✅ 3125 tests passed
  • ❌ 0 tests failed
  • ⚠️ 0 tests skipped
  • ⏱️ 946 ms. run duration

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win64_VK_Release Test Results

  • ✅ 3125 tests passed
  • ❌ 0 tests failed
  • ⚠️ 0 tests skipped
  • ⏱️ 1000 ms. run duration

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win64_DX_Release Test Results

  • ✅ 3125 tests passed
  • ❌ 0 tests failed
  • ⚠️ 0 tests skipped
  • ⏱️ 983 ms. run duration

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu_VK_Release Test Results

  • ✅ 3126 tests passed
  • ❌ 0 tests failed
  • ⚠️ 0 tests skipped
  • ⏱️ 14310 ms. run duration

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win32_VK_Release Test Results

  • ✅ 3125 tests passed
  • ❌ 0 tests failed
  • ⚠️ 0 tests skipped
  • ⏱️ 1014 ms. run duration

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win32_DX_Release Test Results

  • ✅ 3125 tests passed
  • ❌ 0 tests failed
  • ⚠️ 0 tests skipped
  • ⏱️ 981 ms. run duration

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win64_DX_SonarScan Tests Code Coverage

Code Coverage

Package Line Rate Branch Rate Health
D:\a\MethaneKit\MethaneKit\Build\Output\Ninja-Win-DX-Scan\Install\Tests\MethaneDataEventsTest.exe 95% 100%
D:\a\MethaneKit\MethaneKit\Build\Output\Ninja-Win-DX-Scan\Install\Tests\MethaneDataRangeSetTest.exe 91% 100%
D:\a\MethaneKit\MethaneKit\Build\Output\Ninja-Win-DX-Scan\Install\Tests\MethaneDataTypesTest.exe 98% 100%
D:\a\MethaneKit\MethaneKit\Build\Output\Ninja-Win-DX-Scan\Install\Tests\MethaneGraphicsCameraTest.exe 61% 100%
D:\a\MethaneKit\MethaneKit\Build\Output\Ninja-Win-DX-Scan\Install\Tests\MethaneGraphicsRhiTest.exe 43% 100%
D:\a\MethaneKit\MethaneKit\Build\Output\Ninja-Win-DX-Scan\Install\Tests\MethaneGraphicsTypesTest.exe 98% 100%
D:\a\MethaneKit\MethaneKit\Build\Output\Ninja-Win-DX-Scan\Install\Tests\MethanePlatformInputTest.exe 43% 100%
D:\a\MethaneKit\MethaneKit\Build\Output\Ninja-Win-DX-Scan\Install\Tests\MethaneUserInterfaceTypesTest.exe 9% 100%
Summary 34% (4497 / 13281) 100% (0 / 0)

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu_VK_SonarScan Tests Code Coverage

Code Coverage

Package Line Rate Branch Rate Health
Default 38% 100%
Summary 38% (7679 / 20087) 100% (0 / 0)

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacOS_MTL_SonarScan Tests Code Coverage

Code Coverage

Package Line Rate Branch Rate Health
Default 51% 21%
Summary 51% (12688 / 24964) 21% (3624 / 17168)

Please sign in to comment.