Skip to content

Commit

Permalink
Merge branch 'release/2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
naavis committed Jul 29, 2019
2 parents 0a5be53 + faa27f8 commit 48ad57e
Show file tree
Hide file tree
Showing 17 changed files with 246 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/*
.vscode/*
src/version.h
Testing/
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ 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).

## 2.4.0 - 2019-07-29

### 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
- 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

Expand Down
22 changes: 15 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
project(HaloRay)
include(Dart)

# 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
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(
Expand All @@ -30,8 +26,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)
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2.3.1-{build}'
version: '2.4.0-{build}'
branches:
only:
- master
Expand All @@ -12,6 +12,8 @@ build_script:
- ps: scripts\build.ps1
after_build:
- ps: scripts\package.ps1
test_script:
- ps: scripts\test.ps1
artifacts:
- path: '*.zip'
deploy:
Expand Down
21 changes: 19 additions & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ $gitBranch = $env:APPVEYOR_REPO_BRANCH
$extraParameters = if ($gitBranch -eq "master") {
"-DHALORAY_VERSION='${env:APPVEYOR_BUILD_VERSION}'"
} else {
""
"-DGIT_BRANCH='${gitBranch}'"
}

pushd
mkdir build
cd build

pushd
cmake .. -G "Visual Studio 15 2017 Win64" $extraParameters
cmake --build . --config Release
cd .\src\Release\
Expand All @@ -23,7 +25,22 @@ cd .\src\Release\
--no-webkit2 `
--no-angle `
--no-opengl-sw `
-no-system-d3d-compiler `
--no-system-d3d-compiler `
--release `
haloray.exe
popd

pushd
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 `
.
popd

popd
36 changes: 36 additions & 0 deletions scripts/ctest-to-junit.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<testsuites>
<xsl:variable name="buildName" select="//Site/@BuildName"/>
<xsl:variable name="numberOfTests" select="count(//Site/Testing/Test)"/>
<xsl:variable name="numberOfFailures" select="count(//Site/Testing/Test[@Status!='passed'])" />
<testsuite name="CTest"
tests="{$numberOfTests}" time="0"
failures="{$numberOfFailures}" errors="0"
skipped="0">
<xsl:for-each select="//Site/Testing/Test">
<xsl:variable name="testName" select="translate(Name, '-', '_')"/>
<xsl:variable name="duration" select="Results/NamedMeasurement[@name='Execution Time']/Value"/>
<xsl:variable name="status" select="@Status"/>
<xsl:variable name="output" select="Results/Measurement/Value"/>
<xsl:variable name="className" select="translate(Path, '/.', '.')"/>
<testcase classname="projectroot{$className}"
name="{$testName}"
time="{$duration}">
<xsl:if test="@Status!='passed'">
<failure>
<xsl:value-of select="$output" />
</failure>
</xsl:if>
<system-out>
<xsl:value-of select="$output" />
</system-out>
</testcase>
</xsl:for-each>
</testsuite>
</testsuites>
</xsl:template>
</xsl:stylesheet>

7 changes: 4 additions & 3 deletions scripts/package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7z a $destination $buildLocation '-x!*.lib'
7z a $destination "${env:APPVEYOR_BUILD_FOLDER}\*.md"
21 changes: 21 additions & 0 deletions scripts/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Windows test script for Appveyor

$ErrorActionPreference = "Stop";

$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
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."
}
}
popd
22 changes: 8 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
1 change: 1 addition & 0 deletions src/gui/crystalModel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "crystalModel.h"
#include <QAbstractItemModel>

CrystalModel::CrystalModel(std::shared_ptr<HaloSim::CrystalPopulationRepository> crystalRepository, QWidget *parent)
: QAbstractTableModel(parent),
Expand Down
1 change: 1 addition & 0 deletions src/gui/mainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 28 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <QtGlobal>
#include <QApplication>
#include <QSurfaceFormat>
#include <QMessageBox>
#include <QOpenGLContext>
#include <QString>
#include <QObject>
#include "gui/mainWindow.h"

void logHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
Expand Down Expand Up @@ -28,18 +32,41 @@ 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[])
{
Q_INIT_RESOURCE(haloray);
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();

Expand Down
5 changes: 2 additions & 3 deletions src/resources/shaders/raytrace.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -44,8 +45,6 @@ uniform struct camera_t
int hideSubHorizon;
} camera;

uniform float multipleScatteringProbability;

const float PI = 3.1415926535;

struct intersection {
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion src/simulation/simulationEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -178,7 +178,11 @@ void SimulationEngine::initialize()
void SimulationEngine::initializeShader()
{
mSimulationShader = std::make_unique<QOpenGLShaderProgram>();
#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());
Expand Down
7 changes: 7 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_executable(cameraTests cameraTests.cpp)
target_link_libraries(cameraTests Qt5::Core Qt5::Test halorayLib)
add_test(cameraTests cameraTests)

add_executable(crystalRepoTests crystalPopulationRepositoryTests.cpp)
target_link_libraries(crystalRepoTests Qt5::Core Qt5::Test halorayLib)
add_test(crystalRepoTests crystalRepoTests)
35 changes: 35 additions & 0 deletions tests/cameraTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <QtTest/QtTest>
#include "../src/simulation/camera.h"

Q_DECLARE_METATYPE(HaloSim::Projection)

using namespace HaloSim;

class CameraTests : public QObject
{
Q_OBJECT
private slots:
void maxFov()
{
QFETCH(Projection, projection);
QFETCH(float, expectedMaxFov);

auto c = Camera();
c.projection = projection;
QCOMPARE(c.getMaximumFov(), expectedMaxFov);
}
void maxFov_data()
{
QTest::addColumn<Projection>("projection");
QTest::addColumn<float>("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"
Loading

0 comments on commit 48ad57e

Please sign in to comment.