From 9d69c459a1ba4c872a90400a3383b2d93f3b1c03 Mon Sep 17 00:00:00 2001 From: Lumina Wang Date: Wed, 31 Jul 2024 18:38:22 +0800 Subject: [PATCH] Release v24.08 (#189) * Fix Image Processing Crash; * Upgrade USD to v24.08 (along with other dependencies). --- Applications/Plasma/CMakeLists.txt | 6 +- Applications/Plasma/pch.h | 2 + CMakeLists.txt | 6 +- Jenkinsfile | 162 ------------------ Libraries/Aurora/API/Aurora/Aurora.h | 55 +++--- Libraries/Aurora/CMakeLists.txt | 2 +- .../Source/MaterialX/BSDFCodeGenerator.h | 4 +- Libraries/Aurora/Source/RendererBase.h | 1 - Libraries/HdAurora/HdAuroraImageCache.cpp | 20 ++- Libraries/HdAurora/HdAuroraInstancer.cpp | 16 +- Libraries/HdAurora/HdAuroraPlugin.cpp | 8 +- Libraries/HdAurora/HdAuroraPlugin.h | 8 +- Libraries/HdAurora/HdAuroraRenderBuffer.cpp | 4 + Libraries/HdAurora/HdAuroraRenderDelegate.h | 65 ++++--- .../ImageProcessingResolver/Resolver.cpp | 16 +- Scripts/Patches/OpenImageIO.patch | 88 +--------- Scripts/Patches/USD.patch | 118 +++++++------ Scripts/cmake/modules/FindTinyGLTF.cmake | 4 + Scripts/cmake/modules/Findglm.cmake | 30 +++- Scripts/installExternals.py | 52 +++--- .../TextFiles/HdAuroraTextureTest_Setup.glsl | 11 +- .../TextFiles/HdAuroraTextureTest_Struct.glsl | 2 +- .../TextFiles/TestMaterialX2_Setup.glsl | 11 +- .../TextFiles/TestMaterialX2_Struct.glsl | 2 +- .../TextFiles/TestMaterialX3_Setup.glsl | 11 +- .../TextFiles/TestMaterialX3_Struct.glsl | 2 +- Tests/Assets/Textures/invalid_image.jpg | 3 + .../Assets/Textures/pretville_street_24k.exr | 3 + Tests/Aurora/Tests/TestMaterial.cpp | 11 +- .../Common/TestMaterialGenerator.cpp | 136 +++++++-------- Tests/CMakeLists.txt | 1 + Tests/HdAurora/CMakeLists.txt | 80 +++++++++ Tests/HdAurora/HdAuroraMain.cpp | 21 +++ Tests/HdAurora/Tests/TestStability.cpp | 116 +++++++++++++ Tests/Helpers/AuroraTestHelpers.h | 2 + Tests/Helpers/BaselineImageHelpers.cpp | 6 +- Tests/Helpers/RendererTestHelpers.h | 2 + 37 files changed, 565 insertions(+), 522 deletions(-) delete mode 100644 Jenkinsfile create mode 100644 Scripts/cmake/modules/FindTinyGLTF.cmake create mode 100644 Tests/Assets/Textures/invalid_image.jpg create mode 100644 Tests/Assets/Textures/pretville_street_24k.exr create mode 100644 Tests/HdAurora/CMakeLists.txt create mode 100644 Tests/HdAurora/HdAuroraMain.cpp create mode 100644 Tests/HdAurora/Tests/TestStability.cpp diff --git a/Applications/Plasma/CMakeLists.txt b/Applications/Plasma/CMakeLists.txt index 0893842..02aedee 100644 --- a/Applications/Plasma/CMakeLists.txt +++ b/Applications/Plasma/CMakeLists.txt @@ -52,17 +52,13 @@ PRIVATE cxxopts::cxxopts stb::stb tinyobjloader::tinyobjloader + tinygltf::tinygltf Foundation Aurora ${WINSDK_LIB} ${CMAKE_DL_LIBS} ) -target_include_directories(${PROJECT_NAME} -PRIVATE - "${TinyGLTF_INCLUDE_DIR}" -) - if(WIN32 AND ENABLE_INTERACTIVE_PLASMA) # set windows-specific properties including WIN32 executable (gui app) set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE) diff --git a/Applications/Plasma/pch.h b/Applications/Plasma/pch.h index cfd481d..fd8939e 100644 --- a/Applications/Plasma/pch.h +++ b/Applications/Plasma/pch.h @@ -53,6 +53,8 @@ using namespace std; // GLM - OpenGL Mathematics // NOTE: This is a math library, and not specific to OpenGL. #define GLM_FORCE_CTOR_INIT +// Enable glm experimental for transform.hpp. +#define GLM_ENABLE_EXPERIMENTAL #pragma warning(push) #pragma warning(disable : 4127) // nameless struct/union #pragma warning(disable : 4201) // conditional expression is not constant diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bdb7a1..f1fb42a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.24) -# 3.24 is required to have Vulkan::shaderc_combined +cmake_minimum_required(VERSION 3.29) +# 3.29 is required to have boost 1.85 # Forbid the in-source build @@ -17,7 +17,7 @@ if(USD_usdviewq_LIBRARY_RELEASE OR USD_usdviewq_LIBRARY_DEBUG) endif() # Set the project name and project variables -project(Aurora VERSION 24.03.0.0) +project(Aurora VERSION 24.08.0.0) # Create a folder for the version header files set(VERSION_FOLDER "${PROJECT_BINARY_DIR}/VersionFiles") diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index d1539a7..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env groovy -@Library('PSL@master') _ - -def isPrimaryBranch(){ - return env.BRANCH_NAME == "dev" || env.BRANCH_NAME == "main" -} - -def isReleaseBranch(){ - def match = env.BRANCH_NAME =~/(?i)^release-\/.*/ - def result = match ? true : false - match = null - return result -} - -def isInventorBranch(){ - def match = env.BRANCH_NAME =~/(?i)^inventor_fy.*/ - def result = match ? true : false - match = null - return result -} - -def isPullRequest(){ - def match = env.BRANCH_NAME =~/(?i)^pr-.*/ - def result = match ? true : false - match = null - return result -} - -// Build upon primary branches or those with PR opened, -// and skip for the rest to save build resources -if (!(isPrimaryBranch() || isReleaseBranch() || isInventorBranch() || isPullRequest())) { - echo "Skip CI build other than 'dev', 'main', 'release' and branches with open PRs" - return -} - -def jenkinsProperties = [] -// Abort previous running build after any new commit pushed to PRs -if (isPullRequest()) { - jenkinsProperties.add(disableConcurrentBuilds(abortPrevious: true)) -} -properties(jenkinsProperties) - -/////////////////////////////////////////////////// -// Global constants -COMMONSHELL = new ors.utils.CommonShell(steps, env) - -node('OGS_Win_002') { - try { - stage ("Checkout Windows") { - checkoutGit() - } - stage ("Build Windows Release") { - windowsBuild("Release") - } - stage ("Build Windows Debug") { - windowsBuild("Debug") - } - stage ('Test Windows Release') { - windowsTest("Release") - } - stage ('Test Windows Debug') { - windowsTest("Debug") - } - } - finally { - // Clear the repo - deleteDir() - } -} - -/////////////////////////////////////////////////// -// Checkout Functions - -def checkoutGit() { - checkout([$class: 'GitSCM', - branches: scm.branches, - doGenerateSubmoduleConfigurations: false, - extensions: [[$class: 'GitLFSPull']], - submoduleCfg: [], - userRemoteConfigs: scm.userRemoteConfigs]) -} - -/////////////////////////////////////////////////// -// Build functions - -def windowsBuild(Config) { - def EXTERNALS_DIR="c:\\jenkins\\workspace\\AuroraExternals" - def EXTERNALS_DIR_AURORA="${EXTERNALS_DIR}\\vs2019\\${Config}" - bat """ - :: Set up EXTERNALS_DIR - if not exist ${EXTERNALS_DIR_AURORA} call mkdir ${EXTERNALS_DIR_AURORA} - - :: Set up nasm - if not exist ${EXTERNALS_DIR}\\nasm-2.15.05-win64.zip call curl -o ${EXTERNALS_DIR}\\nasm-2.15.05-win64.zip https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-win64.zip - if not exist ${EXTERNALS_DIR}\\nasm-2.15.05 call 7z x -y -aoa ${EXTERNALS_DIR}\\nasm-2.15.05-win64.zip -o${EXTERNALS_DIR} - call set PATH=${EXTERNALS_DIR}\\nasm-2.15.05;%PATH% - - :: Set up Pyside6/PyOpenGL - call python -m pip install --upgrade pip - call python -m pip install PySide6 - call python -m pip install PyOpenGL - - :: Set up Vulkan SDK - :: We need to install Vulkan SDK silently. For more details please refer to https://vulkan.lunarg.com/doc/view/latest/windows/getting_started.html - if not exist "C:\\VulkanSDK\\1.3.231.1\\bin" if not exist ${EXTERNALS_DIR}\\VulkanSDK-1.3.231.1-Installer.exe call curl -o ${EXTERNALS_DIR}\\VulkanSDK-1.3.231.1-Installer.exe https://sdk.lunarg.com/sdk/download/1.3.231.1/windows/VulkanSDK-1.3.231.1-Installer.exe - if not exist "C:\\VulkanSDK\\1.3.231.1\\bin" call ${EXTERNALS_DIR}\\VulkanSDK-1.3.231.1-Installer.exe --accept-licenses --default-answer --confirm-command install com.lunarg.vulkan.debug - call set PATH=C:\\VulkanSDK\\1.3.231.1\\bin;%PATH% - call set VK_SDK_PATH=C:\\VulkanSDK\\1.3.231.1 - call set VULKAN_SDK=C:\\VulkanSDK\\1.3.231.1 - - :: Set up Visual Studio 2019 Environment - for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere" -property installationPath`) do ( - if exist "%%i\\MSBuild\\Microsoft\\VisualStudio\\v16.0" set "VSInstallPath=%%i" - ) - call "%VSInstallPath%\\VC\\Auxiliary\\Build\\vcvars64.bat" - - :: install externals - python -u Scripts\\installExternals.py ${EXTERNALS_DIR_AURORA} --build-variant=${Config} -v -v - - :: build Aurora - echo Configure CMake project - if exist Build\\CMakeCache.txt del /f Build\\CMakeCache.txt - - :: As the build machine is Windows Server 2019 while target running machine is Windows 10, - :: Use CMAKE_SYSTEM_VERSION to target the build for a different version of the host operating system than is actually running on the host - cmake -S . -B Build -D CMAKE_BUILD_TYPE=${Config} -D EXTERNALS_DIR=${EXTERNALS_DIR_AURORA} -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -A x64 - cmake --build Build --config ${Config} - if not errorlevel 0 ( - echo ERROR: Failed to build the project for ${Config} binaries, see console output for details - exit /b %errorlevel% - ) - """ -} - -/////////////////////////////////////////////////// -// Test functions - -def windowsTest(Config) { - bat """ - :: Start unit test - echo Starting OGS modernization unit test for ${Config} - setlocal EnableDelayedExpansion - pushd Build\\bin\\${Config} - set exit_code=0 - for %%i in (.\\*Tests.exe) do ( - set exe=%%i - set exe_name=!exe:~2,-4! - !exe! - - if !errorlevel! neq 0 ( - echo ERROR: Test !exe_name! exited with non-zero exit code, see console output for details - set exit_code=1 - ) - ) - popd - :: Break further execution when test fails - if %exit_code% equ 1 goto end - echo Done All tests for ${Config} - :end - exit /b %exit_code% - """ -} \ No newline at end of file diff --git a/Libraries/Aurora/API/Aurora/Aurora.h b/Libraries/Aurora/API/Aurora/Aurora.h index fced74c..a7a8048 100644 --- a/Libraries/Aurora/API/Aurora/Aurora.h +++ b/Libraries/Aurora/API/Aurora/Aurora.h @@ -1,4 +1,4 @@ -// Copyright 2023 Autodesk, Inc. +// Copyright 2024 Autodesk, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -59,8 +59,8 @@ namespace Aurora /// \param pFileNameOut File name of the loaded resource containing the (used as hint for subsequent /// processing) /// \return True if loaded successfully. -using LoadResourceFunction = - function* pBufferOut, string* pFileNameOut)>; +using LoadResourceFunction = std::function* pBufferOut, std::string* pFileNameOut)>; // Math objects. using vec2 = glm::vec2; @@ -282,39 +282,40 @@ struct PropertyValue } /// Convert value to string. - string toString() const + std::string toString() const { // Compare based on type value. switch (type) { case Type::Bool: - return to_string(_bool); + return std::to_string(_bool); case Type::Int: - return to_string(_int); + return std::to_string(_int); case Type::Float: - return to_string(_float); + return std::to_string(_float); case Type::Float2: - return to_string(_float2.x) + ", " + to_string(_float2.y); + return std::to_string(_float2.x) + ", " + std::to_string(_float2.y); case Type::Float3: - return to_string(_float3.x) + ", " + to_string(_float3.y) + ", " + to_string(_float3.z); + return std::to_string(_float3.x) + ", " + std::to_string(_float3.y) + ", " + + std::to_string(_float3.z); case Type::Float4: - return to_string(_float4.x) + ", " + to_string(_float4.y) + ", " + - to_string(_float4.z) + ", " + to_string(_float4.w); + return std::to_string(_float4.x) + ", " + std::to_string(_float4.y) + ", " + + std::to_string(_float4.z) + ", " + std::to_string(_float4.w); case Type::Matrix4: - return to_string(_matrix4[0][0]) + ", " + to_string(_matrix4[0][1]) + ", " + - to_string(_matrix4[0][2]) + ", " + to_string(_matrix4[0][3]) + ", " + - to_string(_matrix4[1][0]) + ", " + to_string(_matrix4[1][1]) + ", " + - to_string(_matrix4[1][2]) + ", " + to_string(_matrix4[1][3]) + ", " + - to_string(_matrix4[2][0]) + ", " + to_string(_matrix4[2][1]) + ", " + - to_string(_matrix4[2][2]) + ", " + to_string(_matrix4[2][3]) + ", " + - to_string(_matrix4[3][0]) + ", " + to_string(_matrix4[3][1]) + ", " + - to_string(_matrix4[3][2]) + ", " + to_string(_matrix4[3][3]); + return std::to_string(_matrix4[0][0]) + ", " + std::to_string(_matrix4[0][1]) + ", " + + std::to_string(_matrix4[0][2]) + ", " + std::to_string(_matrix4[0][3]) + ", " + + std::to_string(_matrix4[1][0]) + ", " + std::to_string(_matrix4[1][1]) + ", " + + std::to_string(_matrix4[1][2]) + ", " + std::to_string(_matrix4[1][3]) + ", " + + std::to_string(_matrix4[2][0]) + ", " + std::to_string(_matrix4[2][1]) + ", " + + std::to_string(_matrix4[2][2]) + ", " + std::to_string(_matrix4[2][3]) + ", " + + std::to_string(_matrix4[3][0]) + ", " + std::to_string(_matrix4[3][1]) + ", " + + std::to_string(_matrix4[3][2]) + ", " + std::to_string(_matrix4[3][3]); case Type::String: return _string; case Type::Strings: { - string res; + std::string res; // If any string does not match equality is false. for (size_t i = 0; i < _strings.size(); i++) { @@ -456,7 +457,7 @@ struct VertexDescription /// GetAttributeDataFunction. struct AttributeData { - /// Pointer to actual vertex or index atttribute data. + /// Pointer to actual vertex or index attribute data. const void* address = nullptr; /// Offset in bytes to start of attribute data. @@ -812,10 +813,10 @@ class AURORA_API IMaterial MAKE_AURORA_PTR(IMaterial); // Definition of an instance layer (material+geometry) -using LayerDefinition = pair; +using LayerDefinition = std::pair; // Array of layer definitions. -using LayerDefinitions = vector; +using LayerDefinitions = std::vector; /// A class representing an instance of geometry, including a per-instance material and transform. class AURORA_API IInstance @@ -900,7 +901,7 @@ class AURORA_API IScene /// /// \param atPath The Aurora path at which the image will be created. /// \param filePath The path to the image file, if the string is empty, then atPath is used. - virtual void setImageFromFilePath(const Path& atPath, const string& filePath = "", + virtual void setImageFromFilePath(const Path& atPath, const std::string& filePath = "", bool linearize = true, bool isEnvironment = false) = 0; /// Set the properties for sampler with given path. @@ -1024,7 +1025,7 @@ class AURORA_API IScene /// \param lightType Type of light (one of strings in /// Aurora::Names::LightTypes). /// \return A smart pointer to the new lights. - virtual ILightPtr addLightPointer(const string& lightType) = 0; + virtual ILightPtr addLightPointer(const std::string& lightType) = 0; protected: virtual ~IScene() = default; // hidden destructor @@ -1174,7 +1175,7 @@ class AURORA_API IRenderer virtual const std::vector& builtInMaterials() = 0; /// \desc Set the callback function used to load resources, such as textures, from a URI. - /// \param func Callback function to be used for all subsquent loading. + /// \param func Callback function to be used for all subsequent loading. virtual void setLoadResourceFunction(LoadResourceFunction func) = 0; protected: @@ -1185,7 +1186,7 @@ MAKE_AURORA_PTR(IRenderer); // Gets the logger for the Aurora library, used to report console output and errors. AURORA_API Foundation::Log& logger(); -// Creates a renderer with the specified baclend and number of simultaneously active tasks. +// Creates a renderer with the specified backend and number of simultaneously active tasks. AURORA_API IRendererPtr createRenderer( IRenderer::Backend type = IRenderer::Backend::Default, uint32_t taskCount = 3); diff --git a/Libraries/Aurora/CMakeLists.txt b/Libraries/Aurora/CMakeLists.txt index b01ed12..f936eb2 100644 --- a/Libraries/Aurora/CMakeLists.txt +++ b/Libraries/Aurora/CMakeLists.txt @@ -426,7 +426,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFAULT_COMPILE_DEFINITIONS if(ENABLE_DIRECTX_BACKEND) # Compile the standalone compute shaders. # NOTE: These are compiled with DXC at build time unlike all the other shaders. - # TODO: Runtime compile this too, see OGSMOD-1215. + # TODO: Runtime compile this too. set_source_files_properties(Source/DirectX/Shaders/Accumulation.hlsl PROPERTIES VS_SHADER_TYPE Compute VS_SHADER_MODEL 6.3 diff --git a/Libraries/Aurora/Source/MaterialX/BSDFCodeGenerator.h b/Libraries/Aurora/Source/MaterialX/BSDFCodeGenerator.h index 22f420e..6aa7e5f 100644 --- a/Libraries/Aurora/Source/MaterialX/BSDFCodeGenerator.h +++ b/Libraries/Aurora/Source/MaterialX/BSDFCodeGenerator.h @@ -13,7 +13,7 @@ #include // Forward declare MaterialX types. -namespace MaterialX_v1_38_8 +namespace MaterialX_v1_38_10 { class Document; class FileSearchPath; @@ -26,7 +26,7 @@ class UnitConverterRegistry; class UnitSystem; class ShaderNode; class TypeDesc; -} // namespace MaterialX_v1_38_8 +} // namespace MaterialX_v1_38_10 #include "Properties.h" diff --git a/Libraries/Aurora/Source/RendererBase.h b/Libraries/Aurora/Source/RendererBase.h index 1f49c99..c44b879 100644 --- a/Libraries/Aurora/Source/RendererBase.h +++ b/Libraries/Aurora/Source/RendererBase.h @@ -202,7 +202,6 @@ class RendererBase : public IRenderer, public FixedValues // TODO: Destruction via shared_ptr is not safe, we should have some kind of kill list system, but // can't seem to get it to work. -// See OGSMOD-1912 #if 0 vector _imageDestroyList; #endif diff --git a/Libraries/HdAurora/HdAuroraImageCache.cpp b/Libraries/HdAurora/HdAuroraImageCache.cpp index 3973731..7670736 100644 --- a/Libraries/HdAurora/HdAuroraImageCache.cpp +++ b/Libraries/HdAurora/HdAuroraImageCache.cpp @@ -1,4 +1,4 @@ -// Copyright 2023 Autodesk, Inc. +// Copyright 2024 Autodesk, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -59,6 +59,11 @@ Aurora::Path HdAuroraImageCache::acquireImage( imageData.depth = 1; imageData.flipped = _isYFlipped; imageData.format = image->GetFormat(); + + // NOTE: Multiplying int values may exceed INT_MAX. Cast to size_t for security. + const size_t widthSizeT = image->GetWidth(); + const size_t heightSizeT = image->GetHeight(); + const size_t bppSizeT = image->GetBytesPerPixel(); bool paddingRequired = hioFormat == HioFormatUNorm8Vec3srgb || hioFormat == HioFormatUNorm8Vec3; @@ -69,17 +74,18 @@ Aurora::Path HdAuroraImageCache::acquireImage( uint8_t* pPixelData; if (paddingRequired) { - hioFormat = hioFormat == HioFormatUNorm8Vec3srgb ? HioFormatUNorm8Vec4srgb - : HioFormatUNorm8Vec4; - dataOut.bufferSize = image->GetWidth() * image->GetHeight() * 4; - pUnpaddedPixels.reset( - new uint8_t[image->GetWidth() * image->GetHeight() * image->GetBytesPerPixel()]); + hioFormat = hioFormat == HioFormatUNorm8Vec3srgb ? HioFormatUNorm8Vec4srgb + : HioFormatUNorm8Vec4; + + const size_t newPixelSize = 4; + dataOut.bufferSize = widthSizeT * heightSizeT * newPixelSize; + pUnpaddedPixels.reset(new uint8_t[widthSizeT * heightSizeT * bppSizeT]); imageData.data = pUnpaddedPixels.get(); pPixelData = static_cast(alloc(dataOut.bufferSize)); } else { - dataOut.bufferSize = image->GetWidth() * image->GetHeight() * image->GetBytesPerPixel(); + dataOut.bufferSize = widthSizeT * heightSizeT * bppSizeT; pPixelData = static_cast(alloc(dataOut.bufferSize)); imageData.data = pPixelData; } diff --git a/Libraries/HdAurora/HdAuroraInstancer.cpp b/Libraries/HdAurora/HdAuroraInstancer.cpp index 5a9e56f..76b8295 100644 --- a/Libraries/HdAurora/HdAuroraInstancer.cpp +++ b/Libraries/HdAurora/HdAuroraInstancer.cpp @@ -98,9 +98,9 @@ VtMatrix4dArray HdAuroraInstancer::ComputeInstanceTransforms(SdfPath const& prot } // "translate" holds a translation vector for each index. - if (_primvarMap.count(HdInstancerTokens->translate) > 0) + if (_primvarMap.count(HdInstancerTokens->instanceTranslations) > 0) { - const auto* pBuffer = _primvarMap[HdInstancerTokens->translate]; + const auto* pBuffer = _primvarMap[HdInstancerTokens->instanceTranslations]; for (size_t i = 0; i < instanceIndices.size(); ++i) { GfVec3f translate; @@ -114,9 +114,9 @@ VtMatrix4dArray HdAuroraInstancer::ComputeInstanceTransforms(SdfPath const& prot } // "rotate" holds a quaternion in format for each index. - if (_primvarMap.count(HdInstancerTokens->rotate) > 0) + if (_primvarMap.count(HdInstancerTokens->instanceRotations) > 0) { - const auto* pBuffer = _primvarMap[HdInstancerTokens->rotate]; + const auto* pBuffer = _primvarMap[HdInstancerTokens->instanceRotations]; for (size_t i = 0; i < instanceIndices.size(); ++i) { GfVec4f quat; @@ -130,9 +130,9 @@ VtMatrix4dArray HdAuroraInstancer::ComputeInstanceTransforms(SdfPath const& prot } // "scale" holds an axis-aligned scale vector for each index. - if (_primvarMap.count(HdInstancerTokens->scale) > 0) + if (_primvarMap.count(HdInstancerTokens->instanceScales) > 0) { - const auto* pBuffer = _primvarMap[HdInstancerTokens->scale]; + const auto* pBuffer = _primvarMap[HdInstancerTokens->instanceScales]; for (size_t i = 0; i < instanceIndices.size(); ++i) { GfVec3f scale; @@ -146,9 +146,9 @@ VtMatrix4dArray HdAuroraInstancer::ComputeInstanceTransforms(SdfPath const& prot } // "instanceTransform" holds a 4x4 transform matrix for each index. - if (_primvarMap.count(HdInstancerTokens->instanceTransform) > 0) + if (_primvarMap.count(HdInstancerTokens->instanceTransforms) > 0) { - const auto* pBuffer = _primvarMap[HdInstancerTokens->instanceTransform]; + const auto* pBuffer = _primvarMap[HdInstancerTokens->instanceTransforms]; for (size_t i = 0; i < instanceIndices.size(); ++i) { GfMatrix4d instanceTransform; diff --git a/Libraries/HdAurora/HdAuroraPlugin.cpp b/Libraries/HdAurora/HdAuroraPlugin.cpp index 0e19566..9482852 100644 --- a/Libraries/HdAurora/HdAuroraPlugin.cpp +++ b/Libraries/HdAurora/HdAuroraPlugin.cpp @@ -76,10 +76,10 @@ void HdAuroraRendererPlugin::DeleteRenderDelegate(HdRenderDelegate* renderDelega delete renderDelegate; } -// The extra arguments to IsSupported were added with Hydra version 50. As we need to support -// both USD 23.08.01 and older versions, make arguments conditional at compile time. -#if HD_API_VERSION >= 50 -bool HdAuroraRendererPlugin::IsSupported(bool /*gpuEnabled*/, TfToken /* hgiToken*/) const +// The extra arguments to IsSupported were added with Hydra version 46. As we need to support +// both USD 24.08 and older versions, make arguments conditional at compile time. +#if HD_API_VERSION >= 46 +bool HdAuroraRendererPlugin::IsSupported(bool /*gpuEnabled*/) const #else bool HdAuroraRendererPlugin::IsSupported() const #endif diff --git a/Libraries/HdAurora/HdAuroraPlugin.h b/Libraries/HdAurora/HdAuroraPlugin.h index 19dd62e..d7621ef 100644 --- a/Libraries/HdAurora/HdAuroraPlugin.h +++ b/Libraries/HdAurora/HdAuroraPlugin.h @@ -25,10 +25,10 @@ class HdAuroraRendererPlugin : public HdRendererPlugin void DeleteRenderDelegate(HdRenderDelegate* renderDelegate) override; -// The extra arguments to IsSupported were added with Hydra version 50. As we need to support -// both USD 23.08.01 and older versions, make arguments conditional at compile time. -#if HD_API_VERSION >= 50 - virtual bool IsSupported(bool gpuEnabled = true, TfToken hgiToken = TfToken("")) const override; +// The extra arguments to IsSupported were added with Hydra version 46. As we need to support +// both USD 24.08 and older versions, make arguments conditional at compile time. +#if HD_API_VERSION >= 46 + virtual bool IsSupported(bool gpuEnabled = true) const override; #else bool IsSupported() const override; #endif diff --git a/Libraries/HdAurora/HdAuroraRenderBuffer.cpp b/Libraries/HdAurora/HdAuroraRenderBuffer.cpp index 4c10fb8..7a2d74b 100644 --- a/Libraries/HdAurora/HdAuroraRenderBuffer.cpp +++ b/Libraries/HdAurora/HdAuroraRenderBuffer.cpp @@ -59,6 +59,8 @@ class HgiHdAuroraTextureGL final : public HgiTexture /// Returns the OpenGL id / name of the texture. uint32_t GetTextureId() const { return _textureId; } + void SubmitLayoutChange(HgiTextureUsage /*newLayout*/) override { return; } + private: HgiHdAuroraTextureGL() = delete; HgiHdAuroraTextureGL& operator=(const HgiHdAuroraTextureGL&) = delete; @@ -210,6 +212,8 @@ class HgiHdAuroraTextureDX final : public HgiTexture uint64_t GetRawResource() const override { return reinterpret_cast(_sharedDXHandle); } + void SubmitLayoutChange(HgiTextureUsage /*newLayout*/) override { return; } + private: HgiHdAuroraTextureDX() = delete; HgiHdAuroraTextureDX& operator=(const HgiHdAuroraTextureDX&) = delete; diff --git a/Libraries/HdAurora/HdAuroraRenderDelegate.h b/Libraries/HdAurora/HdAuroraRenderDelegate.h index 305a9eb..f816bd6 100644 --- a/Libraries/HdAurora/HdAuroraRenderDelegate.h +++ b/Libraries/HdAurora/HdAuroraRenderDelegate.h @@ -1,4 +1,4 @@ -// Copyright 2023 Autodesk, Inc. +// Copyright 2024 Autodesk, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ class HdAuroraRenderPass; class HdAuroraRenderBuffer; class HdAuroraImageCache; -// Functoin used to update a Hydra render setting. -using UpdateRenderSettingFunction = std::function; +// Function used to update a Hydra render setting. +using UpdateRenderSettingFunction = function; class HdAuroraRenderDelegate final : public HdRenderDelegate { @@ -29,36 +29,35 @@ class HdAuroraRenderDelegate final : public HdRenderDelegate HdAuroraRenderDelegate(HdRenderSettingsMap const& settings = {}); ~HdAuroraRenderDelegate() override; - void SetDrivers(pxr::HdDriverVector const& drivers) override; + void SetDrivers(HdDriverVector const& drivers) override; - const pxr::TfTokenVector& GetSupportedRprimTypes() const override; - const pxr::TfTokenVector& GetSupportedSprimTypes() const override; - const pxr::TfTokenVector& GetSupportedBprimTypes() const override; + const TfTokenVector& GetSupportedRprimTypes() const override; + const TfTokenVector& GetSupportedSprimTypes() const override; + const TfTokenVector& GetSupportedBprimTypes() const override; - pxr::HdRprim* CreateRprim(pxr::TfToken const& typeId, pxr::SdfPath const& rprimId) override; - pxr::HdSprim* CreateSprim(pxr::TfToken const& typeId, pxr::SdfPath const& sprimId) override; - pxr::HdBprim* CreateBprim(pxr::TfToken const& typeId, pxr::SdfPath const& bprimId) override; + HdRprim* CreateRprim(TfToken const& typeId, SdfPath const& rprimId) override; + HdSprim* CreateSprim(TfToken const& typeId, SdfPath const& sprimId) override; + HdBprim* CreateBprim(TfToken const& typeId, SdfPath const& bprimId) override; - void DestroyRprim(pxr::HdRprim* rPrim) override; - void DestroySprim(pxr::HdSprim* sprim) override; - void DestroyBprim(pxr::HdBprim* bprim) override; + void DestroyRprim(HdRprim* rPrim) override; + void DestroySprim(HdSprim* sprim) override; + void DestroyBprim(HdBprim* bprim) override; - pxr::HdSprim* CreateFallbackSprim(pxr::TfToken const& typeId) override; - pxr::HdBprim* CreateFallbackBprim(pxr::TfToken const& typeId) override; + HdSprim* CreateFallbackSprim(TfToken const& typeId) override; + HdBprim* CreateFallbackBprim(TfToken const& typeId) override; - pxr::HdInstancer* CreateInstancer( - pxr::HdSceneDelegate* delegate, pxr::SdfPath const& id) override; - void DestroyInstancer(pxr::HdInstancer* instancer) override; + HdInstancer* CreateInstancer(HdSceneDelegate* delegate, SdfPath const& id) override; + void DestroyInstancer(HdInstancer* instancer) override; - pxr::HdRenderParam* GetRenderParam() const override; + HdRenderParam* GetRenderParam() const override; HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const override; - pxr::HdRenderPassSharedPtr CreateRenderPass( - pxr::HdRenderIndex* index, pxr::HdRprimCollection const& collection) override; + HdRenderPassSharedPtr CreateRenderPass( + HdRenderIndex* index, HdRprimCollection const& collection) override; - pxr::HdResourceRegistrySharedPtr GetResourceRegistry() const override; - void CommitResources(pxr::HdChangeTracker* tracker) override; + HdResourceRegistrySharedPtr GetResourceRegistry() const override; + void CommitResources(HdChangeTracker* tracker) override; void SetRenderSetting(TfToken const& key, VtValue const& value) override; VtValue GetRenderSetting(TfToken const& key) const override; @@ -66,7 +65,7 @@ class HdAuroraRenderDelegate final : public HdRenderDelegate Aurora::IScenePtr GetScene() { return _auroraScene; } // Update the scene bounds with the AABB for a single mesh. - void UpdateBounds(const pxr::GfVec3f& min, const GfVec3f& max); + void UpdateBounds(const GfVec3f& min, const GfVec3f& max); // Reset the scene bounds. // This will reset them to invalid values, so the next call to UpdateBounds will set the bounds. void ResetBounds(); @@ -77,12 +76,12 @@ class HdAuroraRenderDelegate final : public HdRenderDelegate bool SampleRestartNeeded() const { return _sampleRestartNeeded; } void SetSampleRestartNeeded(bool needed) { _sampleRestartNeeded = needed; } - void ActivateRenderPass(HdAuroraRenderPass* pRenderPass, - const std::map& pRenderBuffers); + void ActivateRenderPass( + HdAuroraRenderPass* pRenderPass, const map& pRenderBuffers); void RenderPassDestroyed(HdAuroraRenderPass* pRenderPass); // Returns Hydra graphics interface - pxr::Hgi* GetHgi() { return _hgi; } + Hgi* GetHgi() { return _hgi; } // Settings for shared buffers. // NOTE: This determines whether the GetRawResource() function of the HgiTexture object created @@ -95,10 +94,10 @@ class HdAuroraRenderDelegate final : public HdRenderDelegate }; RenderBufferSharingType GetRenderBufferSharingType() { return _renderBufferSharingType; } - std::mutex& rendererMutex() { return _rendererMutex; } + mutex& rendererMutex() { return _rendererMutex; } // Get the primIndex mutex, required to access prim. index via GetSprimSubtree as this is not // thread safe. - std::mutex& primIndexMutex() { return _primIndexMutex; } + mutex& primIndexMutex() { return _primIndexMutex; } HdAuroraImageCache& imageCache() { return *_pImageCache; } void setAuroraEnvironmentLightImagePath(const Aurora::Path& path) @@ -116,8 +115,8 @@ class HdAuroraRenderDelegate final : public HdRenderDelegate void UpdateAuroraEnvironment(); private: - std::mutex _rendererMutex; - std::mutex _primIndexMutex; + mutex _rendererMutex; + mutex _primIndexMutex; map _settingFunctions; Aurora::IRendererPtr _auroraRenderer; @@ -141,13 +140,13 @@ class HdAuroraRenderDelegate final : public HdRenderDelegate GfVec3f _backgroundTopColor = GfVec3f(1.0f, 1.0f, 1.0f); GfVec3f _backgroundBottomColor = GfVec3f(1.0f, 1.0f, 1.0f); glm::mat4 _auroraEnvironmentLightTransform; - std::string _backgroundImageFilePath; + string _backgroundImageFilePath; Aurora::Path _auroraEnvironmentBackgroundImagePath; Aurora::Path _auroraEnvironmentLightImagePath; Aurora::Path _auroraEnvironmentPath; RenderBufferSharingType _renderBufferSharingType = RenderBufferSharingType::NONE; - pxr::Hgi* _hgi; + Hgi* _hgi; }; // A class that manages ground plane data, including an Aurora ground plane object. diff --git a/Libraries/ImageProcessingResolver/Resolver.cpp b/Libraries/ImageProcessingResolver/Resolver.cpp index f7236fd..bfc3fbd 100644 --- a/Libraries/ImageProcessingResolver/Resolver.cpp +++ b/Libraries/ImageProcessingResolver/Resolver.cpp @@ -1,3 +1,6 @@ +// Copyright 2024 Autodesk, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // @@ -20,7 +23,9 @@ #define TINYEXR_USE_MINIZ 1 #define TINYEXR_IMPLEMENTATION #pragma warning(push) -#pragma warning(disable : 4706) +#pragma warning(disable : 4706) // assignment within conditional expression +#pragma warning(disable : 4245) // signed/unsigned mismatch +#pragma warning(disable : 4702) // unreachable code #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-but-set-variable" #include "tinyexr.h" @@ -185,7 +190,10 @@ std::shared_ptr ImageProcessingResolverPlugin::_OpenAsset( } // Create a temp buffer for the source image pixels. - size_t sizeInBytes = image->GetWidth() * image->GetHeight() * image->GetBytesPerPixel(); + // NOTE: Multiplying int values may exceed INT_MAX. Cast to size_t for security. + size_t sizeInBytes = static_cast(image->GetWidth()) * + static_cast(image->GetHeight()) * + static_cast(image->GetBytesPerPixel()); std::vector tempBuf(sizeInBytes); // Read the source image into the temp buffer. pxr::HioImage::StorageSpec imageData; @@ -276,7 +284,7 @@ std::shared_ptr ImageProcessingResolverPlugin::_OpenAsset( unsigned char* pBuffer; const char* pErr; int len = SaveEXRToMemory((const float*)pPixels, imageData.width, imageData.height, - nChannels, 0, (const unsigned char**)&pBuffer, &pErr); + nChannels, 0, &pBuffer, &pErr); // If successful create an ArAsset from the EXR in memory. if (len) @@ -296,7 +304,7 @@ std::shared_ptr ImageProcessingResolverPlugin::_OpenAsset( return cacheEntry.pAsset; } - // If not an imageProcesing URI run the default _OpenAsset Function. + // If not an imageProcessing URI run the default _OpenAsset Function. std::shared_ptr pRes = ArDefaultResolver::_OpenAsset(resolvedPath); return pRes; } diff --git a/Scripts/Patches/OpenImageIO.patch b/Scripts/Patches/OpenImageIO.patch index 1b4bd0a..476b5db 100644 --- a/Scripts/Patches/OpenImageIO.patch +++ b/Scripts/Patches/OpenImageIO.patch @@ -1,8 +1,8 @@ diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake -index 3ca046b2..36faf2d0 100644 +index 9835ed398..b484383c5 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake -@@ -185,7 +185,6 @@ checked_find_package (OpenCV 3.0 +@@ -195,7 +195,6 @@ checked_find_package (OpenCV 3.0 DEFINITIONS -DUSE_OPENCV=1) # Intel TBB @@ -10,87 +10,3 @@ index 3ca046b2..36faf2d0 100644 checked_find_package (TBB 2017 SETVARIABLES OIIO_TBB PREFER_CONFIG) -diff --git a/src/cmake/modules/FindJPEGTurbo.cmake b/src/cmake/modules/FindJPEGTurbo.cmake -index a6fb7560..36a4f99a 100644 ---- a/src/cmake/modules/FindJPEGTurbo.cmake -+++ b/src/cmake/modules/FindJPEGTurbo.cmake -@@ -5,51 +5,8 @@ - # JPEG_INCLUDE_DIRS - the libjpeg-turbo include directories - # JPEG_LIBRARIES - link these to use libjpeg-turbo - # -- --include (FindPackageHandleStandardArgs) -- --find_path(JPEG_INCLUDE_DIR turbojpeg.h -- HINTS /usr/local/opt/jpeg-turbo/include -- PATH_SUFFIXES include) --set(JPEG_NAMES ${JPEG_NAMES} jpeg libjpeg turbojpeg libturbojpeg) -- --find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES} -- HINTS ${JPEG_INCLUDE_DIR}/.. -- /usr/local/opt/jpeg-turbo -- /opt/libjpeg-turbo -- PATH_SUFFIXES lib lib64 -- NO_DEFAULT_PATH) --if (NOT JPEG_LIBRARY) -- find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES} -- HINTS ${JPEG_INCLUDE_DIR}/.. -- /usr/local/opt/jpeg-turbo -- PATH_SUFFIXES lib lib64) --endif () -- --if (JPEG_INCLUDE_DIR AND JPEG_LIBRARY) -- set (JPEG_INCLUDE_DIRS ${JPEG_INCLUDE_DIR} CACHE PATH "JPEG include dirs") -- set (JPEG_LIBRARIES ${JPEG_LIBRARY} CACHE STRING "JPEG libraries") -- file(STRINGS "${JPEG_INCLUDE_DIR}/jconfig.h" -- jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*") -- if (jpeg_lib_version) -- string(REGEX REPLACE "^#define[\t ]+JPEG_LIB_VERSION[\t ]+([0-9]+).*" -- "\\1" JPEG_VERSION "${jpeg_lib_version}") -- endif () --endif () -- --# handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if --# all listed variables are TRUE --FIND_PACKAGE_HANDLE_STANDARD_ARGS(JPEG DEFAULT_MSG JPEG_LIBRARIES JPEG_INCLUDE_DIRS) -+find_package(JPEG ${ARGN}) - - if (JPEG_FOUND) - set (JPEGTURBO_FOUND true) -- -- # Use an intermediary target named "JPEG::JPEG" to match libjpeg's export -- if(NOT TARGET JPEG::JPEG) -- add_library(JPEG::JPEG INTERFACE IMPORTED) -- target_link_libraries(JPEG::JPEG INTERFACE ${JPEG_LIBRARY}) -- endif() - endif () -- --mark_as_advanced(JPEG_LIBRARIES JPEG_INCLUDE_DIRS ) -- -diff --git a/src/cmake/modules/FindOpenEXR.cmake b/src/cmake/modules/FindOpenEXR.cmake -index 3ade82e9..e37d43f8 100644 ---- a/src/cmake/modules/FindOpenEXR.cmake -+++ b/src/cmake/modules/FindOpenEXR.cmake -@@ -219,15 +219,18 @@ endif () - # Look for the libraries themselves, for all the components. - # This is complicated because the OpenEXR libraries may or may not be - # built with version numbers embedded. -+if (CMAKE_BUILD_TYPE STREQUAL "Debug") -+ set(LIB_POSTFIX "d") -+else() -+ set(LIB_POSTFIX "") -+endif() - set (_openexr_components IlmThread IlmImf Imath Iex Half) - foreach (COMPONENT ${_openexr_components}) - string (TOUPPER ${COMPONENT} UPPERCOMPONENT) - # First try with the version embedded - find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY -- NAMES ${COMPONENT}-${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR} -- ${COMPONENT} -- ${COMPONENT}-${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR}_d -- ${COMPONENT}_d -+ NAMES ${COMPONENT}-${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}${LIB_POSTFIX} -+ ${COMPONENT}${LIB_POSTFIX} - HINTS ${OPENEXR_LIBRARY_DIR} $ENV{OPENEXR_LIBRARY_DIR} - ${GENERIC_LIBRARY_PATHS} ) - endforeach () diff --git a/Scripts/Patches/USD.patch b/Scripts/Patches/USD.patch index e23c2ca..c33871a 100644 --- a/Scripts/Patches/USD.patch +++ b/Scripts/Patches/USD.patch @@ -1,94 +1,98 @@ diff --git a/cmake/modules/FindOpenEXR.cmake b/cmake/modules/FindOpenEXR.cmake -index 639a01cf1..d57af1d79 100644 +index 7cf5d4681..633c4383e 100644 --- a/cmake/modules/FindOpenEXR.cmake +++ b/cmake/modules/FindOpenEXR.cmake -@@ -56,6 +56,10 @@ if(OPENEXR_INCLUDE_DIR) - endif() - endif() - -+if(CMAKE_BUILD_TYPE STREQUAL Debug) -+ SET(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX}) -+endif() -+ - foreach(OPENEXR_LIB - Half - Iex -@@ -70,8 +74,8 @@ foreach(OPENEXR_LIB +@@ -52,9 +52,11 @@ foreach(OPENEXR_LIB + # OpenEXR libraries may be suffixed with the version number, so we search # using both versioned and unversioned names. + set(DEBUG_POSTFIX ) +- if(DEFINED PXR_USE_DEBUG_BUILD) +- if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND ${PXR_USE_DEBUG_BUILD} MATCHES ON) ++ if(CMAKE_BUILD_TYPE STREQUAL Debug) ++ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(DEBUG_POSTFIX _d) ++ else() ++ set(DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) + endif() + endif() find_library(OPENEXR_${OPENEXR_LIB}_LIBRARY - NAMES -- ${OPENEXR_LIB}-${OPENEXR_MAJOR_VERSION}_${OPENEXR_MINOR_VERSION} -- ${OPENEXR_LIB} -+ ${OPENEXR_LIB}-${OPENEXR_MAJOR_VERSION}_${OPENEXR_MINOR_VERSION}${LIB_POSTFIX} -+ ${OPENEXR_LIB}${LIB_POSTFIX} - HINTS - "${OPENEXR_LOCATION}" - "$ENV{OPENEXR_LOCATION}" diff --git a/cmake/modules/FindOpenImageIO.cmake b/cmake/modules/FindOpenImageIO.cmake -index 9df47ff23..7d2811b84 100644 +index 4d2ff1ec4..c8045efdf 100644 --- a/cmake/modules/FindOpenImageIO.cmake +++ b/cmake/modules/FindOpenImageIO.cmake -@@ -22,6 +22,10 @@ - # language governing permissions and limitations under the Apache License. +@@ -5,6 +5,15 @@ + # https://openusd.org/license. # ++set(DEBUG_POSTFIX ) +if(CMAKE_BUILD_TYPE STREQUAL Debug) -+ SET(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX}) ++ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ++ set(DEBUG_POSTFIX _d) ++ else() ++ set(DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) ++ endif() +endif() + if(UNIX) find_path(OIIO_BASE_DIR include/OpenImageIO/oiioversion.h -@@ -31,7 +35,7 @@ if(UNIX) +@@ -13,14 +22,8 @@ if(UNIX) + "$ENV{OIIO_LOCATION}" "/opt/oiio" ) +- set(LIBNAME libOpenImageIO.so) +- if(DEFINED PXR_USE_DEBUG_BUILD) +- if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND ${PXR_USE_DEBUG_BUILD} MATCHES ON) +- set(LIBNAME libOpenImageIO_d.dylib) +- endif() +- endif() find_path(OIIO_LIBRARY_DIR -- libOpenImageIO.so -+ libOpenImageIO${LIB_POSTFIX}.so +- ${LIBNAME} ++ libOpenImageIO${DEBUG_POSTFIX}.so HINTS "${OIIO_LOCATION}" "$ENV{OIIO_LOCATION}" -@@ -49,7 +53,7 @@ elseif(WIN32) +@@ -38,7 +41,7 @@ elseif(WIN32) "$ENV{OIIO_LOCATION}" ) find_path(OIIO_LIBRARY_DIR - OpenImageIO.lib -+ OpenImageIO${LIB_POSTFIX}.lib ++ OpenImageIO${DEBUG_POSTFIX}.lib HINTS "${OIIO_LOCATION}" "$ENV{OIIO_LOCATION}" -@@ -81,7 +85,7 @@ foreach(OIIO_LIB - ) +@@ -63,12 +66,6 @@ find_path(OIIO_INCLUDE_DIR + ) - find_library(OIIO_${OIIO_LIB}_LIBRARY -- ${OIIO_LIB} -+ ${OIIO_LIB}${LIB_POSTFIX} - HINTS - "${OIIO_LOCATION}" - "$ENV{OIIO_LOCATION}" + list(APPEND OIIO_INCLUDE_DIRS ${OIIO_INCLUDE_DIR}) +-set(DEBUG_POSTFIX ) +-if(DEFINED PXR_USE_DEBUG_BUILD) +- if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND ${PXR_USE_DEBUG_BUILD} MATCHES ON) +- set(DEBUG_POSTFIX _d) +- endif() +-endif() + foreach(OIIO_LIB + OpenImageIO${DEBUG_POSTFIX} + OpenImageIO_Util${DEBUG_POSTFIX} diff --git a/cmake/modules/FindOpenSubdiv.cmake b/cmake/modules/FindOpenSubdiv.cmake -index 686af9b16..7cbdb0f47 100644 +index 77bdb27ca..2fe33e220 100644 --- a/cmake/modules/FindOpenSubdiv.cmake +++ b/cmake/modules/FindOpenSubdiv.cmake -@@ -27,15 +27,14 @@ IF(NOT OPENSUBDIV_ROOT_DIR AND NOT $ENV{OPENSUBDIV_ROOT_DIR} STREQUAL "") - SET(OPENSUBDIV_ROOT_DIR $ENV{OPENSUBDIV_ROOT_DIR}) - ENDIF() +@@ -75,12 +75,16 @@ if(OPENSUBDIV_INCLUDE_DIR AND EXISTS "${OPENSUBDIV_INCLUDE_DIR}/opensubdiv/versi + ) + endif() --SET(_opensubdiv_FIND_COMPONENTS -- osdCPU --) --if(OPENSUBDIV_USE_GPU) -- list(APPEND -- _opensubdiv_FIND_COMPONENTS -- osdGPU) +if(CMAKE_BUILD_TYPE STREQUAL Debug) + SET(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX}) - endif() - -+SET(_opensubdiv_FIND_COMPONENTS osdCPU${LIB_POSTFIX}) -+if(OPENSUBDIV_USE_GPU) -+ list(APPEND _opensubdiv_FIND_COMPONENTS osdGPU${LIB_POSTFIX}) +endif() - - SET(_opensubdiv_SEARCH_DIRS - ${OPENSUBDIV_ROOT_DIR} ++ + SET(_opensubdiv_LIBRARIES) + FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS}) + STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) + FIND_LIBRARY(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY + NAMES +- ${COMPONENT} ++ ${COMPONENT}${LIB_POSTFIX} + HINTS + ${_opensubdiv_SEARCH_DIRS} + PATH_SUFFIXES diff --git a/Scripts/cmake/modules/FindTinyGLTF.cmake b/Scripts/cmake/modules/FindTinyGLTF.cmake new file mode 100644 index 0000000..641db44 --- /dev/null +++ b/Scripts/cmake/modules/FindTinyGLTF.cmake @@ -0,0 +1,4 @@ +if(TinyGLTF_ROOT AND NOT TinyGLTF_DIR) + set(TinyGLTF_DIR "${TinyGLTF_ROOT}/lib/cmake") +endif() +find_package(TinyGLTF CONFIG ${ARGN}) diff --git a/Scripts/cmake/modules/Findglm.cmake b/Scripts/cmake/modules/Findglm.cmake index bf73538..0e4dca5 100644 --- a/Scripts/cmake/modules/Findglm.cmake +++ b/Scripts/cmake/modules/Findglm.cmake @@ -1,4 +1,28 @@ -if(glm_ROOT AND NOT glm_DIR) - set(glm_DIR "${glm_ROOT}/cmake/glm") +# Prevent re-defining the package target +if(TARGET glm::glm) + return() endif() -find_package(glm CONFIG ${ARGN}) + +# Find the stb include path +if (DEFINED glm_ROOT) + find_path(GLM_INCLUDE_DIR # Set variable GLM_INCLUDE_DIR + glm/glm.hpp # Find a path with glm.hpp + NO_DEFAULT_PATH + PATHS "${glm_ROOT}") +endif() +find_path(GLM_INCLUDE_DIR glm/glm.hpp) + +set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIR}) + +# Handles the REQUIRED, QUIET and version-related arguments of find_package(). +# It also sets the _FOUND variable. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(glm DEFAULT_MSG GLM_INCLUDE_DIRS) + +if(glm_FOUND) + add_library(glm::glm INTERFACE IMPORTED) + set_target_properties(glm::glm PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${GLM_INCLUDE_DIRS}) +endif() + +mark_as_advanced(glm_ROOT) diff --git a/Scripts/installExternals.py b/Scripts/installExternals.py index 9d3b27b..36ccbea 100644 --- a/Scripts/installExternals.py +++ b/Scripts/installExternals.py @@ -101,8 +101,8 @@ def InstallZlib(context, force, buildArgs): ############################################################ # boost -BOOST_URL = "https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.gz" -# Use a sub-version in the version string to force reinstallation, even if 1.78.0 installed. +BOOST_URL = "https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.tar.gz" +# Use a sub-version in the version string to force reinstallation, even if 1.85.0 installed. BOOST_VERSION_STRING = BOOST_URL+".a" if Linux(): @@ -112,7 +112,7 @@ def InstallZlib(context, force, buildArgs): # subdirectory, which we have to account for here. In theory, specifying # "layout=system" would make the Windows install match Linux, but that # causes problems for other dependencies that look for boost. - BOOST_VERSION_FILE = "include/boost-1_78/boost/version.hpp" + BOOST_VERSION_FILE = "include/boost-1_85/boost/version.hpp" BOOST_INSTALL_FOLDER = "boost" BOOST_PACKAGE_NAME = "Boost" @@ -249,10 +249,11 @@ def InstallBoost(context, force, buildArgs): # Intel TBB if Windows(): - TBB_URL = "https://github.com/oneapi-src/oneTBB/releases/download/2019_U6/tbb2019_20190410oss_win.zip" - TBB_ROOT_DIR_NAME = "tbb2019_20190410oss" + TBB_URL = "https://github.com/oneapi-src/oneTBB/releases/download/v2020.3/tbb-2020.3-win.zip" + TBB_ROOT_DIR_NAME = "tbb" else: - TBB_URL = "https://github.com/oneapi-src/oneTBB/archive/refs/tags/2019_U6.tar.gz" + # Use point release with fix https://github.com/oneapi-src/oneTBB/pull/833 + TBB_URL = "https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2020.3.1.zip" TBB_INSTALL_FOLDER = "tbb" TBB_PACKAGE_NAME = "TBB" @@ -300,7 +301,7 @@ def InstallTBB_Linux(context, force, buildArgs): ############################################################ # JPEG -JPEG_URL = "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.1.zip" +JPEG_URL = "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.1.zip" JPEG_INSTALL_FOLDER = "libjpeg" JPEG_PACKAGE_NAME = "JPEG" @@ -347,7 +348,7 @@ def InstallTIFF(context, force, buildArgs): ############################################################ # PNG -PNG_URL = "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.29.tar.gz" +PNG_URL = "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.38.zip" PNG_INSTALL_FOLDER = "libpng" PNG_PACKAGE_NAME = "PNG" @@ -360,14 +361,13 @@ def InstallPNG(context, force, buildArgs): ############################################################ # GLM -GLM_URL = "https://github.com/g-truc/glm/archive/refs/tags/0.9.9.8.zip" +GLM_URL = "https://github.com/g-truc/glm/archive/refs/tags/1.0.1.zip" GLM_INSTALL_FOLDER = "glm" GLM_PACKAGE_NAME = "glm" def InstallGLM(context, force, buildArgs): with CurrentWorkingDirectory(DownloadURL(GLM_URL, context, force)): CopyDirectory(context, "glm", "glm", GLM_INSTALL_FOLDER) - CopyDirectory(context, "cmake/glm", "cmake/glm", GLM_INSTALL_FOLDER) GLM = Dependency(GLM_INSTALL_FOLDER, GLM_PACKAGE_NAME, InstallGLM, GLM_URL, "glm/glm.hpp") @@ -375,7 +375,7 @@ def InstallGLM(context, force, buildArgs): # STB STB_URL = "https://github.com/nothings/stb.git" -STB_SHA = "5736b15f7ea0ffb08dd38af21067c314d6a3aae9" # master on 2023-01-29 +STB_SHA = "013ac3beddff3dbffafd5177e7972067cd2b5083" # master on 2024-06-01 STB_INSTALL_FOLDER = "stb" STB_PACKAGE_NAME = "stb" @@ -389,7 +389,7 @@ def InstallSTB(context, force, buildArgs): ############################################################ # TinyGLTF -TinyGLTF_URL = "https://github.com/syoyo/tinygltf/archive/refs/tags/v2.5.0.zip" +TinyGLTF_URL = "https://github.com/syoyo/tinygltf/archive/refs/tags/v2.9.2.zip" TinyGLTF_INSTALL_FOLDER = "tinygltf" TinyGLTF_PACKAGE_NAME = "TinyGLTF" @@ -415,7 +415,7 @@ def InstallTinyObjLoader(context, force, buildArgs): ############################################################ # TinyEXR -TinyEXR_URL = "https://github.com/syoyo/tinyexr/archive/refs/tags/v1.0.2.zip" +TinyEXR_URL = "https://github.com/syoyo/tinyexr/archive/refs/tags/v1.0.8.zip" TinyEXR_INSTALL_FOLDER = "tinyexr" TinyEXR_PACKAGE_NAME = "tinyexr" TinyEXR_INSTALL_FOLDER = "tinyexr" @@ -470,10 +470,7 @@ def InstallURIParser(context, force, buildArgs): ############################################################ # IlmBase/OpenEXR -if Windows(): - OPENEXR_URL = "https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v2.5.2.zip" -else: - OPENEXR_URL = "https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v2.4.3.zip" +OPENEXR_URL = "https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v3.1.11.zip" OPENEXR_INSTALL_FOLDER = "OpenEXR" OPENEXR_PACKAGE_NAME = "OpenEXR" @@ -498,7 +495,9 @@ def InstallOpenEXR(context, force, buildArgs): ############################################################ # OpenImageIO -OIIO_URL = "https://github.com/OpenImageIO/oiio/archive/refs/tags/v2.4.5.0.zip" + +# Update to a newer version than the one adopted by OpenUSD to avoid using deprecated boost methods. +OIIO_URL = "https://github.com/OpenImageIO/oiio/archive/refs/tags/v2.5.11.0.zip" OIIO_INSTALL_FOLDER = "OpenImageIO" OIIO_PACKAGE_NAME = "OpenImageIO" @@ -509,6 +508,7 @@ def InstallOpenImageIO(context, force, buildArgs): extraArgs = ['-DOIIO_BUILD_TOOLS=OFF', '-DOIIO_BUILD_TESTS=OFF', + '-DBUILD_DOCS=OFF', '-DUSE_PYTHON=OFF', '-DSTOP_ON_WARNING=OFF', '-DUSE_PTEX=OFF'] @@ -544,7 +544,7 @@ def InstallOpenImageIO(context, force, buildArgs): ############################################################ # OpenSubdiv -OPENSUBDIV_URL = "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v3_4_4.zip" +OPENSUBDIV_URL = "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v3_6_0.zip" OPENSUBDIV_INSTALL_FOLDER = "OpenSubdiv" OPENSUBDIV_PACKAGE_NAME = "OpenSubdiv" @@ -597,7 +597,7 @@ def InstallOpenSubdiv(context, force, buildArgs): ############################################################ # MaterialX -MATERIALX_URL = "https://github.com/AcademySoftwareFoundation/MaterialX/archive/v1.38.8.zip" +MATERIALX_URL = "https://github.com/AcademySoftwareFoundation/MaterialX/archive/v1.38.10.zip" MATERIALX_INSTALL_FOLDER = "MaterialX" MATERIALX_PACKAGE_NAME = "MaterialX" @@ -612,7 +612,7 @@ def InstallMaterialX(context, force, buildArgs): ############################################################ # USD -USD_URL = "https://github.com/autodesk-forks/USD/archive/refs/tags/v22.08-Aurora-v22.11.zip" +USD_URL = "https://github.com/autodesk-forks/USD/archive/refs/tags/v24.08-Aurora-v24.08.zip" USD_INSTALL_FOLDER = "USD" USD_PACKAGE_NAME = "pxr" @@ -620,16 +620,16 @@ def InstallUSD(context, force, buildArgs): with CurrentWorkingDirectory(DownloadURL(USD_URL, context, force)): # USD_URL = "https://github.com/autodesk-forks/USD.git" -# USD_TAG = "v22.08-Aurora-v22.11" +# USD_TAG = "v24.08-Aurora-v24.08" +# USD_FOLDER = "USD-" + USD_TAG # USD_INSTALL_FOLDER = "USD" # USD_PACKAGE_NAME = "pxr" # def InstallUSD(context, force, buildArgs): -# USD_FOLDER = "USD-"+USD_TAG # with CurrentWorkingDirectory(GitClone(USD_URL, USD_TAG, USD_FOLDER, context)): # We need to apply patch to make USD build with our externals configuration - ApplyGitPatch(context, "USD.patch") + # ApplyGitPatch(context, "USD.patch") extraArgs = [] @@ -826,7 +826,7 @@ def InstallCXXOPTS(context, force, buildArgs): ############################################################ # GTEST -GTEST_URL = "https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip" +GTEST_URL = "https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip" GTEST_INSTALL_FOLDER = "gtest" GTEST_PACKAGE_NAME = "GTest" @@ -1227,4 +1227,4 @@ def FormatBuildArguments(buildArgs): cmake --build Build """.format(externalsDir=context.externalsInstDir) -Print(buildStepsMsg) \ No newline at end of file +Print(buildStepsMsg) diff --git a/Tests/Assets/TextFiles/HdAuroraTextureTest_Setup.glsl b/Tests/Assets/TextFiles/HdAuroraTextureTest_Setup.glsl index 6272dfb..8141b10 100644 --- a/Tests/Assets/TextFiles/HdAuroraTextureTest_Setup.glsl +++ b/Tests/Assets/TextFiles/HdAuroraTextureTest_Setup.glsl @@ -1,5 +1,5 @@ -void setupMaterial_498292f537214e2a( - Material_498292f537214e2a material, +void setupMaterial_c4e7dcaed703027e( + Material_c4e7dcaed703027e material, sampler2D base_color_image_image_parameter, sampler2D specular_roughness_image_image_parameter, out vec3 base_color, @@ -43,10 +43,15 @@ vec3 base_color_image_default1 = vec3(0, 0, 0)//}; //Temp input variables for geomprop_UV0 vec2 nodeOutTmp_geomprop_UV0_out; //Temp output variable for out int nodeTmp_geomprop_UV0_index; //Temp input variable for index + // Graph input UV0 + //{ +int geomprop_UV0_index1 = 0//}; +; + nodeTmp_geomprop_UV0_index = geomprop_UV0_index1;// Output connection // Graph input function call texcoord (See definition IM_texcoord_vector2_genglsl) { //{ - vec2 geomprop_UV0_out1 = vertexData.texCoord; + vec2 geomprop_UV0_out1 = vertexData.texCoord.xy; //}; nodeOutTmp_geomprop_UV0_out = geomprop_UV0_out1;// Output connection nodeTmp_base_color_image_texcoord = geomprop_UV0_out1;// Output connection diff --git a/Tests/Assets/TextFiles/HdAuroraTextureTest_Struct.glsl b/Tests/Assets/TextFiles/HdAuroraTextureTest_Struct.glsl index bf9b823..6aae557 100644 --- a/Tests/Assets/TextFiles/HdAuroraTextureTest_Struct.glsl +++ b/Tests/Assets/TextFiles/HdAuroraTextureTest_Struct.glsl @@ -1,4 +1,4 @@ -struct Material_498292f537214e2a { +struct Material_c4e7dcaed703027e { float specular_IOR; vec3 emission_color; float transmission; diff --git a/Tests/Assets/TextFiles/TestMaterialX2_Setup.glsl b/Tests/Assets/TextFiles/TestMaterialX2_Setup.glsl index 6272dfb..8141b10 100644 --- a/Tests/Assets/TextFiles/TestMaterialX2_Setup.glsl +++ b/Tests/Assets/TextFiles/TestMaterialX2_Setup.glsl @@ -1,5 +1,5 @@ -void setupMaterial_498292f537214e2a( - Material_498292f537214e2a material, +void setupMaterial_c4e7dcaed703027e( + Material_c4e7dcaed703027e material, sampler2D base_color_image_image_parameter, sampler2D specular_roughness_image_image_parameter, out vec3 base_color, @@ -43,10 +43,15 @@ vec3 base_color_image_default1 = vec3(0, 0, 0)//}; //Temp input variables for geomprop_UV0 vec2 nodeOutTmp_geomprop_UV0_out; //Temp output variable for out int nodeTmp_geomprop_UV0_index; //Temp input variable for index + // Graph input UV0 + //{ +int geomprop_UV0_index1 = 0//}; +; + nodeTmp_geomprop_UV0_index = geomprop_UV0_index1;// Output connection // Graph input function call texcoord (See definition IM_texcoord_vector2_genglsl) { //{ - vec2 geomprop_UV0_out1 = vertexData.texCoord; + vec2 geomprop_UV0_out1 = vertexData.texCoord.xy; //}; nodeOutTmp_geomprop_UV0_out = geomprop_UV0_out1;// Output connection nodeTmp_base_color_image_texcoord = geomprop_UV0_out1;// Output connection diff --git a/Tests/Assets/TextFiles/TestMaterialX2_Struct.glsl b/Tests/Assets/TextFiles/TestMaterialX2_Struct.glsl index bf9b823..6aae557 100644 --- a/Tests/Assets/TextFiles/TestMaterialX2_Struct.glsl +++ b/Tests/Assets/TextFiles/TestMaterialX2_Struct.glsl @@ -1,4 +1,4 @@ -struct Material_498292f537214e2a { +struct Material_c4e7dcaed703027e { float specular_IOR; vec3 emission_color; float transmission; diff --git a/Tests/Assets/TextFiles/TestMaterialX3_Setup.glsl b/Tests/Assets/TextFiles/TestMaterialX3_Setup.glsl index 6d67b7f..60cb420 100644 --- a/Tests/Assets/TextFiles/TestMaterialX3_Setup.glsl +++ b/Tests/Assets/TextFiles/TestMaterialX3_Setup.glsl @@ -1,5 +1,5 @@ -void setupMaterial_a07c7c12bcd815f6( - Material_a07c7c12bcd815f6 material, +void setupMaterial_e757910544ff95e9( + Material_e757910544ff95e9 material, sampler2D base_color_image_image_parameter, out vec3 base_color) { @@ -35,10 +35,15 @@ vec3 base_color_image_default1 = vec3(0, 0, 0)//}; //Temp input variables for geomprop_UV0 vec2 nodeOutTmp_geomprop_UV0_out; //Temp output variable for out int nodeTmp_geomprop_UV0_index; //Temp input variable for index + // Graph input UV0 + //{ +int geomprop_UV0_index1 = 0//}; +; + nodeTmp_geomprop_UV0_index = geomprop_UV0_index1;// Output connection // Graph input function call texcoord (See definition IM_texcoord_vector2_genglsl) { //{ - vec2 geomprop_UV0_out1 = vertexData.texCoord; + vec2 geomprop_UV0_out1 = vertexData.texCoord.xy; //}; nodeOutTmp_geomprop_UV0_out = geomprop_UV0_out1;// Output connection nodeTmp_base_color_image_texcoord = geomprop_UV0_out1;// Output connection diff --git a/Tests/Assets/TextFiles/TestMaterialX3_Struct.glsl b/Tests/Assets/TextFiles/TestMaterialX3_Struct.glsl index 1f078d0..1e7071d 100644 --- a/Tests/Assets/TextFiles/TestMaterialX3_Struct.glsl +++ b/Tests/Assets/TextFiles/TestMaterialX3_Struct.glsl @@ -1,2 +1,2 @@ -struct Material_a07c7c12bcd815f6 { +struct Material_e757910544ff95e9 { }; diff --git a/Tests/Assets/Textures/invalid_image.jpg b/Tests/Assets/Textures/invalid_image.jpg new file mode 100644 index 0000000..484f99c --- /dev/null +++ b/Tests/Assets/Textures/invalid_image.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c37089d92a904a0002d9b5609f058decaed2e18c84f2d62090b7eb37ee09b5f +size 28 diff --git a/Tests/Assets/Textures/pretville_street_24k.exr b/Tests/Assets/Textures/pretville_street_24k.exr new file mode 100644 index 0000000..801abc0 --- /dev/null +++ b/Tests/Assets/Textures/pretville_street_24k.exr @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8de17765b23fc43f611b8c5c0db4e4692a55fca09dd864f5767380e7e64a34f6 +size 3348299363 diff --git a/Tests/Aurora/Tests/TestMaterial.cpp b/Tests/Aurora/Tests/TestMaterial.cpp index 90bfbf3..b49d32f 100644 --- a/Tests/Aurora/Tests/TestMaterial.cpp +++ b/Tests/Aurora/Tests/TestMaterial.cpp @@ -261,8 +261,7 @@ TEST_P(MaterialTest, TestMaterialClearMaterialProperty) pScene->setMaterialProperties(material, matProps); // Render the scene and check baseline image. - // On rasteriser this will appear incorrect (the previous color will still be used, see - // OGSMOD-858) + // On rasterizer this will appear incorrect (the previous color will still be used). ASSERT_BASELINE_IMAGE_PASSES_IN_FOLDER(currentTestName() + "_AfterClear", "Materials"); } @@ -446,7 +445,7 @@ TEST_P(MaterialTest, TestMaterialBasicMaterialProperties) currentTestName() + "_Roughness_" + mtlType, "Materials"); // Test diffuse_roughness (X-axis) against specular_roughness (Y-axis), with tiny metalness - // value. This should be no different to zero but is very different (see OGSMOD-867) + // value. This should be no different to zero but is very different. for (uint32_t i = 0; i < gridHeight; i++) { // Calculate the V coordinate from Y grid position. @@ -745,7 +744,7 @@ TEST_P(MaterialTest, TestMaterialAdvancedMaterialProperties) } // Render the scene and check baseline image. - // TODO: The PT does not support this currently (see OGSMOD-699) + // TODO: The PT does not support this currently. ASSERT_BASELINE_IMAGE_PASSES_IN_FOLDER(currentTestName() + "_Coat_" + mtlType, "Materials"); // Test coat_affect_color (X-axis) against coat_affect_roughness (Y-axis.) @@ -784,7 +783,7 @@ TEST_P(MaterialTest, TestMaterialAdvancedMaterialProperties) } // Render the scene and check baseline image. - // TODO: The PT does not support this currently (see OGSMOD-699) + // TODO: The PT does not support this currently. ASSERT_BASELINE_IMAGE_PASSES_IN_FOLDER( currentTestName() + "_CoatAffect_" + mtlType, "Materials"); @@ -821,7 +820,7 @@ TEST_P(MaterialTest, TestMaterialAdvancedMaterialProperties) } // Render the scene and check baseline image. - // TODO: PT does not support transmission currently (see OGSMOD-699) + // TODO: PT does not support transmission currently. ASSERT_BASELINE_IMAGE_PASSES_IN_FOLDER( currentTestName() + "_Transmission_" + mtlType, "Materials"); } diff --git a/Tests/AuroraInternals/Common/TestMaterialGenerator.cpp b/Tests/AuroraInternals/Common/TestMaterialGenerator.cpp index f8fd36d..b2716ba 100644 --- a/Tests/AuroraInternals/Common/TestMaterialGenerator.cpp +++ b/Tests/AuroraInternals/Common/TestMaterialGenerator.cpp @@ -60,9 +60,9 @@ bool readTextFile(const string& filename, string& textOut) const char* materialXString0 = R""""( - + - + @@ -77,9 +77,9 @@ const char* materialXString0 = R""""( const char* materialXString1 = R""""( - + - + @@ -95,7 +95,7 @@ const char* materialXString1 = R""""( const char* materialXString2 = R""""( - + @@ -112,7 +112,7 @@ const char* materialXString2 = R""""( - + @@ -134,14 +134,14 @@ const char* materialXString2 = R""""( const char* materialXString3 = R""""( - + - + @@ -161,56 +161,56 @@ TEST_F(MaterialGeneratorTest, BasicTest) Aurora::MaterialDefinitionPtr pMtlDef0 = matGen.generate(materialXString0); ASSERT_NE(pMtlDef0, nullptr); - ASSERT_STREQ(pMtlDef0->source().uniqueId.c_str(), "MaterialX_d183faa1b8cb18d7"); - ASSERT_EQ(pMtlDef0->defaults().properties.size(), 7); - ASSERT_EQ(pMtlDef0->defaults().propertyDefinitions.size(), 7); - ASSERT_NEAR(pMtlDef0->defaults().properties[2].asFloat(), 0.8f, 0.01f); - ASSERT_EQ(pMtlDef0->defaults().textureNames.size(), 0); - ASSERT_EQ(pMtlDef0->defaults().textures.size(), 0); + EXPECT_STREQ(pMtlDef0->source().uniqueId.c_str(), "MaterialX_d183faa1b8cb18d7"); + EXPECT_EQ(pMtlDef0->defaults().properties.size(), 7); + EXPECT_EQ(pMtlDef0->defaults().propertyDefinitions.size(), 7); + EXPECT_NEAR(pMtlDef0->defaults().properties[2].asFloat(), 0.8f, 0.01f); + EXPECT_EQ(pMtlDef0->defaults().textureNames.size(), 0); + EXPECT_EQ(pMtlDef0->defaults().textures.size(), 0); Aurora::MaterialDefinitionPtr pMtlDef1 = matGen.generate(materialXString1); ASSERT_NE(pMtlDef1, nullptr); - ASSERT_STREQ(pMtlDef1->source().uniqueId.c_str(), "MaterialX_d183faa1b8cb18d7"); - ASSERT_EQ(pMtlDef1->defaults().properties.size(), 7); - ASSERT_EQ(pMtlDef1->defaults().propertyDefinitions.size(), 7); - ASSERT_NEAR(pMtlDef1->defaults().properties[2].asFloat(), 0.1f, 0.01f); - ASSERT_EQ(pMtlDef1->defaults().textureNames.size(), 0); - ASSERT_EQ(pMtlDef1->defaults().textures.size(), 0); + EXPECT_STREQ(pMtlDef1->source().uniqueId.c_str(), "MaterialX_d183faa1b8cb18d7"); + EXPECT_EQ(pMtlDef1->defaults().properties.size(), 7); + EXPECT_EQ(pMtlDef1->defaults().propertyDefinitions.size(), 7); + EXPECT_NEAR(pMtlDef1->defaults().properties[2].asFloat(), 0.1f, 0.01f); + EXPECT_EQ(pMtlDef1->defaults().textureNames.size(), 0); + EXPECT_EQ(pMtlDef1->defaults().textures.size(), 0); Aurora::MaterialShaderDefinition shaderDef0; pMtlDef0->getShaderDefinition(shaderDef0); Aurora::MaterialShaderDefinition shaderDef1; pMtlDef1->getShaderDefinition(shaderDef1); - ASSERT_TRUE(shaderDef0.compare(shaderDef1)); + EXPECT_TRUE(shaderDef0.compare(shaderDef1)); Aurora::MaterialDefinitionPtr pMtlDef2 = matGen.generate(materialXString2); ASSERT_NE(pMtlDef2, nullptr); - ASSERT_STREQ(pMtlDef2->source().uniqueId.c_str(), "MaterialX_ef09b35c573765bd"); - ASSERT_EQ(pMtlDef2->defaults().properties.size(), 6); - ASSERT_EQ(pMtlDef2->defaults().propertyDefinitions.size(), 6); - ASSERT_EQ(pMtlDef2->defaults().textureNames.size(), 2); - ASSERT_EQ(pMtlDef2->defaults().textures.size(), 2); - ASSERT_STREQ(pMtlDef2->defaults().textureNames[0].image.c_str(), "base_color_image"); - ASSERT_STREQ(pMtlDef2->defaults().textureNames[0].sampler.c_str(), "base_color_image_sampler"); - ASSERT_STREQ( + EXPECT_STREQ(pMtlDef2->source().uniqueId.c_str(), "MaterialX_845875d7ffe5edaf"); + EXPECT_EQ(pMtlDef2->defaults().properties.size(), 6); + EXPECT_EQ(pMtlDef2->defaults().propertyDefinitions.size(), 6); + EXPECT_EQ(pMtlDef2->defaults().textureNames.size(), 2); + EXPECT_EQ(pMtlDef2->defaults().textures.size(), 2); + EXPECT_STREQ(pMtlDef2->defaults().textureNames[0].image.c_str(), "base_color_image"); + EXPECT_STREQ(pMtlDef2->defaults().textureNames[0].sampler.c_str(), "base_color_image_sampler"); + EXPECT_STREQ( pMtlDef2->defaults().textures[0].defaultFilename.c_str(), "../Textures/CoatOfArms.bmp"); - ASSERT_STREQ(pMtlDef2->defaults().textureNames[1].image.c_str(), "specular_roughness_image"); - ASSERT_STREQ( + EXPECT_STREQ(pMtlDef2->defaults().textureNames[1].image.c_str(), "specular_roughness_image"); + EXPECT_STREQ( pMtlDef2->defaults().textureNames[1].sampler.c_str(), "specular_roughness_image_sampler"); - ASSERT_STREQ(pMtlDef2->defaults().textures[1].defaultFilename.c_str(), + EXPECT_STREQ(pMtlDef2->defaults().textures[1].defaultFilename.c_str(), "../Textures/fishscale_roughness.png"); Aurora::MaterialShaderDefinition shaderDef2; pMtlDef2->getShaderDefinition(shaderDef2); - ASSERT_FALSE(shaderDef0.compare(shaderDef2)); + EXPECT_FALSE(shaderDef0.compare(shaderDef2)); Aurora::MaterialDefinitionPtr pMtlDef2Dupe = matGen.generate(materialXString2); Aurora::MaterialDefinition* pMtlDef2Raw = pMtlDef2.get(); - ASSERT_EQ(pMtlDef2Dupe.get(), pMtlDef2Raw); - ASSERT_EQ(pMtlDef2.use_count(), 2); + EXPECT_EQ(pMtlDef2Dupe.get(), pMtlDef2Raw); + EXPECT_EQ(pMtlDef2.use_count(), 2); pMtlDef2Dupe.reset(); - ASSERT_EQ(pMtlDef2.use_count(), 1); + EXPECT_EQ(pMtlDef2.use_count(), 1); pMtlDef2.reset(); } @@ -227,8 +227,8 @@ TEST_F(MaterialGeneratorTest, MaterialShaderLibraryTest) Aurora::MaterialShaderPtr pShader0 = shaderLib.acquire(shaderDef0); ASSERT_NE(pShader0, nullptr); - ASSERT_EQ(pShader0->libraryIndex(), 0); - ASSERT_EQ(pShader0->entryPoints().size(), 2); + EXPECT_EQ(pShader0->libraryIndex(), 0); + EXPECT_EQ(pShader0->entryPoints().size(), 2); Aurora::MaterialDefinitionPtr pMtlDef1 = matGen.generate(materialXString1); Aurora::MaterialShaderDefinition shaderDef1; @@ -236,7 +236,7 @@ TEST_F(MaterialGeneratorTest, MaterialShaderLibraryTest) Aurora::MaterialShaderPtr pShader1 = shaderLib.acquire(shaderDef1); ASSERT_NE(pShader1, nullptr); - ASSERT_EQ(pShader1.get(), pShader0.get()); + EXPECT_EQ(pShader1.get(), pShader0.get()); Aurora::MaterialDefinitionPtr pMtlDef2 = matGen.generate(materialXString2); Aurora::MaterialShaderDefinition shaderDef2; @@ -244,8 +244,8 @@ TEST_F(MaterialGeneratorTest, MaterialShaderLibraryTest) Aurora::MaterialShaderPtr pShader2 = shaderLib.acquire(shaderDef2); ASSERT_NE(pShader2, nullptr); - ASSERT_EQ(pShader2->libraryIndex(), 1); - ASSERT_NE(pShader2.get(), pShader0.get()); + EXPECT_EQ(pShader2->libraryIndex(), 1); + EXPECT_NE(pShader2.get(), pShader0.get()); int numCompiled = 0; int numDestroyed = 0; @@ -256,26 +256,26 @@ TEST_F(MaterialGeneratorTest, MaterialShaderLibraryTest) auto destroyFunc = [&numDestroyed](int) { numDestroyed++; }; shaderLib.update(compileFunc, destroyFunc); - ASSERT_EQ(numCompiled, 2); - ASSERT_EQ(numDestroyed, 0); + EXPECT_EQ(numCompiled, 2); + EXPECT_EQ(numDestroyed, 0); pShader2.reset(); shaderLib.update(compileFunc, destroyFunc); - ASSERT_EQ(numCompiled, 2); - ASSERT_EQ(numDestroyed, 1); + EXPECT_EQ(numCompiled, 2); + EXPECT_EQ(numDestroyed, 1); pShader0->incrementRefCount("foo"); shaderLib.update(compileFunc, destroyFunc); - ASSERT_EQ(numCompiled, 3); - ASSERT_EQ(numDestroyed, 1); + EXPECT_EQ(numCompiled, 3); + EXPECT_EQ(numDestroyed, 1); Aurora::MaterialShaderPtr pShader3 = shaderLib.acquire(shaderDef2); ASSERT_NE(pShader3, nullptr); - ASSERT_EQ(pShader3->libraryIndex(), 1); + EXPECT_EQ(pShader3->libraryIndex(), 1); shaderLib.update(compileFunc, destroyFunc); - ASSERT_EQ(numCompiled, 4); - ASSERT_EQ(numDestroyed, 1); + EXPECT_EQ(numCompiled, 4); + EXPECT_EQ(numDestroyed, 1); } TEST_F(MaterialGeneratorTest, CodeGenTest) @@ -333,16 +333,16 @@ TEST_F(MaterialGeneratorTest, CodeGenTest) errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX0_Setup.glsl", res.materialSetupCode, "Generated setup code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX0_Struct.glsl", res.materialStructCode, "Generated struct code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.generateDefinitions(&defStr); errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX0_Defs.glsl", defStr, "Generated definitions code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.clearDefinitions(); ok = codeGen.generate(materialXString1, &res, supportedBSDFInputs); @@ -350,16 +350,16 @@ TEST_F(MaterialGeneratorTest, CodeGenTest) errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX1_Setup.glsl", res.materialSetupCode, "Generated setup code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX1_Struct.glsl", res.materialStructCode, "Generated struct code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.generateDefinitions(&defStr); errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX1_Defs.glsl", defStr, "Generated definitions code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.clearDefinitions(); ok = codeGen.generate(materialXString2, &res, supportedBSDFInputs); @@ -367,16 +367,16 @@ TEST_F(MaterialGeneratorTest, CodeGenTest) errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX2_Setup.glsl", res.materialSetupCode, "Generated setup code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX2_Struct.glsl", res.materialStructCode, "Generated struct code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.generateDefinitions(&defStr); errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX2_Defs.glsl", defStr, "Generated definitions code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.clearDefinitions(); ok = codeGen.generate(materialXString3, &res, supportedBSDFInputs); @@ -384,16 +384,16 @@ TEST_F(MaterialGeneratorTest, CodeGenTest) errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX3_Setup.glsl", res.materialSetupCode, "Generated setup code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX3_Struct.glsl", res.materialStructCode, "Generated struct code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.generateDefinitions(&defStr); errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/TestMaterialX3_Defs.glsl", defStr, "Generated definitions code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; string readMtlXText; @@ -407,16 +407,16 @@ TEST_F(MaterialGeneratorTest, CodeGenTest) errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/Mask_Setup.glsl", res.materialSetupCode, "Generated setup code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/Mask_Struct.glsl", res.materialStructCode, "Generated struct code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.generateDefinitions(&defStr); errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/Mask_Defs.glsl", defStr, "Generated definitions code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; } ok = readTextFile(dataPath() + "/Materials/HdAuroraTextureTest.mtlx", readMtlXText); @@ -427,16 +427,16 @@ TEST_F(MaterialGeneratorTest, CodeGenTest) errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/HdAuroraTextureTest_Setup.glsl", res.materialSetupCode, "Generated setup code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/HdAuroraTextureTest_Struct.glsl", res.materialStructCode, "Generated struct code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; codeGen.generateDefinitions(&defStr); errMsg = TestHelpers::compareTextFile(dataPath() + "/TextFiles/HdAuroraTextureTest_Defs.glsl", defStr, "Generated definitions code comparison failed"); - ASSERT_TRUE(errMsg.empty()) << errMsg; + EXPECT_TRUE(errMsg.empty()) << errMsg; } } // namespace diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index a5e6ec8..d1192f9 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -51,3 +51,4 @@ add_compile_definitions(AURORA_ROOT_PATH=${AURORA_ROOT_DIR}) add_subdirectory(Foundation) add_subdirectory(AuroraInternals) add_subdirectory(Aurora) +add_subdirectory(HdAurora) diff --git a/Tests/HdAurora/CMakeLists.txt b/Tests/HdAurora/CMakeLists.txt new file mode 100644 index 0000000..4c3db62 --- /dev/null +++ b/Tests/HdAurora/CMakeLists.txt @@ -0,0 +1,80 @@ +# Specify the library (for dependents), project (IDE), and output (binary file) names. +project(HdAuroraTests) + +find_package(GLEW REQUIRED) +find_package(MaterialX REQUIRED) +find_package(pxr REQUIRED) +# Alias the namespace to meet the cmake convention on imported targets +add_library(MaterialX::GenGlsl ALIAS MaterialXGenGlsl) + +# List of common helper files shared by all tests. TEST_HELPERS_FOLDER variable is set in parent cmake file. +set(HELPER_FILES + "${TEST_HELPERS_FOLDER}/TestHelpers.cpp" + "${TEST_HELPERS_FOLDER}/TestHelpers.h") + +# List of actual test files. +set(TEST_FILES + "Tests/TestStability.cpp") + +# Avoid using ${CMAKE_SOURCE_DIR} as it may break the generation when the project is included as a subdirectory. +# ImageProcessingResolver as a runtime dependency is not needed for the test build. +set(HDAURORA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../Libraries/HdAurora") +file(GLOB HDAURORA_FILES + ${HDAURORA_SOURCE_DIR}/*.cpp + ${HDAURORA_SOURCE_DIR}/*.h +) + +# Add test executable with all source files. +add_executable(${PROJECT_NAME} + ${HELPER_FILES} + ${TEST_FILES} + ${HDAURORA_FILES} + "HdAuroraMain.cpp" +) + +# Put test files and helpers in seperate folders. +source_group("Helpers" FILES ${HELPER_FILES}) +source_group("Tests" FILES ${TEST_FILES}) +source_group("HdAurora" FILES ${HDAURORA_FILES}) + +# Set custom output properties. +set_target_properties(${PROJECT_NAME} PROPERTIES + FOLDER "Tests" + RUNTIME_OUTPUT_DIRECTORY "${RUNTIME_OUTPUT_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_DIR}" + ARCHIVE_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_DIR}" + PDB_OUTPUT_DIRECTORY "${RUNTIME_OUTPUT_DIR}" + VS_DEBUGGER_WORKING_DIRECTORY "${RUNTIME_OUTPUT_DIR}" + VS_DEBUGGER_ENVIRONMENT "${VS_DEBUGGING_ENV}" + XCODE_SCHEME_ENVIRONMENT "${XCODE_DEBUGGING_ENV}") + +# Add dependencies. +target_link_libraries(${PROJECT_NAME} +PRIVATE + glm::glm + GTest::gtest + GTest::gmock + ${CMAKE_DL_LIBS} + stb::stb + OpenGL::GL + GLEW::glew + MaterialX::GenGlsl + pxr::usd + pxr::hf + pxr::hd + pxr::hdx + Foundation + Aurora +) + +# Add helpers include folder. +target_include_directories(${PROJECT_NAME} PRIVATE ${HDAURORA_SOURCE_DIR} ${TEST_HELPERS_FOLDER}) + +# Add default compile definitions (set in root CMakefile) +target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFAULT_COMPILE_DEFINITIONS}) + +# Run gtest discover tests function. +gtest_discover_tests(${PROJECT_NAME} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${RUNTIME_OUTPUT_DIR}" +) diff --git a/Tests/HdAurora/HdAuroraMain.cpp b/Tests/HdAurora/HdAuroraMain.cpp new file mode 100644 index 0000000..80e4169 --- /dev/null +++ b/Tests/HdAurora/HdAuroraMain.cpp @@ -0,0 +1,21 @@ +// Copyright 2024 Autodesk, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/Tests/HdAurora/Tests/TestStability.cpp b/Tests/HdAurora/Tests/TestStability.cpp new file mode 100644 index 0000000..2da11ba --- /dev/null +++ b/Tests/HdAurora/Tests/TestStability.cpp @@ -0,0 +1,116 @@ +// Copyright 2024 Autodesk, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DISABLE_UNIT_TESTS +#include + +#include "TestHelpers.h" + +// USD headers required by HdAurora. +#include +#include +#include +#include +#include +#include + +// Aurora & glm headers. +#include +#include + +// Internal HdAurora headers. +using namespace std; +PXR_NAMESPACE_USING_DIRECTIVE +#include "HdAuroraImageCache.h" +#include "HdAuroraRenderDelegate.h" + +namespace +{ +class StabilityTest : public ::testing::Test +{ +public: + StabilityTest() : _dataPath(TestHelpers::kSourceRoot + "/Tests/Assets") {} + ~StabilityTest() {} + + // Optionally override the base class's setUp function to create some + // data for the tests to use. + void SetUp() override {} + + // Optionally override the base class's tearDown to clear out any changes + // and release resources. + void TearDown() override {} + +protected: + const std::string _dataPath; +}; + +// Illegal texture tests. +TEST_F(StabilityTest, TestTextures) +{ + // NOTE: In the following tests, all images will be treated as environment images since there + // is no difference between processing material textures and environment maps when loading. + std::unique_ptr pAuroraRenderDelegate = + std::make_unique(); + + // Test empty path. /////////////////////////////////////////////////////// + auto resPath = pAuroraRenderDelegate->imageCache().acquireImage("", true, false); + EXPECT_FALSE(resPath.empty()); + // Ensure no crash when resource activated. + pAuroraRenderDelegate->setAuroraEnvironmentLightImagePath(resPath); + pAuroraRenderDelegate->UpdateAuroraEnvironment(); + + resPath = pAuroraRenderDelegate->imageCache().acquireImage("", true, true); + EXPECT_FALSE(resPath.empty()); + // Ensure no crash when resource activated. + pAuroraRenderDelegate->setAuroraEnvironmentLightImagePath(resPath); + pAuroraRenderDelegate->UpdateAuroraEnvironment(); + + // Test broken textures. ////////////////////////////////////////////////// + const std::string texFilename = _dataPath + "/Textures/invalid_image.jpg"; + + resPath = pAuroraRenderDelegate->imageCache().acquireImage(texFilename, true, false); + EXPECT_FALSE(resPath.empty()); + // Ensure no crash when resource activated. + pAuroraRenderDelegate->setAuroraEnvironmentLightImagePath(resPath); + pAuroraRenderDelegate->UpdateAuroraEnvironment(); + + resPath = pAuroraRenderDelegate->imageCache().acquireImage(texFilename, true, true); + EXPECT_FALSE(resPath.empty()); + // Ensure no crash when resource activated. + pAuroraRenderDelegate->setAuroraEnvironmentLightImagePath(resPath); + pAuroraRenderDelegate->UpdateAuroraEnvironment(); + +// TODO: To pass the extreme-sized tests, the corresponding fix in USD (hiooiio) is required. +// Enable the following tests once USD is upgraded. +#ifdef ENABLE_EXTREME_SIZE_TEST + // Test extreme-sized textures. /////////////////////////////////////////// + const std::string environmentImage = _dataPath + "/Textures/pretville_street_24k.exr"; + + resPath = pAuroraRenderDelegate->imageCache().acquireImage(environmentImage, true, false); + EXPECT_FALSE(resPath.empty()); + // Ensure no crash when resource activated. + pAuroraRenderDelegate->setAuroraEnvironmentLightImagePath(resPath); + pAuroraRenderDelegate->UpdateAuroraEnvironment(); + + resPath = pAuroraRenderDelegate->imageCache().acquireImage(environmentImage, true, true); + EXPECT_FALSE(resPath.empty()); + // Ensure no crash when resource activated. + pAuroraRenderDelegate->setAuroraEnvironmentLightImagePath(resPath); + pAuroraRenderDelegate->UpdateAuroraEnvironment(); +#endif +} + +} // namespace + +#endif diff --git a/Tests/Helpers/AuroraTestHelpers.h b/Tests/Helpers/AuroraTestHelpers.h index f1b3603..d080733 100644 --- a/Tests/Helpers/AuroraTestHelpers.h +++ b/Tests/Helpers/AuroraTestHelpers.h @@ -25,6 +25,8 @@ using namespace std; // GLM used by all renderers tests #define GLM_FORCE_CTOR_INIT +// Enable glm experimental for transform.hpp. +#define GLM_ENABLE_EXPERIMENTAL #pragma warning(push) #pragma warning(disable : 4127) // nameless struct/union #pragma warning(disable : 4201) // conditional expression is not constant diff --git a/Tests/Helpers/BaselineImageHelpers.cpp b/Tests/Helpers/BaselineImageHelpers.cpp index f74bc56..03155cf 100644 --- a/Tests/Helpers/BaselineImageHelpers.cpp +++ b/Tests/Helpers/BaselineImageHelpers.cpp @@ -110,7 +110,7 @@ static bool writeBuffer(const OIIO::ImageBuf& buffer, const string& fileName) return false; // Open the OIIO output image (return false if failed) - // Flawfinder: ignore (Bug in Flawfinder which flags anything called "open", see OGSMOD-832) + // Flawfinder: ignore (Bug in Flawfinder which flags anything called "open") if (!pImgOut->open(fileName.c_str(), buffer.spec())) return false; @@ -191,7 +191,7 @@ Result compare(const uint8_t* renderedPixels, size_t width, size_t height, // reloaded like this. The comparison *should* succeed without having to do this. OIIO::ImageBuf readbackOutputImageBuffer; readbackOutputImageBuffer.reset(outputFile); - // Flawfinder: ignore (Bug in Flawfinder which flags anything called "read", see OGSMOD-832) + // Flawfinder: ignore (Bug in Flawfinder which flags anything called "read"). if (!readbackOutputImageBuffer.read()) { return Result(Result::Status::FileIOError, outputFile, baselineFile); @@ -200,7 +200,7 @@ Result compare(const uint8_t* renderedPixels, size_t width, size_t height, // Read the baseline file into an OIIO image buffer. OIIO::ImageBuf baselineImageBuffer; baselineImageBuffer.reset(baselineFile); - // Flawfinder: ignore (Bug in Flawfinder which flags anything called "read", see OGSMOD-832) + // Flawfinder: ignore (Bug in Flawfinder which flags anything called "read"). if (!baselineImageBuffer.read()) { return Result(Result::Status::FileIOError, outputFile, baselineFile); diff --git a/Tests/Helpers/RendererTestHelpers.h b/Tests/Helpers/RendererTestHelpers.h index 12d1457..f30a5d2 100644 --- a/Tests/Helpers/RendererTestHelpers.h +++ b/Tests/Helpers/RendererTestHelpers.h @@ -24,6 +24,8 @@ using namespace std; // GLM used by many tests #define GLM_FORCE_CTOR_INIT +// Enable glm experimental for transform.hpp. +#define GLM_ENABLE_EXPERIMENTAL #pragma warning(push) #pragma warning(disable : 4127) // nameless struct/union #pragma warning(disable : 4201) // conditional expression is not constant