Skip to content

Commit

Permalink
Added various command line options for automated functional testing, …
Browse files Browse the repository at this point in the history
…a GitLab CI configuration, and reduced the console output in non-verbose mode.

The tests and reference images are stored separately.
  • Loading branch information
apanteleev committed Nov 23, 2021
1 parent 522f7b8 commit 51b7081
Show file tree
Hide file tree
Showing 24 changed files with 706 additions and 169 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.sublime-project
*.sublime-workspace
compile-shaders.bat
/tests
141 changes: 141 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
stages:
- build
- test

variables:
GIT_SUBMODULE_STRATEGY: none
TEST_REPO_BRANCH: main

# Variables that should be specified from the project settings:
# - GITHUB_USERNAME : username for the private dependencies on GitHub
# - GITHUB_ACCESS_TOKEN : access token for the private dependencies on GitHub
# - TEST_REPO_URL : URL of the repository with tests, including the username and token parts if necessary
# - ENABLE_JOBS : list of jobs to run, such as "build-linux,test-linux"

# The script assumes that the following software is installed on the runner:
# - GCC or Clang (Linux)
# - Visual Studio 2019 (Windows)
# - CMake 3.10+
# - Ninja build system
# - Python 3.8+ and scikit-image


# Add the GitHub credentials for the submodules
.checkout-submodules: &checkout-submodules
- git submodule set-url RTXGI https://${GITHUB_USERNAME}:${GITHUB_ACCESS_TOKEN}@github.com/NVIDIAGameWorks/RTXGI.git
- git submodule set-url NRD https://${GITHUB_USERNAME}:${GITHUB_ACCESS_TOKEN}@github.com/NVIDIAGameWorks/RayTracingDenoiser.git
- git submodule update --init --recursive


# Remove the credentials to avoid storing them in the runner working tree
.cleanup-submodules: &cleanup-submodules
- git submodule set-url RTXGI https://github.com/NVIDIAGameWorks/RTXGI.git
- git submodule set-url NRD https://github.com/NVIDIAGameWorks/RayTracingDenoiser.git


# Clone the tests repository
.clone-tests: &clone-tests
- git clone -b ${TEST_REPO_BRANCH} ${TEST_REPO_URL} tests


build-linux:
stage: build
tags:
- linux
rules:
- if: '$ENABLE_JOBS =~ /build-linux/'
before_script:
- *checkout-submodules
- ./update_dependencies.sh
script:
- mkdir build && cd build
- cmake .. -GNinja
- ninja
after_script:
- *cleanup-submodules
artifacts:
name: "rtxdi-linux-${CI_COMMIT_SHORT_SHA}"
paths:
- build/bin/

build-windows:
stage: build
tags:
- windows
rules:
- if: '$ENABLE_JOBS =~ /build-windows/'
before_script:
- *checkout-submodules
- ./update_dependencies.bat
script:
- ./set_vs_vars.ps1
- mkdir build
- cd build
- cmake .. -GNinja -DRTXDI_CONSOLE_APP=ON
- cmake --build .
after_script:
- *cleanup-submodules
artifacts:
name: "rtxdi-windows-${CI_COMMIT_SHORT_SHA}"
paths:
- build/bin/

test-linux:
stage: test
tags:
- linux
rules:
- if: '$ENABLE_JOBS =~ /test-linux/'
dependencies:
- build-linux
before_script:
- ./update_dependencies.sh
- *clone-tests
script:
- cd tests
- python test.py
artifacts:
name: "rtxdi-linux-test-outputs-${CI_COMMIT_SHORT_SHA}"
when: on_failure
paths:
- tests/outputs/

test-windows-dx12:
stage: test
tags:
- windows
rules:
- if: '$ENABLE_JOBS =~ /test-windows-dx12/'
dependencies:
- build-windows
before_script:
- ./update_dependencies.bat
- *clone-tests
script:
- cd tests
- python test.py
artifacts:
name: "rtxdi-windows-test-outputs-dx12-${CI_COMMIT_SHORT_SHA}"
when: on_failure
paths:
- tests/outputs/

