diff --git a/.github/ISSUE_TEMPLATE/nightly_build_failure_bug_template.md b/.github/ISSUE_TEMPLATE/nightly_build_failure_bug_template.md new file mode 100644 index 0000000000..40f6f0dbbc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/nightly_build_failure_bug_template.md @@ -0,0 +1,36 @@ +--- +name: Nightly Build Error bug report +about: Create a report when the nightly build process fails +title: 'Nightly Build Failure' +labels: 'needs-triage,needs-sig,kind/bug,kind/nightlybuildfailure' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Failure type** +Build | Asset Processing | Test Tools | Infrastructure | Test + +**To Reproduce Test Failures** + - Paste the command line that reproduces the test failure + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Logs** +Attach the Jenkins logs that are relevant to the failure + +**Desktop/Device (please complete the following information):** + - Device: [e.g. PC, Mac, iPhone, Samsung] + - OS: [e.g. Windows, macOS, iOS, Android] + - Version [e.g. 10, Bug Sur, Oreo] + - CPU [e.g. Intel I9-9900k , Ryzen 5900x, ] + - GPU [AMD 6800 XT, NVidia RTX 3090] + - Memory [e.g. 16GB] + +**Additional context** +Add any other context about the problem here. \ No newline at end of file diff --git a/AutomatedTesting/Gem/Code/CMakeLists.txt b/AutomatedTesting/Gem/Code/CMakeLists.txt index 58ffd957d6..6f55cc2764 100644 --- a/AutomatedTesting/Gem/Code/CMakeLists.txt +++ b/AutomatedTesting/Gem/Code/CMakeLists.txt @@ -35,37 +35,11 @@ ly_create_alias(NAME AutomatedTesting.Servers NAMESPACE Gem TARGETS Gem::Automa # Gem dependencies ################################################################################ -# The GameLauncher uses "Clients" gem variants: -ly_enable_gems(PROJECT_NAME AutomatedTesting GEM_FILE enabled_gems.cmake - TARGETS AutomatedTesting.GameLauncher - VARIANTS Clients) +# Enable the enabled_gems for the Project: +ly_enable_gems(PROJECT_NAME AutomatedTesting GEM_FILE enabled_gems.cmake) -# If we build a server, then apply the gems to the server +# Add project to the list server projects to create the AutomatedTesting.ServerLauncher if(PAL_TRAIT_BUILD_SERVER_SUPPORTED) - # if we're making a server, then add the "Server" gem variants to it: - ly_enable_gems(PROJECT_NAME AutomatedTesting GEM_FILE enabled_gems.cmake - TARGETS AutomatedTesting.ServerLauncher - VARIANTS Servers) - set_property(GLOBAL APPEND PROPERTY LY_LAUNCHER_SERVER_PROJECTS AutomatedTesting) endif() -if (PAL_TRAIT_BUILD_HOST_TOOLS) - # The Editor uses "Tools" gem variants: - ly_enable_gems( - PROJECT_NAME AutomatedTesting GEM_FILE enabled_gems.cmake - TARGETS Editor - VARIANTS Tools) - - # The Material Editor needs the Lyshine "Tools" gem variant for the custom LyShine pass - ly_enable_gems( - PROJECT_NAME AutomatedTesting GEMS LyShine - TARGETS MaterialEditor - VARIANTS Tools) - - # The pipeline tools use "Builders" gem variants: - ly_enable_gems( - PROJECT_NAME AutomatedTesting GEM_FILE enabled_gems.cmake - TARGETS AssetBuilder AssetProcessor AssetProcessorBatch - VARIANTS Builders) -endif() diff --git a/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.cpp b/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.cpp index ad6cf216d7..1528e09169 100644 --- a/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.cpp +++ b/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.cpp @@ -17,7 +17,7 @@ namespace PythonCoverage { - static constexpr char* const LogCallSite = "PythonCoverageEditorSystemComponent"; + static constexpr const char* const LogCallSite = "PythonCoverageEditorSystemComponent"; void PythonCoverageEditorSystemComponent::Reflect(AZ::ReflectContext* context) { diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py index b3c51ca912..9047b4c871 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/atom_hydra_scripts/hydra_AtomMaterialEditor_BasicTests.py @@ -33,6 +33,7 @@ MATERIAL_TYPE_PATH = os.path.join( azlmbr.paths.devroot, "Gems", "Atom", "Feature", "Common", "Assets", "Materials", "Types", "StandardPBR.materialtype", ) +CACHE_FILE_EXTENSION = ".azmaterial" def run(): @@ -67,6 +68,7 @@ def run(): material_editor.save_document_as_child(document_id, target_path) material_editor.wait_for_condition(lambda: os.path.exists(target_path), 2.0) print(f"New asset created: {os.path.exists(target_path)}") + time.sleep(2.0) # Verify if the newly created document is open new_document_id = material_editor.open_material(target_path) @@ -101,22 +103,29 @@ def run(): expected_color = math.Color(0.25, 0.25, 0.25, 1.0) material_editor.set_property(document_id, property_name, expected_color) material_editor.save_document(document_id) + time.sleep(2.0) # 7) Test Case: Saving as a New Material # Assign new color to the material file and save the document as copy expected_color_1 = math.Color(0.5, 0.5, 0.5, 1.0) material_editor.set_property(document_id, property_name, expected_color_1) target_path_1 = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL_1) + cache_file_name_1 = os.path.splitext(NEW_MATERIAL_1) # Example output: ('test_material_1', '.material') + cache_file_1 = f"{cache_file_name_1[0]}{CACHE_FILE_EXTENSION}" + target_path_1_cache = os.path.join(azlmbr.paths.devassets, "Cache", "pc", "materials", cache_file_1) material_editor.save_document_as_copy(document_id, target_path_1) - time.sleep(2.0) + material_editor.wait_for_condition(lambda: os.path.exists(target_path_1_cache), 4.0) # 8) Test Case: Saving as a Child Material # Assign new color to the material file save the document as child expected_color_2 = math.Color(0.75, 0.75, 0.75, 1.0) material_editor.set_property(document_id, property_name, expected_color_2) target_path_2 = os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Materials", NEW_MATERIAL_2) + cache_file_name_2 = os.path.splitext(NEW_MATERIAL_1) # Example output: ('test_material_2', '.material') + cache_file_2 = f"{cache_file_name_2[0]}{CACHE_FILE_EXTENSION}" + target_path_2_cache = os.path.join(azlmbr.paths.devassets, "Cache", "pc", "materials", cache_file_2) material_editor.save_document_as_child(document_id, target_path_2) - time.sleep(2.0) + material_editor.wait_for_condition(lambda: os.path.exists(target_path_2_cache), 4.0) # Close/Reopen documents material_editor.close_all_documents() diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py index bb7a16ad6b..c40dc8f178 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py @@ -16,7 +16,6 @@ import editor_python_test_tools.hydra_test_utils as hydra from atom_renderer.atom_utils.atom_constants import LIGHT_TYPES logger = logging.getLogger(__name__) -EDITOR_TIMEOUT = 120 TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts") @@ -175,7 +174,7 @@ class TestAtomEditorComponentsMain(object): TEST_DIRECTORY, editor, "hydra_AtomEditorComponents_AddedToEntity.py", - timeout=EDITOR_TIMEOUT, + timeout=120, expected_lines=expected_lines, unexpected_lines=unexpected_lines, halt_on_unexpected=True, @@ -236,7 +235,7 @@ class TestAtomEditorComponentsMain(object): TEST_DIRECTORY, editor, "hydra_AtomEditorComponents_LightComponent.py", - timeout=EDITOR_TIMEOUT, + timeout=120, expected_lines=expected_lines, unexpected_lines=unexpected_lines, halt_on_unexpected=True, @@ -299,7 +298,7 @@ class TestMaterialEditorBasicTests(object): generic_launcher, "hydra_AtomMaterialEditor_BasicTests.py", run_python="--runpython", - timeout=80, + timeout=120, expected_lines=expected_lines, unexpected_lines=unexpected_lines, halt_on_unexpected=True, diff --git a/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index c54fe60c4d..18946c7874 100644 --- a/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -90,6 +90,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_tableModel->setFilterRole(Qt::DisplayRole); m_tableModel->setSourceModel(m_filterModel.data()); + m_tableModel->setDynamicSortFilter(true); m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); connect( diff --git a/Code/Editor/CMakeLists.txt b/Code/Editor/CMakeLists.txt index 9256fd041f..5158ebc6d5 100644 --- a/Code/Editor/CMakeLists.txt +++ b/Code/Editor/CMakeLists.txt @@ -174,6 +174,8 @@ ly_add_target( Legacy::EditorLib ProjectManager ) + +ly_set_gem_variant_to_load(TARGETS Editor VARIANTS Tools) set_property(SOURCE CryEdit.cpp APPEND PROPERTY diff --git a/Code/Editor/EditorPanelUtils.cpp b/Code/Editor/EditorPanelUtils.cpp index 12e9457474..a270de5978 100644 --- a/Code/Editor/EditorPanelUtils.cpp +++ b/Code/Editor/EditorPanelUtils.cpp @@ -47,7 +47,6 @@ struct ToolTip class CEditorPanelUtils_Impl : public IEditorPanelUtils { - #pragma region Drag & Drop public: void SetViewportDragOperation(void(* dropCallback)(CViewport* viewport, int dragPointX, int dragPointY, void* custom), void* custom) override { @@ -56,8 +55,7 @@ public: GetIEditor()->GetViewManager()->GetView(i)->SetGlobalDropCallback(dropCallback, custom); } } - #pragma endregion - #pragma region Preview Window + public: int PreviewWindow_GetDisplaySettingsDebugFlags(CDisplaySettings* settings) override @@ -72,8 +70,6 @@ public: settings->SetDebugFlags(flags); } - #pragma endregion - #pragma region Shortcuts protected: QVector hotkeys; bool m_hotkeysAreEnabled; @@ -408,8 +404,6 @@ public: return m_hotkeysAreEnabled; } - #pragma endregion - #pragma region ToolTip protected: QMap m_tooltips; @@ -539,7 +533,6 @@ public: } return GetToolTip(path).disabledContent; } - #pragma endregion ToolTip }; IEditorPanelUtils* CreateEditorPanelUtils() diff --git a/Code/Editor/IEditorImpl.cpp b/Code/Editor/IEditorImpl.cpp index 8f4abae9dd..880773966b 100644 --- a/Code/Editor/IEditorImpl.cpp +++ b/Code/Editor/IEditorImpl.cpp @@ -84,12 +84,6 @@ AZ_POP_DISABLE_WARNING #include "IEditorPanelUtils.h" #include "EditorPanelUtils.h" - -// even in Release mode, the editor will return its heap, because there's no Profile build configuration for the editor -#ifdef _RELEASE -#undef _RELEASE -#endif - #include "Core/QtEditorApplication.h" // for Editor::EditorQtApplication static CCryEditDoc * theDocument; @@ -104,8 +98,6 @@ static CCryEditDoc * theDocument; #define VERIFY(EXPRESSION) { auto e = EXPRESSION; assert(e); } #endif -#undef GetCommandLine - const char* CEditorImpl::m_crashLogFileName = "SessionStatus/editor_statuses.json"; CEditorImpl::CEditorImpl() diff --git a/Code/Editor/Platform/Mac/main_dummy.cpp b/Code/Editor/Platform/Mac/main_dummy.cpp index 814cbfde66..348a32ab47 100644 --- a/Code/Editor/Platform/Mac/main_dummy.cpp +++ b/Code/Editor/Platform/Mac/main_dummy.cpp @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) processLaunchInfo.m_environmentVariables = &envVars; processLaunchInfo.m_showWindow = true; - AZStd::unique_ptr processWatcher(AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE)); + AzFramework::ProcessLauncher::LaunchUnwatchedProcess(processLaunchInfo); application.Destroy(); diff --git a/Code/Editor/Settings.cpp b/Code/Editor/Settings.cpp index 8672bad5c4..94b5668efc 100644 --- a/Code/Editor/Settings.cpp +++ b/Code/Editor/Settings.cpp @@ -35,7 +35,6 @@ #include "CryEdit.h" #include "MainWindow.h" -#pragma comment(lib, "Gdi32.lib") ////////////////////////////////////////////////////////////////////////// // Global Instance of Editor settings. diff --git a/Code/Framework/AzCore/AzCore/Debug/Trace.cpp b/Code/Framework/AzCore/AzCore/Debug/Trace.cpp index 26c702c13a..87f6def0d2 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Trace.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/Trace.cpp @@ -174,6 +174,8 @@ namespace AZ AZStd::this_thread::sleep_for(milliseconds(1)); } return AZ::Debug::Trace::IsDebuggerPresent(); +#else + return false; #endif } diff --git a/Code/Framework/AzCore/AzCore/IO/Path/Path.inl b/Code/Framework/AzCore/AzCore/IO/Path/Path.inl index 309a4fa050..6354324136 100644 --- a/Code/Framework/AzCore/AzCore/IO/Path/Path.inl +++ b/Code/Framework/AzCore/AzCore/IO/Path/Path.inl @@ -11,6 +11,7 @@ #include #include #include +#include // extern instantiations of Path templates to prevent implicit instantiations namespace AZ::IO @@ -92,11 +93,23 @@ namespace AZ::IO::Internal constexpr auto ConsumeRootName(InputIt entryBeginIter, InputIt entryEndIter, const char preferredSeparator) -> AZStd::enable_if_t, InputIt> { - if (preferredSeparator == '/') + if (preferredSeparator == PosixPathSeparator) { // If the preferred separator is forward slash the parser is in posix path - // parsing mode, which doesn't have a root name + // parsing mode, which doesn't have a root name, + // unless we're on a posix platform that uses a custom path root separator + #if defined(AZ_TRAIT_CUSTOM_PATH_ROOT_SEPARATOR) + const AZStd::string_view path{ entryBeginIter, entryEndIter }; + const auto positionOfPathSeparator = path.find(AZ_TRAIT_CUSTOM_PATH_ROOT_SEPARATOR); + if (positionOfPathSeparator == AZStd::string_view::npos) + { + return entryBeginIter; + } + const AZStd::string_view rootName{ path.substr(0, positionOfPathSeparator + 1) }; + return AZStd::next(entryBeginIter, rootName.size()); + #else return entryBeginIter; + #endif } else { @@ -185,13 +198,18 @@ namespace AZ::IO::Internal template >> static constexpr bool IsAbsolute(InputIt first, EndIt last, const char preferredSeparator) { - size_t pathSize = AZStd::distance(first, last); - // If the preferred separator is a forward slash - // than an absolute path is simply one that starts with a forward slash - if (preferredSeparator == '/') + // than an absolute path is simply one that starts with a forward slash, + // unless we're on a posix platform that uses a custom path root separator + if (preferredSeparator == PosixPathSeparator) { + #if defined(AZ_TRAIT_CUSTOM_PATH_ROOT_SEPARATOR) + const AZStd::string_view path{ first, last }; + return path.find(AZ_TRAIT_CUSTOM_PATH_ROOT_SEPARATOR) != AZStd::string_view::npos; + #else + const size_t pathSize = AZStd::distance(first, last); return pathSize > 0 && IsSeparator(*first); + #endif } else { @@ -199,6 +217,7 @@ namespace AZ::IO::Internal { // If a windows path ends starts with C:foo it is a root relative path // A path is absolute root absolute on windows if it starts with + const size_t pathSize = AZStd::distance(first, last); return pathSize > 2 && Internal::IsSeparator(*AZStd::next(first, 2)); } diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp index 6b89b8c044..0ca354ac95 100644 --- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp +++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp @@ -550,7 +550,7 @@ namespace AZ::SettingsRegistryMergeUtils } registry.Set(FilePathKey_ProjectUserPath, projectUserPath.Native()); - // Set the user directory with the provided path or using project/user as default + // Set the log directory with the provided path or using project/user/log as default auto projectLogPathKey = FixedValueString::format("%s/project_log_path", BootstrapSettingsRootKey); AZ::IO::FixedMaxPath projectLogPath; if (!registry.Get(projectLogPath.Native(), projectLogPathKey)) @@ -640,7 +640,7 @@ namespace AZ::SettingsRegistryMergeUtils } #if !AZ_TRAIT_OS_IS_HOST_OS_PLATFORM - // Setup the cache and user paths when to platform specific locations when running on non-host platforms + // Setup the cache, user, and log paths to platform specific locations when running on non-host platforms path = engineRoot; if (AZStd::optional nonHostCacheRoot = Utils::GetDefaultAppRootPath(); nonHostCacheRoot) @@ -656,13 +656,16 @@ namespace AZ::SettingsRegistryMergeUtils if (AZStd::optional devWriteStorage = Utils::GetDevWriteStoragePath(); devWriteStorage) { - registry.Set(FilePathKey_DevWriteStorage, *devWriteStorage); - registry.Set(FilePathKey_ProjectUserPath, *devWriteStorage); + const AZ::IO::FixedMaxPath devWriteStoragePath(*devWriteStorage); + registry.Set(FilePathKey_DevWriteStorage, devWriteStoragePath.LexicallyNormal().Native()); + registry.Set(FilePathKey_ProjectUserPath, (devWriteStoragePath / "user").LexicallyNormal().Native()); + registry.Set(FilePathKey_ProjectLogPath, (devWriteStoragePath / "user/log").LexicallyNormal().Native()); } else { registry.Set(FilePathKey_DevWriteStorage, path.LexicallyNormal().Native()); registry.Set(FilePathKey_ProjectUserPath, (path / "user").LexicallyNormal().Native()); + registry.Set(FilePathKey_ProjectLogPath, (path / "user/log").LexicallyNormal().Native()); } #endif // AZ_TRAIT_OS_IS_HOST_OS_PLATFORM } diff --git a/Code/Framework/AzCore/AzCore/std/function/function_base.h b/Code/Framework/AzCore/AzCore/std/function/function_base.h index b39a5cf81b..8ceba11239 100644 --- a/Code/Framework/AzCore/AzCore/std/function/function_base.h +++ b/Code/Framework/AzCore/AzCore/std/function/function_base.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #define AZSTD_FUNCTION_TARGET_FIX(x) @@ -591,8 +592,8 @@ namespace AZStd Internal::function_util::function_buffer type_result; type_result.type.type = aztypeid(Functor); - type_result.type.const_qualified = is_const::value; - type_result.type.volatile_qualified = is_volatile::value; + type_result.type.const_qualified = AZStd::is_const::value; + type_result.type.volatile_qualified = AZStd::is_volatile::value; vtable->manager(functor, type_result, Internal::function_util::check_functor_type_tag); return static_cast(type_result.obj_ptr); } @@ -608,7 +609,7 @@ namespace AZStd Internal::function_util::function_buffer type_result; type_result.type.type = aztypeid(Functor); type_result.type.const_qualified = true; - type_result.type.volatile_qualified = is_volatile::value; + type_result.type.volatile_qualified = AZStd::is_volatile::value; vtable->manager(functor, type_result, Internal::function_util::check_functor_type_tag); // GCC 2.95.3 gets the CV qualifiers wrong here, so we // can't do the static_cast that we should do. diff --git a/Code/Framework/AzCore/AzCore/std/function/function_template.h b/Code/Framework/AzCore/AzCore/std/function/function_template.h index 7f388c4006..8e389cb53d 100644 --- a/Code/Framework/AzCore/AzCore/std/function/function_template.h +++ b/Code/Framework/AzCore/AzCore/std/function/function_template.h @@ -359,7 +359,7 @@ namespace AZStd { functor.obj_ref.obj_ptr = (void*)&f.get(); functor.obj_ref.is_const_qualified = is_const::value; - functor.obj_ref.is_volatile_qualified = is_volatile::value; + functor.obj_ref.is_volatile_qualified = AZStd::is_volatile::value; return true; } else diff --git a/Code/Framework/AzCore/AzCore/std/parallel/binary_semaphore.h b/Code/Framework/AzCore/AzCore/std/parallel/binary_semaphore.h index f9d0cdbe4d..9496d7c18b 100644 --- a/Code/Framework/AzCore/AzCore/std/parallel/binary_semaphore.h +++ b/Code/Framework/AzCore/AzCore/std/parallel/binary_semaphore.h @@ -70,11 +70,11 @@ namespace AZStd bool try_acquire_until(const chrono::time_point& abs_time) { auto timeNow = chrono::system_clock::now(); - if (timeNow >= absTime) + if (timeNow >= abs_time) { return false; // we timed out already! } - auto deltaTime = absTime - timeNow; + auto deltaTime = abs_time - timeNow; auto timeToTry = chrono::duration_cast(deltaTime); return (WaitForSingleObject(m_event, aznumeric_cast(timeToTry.count())) == AZ_WAIT_OBJECT_0); } diff --git a/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/std/parallel/internal/condition_variable_WinAPI.h b/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/std/parallel/internal/condition_variable_WinAPI.h index 536144b814..b0ed025a36 100644 --- a/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/std/parallel/internal/condition_variable_WinAPI.h +++ b/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/std/parallel/internal/condition_variable_WinAPI.h @@ -198,7 +198,7 @@ namespace AZStd AZ_FORCE_INLINE cv_status condition_variable_any::wait_for(Lock& lock, const chrono::duration& rel_time) { chrono::milliseconds toWait = rel_time; - EnterCriticalSection(&m_mutex); + EnterCriticalSection(AZ_STD_MUTEX_CAST(m_mutex)); lock.unlock(); // We need to make sure we use CriticalSection based mutex. @@ -217,7 +217,7 @@ namespace AZStd returnCode = cv_status::timeout; } } - LeaveCriticalSection(&m_mutex); + LeaveCriticalSection(AZ_STD_MUTEX_CAST(m_mutex)); lock.lock(); return returnCode; } diff --git a/Code/Framework/AzCore/Tests/AZStd/Any.cpp b/Code/Framework/AzCore/Tests/AZStd/Any.cpp index 4040573462..d6e31ea07b 100644 --- a/Code/Framework/AzCore/Tests/AZStd/Any.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/Any.cpp @@ -480,7 +480,9 @@ namespace UnitTest TEST_F(AnyTest, Any_CopyAssignSelfEmpty_IsEmpty) { any a; + AZ_PUSH_DISABLE_WARNING(, "-Wself-assign-overloaded") a = a; + AZ_POP_DISABLE_WARNING EXPECT_TRUE(a.empty()); } @@ -491,7 +493,9 @@ namespace UnitTest any a((TypeParam(1))); EXPECT_EQ(TypeParam::s_count, 1); + AZ_PUSH_DISABLE_WARNING(, "-Wself-assign-overloaded") a = a; + AZ_POP_DISABLE_WARNING EXPECT_EQ(TypeParam::s_count, 1); EXPECT_EQ(any_cast(a).val(), 1); diff --git a/Code/Framework/AzCore/Tests/AZStd/FunctorsBind.cpp b/Code/Framework/AzCore/Tests/AZStd/FunctorsBind.cpp index 58ab71096b..6bfda10ddc 100644 --- a/Code/Framework/AzCore/Tests/AZStd/FunctorsBind.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/FunctorsBind.cpp @@ -285,7 +285,9 @@ namespace UnitTest // Invocation and self-assignment global_int = 0; + AZ_PUSH_DISABLE_WARNING(, "-Wself-assign-overloaded") v1 = v1; + AZ_POP_DISABLE_WARNING v1(); AZ_TEST_ASSERT(global_int == 3); @@ -294,7 +296,9 @@ namespace UnitTest // Invocation and self-assignment global_int = 0; + AZ_PUSH_DISABLE_WARNING(, "-Wself-assign-overloaded") v1 = (v1); + AZ_POP_DISABLE_WARNING v1(); AZ_TEST_ASSERT(global_int == 5); diff --git a/Code/Framework/AzCore/Tests/AZStd/Hashed.cpp b/Code/Framework/AzCore/Tests/AZStd/Hashed.cpp index 4e4dfc1f89..b92dee44b6 100644 --- a/Code/Framework/AzCore/Tests/AZStd/Hashed.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/Hashed.cpp @@ -2100,8 +2100,8 @@ namespace UnitTest typename TypeParam::ContainerType container; container.emplace(-2352); container.emplace(3534); - container.emplace(1535408957); - container.emplace(3310556522); + container.emplace(535408957); + container.emplace(1310556522); container.emplace(55546193); container.emplace(1582); diff --git a/Code/Framework/AzCore/Tests/AZStd/Ordered.cpp b/Code/Framework/AzCore/Tests/AZStd/Ordered.cpp index 79abd71a70..ca7d5cba42 100644 --- a/Code/Framework/AzCore/Tests/AZStd/Ordered.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/Ordered.cpp @@ -1805,8 +1805,8 @@ namespace UnitTest typename TypeParam::ContainerType container; container.emplace(-2352); container.emplace(3534); - container.emplace(1535408957); - container.emplace(3310556522); + container.emplace(535408957); + container.emplace(1310556522); container.emplace(55546193); container.emplace(1582); diff --git a/Code/Framework/AzCore/Tests/AZStd/SmartPtr.cpp b/Code/Framework/AzCore/Tests/AZStd/SmartPtr.cpp index c852fd35bb..f50da28b1f 100644 --- a/Code/Framework/AzCore/Tests/AZStd/SmartPtr.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/SmartPtr.cpp @@ -920,7 +920,9 @@ namespace UnitTest AZStd::shared_ptr p1; + AZ_PUSH_DISABLE_WARNING(, "-Wself-assign-overloaded") p1 = p1; + AZ_POP_DISABLE_WARNING EXPECT_EQ(p1, p1); EXPECT_FALSE(p1); @@ -950,7 +952,9 @@ namespace UnitTest { AZStd::shared_ptr p1; + AZ_PUSH_DISABLE_WARNING(, "-Wself-assign-overloaded") p1 = p1; + AZ_POP_DISABLE_WARNING EXPECT_EQ(p1, p1); EXPECT_FALSE(p1); @@ -996,7 +1000,9 @@ namespace UnitTest using X = SharedPtr::test::X; AZStd::shared_ptr p1; + AZ_PUSH_DISABLE_WARNING(, "-Wself-assign-overloaded") p1 = p1; + AZ_POP_DISABLE_WARNING EXPECT_EQ(p1, p1); EXPECT_FALSE(p1); diff --git a/Code/Framework/AzFramework/AzFramework/API/ApplicationAPI.h b/Code/Framework/AzFramework/AzFramework/API/ApplicationAPI.h index 11778b9239..dbbf443656 100644 --- a/Code/Framework/AzFramework/AzFramework/API/ApplicationAPI.h +++ b/Code/Framework/AzFramework/AzFramework/API/ApplicationAPI.h @@ -72,11 +72,8 @@ namespace AzFramework /// Retrieves the app root path for the application. virtual const char* GetAppRoot() const { return nullptr; } -#pragma push_macro("GetCommandLine") -#undef GetCommandLine /// Get the Command Line arguments passed in. virtual const CommandLine* GetCommandLine() { return nullptr; } -#pragma pop_macro("GetCommandLine") /// Get the Command Line arguments passed in. (Avoids collisions with platform specific macros.) virtual const CommandLine* GetApplicationCommandLine() { return nullptr; } diff --git a/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.cpp b/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.cpp index aca7a41950..55e4f06db0 100644 --- a/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.cpp +++ b/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.cpp @@ -707,6 +707,7 @@ namespace AZ resolvedPathLen += postAliasView.size(); // Null-Terminated the resolved path resolvedPath[resolvedPathLen] = '\0'; + // If the path started with one of the "asset cache" path aliases, lowercase the path const char* assetAliasPath = GetAlias("@assets@"); const char* rootAliasPath = GetAlias("@root@"); @@ -714,10 +715,13 @@ namespace AZ const bool lowercasePath = (assetAliasPath != nullptr && AZ::StringFunc::StartsWith(resolvedPath, assetAliasPath)) || (rootAliasPath != nullptr && AZ::StringFunc::StartsWith(resolvedPath, rootAliasPath)) || (projectPlatformCacheAliasPath != nullptr && AZ::StringFunc::StartsWith(resolvedPath, projectPlatformCacheAliasPath)); + if (lowercasePath) { - AZStd::to_lower(resolvedPath, resolvedPath + resolvedPathLen); + // Lowercase only the relative part after the replaced alias. + AZStd::to_lower(resolvedPath + aliasValue.size(), resolvedPath + resolvedPathLen); } + // Replace any backslashes with posix slashes AZStd::replace(resolvedPath, resolvedPath + resolvedPathLen, AZ::IO::WindowsPathSeparator, AZ::IO::PosixPathSeparator); return true; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 0601a34cf5..acf935e6dc 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -31,10 +31,10 @@ namespace AzToolsFramework AssetBrowserFilterModel::AssetBrowserFilterModel(QObject* parent) : QSortFilterProxyModel(parent) { - m_showColumn.insert(aznumeric_cast(AssetBrowserEntry::Column::DisplayName)); + m_shownColumns.insert(aznumeric_cast(AssetBrowserEntry::Column::DisplayName)); if (ed_useNewAssetBrowserTableView) { - m_showColumn.insert(aznumeric_cast(AssetBrowserEntry::Column::Path)); + m_shownColumns.insert(aznumeric_cast(AssetBrowserEntry::Column::Path)); } m_collator.setNumericMode(true); AssetBrowserComponentNotificationBus::Handler::BusConnect(); @@ -96,7 +96,7 @@ namespace AzToolsFramework bool AssetBrowserFilterModel::filterAcceptsColumn(int source_column, const QModelIndex&) const { //if the column is in the set we want to show it - return m_showColumn.find(source_column) != m_showColumn.end(); + return m_shownColumns.find(source_column) != m_shownColumns.end(); } bool AssetBrowserFilterModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h index 2b91158f0e..5d3ad0e1b0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h @@ -27,6 +27,8 @@ namespace AzToolsFramework { namespace AssetBrowser { + using ShownColumnsSet = AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)>; + class AssetBrowserFilterModel : public QSortFilterProxyModel , public AssetBrowserComponentNotificationBus::Handler @@ -61,11 +63,11 @@ namespace AzToolsFramework void filterUpdatedSlot(); protected: - //set for filtering columns - //if the column is in the set the column is not filtered and is shown - AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; + // Set for filtering columns + // If the column is in the set the column is not filtered and is shown + ShownColumnsSet m_shownColumns; bool m_alreadyRecomputingFilters = false; - //asset source name match filter + //Asset source name match filter FilterConstType m_filter; AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' QWeakPointer m_stringFilter; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index d0999c5c56..fdbd4287ce 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -16,7 +16,6 @@ namespace AzToolsFramework AssetBrowserTableModel::AssetBrowserTableModel(QObject* parent /* = nullptr */) : QSortFilterProxyModel(parent) { - setDynamicSortFilter(false); } void AssetBrowserTableModel::setSourceModel(QAbstractItemModel* sourceModel) @@ -47,7 +46,7 @@ namespace AzToolsFramework QModelIndex AssetBrowserTableModel::mapToSource(const QModelIndex& proxyIndex) const { - Q_ASSERT(!proxyIndex.isValid() || proxyIndex.model() == this); + Q_ASSERT(!proxyIndex.isValid() || proxyIndex.model() != this); if (!proxyIndex.isValid() || !m_indexMap.contains(proxyIndex.row())) { return QModelIndex(); @@ -132,7 +131,7 @@ namespace AzToolsFramework { QModelIndex index = model->index(currentRow, 0, parent); AssetBrowserEntry* entry = GetAssetEntry(m_filterModel->mapToSource(index)); - // We only want to see the source assets. + // We only want to see source and product assets. if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source || entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Product) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index 04559fbfbc..55dcbb1532 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -21,8 +21,7 @@ namespace AzToolsFramework class AssetBrowserFilterModel; class AssetBrowserEntry; - class AssetBrowserTableModel - : public QSortFilterProxyModel + class AssetBrowserTableModel : public QSortFilterProxyModel { Q_OBJECT diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.cpp index 11e1ba018f..76b634b51e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.cpp @@ -9,9 +9,11 @@ #include #include +#include #include #include +#include #include #include #include @@ -26,6 +28,11 @@ AZ_PUSH_DISABLE_WARNING(4251 4244, "-Wunknown-warning-option") // disable warnin #include AZ_POP_DISABLE_WARNING +AZ_CVAR( + bool, ed_hideAssetPickerPathColumn, false, nullptr, AZ::ConsoleFunctorFlags::Null, + "Hide AssetPicker path column for a clearer view."); +AZ_CVAR_EXTERNED(bool, ed_useNewAssetBrowserTableView); + namespace AzToolsFramework { namespace AssetBrowser @@ -34,6 +41,7 @@ namespace AzToolsFramework : QDialog(parent) , m_ui(new Ui::AssetPickerDialogClass()) , m_filterModel(new AssetBrowserFilterModel(parent)) + , m_tableModel(new AssetBrowserTableModel(parent)) , m_selection(selection) , m_hasFilter(false) { @@ -97,6 +105,56 @@ namespace AzToolsFramework m_persistentState = AZ::UserSettings::CreateFind(AZ::Crc32(("AssetBrowserTreeView_Dialog_" + name).toUtf8().data()), AZ::UserSettings::CT_GLOBAL); + m_ui->m_assetBrowserTableViewWidget->setVisible(false); + if (ed_useNewAssetBrowserTableView) + { + m_ui->m_assetBrowserTreeViewWidget->setVisible(false); + m_ui->m_assetBrowserTableViewWidget->setVisible(true); + m_tableModel->setSourceModel(m_filterModel.get()); + m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.get()); + + m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_" + name); + m_ui->m_assetBrowserTableViewWidget->setDragEnabled(false); + m_ui->m_assetBrowserTableViewWidget->setSelectionMode( + selection.GetMultiselect() ? QAbstractItemView::SelectionMode::ExtendedSelection + : QAbstractItemView::SelectionMode::SingleSelection); + + if (ed_hideAssetPickerPathColumn) + { + m_ui->m_assetBrowserTableViewWidget->hideColumn(1); + } + + // if the current selection is invalid, disable the Ok button + m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(EvaluateSelection()); + + connect( + m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, this, + [this]() + { + m_tableModel->UpdateTableModelMaps(); + }); + + connect( + m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::selectionChangedSignal, this, + [this](const QItemSelection&, const QItemSelection&) + { + AssetPickerDialog::SelectionChangedSlot(); + }); + + connect(m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AssetPickerDialog::DoubleClickedSlot); + + connect( + m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget, + &SearchWidget::ClearStringFilter); + + connect( + m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget, + &SearchWidget::ClearTypeFilter); + + m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); + m_tableModel->UpdateTableModelMaps(); + } + QTimer::singleShot(0, this, &AssetPickerDialog::RestoreState); SelectionChangedSlot(); } @@ -134,6 +192,7 @@ namespace AzToolsFramework { m_ui->m_assetBrowserTreeViewWidget->expandAll(); }); + m_tableModel->UpdateTableModelMaps(); } if (m_hasFilter && !hasFilter) @@ -166,7 +225,8 @@ namespace AzToolsFramework bool AssetPickerDialog::EvaluateSelection() const { - auto selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets(); + auto selectedAssets = m_ui->m_assetBrowserTreeViewWidget->isVisible() ? m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets() + : m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets(); // exactly one item must be selected, even if multi-select option is disabled, still good practice to check if (selectedAssets.empty()) { @@ -197,7 +257,10 @@ namespace AzToolsFramework void AssetPickerDialog::UpdatePreview() const { - auto selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets(); + auto selectedAssets = m_ui->m_assetBrowserTreeViewWidget->isVisible() + ? m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets() + : m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets(); + ; if (selectedAssets.size() != 1) { m_ui->m_previewerFrame->Clear(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.h index 89eca2f4e3..bab265c134 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.h @@ -33,6 +33,7 @@ namespace AzToolsFramework { class ProductAssetBrowserEntry; class AssetBrowserFilterModel; + class AssetBrowserTableModel; class AssetBrowserModel; class AssetSelectionModel; @@ -69,6 +70,7 @@ namespace AzToolsFramework QScopedPointer m_ui; AssetBrowserModel* m_assetBrowserModel = nullptr; QScopedPointer m_filterModel; + QScopedPointer m_tableModel; AssetSelectionModel& m_selection; bool m_hasFilter; AZStd::unique_ptr m_filterStateSaver; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.ui b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.ui index 3dd0c0d861..b11ffb3990 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.ui +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.ui @@ -142,6 +142,9 @@ + + + @@ -197,6 +200,11 @@
AzToolsFramework/AssetBrowser/Previewer/PreviewerFrame.h
1 + + AzToolsFramework::AssetBrowser::AssetBrowserTableView + QTableView +
AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h
+
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index e5426037bf..5fbdab2ec5 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -53,7 +53,6 @@ namespace AzToolsFramework // AssetBrowserComponentNotificationBus void OnAssetBrowserComponentReady() override; ////////////////////////////////////////////////////////////////////////// - Q_SIGNALS: void selectionChangedSignal(const QItemSelection& selected, const QItemSelection& deselected); void ClearStringFilter(); diff --git a/Code/LauncherUnified/launcher_generator.cmake b/Code/LauncherUnified/launcher_generator.cmake index 9c8a6b8f16..b30f752c85 100644 --- a/Code/LauncherUnified/launcher_generator.cmake +++ b/Code/LauncherUnified/launcher_generator.cmake @@ -6,8 +6,8 @@ # # - set_property(GLOBAL PROPERTY LAUNCHER_UNIFIED_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + # Launcher targets for a project need to be generated when configuring a project. # When building the engine source, this file will be included by LauncherUnified's CMakeLists.txt # When using an installed engine, this file will be included by the FindLauncherGenerator.cmake script @@ -121,6 +121,7 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC set_target_properties(${project_name}.GameLauncher PROPERTIES FOLDER ${project_name} + LY_PROJECT_NAME ${project_name} ) # After ensuring that we correctly support DPI scaling, this should be switched to "PerMonitor" @@ -129,6 +130,9 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC set_property(TARGET ${project_name}.GameLauncher APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${LY_DEFAULT_PROJECT_PATH}\"") endif() + # Associate the Clients Gem Variant with each projects GameLauncher + ly_set_gem_variant_to_load(TARGETS ${project_name}.GameLauncher VARIANTS Clients) + ################################################################################ # Server ################################################################################ @@ -168,11 +172,15 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC set_target_properties(${project_name}.ServerLauncher PROPERTIES FOLDER ${project_name} + LY_PROJECT_NAME ${project_name} ) if(LY_DEFAULT_PROJECT_PATH) set_property(TARGET ${project_name}.ServerLauncher APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${LY_DEFAULT_PROJECT_PATH}\"") endif() + + # Associate the Servers Gem Variant with each projects ServerLauncher + ly_set_gem_variant_to_load(TARGETS ${project_name}.ServerLauncher VARIANTS Servers) endif() endif() diff --git a/Code/LauncherUnified/launcher_project_files.cmake b/Code/LauncherUnified/launcher_project_files.cmake index 9f5bacbce5..2276631fbe 100644 --- a/Code/LauncherUnified/launcher_project_files.cmake +++ b/Code/LauncherUnified/launcher_project_files.cmake @@ -9,4 +9,5 @@ set(FILES LauncherProject.cpp StaticModules.in + launcher_generator.cmake ) diff --git a/Code/Legacy/CryCommon/AppleSpecific.h b/Code/Legacy/CryCommon/AppleSpecific.h index 60ab80ade6..e4c4fadb89 100644 --- a/Code/Legacy/CryCommon/AppleSpecific.h +++ b/Code/Legacy/CryCommon/AppleSpecific.h @@ -13,10 +13,6 @@ #define CRYINCLUDE_CRYCOMMON_APPLESPECIFIC_H #pragma once -#if defined(__clang__) -#pragma diagnostic ignore "-W#pragma-messages" -#endif - ////////////////////////////////////////////////////////////////////////// // Standard includes. ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/IConsole.h b/Code/Legacy/CryCommon/IConsole.h index dcbb0399aa..f68a82f9dc 100644 --- a/Code/Legacy/CryCommon/IConsole.h +++ b/Code/Legacy/CryCommon/IConsole.h @@ -118,10 +118,6 @@ struct IConsoleVarSink // }; -#if defined(GetCommandLine) -#undef GetCommandLine -#endif - // Interface to the arguments of the console command. struct IConsoleCmdArgs { diff --git a/Code/Tools/AssetProcessor/AssetBuilder/CMakeLists.txt b/Code/Tools/AssetProcessor/AssetBuilder/CMakeLists.txt index 64655c5164..6baa99d43b 100644 --- a/Code/Tools/AssetProcessor/AssetBuilder/CMakeLists.txt +++ b/Code/Tools/AssetProcessor/AssetBuilder/CMakeLists.txt @@ -39,6 +39,7 @@ ly_add_source_properties( ) if(TARGET AssetBuilder) + ly_set_gem_variant_to_load(TARGETS AssetBuilder VARIANTS Builders) # Adds the AssetBuilder target as a C preprocessor define so that it can be used as a Settings Registry # specialization in order to look up the generated .setreg which contains the dependencies # specified for the AssetBuilder in the /Gem/Code/CMakeLists via ly_add_project_dependencies diff --git a/Code/Tools/AssetProcessor/CMakeLists.txt b/Code/Tools/AssetProcessor/CMakeLists.txt index f10e4a9e05..431a167163 100644 --- a/Code/Tools/AssetProcessor/CMakeLists.txt +++ b/Code/Tools/AssetProcessor/CMakeLists.txt @@ -81,6 +81,7 @@ ly_add_target( # specialization in order to look up the generated .setreg which contains the dependencies # specified for the target. if(TARGET AssetProcessor) + ly_set_gem_variant_to_load(TARGETS AssetProcessor VARIANTS Builders) set_source_files_properties( native/AssetProcessorBuildTarget.cpp PROPERTIES @@ -130,6 +131,7 @@ endif() # specialization in order to look up the generated .setreg which contains the dependencies # specified for the target. if(TARGET AssetProcessorBatch) + ly_set_gem_variant_to_load(TARGETS AssetProcessorBatch VARIANTS Builders) set_source_files_properties( native/AssetProcessorBatchBuildTarget.cpp PROPERTIES diff --git a/Code/Tools/AssetProcessor/Platform/Mac/main_dummy.cpp b/Code/Tools/AssetProcessor/Platform/Mac/main_dummy.cpp index e624b40787..3eed37e555 100644 --- a/Code/Tools/AssetProcessor/Platform/Mac/main_dummy.cpp +++ b/Code/Tools/AssetProcessor/Platform/Mac/main_dummy.cpp @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) processLaunchInfo.m_environmentVariables = &envVars; processLaunchInfo.m_showWindow = true; - AZStd::unique_ptr processWatcher(AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE)); + AzFramework::ProcessLauncher::LaunchUnwatchedProcess(processLaunchInfo); application.Destroy(); diff --git a/Code/Tools/AssetProcessor/native/unittests/AssetProcessingStateDataUnitTests.cpp b/Code/Tools/AssetProcessor/native/unittests/AssetProcessingStateDataUnitTests.cpp index 1c9e29c4e8..e19b95a76b 100644 --- a/Code/Tools/AssetProcessor/native/unittests/AssetProcessingStateDataUnitTests.cpp +++ b/Code/Tools/AssetProcessor/native/unittests/AssetProcessingStateDataUnitTests.cpp @@ -715,12 +715,7 @@ void AssetProcessingStateDataUnitTest::DataTest(AssetProcessor::AssetDatabaseCon //try retrieving this source by id UNIT_TEST_EXPECT_TRUE(stateData->GetJobByJobID(job.m_jobID, job)); - if (job.m_jobID == AzToolsFramework::AssetDatabase::InvalidEntryId || - job.m_jobID != job.m_jobID || - job.m_sourcePK != job.m_sourcePK || - job.m_jobKey != job.m_jobKey || - job.m_fingerprint != job.m_fingerprint || - job.m_platform != job.m_platform) + if (job.m_jobID == AzToolsFramework::AssetDatabase::InvalidEntryId) { Q_EMIT UnitTestFailed("AssetProcessingStateDataTest Failed - GetJobByJobID failed"); return; diff --git a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp index 7292990a72..85801bdf8a 100644 --- a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp @@ -57,9 +57,6 @@ #include -// windows headers bring in a macro which conflicts GetCommandLine -#undef GetCommandLine - namespace AssetUtilsInternal { static const unsigned int g_RetryWaitInterval = 250; // The amount of time that we are waiting for retry. diff --git a/Code/Tools/AzTestRunner/Platform/Android/platform_android.cpp b/Code/Tools/AzTestRunner/Platform/Android/platform_android.cpp index 1e4f731b9a..9e0ea304ef 100644 --- a/Code/Tools/AzTestRunner/Platform/Android/platform_android.cpp +++ b/Code/Tools/AzTestRunner/Platform/Android/platform_android.cpp @@ -64,7 +64,7 @@ namespace AzTestRunner { static char cwd_buffer[AZ_MAX_PATH_LEN] = { '\0' }; - AZ::Utils::ExecutablePathResult result = AZ::Utils::GetExecutableDirectory(cwd_buffer, AZ_ARRAY_SIZE(cwd_buffer)); + [[maybe_unused]] AZ::Utils::ExecutablePathResult result = AZ::Utils::GetExecutableDirectory(cwd_buffer, AZ_ARRAY_SIZE(cwd_buffer)); AZ_Assert(result == AZ::Utils::ExecutablePathResult::Success, "Error retrieving executable path"); return static_cast(cwd_buffer); diff --git a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/Views/PairIteratorTests.cpp b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/Views/PairIteratorTests.cpp index d80f54dfb5..2437d8557e 100644 --- a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/Views/PairIteratorTests.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/Views/PairIteratorTests.cpp @@ -19,6 +19,18 @@ #include #include +// This test gives trouble with /permissive-, the following instantiation workarounds the missing resolution +namespace std +{ + template<> + void iter_swap( + AZ::SceneAPI::Containers::Views::PairIterator lhs, + AZ::SceneAPI::Containers::Views::PairIterator rhs) + { + AZStd::iter_swap(lhs, rhs); + } +} + namespace AZ { namespace SceneAPI diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/MaterialData.cpp b/Code/Tools/SceneAPI/SceneData/GraphData/MaterialData.cpp index d58a89a110..117a1196f8 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/MaterialData.cpp +++ b/Code/Tools/SceneAPI/SceneData/GraphData/MaterialData.cpp @@ -230,6 +230,19 @@ namespace AZ return m_uniqueId; } + namespace Helper + { + template + T ReturnOptionalValue(AZStd::optional value) + { + if (!value) + { + return {}; + } + return value.value(); + } + } + void MaterialData::Reflect(ReflectContext* context) { SerializeContext* serializeContext = azrtti_cast(context); @@ -285,6 +298,76 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_useAOMap, "Use Ambient Occlusion Map", "True to use an ambient occlusion map, false to ignore it."); } } + + BehaviorContext* behaviorContext = azrtti_cast(context); + if (behaviorContext) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene"); + + using namespace Helper; + using DataTypes::IMaterialData; + + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene") + ->Constant("AmbientOcclusion", BehaviorConstant(TextureMapType::AmbientOcclusion)) + ->Constant("BaseColor", BehaviorConstant(TextureMapType::BaseColor)) + ->Constant("Bump", BehaviorConstant(TextureMapType::Bump)) + ->Constant("Diffuse", BehaviorConstant(TextureMapType::Diffuse)) + ->Constant("Emissive", BehaviorConstant(TextureMapType::Emissive)) + ->Constant("Metallic", BehaviorConstant(TextureMapType::Metallic)) + ->Constant("Normal", BehaviorConstant(TextureMapType::Normal)) + ->Constant("Roughness", BehaviorConstant(TextureMapType::Roughness)) + ->Constant("Specular", BehaviorConstant(TextureMapType::Specular)) + ->Method("GetTexture", &MaterialData::GetTexture) + ->Method("GetMaterialName", &MaterialData::GetMaterialName) + ->Method("IsNoDraw", &MaterialData::IsNoDraw) + ->Method("GetDiffuseColor", &MaterialData::GetDiffuseColor) + ->Method("GetSpecularColor", &MaterialData::GetSpecularColor) + ->Method("GetEmissiveColor", &MaterialData::GetEmissiveColor) + ->Method("GetOpacity", &MaterialData::GetOpacity) + ->Method("GetUniqueId", &MaterialData::GetUniqueId) + ->Method("GetShininess", &MaterialData::GetShininess) + ->Method("GetUseColorMap", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetUseColorMap()); + }) + ->Method("GetBaseColor", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetBaseColor()); + }) + ->Method("GetUseMetallicMap", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetUseMetallicMap()); + }) + ->Method("GetMetallicFactor", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetMetallicFactor()); + }) + ->Method("GetUseRoughnessMap", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetUseRoughnessMap()); + }) + ->Method("GetRoughnessFactor", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetRoughnessFactor()); + }) + ->Method("GetUseEmissiveMap", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetUseEmissiveMap()); + }) + ->Method("GetEmissiveIntensity", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetEmissiveIntensity()); + }) + ->Method("GetUseAOMap", [](const MaterialData& self) + { + return ReturnOptionalValue(self.GetUseAOMap()); + }); + } } } // namespace GraphData } // namespace SceneData diff --git a/Code/Tools/SceneAPI/SceneData/Tests/GraphData/GraphDataBehaviorTests.cpp b/Code/Tools/SceneAPI/SceneData/Tests/GraphData/GraphDataBehaviorTests.cpp index ab0fa79e62..4a2d206cc7 100644 --- a/Code/Tools/SceneAPI/SceneData/Tests/GraphData/GraphDataBehaviorTests.cpp +++ b/Code/Tools/SceneAPI/SceneData/Tests/GraphData/GraphDataBehaviorTests.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include namespace AZ { @@ -145,6 +147,38 @@ namespace AZ blendShapeData->SetVertexIndexToControlPointIndexMap(2, 0); return true; } + else if (data.get_type_info().m_id == azrtti_typeid()) + { + auto* materialDataData = AZStd::any_cast(&data); + materialDataData->SetBaseColor(AZStd::make_optional(AZ::Vector3(0.1, 0.2, 0.3))); + materialDataData->SetDiffuseColor({ 0.3, 0.4, 0.5 }); + materialDataData->SetEmissiveColor({ 0.4, 0.5, 0.6 }); + materialDataData->SetEmissiveIntensity(AZStd::make_optional(0.789f)); + materialDataData->SetMaterialName("TestMaterialName"); + materialDataData->SetMetallicFactor(AZStd::make_optional(0.123f)); + materialDataData->SetNoDraw(true); + materialDataData->SetOpacity(0.7); + materialDataData->SetRoughnessFactor(AZStd::make_optional(0.456f)); + materialDataData->SetShininess(1.23); + materialDataData->SetSpecularColor({ 0.8, 0.9, 1.0 }); + materialDataData->SetUseAOMap(AZStd::make_optional(true)); + materialDataData->SetUseColorMap(AZStd::make_optional(true)); + materialDataData->SetUseMetallicMap(AZStd::make_optional(true)); + materialDataData->SetUseRoughnessMap(AZStd::make_optional(true)); + materialDataData->SetUseEmissiveMap(AZStd::make_optional(true)); + materialDataData->SetUniqueId(102938); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::AmbientOcclusion, "ambientocclusion"); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::BaseColor, "basecolor"); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::Bump, "bump"); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::Diffuse, "diffuse"); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::Emissive, "emissive"); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::Metallic, "metallic"); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::Normal, "normal"); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::Roughness, "roughness"); + materialDataData->SetTexture(AZ::SceneAPI::DataTypes::IMaterialData::TextureMapType::Specular, "specular"); + return true; + } + return false; } @@ -337,7 +371,7 @@ namespace AZ ExpectExecute("TestExpectFloatEquals(tangentData.z, 0.19)"); ExpectExecute("TestExpectFloatEquals(tangentData.w, 0.29)"); ExpectExecute("TestExpectIntegerEquals(meshVertexTangentData:GetTangentSetIndex(), 2)"); - ExpectExecute("TestExpectTrue(meshVertexTangentData:GetGenerationMethod(), MeshVertexTangentData.EMotionFX)"); + ExpectExecute("TestExpectTrue(meshVertexTangentData:GetGenerationMethod(), MeshVertexTangentData.MikkT)"); } TEST_F(GrapDatahBehaviorScriptTest, SceneGraph_AnimationData_AccessWorks) @@ -449,6 +483,49 @@ namespace AZ ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(2).y, 0.3)"); ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(2).z, 0.4)"); } + + TEST_F(GrapDatahBehaviorScriptTest, SceneGraph_MaterialData_AccessWorks) + { + ExpectExecute("materialData = MaterialData()"); + ExpectExecute("TestExpectTrue(materialData ~= nil)"); + ExpectExecute("TestExpectTrue(materialData:IsNoDraw() == false)"); + ExpectExecute("TestExpectTrue(materialData:GetUseColorMap() == false)"); + ExpectExecute("TestExpectTrue(materialData:GetUseMetallicMap() == false)"); + ExpectExecute("TestExpectTrue(materialData:GetUseRoughnessMap() == false)"); + ExpectExecute("TestExpectTrue(materialData:GetUseEmissiveMap() == false)"); + ExpectExecute("TestExpectTrue(materialData:GetUseAOMap() == false)"); + ExpectExecute("MockGraphData.FillData(materialData)"); + ExpectExecute("TestExpectTrue(materialData:IsNoDraw())"); + ExpectExecute("TestExpectTrue(materialData:GetUseColorMap())"); + ExpectExecute("TestExpectTrue(materialData:GetUseMetallicMap())"); + ExpectExecute("TestExpectTrue(materialData:GetUseRoughnessMap())"); + ExpectExecute("TestExpectTrue(materialData:GetUseEmissiveMap())"); + ExpectExecute("TestExpectTrue(materialData:GetUseAOMap())"); + ExpectExecute("TestExpectFloatEquals(materialData:GetMetallicFactor(), 0.123)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetRoughnessFactor(), 0.456)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetEmissiveIntensity(), 0.789)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetOpacity(), 0.7)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetShininess(), 1.23)"); + ExpectExecute("TestExpectTrue(materialData:GetMaterialName() == 'TestMaterialName')"); + ExpectExecute("TestExpectFloatEquals(materialData:GetBaseColor().x, 0.1)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetBaseColor().y, 0.2)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetBaseColor().z, 0.3)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetDiffuseColor().x, 0.3)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetDiffuseColor().y, 0.4)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetDiffuseColor().z, 0.5)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetEmissiveColor().x, 0.4)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetEmissiveColor().y, 0.5)"); + ExpectExecute("TestExpectFloatEquals(materialData:GetEmissiveColor().z, 0.6)"); + ExpectExecute("TestExpectIntegerEquals(materialData:GetUniqueId(), 102938)"); + ExpectExecute("TestExpectTrue(materialData:GetTexture(MaterialData.AmbientOcclusion) == 'ambientocclusion')"); + ExpectExecute("TestExpectTrue(materialData:GetTexture(MaterialData.Bump) == 'bump')"); + ExpectExecute("TestExpectTrue(materialData:GetTexture(MaterialData.Diffuse) == 'diffuse')"); + ExpectExecute("TestExpectTrue(materialData:GetTexture(MaterialData.Emissive) == 'emissive')"); + ExpectExecute("TestExpectTrue(materialData:GetTexture(MaterialData.Metallic) == 'metallic')"); + ExpectExecute("TestExpectTrue(materialData:GetTexture(MaterialData.Normal) == 'normal')"); + ExpectExecute("TestExpectTrue(materialData:GetTexture(MaterialData.Roughness) == 'roughness')"); + ExpectExecute("TestExpectTrue(materialData:GetTexture(MaterialData.Specular) == 'specular')"); + } } } } diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Include/TestImpactFramework/TestImpactClientSequenceReport.h b/Code/Tools/TestImpactFramework/Runtime/Code/Include/TestImpactFramework/TestImpactClientSequenceReport.h index 1ddd1042e6..b39c2c8bcb 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Include/TestImpactFramework/TestImpactClientSequenceReport.h +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Include/TestImpactFramework/TestImpactClientSequenceReport.h @@ -368,7 +368,7 @@ namespace TestImpact const AZStd::vector& draftedTestRuns, TestRunReport&& selectedTestRunReport, TestRunReport&& draftedTestRunReport) - : SequenceReportBase( + : SequenceReportBase ( type, maxConcurrency, testTargetTimeout, @@ -397,57 +397,57 @@ namespace TestImpact // SequenceReport overrides ... AZStd::chrono::milliseconds GetDuration() const override { - return SequenceReportBase::GetDuration() + m_draftedTestRunReport.GetDuration(); + return GetDuration() + m_draftedTestRunReport.GetDuration(); } TestSequenceResult GetResult() const override { - return CalculateMultiTestSequenceResult({ SequenceReportBase::GetResult(), m_draftedTestRunReport.GetResult() }); + return CalculateMultiTestSequenceResult({ GetResult(), m_draftedTestRunReport.GetResult() }); } size_t GetTotalNumTestRuns() const override { - return SequenceReportBase::GetTotalNumTestRuns() + m_draftedTestRunReport.GetTotalNumTestRuns(); + return GetTotalNumTestRuns() + m_draftedTestRunReport.GetTotalNumTestRuns(); } size_t GetTotalNumPassingTests() const override { - return SequenceReportBase::GetTotalNumPassingTests() + m_draftedTestRunReport.GetTotalNumPassingTests(); + return GetTotalNumPassingTests() + m_draftedTestRunReport.GetTotalNumPassingTests(); } size_t GetTotalNumFailingTests() const override { - return SequenceReportBase::GetTotalNumFailingTests() + m_draftedTestRunReport.GetTotalNumFailingTests(); + return GetTotalNumFailingTests() + m_draftedTestRunReport.GetTotalNumFailingTests(); } size_t GetTotalNumDisabledTests() const override { - return SequenceReportBase::GetTotalNumDisabledTests() + m_draftedTestRunReport.GetTotalNumDisabledTests(); + return GetTotalNumDisabledTests() + m_draftedTestRunReport.GetTotalNumDisabledTests(); } size_t GetTotalNumPassingTestRuns() const override { - return SequenceReportBase::GetTotalNumPassingTestRuns() + m_draftedTestRunReport.GetNumPassingTestRuns(); + return GetTotalNumPassingTestRuns() + m_draftedTestRunReport.GetNumPassingTestRuns(); } size_t GetTotalNumFailingTestRuns() const override { - return SequenceReportBase::GetTotalNumFailingTestRuns() + m_draftedTestRunReport.GetNumFailingTestRuns(); + return GetTotalNumFailingTestRuns() + m_draftedTestRunReport.GetNumFailingTestRuns(); } size_t GetTotalNumExecutionFailureTestRuns() const override { - return SequenceReportBase::GetTotalNumExecutionFailureTestRuns() + m_draftedTestRunReport.GetNumExecutionFailureTestRuns(); + return GetTotalNumExecutionFailureTestRuns() + m_draftedTestRunReport.GetNumExecutionFailureTestRuns(); } size_t GetTotalNumTimedOutTestRuns() const override { - return SequenceReportBase::GetTotalNumTimedOutTestRuns() + m_draftedTestRunReport.GetNumTimedOutTestRuns(); + return GetTotalNumTimedOutTestRuns() + m_draftedTestRunReport.GetNumTimedOutTestRuns(); } size_t GetTotalNumUnexecutedTestRuns() const override { - return SequenceReportBase::GetTotalNumUnexecutedTestRuns() + m_draftedTestRunReport.GetNumUnexecutedTestRuns(); + return GetTotalNumUnexecutedTestRuns() + m_draftedTestRunReport.GetNumUnexecutedTestRuns(); } private: AZStd::vector m_draftedTestRuns; diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Include/TestImpactFramework/TestImpactRepoPath.h b/Code/Tools/TestImpactFramework/Runtime/Code/Include/TestImpactFramework/TestImpactRepoPath.h index 86f4a98b78..e784c43500 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Include/TestImpactFramework/TestImpactRepoPath.h +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Include/TestImpactFramework/TestImpactRepoPath.h @@ -26,11 +26,11 @@ namespace TestImpact constexpr RepoPath() = default; constexpr RepoPath(const RepoPath&) = default; constexpr RepoPath(RepoPath&&) noexcept = default; - constexpr RepoPath::RepoPath(const string_type& path) noexcept; - constexpr RepoPath::RepoPath(const string_view_type& path) noexcept; - constexpr RepoPath::RepoPath(const value_type* path) noexcept; - constexpr RepoPath::RepoPath(const AZ::IO::PathView& path); - constexpr RepoPath::RepoPath(const AZ::IO::Path& path); + constexpr RepoPath(const string_type& path) noexcept; + constexpr RepoPath(const string_view_type& path) noexcept; + constexpr RepoPath(const value_type* path) noexcept; + constexpr RepoPath(const AZ::IO::PathView& path); + constexpr RepoPath(const AZ::IO::Path& path); RepoPath& operator=(const RepoPath&) noexcept = default; RepoPath& operator=(const string_type&) noexcept; diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Platform/Windows/TestEngine/JobRunner/TestImpactWin32_TestTargetExtension.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Platform/Windows/TestEngine/JobRunner/TestImpactWin32_TestTargetExtension.cpp index 57647bb118..68beae5a0a 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Platform/Windows/TestEngine/JobRunner/TestImpactWin32_TestTargetExtension.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Platform/Windows/TestEngine/JobRunner/TestImpactWin32_TestTargetExtension.cpp @@ -14,8 +14,8 @@ namespace TestImpact { AZStd::string GetTestTargetExtension(const TestTarget* testTarget) { - static constexpr char* const standAloneExtension = ".exe"; - static constexpr char* const testRunnerExtension = ".dll"; + static constexpr const char* const standAloneExtension = ".exe"; + static constexpr const char* const testRunnerExtension = ".dll"; switch (const auto launchMethod = testTarget->GetLaunchMethod(); launchMethod) { diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Weights.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Weights.cpp index 170805aa57..41b0fd8b41 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Weights.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Weights.cpp @@ -296,9 +296,8 @@ namespace ImageProcessingAtom /* skip leading and trailing zeros */ if (trimZeros) { - /* set i0 and i1 to the nonzero support of the filter */ - i0 = i0; - i1 = i1 = lastnonzero + 1; + /* set i1 to the nonzero support of the filter */ + i1 = lastnonzero + 1; } if (sumiWeights != WEIGHTONE) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/External/CubeMapGen/CCubeMapProcessor.cpp b/Gems/Atom/Asset/ImageProcessingAtom/External/CubeMapGen/CCubeMapProcessor.cpp index 8a4d727e8c..dc8af67877 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/External/CubeMapGen/CCubeMapProcessor.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/External/CubeMapGen/CCubeMapProcessor.cpp @@ -616,8 +616,6 @@ namespace ImageProcessingAtom a_FilterExtents[oppositeFaceIdx].Augment((a_SrcSize-1), (a_SrcSize-1), 0); } } - - minV=minV; } diff --git a/Gems/Atom/Asset/Shader/Code/CMakeLists.txt b/Gems/Atom/Asset/Shader/Code/CMakeLists.txt index 298f00825f..c0bdfd4a8b 100644 --- a/Gems/Atom/Asset/Shader/Code/CMakeLists.txt +++ b/Gems/Atom/Asset/Shader/Code/CMakeLists.txt @@ -101,8 +101,7 @@ ly_add_target( # The Atom_Asset_Shader is a required gem for Builders in order to process the assets that come WITHOUT # the Atom_Feature_Common required gem -ly_enable_gems(GEMS Atom_Asset_Shader VARIANTS Builders - TARGETS AssetBuilder AssetProcessor AssetProcessorBatch) +ly_enable_gems(GEMS Atom_Asset_Shader) ################################################################################ # Tests diff --git a/Gems/Atom/Bootstrap/Code/CMakeLists.txt b/Gems/Atom/Bootstrap/Code/CMakeLists.txt index 1787af04ed..fd9df96124 100644 --- a/Gems/Atom/Bootstrap/Code/CMakeLists.txt +++ b/Gems/Atom/Bootstrap/Code/CMakeLists.txt @@ -45,14 +45,4 @@ ly_create_alias(NAME Atom_Bootstrap.Clients NAMESPACE Gem TARGETS Gem::Atom_Boot ly_create_alias(NAME Atom_Bootstrap.Servers NAMESPACE Gem TARGETS Gem::Atom_Bootstrap) # The Atom_Bootstrap gem is responsible for making the NativeWindow handle in the launcher applications -# Loop over each Project name to allow the ${ProjectName}.GameLauncher and ${ProjectName}.ServerLauncher -# target to add the gem the Clients and Servers variant -get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME) -foreach(project_name IN LISTS LY_PROJECTS_TARGET_NAME) - # Add gem as a dependency of the Clients Launcher - ly_enable_gems(PROJECT_NAME ${project_name} GEMS Atom_Bootstrap VARIANTS Clients TARGETS ${project_name}.GameLauncher) - # Add gem as a dependency of the Servers Launcher - if(PAL_TRAIT_BUILD_SERVER_SUPPORTED) - ly_enable_gems(PROJECT_NAME ${project_name} GEMS Atom_Bootstrap VARIANTS Servers TARGETS ${project_name}.ServerLauncher) - endif() -endforeach() +ly_enable_gems(GEMS Atom_Bootstrap) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/FrameCaptureBus.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/FrameCaptureBus.h index 919d1b7468..93600ec08f 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/FrameCaptureBus.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Utils/FrameCaptureBus.h @@ -31,6 +31,11 @@ namespace AZ { public: virtual ~FrameCaptureRequests() = default; + + //! Return true if frame capture is available. + //! It may return false if null renderer is used. + //! If the frame capture is not available, all capture functions in this interface would return false + virtual bool CanCapture() const = 0; //! Capture final screen output for the specified window and save it to given file path. //! The image format is determinate by file extension diff --git a/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.cpp b/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.cpp index 7374fdaf71..9f6d2a343d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.cpp @@ -8,6 +8,8 @@ #include "FrameCaptureSystemComponent.h" +#include + #include #include #include @@ -254,8 +256,18 @@ namespace AZ return AZStd::string(resolvedPath); } + bool FrameCaptureSystemComponent::CanCapture() const + { + return !AZ::RHI::IsNullRenderer(); + } + bool FrameCaptureSystemComponent::CaptureScreenshotForWindow(const AZStd::string& filePath, AzFramework::NativeWindowHandle windowHandle) { + if (!CanCapture()) + { + return false; + } + InitReadback(); if (m_state != State::Idle) @@ -301,6 +313,11 @@ namespace AZ bool FrameCaptureSystemComponent::CaptureScreenshotWithPreview(const AZStd::string& outputFilePath) { + if (!CanCapture()) + { + return false; + } + InitReadback(); if (m_state != State::Idle) @@ -350,6 +367,11 @@ namespace AZ bool FrameCaptureSystemComponent::CapturePassAttachment(const AZStd::vector& passHierarchy, const AZStd::string& slot, const AZStd::string& outputFilePath, RPI::PassAttachmentReadbackOption option) { + if (!CanCapture()) + { + return false; + } + InitReadback(); if (m_state != State::Idle) @@ -396,6 +418,11 @@ namespace AZ bool FrameCaptureSystemComponent::CapturePassAttachmentWithCallback(const AZStd::vector& passHierarchy, const AZStd::string& slotName , RPI::AttachmentReadback::CallbackFunction callback, RPI::PassAttachmentReadbackOption option) { + if (!CanCapture()) + { + return false; + } + bool result = CapturePassAttachment(passHierarchy, slotName, "", option); // Append state change to user provided call back diff --git a/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.h b/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.h index 5dbaa5dee6..20e233ce62 100644 --- a/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.h +++ b/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.h @@ -34,6 +34,7 @@ namespace AZ void Deactivate() override; // FrameCaptureRequestBus overrides ... + bool CanCapture() const override; bool CaptureScreenshot(const AZStd::string& filePath) override; bool CaptureScreenshotForWindow(const AZStd::string& filePath, AzFramework::NativeWindowHandle windowHandle) override; bool CaptureScreenshotWithPreview(const AZStd::string& outputFilePath) override; diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/__init__.py b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/__init__.py index af73f82b8d..d500d6e09c 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/__init__.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/__init__.py @@ -76,6 +76,7 @@ DCCSI_GDEBUG = env_bool('DCCSI_GDEBUG', False) DCCSI_DEV_MODE = env_bool('DCCSI_DEV_MODE', False) DCCSI_GDEBUGGER = env_bool('DCCSI_GDEBUGGER', False) DCCSI_LOGLEVEL = env_bool('DCCSI_LOGLEVEL', int(20)) +DCCSI_WING_VERSION_MAJOR = env_bool('DCCSI_WING_VERSION_MAJOR', '7') # ------------------------------------------------------------------------- @@ -162,6 +163,25 @@ _LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME})) # ------------------------------------------------------------------------- +def get_datadir() -> pathlib.Path: + """ + persistent application data. + # linux: ~/.local/share + # macOS: ~/Library/Application Support + # windows: C:/Users//AppData/Roaming + """ + + home = pathlib.Path.home() + + if sys.platform == "win32": + return home / "AppData/Roaming" + elif sys.platform == "linux": + return home / ".local/share" + elif sys.platform == "darwin": + return home / "Library/Application Support" +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- def makedirs(folder, *args, **kwargs): """a makedirs for py2.7 support""" diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/exr_to_3dl_azasset.py b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/exr_to_3dl_azasset.py index 9166ef5a44..6c2aa1d5bb 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/exr_to_3dl_azasset.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/exr_to_3dl_azasset.py @@ -27,18 +27,17 @@ import numpy as np # ------------------------------------------------------------------------ _MODULENAME = 'ColorGrading.exr_to_3dl_azasset' -import ColorGrading.initialize -ColorGrading.initialize.start() - _LOGGER = _logging.getLogger(_MODULENAME) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) -try: - import OpenImageIO as oiio - pass -except ImportError as e: - _LOGGER.error(f"invalid import: {e}") - sys.exit(1) +import ColorGrading.initialize +if ColorGrading.initialize.start(): + try: + import OpenImageIO as oiio + pass + except ImportError as e: + _LOGGER.error(f"invalid import: {e}") + sys.exit(1) # ------------------------------------------------------------------------ diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/from_3dl_to_azasset.py b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/from_3dl_to_azasset.py index e61ca33710..ba37994e63 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/from_3dl_to_azasset.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/from_3dl_to_azasset.py @@ -18,18 +18,17 @@ import logging as _logging # ------------------------------------------------------------------------ _MODULENAME = 'ColorGrading.from_3dl_to_azasset' -import ColorGrading.initialize -ColorGrading.initialize.start() - _LOGGER = _logging.getLogger(_MODULENAME) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) -try: - import OpenImageIO as oiio - pass -except ImportError as e: - _LOGGER.error(f"invalid import: {e}") - sys.exit(1) +import ColorGrading.initialize +if ColorGrading.initialize.start(): + try: + import OpenImageIO as oiio + pass + except ImportError as e: + _LOGGER.error(f"invalid import: {e}") + sys.exit(1) # ------------------------------------------------------------------------ diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py index 536c10ed05..ac64ade322 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py @@ -17,13 +17,10 @@ from pathlib import Path import logging as _logging # local imports -from ColorGrading import env_bool from ColorGrading import initialize_logger from ColorGrading import DCCSI_GDEBUG from ColorGrading import DCCSI_DEV_MODE -from ColorGrading import DCCSI_GDEBUGGER from ColorGrading import DCCSI_LOGLEVEL -from ColorGrading import FRMT_LOG_LONG __all__ = ['start'] @@ -44,15 +41,21 @@ _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # connect to the debugger if DCCSI_DEV_MODE: - APP_DATA_WING = Path('C:/Users/gallowj/AppData/Roaming/Wing Pro 7') - APP_DATA_WING.resolve() - site.addsitedir(pathlib.PureWindowsPath(APP_DATA_WING).as_posix()) - import wingdbstub as debugger - try: - debugger.Ensure() - _LOGGER.info("Wing debugger attached") - except Exception as e: - _LOGGER.debug('Can not attach Wing debugger (running in IDE already?)') + from ColorGrading import DCCSI_WING_VERSION_MAJOR + from ColorGrading import get_datadir + APPDATA = get_datadir() # os APPDATA + APPDATA_WING = Path(APPDATA, f"Wing Pro {DCCSI_WING_VERSION_MAJOR}").resolve() + if APPDATA_WING.exists(): + site.addsitedir(pathlib.PureWindowsPath(APPDATA_WING).as_posix()) + import wingdbstub as debugger + try: + debugger.Ensure() + _LOGGER.info("Wing debugger attached") + except Exception as e: + _LOGGER.debug('Can not attach Wing debugger (running in IDE already?)') + else: + _LOGGER.warning("Path envar doesn't exist: APPDATA_WING") + _LOGGER.info(f"Pattern: {APPDATA_WING}") # ------------------------------------------------------------------------ @@ -60,28 +63,16 @@ if DCCSI_DEV_MODE: def start(): """set up access to OpenImageIO, within o3de or without""" # ------------------------------------------------------------------------ + running_editor = None try: # running in o3de import azlmbr - - _O3DE_DEV = Path(os.getenv('O3DE_DEV', Path(azlmbr.paths.engroot))) - os.environ['O3DE_DEV'] = pathlib.PureWindowsPath(_O3DE_DEV).as_posix() - _LOGGER.debug(_O3DE_DEV) - - _O3DE_BIN_PATH = Path(str(_O3DE_DEV),Path(azlmbr.paths.executableFolder)) - - _O3DE_BIN = Path(os.getenv('O3DE_BIN', _O3DE_BIN_PATH.resolve())) - os.environ['O3DE_BIN'] = pathlib.PureWindowsPath(_O3DE_BIN).as_posix() - - _LOGGER.debug(_O3DE_BIN) - - site.addsitedir(_O3DE_BIN) + running_editor = True except Exception as e: # running external, start this module from: - # "C:\Depot\o3de-engine\Gems\Atom\Feature\Common\Tools\ColorGrading\cmdline\CMD_ColorGradinTools.bat" - pass - + # "C:\Depot\o3de-engine\Gems\Atom\Feature\Common\Tools\ColorGrading\cmdline\CMD_ColorGradingTools.bat" + try: _O3DE_DEV = Path(os.getenv('O3DE_DEV')) _O3DE_DEV = _O3DE_DEV.resolve() @@ -102,15 +93,32 @@ def start(): except EnvironmentError as e: _LOGGER.error('O3DE bin folder not set or found') raise e -# ------------------------------------------------------------------------ + + if running_editor: + _O3DE_DEV = Path(os.getenv('O3DE_DEV', Path(azlmbr.paths.engroot))) + os.environ['O3DE_DEV'] = pathlib.PureWindowsPath(_O3DE_DEV).as_posix() + _LOGGER.debug(_O3DE_DEV) + + _O3DE_BIN_PATH = Path(str(_O3DE_DEV),Path(azlmbr.paths.executableFolder)) + + _O3DE_BIN = Path(os.getenv('O3DE_BIN', _O3DE_BIN_PATH.resolve())) + os.environ['O3DE_BIN'] = pathlib.PureWindowsPath(_O3DE_BIN).as_posix() + + _LOGGER.debug(_O3DE_BIN) + + site.addsitedir(_O3DE_BIN) - -# ------------------------------------------------------------------------ -try: - import OpenImageIO as OpenImageIO -except ImportError as e: - _LOGGER.error(f"invalid import: {e}") - sys.exit(1) + # test access to oiio + if os.name == 'nt': + try: + import OpenImageIO as oiio + return True + except ImportError as e: + _LOGGER.error(f"invalid import: {e}") + pass + else: + _LOGGER.info("Non-Windows platforms not yet supported...") + return False # ------------------------------------------------------------------------ @@ -120,4 +128,5 @@ except ImportError as e: if __name__ == '__main__': """Run this file as main""" - start() \ No newline at end of file + oiio_exists = start() + _LOGGER.debug(f"Import OpenImageIO performed: {oiio_exists}") \ No newline at end of file diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/lut_compositor.py b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/lut_compositor.py index 74ba44dc27..75c21a31c4 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/lut_compositor.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/lut_compositor.py @@ -11,42 +11,23 @@ import sys import os -import site import argparse -import math -import pathlib -from pathlib import Path import logging as _logging -from env_bool import env_bool # ------------------------------------------------------------------------ _MODULENAME = 'ColorGrading.lut_compositor' -# set these true if you want them set globally for debugging -_DCCSI_GDEBUG = env_bool('DCCSI_GDEBUG', False) -_DCCSI_DEV_MODE = env_bool('DCCSI_DEV_MODE', False) -_DCCSI_GDEBUGGER = env_bool('DCCSI_GDEBUGGER', False) -_DCCSI_LOGLEVEL = env_bool('DCCSI_LOGLEVEL', int(20)) - -if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) - -FRMT_LOG_LONG = "[%(name)s][%(levelname)s] >> %(message)s (%(asctime)s; %(filename)s:%(lineno)d)" -_logging.basicConfig(level=_DCCSI_LOGLEVEL, - format=FRMT_LOG_LONG, - datefmt='%m-%d %H:%M') _LOGGER = _logging.getLogger(_MODULENAME) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) import ColorGrading.initialize -ColorGrading.initialize.start() - -try: - import OpenImageIO as oiio - pass -except ImportError as e: - _LOGGER.error(f"invalid import: {e}") - sys.exit(1) +if ColorGrading.initialize.start(): + try: + import OpenImageIO as oiio + pass + except ImportError as e: + _LOGGER.error(f"invalid import: {e}") + sys.exit(1) # ------------------------------------------------------------------------ operations = {"composite": 0, "extract": 1} @@ -62,49 +43,49 @@ args = parser.parse_args() op = operations.get(args.op, invalidOp) if op == invalidOp: - print("invalid operation") + _LOGGER.warning("invalid operation") sys.exit(1) elif op == 0: if args.l is None: - print("no LUT file specified") + _LOGGER.warning("no LUT file specified") sys.exit() # read in the input image -inBuf = oiio.ImageBuf(args.i) -inSpec = inBuf.spec() -print("Input resolution is ", inBuf.spec().width, " x ", inBuf.spec().height) +image_buffer = oiio.ImageBuf(args.i) +image_spec = image_buffer.spec() +_LOGGER.info("Input resolution is ", image_buffer.spec().width, " x ", image_buffer.spec().height) if op == 0: - outFileName = args.o - print("writing %s..." % (outFileName)) - lutBuf = oiio.ImageBuf(args.l) - lutSpec = lutBuf.spec() - print("Resolution is ", lutBuf.spec().width, " x ", lutBuf.spec().height) - if lutSpec.width != lutSpec.height*lutSpec.height: - print("invalid input file dimensions. Expect lengthwise LUT with dimension W: s*s X H: s, where s is the size of the LUT") + out_file_name = args.o + _LOGGER.info("writing %s..." % (out_file_name)) + lut_buffer = oiio.ImageBuf(args.l) + lut_spec = lut_buffer.spec() + _LOGGER.info("Resolution is ", lut_buffer.spec().width, " x ", lut_buffer.spec().height) + if lut_spec.width != lut_spec.height*lut_spec.height: + _LOGGER.warning("invalid input file dimensions. Expect lengthwise LUT with dimension W: s*s X H: s, where s is the size of the LUT") sys.exit(1) - lutSize = lutSpec.height - outSpec = oiio.ImageSpec(inSpec.width, inSpec.height, 3, oiio.TypeFloat) - outBuf = oiio.ImageBuf(outSpec) - outBuf.write(outFileName) - for y in range(outBuf.ybegin, outBuf.yend): - for x in range(outBuf.xbegin, outBuf.xend): - srcPx = inBuf.getpixel(x, y) - dstPx = (srcPx[0], srcPx[1], srcPx[2]) - if y < lutSpec.height and x < lutSpec.width: - lutPx = lutBuf.getpixel(x, y) - dstPx = (lutPx[0], lutPx[1], lutPx[2]) - outBuf.setpixel(x, y, dstPx) - outBuf.write(outFileName) + lut_size = lut_spec.height + out_image_spec = oiio.ImageSpec(image_spec.width, image_spec.height, 3, oiio.TypeFloat) + out_image_buffer = oiio.ImageBuf(out_image_spec) + out_image_buffer.write(out_file_name) + for y in range(out_image_buffer.ybegin, out_image_buffer.yend): + for x in range(out_image_buffer.xbegin, out_image_buffer.xend): + src_pixel = image_buffer.getpixel(x, y) + dst_pixel = (src_pixel[0], src_pixel[1], src_pixel[2]) + if y < lut_spec.height and x < lut_spec.width: + lut_pixel = lut_buffer.getpixel(x, y) + dst_pixel = (lut_pixel[0], lut_pixel[1], lut_pixel[2]) + out_image_buffer.setpixel(x, y, dst_pixel) + out_image_buffer.write(out_file_name) elif op == 1: - outFileName = args.o - print("writing %s..." % (outFileName)) - lutSize = args.s - lutSpec = oiio.ImageSpec(lutSize*lutSize, lutSize, 3, oiio.TypeFloat) - lutBuf = oiio.ImageBuf(lutSpec) - for y in range(lutBuf.ybegin, lutBuf.yend): - for x in range(lutBuf.xbegin, lutBuf.xend): - srcPx = inBuf.getpixel(x, y) - dstPx = (srcPx[0], srcPx[1], srcPx[2]) - lutBuf.setpixel(x, y, dstPx) - lutBuf.write(outFileName) \ No newline at end of file + out_file_name = args.o + _LOGGER.info("writing %s..." % (out_file_name)) + lut_size = args.s + lut_spec = oiio.ImageSpec(lut_size*lut_size, lut_size, 3, oiio.TypeFloat) + lut_buffer = oiio.ImageBuf(lut_spec) + for y in range(lut_buffer.ybegin, lut_buffer.yend): + for x in range(lut_buffer.xbegin, lut_buffer.xend): + src_pixel = image_buffer.getpixel(x, y) + dst_pixel = (src_pixel[0], src_pixel[1], src_pixel[2]) + lut_buffer.setpixel(x, y, dst_pixel) + lut_buffer.write(out_file_name) \ No newline at end of file diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/lut_helper.py b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/lut_helper.py index 459fe241fa..da774ffd1a 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/lut_helper.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/lut_helper.py @@ -23,18 +23,17 @@ from pathlib import Path # ------------------------------------------------------------------------ _MODULENAME = 'ColorGrading.lut_helper' -import ColorGrading.initialize -ColorGrading.initialize.start() - _LOGGER = _logging.getLogger(_MODULENAME) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) -try: - import OpenImageIO as oiio - pass -except ImportError as e: - _LOGGER.error(f"invalid import: {e}") - sys.exit(1) +import ColorGrading.initialize +if ColorGrading.initialize.start(): + try: + import OpenImageIO as oiio + pass + except ImportError as e: + _LOGGER.error(f"invalid import: {e}") + sys.exit(1) # ------------------------------------------------------------------------ diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/bootstrap.py b/Gems/Atom/Feature/Common/Editor/Scripts/bootstrap.py index 0070611592..90dfe6de8f 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/bootstrap.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/bootstrap.py @@ -13,48 +13,19 @@ Example: color grading related scripts """ # ------------------------------------------------------------------------ # standard imports -import sys import os import inspect -import pathlib import site from pathlib import Path -import logging as _logging # ------------------------------------------------------------------------ _MODULENAME = 'Gems.Atom.Feature.Common.bootstrap' -# print (inspect.getfile(inspect.currentframe()) # script filename (usually with path) # script directory _MODULE_PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) _MODULE_PATH = Path(_MODULE_PATH) site.addsitedir(_MODULE_PATH.resolve()) -from ColorGrading import env_bool from ColorGrading import initialize_logger -from ColorGrading import DCCSI_GDEBUG -from ColorGrading import DCCSI_DEV_MODE -from ColorGrading import DCCSI_LOGLEVEL - -if DCCSI_GDEBUG: - DCCSI_LOGLEVEL = int(10) - -_LOGGER = initialize_logger(_MODULENAME, log_to_file=False, default_log_level=DCCSI_LOGLEVEL) -_LOGGER.info('Initializing: {0}.'.format({_MODULENAME})) +_LOGGER = initialize_logger(_MODULENAME, log_to_file=False) _LOGGER.info(f'site.addsitedir({_MODULE_PATH.resolve()})') - -# early connect to the debugger -if DCCSI_DEV_MODE: - APP_DATA_WING = Path('C:/Users/gallowj/AppData/Roaming/Wing Pro 7') - APP_DATA_WING.resolve() - site.addsitedir(pathlib.PureWindowsPath(APP_DATA_WING).as_posix()) - import wingdbstub as debugger - try: - debugger.Ensure() - _LOGGER.info("Wing debugger attached") - except Exception as e: - _LOGGER.debug('Can not attach Wing debugger (running in IDE already?)') - - -from ColorGrading.initialize import start -start() # ------------------------------------------------------------------------ \ No newline at end of file diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Extreme_Grade/Nuke_Test_Extreme_Grade.nk~ b/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Extreme_Grade/Nuke_Test_Extreme_Grade.nk~ deleted file mode 100644 index a7c1f478b2..0000000000 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Extreme_Grade/Nuke_Test_Extreme_Grade.nk~ +++ /dev/null @@ -1,232 +0,0 @@ -#! C:/Program Files/Nuke13.0v3/nuke-13.0.3.dll -nx -version 13.0 v3 -define_window_layout_xml { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} -Root { - inputs 0 - name C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Extreme_Grade/Nuke_Test_Extreme_Grade.nk - project_directory "\"C:/Depot/o3de-engine/Gems/AtomLyIntegration/CommonFeatures/Tools/ColorGrading/TestData/Nuke/" - format "2048 1556 0 0 2048 1556 1 2K_Super_35(full-ap)" - proxy_type scale - proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)" - colorManagement OCIO - OCIO_config aces_1.0.3 - defaultViewerLUT "OCIO LUTs" - workingSpaceLUT scene_linear - monitorLut ACES/Rec.709 - monitorOutLUT "sRGB (ACES)" - int8Lut matte_paint - int16Lut texture_paint - logLut compositing_log - floatLut scene_linear -} -Read { - inputs 0 - file_type exr - file C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/LUTs/linear_32_LUT.exr - format "1024 32 0 0 1024 32 1 " - origset true - colorspace data - name Read_Linear_LUT_32 - xpos -846 - ypos 10 -} -set Ncf69800 [stack 0] -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer1 - xpos -847 - ypos 135 -} -push $Ncf69800 -OCIOFileTransform { - file C:/Depot/o3de-engine/Tools/ColorGrading/OpenColorIO-Configs/aces_1.0.3/luts/Log2_48_nits_Shaper_to_linear.spi1d - working_space scene_linear - name Log2_48_nits_Shaper_to_linear - xpos -710 - ypos 46 -} -set Ncf69000 [stack 0] -Transform { - center {1024 778} - name Transform_Position_LUT - xpos -579 - ypos 3 -} -set Ncf68c00 [stack 0] -Read { - inputs 0 - file_type exr - file C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/displaymapperpassthrough.exr - format "2802 1854 0 0 2802 1854 1 " - origset true - name Read_DisplayMapperPassthrough - xpos -577 - ypos -119 -} -ZMerge { - inputs 2 - name ZMerge_Combine - xpos -413 - ypos -83 -} -set Ncef7c00 [stack 0] -HueShift { - ingray 0.136 - outgray 0.31 - saturation 2 - color_saturation 0.3 - hue_rotation -150 - brightness 0.81 - name HueShift1 - xpos -256 - ypos -83 -} -set Ncef7800 [stack 0] -OCIOCDLTransform { - saturation 1.23 - working_space scene_linear - name INV_Log2_48_nits_Shaper_to_linear - xpos -86 - ypos -83 -} -set Ncef7400 [stack 0] -Crop { - box {0 0 1024 32} - reformat true - crop false - name Crop1 - xpos -86 - ypos 32 -} -set Ncef7000 [stack 0] -OCIOFileTransform { - file C:/Depot/o3de-engine/Tools/ColorGrading/OpenColorIO-Configs/aces_1.0.3/luts/Log2_48_nits_Shaper_to_linear.spi1d - direction inverse - working_space reference - name OCIOFileTransform2 - xpos 84 - ypos 32 -} -Write { - file C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Extreme_Grade/test-extreme-grade_inv-Log2-48nits_32_LUT.exr - colorspace data - raw true - file_type exr - write_ACES_compliant_EXR true - datatype "32 bit float" - first_part rgba - version 8 - name Write_RAW_LUT - xpos 242 - ypos 20 -} -Viewer { - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer7 - xpos 242 - ypos 135 -} -push $Ncef7400 -Write { - file C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/Shot_post_test-extreme-grade.exr - colorspace compositing_linear - file_type exr - write_ACES_compliant_EXR true - datatype "32 bit float" - first_part rgba - version 7 - name Write_Shot_Grade_Comp - xpos 353 - ypos -95 -} -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer8 - xpos 357 - ypos 135 -} -push $Ncf69000 -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer2 - xpos -710 - ypos 137 -} -push $Ncf68c00 -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer3 - xpos -579 - ypos 135 -} -push $Ncef7c00 -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer4 - xpos -413 - ypos 133 -} -push $Ncef7800 -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer5 - xpos -254 - ypos 133 -} -push $Ncef7000 -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer6 - xpos -86 - ypos 134 -} diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Extreme_Grade/Shot_post_test-extreme-grade.exr b/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Extreme_Grade/Shot_post_test-extreme-grade.exr deleted file mode 100644 index f9235dac3a..0000000000 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Extreme_Grade/Shot_post_test-extreme-grade.exr +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7ea4288b55725bfa89d7add69ea45b0ac9315cfffd6acfba66082f4d21c1ac1a -size 31227624 diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/Shot_post_test-grade.exr b/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/Shot_post_test-grade.exr deleted file mode 100644 index 49e0460826..0000000000 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/Shot_post_test-grade.exr +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9ff499c054a259a3cd389b613382066f258287215f61da56115b3e958733dbe6 -size 31227639 diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/Test-Grade.nk~ b/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/Test-Grade.nk~ deleted file mode 100644 index 084ba1495d..0000000000 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/Test-Grade.nk~ +++ /dev/null @@ -1,227 +0,0 @@ -#! C:/Program Files/Nuke13.0v3/nuke-13.0.3.dll -nx -version 13.0 v3 -define_window_layout_xml { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} -Root { - inputs 0 - name C:/Depot/o3de/Gems/Atom/Feature/Common/Assets/ColorGrading/TestData/Nuke/HDR/Test_Grade/Test-Grade.nk - project_directory "\"C:/Depot/o3de-engine/Gems/AtomLyIntegration/CommonFeatures/Tools/ColorGrading/TestData/Nuke/" - format "2048 1556 0 0 2048 1556 1 2K_Super_35(full-ap)" - proxy_type scale - proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)" - colorManagement OCIO - OCIO_config aces_1.0.3 - defaultViewerLUT "OCIO LUTs" - workingSpaceLUT scene_linear - monitorLut ACES/Rec.709 - monitorOutLUT "sRGB (ACES)" - int8Lut matte_paint - int16Lut texture_paint - logLut compositing_log - floatLut scene_linear -} -Read { - inputs 0 - file_type exr - file C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/LUTs/linear_32_LUT.exr - format "1024 32 0 0 1024 32 1 " - origset true - colorspace data - raw true - name Read_Linear_LUT_32 - xpos -846 - ypos 10 -} -set N3bfa9800 [stack 0] -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer1 - xpos -846 - ypos 135 -} -push $N3bfa9800 -OCIOFileTransform { - file C:/Depot/o3de-engine/Tools/ColorGrading/OpenColorIO-Configs/aces_1.0.3/luts/Log2_48_nits_Shaper_to_linear.spi1d - working_space rendering - name Log2_48_nits_Shaper_to_linear - xpos -710 - ypos 46 -} -set N3bfa9000 [stack 0] -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer2 - xpos -710 - ypos 137 -} -push $N3bfa9000 -Transform { - center {1024 778} - name Transform_Position_LUT - xpos -579 - ypos 3 -} -set N3bfa8c00 [stack 0] -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer3 - xpos -579 - ypos 135 -} -push $N3bfa8c00 -Read { - inputs 0 - file_type exr - file C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/displaymapperpassthrough.exr - format "2802 1854 0 0 2802 1854 1 " - origset true - name Read_DisplayMapperPassthrough - xpos -580 - ypos -146 -} -ZMerge { - inputs 2 - name ZMerge_Combine - xpos -413 - ypos -83 -} -set N3bf5bc00 [stack 0] -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer4 - xpos -413 - ypos 128 -} -push $N3bf5bc00 -HueShift { - ingray {0.18 0.18 0.18} - outgray {0.18 0.18 0.18} - saturation 1.26 - color {0.12 0.12 0.12} - color_saturation 0.78 - hue_rotation -150 - brightness 0.74 - name HueShift1 - xpos -256 - ypos -83 -} -set N3bf5b800 [stack 0] -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer5 - xpos -256 - ypos 130 -} -push $N3bf5b800 -Crop { - box {0 0 1024 32} - reformat true - crop false - name Crop1 - xpos -86 - ypos 32 -} -set N3bf5ac00 [stack 0] -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer6 - xpos -86 - ypos 134 -} -push $N3bf5b800 -Write { - file C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/Nuke_Shot_post_grade.exr - colorspace compositing_linear - file_type exr - write_ACES_compliant_EXR true - datatype "32 bit float" - first_part rgba - version 10 - name Write_Shot_Grade_Comp - selected true - xpos 353 - ypos -95 -} -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer8 - xpos 353 - ypos 135 -} -push $N3bf5ac00 -OCIOFileTransform { - file C:/Depot/o3de-engine/Tools/ColorGrading/OpenColorIO-Configs/aces_1.0.3/luts/Log2_48_nits_Shaper_to_linear.spi1d - direction inverse - working_space data - name invLog2_48_nits_Shaper_to_linear - xpos 74 - ypos -14 -} -Write { - file C:/Depot/o3de/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Nuke/HDR/Test_Grade/test-grade_inv-Log2-48nits_32_LUT.exr - colorspace data - file_type exr - datatype "32 bit float" - first_part rgba - version 10 - name Write_RAW_LUT - xpos 242 - ypos 20 -} -Viewer { - frame 1 - frame_range 1-100 - viewerProcess "sRGB (ACES)" - name Viewer7 - xpos 242 - ypos 135 -} diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Photoshop/Log2-48nits/CLT_grade.psd b/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Photoshop/Log2-48nits/CLT_grade.psd deleted file mode 100644 index 3718e0facf..0000000000 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Photoshop/Log2-48nits/CLT_grade.psd +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c0276e1d329cda3514f46a55fd1d3ce90fce617814198ab69d234f2c58c15882 -size 98742272 diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Photoshop/Log2-48nits/LUT_layer_composite_hue-sat_grade.psd b/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Photoshop/Log2-48nits/LUT_layer_composite_hue-sat_grade.psd deleted file mode 100644 index 82eca8b3cc..0000000000 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/Resources/TestData/Photoshop/Log2-48nits/LUT_layer_composite_hue-sat_grade.psd +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ce91088eaa54afab608bfcea6ab4009cbb3027cb83c76710a46470144e7d799d -size 98638424 diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/CMD_ColorGradingTools.bat b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/CMD_ColorGradingTools.bat index 2c5809ec15..c655eb2e6c 100644 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/CMD_ColorGradingTools.bat +++ b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/CMD_ColorGradingTools.bat @@ -24,7 +24,7 @@ PUSHD %~dp0 SETLOCAL ENABLEDELAYEDEXPANSION :: if the user has set up a custom env call it -IF EXIST "%~dp0User_env.bat" CALL %~dp0User_env.bat +IF EXIST "%~dp0User_Env.bat" CALL %~dp0User_Env.bat :: Initialize env CALL %~dp0\Env_Core.bat diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Env_Python.bat b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Env_Python.bat index 83b7382dc6..fc4afc964e 100644 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Env_Python.bat +++ b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Env_Python.bat @@ -20,8 +20,6 @@ PUSHD %~dp0 CALL %~dp0\Env_Core.bat -::SETLOCAL ENABLEDELAYEDEXPANSION - echo. echo _____________________________________________________________________ echo. @@ -67,11 +65,14 @@ echo DCCSI_PY_BASE = %DCCSI_PY_BASE% :: ide and debugger plug set DCCSI_PY_DEFAULT=%DCCSI_PY_BASE% -set DCCSI_PY_IDE=%DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev1-windows\python +IF "%DCCSI_PY_REV%"=="" (set DCCSI_PY_REV=rev2) +IF "%DCCSI_PY_PLATFORM%"=="" (set DCCSI_PY_PLATFORM=windows) + +set DCCSI_PY_IDE=%DCCSI_PYTHON_INSTALL%\runtime\python-%DCCSI_PY_VERSION_MAJOR%.%DCCSI_PY_VERSION_MINOR%.%DCCSI_PY_VERSION_RELEASE%-%DCCSI_PY_REV%-%DCCSI_PY_PLATFORM%\python echo DCCSI_PY_IDE = %DCCSI_PY_IDE% :: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_EXE=%DCCSI_PYTHON_INSTALL%\runtime\python-3.7.10-rev1-windows\python\python.exe +set DCCSI_PY_EXE=%DCCSI_PY_IDE%\python.exe echo DCCSI_PY_EXE = %DCCSI_PY_EXE% set DCCSI_PY_IDE_PACKAGES=%DCCSI_PY_IDE%\Lib\site-packages @@ -90,7 +91,10 @@ SET PATH=%DCCSI_PYTHON_INSTALL%;%DCCSI_PY_IDE%;%DCCSI_PY_IDE_PACKAGES%;%DCCSI_PY set PYTHONPATH=%DCCSIG_PATH%;%DCCSI_PYTHON_LIB_PATH%;%O3DE_BIN_PATH%;%DCCSI_COLORGRADING_SCRIPTS%;%DCCSI_FEATURECOMMON_SCRIPTS%;%PYTHONPATH% echo PYTHONPATH = %PYTHONPATH% -::ENDLOCAL +:: used for debugging in WingIDE (but needs to be here) +IF "%TAG_USERNAME%"=="" (set TAG_USERNAME=NOT_SET) +echo TAG_USERNAME = %TAG_USERNAME% +IF "%TAG_USERNAME%"=="NOT_SET" (echo Add TAG_USERNAME to User_Env.bat) :: Set flag so we don't initialize dccsi environment twice SET O3DE_ENV_PY_INIT=1 diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Env_WingIDE.bat b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Env_WingIDE.bat index 4c297f53a9..29982db4f1 100644 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Env_WingIDE.bat +++ b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Env_WingIDE.bat @@ -38,8 +38,6 @@ set DCCSI_PY_DEFAULT=%DCCSI_PY_IDE%\python.exe set WINGHOME=%PROGRAMFILES(X86)%\Wing Pro %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% IF "%WING_PROJ%"=="" (set WING_PROJ=%O3DE_PROJECT_PATH%\.solutions\.wing\o3de_color_grading_%DCCSI_WING_VERSION_MAJOR%x.wpr) -::SETLOCAL ENABLEDELAYEDEXPANSION - echo. echo _____________________________________________________________________ echo. @@ -55,8 +53,6 @@ echo WING_PROJ = %WING_PROJ% :: add to the PATH SET PATH=%WINGHOME%;%PATH% -::ENDLOCAL - :: Set flag so we don't initialize dccsi environment twice SET DCCSI_ENV_WINGIDE_INIT=1 GOTO END_OF_FILE diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Launch_WingIDE-7-1.bat b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Launch_WingIDE-7-1.bat index 93f5fb7fa6..15d31b2074 100644 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Launch_WingIDE-7-1.bat +++ b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/Launch_WingIDE-7-1.bat @@ -73,9 +73,6 @@ echo DCCSI_PY_BASE = %DCCSI_PY_BASE% set DCCSI_PY_DEFAULT=%DCCSI_PY_BASE% echo DCCSI_PY_DEFAULT = %DCCSI_PY_DEFAULT% -:: if the user has set up a custom env call it -IF EXIST "%~dp0User_Dev.bat" CALL %~dp0User_Dev.bat - echo. :: Change to root dir diff --git a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/User_Env.bat.template b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/User_Env.bat.template index 558505f80f..81a53393cf 100644 --- a/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/User_Env.bat.template +++ b/Gems/Atom/Feature/Common/Tools/ColorGrading/cmdline/User_Env.bat.template @@ -19,17 +19,16 @@ IF "%O3DE_USER_ENV_INIT%"=="1" GOTO :END_OF_FILE cd %~dp0 PUSHD %~dp0 -SETLOCAL ENABLEDELAYEDEXPANSION - SET O3DE_DEV=C:\Depot\o3de-engine ::SET OCIO_APPS=C:\Depot\o3de-engine\Tools\ColorGrading\ocio\build\src\apps SET TAG_LY_BUILD_PATH=build SET DCCSI_GDEBUG=True SET DCCSI_DEV_MODE=True -SET WING_PROJ=%O3DE_PROJECT_PATH%\.solutions\.wing\o3de_color_grading_%DCCSI_WING_VERSION_MAJOR%x.wpr - -::ENDLOCAL +:: set the your user name here for windows path +SET TAG_USERNAME=< not set > +SET DCCSI_PY_REV=rev1 +SET DCCSI_PY_PLATFORM=windows :: Set flag so we don't initialize dccsi environment twice SET O3DE_USER_ENV_INIT=1 diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h index b0c8642d68..443ab3e73a 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/Gems/Atom/RHI/Null/Code/Source/RHI/Fence.cpp b/Gems/Atom/RHI/Null/Code/Source/RHI/Fence.cpp new file mode 100644 index 0000000000..dc3743c101 --- /dev/null +++ b/Gems/Atom/RHI/Null/Code/Source/RHI/Fence.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#include + + +namespace AZ +{ + namespace Null + { + RHI::Ptr Fence::Create() + { + return aznew Fence(); + } + } +} diff --git a/Gems/Atom/RHI/Null/Code/Source/RHI/Fence.h b/Gems/Atom/RHI/Null/Code/Source/RHI/Fence.h new file mode 100644 index 0000000000..fb64727362 --- /dev/null +++ b/Gems/Atom/RHI/Null/Code/Source/RHI/Fence.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#pragma once + +#include + +namespace AZ +{ + namespace Null + { + class Fence + : public RHI::Fence + { + using Base = RHI::Fence; + public: + AZ_RTTI(Fence, "{34908F40-A7DE-4EE8-A871-71ACE0C24972}", Base); + AZ_CLASS_ALLOCATOR(Fence, AZ::SystemAllocator, 0); + + static RHI::Ptr Create(); + + private: + Fence() = default; + + ////////////////////////////////////////////////////////////////////////// + // RHI::Fence + RHI::ResultCode InitInternal([[maybe_unused]] RHI::Device& device, [[maybe_unused]] RHI::FenceState initialState) override { return RHI::ResultCode::Success;} + void ShutdownInternal() override {} + void SignalOnCpuInternal() override {} + void WaitOnCpuInternal() const override {} + void ResetInternal() override {} + RHI::FenceState GetFenceStateInternal() const override { return RHI::FenceState::Signaled;}; + ////////////////////////////////////////////////////////////////////////// + }; + } +} diff --git a/Gems/Atom/RHI/Null/Code/Source/RHI/SystemComponent.cpp b/Gems/Atom/RHI/Null/Code/Source/RHI/SystemComponent.cpp index d72de7996e..091084b097 100644 --- a/Gems/Atom/RHI/Null/Code/Source/RHI/SystemComponent.cpp +++ b/Gems/Atom/RHI/Null/Code/Source/RHI/SystemComponent.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -99,7 +100,7 @@ namespace AZ RHI::Ptr SystemComponent::CreateFence() { - return nullptr; + return Fence::Create(); } RHI::Ptr SystemComponent::CreateBuffer() diff --git a/Gems/Atom/RHI/Null/Code/atom_rhi_null_private_common_files.cmake b/Gems/Atom/RHI/Null/Code/atom_rhi_null_private_common_files.cmake index 13e16be77b..ad57002dd3 100644 --- a/Gems/Atom/RHI/Null/Code/atom_rhi_null_private_common_files.cmake +++ b/Gems/Atom/RHI/Null/Code/atom_rhi_null_private_common_files.cmake @@ -21,6 +21,8 @@ set(FILES Source/RHI/CommandQueue.h Source/RHI/Device.cpp Source/RHI/Device.h + Source/RHI/Fence.cpp + Source/RHI/Fence.h Source/RHI/FrameGraphCompiler.cpp Source/RHI/FrameGraphCompiler.h Source/RHI/FrameGraphExecuter.cpp diff --git a/Gems/Atom/RHI/Vulkan/Code/Include/Platform/Android/Atom_RHI_Vulkan_Android.h b/Gems/Atom/RHI/Vulkan/Code/Include/Platform/Android/Atom_RHI_Vulkan_Android.h index 9289423b37..b8e83ab8a3 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Include/Platform/Android/Atom_RHI_Vulkan_Android.h +++ b/Gems/Atom/RHI/Vulkan/Code/Include/Platform/Android/Atom_RHI_Vulkan_Android.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/AttachmentReadback.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/AttachmentReadback.cpp index 319cf85fe5..146c37fe1b 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/AttachmentReadback.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/AttachmentReadback.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -175,6 +176,11 @@ namespace AZ bool AttachmentReadback::ReadPassAttachment(const PassAttachment* attachment, const AZ::Name& readbackName) { + if (AZ::RHI::IsNullRenderer()) + { + return false; + } + if (!IsReady()) { AZ_Assert(false, "AttachmentReadback is not ready to readback an attachment"); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/CMakeLists.txt b/Gems/Atom/Tools/MaterialEditor/Code/CMakeLists.txt index c83ca2bb19..6230217ac2 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/CMakeLists.txt +++ b/Gems/Atom/Tools/MaterialEditor/Code/CMakeLists.txt @@ -133,6 +133,9 @@ ly_add_target_dependencies( DEPENDENCIES_FILES tool_dependencies.cmake Source/Platform/${PAL_PLATFORM_NAME}/tool_dependencies_${PAL_PLATFORM_NAME_LOWERCASE}.cmake + # The Material Editor needs the LyShine "Tools" gem variant for the custom LyShine pass + DEPENDENT_TARGETS + Gem::LyShine.Tools ) # Inject the project path into the MaterialEditor VS debugger command arguments if the build system being invoked diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/CMakeLists.txt b/Gems/AtomLyIntegration/CommonFeatures/Code/CMakeLists.txt index 804a53ebed..df5ab134fa 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/CMakeLists.txt +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/CMakeLists.txt @@ -123,27 +123,10 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS) Gem::AtomLyIntegration_CommonFeatures.Editor Gem::GradientSignal.Tools ) - - # AtomLyIntergration_CommonFeatures gem targets are required as part of the Editor and AssetProcessor - # due to the AZ::Render::EditorDirectionalLightComponent, AZ::Render::EditorMeshComponent, - # AZ::Render::EditorGridComponent, AZ::Render::EditorHDRiSkyboxComponent, - # AZ::Render::EditorImageBasedLightComponent being saved as part of the DefaultLevel.prefab - ly_enable_gems(GEMS AtomLyIntegration_CommonFeatures VARIANTS Tools - TARGETS Editor) - ly_enable_gems(GEMS AtomLyIntegration_CommonFeatures VARIANTS Builders - TARGETS AssetBuilder AssetProcessor AssetProcessorBatch) endif() - -# Added dependencies to the Client and Server Launchers -get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME) -foreach(project_name IN LISTS LY_PROJECTS_TARGET_NAME) - # Add gem as a dependency of the Clients Launcher - ly_enable_gems(PROJECT_NAME ${project_name} GEMS AtomLyIntegration_CommonFeatures VARIANTS Clients - TARGETS ${project_name}.GameLauncher) - # Add gem as a dependency of the Servers Launcher - if(PAL_TRAIT_BUILD_SERVER_SUPPORTED) - ly_enable_gems(PROJECT_NAME ${project_name} GEMS AtomLyIntegration_CommonFeatures VARIANTS Servers - TARGETS ${project_name}.ServerLauncher) - endif() -endforeach() +# AtomLyIntegration_CommonFeatures gem targets are required as part of the Editor and AssetProcessor +# due to the AZ::Render::EditorDirectionalLightComponent, AZ::Render::EditorMeshComponent, +# AZ::Render::EditorGridComponent, AZ::Render::EditorHDRiSkyboxComponent, +# AZ::Render::EditorImageBasedLightComponent being saved as part of the DefaultLevel.prefab +ly_enable_gems(GEMS AtomLyIntegration_CommonFeatures) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index ade4beaa33..9e0c285001 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -578,15 +578,14 @@ namespace AZ { if (m_meshHandle.IsValid() && m_meshFeatureProcessor) { - Aabb aabb = m_meshFeatureProcessor->GetLocalAabb(m_meshHandle); + if (Aabb aabb = m_meshFeatureProcessor->GetLocalAabb(m_meshHandle); aabb.IsValid()) + { + aabb.MultiplyByScale(m_cachedNonUniformScale); + return aabb; + } + } - aabb.MultiplyByScale(m_cachedNonUniformScale); - return aabb; - } - else - { - return Aabb::CreateNull(); - } + return Aabb::CreateNull(); } AzFramework::RenderGeometry::RayResult MeshComponentController::RenderGeometryIntersect( diff --git a/Gems/Blast/Code/Source/Family/DamageManager.h b/Gems/Blast/Code/Source/Family/DamageManager.h index af7bae096b..f56bd7bbdf 100644 --- a/Gems/Blast/Code/Source/Family/DamageManager.h +++ b/Gems/Blast/Code/Source/Family/DamageManager.h @@ -9,6 +9,7 @@ #include #include +#include namespace Blast { diff --git a/Gems/Camera/Code/CMakeLists.txt b/Gems/Camera/Code/CMakeLists.txt index deb123824f..3fbeec0908 100644 --- a/Gems/Camera/Code/CMakeLists.txt +++ b/Gems/Camera/Code/CMakeLists.txt @@ -66,22 +66,7 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) # tools and builders use the above module. ly_create_alias(NAME Camera.Tools NAMESPACE Gem TARGETS Gem::Camera.Editor) ly_create_alias(NAME Camera.Builders NAMESPACE Gem TARGETS Gem::Camera.Editor) - - # The DefaultPrefab contains an EditorCameraComponent which makes this gem required - ly_enable_gems(GEMS Camera VARIANTS Tools TARGETS Editor) - ly_enable_gems(GEMS Camera VARIANTS Builders TARGETS AssetBuilder AssetProcessor AssetProcessorBatch) endif() - -# Added dependencies to the Client and Server Launchers -get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME) -foreach(project_name IN LISTS LY_PROJECTS_TARGET_NAME) - # Add gem as a dependency of the Clients Launcher - ly_enable_gems(PROJECT_NAME ${project_name} GEMS Camera VARIANTS Clients - TARGETS ${project_name}.GameLauncher) - # Add gem as a dependency of the Servers Launcher - if(PAL_TRAIT_BUILD_SERVER_SUPPORTED) - ly_enable_gems(PROJECT_NAME ${project_name} GEMS Camera VARIANTS Servers - TARGETS ${project_name}.ServerLauncher) - endif() -endforeach() +# The DefaultPrefab contains an EditorCameraComponent which makes this gem required +ly_enable_gems(GEMS Camera) diff --git a/Gems/InAppPurchases/Code/Source/Platform/Android/InAppPurchasesAndroid.cpp b/Gems/InAppPurchases/Code/Source/Platform/Android/InAppPurchasesAndroid.cpp index 5c8195235b..bd13e91dc6 100644 --- a/Gems/InAppPurchases/Code/Source/Platform/Android/InAppPurchasesAndroid.cpp +++ b/Gems/InAppPurchases/Code/Source/Platform/Android/InAppPurchasesAndroid.cpp @@ -250,7 +250,7 @@ namespace InAppPurchases document.Parse(fileBuffer.data()); if (document.HasParseError()) { - const char* errorStr = rapidjson::GetParseError_En(document.GetParseError()); + [[maybe_unused]] const char* errorStr = rapidjson::GetParseError_En(document.GetParseError()); AZ_TracePrintf("LumberyardInAppBilling", "Failed to parse product_ids.json: %s\n", errorStr); return; } diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewCurveEditor.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewCurveEditor.cpp index 51209c7f02..d677acea02 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewCurveEditor.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewCurveEditor.cpp @@ -8,7 +8,7 @@ #include "EditorDefs.h" -#include "Resource.h" +#include "Editor/Resource.h" #include "UiEditorAnimationBus.h" #include "UiAnimViewCurveEditor.h" diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDialog.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDialog.cpp index a9f76cd443..e6c2dda74c 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDialog.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDialog.cpp @@ -15,7 +15,7 @@ // ----- End UI_ANIMATION_REVISIT #include "EditorDefs.h" -#include "Resource.h" +#include "Editor/Resource.h" #include "UiAnimViewDialog.h" diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp index 8672f539bf..9f67503b73 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp @@ -8,7 +8,7 @@ #include "EditorDefs.h" -#include "Resource.h" +#include "Editor/Resource.h" #include "UiEditorAnimationBus.h" #include "UiAnimViewDopeSheetBase.h" diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp index 472100b334..a3aa330dca 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp @@ -8,7 +8,7 @@ #include "EditorDefs.h" -#include "Resource.h" +#include "Editor/Resource.h" #include "UiEditorAnimationBus.h" #include "UiAnimViewNodes.h" #include "UiAnimViewDopeSheetBase.h" diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSplineCtrl.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSplineCtrl.cpp index e071a3e631..61610e3c8e 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSplineCtrl.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSplineCtrl.cpp @@ -9,7 +9,7 @@ #include "UiEditorAnimationBus.h" #include "EditorDefs.h" -#include "Resource.h" +#include "Editor/Resource.h" #include "UiAnimViewSequenceManager.h" #include "UiAnimViewSplineCtrl.h" #include "UiAnimViewSequence.h" diff --git a/Gems/Maestro/Code/CMakeLists.txt b/Gems/Maestro/Code/CMakeLists.txt index 56d1f2f3c4..2ae737acc7 100644 --- a/Gems/Maestro/Code/CMakeLists.txt +++ b/Gems/Maestro/Code/CMakeLists.txt @@ -75,23 +75,10 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) ly_create_alias(NAME Maestro.Tools NAMESPACE Gem TARGETS Gem::Maestro.Editor) ly_create_alias(NAME Maestro.Builders NAMESPACE Gem TARGETS Gem::Maestro.Editor) - # Maestro is still used by the CrySystem Level System and SystemInit and TrackView - # It is required by the GameLauncher, ServerLauncher and Editor applications - ly_enable_gems(GEMS Maestro VARIANTS Tools TARGETS Editor) - endif() -# Loop over each Project name to allow the ${ProjectName}.GameLauncher and ${ProjectName}.ServerLauncher -# target to add the gem the Clients and Servers variant -get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME) -foreach(project_name IN LISTS LY_PROJECTS_TARGET_NAME) - # Add gem as a dependency of the Clients Launcher - ly_enable_gems(PROJECT_NAME ${project_name} GEMS Maestro VARIANTS Clients TARGETS ${project_name}.GameLauncher) - # Add gem as a dependency of the Servers Launcher - if(PAL_TRAIT_BUILD_SERVER_SUPPORTED) - ly_enable_gems(PROJECT_NAME ${project_name} GEMS Maestro VARIANTS Servers TARGETS ${project_name}.ServerLauncher) - endif() -endforeach() +# Maestro is still used by the CrySystem Level System, CSystem::SystemInit and TrackView +ly_enable_gems(GEMS Maestro) ################################################################################ diff --git a/Gems/Microphone/Code/Include/Microphone/WAVUtil.h b/Gems/Microphone/Code/Include/Microphone/WAVUtil.h index 71c1ec13d1..9fdcc95a97 100644 --- a/Gems/Microphone/Code/Include/Microphone/WAVUtil.h +++ b/Gems/Microphone/Code/Include/Microphone/WAVUtil.h @@ -89,7 +89,7 @@ namespace Audio AZ::IO::FileIOStream fileStream(filePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary); if (fileStream.IsOpen()) { - auto bytesWritten = fileStream.Write(m_bufferSize, m_buffer); + [[maybe_unused]] auto bytesWritten = fileStream.Write(m_bufferSize, m_buffer); AZ_TracePrintf("WAVUtil", "Wrote WAV file: %s, %d bytes\n", filePath.c_str(), bytesWritten); return true; } diff --git a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp index c337ab0a85..4aa240eaae 100644 --- a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp +++ b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp @@ -796,7 +796,7 @@ namespace PhysX entityRigidbody->GetRigidBody()->IsKinematic() == false) { AZStd::string assetPath = m_shapeConfiguration.m_physicsAsset.m_configuration.m_asset.GetHint().c_str(); - const uint lastSlash = static_cast(assetPath.rfind('/')); + const size_t lastSlash = assetPath.rfind('/'); if (lastSlash != AZStd::string::npos) { assetPath = assetPath.substr(lastSlash + 1); diff --git a/Gems/PhysX/Code/Tests/PhysXJointsTest.cpp b/Gems/PhysX/Code/Tests/PhysXJointsTest.cpp index ac5a99e29a..3a7eac0884 100644 --- a/Gems/PhysX/Code/Tests/PhysXJointsTest.cpp +++ b/Gems/PhysX/Code/Tests/PhysXJointsTest.cpp @@ -329,23 +329,23 @@ namespace PhysX if (auto* sceneInterface = AZ::Interface::Get()) { - jointHandle = sceneInterface->AddJoint(m_testSceneHandle, &jointConfiguration, m_parentBodyHandle, m_childBodyHandle); + jointHandle = sceneInterface->AddJoint(this->m_testSceneHandle, &jointConfiguration, this->m_parentBodyHandle, this->m_childBodyHandle); } EXPECT_NE(jointHandle, AzPhysics::InvalidJointHandle); // run physics to trigger the the move of parent body - TestUtils::UpdateScene(m_testSceneHandle, AzPhysics::SystemConfiguration::DefaultFixedTimestep, 1); + TestUtils::UpdateScene(this->m_testSceneHandle, AzPhysics::SystemConfiguration::DefaultFixedTimestep, 1); AZ::Vector3 childCurrentPos; if (auto* sceneInterface = AZ::Interface::Get()) { - auto* childBody = sceneInterface->GetSimulatedBodyFromHandle(m_testSceneHandle, m_childBodyHandle); + auto* childBody = sceneInterface->GetSimulatedBodyFromHandle(this->m_testSceneHandle, this->m_childBodyHandle); childCurrentPos = childBody->GetPosition(); } - EXPECT_GT(childCurrentPos.GetX(), m_childInitialPos.GetX()); + EXPECT_GT(childCurrentPos.GetX(), this->m_childInitialPos.GetX()); } #endif // ENABLE_JOINTS_TYPED_TEST_CASE } diff --git a/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp b/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp index 7baaa34ab5..a4db2e9f0e 100644 --- a/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp +++ b/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp @@ -171,7 +171,7 @@ namespace PhysX //invalid simulated body handle returns null nullBody = sceneInterface->GetSimulatedBodyFromHandle(AzPhysics::InvalidSceneHandle, AzPhysics::InvalidSimulatedBodyHandle); EXPECT_TRUE(nullBody == nullptr); - nullBody = sceneInterface->GetSimulatedBodyFromHandle(m_testSceneHandle, AzPhysics::SimulatedBodyHandle(2347892348, 9)); + nullBody = sceneInterface->GetSimulatedBodyFromHandle(m_testSceneHandle, AzPhysics::SimulatedBodyHandle(1347892348, 9)); EXPECT_TRUE(nullBody == nullptr); //get 1 simulated body, should not be null. diff --git a/Gems/Prefab/PrefabBuilder/CMakeLists.txt b/Gems/Prefab/PrefabBuilder/CMakeLists.txt index c4c57155ab..450b8d0408 100644 --- a/Gems/Prefab/PrefabBuilder/CMakeLists.txt +++ b/Gems/Prefab/PrefabBuilder/CMakeLists.txt @@ -23,7 +23,7 @@ ly_add_target( ) ly_add_target( - NAME PrefabBuilder GEM_MODULE + NAME PrefabBuilder.Builders GEM_MODULE NAMESPACE Gem INCLUDE_DIRECTORIES PRIVATE @@ -36,15 +36,9 @@ ly_add_target( ) # the prefab builder only needs to be active in builders -# use the PrefabBuilder module in Clients and Servers: -ly_create_alias(NAME PrefabBuilder.Builders NAMESPACE Gem TARGETS Gem::PrefabBuilder) # we automatically add this gem, if it is present, to all our known set of builder applications: -ly_enable_gems(GEMS PrefabBuilder VARIANTS Builders TARGETS AssetProcessor AssetProcessorBatch AssetBuilder) - -# if you have a custom builder application in your project, then use ly_enable_gems() to -# add it to that application for your project, like this to make YOUR_TARGET_NAME load it automatically -# ly_enable_gems(PROJECT_NAME (YOUR_PROJECT_NAME) GEMS PrefabBuilder VARIANTS Builders TARGETS (YOUR_TARGET_NAME) ) +ly_enable_gems(GEMS PrefabBuilder) if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) ly_add_target( diff --git a/Gems/SceneProcessing/Code/CMakeLists.txt b/Gems/SceneProcessing/Code/CMakeLists.txt index 6602c1d7d6..667103b4a7 100644 --- a/Gems/SceneProcessing/Code/CMakeLists.txt +++ b/Gems/SceneProcessing/Code/CMakeLists.txt @@ -68,14 +68,10 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) ly_create_alias(NAME SceneProcessing.Builders NAMESPACE Gem TARGETS Gem::SceneProcessing.Editor) ly_create_alias(NAME SceneProcessing.Tools NAMESPACE Gem TARGETS Gem::SceneProcessing.Editor) -# SceneProcessing Gem is only used in Tools and builders and is a requirement for the Editor -ly_enable_gems(GEMS SceneProcessing VARIANTS Tools - TARGETS Editor) -ly_enable_gems(GEMS SceneProcessing VARIANTS Builders - TARGETS AssetBuilder AssetProcessor AssetProcessorBatch) + # SceneProcessing Gem is only used in Tools and builders and is a requirement for the Editor and AssetProcessor + ly_enable_gems(GEMS SceneProcessing) endif() - ################################################################################ # Tests ################################################################################ diff --git a/Gems/ScriptCanvas/Code/CMakeLists.txt b/Gems/ScriptCanvas/Code/CMakeLists.txt index 57d7a4a476..c126d343ed 100644 --- a/Gems/ScriptCanvas/Code/CMakeLists.txt +++ b/Gems/ScriptCanvas/Code/CMakeLists.txt @@ -47,8 +47,7 @@ ly_add_target( ) # the script canvas debugger is an optional gem module -# To Enable it: ly_enable_gems( ... TARGETS xxxyyzzz GEMS ScriptCanvasDebugger ...) -# in any particular target. +# To Enable it, associate it with a project ly_create_alias(NAME ScriptCanvasDebugger.Builders NAMESPACE Gem TARGETS Gem::ScriptCanvasDebugger) ly_create_alias(NAME ScriptCanvasDebugger.Tools NAMESPACE Gem TARGETS Gem::ScriptCanvasDebugger) ly_create_alias(NAME ScriptCanvasDebugger.Clients NAMESPACE Gem TARGETS Gem::ScriptCanvasDebugger) diff --git a/Gems/ScriptCanvas/Code/Editor/Model/UnitTestBrowserFilterModel.cpp b/Gems/ScriptCanvas/Code/Editor/Model/UnitTestBrowserFilterModel.cpp index ab35ec5049..e3fe865e94 100644 --- a/Gems/ScriptCanvas/Code/Editor/Model/UnitTestBrowserFilterModel.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Model/UnitTestBrowserFilterModel.cpp @@ -28,7 +28,7 @@ namespace ScriptCanvasEditor { setDynamicSortFilter(true); - m_showColumn.insert(aznumeric_cast(AssetBrowserEntry::Column::DisplayName)); + m_shownColumns.insert(aznumeric_cast(AssetBrowserEntry::Column::DisplayName)); UnitTestWidgetNotificationBus::Handler::BusConnect(); diff --git a/Gems/ScriptCanvas/Code/Editor/Nodes/NodeCreateUtils.cpp b/Gems/ScriptCanvas/Code/Editor/Nodes/NodeCreateUtils.cpp index 3bcd940a01..c1b557c9c4 100644 --- a/Gems/ScriptCanvas/Code/Editor/Nodes/NodeCreateUtils.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Nodes/NodeCreateUtils.cpp @@ -408,7 +408,7 @@ namespace ScriptCanvasEditor::Nodes AZ::BehaviorAzEventDescription behaviorAzEventDesc; AZ::AttributeReader azEventDescAttributeReader(nullptr, azEventDescAttribute); azEventDescAttributeReader.Read(behaviorAzEventDesc); - if(behaviorAzEventDesc.m_eventName.empty()) + if (behaviorAzEventDesc.m_eventName.empty()) { AZ_Error("NodeUtils", false, "Cannot create an AzEvent node with empty event name") return {}; diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp index 38def487e6..390dbaf0fb 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp @@ -140,21 +140,10 @@ namespace // If the reflected method returns an AZ::Event, reflect it to the SerializeContext if (AZ::MethodReturnsAzEventByReferenceOrPointer(method)) { - AZ::SerializeContext* serializeContext{}; - AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationRequests::GetSerializeContext); const AZ::BehaviorParameter* resultParameter = method.GetResult(); - AZ::SerializeContext::ClassData classData; - classData.m_name = resultParameter->m_name; - classData.m_typeId = resultParameter->m_typeId; - classData.m_azRtti = resultParameter->m_azRtti; - - auto EventPlaceholderAnyCreator = [](AZ::SerializeContext*) -> AZStd::any - { - return AZStd::make_any(); - }; - serializeContext->RegisterType(resultParameter->m_typeId, AZStd::move(classData), EventPlaceholderAnyCreator); - + ScriptCanvas::ReflectEventTypeOnDemand(resultParameter->m_typeId, resultParameter->m_name, resultParameter->m_azRtti); } + nodePaletteModel.RegisterClassNode(categoryPath, behaviorClass ? behaviorClass->m_name : "", name, &method, &behaviorContext, propertyStatus, isOverloaded); } @@ -177,19 +166,8 @@ namespace // If the reflected method returns an AZ::Event, reflect it to the SerializeContext if (AZ::MethodReturnsAzEventByReferenceOrPointer(behaviorMethod)) { - AZ::SerializeContext* serializeContext{}; - AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationRequests::GetSerializeContext); const AZ::BehaviorParameter* resultParameter = behaviorMethod.GetResult(); - AZ::SerializeContext::ClassData classData; - classData.m_name = resultParameter->m_name; - classData.m_typeId = resultParameter->m_typeId; - classData.m_azRtti = resultParameter->m_azRtti; - - auto EventPlaceholderAnyCreator = [](AZ::SerializeContext*) -> AZStd::any - { - return AZStd::make_any(); - }; - serializeContext->RegisterType(resultParameter->m_typeId, AZStd::move(classData), EventPlaceholderAnyCreator); + ScriptCanvas::ReflectEventTypeOnDemand(resultParameter->m_typeId, resultParameter->m_name, resultParameter->m_azRtti); } nodePaletteModel.RegisterMethodNode(behaviorContext, behaviorMethod); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp index c45dc01c35..1986eb653e 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp @@ -153,4 +153,22 @@ namespace ScriptCanvas grammarVersion = GrammarVersion::Current; runtimeVersion = RuntimeVersion::Current; } + + void ReflectEventTypeOnDemand(const AZ::TypeId& typeId, AZStd::string_view name, AZ::IRttiHelper* rttiHelper) + { + AZ::SerializeContext* serializeContext{}; + AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationRequests::GetSerializeContext); + AZ::SerializeContext::ClassData classData; + classData.m_name = name.data(); + classData.m_typeId = typeId; + classData.m_azRtti = rttiHelper; + + auto EventPlaceholderAnyCreator = [](AZ::SerializeContext*) -> AZStd::any + { + return AZStd::make_any(); + }; + + serializeContext->RegisterType(typeId, AZStd::move(classData), EventPlaceholderAnyCreator); + } + } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h index 76542d6097..170e4c5acb 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h @@ -279,6 +279,8 @@ namespace ScriptCanvas bool m_wasAdded = false; AZ::Entity* m_buildEntity = nullptr; }; + + void ReflectEventTypeOnDemand(const AZ::TypeId& typeId, AZStd::string_view name, AZ::IRttiHelper* rttiHelper = nullptr); } namespace AZStd diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Serialization/DatumSerializer.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Serialization/DatumSerializer.cpp index 5bfb69b11e..37d6e2c35f 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Serialization/DatumSerializer.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Serialization/DatumSerializer.cpp @@ -6,12 +6,27 @@ * */ +#include #include #include #include using namespace ScriptCanvas; +namespace DatumSerializerCpp +{ + bool IsEventInput(const AZ::Uuid& inputType) + { + AZ::BehaviorContext* behaviorContext = nullptr; + AZ::ComponentApplicationBus::BroadcastResult(behaviorContext, &AZ::ComponentApplicationRequests::GetBehaviorContext); + AZ_Assert(behaviorContext, "Can't serialize data properly without checking the type, for which we need behavior context!"); + auto bcClassIter = behaviorContext->m_typeToClassMap.find(inputType); + return bcClassIter != behaviorContext->m_typeToClassMap.end() + && bcClassIter->second->m_azRtti + && bcClassIter->second->m_azRtti->GetGenericTypeId() == azrtti_typeid(); + } +} + namespace AZ { AZ_CLASS_ALLOCATOR_IMPL(DatumSerializer, SystemAllocator, 0); @@ -57,7 +72,7 @@ namespace AZ return context.Report ( JSR::Tasks::ReadField , JSR::Outcomes::Missing - , "DatumSerializer::Load failed to load the 'isNullPointer'' member"); + , "DatumSerializer::Load failed to load the 'isNullPointer' member"); } if (isNullPointerMember->value.GetBool()) @@ -159,11 +174,13 @@ namespace AZ , azrtti_typeidGetType())>() , context)); + // datum storage begin auto inputObjectSource = inputScriptDataPtr->GetAsDanger(); - outputValue.AddMember("isNullPointer", rapidjson::Value(inputObjectSource == nullptr), context.GetJsonAllocator()); + const bool isNullPointer = inputObjectSource == nullptr || DatumSerializerCpp::IsEventInput(inputScriptDataPtr->GetType().GetAZType()); + outputValue.AddMember("isNullPointer", rapidjson::Value(isNullPointer), context.GetJsonAllocator()); - if (inputObjectSource) + if (!isNullPointer) { rapidjson::Value typeValue; result.Combine(StoreTypeId(typeValue, inputScriptDataPtr->GetType().GetAZType(), context)); diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/InteractionTests.cpp b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/InteractionTests.cpp index 7a6f628431..264583c1a9 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/InteractionTests.cpp +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/InteractionTests.cpp @@ -176,7 +176,7 @@ namespace ScriptCanvasDeveloper ProcessCreationSet(); } } - else if (stateId == stateId == m_duplicateCheckpoint->GetStateId()) + else if (stateId == m_duplicateCheckpoint->GetStateId()) { if (m_createdSet.empty()) { diff --git a/Gems/Terrain/Code/Source/Components/TerrainWorldComponent.cpp b/Gems/Terrain/Code/Source/Components/TerrainWorldComponent.cpp index e2af58e3eb..669a8f4b02 100644 --- a/Gems/Terrain/Code/Source/Components/TerrainWorldComponent.cpp +++ b/Gems/Terrain/Code/Source/Components/TerrainWorldComponent.cpp @@ -85,8 +85,10 @@ namespace Terrain void TerrainWorldComponent::Activate() { - TerrainSystemServiceRequestBus::Broadcast(&TerrainSystemServiceRequestBus::Events::SetWorldMin, m_configuration.m_worldMin); - TerrainSystemServiceRequestBus::Broadcast(&TerrainSystemServiceRequestBus::Events::SetWorldMax, m_configuration.m_worldMax); + TerrainSystemServiceRequestBus::Broadcast( + &TerrainSystemServiceRequestBus::Events::SetWorldBounds, + AZ::Aabb::CreateFromMinMax(m_configuration.m_worldMin, m_configuration.m_worldMax) + ); TerrainSystemServiceRequestBus::Broadcast( &TerrainSystemServiceRequestBus::Events::SetHeightQueryResolution, m_configuration.m_heightQueryResolution); diff --git a/Gems/Terrain/Code/Source/Components/TerrainWorldDebuggerComponent.cpp b/Gems/Terrain/Code/Source/Components/TerrainWorldDebuggerComponent.cpp index 1fea51ded4..d7504295c2 100644 --- a/Gems/Terrain/Code/Source/Components/TerrainWorldDebuggerComponent.cpp +++ b/Gems/Terrain/Code/Source/Components/TerrainWorldDebuggerComponent.cpp @@ -92,20 +92,13 @@ namespace Terrain { m_wireframeBounds = AZ::Aabb::CreateNull(); - TerrainSystemServiceRequestBus::Broadcast( - &TerrainSystemServiceRequestBus::Events::SetDebugWireframe, m_configuration.m_drawWireframe); - AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId()); AzFramework::BoundsRequestBus::Handler::BusConnect(GetEntityId()); AzFramework::Terrain::TerrainDataNotificationBus::Handler::BusConnect(); - } void TerrainWorldDebuggerComponent::Deactivate() { - TerrainSystemServiceRequestBus::Broadcast( - &TerrainSystemServiceRequestBus::Events::SetDebugWireframe, false); - AzFramework::Terrain::TerrainDataNotificationBus::Handler::BusDisconnect(); AzFramework::BoundsRequestBus::Handler::BusDisconnect(); AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect(); diff --git a/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp b/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp index 812ed3f0da..2178151e3d 100644 --- a/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp +++ b/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp @@ -10,12 +10,14 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -34,6 +36,7 @@ namespace Terrain namespace { const uint32_t DEFAULT_UploadBufferSize = 512 * 1024; // 512k + const char* TerrainFPName = "TerrainFeatureProcessor"; } namespace ShaderInputs @@ -59,7 +62,7 @@ namespace Terrain void TerrainFeatureProcessor::Activate() { - m_areaData.clear(); + m_areaData = {}; InitializeAtomStuff(); EnableSceneNotification(); @@ -69,43 +72,18 @@ namespace Terrain { m_rhiSystem = AZ::RHI::RHISystemInterface::Get(); - m_rhiSystem->GetDrawListTagRegistry()->AcquireTag(AZ::Name("Terrain")); - { // Load the shader - - const char* terrainShaderFilePath = "Shaders/Terrain/Terrain.azshader"; - - AZ::Data::AssetId shaderAssetId; - AZ::Data::AssetCatalogRequestBus::BroadcastResult( - shaderAssetId, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetIdByPath, - terrainShaderFilePath, azrtti_typeid(), false); - if (!shaderAssetId.IsValid()) - { - AZ_Error("Terrain", false, "Failed to get shader asset id with path %s", terrainShaderFilePath); - return; - } - - auto shaderAsset = AZ::Data::AssetManager::Instance().GetAsset(shaderAssetId, AZ::Data::AssetLoadBehavior::PreLoad); - shaderAsset.BlockUntilLoadComplete(); - - if (!shaderAsset.IsReady()) - { - AZ_Error("Terrain", false, "Failed to get shader asset with path %s", terrainShaderFilePath); - return; - } - - m_shader = AZ::RPI::Shader::FindOrCreate(shaderAsset); + constexpr const char* TerrainShaderFilePath = "Shaders/Terrain/Terrain.azshader"; + m_shader = AZ::RPI::LoadShader(TerrainShaderFilePath); if (!m_shader) { - AZ_Error("Terrain", false, "Failed to find or create a shader instance from shader asset '%s'", terrainShaderFilePath); + AZ_Error(TerrainFPName, false, "Failed to find or create a shader instance from shader asset '%s'", TerrainShaderFilePath); return; } // Create the data layout - m_pipelineStateDescriptor = AZ::RHI::PipelineStateDescriptorForDraw{}; - { AZ::RHI::InputStreamLayoutBuilder layoutBuilder; @@ -124,41 +102,41 @@ namespace Terrain m_perObjectSrgAsset = m_shader->FindShaderResourceGroupLayout(AZ::Name{"ObjectSrg"}); if (!m_perObjectSrgAsset) { - AZ_Error("Terrain", false, "Failed to get shader resource group asset"); + AZ_Error(TerrainFPName, false, "Failed to get shader resource group asset"); return; } else if (!m_perObjectSrgAsset->IsFinalized()) { - AZ_Error("Terrain", false, "Shader resource group asset is not loaded"); + AZ_Error(TerrainFPName, false, "Shader resource group asset is not loaded"); return; } const AZ::RHI::ShaderResourceGroupLayout* shaderResourceGroupLayout = &(*m_perObjectSrgAsset); m_heightmapImageIndex = shaderResourceGroupLayout->FindShaderInputImageIndex(AZ::Name(ShaderInputs::HeightmapImage)); - AZ_Error("Terrain", m_heightmapImageIndex.IsValid(), "Failed to find shader input image %s.", ShaderInputs::HeightmapImage); + AZ_Error(TerrainFPName, m_heightmapImageIndex.IsValid(), "Failed to find shader input image %s.", ShaderInputs::HeightmapImage); m_modelToWorldIndex = shaderResourceGroupLayout->FindShaderInputConstantIndex(AZ::Name(ShaderInputs::ModelToWorld)); - AZ_Error("Terrain", m_modelToWorldIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::ModelToWorld); + AZ_Error(TerrainFPName, m_modelToWorldIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::ModelToWorld); m_heightScaleIndex = shaderResourceGroupLayout->FindShaderInputConstantIndex(AZ::Name(ShaderInputs::HeightScale)); - AZ_Error("Terrain", m_heightScaleIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::HeightScale); + AZ_Error(TerrainFPName, m_heightScaleIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::HeightScale); m_uvMinIndex = shaderResourceGroupLayout->FindShaderInputConstantIndex(AZ::Name(ShaderInputs::UvMin)); - AZ_Error("Terrain", m_uvMinIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::UvMin); + AZ_Error(TerrainFPName, m_uvMinIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::UvMin); m_uvMaxIndex = shaderResourceGroupLayout->FindShaderInputConstantIndex(AZ::Name(ShaderInputs::UvMax)); - AZ_Error("Terrain", m_uvMaxIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::UvMax); + AZ_Error(TerrainFPName, m_uvMaxIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::UvMax); m_uvStepIndex = shaderResourceGroupLayout->FindShaderInputConstantIndex(AZ::Name(ShaderInputs::UvStep)); - AZ_Error("Terrain", m_uvStepIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::UvStep); + AZ_Error(TerrainFPName, m_uvStepIndex.IsValid(), "Failed to find shader input constant %s.", ShaderInputs::UvStep); // If this fails to run now, it's ok, we'll initialize it in OnRenderPipelineAdded later. bool success = GetParentScene()->ConfigurePipelineState(m_shader->GetDrawListTag(), m_pipelineStateDescriptor); if (success) { m_pipelineState = m_shader->AcquirePipelineState(m_pipelineStateDescriptor); - AZ_Assert(m_pipelineState, "Failed to acquire default pipeline state for shader '%s'", terrainShaderFilePath); + AZ_Assert(m_pipelineState, "Failed to acquire default pipeline state for shader '%s'", TerrainShaderFilePath); } } @@ -172,7 +150,7 @@ namespace Terrain if (resultCode != AZ::RHI::ResultCode::Success) { - AZ_Error("Terrain", false, "Failed to create host buffer pool from RPI"); + AZ_Error(TerrainFPName, false, "Failed to create host buffer pool from RPI"); return; } @@ -180,7 +158,7 @@ namespace Terrain if (!InitializeRenderBuffers()) { - AZ_Error("Terrain", false, "Failed to create Terrain render buffers!"); + AZ_Error(TerrainFPName, false, "Failed to create Terrain render buffers!"); return; } } @@ -210,7 +188,7 @@ namespace Terrain DisableSceneNotification(); DestroyRenderBuffers(); - m_areaData.clear(); + m_areaData = {}; if (m_hostPool) { @@ -226,7 +204,6 @@ namespace Terrain } void TerrainFeatureProcessor::UpdateTerrainData( - AZ::EntityId areaId, const AZ::Transform& transform, const AZ::Aabb& worldBounds, [[maybe_unused]] float sampleSpacing, @@ -234,37 +211,33 @@ namespace Terrain { if (!worldBounds.IsValid()) { - m_areaData.erase(areaId); return; } - TerrainAreaData areaData; - - areaData.m_transform = transform; - areaData.m_heightScale = worldBounds.GetZExtent(); - areaData.m_terrainBounds = worldBounds; - areaData.m_heightmapImageHeight = height; - areaData.m_heightmapImageWidth = width; + m_areaData.m_transform = transform; + m_areaData.m_heightScale = worldBounds.GetZExtent(); + m_areaData.m_terrainBounds = worldBounds; + m_areaData.m_heightmapImageHeight = height; + m_areaData.m_heightmapImageWidth = width; // Create heightmap image data { - areaData.m_propertiesDirty = true; + m_areaData.m_propertiesDirty = true; AZ::RHI::Size imageSize; imageSize.m_width = width; imageSize.m_height = height; AZ::Data::Instance streamingImagePool = AZ::RPI::ImageSystemInterface::Get()->GetSystemStreamingPool(); - areaData.m_heightmapImage = AZ::RPI::StreamingImage::CreateFromCpuData(*streamingImagePool, + m_areaData.m_heightmapImage = AZ::RPI::StreamingImage::CreateFromCpuData(*streamingImagePool, AZ::RHI::ImageDimension::Image2D, imageSize, AZ::RHI::Format::R32_FLOAT, (uint8_t*)heightData.data(), heightData.size() * sizeof(float)); - AZ_Error("Terrain", areaData.m_heightmapImage, "Failed to initialize the heightmap image!"); + AZ_Error(TerrainFPName, m_areaData.m_heightmapImage, "Failed to initialize the heightmap image!"); } - m_areaData.insert_or_assign(areaId, areaData); } void TerrainFeatureProcessor::ProcessSurfaces(const FeatureProcessor::RenderPacket& process) @@ -276,31 +249,30 @@ namespace Terrain return; } - if (m_areaData.empty()) + if (!m_areaData.m_terrainBounds.IsValid()) { return; } - - m_drawPackets.clear(); - m_processSrgs.clear(); - - AZ::RHI::DrawPacketBuilder drawPacketBuilder; - - uint32_t numIndices = static_cast(m_gridIndices.size()); - - AZ::RHI::DrawIndexed drawIndexed; - drawIndexed.m_indexCount = numIndices; - drawIndexed.m_indexOffset = 0; - drawIndexed.m_vertexOffset = 0; - - for (auto& [areaId, areaData] : m_areaData) + + if (m_areaData.m_propertiesDirty) { + m_sectorData.clear(); + + AZ::RHI::DrawPacketBuilder drawPacketBuilder; + + uint32_t numIndices = static_cast(m_gridIndices.size()); + + AZ::RHI::DrawIndexed drawIndexed; + drawIndexed.m_indexCount = numIndices; + drawIndexed.m_indexOffset = 0; + drawIndexed.m_vertexOffset = 0; + float xFirstPatchStart = - areaData.m_terrainBounds.GetMin().GetX() - fmod(areaData.m_terrainBounds.GetMin().GetX(), m_gridMeters); - float xLastPatchStart = areaData.m_terrainBounds.GetMax().GetX() - fmod(areaData.m_terrainBounds.GetMax().GetX(), m_gridMeters); + m_areaData.m_terrainBounds.GetMin().GetX() - fmod(m_areaData.m_terrainBounds.GetMin().GetX(), m_gridMeters); + float xLastPatchStart = m_areaData.m_terrainBounds.GetMax().GetX() - fmod(m_areaData.m_terrainBounds.GetMax().GetX(), m_gridMeters); float yFirstPatchStart = - areaData.m_terrainBounds.GetMin().GetY() - fmod(areaData.m_terrainBounds.GetMin().GetY(), m_gridMeters); - float yLastPatchStart = areaData.m_terrainBounds.GetMax().GetY() - fmod(areaData.m_terrainBounds.GetMax().GetY(), m_gridMeters); + m_areaData.m_terrainBounds.GetMin().GetY() - fmod(m_areaData.m_terrainBounds.GetMin().GetY(), m_gridMeters); + float yLastPatchStart = m_areaData.m_terrainBounds.GetMax().GetY() - fmod(m_areaData.m_terrainBounds.GetMax().GetY(), m_gridMeters); for (float yPatch = yFirstPatchStart; yPatch <= yLastPatchStart; yPatch += m_gridMeters) { @@ -310,62 +282,70 @@ namespace Terrain drawPacketBuilder.SetDrawArguments(drawIndexed); drawPacketBuilder.SetIndexBufferView(m_indexBufferView); - auto m_resourceGroup = AZ::RPI::ShaderResourceGroup::Create(m_shader->GetAsset(), m_shader->GetSupervariantIndex(), AZ::Name("ObjectSrg")); + auto resourceGroup = AZ::RPI::ShaderResourceGroup::Create(m_shader->GetAsset(), m_shader->GetSupervariantIndex(), AZ::Name("ObjectSrg")); //auto m_resourceGroup = AZ::RPI::ShaderResourceGroup::Create(m_shader->GetAsset(), AZ::Name("ObjectSrg")); - if (!m_resourceGroup) + if (!resourceGroup) { - AZ_Error("Terrain", false, "Failed to create shader resource group"); + AZ_Error(TerrainFPName, false, "Failed to create shader resource group"); return; } float uvMin[2] = { 0.0f, 0.0f }; float uvMax[2] = { 1.0f, 1.0f }; - uvMin[0] = (float)((xPatch - areaData.m_terrainBounds.GetMin().GetX()) / areaData.m_terrainBounds.GetXExtent()); - uvMin[1] = (float)((yPatch - areaData.m_terrainBounds.GetMin().GetY()) / areaData.m_terrainBounds.GetYExtent()); + uvMin[0] = (float)((xPatch - m_areaData.m_terrainBounds.GetMin().GetX()) / m_areaData.m_terrainBounds.GetXExtent()); + uvMin[1] = (float)((yPatch - m_areaData.m_terrainBounds.GetMin().GetY()) / m_areaData.m_terrainBounds.GetYExtent()); uvMax[0] = - (float)(((xPatch + m_gridMeters) - areaData.m_terrainBounds.GetMin().GetX()) / areaData.m_terrainBounds.GetXExtent()); + (float)(((xPatch + m_gridMeters) - m_areaData.m_terrainBounds.GetMin().GetX()) / m_areaData.m_terrainBounds.GetXExtent()); uvMax[1] = - (float)(((yPatch + m_gridMeters) - areaData.m_terrainBounds.GetMin().GetY()) / areaData.m_terrainBounds.GetYExtent()); + (float)(((yPatch + m_gridMeters) - m_areaData.m_terrainBounds.GetMin().GetY()) / m_areaData.m_terrainBounds.GetYExtent()); float uvStep[2] = { - 1.0f / areaData.m_heightmapImageWidth, 1.0f / areaData.m_heightmapImageHeight, + 1.0f / m_areaData.m_heightmapImageWidth, 1.0f / m_areaData.m_heightmapImageHeight, }; - AZ::Transform transform = areaData.m_transform; - transform.SetTranslation(xPatch, yPatch, areaData.m_transform.GetTranslation().GetZ()); + AZ::Transform transform = m_areaData.m_transform; + transform.SetTranslation(xPatch, yPatch, m_areaData.m_transform.GetTranslation().GetZ()); AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(transform); - m_resourceGroup->SetImage(m_heightmapImageIndex, areaData.m_heightmapImage); - m_resourceGroup->SetConstant(m_modelToWorldIndex, matrix3x4); - m_resourceGroup->SetConstant(m_heightScaleIndex, areaData.m_heightScale); - m_resourceGroup->SetConstant(m_uvMinIndex, uvMin); - m_resourceGroup->SetConstant(m_uvMaxIndex, uvMax); - m_resourceGroup->SetConstant(m_uvStepIndex, uvStep); - m_resourceGroup->Compile(); - m_processSrgs.push_back(m_resourceGroup); - - if (m_resourceGroup != nullptr) - { - drawPacketBuilder.AddShaderResourceGroup(m_resourceGroup->GetRHIShaderResourceGroup()); - } + resourceGroup->SetImage(m_heightmapImageIndex, m_areaData.m_heightmapImage); + resourceGroup->SetConstant(m_modelToWorldIndex, matrix3x4); + resourceGroup->SetConstant(m_heightScaleIndex, m_areaData.m_heightScale); + resourceGroup->SetConstant(m_uvMinIndex, uvMin); + resourceGroup->SetConstant(m_uvMaxIndex, uvMax); + resourceGroup->SetConstant(m_uvStepIndex, uvStep); + resourceGroup->Compile(); + drawPacketBuilder.AddShaderResourceGroup(resourceGroup->GetRHIShaderResourceGroup()); AZ::RHI::DrawPacketBuilder::DrawRequest drawRequest; drawRequest.m_listTag = m_drawListTag; drawRequest.m_pipelineState = m_pipelineState.get(); - drawRequest.m_streamBufferViews = m_vertexBufferViews; + drawRequest.m_streamBufferViews = AZStd::array_view(&m_vertexBufferView, 1); drawPacketBuilder.AddDrawItem(drawRequest); - - const AZ::RHI::DrawPacket* drawPacket = drawPacketBuilder.End(); - m_drawPackets.emplace_back(drawPacket); - - for (auto& view : process.m_views) - { - view->AddDrawPacket(drawPacket); - } + + m_sectorData.emplace_back( + drawPacketBuilder.End(), + AZ::Aabb::CreateFromMinMax( + AZ::Vector3(xPatch, yPatch, m_areaData.m_terrainBounds.GetMin().GetZ()), + AZ::Vector3(xPatch + m_gridMeters, yPatch + m_gridMeters, m_areaData.m_terrainBounds.GetMax().GetZ()) + ), + resourceGroup + ); + } + } + } + + for (auto& view : process.m_views) + { + AZ::Frustum viewFrustum = AZ::Frustum::CreateFromMatrixColumnMajor(view->GetWorldToClipMatrix()); + for (auto& sectorData : m_sectorData) + { + if (viewFrustum.IntersectAabb(sectorData.m_aabb) != AZ::IntersectResult::Exterior) + { + view->AddDrawPacket(sectorData.m_drawPacket.get()); } } } @@ -413,9 +393,6 @@ namespace Terrain m_indexBuffer->SetName(AZ::Name("TerrainIndexBuffer")); m_vertexBuffer->SetName(AZ::Name("TerrainVertexBuffer")); - // We only need one vertex buffer view. - m_vertexBufferViews.resize(1); - AZStd::vector> buffers = { m_indexBuffer , m_vertexBuffer }; // Fill our buffers with the vertex/index data @@ -433,7 +410,7 @@ namespace Terrain if (result != AZ::RHI::ResultCode::Success) { - AZ_Error("Terrain", false, "Failed to create GPU buffers for Terrain"); + AZ_Error(TerrainFPName, false, "Failed to create GPU buffers for Terrain"); return false; } @@ -462,10 +439,10 @@ namespace Terrain const uint64_t elementSize = m_gridVertices.size() * sizeof(Vertex); memcpy(mappedData, m_gridVertices.data(), elementSize); - m_vertexBufferViews[bufferIndex - 1] = AZ::RHI::StreamBufferView( + m_vertexBufferView = AZ::RHI::StreamBufferView( *buffer, 0, static_cast(elementSize), static_cast(sizeof(Vertex))); - AZ::RHI::ValidateStreamBufferViews(m_pipelineStateDescriptor.m_inputStreamLayout, m_vertexBufferViews); + AZ::RHI::ValidateStreamBufferViews(m_pipelineStateDescriptor.m_inputStreamLayout, { { m_vertexBufferView } }); } m_hostPool->UnmapBuffer(*buffer); @@ -479,9 +456,8 @@ namespace Terrain m_indexBuffer.reset(); m_vertexBuffer.reset(); - m_vertexBufferViews.clear(); - - m_processSrgs.clear(); + m_indexBufferView = {}; + m_vertexBufferView = {}; m_pipelineStateDescriptor = AZ::RHI::PipelineStateDescriptorForDraw{}; m_pipelineState = nullptr; diff --git a/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.h b/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.h index 2a1d5b7514..7a7b63b634 100644 --- a/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.h +++ b/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.h @@ -47,16 +47,12 @@ namespace Terrain void Deactivate() override; void Render(const AZ::RPI::FeatureProcessor::RenderPacket& packet) override; - void UpdateTerrainData(AZ::EntityId areaId, const AZ::Transform& transform, const AZ::Aabb& worldBounds, float sampleSpacing, + void UpdateTerrainData(const AZ::Transform& transform, const AZ::Aabb& worldBounds, float sampleSpacing, uint32_t width, uint32_t height, const AZStd::vector& heightData); - void RemoveTerrainData(AZ::EntityId areaId) - { - m_areaData.erase(areaId); - } void RemoveTerrainData() { - m_areaData.clear(); + m_areaData = {}; } private: @@ -122,13 +118,13 @@ namespace Terrain AZ::RHI::Ptr m_indexBuffer; AZ::RHI::Ptr m_vertexBuffer; AZ::RHI::IndexBufferView m_indexBufferView; - AZStd::fixed_vector m_vertexBufferViews; + AZ::RHI::StreamBufferView m_vertexBufferView; // Per-area data struct TerrainAreaData { - AZ::Transform m_transform; - AZ::Aabb m_terrainBounds; + AZ::Transform m_transform{ AZ::Transform::CreateIdentity() }; + AZ::Aabb m_terrainBounds{ AZ::Aabb::CreateNull() }; float m_heightScale; AZ::Data::Instance m_heightmapImage; uint32_t m_heightmapImageWidth; @@ -136,10 +132,21 @@ namespace Terrain bool m_propertiesDirty{ true }; }; - AZStd::unordered_map m_areaData; + TerrainAreaData m_areaData; - // These could either be per-area or system-level - AZStd::vector> m_drawPackets; - AZStd::vector> m_processSrgs; + struct SectorData + { + AZ::Data::Instance m_srg; + AZ::Aabb m_aabb; + AZStd::unique_ptr m_drawPacket; + + SectorData(const AZ::RHI::DrawPacket* drawPacket, AZ::Aabb aabb, AZ::Data::Instance srg) + : m_srg(srg) + , m_aabb(aabb) + , m_drawPacket(drawPacket) + {} + }; + + AZStd::vector m_sectorData; }; } diff --git a/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.cpp b/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.cpp index 872b37a02e..90b74f08ba 100644 --- a/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.cpp +++ b/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.cpp @@ -49,15 +49,9 @@ void TerrainSystem::Deactivate() m_terrainSettingsDirty = true; } -void TerrainSystem::SetWorldMin(AZ::Vector3 worldOrigin) -{ - m_requestedSettings.m_worldBounds.SetMin(worldOrigin); - m_terrainSettingsDirty = true; -} - -void TerrainSystem::SetWorldMax(AZ::Vector3 worldBounds) -{ - m_requestedSettings.m_worldBounds.SetMax(worldBounds); +void TerrainSystem::SetWorldBounds(const AZ::Aabb& worldBounds) +{ + m_requestedSettings.m_worldBounds = worldBounds; m_terrainSettingsDirty = true; } @@ -67,13 +61,6 @@ void TerrainSystem::SetHeightQueryResolution(AZ::Vector2 queryResolution) m_terrainSettingsDirty = true; } -void TerrainSystem::SetDebugWireframe(bool wireframeEnabled) -{ - m_requestedSettings.m_debugWireframeEnabled = wireframeEnabled; - m_terrainSettingsDirty = true; -} - - AZ::Aabb TerrainSystem::GetTerrainAabb() const { return m_currentSettings.m_worldBounds; @@ -378,13 +365,6 @@ void TerrainSystem::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/) terrainSettingsChanged = true; } - if (m_requestedSettings.m_debugWireframeEnabled != m_currentSettings.m_debugWireframeEnabled) - { - m_dirtyRegion = AZ::Aabb::CreateNull(); - m_terrainHeightDirty = true; - terrainSettingsChanged = true; - } - if (m_requestedSettings.m_heightQueryResolution != m_currentSettings.m_heightQueryResolution) { m_dirtyRegion = AZ::Aabb::CreateNull(); @@ -409,7 +389,6 @@ void TerrainSystem::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/) { AZStd::shared_lock lock(m_areaMutex); - AZ::EntityId entityId(0); AZ::Transform transform = AZ::Transform::CreateTranslation(m_currentSettings.m_worldBounds.GetCenter()); uint32_t width = aznumeric_cast( @@ -417,7 +396,7 @@ void TerrainSystem::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/) uint32_t height = aznumeric_cast( (float)m_currentSettings.m_worldBounds.GetYExtent() / m_currentSettings.m_heightQueryResolution.GetY()); AZStd::vector pixels; - pixels.resize(width * height); + pixels.resize_no_construct(width * height); const uint32_t pixelDataSize = width * height * sizeof(float); memset(pixels.data(), 0, pixelDataSize); @@ -454,8 +433,7 @@ void TerrainSystem::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/) if (terrainFeatureProcessor) { terrainFeatureProcessor->UpdateTerrainData( - entityId, transform, m_currentSettings.m_worldBounds, m_currentSettings.m_heightQueryResolution.GetX(), width, height, - pixels); + transform, m_currentSettings.m_worldBounds, m_currentSettings.m_heightQueryResolution.GetX(), width, height, pixels); } } diff --git a/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.h b/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.h index 56ed182047..2d2286a0c3 100644 --- a/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.h +++ b/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystem.h @@ -36,11 +36,9 @@ namespace Terrain /////////////////////////////////////////// // TerrainSystemServiceRequestBus::Handler Impl - - void SetWorldMin(AZ::Vector3 worldOrigin) override; - void SetWorldMax(AZ::Vector3 worldBounds) override; + + void SetWorldBounds(const AZ::Aabb& worldBounds) override; void SetHeightQueryResolution(AZ::Vector2 queryResolution) override; - void SetDebugWireframe(bool wireframeEnabled) override; void Activate() override; void Deactivate() override; @@ -103,7 +101,6 @@ namespace Terrain { AZ::Aabb m_worldBounds; AZ::Vector2 m_heightQueryResolution{ 1.0f }; - bool m_debugWireframeEnabled{ false }; bool m_systemActive{ false }; }; diff --git a/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystemBus.h b/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystemBus.h index 08521fd780..e999cbf8be 100644 --- a/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystemBus.h +++ b/Gems/Terrain/Code/Source/TerrainSystem/TerrainSystemBus.h @@ -39,10 +39,8 @@ namespace Terrain virtual void Activate() = 0; virtual void Deactivate() = 0; - virtual void SetWorldMin(AZ::Vector3 worldOrigin) = 0; - virtual void SetWorldMax(AZ::Vector3 worldBounds) = 0; + virtual void SetWorldBounds(const AZ::Aabb& worldBounds) = 0; virtual void SetHeightQueryResolution(AZ::Vector2 queryResolution) = 0; - virtual void SetDebugWireframe(bool wireframeEnabled) = 0; // register an area to override terrain virtual void RegisterArea(AZ::EntityId areaId) = 0; @@ -111,8 +109,6 @@ namespace Terrain virtual void GetHeight(const AZ::Vector3& inPosition, AZ::Vector3& outPosition, Sampler sampleFilter = Sampler::DEFAULT) = 0; virtual void GetNormal(const AZ::Vector3& inPosition, AZ::Vector3& outNormal, Sampler sampleFilter = Sampler::DEFAULT) = 0; - //virtual void GetSurfaceWeights(const AZ::Vector3& inPosition, SurfaceTagWeightMap& outSurfaceWeights, Sampler sampleFilter = DEFAULT) = 0; - //virtual void GetSurfacePoint(const AZ::Vector3& inPosition, SurfacePoint& outSurfacePoint, SurfacePointDataMask dataMask = DEFAULT, Sampler sampleFilter = DEFAULT) = 0; }; using TerrainAreaHeightRequestBus = AZ::EBus; diff --git a/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp b/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp index 7e96c83810..afba511603 100644 --- a/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp +++ b/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp @@ -29,6 +29,46 @@ #include #include +namespace OpenMesh +{ + // Overload methods need to be declared before including OpenMesh so their definitions are found + + inline AZ::Vector3 normalize(const AZ::Vector3& v) + { + AZ::Vector3 vret = v; + vret.Normalize(); + return vret; + } + + inline float dot(const AZ::Vector3& v1, const AZ::Vector3& v2) + { + return v1.Dot(v2); + } + + inline float norm(const AZ::Vector3& v) + { + return v.GetLength(); + } + + inline AZ::Vector3 cross(const AZ::Vector3& v1, const AZ::Vector3& v2) + { + return v1.Cross(v2); + } + + inline AZ::Vector3 vectorize(AZ::Vector3& v, float s) + { + v = AZ::Vector3(s); + return v; + } + + inline void newell_norm(AZ::Vector3& n, const AZ::Vector3& a, const AZ::Vector3& b) + { + n.SetX(n.GetX() + (a.GetY() * b.GetZ())); + n.SetY(n.GetY() + (a.GetZ() * b.GetX())); + n.SetZ(n.GetZ() + (a.GetX() * b.GetY())); + } +} + // OpenMesh includes AZ_PUSH_DISABLE_WARNING(4702, "-Wunknown-warning-option") // OpenMesh\Core\Utils\Property.hh has unreachable code #include @@ -82,40 +122,6 @@ namespace OpenMesh } }; - inline AZ::Vector3 normalize(AZ::Vector3& v) - { - v.Normalize(); - return v; - } - - inline float dot(const AZ::Vector3& v1, const AZ::Vector3& v2) - { - return v1.Dot(v2); - } - - inline float norm(const AZ::Vector3& v) - { - return v.GetLength(); - } - - inline AZ::Vector3 cross(const AZ::Vector3& v1, const AZ::Vector3& v2) - { - return v1.Cross(v2); - } - - inline AZ::Vector3 vectorize(AZ::Vector3& v, float s) - { - v = AZ::Vector3(s); - return v; - } - - inline void newell_norm(AZ::Vector3& n, const AZ::Vector3& a, const AZ::Vector3& b) - { - n.SetX(n.GetX() + (a.GetY() * b.GetZ())); - n.SetY(n.GetY() + (a.GetZ() * b.GetX())); - n.SetZ(n.GetZ() + (a.GetX() * b.GetY())); - } - template<> inline void vector_cast(const AZ::Vector3& src, OpenMesh::Vec3f& dst, GenProg::Int2Type<3> /*unused*/) { diff --git a/Templates/DefaultProject/Template/Code/CMakeLists.txt b/Templates/DefaultProject/Template/Code/CMakeLists.txt index 0c6f6553fb..7bbb9a0852 100644 --- a/Templates/DefaultProject/Template/Code/CMakeLists.txt +++ b/Templates/DefaultProject/Template/Code/CMakeLists.txt @@ -68,46 +68,12 @@ ly_create_alias(NAME ${Name}.Servers NAMESPACE Gem TARGETS Gem::${Name}) # Gem dependencies ################################################################################ -# The GameLauncher uses "Clients" gem variants: -ly_enable_gems( - PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake - TARGETS - ${Name}.GameLauncher - VARIANTS - Clients) - -if(PAL_TRAIT_BUILD_HOST_TOOLS) - - # the builder type applications use the "Builders" variants of the enabled gems. - ly_enable_gems( - PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake - TARGETS - AssetBuilder - AssetProcessor - AssetProcessorBatch - VARIANTS - Builders) - - # the Editor applications use the "Tools" variants of the enabled gems. - ly_enable_gems( - PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake - TARGETS - Editor - VARIANTS - Tools) -endif() +# Enable the specified list of gems from GEM_FILE or GEMS list for this specific project: +ly_enable_gems(PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake) if(PAL_TRAIT_BUILD_SERVER_SUPPORTED) # this property causes it to actually make a ServerLauncher. # if you don't want a Server application, you can remove this and the # following ly_enable_gems lines. set_property(GLOBAL APPEND PROPERTY LY_LAUNCHER_SERVER_PROJECTS ${Name}) - - # The ServerLauncher uses the "Servers" variants of enabled gems: - ly_enable_gems( - PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake - TARGETS - ${Name}.ServerLauncher - VARIANTS - Servers) endif() diff --git a/Templates/MinimalProject/Template/Code/CMakeLists.txt b/Templates/MinimalProject/Template/Code/CMakeLists.txt index 0c6f6553fb..5e646c0704 100644 --- a/Templates/MinimalProject/Template/Code/CMakeLists.txt +++ b/Templates/MinimalProject/Template/Code/CMakeLists.txt @@ -68,46 +68,13 @@ ly_create_alias(NAME ${Name}.Servers NAMESPACE Gem TARGETS Gem::${Name}) # Gem dependencies ################################################################################ -# The GameLauncher uses "Clients" gem variants: -ly_enable_gems( - PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake - TARGETS - ${Name}.GameLauncher - VARIANTS - Clients) +# Enable the specified list of gems from GEM_FILE or GEMS list for this specific project: +ly_enable_gems(PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake) -if(PAL_TRAIT_BUILD_HOST_TOOLS) - - # the builder type applications use the "Builders" variants of the enabled gems. - ly_enable_gems( - PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake - TARGETS - AssetBuilder - AssetProcessor - AssetProcessorBatch - VARIANTS - Builders) - - # the Editor applications use the "Tools" variants of the enabled gems. - ly_enable_gems( - PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake - TARGETS - Editor - VARIANTS - Tools) -endif() if(PAL_TRAIT_BUILD_SERVER_SUPPORTED) # this property causes it to actually make a ServerLauncher. # if you don't want a Server application, you can remove this and the # following ly_enable_gems lines. set_property(GLOBAL APPEND PROPERTY LY_LAUNCHER_SERVER_PROJECTS ${Name}) - - # The ServerLauncher uses the "Servers" variants of enabled gems: - ly_enable_gems( - PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake - TARGETS - ${Name}.ServerLauncher - VARIANTS - Servers) endif() diff --git a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake index a65e8b45e4..cbdca10af9 100644 --- a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake +++ b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake @@ -27,4 +27,4 @@ ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-android TARGETS goo ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-android TARGETS GoogleBenchmark PACKAGE_HASH 20b46e572211a69d7d94ddad1c89ec37bb958711d6ad4025368ac89ea83078fb) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-android TARGETS libsamplerate PACKAGE_HASH bf13662afe65d02bcfa16258a4caa9b875534978227d6f9f36c9cfa92b3fb12b) ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev1-android TARGETS OpenSSL PACKAGE_HASH 4036d4019d722f0e1b7a1621bf60b5a17ca6a65c9c78fd8701cee1131eec8480) -ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev1-android TARGETS zlib PACKAGE_HASH 832b163cae0cccbe4fddc5988f5725fac56ef7dba5bfe95bf8c71281fba2e12c) +ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev2-android TARGETS zlib PACKAGE_HASH 85b730b97176772538cfcacd6b6aaf4655fc2d368d134d6dd55e02f28f183826) diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index ba63ef5d64..0cbb799304 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -43,7 +43,7 @@ ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev2-linux ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-1.6.2104-o3de-rev3-linux TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 88c4a359325d749bc34090b9ac466424847f3b71ba0de15045cf355c17c07099) ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-linux TARGETS SPIRVCross PACKAGE_HASH 7889ee5460a688e9b910c0168b31445c0079d363affa07b25d4c8aeb608a0b80) ly_associate_package(PACKAGE_NAME azslc-1.7.23-rev2-linux TARGETS azslc PACKAGE_HASH 1ba84d8321a566d35a1e9aa7400211ba8e6d1c11c08e4be3c93e6e74b8f7aef1) -ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev1-linux TARGETS zlib PACKAGE_HASH 6418e93b9f4e6188f3b62cbd3a7822e1c4398a716e786d1522b809a727d08ba9) +ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev2-linux TARGETS zlib PACKAGE_HASH 16f3b9e11cda525efb62144f354c1cfc30a5def9eff020dbe49cb00ee7d8234f) ly_associate_package(PACKAGE_NAME squish-ccr-deb557d-rev1-linux TARGETS squish-ccr PACKAGE_HASH 85fecafbddc6a41a27c5f59ed4a5dfb123a94cb4666782cf26e63c0a4724c530) ly_associate_package(PACKAGE_NAME ISPCTexComp-36b80aa-rev1-linux TARGETS ISPCTexComp PACKAGE_HASH 065fd12abe4247dde247330313763cf816c3375c221da030bdec35024947f259) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index be89612c1b..e18bb07772 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -41,7 +41,7 @@ ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-mac ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev1-mac TARGETS OpenSSL PACKAGE_HASH 28adc1c0616ac0482b2a9d7b4a3a3635a1020e87b163f8aba687c501cf35f96c) ly_associate_package(PACKAGE_NAME qt-5.15.2-rev5-mac TARGETS Qt PACKAGE_HASH 9d25918351898b308ded3e9e571fff6f26311b2071aeafd00dd5b249fdf53f7e) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-mac TARGETS libsamplerate PACKAGE_HASH b912af40c0ac197af9c43d85004395ba92a6a859a24b7eacd920fed5854a97fe) -ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev1-mac TARGETS zlib PACKAGE_HASH 7fd8a77b3598423d9d6be5f8c60d52aecf346ab4224f563a5282db283aa0da02) +ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev2-mac TARGETS zlib PACKAGE_HASH 21714e8a6de4f2523ee92a7f52d51fbee29c5f37ced334e00dc3c029115b472e) ly_associate_package(PACKAGE_NAME squish-ccr-deb557d-rev1-mac TARGETS squish-ccr PACKAGE_HASH 155bfbfa17c19a9cd2ef025de14c5db598f4290045d5b0d83ab58cb345089a77) ly_associate_package(PACKAGE_NAME ISPCTexComp-36b80aa-rev1-mac TARGETS ISPCTexComp PACKAGE_HASH 8a4e93277b8face6ea2fd57c6d017bdb55643ed3d6387110bc5f6b3b884dd169) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index 10b56f90d9..305d1291e7 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -48,6 +48,6 @@ ly_associate_package(PACKAGE_NAME OpenMesh-8.1-rev1-windows ly_associate_package(PACKAGE_NAME civetweb-1.8-rev1-windows TARGETS civetweb PACKAGE_HASH 36d0e58a59bcdb4dd70493fb1b177aa0354c945b06c30416348fd326cf323dd4) ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev2-windows TARGETS OpenSSL PACKAGE_HASH 9af1c50343f89146b4053101a7aeb20513319a3fe2f007e356d7ce25f9241040) ly_associate_package(PACKAGE_NAME Crashpad-0.8.0-rev1-windows TARGETS Crashpad PACKAGE_HASH d162aa3070147bc0130a44caab02c5fe58606910252caf7f90472bd48d4e31e2) -ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev1-windows TARGETS zlib PACKAGE_HASH 6fb46a0ef8c8614cde3517b50fca47f2a6d1fd059b21f3b8ff13e635ca7f2fa6) +ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev2-windows TARGETS zlib PACKAGE_HASH 9afab1d67641ed8bef2fb38fc53942da47f2ab339d9e77d3d20704a48af2da0b) ly_associate_package(PACKAGE_NAME squish-ccr-deb557d-rev1-windows TARGETS squish-ccr PACKAGE_HASH 5c3d9fa491e488ccaf802304ad23b932268a2b2846e383f088779962af2bfa84) ly_associate_package(PACKAGE_NAME ISPCTexComp-36b80aa-rev1-windows TARGETS ISPCTexComp PACKAGE_HASH b6fa6ea28a2808a9a5524c72c37789c525925e435770f2d94eb2d387360fa2d0) diff --git a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake index c288460dd0..0574f38654 100644 --- a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake +++ b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake @@ -28,4 +28,4 @@ ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-ios TARGETS googlet ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-ios TARGETS GoogleBenchmark PACKAGE_HASH c2ffaed2b658892b1bcf81dee4b44cd1cb09fc78d55584ef5cb8ab87f2d8d1ae) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-ios TARGETS libsamplerate PACKAGE_HASH 7656b961697f490d4f9c35d2e61559f6fc38c32102e542a33c212cd618fc2119) ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev1-ios TARGETS OpenSSL PACKAGE_HASH cd0dfce3086a7172777c63dadbaf0ac3695b676119ecb6d0614b5fb1da03462f) -ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev1-ios TARGETS zlib PACKAGE_HASH 20bfccf3b98bd9a7d3506cf344ac48135035eb517752bf9bede1e821f163608d) +ly_associate_package(PACKAGE_NAME zlib-1.2.11-rev2-ios TARGETS zlib PACKAGE_HASH a59fc0f83a02c616b679799310e9d86fde84514c6d2acefa12c6def0ae4a880c) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 3863cdc313..f40c72b540 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -35,7 +35,9 @@ function(ly_add_dependencies TARGET) if(TARGET ${TARGET}) # Target already created, add it ly_parse_third_party_dependencies("${extra_function_args}") - add_dependencies(${TARGET} ${extra_function_args}) + # Dependencies can only be added on non-alias target + ly_de_alias_target(${TARGET} de_aliased_target) + add_dependencies(${de_aliased_target} ${extra_function_args}) else() set_property(GLOBAL APPEND PROPERTY LY_DELAYED_DEPENDENCIES_${TARGET} ${extra_function_args}) endif() diff --git a/cmake/Gems.cmake b/cmake/Gems.cmake index bcb619fd8d..e01740c265 100644 --- a/cmake/Gems.cmake +++ b/cmake/Gems.cmake @@ -6,7 +6,13 @@ # # -# This file contains utility wrappers for dealing with the Gems system. +# This file contains utility wrappers for dealing with the Gems system. + +define_property(TARGET PROPERTY LY_PROJECT_NAME + BRIEF_DOCS "Name of the project, this target can use enabled gems from" + FULL_DOCS "If set, the when iterating over the enabled gems in ly_enabled_gems_delayed + only a project with that name can have it's enabled gem list added as a dependency to this target. + If the __NOPROJECT__ placeholder is associated with a list enabled gems, then it applies to this target regardless of this property value") # ly_create_alias # given an alias to create, and a list of one or more targets, @@ -34,7 +40,8 @@ function(ly_create_alias) # easy version - if its just one target and it exist at the time of this call, # we can directly get the target, and make both aliases, - # the namespaced and non namespaced one, point at it. + # the namespace and non namespace one, point at it. + set(create_interface_target TRUE) list(LENGTH ly_create_alias_TARGETS number_of_targets) if (number_of_targets EQUAL 1) if(TARGET ${ly_create_alias_TARGETS}) @@ -43,11 +50,7 @@ function(ly_create_alias) if (NOT TARGET ${ly_create_alias_NAME}) add_library(${ly_create_alias_NAME} ALIAS ${de_aliased_target_name}) endif() - # Store off the arguments needed used ly_create_alias into a DIRECTORY property - # This will be used to re-create the calls in the generated CMakeLists.txt in the INSTALL step - string(REPLACE ";" " " create_alias_args "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}") - set_property(DIRECTORY APPEND PROPERTY LY_CREATE_ALIAS_ARGUMENTS "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}") - return() + set(create_interface_target FALSE) endif() endif() @@ -55,41 +58,48 @@ function(ly_create_alias) # To actually achieve this we have to create an interface library with those dependencies, # then we have to create an alias to that target. # By convention we create one without a namespace then alias the namespaced one. - - if(TARGET ${ly_create_alias_NAME}) - message(FATAL_ERROR "Internal alias target already exists, cannot create an alias for it: ${ly_create_alias_NAME}\n" - "This could be a copy-paste error, where some part of the ly_create_alias call was changed but the other") - endif() - - add_library(${ly_create_alias_NAME} INTERFACE IMPORTED GLOBAL) - set_target_properties(${ly_create_alias_NAME} PROPERTIES GEM_MODULE TRUE) - - foreach(target_name ${ly_create_alias_TARGETS}) - if(TARGET ${target_name}) - ly_de_alias_target(${target_name} de_aliased_target_name) - if(NOT de_aliased_target_name) - message(FATAL_ERROR "Target not found in ly_create_alias call: ${target_name} - check your spelling of the target name") - endif() - else() - set(de_aliased_target_name ${target_name}) + if(create_interface_target) + if(TARGET ${ly_create_alias_NAME}) + message(FATAL_ERROR "Internal alias target already exists, cannot create an alias for it: ${ly_create_alias_NAME}\n" + "This could be a copy-paste error, where some part of the ly_create_alias call was changed but the other") endif() - list(APPEND final_targets ${de_aliased_target_name}) - endforeach() - - # add_dependencies must be called with at least one dependent target - if(final_targets) - ly_parse_third_party_dependencies("${final_targets}") - ly_add_dependencies(${ly_create_alias_NAME} ${final_targets}) - endif() - # now add the final alias: - add_library(${ly_create_alias_NAMESPACE}::${ly_create_alias_NAME} ALIAS ${ly_create_alias_NAME}) + add_library(${ly_create_alias_NAME} INTERFACE IMPORTED GLOBAL) + set_target_properties(${ly_create_alias_NAME} PROPERTIES GEM_MODULE TRUE) + + foreach(target_name ${ly_create_alias_TARGETS}) + if(TARGET ${target_name}) + ly_de_alias_target(${target_name} de_aliased_target_name) + if(NOT de_aliased_target_name) + message(FATAL_ERROR "Target not found in ly_create_alias call: ${target_name} - check your spelling of the target name") + endif() + else() + set(de_aliased_target_name ${target_name}) + endif() + list(APPEND final_targets ${de_aliased_target_name}) + endforeach() + + # add_dependencies must be called with at least one dependent target + if(final_targets) + ly_parse_third_party_dependencies("${final_targets}") + ly_add_dependencies(${ly_create_alias_NAME} ${final_targets}) + endif() + + # now add the final alias: + add_library(${ly_create_alias_NAMESPACE}::${ly_create_alias_NAME} ALIAS ${ly_create_alias_NAME}) + endif() # Store off the arguments used by ly_create_alias into a DIRECTORY property # This will be used to re-create the calls in the generated CMakeLists.txt in the INSTALL step - - # Replace the CMake list separator with a space to replicate the space separated TARGETS arguments - string(REPLACE ";" " " create_alias_args "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}") + # Replace the CMake list separator with a space to replicate the space separated arguments + # A single create_alias_args variable encodes two values. The alias NAME used to check if the target exists + # and the ly_create_alias arguments to replace this function call + unset(create_alias_args) + list(APPEND create_alias_args "${ly_create_alias_NAME}," + NAME ${ly_create_alias_NAME} + NAMESPACE ${ly_create_alias_NAMESPACE} + TARGETS ${ly_create_alias_TARGETS}) + list(JOIN create_alias_args " " create_alias_args) set_property(DIRECTORY APPEND PROPERTY LY_CREATE_ALIAS_ARGUMENTS "${create_alias_args}") # Store the directory path in the GLOBAL property so that it can be accessed @@ -100,13 +110,54 @@ function(ly_create_alias) endif() endfunction() +# ly_set_gem_variant_to_load +# Associates a key, value entry of CMake target -> Gem variant +# \arg:TARGETS - list of Targets to associate with the Gem variant +# \arg:VARIANTS - Gem variant +function(ly_set_gem_variant_to_load) + set(options) + set(oneValueArgs) + set(multiValueArgs TARGETS VARIANTS) + + cmake_parse_arguments(ly_set_gem_variant_to_load "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (NOT ly_set_gem_variant_to_load_TARGETS) + message(FATAL_ERROR "You must provide at least 1 target to ${CMAKE_CURRENT_FUNCTION} using the TARGETS keyword") + endif() + + # Store a list of targets + foreach(target_name ${ly_set_gem_variant_to_load_TARGETS}) + # Append the target to the list of targets with variants if it has not been added + get_property(ly_targets_with_variants GLOBAL PROPERTY LY_TARGETS_WITH_GEM_VARIANTS) + if(NOT target_name IN_LIST ly_targets_with_variants) + set_property(GLOBAL APPEND PROPERTY LY_TARGETS_WITH_GEM_VARIANTS "${target_name}") + endif() + foreach(variant_name ${ly_set_gem_variant_to_load_VARIANTS}) + get_property(target_gem_variants GLOBAL PROPERTY LY_GEM_VARIANTS_"${target_name}") + if(NOT variant_name IN_LIST target_gem_variants) + set_property(GLOBAL APPEND PROPERTY LY_GEM_VARIANTS_"${target_name}" "${variant_name}") + endif() + endforeach() + endforeach() + + # Store of the arguments used to invoke this function in order to replicate the call in the generated CMakeLists.txt + # in the install layout + unset(set_gem_variant_args) + list(APPEND set_gem_variant_args + TARGETS ${ly_set_gem_variant_to_load_TARGETS} + VARIANTS ${ly_set_gem_variant_to_load_VARIANTS}) + # Replace the list separator with space to have it be stored as a single property element + list(JOIN set_gem_variant_args " " set_gem_variant_args) + set_property(DIRECTORY APPEND PROPERTY LY_SET_GEM_VARIANT_TO_LOAD_ARGUMENTS "${set_gem_variant_args}") +endfunction() + # ly_enable_gems # this function makes sure that the given gems, or gems listed in the variable ENABLED_GEMS # in the GEM_FILE name, are set as runtime dependencies (and thus loaded) for the given targets # in the context of the given project. # note that it can't do this immediately, so it saves the data for later processing. # Note: If you don't supply a project name, it will apply it across the board to all projects. -# this is useful in the case of "ly_add_gems being called for so called 'mandatory gems' inside the engine. +# this is useful in the case of "ly_enable_gems" being called for so called 'mandatory gems' inside the engine. # if you specify a gem name with a namespace, it will be used, otherwise it will assume Gem:: function(ly_enable_gems) set(options) @@ -115,23 +166,21 @@ function(ly_enable_gems) cmake_parse_arguments(ly_enable_gems "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if (NOT ly_enable_gems_TARGETS) - message(FATAL_ERROR "You must provide the targets to add gems to using the TARGETS keyword") - endif() - - if (NOT ly_enable_gems_PROJECT_NAME) message(VERBOSE "Note: ly_enable_gems called with no PROJECT_NAME name, applying to all projects: \n" - " - VARIANTS ${ly_enable_gems_VARIANTS} \n" - " - GEMS ${ly_enable_gems_GEMS} \n" - " - TARGETS ${ly_enable_gems_TARGETS} \n" + " - GEMS ${ly_enable_gems_GEMS} \n" " - GEM_FILE ${ly_enable_gems_GEM_FILE}") set(ly_enable_gems_PROJECT_NAME "__NOPROJECT__") # so that the token is not blank endif() - if (NOT ly_enable_gems_VARIANTS) - message(FATAL_ERROR "You must provide at least 1 variant of the gem modules (Editor, Server, Client, Builder) to " - "add to your targets, using the VARIANTS keyword") + # Backwards-Compatibility - Delegate any TARGETS and VARIANTS arguments to the ly_set_gem_variant_to_load + # command. That command is used to associate TARGETS with the list of Gem Variants they desire to use + if (ly_enable_gems_TARGETS AND ly_enable_gems_VARIANTS) + message(DEPRECATION "The TARGETS and VARIANTS arguments to \"${CMAKE_CURRENT_FUNCTION}\" is deprecated.\n" + "Please use the \"ly_set_gem_variant_to_load\" function directly to associate a Target with a Gem Variant.\n" + "This function will forward the TARGETS and VARIANTS arguments to \"ly_set_gem_variant_to_load\" for now," + " but this functionality will be removed.") + ly_set_gem_variant_to_load(TARGETS ${ly_enable_gems_TARGETS} VARIANTS ${ly_enable_gems_VARIANTS}) endif() if ((NOT ly_enable_gems_GEMS AND NOT ly_enable_gems_GEM_FILE) OR (ly_enable_gems_GEMS AND ly_enable_gems_GEM_FILE)) @@ -153,103 +202,126 @@ function(ly_enable_gems) endif() # all the actual work has to be done later. - foreach(target_name ${ly_enable_gems_TARGETS}) - foreach(variant_name ${ly_enable_gems_VARIANTS}) - set_property(GLOBAL APPEND PROPERTY LY_DELAYED_ENABLE_GEMS "${ly_enable_gems_PROJECT_NAME},${target_name},${variant_name}") - define_property(GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_"${ly_enable_gems_PROJECT_NAME},${target_name},${variant_name}" - BRIEF_DOCS "List of gem names to evaluate variants against" FULL_DOCS "Names of gems that will be paired with the variant name - to determine if it is valid target that should be added as an application dynamic load dependency") - set_property(GLOBAL APPEND PROPERTY LY_DELAYED_ENABLE_GEMS_"${ly_enable_gems_PROJECT_NAME},${target_name},${variant_name}" ${ly_enable_gems_GEMS}) - endforeach() - endforeach() + set_property(GLOBAL APPEND PROPERTY LY_DELAYED_ENABLE_GEMS "${ly_enable_gems_PROJECT_NAME}") + define_property(GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_"${ly_enable_gems_PROJECT_NAME}" + BRIEF_DOCS "List of gem names to evaluate variants against" FULL_DOCS "Names of gems that will be paired with the variant name + to determine if it is valid target that should be added as an application dynamic load dependency") + set_property(GLOBAL APPEND PROPERTY LY_DELAYED_ENABLE_GEMS_"${ly_enable_gems_PROJECT_NAME}" ${ly_enable_gems_GEMS}) # Store off the arguments used by ly_enable_gems into a DIRECTORY property # This will be used to re-create the ly_enable_gems call in the generated CMakeLists.txt at the INSTALL step # Replace the CMake list separator with a space to replicate the space separated TARGETS arguments if(NOT ly_enable_gems_PROJECT_NAME STREQUAL "__NOPROJECT__") - set(replicated_project_name ${ly_enable_gems_PROJECT_NAME}) + set(replicated_project_name PROJECT_NAME ${ly_enable_gems_PROJECT_NAME}) endif() # The GEM_FILE file is used to populate the GEMS argument via the ENABLED_GEMS variable in the file. # Furthermore the GEM_FILE itself is not copied over to the install layout, so make its argument entry blank and use the list of GEMS # stored in ly_enable_gems_GEMS - string(REPLACE ";" " " enable_gems_args "${replicated_project_name},${ly_enable_gems_GEMS},,${ly_enable_gems_VARIANTS},${ly_enable_gems_TARGETS}") + unset(enable_gems_args) + list(APPEND enable_gems_args + ${replicated_project_name} + GEMS ${ly_enable_gems_GEMS}) + list(JOIN enable_gems_args " " enable_gems_args) set_property(DIRECTORY APPEND PROPERTY LY_ENABLE_GEMS_ARGUMENTS "${enable_gems_args}") endfunction() + +function(ly_add_gem_dependencies_to_project_variants) + set(options) + set(oneValueArgs PROJECT_NAME TARGET VARIANT) + set(multiValueArgs GEM_DEPENDENCIES) + + cmake_parse_arguments(ly_add_gem_dependencies "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if (NOT ly_add_gem_dependencies_PROJECT_NAME) + message(FATAL_ERROR "Missing required PROJECT_NAME argument which is used to determine gem load prefix") + endif() + if (NOT ly_add_gem_dependencies_TARGET) + message(FATAL_ERROR "Missing required TARGET argument ") + endif() + if (NOT ly_add_gem_dependencies_VARIANT) + message(FATAL_ERROR "Missing required gem VARIANT argument needed to determine which gem variants to load for the target") + endif() + + if(${ly_add_gem_dependencies_PROJECT_NAME} STREQUAL "__NOPROJECT__") + # special case, apply to all + unset(PREFIX_CLAUSE) + else() + set(PREFIX_CLAUSE "PREFIX;${ly_add_gem_dependencies_PROJECT_NAME}") + endif() + + # apply the list of gem targets. Adding a gem really just means adding the appropriate dependency. + foreach(gem_name ${ly_add_gem_dependencies_GEM_DEPENDENCIES}) + set(gem_target ${gem_name}.${ly_add_gem_dependencies_VARIANT}) + + # if the target exists, add it. + if (TARGET ${gem_target}) + # Dealias actual target + ly_de_alias_target(${gem_target} dealiased_gem_target) + ly_add_target_dependencies( + ${PREFIX_CLAUSE} + TARGETS ${ly_add_gem_dependencies_TARGET} + DEPENDENT_TARGETS ${dealiased_gem_target}) + endif() + endforeach() +endfunction() + # call this before runtime dependencies are used to add any relevant targets # saved by the above function function(ly_enable_gems_delayed) - get_property(ly_delayed_enable_gems GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS) - foreach(project_target_variant ${ly_delayed_enable_gems}) - # we expect a colon separated list of - # PROJECT_NAME,target_name,variant_name - string(REPLACE "," ";" project_target_variant_list "${project_target_variant}") - list(LENGTH project_target_variant_list project_target_variant_length) - if(project_target_variant_length EQUAL 0) - continue() - endif() - - if(NOT project_target_variant_length EQUAL 3) - message(FATAL_ERROR "Invalid specification of gems, expected 'project','target','variant' and got ${project_target_variant}") - endif() - - list(POP_BACK project_target_variant_list variant) - list(POP_BACK project_target_variant_list target) - list(POP_BACK project_target_variant_list project) - - get_property(gem_dependencies GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_"${project_target_variant}") - if (NOT gem_dependencies) - get_property(gem_dependencies_defined GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_"${project_target_variant}" DEFINED) - if (gem_dependencies_defined) - # special case, if the LY_DELAYED_ENABLE_GEMS_"${project_target_variant}" property is DEFINED - # but empty, add an entry to the LY_DELAYED_LOAD_DEPENDENCIES to have the - # cmake_dependencies.*.setreg file for the (project, target) tuple to be regenerated - # This is needed if the ENABLED_GEMS list for a project goes from >0 to 0. In this case - # the cmake_dependencies would have a stale list of gems to load unless it is regenerated - get_property(delayed_load_target_set GLOBAL PROPERTY LY_DELAYED_LOAD_"${project},${target}" SET) - if(NOT delayed_load_target_set) - set_property(GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_DEPENDENCIES "${project},${target}") - set_property(GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_"${project},${target}" "") - endif() - endif() - # Continue to the next iteration loop regardless as there are no gem dependencies - continue() - endif() - - if(${project} STREQUAL "__NOPROJECT__") - # special case, apply to all - unset(PREFIX_CLAUSE) - else() - set(PREFIX_CLAUSE "PREFIX;${project}") - endif() + # Query the list of targets that are associated with a gem variant + get_property(targets_with_variants GLOBAL PROPERTY LY_TARGETS_WITH_GEM_VARIANTS) + # Query the projects that have made calls to ly_enable_gems + get_property(enable_gem_projects GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS) + foreach(target ${targets_with_variants}) if (NOT TARGET ${target}) - message(FATAL_ERROR "ly_enable_gems specified TARGET '${target}' but no such target was found.") + message(FATAL_ERROR "ly_set_gem_variant_to_load specified TARGET '${target}' but no such target was found.") endif() - # apply the list of gem targets. Adding a gem really just means adding the appropriate dependency. - foreach(gem_name ${gem_dependencies}) - # the gem name may already have a namespace. If it does, we use that one - ly_strip_target_namespace(TARGET ${gem_name} OUTPUT_VARIABLE unaliased_gem_name) - if (${unaliased_gem_name} STREQUAL ${gem_name}) - # if stripping a namespace had no effect, it had no namespace - # and we supply the default Gem:: namespace. - set(gem_name_with_namespace Gem::${gem_name}) - else() - # if stripping the namespace had an effect then we use the original - # with the namespace, instead of assuming Gem:: - set(gem_name_with_namespace ${gem_name}) + # Lookup if the target is scoped to a project + # In that case the target can only use gem targets that is + # - not project specific: i.e "__NOPROJECT__" + # - or specific to the project + get_property(target_project_association TARGET ${target} PROPERTY LY_PROJECT_NAME) + + foreach(project ${enable_gem_projects}) + if (target_project_association AND + (NOT (project STREQUAL "__NOPROJECT__") AND NOT (project STREQUAL target_project_association))) + # Skip adding the gem dependencies to this target if it is associated with a project + # and the current project doesn't match + continue() endif() - - # if the target exists, add it. - if (TARGET ${gem_name_with_namespace}.${variant}) - ly_add_target_dependencies( - ${PREFIX_CLAUSE} - TARGETS ${target} - DEPENDENT_TARGETS ${gem_name_with_namespace}.${variant} - ) + + get_property(gem_dependencies GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_"${project}") + if (NOT gem_dependencies) + get_property(gem_dependencies_defined GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_"${project}" DEFINED) + if (gem_dependencies_defined) + # special case, if the LY_DELAYED_ENABLE_GEMS_"${project_target_variant}" property is DEFINED + # but empty, add an entry to the LY_DELAYED_LOAD_DEPENDENCIES to have the + # cmake_dependencies.*.setreg file for the (project, target) tuple to be regenerated + # This is needed if the ENABLED_GEMS list for a project goes from >0 to 0. In this case + # the cmake_dependencies would have a stale list of gems to load unless it is regenerated + get_property(delayed_load_target_set GLOBAL PROPERTY LY_DELAYED_LOAD_"${project},${target}" SET) + if(NOT delayed_load_target_set) + set_property(GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_DEPENDENCIES "${project},${target}") + set_property(GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_"${project},${target}" "") + endif() + endif() + # Continue to the next iteration loop regardless as there are no gem dependencies + continue() endif() + + # Gather the Gem variants associated with this target and iterate over them to combine them with the enabled + # gems for the each project + get_property(target_gem_variants GLOBAL PROPERTY LY_GEM_VARIANTS_"${target}") + foreach(variant ${target_gem_variants}) + ly_add_gem_dependencies_to_project_variants( + PROJECT_NAME ${project} + TARGET ${target} + VARIANT ${variant} + GEM_DEPENDENCIES ${gem_dependencies}) + endforeach() endforeach() endforeach() endfunction() diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index 3dfef0bbbf..53895c300f 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -330,28 +330,44 @@ function(ly_add_target) set(runtime_dependencies_list SHARED MODULE EXECUTABLE APPLICATION) if(NOT ly_add_target_IMPORTED AND linking_options IN_LIST runtime_dependencies_list) - # the stamp file will be the one that triggers the execution of the custom rule. At the end - # of running the copy of runtime dependencies, the stamp file is touched so the timestamp is updated. - # Adding a config as part of the name since the stamp file is added to the VS project. - # Note the STAMP_OUTPUT_FILE need to match with the one used in runtime dependencies (e.g. RuntimeDependencies_common.cmake) - set(STAMP_OUTPUT_FILE ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${ly_add_target_NAME}_$.stamp) - add_custom_command( - OUTPUT ${STAMP_OUTPUT_FILE} - DEPENDS "$>" - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${ly_add_target_NAME}.cmake - COMMENT "Copying ${ly_add_target_NAME} runtime dependencies to output..." - VERBATIM - ) + # XCode generator doesnt support different source files per configuration, so we cannot have + # the runtime dependencies using file-tracking, instead, we will have them as a post build step + if(CMAKE_GENERATOR MATCHES Xcode) + + add_custom_command(TARGET ${ly_add_target_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${ly_add_target_NAME}.cmake + COMMENT "Copying ${ly_add_target_NAME} runtime dependencies to output..." + DEPENDS ${CMAKE_BINARY_DIR}/runtime_dependencies/${ly_add_target_NAME}.cmake + COMMENT "Copying runtime dependencies..." + VERBATIM + ) - # Unfortunately the VS generator cannot deal with generation expressions as part of the file name, wrapping the - # stamp file on each configuration so it gets properly excluded by the generator - unset(stamp_files_per_config) - foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) - set(stamp_file_conf ${CMAKE_BINARY_DIR}/runtime_dependencies/${conf}/${ly_add_target_NAME}_${conf}.stamp) - set_source_files_properties(${stamp_file_conf} PROPERTIES GENERATED TRUE SKIP_AUTOGEN TRUE) - list(APPEND stamp_files_per_config $<$:${stamp_file_conf}>) - endforeach() - target_sources(${ly_add_target_NAME} PRIVATE ${stamp_files_per_config}) + else() + + # the stamp file will be the one that triggers the execution of the custom rule. At the end + # of running the copy of runtime dependencies, the stamp file is touched so the timestamp is updated. + # Adding a config as part of the name since the stamp file is added to the VS project. + # Note the STAMP_OUTPUT_FILE need to match with the one used in runtime dependencies (e.g. RuntimeDependencies_common.cmake) + set(STAMP_OUTPUT_FILE ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${ly_add_target_NAME}_$.stamp) + add_custom_command( + OUTPUT ${STAMP_OUTPUT_FILE} + DEPENDS "$>" + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${ly_add_target_NAME}.cmake + COMMENT "Copying ${ly_add_target_NAME} runtime dependencies to output..." + VERBATIM + ) + + # Unfortunately the VS generator cannot deal with generation expressions as part of the file name, wrapping the + # stamp file on each configuration so it gets properly excluded by the generator + unset(stamp_files_per_config) + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + set(stamp_file_conf ${CMAKE_BINARY_DIR}/runtime_dependencies/${conf}/${ly_add_target_NAME}_${conf}.stamp) + set_source_files_properties(${stamp_file_conf} PROPERTIES GENERATED TRUE SKIP_AUTOGEN TRUE) + list(APPEND stamp_files_per_config $<$:${stamp_file_conf}>) + endforeach() + target_sources(${ly_add_target_NAME} PRIVATE ${stamp_files_per_config}) + + endif() endif() diff --git a/cmake/Platform/Common/Clang/Configurations_clang.cmake b/cmake/Platform/Common/Clang/Configurations_clang.cmake index 17a89fc1cd..02a94f4e72 100644 --- a/cmake/Platform/Common/Clang/Configurations_clang.cmake +++ b/cmake/Platform/Common/Clang/Configurations_clang.cmake @@ -18,23 +18,13 @@ ly_append_configurations_options( # Disabled warnings (please do not disable any others without first consulting ly-warnings) -Wrange-loop-analysis - -Wno-unknown-warning-option - "-Wno-#pragma-messages" - -Wno-absolute-value - -Wno-dynamic-class-memaccess + -Wno-unknown-warning-option # used as a way to mark warnings that are MSVC only -Wno-format-security -Wno-inconsistent-missing-override - -Wno-invalid-offsetof - -Wno-multichar -Wno-parentheses -Wno-reorder - -Wno-self-assign -Wno-switch - -Wno-tautological-compare -Wno-undefined-var-template - -Wno-unknown-pragmas - # Workaround for compiler seeing file case differently from what OS show in console. - -Wno-nonportable-include-path COMPILATION_DEBUG -O0 # No optimization diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 0bd598f70e..5010760fad 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -138,16 +138,20 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar string(REPLACE "_LIBRARY" "" TARGET_TYPE_PLACEHOLDER ${target_type}) # For HEADER_ONLY libs we end up generating "INTERFACE" libraries, need to specify HEADERONLY instead string(REPLACE "INTERFACE" "HEADERONLY" TARGET_TYPE_PLACEHOLDER ${TARGET_TYPE_PLACEHOLDER}) - if(TARGET_TYPE_PLACEHOLDER STREQUAL "MODULE") + # In non-monolithic mode, gem targets are MODULE libraries, In monolithic mode gem targets are STATIC libraries + set(GEM_LIBRARY_TYPES "MODULE" "STATIC") + if(TARGET_TYPE_PLACEHOLDER IN_LIST GEM_LIBRARY_TYPES) get_target_property(gem_module ${TARGET_NAME} GEM_MODULE) if(gem_module) set(TARGET_TYPE_PLACEHOLDER "GEM_MODULE") endif() endif() + string(REPEAT " " 12 PLACEHOLDER_INDENT) get_target_property(COMPILE_DEFINITIONS_PLACEHOLDER ${TARGET_NAME} INTERFACE_COMPILE_DEFINITIONS) if(COMPILE_DEFINITIONS_PLACEHOLDER) - string(REPLACE ";" "\n" COMPILE_DEFINITIONS_PLACEHOLDER "${COMPILE_DEFINITIONS_PLACEHOLDER}") + set(COMPILE_DEFINITIONS_PLACEHOLDER "${PLACEHOLDER_INDENT}${COMPILE_DEFINITIONS_PLACEHOLDER}") + list(JOIN COMPILE_DEFINITIONS_PLACEHOLDER "\n${PLACEHOLDER_INDENT}" COMPILE_DEFINITIONS_PLACEHOLDER) else() unset(COMPILE_DEFINITIONS_PLACEHOLDER) endif() @@ -159,25 +163,28 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar if(include_genex_expr STREQUAL include) # only for cases where there are no generation expressions # Make the include path relative to the source dir where the target will be declared cmake_path(RELATIVE_PATH include BASE_DIRECTORY ${absolute_target_source_dir} OUTPUT_VARIABLE target_include) - string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "${target_include}\n") + string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "${PLACEHOLDER_INDENT}${target_include}\n") endif() endforeach() endif() + string(REPEAT " " 8 PLACEHOLDER_INDENT) get_target_property(RUNTIME_DEPENDENCIES_PLACEHOLDER ${TARGET_NAME} MANUALLY_ADDED_DEPENDENCIES) if(RUNTIME_DEPENDENCIES_PLACEHOLDER) # not found properties return the name of the variable with a "-NOTFOUND" at the end, here we set it to empty if not found - string(REPLACE ";" "\n" RUNTIME_DEPENDENCIES_PLACEHOLDER "${RUNTIME_DEPENDENCIES_PLACEHOLDER}") + set(RUNTIME_DEPENDENCIES_PLACEHOLDER "${PLACEHOLDER_INDENT}${RUNTIME_DEPENDENCIES_PLACEHOLDER}") + list(JOIN RUNTIME_DEPENDENCIES_PLACEHOLDER "\n${PLACEHOLDER_INDENT}" RUNTIME_DEPENDENCIES_PLACEHOLDER) else() unset(RUNTIME_DEPENDENCIES_PLACEHOLDER) endif() + string(REPEAT " " 12 PLACEHOLDER_INDENT) get_target_property(inteface_build_dependencies_props ${TARGET_NAME} INTERFACE_LINK_LIBRARIES) unset(INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER) if(inteface_build_dependencies_props) foreach(build_dependency ${inteface_build_dependencies_props}) # Skip wrapping produced when targets are not created in the same directory if(NOT ${build_dependency} MATCHES "^::@") - list(APPEND INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "${build_dependency}") + list(APPEND INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "${PLACEHOLDER_INDENT}${build_dependency}") endif() endforeach() endif() @@ -187,12 +194,19 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar foreach(build_dependency ${private_build_dependencies_props}) # Skip wrapping produced when targets are not created in the same directory if(NOT ${build_dependency} MATCHES "^::@") - list(APPEND INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "${build_dependency}") + list(APPEND INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "${PLACEHOLDER_INDENT}${build_dependency}") endif() endforeach() endif() list(REMOVE_DUPLICATES INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER) - string(REPLACE ";" "\n" INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "${INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER}") + list(JOIN INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "\n" INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER) + + string(REPEAT " " 8 PLACEHOLDER_INDENT) + # If a target has an LY_PROJECT_NAME property, forward that property to new target + get_target_property(target_project_association ${TARGET_NAME} LY_PROJECT_NAME) + if(target_project_association) + list(APPEND TARGET_PROPERTIES_PLACEHOLDER "${PLACEHOLDER_INDENT}LY_PROJECT_NAME ${target_project_association}") + endif() # If the target is an executable/application, add a custom target so we can debug the target in project-centric workflow if(should_create_helper) @@ -288,44 +302,9 @@ function(ly_setup_subdirectory absolute_target_source_dir) string(APPEND all_configured_targets "${configured_target}") endforeach() - # Replicate the ly_create_alias() calls based on the SOURCE_DIR for each target that generates an installed CMakeLists.txt - string(JOIN "\n" create_alias_template - "if(NOT TARGET @ALIAS_NAME@)" - " ly_create_alias(NAME @ALIAS_NAME@ NAMESPACE @ALIAS_NAMESPACE@ TARGETS @ALIAS_TARGETS@)" - "endif()" - "" - ) - get_property(create_alias_commands_arg_list DIRECTORY ${absolute_target_source_dir} PROPERTY LY_CREATE_ALIAS_ARGUMENTS) - foreach(create_alias_single_command_arg_list ${create_alias_commands_arg_list}) - # Split the ly_create_alias arguments back out based on commas - string(REPLACE "," ";" create_alias_single_command_arg_list "${create_alias_single_command_arg_list}") - list(POP_FRONT create_alias_single_command_arg_list ALIAS_NAME) - list(POP_FRONT create_alias_single_command_arg_list ALIAS_NAMESPACE) - # The rest of the list are the target dependencies - set(ALIAS_TARGETS ${create_alias_single_command_arg_list}) - string(CONFIGURE "${create_alias_template}" create_alias_command @ONLY) - string(APPEND CREATE_ALIASES_PLACEHOLDER ${create_alias_command}) - endforeach() - - - # Reproduce the ly_enable_gems() calls made in the the SOURCE_DIR for this target into the CMakeLists.txt that - # is about to be generated - set(enable_gems_template "ly_enable_gems(@enable_gem_PROJECT_NAME@ @enable_gem_GEMS@ @enable_gem_GEM_FILE@ @enable_gem_VARIANTS@ @enable_gem_TARGETS@)\n") - get_property(enable_gems_commands_arg_list DIRECTORY ${absolute_target_source_dir} PROPERTY LY_ENABLE_GEMS_ARGUMENTS) - foreach(enable_gems_single_command_arg_list ${enable_gems_commands_arg_list}) - # Split the ly_enable_gems arguments back out based on commas - string(REPLACE "," ";" enable_gems_single_command_arg_list "${enable_gems_single_command_arg_list}") - foreach(enable_gem_arg_kw IN ITEMS PROJECT_NAME GEMS GEM_FILE VARIANTS TARGETS) - list(POP_FRONT enable_gems_single_command_arg_list enable_gem_${enable_gem_arg_kw}) - if(enable_gem_${enable_gem_arg_kw}) - # if the argument exist append to argument keyword to the front - string(PREPEND enable_gem_${enable_gem_arg_kw} "${enable_gem_arg_kw} ") - endif() - endforeach() - - string(CONFIGURE "${enable_gems_template}" enable_gems_command @ONLY) - string(APPEND ENABLE_GEMS_PLACEHOLDER ${enable_gems_command}) - endforeach() + ly_setup_subdirectory_create_alias("${absolute_target_source_dir}" CREATE_ALIASES_PLACEHOLDER) + ly_setup_subdirectory_set_gem_variant_to_load("${absolute_target_source_dir}" GEM_VARIANT_TO_LOAD_PLACEHOLDER) + ly_setup_subdirectory_enable_gems("${absolute_target_source_dir}" ENABLE_GEMS_PLACEHOLDER) ly_file_read(${LY_ROOT_FOLDER}/cmake/install/Copyright.in cmake_copyright_comment) @@ -337,6 +316,7 @@ function(ly_setup_subdirectory absolute_target_source_dir) "${all_configured_targets}" "\n" "${CREATE_ALIASES_PLACEHOLDER}" + "${GEM_VARIANT_TO_LOAD_PLACEHOLDER}" "${ENABLE_GEMS_PLACEHOLDER}" ) @@ -591,3 +571,58 @@ function(ly_setup_assets) endforeach() endfunction() + + +#! ly_setup_subdirectory_create_alias: Replicates the call to the `ly_create_alias` function +#! within the generated CMakeLists.txt in the same relative install layout directory +function(ly_setup_subdirectory_create_alias absolute_target_source_dir output_script) + # Replicate the create_alias() calls made in the SOURCE_DIR into the generated CMakeLists.txt + string(JOIN "\n" create_alias_template + "if(NOT TARGET @alias_name@)" + " ly_create_alias(@create_alias_args@)" + "endif()" + "") + + unset(${output_script} PARENT_SCOPE) + get_property(create_alias_args_list DIRECTORY ${absolute_target_source_dir} PROPERTY LY_CREATE_ALIAS_ARGUMENTS) + foreach(create_alias_args IN LISTS create_alias_args_list) + # Create a list out of the comma separated arguments and store it into the same variable + string(REPLACE "," ";" create_alias_args ${create_alias_args}) + # The first argument of the create alias argument list is the ALIAS NAME so pop it from the list + # It is used to protect against registering the same alias twice + list(POP_FRONT create_alias_args alias_name) + string(CONFIGURE "${create_alias_template}" create_alias_command @ONLY) + string(APPEND create_alias_calls ${create_alias_command}) + endforeach() + set(${output_script} ${create_alias_calls} PARENT_SCOPE) +endfunction() + +#! ly_setup_subdirectory_set_gem_variant_to_load: Replicates the call to the `ly_set_gem_variant_to_load` function +#! within the generated CMakeLists.txt in the same relative install layout directory +function(ly_setup_subdirectory_set_gem_variant_to_load absolute_target_source_dir output_script) + # Replicate the ly_set_gem_variant_to_load() calls made in the SOURCE_DIR for into the generated CMakeLists.txt + set(set_gem_variant_args_template "ly_set_gem_variant_to_load(@set_gem_variant_args@)\n") + + unset(${output_script} PARENT_SCOPE) + get_property(set_gem_variant_args_lists DIRECTORY ${absolute_target_source_dir} PROPERTY LY_SET_GEM_VARIANT_TO_LOAD_ARGUMENTS) + foreach(set_gem_variant_args IN LISTS set_gem_variant_args_lists) + string(CONFIGURE "${set_gem_variant_args_template}" set_gem_variant_to_load_command @ONLY) + string(APPEND set_gem_variant_calls ${set_gem_variant_to_load_command}) + endforeach() + set(${output_script} ${set_gem_variant_calls} PARENT_SCOPE) +endfunction() + +#! ly_setup_subdirectory_enable_gems: Replicates the call to the `ly_enable_gems` function +#! within the generated CMakeLists.txt in the same relative install layout directory +function(ly_setup_subdirectory_enable_gems absolute_target_source_dir output_script) + # Replicate the ly_set_gem_variant_to_load() calls made in the SOURCE_DIR into the generated CMakeLists.txt + set(enable_gems_template "ly_enable_gems(@enable_gems_args@)\n") + + unset(${output_script} PARENT_SCOPE) + get_property(enable_gems_args_list DIRECTORY ${absolute_target_source_dir} PROPERTY LY_ENABLE_GEMS_ARGUMENTS) + foreach(enable_gems_args IN LISTS enable_gems_args_list) + string(CONFIGURE "${enable_gems_template}" enable_gems_command @ONLY) + string(APPEND enable_gems_calls ${enable_gems_command}) + endforeach() + set(${output_script} ${enable_gems_calls} PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/cmake/Platform/Common/MSVC/Configurations_msvc.cmake b/cmake/Platform/Common/MSVC/Configurations_msvc.cmake index 7c7120fe15..647ced54a2 100644 --- a/cmake/Platform/Common/MSVC/Configurations_msvc.cmake +++ b/cmake/Platform/Common/MSVC/Configurations_msvc.cmake @@ -33,6 +33,7 @@ ly_append_configurations_options( /nologo # Suppress Copyright and version number message /W4 # Warning level 4 /WX # Warnings as errors + /permissive- # Conformance with standard # Disabling some warnings /wd4201 # nonstandard extension used: nameless struct/union. This actually became part of the C++11 std, MS has an open issue: https://developercommunity.visualstudio.com/t/warning-level-4-generates-a-bogus-warning-c4201-no/103064 diff --git a/cmake/Platform/Linux/Install_linux.cmake b/cmake/Platform/Linux/Install_linux.cmake index b3e2093b65..87713fa5d6 100644 --- a/cmake/Platform/Linux/Install_linux.cmake +++ b/cmake/Platform/Linux/Install_linux.cmake @@ -14,6 +14,9 @@ function(ly_copy source_file target_directory) if("${source_file}" MATCHES "qt/plugins" AND "${target_filename_ext}" STREQUAL ".so") get_filename_component(target_filename "${source_file}" NAME) file(RPATH_CHANGE FILE "${target_directory}/${target_filename}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..") + elseif("${source_file}" MATCHES "lrelease") + get_filename_component(target_filename "${source_file}" NAME) + file(RPATH_CHANGE FILE "${target_directory}/${target_filename}" OLD_RPATH "\$ORIGIN/../lib" NEW_RPATH "\$ORIGIN") endif() endfunction()]]) diff --git a/cmake/Projects.cmake b/cmake/Projects.cmake index 3f8c4ffc41..6e5b5c5f78 100644 --- a/cmake/Projects.cmake +++ b/cmake/Projects.cmake @@ -53,7 +53,7 @@ function(ly_add_target_dependencies) # Append the DEPENDENT_TARGETS to the list of ALL_GEM_DEPENDENCIES list(APPEND ALL_GEM_DEPENDENCIES ${ly_add_gem_dependencies_DEPENDENT_TARGETS}) - # for each target, add the dependencies and generate gems json + # for each target, add the dependencies and generate setreg json with the list of gems to load foreach(target ${ly_add_gem_dependencies_TARGETS}) ly_add_dependencies(${target} ${ALL_GEM_DEPENDENCIES}) @@ -69,39 +69,6 @@ function(ly_add_target_dependencies) endforeach() endfunction() -#! ly_add_project_dependencies: adds the dependencies to runtime and tools for this project. -# -# Each project may have dependencies to gems. To properly define these dependencies, we are making the project to define -# through a "files list" cmake file the dependencies to the different targets. -# So for example, the game's runtime dependencies are associated to the project's launcher; the game's tools dependencies -# are associated to the asset processor; etc -# -# \arg:PROJECT_NAME name of the game project -# \arg:TARGETS names of the targets to associate the dependencies to -# \arg:DEPENDENCIES_FILES file(s) that contains the runtime dependencies the TARGETS will be associated to -# \arg:DEPENDENT_TARGETS additional list of targets should be added as load-time dependencies for the TARGETS list -# -function(ly_add_project_dependencies) - - set(options) - set(oneValueArgs PROJECT_NAME) - set(multiValueArgs TARGETS DEPENDENCIES_FILES DEPENDENT_TARGETS) - - cmake_parse_arguments(ly_add_project_dependencies "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # Validate input arguments - if(NOT ly_add_project_dependencies_PROJECT_NAME) - message(FATAL_ERROR "PROJECT_NAME parameter missing. If not project name is needed, then call ly_add_target_dependencies directly") - endif() - - ly_add_target_dependencies( - PREFIX ${ly_add_project_dependencies_PROJECT_NAME} - TARGETS ${ly_add_project_dependencies_TARGETS} - DEPENDENCIES_FILES ${ly_add_project_dependencies_DEPENDENCIES_FILES} - DEPENDENT_TARGETS ${ly_add_project_dependencies_DEPENDENT_TARGETS} - ) -endfunction() - #template for generating the project build_path setreg set(project_build_path_template [[ diff --git a/cmake/SettingsRegistry.cmake b/cmake/SettingsRegistry.cmake index ebf2254dc6..58beba089c 100644 --- a/cmake/SettingsRegistry.cmake +++ b/cmake/SettingsRegistry.cmake @@ -28,7 +28,7 @@ set(gems_json_template [[ string(APPEND gem_module_template [=[ "@stripped_gem_target@":]=] "\n" [=[ {]=] "\n" -[=[$<$,INTERFACE_LIBRARY>>: "Modules":["$"]]=] "$\n>" +[=[$<$,MODULE_LIBRARY$SHARED_LIBRARY>: "Modules":["$"]]=] "$\n>" [=[ "SourcePaths":["@gem_module_root_relative_to_engine_root@"]]=] "\n" [=[ }]=] ) @@ -87,7 +87,7 @@ endfunction() # # \arg:gem_target(TARGET) - Target to look upwards from using its SOURCE_DIR property function(ly_get_gem_module_root output_gem_module_root gem_target) - unset(gem_module_roots) + unset(${output_gem_module_root} PARENT_SCOPE) get_property(gem_source_dir TARGET ${gem_target} PROPERTY SOURCE_DIR) if(gem_source_dir) @@ -96,8 +96,8 @@ function(ly_get_gem_module_root output_gem_module_root gem_target) while(NOT EXISTS ${candidate_gem_dir}/gem.json) get_filename_component(parent_dir ${candidate_gem_dir} DIRECTORY) if (${parent_dir} STREQUAL ${candidate_gem_dir}) - message(WARNING "Did not find a gem.json while processing GEM_MODULE target ${gem_target}!") - break() + # "Did not find a gem.json while processing GEM_MODULE target ${gem_target}!" + return() endif() set(candidate_gem_dir ${parent_dir}) endwhile() @@ -160,11 +160,15 @@ function(ly_delayed_generate_settings_registry) endif() ly_get_gem_module_root(gem_module_root ${gem_target}) + if (NOT gem_module_root) + # If the target doesn't have a gem.json, skip it + continue() + endif() file(RELATIVE_PATH gem_module_root_relative_to_engine_root ${LY_ROOT_FOLDER} ${gem_module_root}) # De-alias namespace from gem targets before configuring them into the json template ly_de_alias_target(${gem_target} stripped_gem_target) - string(CONFIGURE ${gem_module_template} gem_module_json @ONLY) + string(CONFIGURE "${gem_module_template}" gem_module_json @ONLY) list(APPEND target_gem_dependencies_names ${gem_module_json}) endforeach() @@ -177,7 +181,8 @@ function(ly_delayed_generate_settings_registry) string(CONFIGURE ${gems_json_template} gem_json @ONLY) get_target_property(is_imported ${target} IMPORTED) get_target_property(target_type ${target} TYPE) - if(is_imported OR target_type STREQUAL UTILITY) + set(non_loadable_types "UTILITY" "INTERFACE_LIBRARY" "STATIC_LIBRARY") + if(is_imported OR (target_type IN_LIST non_loadable_types)) unset(target_dir) foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) string(TOUPPER ${conf} UCONF) diff --git a/cmake/install/InstalledTarget.in b/cmake/install/InstalledTarget.in index a4f4fa4763..2095211bb2 100644 --- a/cmake/install/InstalledTarget.in +++ b/cmake/install/InstalledTarget.in @@ -15,6 +15,8 @@ ly_add_target( @INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER@ RUNTIME_DEPENDENCIES @RUNTIME_DEPENDENCIES_PLACEHOLDER@ + TARGET_PROPERTIES +@TARGET_PROPERTIES_PLACEHOLDER@ ) @TARGET_RUN_HELPER@ diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index b2c06bc720..328e5f8df7 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -6,7 +6,7 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - +import groovy.json.JsonOutput PIPELINE_CONFIG_FILE = 'scripts/build/Jenkins/lumberyard.json' INCREMENTAL_BUILD_SCRIPT_PATH = 'scripts/build/bootstrap/incremental_build_util.py' @@ -383,6 +383,25 @@ def TestMetrics(Map pipelineConfig, String workspace, String branchName, String } } +def BenchmarkMetrics(Map pipelineConfig, String workspace, String branchName, String outputDirectory) { + catchError(buildResult: null, stageResult: null) { + def cmakeBuildDir = [workspace, ENGINE_REPOSITORY_NAME, outputDirectory].join('/') + dir("${workspace}/${ENGINE_REPOSITORY_NAME}") { + checkout scm: [ + $class: 'GitSCM', + branches: [[name: '*/main']], + extensions: [ + [$class: 'AuthorInChangelog'], + [$class: 'RelativeTargetDirectory', relativeTargetDir: 'mars'] + ], + userRemoteConfigs: [[url: "${env.MARS_REPO}", name: 'mars', credentialsId: "${env.GITHUB_USER}"]] + ] + def command = "${pipelineConfig.PYTHON_DIR}/python.cmd -u mars/scripts/python/benchmark_scraper.py ${cmakeBuildDir} ${branchName}" + palSh(command, "Publishing Benchmark Metrics") + } + } +} + def ExportTestResults(Map options, String platform, String type, String workspace, Map params) { catchError(message: "Error exporting tests results (this won't fail the build)", buildResult: 'SUCCESS', stageResult: 'FAILURE') { def o3deroot = "${workspace}/${ENGINE_REPOSITORY_NAME}" @@ -438,6 +457,7 @@ def CreateTestMetricsStage(Map pipelineConfig, String branchName, Map environmen return { stage("${buildJobName}_metrics") { TestMetrics(pipelineConfig, environmentVars['WORKSPACE'], branchName, env.DEFAULT_REPOSITORY_NAME, buildJobName, outputDirectory, configuration) + BenchmarkMetrics(pipelineConfig, environmentVars['WORKSPACE'], branchName, outputDirectory) } } } @@ -750,6 +770,14 @@ finally { } else { buildFailure = tm('${BUILD_FAILURE_ANALYZER}') emailBody = "${BUILD_URL}\n${buildFailure}!" + if(env.SNS_TOPIC_BUILD_FAILURE) { + message_json = ["build_url":env.BUILD_URL, "repository_name":env.REPOSITORY_NAME, "branch_name":env.BRANCH_NAME, "build_failure":buildFailure] + snsPublish( + topicArn: env.SNS_TOPIC_BUILD_FAILURE, + subject:'Build Failure', + message:JsonOutput.toJson(message_json) + ) + } } emailext ( body: "${emailBody}", diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh index 478f3a37dc..88b9f9b505 100755 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh @@ -112,6 +112,23 @@ else fi +# +# Add Amazon Corretto repository to install the necessary JDK for Jenkins and Android +# + +CORRETTO_REPO_COUNT=$(cat /etc/apt/sources.list | grep ^dev | grep https://apt.corretto.aws | wc -l) + +if [ $CORRETTO -eq 0 ] +then + echo Adding Corretto Repository for JDK + + wget -O- https://apt.corretto.aws/corretto.key | apt-key add - + add-apt-repository 'deb https://apt.corretto.aws stable main' + apt-get update +else + echo Corretto repo already set +fi + # Read from the package list and process each package PACKAGE_FILE_LIST=package-list.ubuntu-$UBUNTU_DISTRO.txt diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu.sh index 60f0114872..d83ece9d47 100755 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu.sh @@ -40,6 +40,13 @@ then exit 1 fi +# Add mountpoint for Jenkins +if [ ! -d /data ] +then + echo Data folder does not exist. Creating it. + mkdir /data + chown $USER /data +fi echo Packages and tools for O3DE setup complete exit 0 diff --git a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt index 9cc9d934c1..625909e214 100644 --- a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt +++ b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt @@ -4,6 +4,7 @@ cmake/3.20.1-0kitware1ubuntu18.04.1 # For cmake clang-6.0 # For Ninja Build System ninja-build # For the compiler and its dependencies +java-11-amazon-corretto-jdk # For Jenkins and Android # Build Libraries libglu1-mesa-dev # For Qt (GL dependency) diff --git a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt index d5a50cfa97..21c4755a2e 100644 --- a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt +++ b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt @@ -1,9 +1,10 @@ # Package list for Ubuntu 20.04 # Build Tools Packages -cmake/3.20.1-0kitware1ubuntu20.04.1 # For cmake -clang-6.0 # For Ninja Build System +cmake/3.21.1-0kitware1ubuntu20.04.1 # For cmake +clang-12 # For Ninja Build System ninja-build # For the compiler and its dependencies +java-11-amazon-corretto-jdk # For Jenkins and Android # Build Libraries libglu1-mesa-dev # For Qt (GL dependency) @@ -12,7 +13,6 @@ libxcb-xinput0 # For Qt plugins at runtime libfontconfig1-dev # For Qt plugins at runtime libcurl4-openssl-dev # For HttpRequestor libsdl2-dev # for WWise/Audio +libxkbcommon-dev zlib1g-dev mesa-common-dev - - diff --git a/scripts/commit_validation/commit_validation/tests/validators/test_az_trait_validator.py b/scripts/commit_validation/commit_validation/tests/validators/test_az_trait_validator.py deleted file mode 100755 index 9474fd00b6..0000000000 --- a/scripts/commit_validation/commit_validation/tests/validators/test_az_trait_validator.py +++ /dev/null @@ -1,92 +0,0 @@ -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -import unittest -from unittest.mock import patch, mock_open - -from commit_validation import pal_allowedlist -from commit_validation.tests.mocks.mock_commit import MockCommit -from commit_validation.validators.az_trait_validator import AzTraitValidator - -import pytest - - -class Test_AzTraitValidatorTests(): - def test_fileDoesntCheckAzTraitIsDefined_passes(self): - commit = MockCommit( - files=['someCppFile.cpp'], - file_diffs={ 'someCppFile.cpp' : ''} - ) - error_list = [] - assert AzTraitValidator().run(commit, error_list) - assert len(error_list) == 0, f"Unexpected errors: {error_list}" - - @pytest.mark.parametrize( - 'file_diffs,expect_success', [ - pytest.param('+This file does contain\n' - '+a trait existence check\n' - '+#ifdef AZ_TRAIT_USED_INCORRECTLY\n', - False, - id="AZ_TRAIT_inside_ifdef_fails" ), # gives the test a friendly name! - - pytest.param('+This file does contain\n' - '+a trait existence check\n' - '+#if defined(AZ_TRAIT_USED_INCORRECTLY)\n', - False, - id="AZ_TRAIT_inside_if_defined_fails" ), - - pytest.param('+This file does contain\n' - '+a trait existence check\n' - '+#ifndef AZ_TRAIT_USED_INCORRECTLY\n', - False, - id="AZ_TRAIT_inside_ifndef_fails" ), - - pytest.param('+This file contains a diff which REMOVES an incorrect usage\n' - '-#ifndef AZ_TRAIT_USED_INCORRECTLY\n', - True, - id="AZ_TRAIT_removed_in_diff_passes" ), - - pytest.param('+This file contains a diff which has an old already okayed usage\n' - '+which is not actually part of the diff.\n' - '#ifndef AZ_TRAIT_USED_INCORRECTLY\n', - True, - id="AZ_TRAIT_in_unmodified_section_passes"), - - pytest.param('+This file contains the correct usage\n' - '+#if AZ_TRAIT_USED_CORRECTLY\n', - True, - id="AZ_TRAIT_correct_usage_passes"), - ]) - def test_fileChecksAzTraitIsDefined(self, file_diffs, expect_success): - commit = MockCommit( - files=['someCppFile.cpp'], - file_diffs={ 'someCppFile.cpp' : file_diffs }) - - error_list = [] - if expect_success: - assert AzTraitValidator().run(commit, error_list) - assert len(error_list) == 0, f"Unexpected errors: {error_list}" - else: - assert not AzTraitValidator().run(commit, error_list) - assert len(error_list) != 0, f"Errors were expected but none were returned." - - def test_fileExtensionIgnored_passes(self): - commit = MockCommit(files=['someCppFile.waf_files']) - error_list = [] - assert AzTraitValidator().run(commit, error_list) - assert len(error_list) == 0, f"Unexpected errors: {error_list}" - - @patch('commit_validation.pal_allowedlist.load', return_value=pal_allowedlist.PALAllowedlist(['*/some/path/*'])) - def test_fileAllowedlisted_passes(self, mocked_load): - commit = MockCommit(files=['/path/to/some/path/someCppFile.cpp']) - error_list = [] - assert AzTraitValidator().run(commit, error_list) - assert len(error_list) == 0, f"Unexpected errors: {error_list}" - -if __name__ == '__main__': - unittest.main() diff --git a/scripts/commit_validation/commit_validation/validators/az_trait_validator.py b/scripts/commit_validation/commit_validation/validators/az_trait_validator.py deleted file mode 100755 index 595cea8720..0000000000 --- a/scripts/commit_validation/commit_validation/validators/az_trait_validator.py +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -import os -import re -from typing import Type, List - -import commit_validation.pal_allowedlist as pal_allowedlist -from commit_validation.commit_validation import Commit, CommitValidator, SOURCE_FILE_EXTENSIONS, VERBOSE - -ifdef_regex = re.compile(r'^\+\s*#\s*ifn?def\s+AZ_TRAIT_') -defined_regex = re.compile(r'\sdefined\s*\(\s*AZ_TRAIT_') - - -class AzTraitValidator(CommitValidator): - """A file-level validator that makes sure a file does not contain existence checks for AZ_TRAIT macros""" - - def __init__(self) -> None: - self.pal_allowedlist = pal_allowedlist.load() - - def run(self, commit: Commit, errors: List[str]) -> bool: - for file_name in commit.get_files(): - if os.path.splitext(file_name)[1].lower() not in SOURCE_FILE_EXTENSIONS: - if VERBOSE: print(f'{file_name}::{self.__class__.__name__} SKIPPED - File excluded based on extension.') - continue - if self.pal_allowedlist.is_match(file_name): - if VERBOSE: print(f'{file_name}::{self.__class__.__name__} SKIPPED - File excluded based on PAL allowedlist.') - continue - - file_diff = commit.get_file_diff(file_name) - previous_line_context = "" - - for line in file_diff.splitlines(): - # we only care about added lines. - if line.startswith('+'): - if ifdef_regex.search(line) or defined_regex.search(line): - error_message = str( - f'{file_name}::{self.__class__.__name__} FAILED - Source file contains an existence ' - f'check for an AZ_TRAIT macro in this code: \n' - f' {previous_line_context}\n' - f' ----> {line}\n' - f'Traits should be tested for true/false, since they are guaranteed to exist on all platforms.') - if VERBOSE: print(error_message) - errors.append(error_message) - previous_line_context = line - - return (not errors) - - -def get_validator() -> Type[AzTraitValidator]: - """Returns the validator class for this module""" - return AzTraitValidator