From a053f3d5d4fef3daac34248b13f6ef524bd22e0d Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sun, 14 Jul 2019 12:18:07 +0300 Subject: [PATCH 01/16] Fix multiple scattering bug Changing the multiple scattering probability did not trigger a new render if maximum simulation iterations had already been reached. --- CHANGELOG.md | 6 ++++++ src/gui/mainWindow.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e894de..a28d6de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed +- Fixed bug where changing multiple scattering probability did not trigger a new + render if maximum iterations were reached + ## 2.3.1 - 2019-07-14 ### Fixed diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index 783b58f..f74497d 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -75,6 +75,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) connect(mGeneralSettingsWidget, &GeneralSettingsWidget::maximumNumberOfIterationsChanged, mProgressBar, &QProgressBar::setMaximum); connect(mGeneralSettingsWidget, &GeneralSettingsWidget::multipleScatteringProbabilityChanged, [this](double value) { mEngine->setMultipleScatteringProbability(value); + mOpenGLWidget->update(); }); mGeneralSettingsWidget->setInitialValues(mEngine->getLightSource().diameter, From 9fece3d3e24ddc32b6a11a5300d48f4cb54d398a Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sun, 14 Jul 2019 19:18:27 +0300 Subject: [PATCH 02/16] Fix crashing on Intel GPUs and Linux Not sure if the crashing was about the long uniform name for the multiple scattering probability or the caching of shader binaries, but these change seemed to get rid of crashing. --- CHANGELOG.md | 6 ++++-- src/resources/shaders/raytrace.glsl | 5 ++--- src/simulation/simulationEngine.cpp | 6 +++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a28d6de..398fc31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Fixed -- Fixed bug where changing multiple scattering probability did not trigger a new +- Bug where changing multiple scattering probability did not trigger a new render if maximum iterations were reached +- Crashing on Intel GPUs with Linux and Mesa3D + ## 2.3.1 - 2019-07-14 ### Fixed -- Fixed build configuration bug where resources were not being linked on Linux +- Build configuration bug where resources were not being linked on Linux ## 2.3.0 - 2019-07-13 diff --git a/src/resources/shaders/raytrace.glsl b/src/resources/shaders/raytrace.glsl index e3e307b..900217c 100644 --- a/src/resources/shaders/raytrace.glsl +++ b/src/resources/shaders/raytrace.glsl @@ -8,6 +8,7 @@ layout(binding = 0, rgba32f) uniform coherent image2D outputImage; layout(binding = 1, r32ui) uniform coherent uimage2D spinlock; uniform uint rngSeed; +uniform float multipleScatter; uniform struct sunProperties_t { @@ -44,8 +45,6 @@ uniform struct camera_t int hideSubHorizon; } camera; -uniform float multipleScatteringProbability; - const float PI = 3.1415926535; struct intersection { @@ -467,7 +466,7 @@ void main(void) resultRay = rotationMatrix * resultRay; - if (multipleScatteringProbability != 0.0 && multipleScatteringProbability > rand()) + if (multipleScatter != 0.0 && multipleScatter > rand()) { // Rotation matrix to orient ray/crystal rotationMatrix = getRotationMatrix(); diff --git a/src/simulation/simulationEngine.cpp b/src/simulation/simulationEngine.cpp index 2ee4a60..6b2d706 100644 --- a/src/simulation/simulationEngine.cpp +++ b/src/simulation/simulationEngine.cpp @@ -136,7 +136,7 @@ void SimulationEngine::step() mSimulationShader->setUniformValue("camera.projection", mCamera.projection); mSimulationShader->setUniformValue("camera.hideSubHorizon", mCamera.hideSubHorizon ? 1 : 0); - mSimulationShader->setUniformValue("multipleScatteringProbability", mMultipleScatteringProbability); + mSimulationShader->setUniformValue("multipleScatter", mMultipleScatteringProbability); glDispatchCompute(numRays, 1, 1); } @@ -178,7 +178,11 @@ void SimulationEngine::initialize() void SimulationEngine::initializeShader() { mSimulationShader = std::make_unique(); +#ifdef _WIN32 mSimulationShader->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Compute, ":/shaders/raytrace.glsl"); +#else + mSimulationShader->addShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Compute, ":/shaders/raytrace.glsl"); +#endif if (mSimulationShader->link() == false) { throw std::runtime_error(mSimulationShader->log().toUtf8()); From 966cf77b9f9faf85b75520cc0da4c6b7bed0bbbe Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sun, 14 Jul 2019 22:49:52 +0300 Subject: [PATCH 03/16] Fix typo in build script --- scripts/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 821a9ca..4ce3a83 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -23,7 +23,7 @@ cd .\src\Release\ --no-webkit2 ` --no-angle ` --no-opengl-sw ` - -no-system-d3d-compiler ` + --no-system-d3d-compiler ` --release ` haloray.exe popd From 79ca5be689abd2c87af8583cb527bc28ea64e283 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 18 Jul 2019 21:00:44 +0300 Subject: [PATCH 04/16] Show error message and quit if OpenGL 4.4 not supported --- CHANGELOG.md | 4 +++- src/main.cpp | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 398fc31..299a7ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added +- Show error dialog and exit if GPU does not support OpenGL 4.4 + ### Fixed - Bug where changing multiple scattering probability did not trigger a new render if maximum iterations were reached - Crashing on Intel GPUs with Linux and Mesa3D - ## 2.3.1 - 2019-07-14 ### Fixed diff --git a/src/main.cpp b/src/main.cpp index 10f2c8a..6a6c3cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,10 @@ #include #include #include +#include +#include +#include +#include #include "gui/mainWindow.h" void logHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) @@ -28,18 +32,40 @@ void logHandler(QtMsgType type, const QMessageLogContext &context, const QString } } +bool supportsOpenGL(int requiredMajorVersion, int requiredMinorVersion) +{ + auto testContext = new QOpenGLContext(); + auto majorVersion = testContext->format().majorVersion(); + auto minorVersion = testContext->format().minorVersion(); + delete testContext; + return majorVersion > requiredMajorVersion || + (majorVersion == requiredMajorVersion && minorVersion >= requiredMinorVersion); +} + int main(int argc, char *argv[]) { qInstallMessageHandler(logHandler); QApplication app(argc, argv); + const int requiredOpenGLMajorVersion = 4; + const int requiredOpenGLMinorVersion = 4; + QSurfaceFormat format; - format.setVersion(4, 4); + format.setVersion(requiredOpenGLMajorVersion, requiredOpenGLMinorVersion); format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); format.setSwapBehavior(QSurfaceFormat::SwapBehavior::DoubleBuffer); format.setSwapInterval(1); QSurfaceFormat::setDefaultFormat(format); + if (!supportsOpenGL(requiredOpenGLMajorVersion, requiredOpenGLMinorVersion)) + { + QString errorMessage = QString(QObject::tr("Your graphics processing unit does not support OpenGL %1.%2, which is required to run HaloRay.")) + .arg(requiredOpenGLMajorVersion) + .arg(requiredOpenGLMinorVersion); + QMessageBox::critical(nullptr, QObject::tr("Incompatible GPU"), errorMessage); + return 1; + } + MainWindow mainWindow; mainWindow.show(); From 7e46614e06d8c4534d56dcc571ddb45d9ac7ad43 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 18 Jul 2019 22:06:03 +0300 Subject: [PATCH 05/16] Show branch name correctly in AppVeyor artifacts The git branch is supposed to be shown in the title of HaloRay, but AppVeyor does a shallow clone of the repository and the branch name only shows HEAD. The branch name can however be recovered using the APPVEYOR_REPO_BRANCH environment variable. --- CMakeLists.txt | 9 ++------- scripts/build.ps1 | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6217ae6..9ec20bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,8 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) project(HaloRay) -# Get the current working branch -execute_process( - COMMAND git rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE -) +# Optionally set the git branch in AppVeyor +option(GIT_BRANCH "Current git branch" HEAD) # Get the latest abbreviated commit hash of the working branch execute_process( diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 4ce3a83..5e54735 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -6,7 +6,7 @@ $gitBranch = $env:APPVEYOR_REPO_BRANCH $extraParameters = if ($gitBranch -eq "master") { "-DHALORAY_VERSION='${env:APPVEYOR_BUILD_VERSION}'" } else { - "" + "-DGIT_BRANCH='${gitBranch}'" } pushd From e2c0d6897e33820c1237703b9dff084f04ae93a5 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sat, 6 Jul 2019 19:50:05 +0300 Subject: [PATCH 06/16] Add Qt tests with camera projection tests as an example --- .gitignore | 1 + CMakeLists.txt | 12 ++++++++++++ src/CMakeLists.txt | 22 ++++++++-------------- src/main.cpp | 1 + tests/CMakeLists.txt | 7 +++++++ tests/cameraTests.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/cameraTests.cpp diff --git a/.gitignore b/.gitignore index e922367..a613412 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/* .vscode/* src/version.h +Testing/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ec20bb..67f49ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,20 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +enable_testing() + if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() +# find includes in the corresponding build directories +set(CMAKE_INCLUDE_CURRENT_DIR ON) +# Instruct CMake to run moc automatically when needed +set(CMAKE_AUTOMOC ON) +# Instruct CMake to run Qt RCC for resource files +set(CMAKE_AUTORCC ON) + +find_package(Qt5 COMPONENTS REQUIRED Core Widgets Gui Test) + add_subdirectory(src) +add_subdirectory(tests) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ecf7abb..1a54c3d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,14 +1,4 @@ -# find includes in the corresponding build directories -set(CMAKE_INCLUDE_CURRENT_DIR ON) -# Instruct CMake to run moc automatically when needed -set(CMAKE_AUTOMOC ON) -# Instruct CMake to run Qt RCC for resource files -set(CMAKE_AUTORCC ON) - -find_package(Qt5 COMPONENTS REQUIRED Core Widgets Gui) - set(HALORAY_SOURCES - main.cpp gui/mainWindow.cpp gui/openGLWidget.cpp gui/generalSettingsWidget.cpp @@ -27,12 +17,16 @@ set(HALORAY_SOURCES opengl/textureRenderer.cpp ) -set(RESOURCE_FILES resources/haloray.qrc resources/haloray.rc) +set(RESOURCE_FILES resources/haloray.qrc) + +add_library(halorayLib STATIC ${HALORAY_SOURCES} ${RESOURCE_FILES}) +target_link_libraries(halorayLib Qt5::Core Qt5::Widgets Qt5::Gui) IF (WIN32) - add_executable(haloray WIN32 ${HALORAY_SOURCES} ${RESOURCE_FILES}) + add_executable(haloray WIN32 main.cpp resources/haloray.rc) ELSE() - add_executable(haloray ${HALORAY_SOURCES} ${RESOURCE_FILES}) + add_executable(haloray main.cpp) ENDIF() -target_link_libraries(haloray Qt5::Core Qt5::Widgets Qt5::Gui) + +target_link_libraries(haloray Qt5::Core Qt5::Widgets Qt5::Gui halorayLib) diff --git a/src/main.cpp b/src/main.cpp index 6a6c3cb..f70719d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,6 +44,7 @@ bool supportsOpenGL(int requiredMajorVersion, int requiredMinorVersion) int main(int argc, char *argv[]) { + Q_INIT_RESOURCE(haloray); qInstallMessageHandler(logHandler); QApplication app(argc, argv); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..e714e2b --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,7 @@ +set(TEST_SOURCES + cameraTests.cpp +) + +add_executable(halorayTests ${TEST_SOURCES}) +target_link_libraries(halorayTests Qt5::Core Qt5::Test halorayLib) +add_test(halorayTests halorayTests) diff --git a/tests/cameraTests.cpp b/tests/cameraTests.cpp new file mode 100644 index 0000000..97baccd --- /dev/null +++ b/tests/cameraTests.cpp @@ -0,0 +1,39 @@ +#include +#include "../src/simulation/camera.h" + +Q_DECLARE_METATYPE(HaloSim::Projection) + +using namespace HaloSim; + +class CameraTests : public QObject +{ + Q_OBJECT +private slots: + void maxFov(); + void maxFov_data(); +}; + +void CameraTests::maxFov() +{ + QFETCH(Projection, projection); + QFETCH(float, expectedMaxFov); + + auto c = Camera(); + c.projection = projection; + QCOMPARE(c.getMaximumFov(), expectedMaxFov); +} + +void CameraTests::maxFov_data() +{ + QTest::addColumn("projection"); + QTest::addColumn("expectedMaxFov"); + + QTest::newRow("stereographic") << Projection::Stereographic << 350.0f; + QTest::newRow("rectilinear") << Projection::Rectilinear << 160.0f; + QTest::newRow("equidistant") << Projection::Equidistant << 360.0f; + QTest::newRow("equal area") << Projection::EqualArea << 360.0f; + QTest::newRow("orthographic") << Projection::Orthographic << 180.0f; +} + +QTEST_MAIN(CameraTests) +#include "cameraTests.moc" From 1a92889933fe08f40124759da321ddbeb8d17ca8 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sun, 14 Jul 2019 22:38:10 +0300 Subject: [PATCH 07/16] Remove .lib files from build artifacts --- scripts/package.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/package.ps1 b/scripts/package.ps1 index 5bead40..91c61ce 100644 --- a/scripts/package.ps1 +++ b/scripts/package.ps1 @@ -3,12 +3,13 @@ $ErrorActionPreference = "Stop"; $version = if ($env:APPVEYOR_REPO_BRANCH -eq "master") { "v${env:APPVEYOR_BUILD_VERSION}" -} else { +} +else { "${env:APPVEYOR_REPO_COMMIT}" } $destination = "${env:APPVEYOR_BUILD_FOLDER}\haloray-${version}.zip" $buildLocation = "${env:APPVEYOR_BUILD_FOLDER}\build\src\Release\*" -7z a $destination $buildLocation -7z a $destination "${env:APPVEYOR_BUILD_FOLDER}\*.md" \ No newline at end of file +7z a $destination $buildLocation -x!*.lib +7z a $destination "${env:APPVEYOR_BUILD_FOLDER}\*.md" From 80a09bb8d1467da53519804363135e1a6792a6f2 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sun, 14 Jul 2019 22:49:21 +0300 Subject: [PATCH 08/16] Run windeployqt on test executable too --- scripts/build.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 5e54735..bb6cdea 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -26,4 +26,15 @@ cd .\src\Release\ --no-system-d3d-compiler ` --release ` haloray.exe + +cd ..\tests\Release\ +& "${env:Qt5_DIR}\bin\windeployqt.exe" ` + --no-quick-import ` + --no-translations ` + --no-webkit2 ` + --no-angle ` + --no-opengl-sw ` + --no-system-d3d-compiler ` + --release ` + halorayTests.exe popd From e4a9fb53600f00cb28156646c0470b5cb2d64094 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sun, 14 Jul 2019 23:18:50 +0300 Subject: [PATCH 09/16] Add test running step to AppVeyor file --- CMakeLists.txt | 1 + appveyor.yml | 3 +++ scripts/build.ps1 | 8 +++++++- scripts/package.ps1 | 2 +- scripts/test.ps1 | 17 +++++++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 scripts/test.ps1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 67f49ac..8c98d0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) project(HaloRay) +include(Dart) # Optionally set the git branch in AppVeyor option(GIT_BRANCH "Current git branch" HEAD) diff --git a/appveyor.yml b/appveyor.yml index 4baf777..a510c65 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,7 @@ branches: only: - master - develop + - feature/add-tests image: Visual Studio 2017 clone_depth: 1 environment: @@ -12,6 +13,8 @@ build_script: - ps: scripts\build.ps1 after_build: - ps: scripts\package.ps1 +test_script: + - ps: scripts\test.ps1 artifacts: - path: '*.zip' deploy: diff --git a/scripts/build.ps1 b/scripts/build.ps1 index bb6cdea..975d770 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -12,6 +12,8 @@ $extraParameters = if ($gitBranch -eq "master") { pushd mkdir build cd build + +pushd cmake .. -G "Visual Studio 15 2017 Win64" $extraParameters cmake --build . --config Release cd .\src\Release\ @@ -26,8 +28,10 @@ cd .\src\Release\ --no-system-d3d-compiler ` --release ` haloray.exe +popd -cd ..\tests\Release\ +pushd +cd .\tests\Release\ & "${env:Qt5_DIR}\bin\windeployqt.exe" ` --no-quick-import ` --no-translations ` @@ -38,3 +42,5 @@ cd ..\tests\Release\ --release ` halorayTests.exe popd + +popd diff --git a/scripts/package.ps1 b/scripts/package.ps1 index 91c61ce..3492fdc 100644 --- a/scripts/package.ps1 +++ b/scripts/package.ps1 @@ -11,5 +11,5 @@ else { $destination = "${env:APPVEYOR_BUILD_FOLDER}\haloray-${version}.zip" $buildLocation = "${env:APPVEYOR_BUILD_FOLDER}\build\src\Release\*" -7z a $destination $buildLocation -x!*.lib +7z a $destination $buildLocation '-x!*.lib' 7z a $destination "${env:APPVEYOR_BUILD_FOLDER}\*.md" diff --git a/scripts/test.ps1 b/scripts/test.ps1 new file mode 100644 index 0000000..012350d --- /dev/null +++ b/scripts/test.ps1 @@ -0,0 +1,17 @@ +# Windows test script for Appveyor + +$ErrorActionPreference = "Stop"; + +$env:APPVEYOR_JOB_ID + +pushd +cd build +ctest --no-compress-output -T Test +$testReport = Get-ChildItem -Path .\Testing\*\Test.xml | Select-Object -First 1 +$testReport +$res = (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/xunit/$($env:APPVEYOR_JOB_ID)", $testReport.FullName) +$res +if ($res.FailedCount -gt 0) { + throw "$($res.FailedCount) tests failed." +} +popd From 3f653e2e227c82eeb40e77bf62cbed52ac942acc Mon Sep 17 00:00:00 2001 From: Ilya Finkelshteyn Date: Mon, 15 Jul 2019 13:51:17 -0700 Subject: [PATCH 10/16] Convert CTest results to JUnit format for AppVeyor CTest results don't seem to be xUnit compatible. They are pretty easy to convert to JUnit format with instructions from AppVeyor, though: https://help.appveyor.com/discussions/suggestions/5298-support-ctest-xml-test-results --- scripts/test.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/test.ps1 b/scripts/test.ps1 index 012350d..bbbc13e 100644 --- a/scripts/test.ps1 +++ b/scripts/test.ps1 @@ -9,8 +9,15 @@ cd build ctest --no-compress-output -T Test $testReport = Get-ChildItem -Path .\Testing\*\Test.xml | Select-Object -First 1 $testReport -$res = (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/xunit/$($env:APPVEYOR_JOB_ID)", $testReport.FullName) -$res + +$XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform +$XSLInputElement.Load("https://raw.githubusercontent.com/rpavlik/jenkins-ctest-plugin/master/ctest-to-junit.xsl") +$XSLInputElement.Transform($(Resolve-Path $testReport.FullName), (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml")) +$wc = New-Object 'System.Net.WebClient' +$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\ctest-to-junit-results.xml)) + +$wc.UploadFile("https://ci.appveyor.com/api/testresults/xunit/$($env:APPVEYOR_JOB_ID)", $(Resolve-Path $testReport.FullName)) + if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed." } From 7aaec114338be2939e50331b7ac1e59e24aae5d6 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Tue, 16 Jul 2019 00:06:16 +0300 Subject: [PATCH 11/16] Fetch local copy of ctest-to-junit.xsl file --- scripts/ctest-to-junit.xsl | 36 ++++++++++++++++++++++++++++++++++++ scripts/test.ps1 | 23 ++++++++++------------- 2 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 scripts/ctest-to-junit.xsl diff --git a/scripts/ctest-to-junit.xsl b/scripts/ctest-to-junit.xsl new file mode 100644 index 0000000..8ac48f5 --- /dev/null +++ b/scripts/ctest-to-junit.xsl @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/test.ps1 b/scripts/test.ps1 index bbbc13e..1b6a492 100644 --- a/scripts/test.ps1 +++ b/scripts/test.ps1 @@ -2,23 +2,20 @@ $ErrorActionPreference = "Stop"; -$env:APPVEYOR_JOB_ID +$XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform +$XSLInputElement.Load($(Join-Path $env:APPVEYOR_BUILD_FOLDER "scripts\ctest-to-junit.xsl")) pushd cd build ctest --no-compress-output -T Test -$testReport = Get-ChildItem -Path .\Testing\*\Test.xml | Select-Object -First 1 -$testReport - -$XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform -$XSLInputElement.Load("https://raw.githubusercontent.com/rpavlik/jenkins-ctest-plugin/master/ctest-to-junit.xsl") -$XSLInputElement.Transform($(Resolve-Path $testReport.FullName), (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml")) -$wc = New-Object 'System.Net.WebClient' -$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\ctest-to-junit-results.xml)) - -$wc.UploadFile("https://ci.appveyor.com/api/testresults/xunit/$($env:APPVEYOR_JOB_ID)", $(Resolve-Path $testReport.FullName)) +foreach ($testReport in Get-ChildItem -Path .\Testing\*\Test.xml) +{ + $XSLInputElement.Transform($(Resolve-Path $testReport.FullName), (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml")) + $wc = New-Object 'System.Net.WebClient' + $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\ctest-to-junit-results.xml)) -if ($res.FailedCount -gt 0) { - throw "$($res.FailedCount) tests failed." + if ($res.FailedCount -gt 0) { + throw "$($res.FailedCount) tests failed." + } } popd From 8a40c972a50342defc367fee52b987e33eb1d9c3 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 18 Jul 2019 22:56:12 +0300 Subject: [PATCH 12/16] Change GIT_BRANCH CMake option to cache variable Options can only have values ON or OFF, which is not suitable for a git branch name. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c98d0e..74358ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(HaloRay) include(Dart) # Optionally set the git branch in AppVeyor -option(GIT_BRANCH "Current git branch" HEAD) +set(GIT_BRANCH "Local build" CACHE STRING "Git branch to show in dev builds") # Get the latest abbreviated commit hash of the working branch execute_process( From 3ccd813adb3b01dce10165756bd2155913a0aaf0 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 18 Jul 2019 23:24:37 +0300 Subject: [PATCH 13/16] Add unit tests for CrystalPopulationRepository --- scripts/build.ps1 | 2 +- tests/CMakeLists.txt | 12 +++--- tests/cameraTests.cpp | 44 +++++++++---------- tests/crystalPopulationRepositoryTests.cpp | 49 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 31 deletions(-) create mode 100644 tests/crystalPopulationRepositoryTests.cpp diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 975d770..4d6c00b 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -40,7 +40,7 @@ cd .\tests\Release\ --no-opengl-sw ` --no-system-d3d-compiler ` --release ` - halorayTests.exe + . popd popd diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e714e2b..1fcc675 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,7 @@ -set(TEST_SOURCES - cameraTests.cpp -) +add_executable(cameraTests cameraTests.cpp) +target_link_libraries(cameraTests Qt5::Core Qt5::Test halorayLib) +add_test(cameraTests cameraTests) -add_executable(halorayTests ${TEST_SOURCES}) -target_link_libraries(halorayTests Qt5::Core Qt5::Test halorayLib) -add_test(halorayTests halorayTests) +add_executable(crystalRepoTests crystalPopulationRepositoryTests.cpp) +target_link_libraries(crystalRepoTests Qt5::Core Qt5::Test halorayLib) +add_test(crystalRepoTests crystalRepoTests) diff --git a/tests/cameraTests.cpp b/tests/cameraTests.cpp index 97baccd..237429f 100644 --- a/tests/cameraTests.cpp +++ b/tests/cameraTests.cpp @@ -9,31 +9,27 @@ class CameraTests : public QObject { Q_OBJECT private slots: - void maxFov(); - void maxFov_data(); + void maxFov() + { + QFETCH(Projection, projection); + QFETCH(float, expectedMaxFov); + + auto c = Camera(); + c.projection = projection; + QCOMPARE(c.getMaximumFov(), expectedMaxFov); + } + void maxFov_data() + { + QTest::addColumn("projection"); + QTest::addColumn("expectedMaxFov"); + + QTest::newRow("stereographic") << Projection::Stereographic << 350.0f; + QTest::newRow("rectilinear") << Projection::Rectilinear << 160.0f; + QTest::newRow("equidistant") << Projection::Equidistant << 360.0f; + QTest::newRow("equal area") << Projection::EqualArea << 360.0f; + QTest::newRow("orthographic") << Projection::Orthographic << 180.0f; + } }; -void CameraTests::maxFov() -{ - QFETCH(Projection, projection); - QFETCH(float, expectedMaxFov); - - auto c = Camera(); - c.projection = projection; - QCOMPARE(c.getMaximumFov(), expectedMaxFov); -} - -void CameraTests::maxFov_data() -{ - QTest::addColumn("projection"); - QTest::addColumn("expectedMaxFov"); - - QTest::newRow("stereographic") << Projection::Stereographic << 350.0f; - QTest::newRow("rectilinear") << Projection::Rectilinear << 160.0f; - QTest::newRow("equidistant") << Projection::Equidistant << 360.0f; - QTest::newRow("equal area") << Projection::EqualArea << 360.0f; - QTest::newRow("orthographic") << Projection::Orthographic << 180.0f; -} - QTEST_MAIN(CameraTests) #include "cameraTests.moc" diff --git a/tests/crystalPopulationRepositoryTests.cpp b/tests/crystalPopulationRepositoryTests.cpp new file mode 100644 index 0000000..f1858aa --- /dev/null +++ b/tests/crystalPopulationRepositoryTests.cpp @@ -0,0 +1,49 @@ +#include +#include "../src/simulation/crystalPopulationRepository.h" + +class CrystalPopulationRepositoryTests : public QObject +{ + Q_OBJECT +private slots: + void hasThreePopulationsByDefault() + { + auto repository = HaloSim::CrystalPopulationRepository(); + QCOMPARE(repository.getCount(), 3); + } + + void addingPopulationIncreasesCount() + { + auto repository = HaloSim::CrystalPopulationRepository(); + auto originalCount = repository.getCount(); + repository.add(HaloSim::CrystalPopulationPreset::Random); + QCOMPARE(repository.getCount(), originalCount + 1); + } + + void removingPopulationDecreasesCount() + { + auto repository = HaloSim::CrystalPopulationRepository(); + auto originalCount = repository.getCount(); + repository.add(HaloSim::CrystalPopulationPreset::Random); + repository.remove(0); + QCOMPARE(repository.getCount(), originalCount); + } + + void evenProbabilitiesByDefault() + { + auto repository = HaloSim::CrystalPopulationRepository(); + QCOMPARE(repository.getProbability(0), 1.0 / 3.0); + QCOMPARE(repository.getProbability(1), 1.0 / 3.0); + QCOMPARE(repository.getProbability(2), 1.0 / 3.0); + } + + void evenWeightsByDefault() + { + auto repository = HaloSim::CrystalPopulationRepository(); + QCOMPARE(repository.getWeight(0), 1); + QCOMPARE(repository.getWeight(1), 1); + QCOMPARE(repository.getWeight(2), 1); + } +}; + +QTEST_MAIN(CrystalPopulationRepositoryTests) +#include "crystalPopulationRepositoryTests.moc" From 64ded0d253e8c6a4a44889b295211a5c210958ce Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 18 Jul 2019 23:39:15 +0300 Subject: [PATCH 14/16] Remove feature branch from AppVeyor config file --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index a510c65..14857b8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,6 @@ branches: only: - master - develop - - feature/add-tests image: Visual Studio 2017 clone_depth: 1 environment: From 6e1e795bce6e2765bec5525336faaa1e8eadeb8f Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sat, 20 Jul 2019 16:18:14 +0300 Subject: [PATCH 15/16] Fix Linux compilation issue I got some reports of having difficulties compiling HaloRay without adding an include for QAbstractItemModel because of the checkIndex call. QAbstractItemModel is a grandparent class for CrystalModel, and I have been able to succesfully compile everything without the explicit include, but it does not hurt to have it either. --- src/gui/crystalModel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/crystalModel.cpp b/src/gui/crystalModel.cpp index b5d3c8e..ce06331 100644 --- a/src/gui/crystalModel.cpp +++ b/src/gui/crystalModel.cpp @@ -1,4 +1,5 @@ #include "crystalModel.h" +#include CrystalModel::CrystalModel(std::shared_ptr crystalRepository, QWidget *parent) : QAbstractTableModel(parent), From faa27f84c3159e1e18dd407e6d8aef7f70515e9a Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Mon, 29 Jul 2019 22:38:55 +0300 Subject: [PATCH 16/16] Bump version number --- CHANGELOG.md | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 299a7ab..7f56aea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## 2.4.0 - 2019-07-29 ### Added - Show error dialog and exit if GPU does not support OpenGL 4.4 diff --git a/appveyor.yml b/appveyor.yml index 14857b8..412de44 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: '2.3.1-{build}' +version: '2.4.0-{build}' branches: only: - master