test-windows-vulkan:
stage: test
tags:
- windows
rules:
- if: '$ENABLE_JOBS =~ /test-windows-vulkan/'
dependencies:
- build-windows
before_script:
- ./update_dependencies.bat
- *clone-tests
script:
- cd tests
- python test.py --vulkan
artifacts:
name: "rtxdi-windows-test-outputs-vulkan-${CI_COMMIT_SHORT_SHA}"
when: on_failure
paths:
- tests/outputs/
25 changes: 16 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ set(CMAKE_CXX_EXTENSIONS ON)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /MP")

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
macro(replace_msvcrt var value)
# Remove the existing /MD-type flags, if any
string(REGEX REPLACE "/M[TD]d?\\s*" "" ${var} ${${var}})
# Append the new flag
set(${var} "${${var}} ${value}")
endmacro(replace_msvcrt)

replace_msvcrt(CMAKE_C_FLAGS_DEBUG "/MTd")
replace_msvcrt(CMAKE_C_FLAGS_MINSIZEREL "/MT")
replace_msvcrt(CMAKE_C_FLAGS_RELEASE "/MT")
replace_msvcrt(CMAKE_C_FLAGS_RELWITHDEBINFO "/MT")

replace_msvcrt(CMAKE_CXX_FLAGS_DEBUG "/MTd")
replace_msvcrt(CMAKE_CXX_FLAGS_MINSIZEREL "/MT")
replace_msvcrt(CMAKE_CXX_FLAGS_RELEASE "/MT")
replace_msvcrt(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT")

elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

Expand Down
2 changes: 1 addition & 1 deletion donut
Submodule donut updated from 35d4ab to eb2a06
44 changes: 44 additions & 0 deletions set_vs_vars.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Find vswhere (installed with recent Visual Studio versions).
#
If ($vsWhere = Get-Command "vswhere.exe" -ErrorAction SilentlyContinue) {
$vsWhere = $vsWhere.Path
} ElseIf (Test-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe") {
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
}
Else {
Write-Error "vswhere not found. Aborting." -ErrorAction Stop
}
Write-Host "vswhere found at: $vsWhere" -ForegroundColor Yellow


#
# Get path to Visual Studio installation using vswhere.
#
$vsPath = &$vsWhere -latest -version "[16.0,17.0)" -products * `
-requires Microsoft.Component.MSBuild `
-property installationPath
If ([string]::IsNullOrEmpty("$vsPath")) {
Write-Error "Failed to find Visual Studio 2019 installation. Aborting." -ErrorAction Stop
}
Write-Host "Using Visual Studio installation at: ${vsPath}" -ForegroundColor Yellow


#
# Make sure the Visual Studio Command Prompt variables are set.
#
If (Test-Path env:LIBPATH) {
Write-Host "Visual Studio Command Prompt variables already set." -ForegroundColor Yellow
} Else {
# Load VC vars
Push-Location "${vsPath}\VC\Auxiliary\Build"
cmd /c "vcvarsall.bat x64&set" |
ForEach-Object {
If ($_ -match "=") {
$v = $_.split("="); Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
}
}
Pop-Location
Write-Host "Visual Studio Command Prompt variables set." -ForegroundColor Yellow
}

2 changes: 1 addition & 1 deletion shaders/CompositingPass.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ void main(uint2 globalIdx : SV_DispatchThreadID)
if(any(isnan(compositedColor)))
compositedColor = float3(0, 0, 1);

u_Output[globalIdx] = float4(compositedColor, 0);
u_Output[globalIdx] = float4(compositedColor, 1.0);
}
2 changes: 1 addition & 1 deletion src/AccumulationPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AccumulationPass::AccumulationPass(

void AccumulationPass::CreatePipeline()
{
donut::log::info("Initializing AccumulationPass...");
donut::log::debug("Initializing AccumulationPass...");

m_ComputeShader = m_ShaderFactory->CreateShader("app/AccumulationPass.hlsl", "main", nullptr, nvrhi::ShaderType::Compute);

Expand Down
14 changes: 12 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ file(GLOB sources "*.cpp" "*.h")
set(project rtxdi-sample)
set(folder "RTXDI SDK")

add_executable(${project} WIN32 ${sources})
target_link_libraries(${project} donut_core donut_engine donut_app donut_render rtxdi-sdk)
include(CMakeDependentOption)

cmake_dependent_option(RTXDI_CONSOLE_APP "Build the sample as a console application" OFF WIN32 OFF)

if (RTXDI_CONSOLE_APP)
add_executable(${project} ${sources})
target_compile_definitions(${project} PRIVATE IS_CONSOLE_APP=1)
else()
add_executable(${project} WIN32 ${sources})
endif()

target_link_libraries(${project} donut_core donut_engine donut_app donut_render rtxdi-sdk cxxopts)
add_dependencies(${project} rtxdi-sample-shaders)
set_target_properties(${project} PROPERTIES
FOLDER ${folder}
Expand Down
2 changes: 1 addition & 1 deletion src/CompositingPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ CompositingPass::CompositingPass(

void CompositingPass::CreatePipeline()
{
donut::log::info("Initializing CompositingPass...");
donut::log::debug("Initializing CompositingPass...");

m_ComputeShader = m_ShaderFactory->CreateShader("app/CompositingPass.hlsl", "main", nullptr, nvrhi::ShaderType::Compute);

Expand Down
2 changes: 1 addition & 1 deletion src/ConfidencePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ConfidencePass::ConfidencePass(

void ConfidencePass::CreatePipeline()
{
donut::log::info("Initializing ConfidencePass...");
donut::log::debug("Initializing ConfidencePass...");

m_ComputeShader = m_ShaderFactory->CreateShader("app/ConfidencePass.hlsl", "main", nullptr, nvrhi::ShaderType::Compute);

Expand Down
2 changes: 1 addition & 1 deletion src/FilterGradientsPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ FilterGradientsPass::FilterGradientsPass(

void FilterGradientsPass::CreatePipeline()
{
donut::log::info("Initializing FilterGradientsPass...");
donut::log::debug("Initializing FilterGradientsPass...");

m_ComputeShader = m_ShaderFactory->CreateShader("app/FilterGradientsPass.hlsl", "main", nullptr, nvrhi::ShaderType::Compute);

Expand Down
2 changes: 1 addition & 1 deletion src/GBufferPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void RasterizedGBufferPass::CreateBindingSet()

void RasterizedGBufferPass::CreatePipeline(const RenderTargets& renderTargets)
{
donut::log::info("Initializing RasterizedGBufferPass...");
donut::log::debug("Initializing RasterizedGBufferPass...");

std::vector<ShaderMacro> macros = { { "ALPHA_TESTED", "0"} };

Expand Down
6 changes: 4 additions & 2 deletions src/GBufferPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ class RenderTargets;
class Profiler;
class SampleScene;

typedef int ibool;

struct GBufferSettings
{
float roughnessOverride = 0.5f;
float metalnessOverride = 0.5f;
bool enableRoughnessOverride = false;
bool enableMetalnessOverride = false;
float normalMapScale = 1.f;
bool enableAlphaTestedGeometry = true;
bool enableTransparentGeometry = true;
ibool enableAlphaTestedGeometry = true;
ibool enableTransparentGeometry = true;
float textureLodBias = -1.f;

bool enableMaterialReadback = false;
Expand Down
2 changes: 1 addition & 1 deletion src/GenerateMipsPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GenerateMipsPass::GenerateMipsPass(
: m_SourceTexture(sourceEnvironmentMap)
, m_DestinationTexture(destinationTexture)
{
donut::log::info("Initializing GenerateMipsPass...");
donut::log::debug("Initializing GenerateMipsPass...");

const auto& destinationDesc = m_DestinationTexture->getDesc();

Expand Down
2 changes: 1 addition & 1 deletion src/LightingPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void LightingPasses::CreateBindingSet(

void LightingPasses::CreateComputePass(ComputePass& pass, const char* shaderName, const std::vector<donut::engine::ShaderMacro>& macros)
{
donut::log::info("Initializing ComputePass %s...", shaderName);
donut::log::debug("Initializing ComputePass %s...", shaderName);

pass.Shader = m_ShaderFactory->CreateShader(shaderName, "main", &macros, nvrhi::ShaderType::Compute);

Expand Down
Loading

0 comments on commit 51b7081

Please sign in to comment.