diff --git a/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Sandbox.py b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Sandbox.py index 5299e55a2b..54e3d8cb41 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Sandbox.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/TestSuite_Sandbox.py @@ -20,9 +20,14 @@ TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "tests") @pytest.mark.parametrize("launcher_platform", ['windows_editor']) class TestAutomation(EditorTestSuite): - enable_prefab_system = False + enable_prefab_system = True # this test is intermittently timing out without ever having executed. sandboxing while we investigate cause. @pytest.mark.test_case_id("C36525660") class AtomEditorComponents_DisplayMapperAdded(EditorSharedTest): from Atom.tests import hydra_AtomEditorComponents_DisplayMapperAdded as test_module + + # The "Sponza" level is failing with a hard lock 4-12% of the time, needs root causing and fixing. + @pytest.mark.test_case_id("C36529679") + class AtomLevelLoadTest_Editor_Sandbox(EditorSharedTest): + from Atom.tests import hydra_Atom_LevelLoadTest_Sandbox as test_module diff --git a/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py index 6525536f96..778f9bd3fb 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/atom_constants.py @@ -33,7 +33,9 @@ GLOBAL_ILLUMINATION_QUALITY = { } # Level list used in Editor Level Load Test -LEVEL_LIST = ["hermanubis", "hermanubis_high", "macbeth_shaderballs", "PbrMaterialChart", "ShadowTest", "Sponza"] +# WARNING: "Sponza" level is sandboxed due to an intermittent failure. +LEVEL_LIST = ["hermanubis", "hermanubis_high", "macbeth_shaderballs", "PbrMaterialChart", "ShadowTest"] + class AtomComponentProperties: """ diff --git a/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/material_editor_utils.py b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/material_editor_utils.py index c3c1c76611..90f9399c1c 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/material_editor_utils.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/atom_utils/material_editor_utils.py @@ -162,11 +162,11 @@ def select_model_config(configname): azlmbr.materialeditor.MaterialViewportRequestBus(azlmbr.bus.Broadcast, "SelectModelPresetByName", configname) -def destroy_main_window(): +def exit(): """ - Closes the Material Editor window + Closes the Material Editor """ - azlmbr.atomtools.AtomToolsMainWindowFactoryRequestBus(azlmbr.bus.Broadcast, "DestroyMainWindow") + azlmbr.atomtools.general.exit() def wait_for_condition(function, timeout_in_seconds=1.0): diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomMaterialEditor_BasicTests.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomMaterialEditor_BasicTests.py index bd00a84919..f881660f33 100644 --- a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomMaterialEditor_BasicTests.py +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_AtomMaterialEditor_BasicTests.py @@ -214,7 +214,7 @@ def run(): (not material_editor.is_open(document1_id)) and (not material_editor.is_open(document2_id)) and (not material_editor.is_open(document3_id)), 2.0) - material_editor.destroy_main_window() + material_editor.exit() if __name__ == "__main__": diff --git a/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_Atom_LevelLoadTest_Sandbox.py b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_Atom_LevelLoadTest_Sandbox.py new file mode 100644 index 0000000000..6cee7b2840 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/Atom/tests/hydra_Atom_LevelLoadTest_Sandbox.py @@ -0,0 +1,71 @@ +""" +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 +""" + + +def Atom_LevelLoadTest(): + """ + Summary: + Loads all graphics levels within the AutomatedTesting project in editor. For each level this script will verify that + the level loads, and can enter/exit gameplay without crashing the editor. + + Test setup: + - Store all available levels in a list. + - Set up a for loop to run all checks for each level. + + Expected Behavior: + Test verifies that each level loads, enters/exits game mode, and reports success for all test actions. + + Test Steps for each level: + 1) Create tuple with level load success and failure messages + 2) Open the level using the python test tools command + 3) Verify level is loaded using a separate command, and report success/failure + 4) Enter gameplay and report result using a tuple + 5) Exit Gameplay and report result using a tuple + 6) Look for errors or asserts. + + :return: None + """ + SANDBOX_LEVEL_LIST = ["Sponza"] + + import azlmbr.legacy.general as general + + from editor_python_test_tools.utils import Report, Tracer, TestHelper + + with Tracer() as error_tracer: + + for level in SANDBOX_LEVEL_LIST: + + # 1. Create tuple with level load success and failure messages + level_check_tuple = (f"loaded {level}", f"failed to load {level}") + + # 2. Open the level using the python test tools command + TestHelper.init_idle() + TestHelper.open_level("Graphics", level) + + # 3. Verify level is loaded using a separate command, and report success/failure + Report.result(level_check_tuple, level == general.get_current_level_name()) + + # 4. Enter gameplay and report result using a tuple + enter_game_mode_tuple = (f"{level} entered gameplay successfully ", f"{level} failed to enter gameplay") + TestHelper.enter_game_mode(enter_game_mode_tuple) + general.idle_wait_frames(1) + + # 5. Exit gameplay and report result using a tuple + exit_game_mode_tuple = (f"{level} exited gameplay successfully ", f"{level} failed to exit gameplay") + TestHelper.exit_game_mode(exit_game_mode_tuple) + + # 6. Look for errors or asserts. + TestHelper.wait_for_condition(lambda: error_tracer.has_errors or error_tracer.has_asserts, 1.0) + for error_info in error_tracer.errors: + Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}") + for assert_info in error_tracer.asserts: + Report.info(f"Assert: {assert_info.filename} {assert_info.function} | {assert_info.message}") + + +if __name__ == "__main__": + from editor_python_test_tools.utils import Report + Report.start_test(Atom_LevelLoadTest) diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py index e59282c97b..034930484e 100755 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py +++ b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py @@ -49,9 +49,11 @@ class TestAutomationBase: time_info_str += f"{testcase_name}: (Full:{t} sec, Editor:{editor_t} sec)\n" logger.info(time_info_str) + if cls.asset_processor is not None: + cls.asset_processor.teardown() + # Kill all ly processes - cls.asset_processor.teardown() - cls._kill_ly_processes() + cls._kill_ly_processes(include_asset_processor=True) def _run_test(self, request, workspace, editor, testcase_module, extra_cmdline_args=[], batch_mode=True, autotest_mode=True, use_null_renderer=True, enable_prefab_system=True): @@ -62,14 +64,16 @@ class TestAutomationBase: ######### # Setup # - if self.asset_processor is None: + self._kill_ly_processes(include_asset_processor=True) self.__class__.asset_processor = AssetProcessor(workspace) self.asset_processor.backup_ap_settings() - - self._kill_ly_processes(include_asset_processor=False) - self.asset_processor.start() - self.asset_processor.wait_for_idle() + else: + self._kill_ly_processes(include_asset_processor=False) + + if not self.asset_processor.process_exists(): + self.asset_processor.start() + self.asset_processor.wait_for_idle() def teardown(): if os.path.exists(workspace.paths.editor_log()): diff --git a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Periodic.py b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Periodic.py index 887bfe2426..58a0b42394 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Periodic.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Periodic.py @@ -61,6 +61,7 @@ class TestAutomation(TestAutomationBase): from . import Graph_HappyPath_ZoomInZoomOut as test_module self._run_test(request, workspace, editor, test_module) + @pytest.mark.xfail(reason="Test fails on nightly build builds, it needs to be fixed.") def test_NodePalette_HappyPath_CanSelectNode(self, request, workspace, editor, launcher_platform): from . import NodePalette_HappyPath_CanSelectNode as test_module self._run_test(request, workspace, editor, test_module) @@ -113,6 +114,7 @@ class TestAutomation(TestAutomationBase): from . import Debugger_HappyPath_TargetMultipleGraphs as test_module self._run_test(request, workspace, editor, test_module) + @pytest.mark.xfail(reason="Test fails on nightly build builds, it needs to be fixed.") @pytest.mark.parametrize("level", ["tmp_level"]) def test_Debugger_HappyPath_TargetMultipleEntities(self, request, workspace, editor, launcher_platform, project, level): def teardown(): @@ -174,6 +176,7 @@ class TestAutomation(TestAutomationBase): from . import ScriptEvents_ReturnSetType_Successfully as test_module self._run_test(request, workspace, editor, test_module) + @pytest.mark.xfail(reason="Test fails on nightly build builds, it needs to be fixed.") def test_NodeCategory_ExpandOnClick(self, request, workspace, editor, launcher_platform): from . import NodeCategory_ExpandOnClick as test_module self._run_test(request, workspace, editor, test_module) @@ -187,6 +190,7 @@ class TestAutomation(TestAutomationBase): from . import VariableManager_UnpinVariableType_Works as test_module self._run_test(request, workspace, editor, test_module) + @pytest.mark.xfail(reason="Test fails on nightly build builds, it needs to be fixed.") def test_Node_HappyPath_DuplicateNode(self, request, workspace, editor, launcher_platform): from . import Node_HappyPath_DuplicateNode as test_module self._run_test(request, workspace, editor, test_module) @@ -263,6 +267,7 @@ class TestScriptCanvasTests(object): timeout=60, ) + @pytest.mark.xfail(reason="Test fails on nightly build builds, it needs to be fixed.") def test_VariableManager_Default_CreateDeleteVars(self, request, editor, launcher_platform): var_types = ["Boolean", "Color", "EntityID", "Number", "String", "Transform", "Vector2", "Vector3", "Vector4"] expected_lines = [f"Success: {var_type} variable is created" for var_type in var_types] diff --git a/AutomatedTesting/Levels/Graphics/macbeth_shaderballs/macbeth_shaderballs.prefab b/AutomatedTesting/Levels/Graphics/macbeth_shaderballs/macbeth_shaderballs.prefab index 22504f168a..69b1eac762 100644 --- a/AutomatedTesting/Levels/Graphics/macbeth_shaderballs/macbeth_shaderballs.prefab +++ b/AutomatedTesting/Levels/Graphics/macbeth_shaderballs/macbeth_shaderballs.prefab @@ -38,7 +38,10 @@ }, "Component_[7874177159288365422]": { "$type": "EditorEntitySortComponent", - "Id": 7874177159288365422 + "Id": 7874177159288365422, + "Child Entity Order": [ + "Entity_[471076350497]" + ] }, "Component_[8018146290632383969]": { "$type": "EditorEntityIconComponent", @@ -110,34 +113,14 @@ "Component_[16871442125196328877]": { "$type": "EditorEntitySortComponent", "Id": 16871442125196328877, - "ChildEntityOrderEntryArray": [ - { - "EntityId": "Entity_[604220336673]" - }, - { - "EntityId": "Entity_[599925369377]", - "SortIndex": 1 - }, - { - "EntityId": "Entity_[475371317793]", - "SortIndex": 2 - }, - { - "EntityId": "Entity_[509731056161]", - "SortIndex": 3 - }, - { - "EntityId": "Entity_[505436088865]", - "SortIndex": 4 - }, - { - "EntityId": "Entity_[539795827233]", - "SortIndex": 5 - }, - { - "EntityId": "Entity_[569860598305]", - "SortIndex": 6 - } + "Child Entity Order": [ + "Entity_[604220336673]", + "Entity_[599925369377]", + "Entity_[475371317793]", + "Entity_[509731056161]", + "Entity_[505436088865]", + "Entity_[539795827233]", + "Entity_[569860598305]" ] }, "Component_[18389136819207633744]": { @@ -263,10 +246,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -370,10 +353,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -477,10 +460,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -584,10 +567,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -691,10 +674,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -798,10 +781,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -905,10 +888,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -944,30 +927,13 @@ "Component_[11056805018150955063]": { "$type": "EditorEntitySortComponent", "Id": 11056805018150955063, - "ChildEntityOrderEntryArray": [ - { - "EntityId": "Entity_[488256219681]" - }, - { - "EntityId": "Entity_[483961252385]", - "SortIndex": 1 - }, - { - "EntityId": "Entity_[479666285089]", - "SortIndex": 2 - }, - { - "EntityId": "Entity_[492551186977]", - "SortIndex": 3 - }, - { - "EntityId": "Entity_[496846154273]", - "SortIndex": 4 - }, - { - "EntityId": "Entity_[501141121569]", - "SortIndex": 5 - } + "Child Entity Order": [ + "Entity_[488256219681]", + "Entity_[483961252385]", + "Entity_[479666285089]", + "Entity_[492551186977]", + "Entity_[496846154273]", + "Entity_[501141121569]" ] }, "Component_[11466054095979053511]": { @@ -1028,30 +994,13 @@ "Component_[11056805018150955063]": { "$type": "EditorEntitySortComponent", "Id": 11056805018150955063, - "ChildEntityOrderEntryArray": [ - { - "EntityId": "Entity_[522615958049]" - }, - { - "EntityId": "Entity_[518320990753]", - "SortIndex": 1 - }, - { - "EntityId": "Entity_[514026023457]", - "SortIndex": 2 - }, - { - "EntityId": "Entity_[526910925345]", - "SortIndex": 3 - }, - { - "EntityId": "Entity_[531205892641]", - "SortIndex": 4 - }, - { - "EntityId": "Entity_[535500859937]", - "SortIndex": 5 - } + "Child Entity Order": [ + "Entity_[522615958049]", + "Entity_[518320990753]", + "Entity_[514026023457]", + "Entity_[526910925345]", + "Entity_[531205892641]", + "Entity_[535500859937]" ] }, "Component_[11466054095979053511]": { @@ -1180,10 +1129,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -1287,10 +1236,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -1394,10 +1343,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -1501,10 +1450,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -1608,10 +1557,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -1715,10 +1664,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -1754,30 +1703,13 @@ "Component_[11056805018150955063]": { "$type": "EditorEntitySortComponent", "Id": 11056805018150955063, - "ChildEntityOrderEntryArray": [ - { - "EntityId": "Entity_[552680729121]" - }, - { - "EntityId": "Entity_[548385761825]", - "SortIndex": 1 - }, - { - "EntityId": "Entity_[544090794529]", - "SortIndex": 2 - }, - { - "EntityId": "Entity_[556975696417]", - "SortIndex": 3 - }, - { - "EntityId": "Entity_[561270663713]", - "SortIndex": 4 - }, - { - "EntityId": "Entity_[565565631009]", - "SortIndex": 5 - } + "Child Entity Order": [ + "Entity_[552680729121]", + "Entity_[548385761825]", + "Entity_[544090794529]", + "Entity_[556975696417]", + "Entity_[561270663713]", + "Entity_[565565631009]" ] }, "Component_[11466054095979053511]": { @@ -1906,10 +1838,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2013,10 +1945,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2120,10 +2052,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2227,10 +2159,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2334,10 +2266,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2441,10 +2373,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2480,30 +2412,13 @@ "Component_[11056805018150955063]": { "$type": "EditorEntitySortComponent", "Id": 11056805018150955063, - "ChildEntityOrderEntryArray": [ - { - "EntityId": "Entity_[582745500193]" - }, - { - "EntityId": "Entity_[578450532897]", - "SortIndex": 1 - }, - { - "EntityId": "Entity_[574155565601]", - "SortIndex": 2 - }, - { - "EntityId": "Entity_[587040467489]", - "SortIndex": 3 - }, - { - "EntityId": "Entity_[591335434785]", - "SortIndex": 4 - }, - { - "EntityId": "Entity_[595630402081]", - "SortIndex": 5 - } + "Child Entity Order": [ + "Entity_[582745500193]", + "Entity_[578450532897]", + "Entity_[574155565601]", + "Entity_[587040467489]", + "Entity_[591335434785]", + "Entity_[595630402081]" ] }, "Component_[11466054095979053511]": { @@ -2632,10 +2547,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2739,10 +2654,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2846,10 +2761,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -2953,10 +2868,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -3060,10 +2975,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } @@ -3167,10 +3082,10 @@ "Configuration": { "ModelAsset": { "assetId": { - "guid": "{D0F73AAF-52B7-507C-B045-DBE2FE2D4403}", - "subId": 268677693 + "guid": "{FD340C30-755C-5911-92A3-19A3F7A77931}", + "subId": 281415304 }, - "assetHint": "objects/shaderball_simple/shaberball_simple_1m.azmodel" + "assetHint": "objects/shaderball/shaderball_default_1m.azmodel" }, "LodOverride": 255 } diff --git a/AutomatedTesting/Passes/MainPipeline.pass b/AutomatedTesting/Passes/MainPipeline.pass index 39b992a11d..8ad4006570 100644 --- a/AutomatedTesting/Passes/MainPipeline.pass +++ b/AutomatedTesting/Passes/MainPipeline.pass @@ -460,6 +460,33 @@ } ] }, + { + "Name": "DiffuseProbeGridVisualizationCompositePass", + "TemplateName": "DiffuseProbeGridVisualizationCompositePassTemplate", + "Connections": [ + { + "LocalSlot": "VisualizationInput", + "AttachmentRef": { + "Pass": "OpaquePass", + "Attachment": "DiffuseProbeGridVisualization" + } + }, + { + "LocalSlot": "Depth", + "AttachmentRef": { + "Pass": "DepthPrePass", + "Attachment": "Depth" + } + }, + { + "LocalSlot": "ColorInputOutput", + "AttachmentRef": { + "Pass": "PostProcessPass", + "Attachment": "Output" + } + } + ] + }, { "Name": "AuxGeomPass", "TemplateName": "AuxGeomPassTemplate", @@ -468,8 +495,8 @@ { "LocalSlot": "ColorInputOutput", "AttachmentRef": { - "Pass": "PostProcessPass", - "Attachment": "Output" + "Pass": "DiffuseProbeGridVisualizationCompositePass", + "Attachment": "ColorInputOutput" } }, { diff --git a/Code/Editor/Core/QtEditorApplication.cpp b/Code/Editor/Core/QtEditorApplication.cpp index 2439228476..8f7db74125 100644 --- a/Code/Editor/Core/QtEditorApplication.cpp +++ b/Code/Editor/Core/QtEditorApplication.cpp @@ -32,15 +32,6 @@ #include "Settings.h" #include "CryEdit.h" -enum -{ - // in milliseconds - GameModeIdleFrequency = 0, - EditorModeIdleFrequency = 1, - InactiveModeFrequency = 10, - UninitializedFrequency = 9999, -}; - Q_LOGGING_CATEGORY(InputDebugging, "o3de.editor.input") // internal, private namespace: @@ -234,18 +225,12 @@ namespace Editor EditorQtApplication::EditorQtApplication(int& argc, char** argv) : AzQtApplication(argc, argv) , m_stylesheet(new AzQtComponents::O3DEStylesheet(this)) - , m_idleTimer(new QTimer(this)) { - m_idleTimer->setInterval(UninitializedFrequency); - setWindowIcon(QIcon(":/Application/res/o3de_editor.ico")); // set the default key store for our preferences: setApplicationName("O3DE Editor"); - connect(m_idleTimer, &QTimer::timeout, this, &EditorQtApplication::maybeProcessIdle); - - connect(this, &QGuiApplication::applicationStateChanged, this, [this] { ResetIdleTimerInterval(PollState); }); installEventFilter(this); // Disable our debugging input helpers by default @@ -324,6 +309,10 @@ namespace Editor winapp->OnIdle(0); } } + if (m_applicationActive) + { + QTimer::singleShot(1, this, &EditorQtApplication::maybeProcessIdle); + } } void EditorQtApplication::InstallQtLogHandler() @@ -376,14 +365,6 @@ namespace Editor case eNotify_OnQuit: GetIEditor()->UnregisterNotifyListener(this); break; - - case eNotify_OnBeginGameMode: - // GetIEditor()->IsInGameMode() Isn't reliable when called from within the notification handler - ResetIdleTimerInterval(GameMode); - break; - case eNotify_OnEndGameMode: - ResetIdleTimerInterval(EditorMode); - break; } } @@ -456,55 +437,16 @@ namespace Editor void EditorQtApplication::EnableOnIdle(bool enable) { + m_applicationActive = enable; if (enable) { - if (m_idleTimer->interval() == UninitializedFrequency) - { - ResetIdleTimerInterval(); - } - - m_idleTimer->start(); - } - else - { - m_idleTimer->stop(); + QTimer::singleShot(0, this, &EditorQtApplication::maybeProcessIdle); } } bool EditorQtApplication::OnIdleEnabled() const { - if (m_idleTimer->interval() == UninitializedFrequency) - { - return false; - } - - return m_idleTimer->isActive(); - } - - void EditorQtApplication::ResetIdleTimerInterval(TimerResetFlag flag) - { - bool isInGameMode = flag == GameMode; - if (flag == PollState) - { - isInGameMode = GetIEditor() ? GetIEditor()->IsInGameMode() : false; - } - - // Game mode takes precedence over anything else - if (isInGameMode) - { - m_idleTimer->setInterval(GameModeIdleFrequency); - } - else - { - if (applicationState() & Qt::ApplicationActive) - { - m_idleTimer->setInterval(EditorModeIdleFrequency); - } - else - { - m_idleTimer->setInterval(InactiveModeFrequency); - } - } + return m_applicationActive; } bool EditorQtApplication::eventFilter(QObject* object, QEvent* event) diff --git a/Code/Editor/Core/QtEditorApplication.h b/Code/Editor/Core/QtEditorApplication.h index 28ee8ac14b..9cb03ec644 100644 --- a/Code/Editor/Core/QtEditorApplication.h +++ b/Code/Editor/Core/QtEditorApplication.h @@ -102,13 +102,6 @@ namespace Editor bool m_isMovingOrResizing = false; private: - enum TimerResetFlag - { - PollState, - GameMode, - EditorMode - }; - void ResetIdleTimerInterval(TimerResetFlag = PollState); static QColor InterpolateColors(QColor a, QColor b, float factor); void RefreshStyleSheet(); void InstallFilters(); @@ -125,7 +118,6 @@ namespace Editor QTranslator* m_editorTranslator = nullptr; QTranslator* m_assetBrowserTranslator = nullptr; - QTimer* const m_idleTimer = nullptr; AZ::UserSettingsProvider m_localUserSettings; @@ -133,5 +125,6 @@ namespace Editor QSet m_pressedKeys; bool m_activatedLocalUserSettings = false; + bool m_applicationActive = false; }; } // namespace editor diff --git a/Code/Editor/Platform/Windows/Editor/Core/QtEditorApplication_windows.cpp b/Code/Editor/Platform/Windows/Editor/Core/QtEditorApplication_windows.cpp index f8065af931..1fd7f29ca3 100644 --- a/Code/Editor/Platform/Windows/Editor/Core/QtEditorApplication_windows.cpp +++ b/Code/Editor/Platform/Windows/Editor/Core/QtEditorApplication_windows.cpp @@ -135,7 +135,7 @@ namespace Editor } widget = widget->parentWidget(); } - return false; + return nullptr; }; if (object == toolBarAt(QCursor::pos())) { diff --git a/Code/Editor/Util/3DConnexionDriver.cpp b/Code/Editor/Util/3DConnexionDriver.cpp index 9dc1600185..c0d4393b49 100644 --- a/Code/Editor/Util/3DConnexionDriver.cpp +++ b/Code/Editor/Util/3DConnexionDriver.cpp @@ -116,9 +116,6 @@ bool C3DConnexionDriver::GetInputMessageData(LPARAM lParam, S3DConnexionMessage& { if (event->header.dwType == RIM_TYPEHID) { - static bool bGotTranslation = false, - bGotRotation = false; - static int all6DOFs[6] = {0}; LPRAWHID pRawHid = &event->data.hid; // Translation or Rotation packet? They come in two different packets. diff --git a/Code/Framework/AzCore/AzCore/IO/Path/Path.h b/Code/Framework/AzCore/AzCore/IO/Path/Path.h index 235310a5da..3c2c4f0a8c 100644 --- a/Code/Framework/AzCore/AzCore/IO/Path/Path.h +++ b/Code/Framework/AzCore/AzCore/IO/Path/Path.h @@ -709,7 +709,10 @@ namespace AZ::IO constexpr reference operator*() const; - constexpr pointer operator->() const; + constexpr pointer operator->() const + { + return &m_stashed_elem; + } constexpr PathIterator& operator++(); diff --git a/Code/Framework/AzCore/AzCore/IO/Path/Path.inl b/Code/Framework/AzCore/AzCore/IO/Path/Path.inl index bde2353112..5046b43127 100644 --- a/Code/Framework/AzCore/AzCore/IO/Path/Path.inl +++ b/Code/Framework/AzCore/AzCore/IO/Path/Path.inl @@ -1397,12 +1397,6 @@ namespace AZ::IO return m_stashed_elem; } - template - constexpr auto PathIterator::operator->() const -> pointer - { - return &m_stashed_elem; - } - template constexpr auto PathIterator::operator++() -> PathIterator& { @@ -1542,3 +1536,13 @@ namespace AZ::IO extern template bool operator!=(const PathIterator& lhs, const PathIterator& rhs); } + +namespace AZStd::ranges +{ + // A PathView is a borrowed range, it does not own the content of the Path it is viewing + template<> + inline constexpr bool enable_borrowed_range = true; + + template<> + inline constexpr bool enable_view = true; +} diff --git a/Code/Framework/AzCore/AzCore/Memory/HphaSchema.cpp b/Code/Framework/AzCore/AzCore/Memory/HphaSchema.cpp index 5e0e3e2de8..1b5351cd79 100644 --- a/Code/Framework/AzCore/AzCore/Memory/HphaSchema.cpp +++ b/Code/Framework/AzCore/AzCore/Memory/HphaSchema.cpp @@ -13,6 +13,7 @@ #include // required by certain platforms #include #include +#include #include #ifdef _DEBUG @@ -41,8 +42,8 @@ #define HPPA_ASSERT_PRINT_STACK(...) _EXPAND(_GET_MACRO23(__VA_ARGS__, _HPPA_ASSERT_PRINT_STACK3, _HPPA_ASSERT_PRINT_STACK2)(__VA_ARGS__)) -namespace AZ { - +namespace AZ +{ /// default windows virtual page size \todo Read this from the OS when we create the allocator) #define OS_VIRTUAL_PAGE_SIZE AZ_PAGE_SIZE ////////////////////////////////////////////////////////////////////////// @@ -56,211 +57,78 @@ namespace AZ { // Enabled mutex per bucket #define USE_MUTEX_PER_BUCKET - ////////////////////////////////////////////////////////////////////////// - // TODO: Replace with AZStd::intrusive_list - class intrusive_list_base + namespace HphaInternal { - public: - class node_base + //! Rounds up a value to next power of 2. + //! For example to round 8388609((2^23) + 1) up to 16777216(2^24) the following occurs + //! Subtract one from the value in case it is already + //! equal to a power of 2 + //! 8388609 - 1 = 8388608 + //! Propagate the highest one bit in the value to all the lower bits + //! 8388608 = 0b100'0000'0000'0000'0000'0000 in binary + //! + //! 0b100'0000'0000'0000'0000'0000 + //! |0b010'0000'0000'0000'0000'0000 (>> 1) + //! ------------------------------- + //! 0b110'0000'0000'0000'0000'0000 (Now there are 2 consecutive 1-bits) + //! |0b001'1000'0000'0000'0000'0000 (>> 2) + //! ------------------------------- + //! 0b111'1000'0000'0000'0000'0000 (Now there are 4 consecutive 1-bits) + //! |0b000'0111'1000'0000'0000'0000 (>> 4) + //! ------------------------------- + //! 0b111'1111'1000'0000'0000'0000 (Now there are 8 consecutive 1-bits) + //! |0b000'0000'0111'1111'1000'0000 (>> 8) + //! ------------------------------- + //! 0b111'1111'1111'1111'1000'0000 (Now there are 16 consecutive 1-bits) + //! |0b000'0000'0000'0000'0111'1111 (>> 16) + //! ------------------------------- + //! 0b111'1111'1111'1111'1111'1111 (Now there are 23 consecutive 1-bits) + //! |0b000'0000'0000'0000'0000'0000 (>> 32) + //! ------------------------------- + //! 0b111'1111'1111'1111'1111'1111 + //! Finally since all the one bits are set in the value, adding one pushes it + //! to next power of 2 + //! 0b1000'0000'0000'0000'0000'0000 = 16777216 + static constexpr size_t AlignUpToPowerOfTwo(size_t value) { - node_base* mPrev; - node_base* mNext; - public: - node_base* next() const {return mNext; } - node_base* prev() const {return mPrev; } - void reset() + // If the value is <=2 it is already aligned + if (value <= 2) { - mPrev = this; - mNext = this; + return value; } - void unlink() - { - mNext->mPrev = mPrev; - mPrev->mNext = mNext; - } - void link(node_base* node) - { - mPrev = node->mPrev; - mNext = node; - node->mPrev = this; - mPrev->mNext = this; - } - }; - intrusive_list_base() - { - mHead.reset(); - } - intrusive_list_base(const intrusive_list_base&) - { - mHead.reset(); - } - bool empty() const {return mHead.next() == &mHead; } - void swap(intrusive_list_base& other) - { - node_base* node = &other.mHead; - if (!empty()) - { - node = mHead.next(); - mHead.unlink(); - mHead.reset(); - } - node_base* other_node = &mHead; - if (!other.empty()) - { - other_node = other.mHead.next(); - other.mHead.unlink(); - other.mHead.reset(); - } - mHead.link(other_node); - other.mHead.link(node); - } - protected: - node_base mHead; - }; - ////////////////////////////////////////////////////////////////////////// - // TODO: Replace with AZStd::intrusive_list - template - class intrusive_list - : public intrusive_list_base - { - intrusive_list(const intrusive_list& rhs); - intrusive_list& operator=(const intrusive_list& rhs); - public: - class node - : public node_base - { - public: - T* next() const {return static_cast(node_base::next()); } - T* prev() const {return static_cast(node_base::prev()); } - const T& data() const {return *static_cast(this); } - T& data() {return *static_cast(this); } - }; - - class const_iterator; - class iterator - { - using reference = T&; - using pointer = T*; - friend class const_iterator; - T* mPtr; - public: - iterator() - : mPtr(0) {} - explicit iterator(T* ptr) - : mPtr(ptr) {} - reference operator*() const {return mPtr->data(); } - pointer operator->() const {return &mPtr->data(); } - operator pointer() const { - return &mPtr->data(); - } - iterator& operator++() - { - mPtr = mPtr->next(); - return *this; - } - iterator& operator--() - { - mPtr = mPtr->prev(); - return *this; - } - bool operator==(const iterator& rhs) const {return mPtr == rhs.mPtr; } - bool operator!=(const iterator& rhs) const {return mPtr != rhs.mPtr; } - T* ptr() const {return mPtr; } - }; - - class const_iterator - { - using reference = const T &; - using pointer = const T *; - const T* mPtr; - public: - const_iterator() - : mPtr(0) {} - explicit const_iterator(const T* ptr) - : mPtr(ptr) {} - const_iterator(const iterator& it) - : mPtr(it.mPtr) {} - reference operator*() const {return mPtr->data(); } - pointer operator->() const {return &mPtr->data(); } - operator pointer() const { - return &mPtr->data(); - } - const_iterator& operator++() - { - mPtr = mPtr->next(); - return *this; - } - const_iterator& operator--() - { - mPtr = mPtr->prev(); - return *this; - } - bool operator==(const const_iterator& rhs) const {return mPtr == rhs.mPtr; } - bool operator!=(const const_iterator& rhs) const {return mPtr != rhs.mPtr; } - const T* ptr() const {return mPtr; } - }; - - intrusive_list() - : intrusive_list_base() {} - ~intrusive_list() {clear(); } - - const_iterator begin() const {return const_iterator((const T*)mHead.next()); } - iterator begin() {return iterator((T*)mHead.next()); } - const_iterator end() const {return const_iterator((const T*)&mHead); } - iterator end() {return iterator((T*)&mHead); } - - const T& front() const - { - HPPA_ASSERT(!empty()); - return *begin(); - } - T& front() - { - HPPA_ASSERT(!empty()); - return *begin(); - } - const T& back() const - { - HPPA_ASSERT(!empty()); - return *(--end()); - } - T& back() - { - HPPA_ASSERT(!empty()); - return *(--end()); + // Subtract one to make any values already + // aligned to a power of 2 less than that power of 2 + // so that algorithm doesn't push those values upwards + --value; + value |= value >> 0b1; + value |= value >> 0b10; + value |= value >> 0b100; + value |= value >> 0b1000; + value |= value >> 0b1'0000; + value |= value >> 0b10'0000; + ++value; + return value; } - void push_front(T* v) {insert(this->begin(), v); } - void pop_front() {erase(this->begin()); } - void push_back(T* v) {insert(this->end(), v); } - void pop_back() {erase(--(this->end())); } - - iterator insert(iterator where, T* node) - { - T* newLink = node; - newLink->link(where.ptr()); - return iterator(newLink); - } - iterator erase(iterator where) - { - T* node = where.ptr(); - ++where; - node->unlink(); - return where; - } - void erase(T* node) - { - node->unlink(); - } - void clear() - { - while (!this->empty()) - { - this->pop_back(); - } - } - }; + static_assert(AlignUpToPowerOfTwo(0) == 0); + static_assert(AlignUpToPowerOfTwo(1) == 1); + static_assert(AlignUpToPowerOfTwo(2) == 2); + static_assert(AlignUpToPowerOfTwo(3) == 4); + static_assert(AlignUpToPowerOfTwo(4) == 4); + static_assert(AlignUpToPowerOfTwo(5) == 8); + static_assert(AlignUpToPowerOfTwo(8) == 8); + static_assert(AlignUpToPowerOfTwo(10) == 16); + static_assert(AlignUpToPowerOfTwo(16) == 16); + static_assert(AlignUpToPowerOfTwo(24) == 32); + static_assert(AlignUpToPowerOfTwo(32) == 32); + static_assert(AlignUpToPowerOfTwo(45) == 64); + static_assert(AlignUpToPowerOfTwo(64) == 64); + static_assert(AlignUpToPowerOfTwo(112) == 128); + static_assert(AlignUpToPowerOfTwo(128) == 128); + static_assert(AlignUpToPowerOfTwo(136) == 256); + static_assert(AlignUpToPowerOfTwo(256) == 256); + } ////////////////////////////////////////////////////////////////////////// class HpAllocator @@ -376,7 +244,7 @@ namespace AZ { }; struct page : public block_header_proxy /* must be first */ - , public intrusive_list::node + , public AZStd::list_base_hook::node_type { page(size_t elemSize, size_t pageSize, size_t marker) : mBucketIndex((unsigned short)bucket_spacing_function_aligned(elemSize)) @@ -415,25 +283,22 @@ namespace AZ { void dec_ref() { HPPA_ASSERT(mUseCount > 0); mUseCount--; } bool check_marker(size_t marker) const { return mMarker == (marker ^ ((size_t)this)); } }; - using page_list = intrusive_list; - class bucket + using page_list = AZStd::intrusive_list>; + +#if defined(MULTITHREADED) && defined(USE_MUTEX_PER_BUCKET) + static constexpr size_t BucketAlignment = HphaInternal::AlignUpToPowerOfTwo(sizeof(page_list) + sizeof(AZStd::mutex) + sizeof(size_t)); +#else + static constexpr size_t BucketAlignment = HphaInternal::AlignUpToPowerOfTwo(sizeof(page_list) + sizeof(size_t)); +#endif + AZ_PUSH_DISABLE_WARNING_MSVC(4324) + class alignas(BucketAlignment) bucket { page_list mPageList; -#ifdef MULTITHREADED - #if defined (USE_MUTEX_PER_BUCKET) +#if defined(MULTITHREADED) && defined(USE_MUTEX_PER_BUCKET) mutable AZStd::mutex mLock; - #endif #endif size_t mMarker; -#ifdef MULTITHREADED - #if defined (USE_MUTEX_PER_BUCKET) - unsigned char _padding[sizeof(void*) * 16 - sizeof(page_list) - sizeof(AZStd::mutex) - sizeof(size_t)]; - #else - unsigned char _padding[sizeof(void*) * 16 - sizeof(page_list) - sizeof(size_t)]; - #endif -#else - unsigned char _padding[sizeof(void*) * 4 - sizeof(page_list) - sizeof(size_t)]; -#endif + public: bucket(); #ifdef MULTITHREADED @@ -442,17 +307,19 @@ namespace AZ { #endif #endif size_t marker() const {return mMarker; } - const page* page_list_begin() const {return mPageList.begin(); } - page* page_list_begin() {return mPageList.begin(); } - const page* page_list_end() const {return mPageList.end(); } - page* page_list_end() {return mPageList.end(); } + auto page_list_begin() const {return mPageList.begin(); } + auto page_list_begin() {return mPageList.begin(); } + auto page_list_end() const {return mPageList.end(); } + auto page_list_end() {return mPageList.end(); } bool page_list_empty() const {return mPageList.empty(); } - void add_free_page(page* p) {mPageList.push_front(p); } + void add_free_page(page* p) {mPageList.push_front(*p); } page* get_free_page(); const page* get_free_page() const; void* alloc(page* p); void free(page* p, void* ptr); + void unlink(page* p); }; + AZ_POP_DISABLE_WARNING_MSVC void* bucket_system_alloc(); void bucket_system_free(void* ptr); page* bucket_grow(size_t elemSize, size_t marker); @@ -1237,8 +1104,6 @@ namespace AZ { // Thats why we use SimpleLcgRandom here AZ::SimpleLcgRandom randGenerator = AZ::SimpleLcgRandom(reinterpret_cast(static_cast(this))); mMarker = size_t(randGenerator.Getu64Random()); - - (void)_padding; } HpAllocator::page* HpAllocator::bucket::get_free_page() @@ -1278,8 +1143,8 @@ namespace AZ { if (!next) { // if full, auto sort to back - p->unlink(); - mPageList.push_back(p); + mPageList.erase(*p); + mPageList.push_back(*p); } return (void*)free; } @@ -1295,11 +1160,16 @@ namespace AZ { if (!free) { // if the page was previously full, auto sort to front - p->unlink(); - mPageList.push_front(p); + mPageList.erase(*p); + mPageList.push_front(*p); } } + void HpAllocator::bucket::unlink(page* p) + { + mPageList.erase(*p); + } + void* HpAllocator::bucket_system_alloc() { void* ptr; @@ -1522,8 +1392,8 @@ namespace AZ { AZStd::lock_guard lock(m_mutex); #endif #endif - const page* pageEnd = mBuckets[i].page_list_end(); - for (const page* p = mBuckets[i].page_list_begin(); p != pageEnd; ) + auto pageEnd = mBuckets[i].page_list_end(); + for (auto p = mBuckets[i].page_list_begin(); p != pageEnd; ) { // early out if we reach fully occupied page (the remaining should all be full) if (p->mFreeList == nullptr) @@ -1537,7 +1407,7 @@ namespace AZ { { AZ_TracePrintf("System", "Unused Bucket %d page %p elementSize: %d available: %d elements\n", i, p, elementSize, availableMemory / elementSize); } - p = p->next(); + p = p->m_next; } } return unusedMemory; @@ -1554,21 +1424,21 @@ namespace AZ { AZStd::lock_guard lock(m_mutex); #endif #endif - page* pageEnd = mBuckets[i].page_list_end(); - for (page* p = mBuckets[i].page_list_begin(); p != pageEnd; ) + auto pageEnd = mBuckets[i].page_list_end(); + for (auto p = mBuckets[i].page_list_begin(); p != pageEnd; ) { // early out if we reach fully occupied page (the remaining should all be full) if (p->mFreeList == nullptr) { break; } - page* next = p->next(); + page* next = p->m_next; if (p->empty()) { HPPA_ASSERT(p->mFreeList); - p->unlink(); + mBuckets[i].unlink(AZStd::to_address(p)); p->setInvalid(); - bucket_system_free(p); + bucket_system_free(AZStd::to_address(p)); } p = next; } @@ -2239,11 +2109,17 @@ namespace AZ { size_t HpAllocator::tree_get_max_allocation() const { +#ifdef MULTITHREADED + AZStd::lock_guard lock(mTreeMutex); +#endif return mFreeTree.maximum()->get_block()->size(); } size_t HpAllocator::tree_get_unused_memory(bool isPrint) const { +#ifdef MULTITHREADED + AZStd::lock_guard lock(mTreeMutex); +#endif size_t unusedMemory = 0; for (free_node_tree::const_iterator it = mFreeTree.begin(); it != mFreeTree.end(); ++it) { @@ -2564,7 +2440,7 @@ namespace AZ { m_capacity = desc.m_capacity; } - AZ_Assert(sizeof(HpAllocator) <= sizeof(m_hpAllocatorBuffer), "Increase the m_hpAllocatorBuffer, we need %d bytes but we have %d bytes!", sizeof(HpAllocator), sizeof(m_hpAllocatorBuffer)); + static_assert(sizeof(HpAllocator) <= sizeof(m_hpAllocatorBuffer), "Increase the m_hpAllocatorBuffer, it needs to be at least the sizeof(HpAllocator)"); m_allocator = new (&m_hpAllocatorBuffer) HpAllocator(m_desc); } diff --git a/Code/Framework/AzCore/AzCore/Memory/HphaSchema.h b/Code/Framework/AzCore/AzCore/Memory/HphaSchema.h index 27dbd321d2..fd746e4602 100644 --- a/Code/Framework/AzCore/AzCore/Memory/HphaSchema.h +++ b/Code/Framework/AzCore/AzCore/Memory/HphaSchema.h @@ -73,18 +73,20 @@ namespace AZ void GarbageCollect() override; private: - // [LY-84974][sconel@][2018-08-10] SliceStrike integration up to CL 671758 // this must be at least the max size of HpAllocator (defined in the cpp) + any platform compiler padding - static const int hpAllocatorStructureSize = 16584; - // [LY][sconel@] end + // A static assert inside of HphaSchema.cpp validates that this is the case + // as of commit https://github.com/o3de/o3de/commit/92cd457c256e1ec91eeabe04b56d1d4c61f8b1af + // When MULTITHREADED and USE_MUTEX_PER_BUCKET is defined + // the largest sizeof for HpAllocator is 16640 on MacOS + // On Windows the sizeof HpAllocator is 8384 + // Up this value to 18 KiB to be safe + static constexpr size_t hpAllocatorStructureSize = 18 * 1024; Descriptor m_desc; int m_pad; // pad the Descriptor to avoid C4355 size_type m_capacity; ///< Capacity in bytes. HpAllocator* m_allocator; - // [LY-84974][sconel@][2018-08-10] SliceStrike integration up to CL 671758 - AZStd::aligned_storage::type m_hpAllocatorBuffer; ///< Memory buffer for HpAllocator - // [LY][sconel@] end + AZStd::aligned_storage_t m_hpAllocatorBuffer; ///< Memory buffer for HpAllocator bool m_ownMemoryBlock; }; } // namespace AZ diff --git a/Code/Framework/AzCore/AzCore/PlatformDef.h b/Code/Framework/AzCore/AzCore/PlatformDef.h index 8416099f15..d10b155127 100644 --- a/Code/Framework/AzCore/AzCore/PlatformDef.h +++ b/Code/Framework/AzCore/AzCore/PlatformDef.h @@ -83,7 +83,7 @@ #define AZ_PUSH_DISABLE_WARNING_GCC(_gccOption) /// Compiler specific AZ_POP_DISABLE_WARNING. This needs to be matched with the compiler specific AZ_PUSH_DISABLE_WARNINGs -#define AZ_POP_DISABLE_WARNING_CLANG +#define AZ_POP_DISABLE_WARNING_CLANG #define AZ_POP_DISABLE_WARNING_MSVC \ __pragma(warning(pop)) #define AZ_POP_DISABLE_WARNING_GCC @@ -176,7 +176,7 @@ #define AZ_PUSH_DISABLE_WARNING_3(_1, _2, _gccOption) AZ_PUSH_DISABLE_WARNING_GCC(_gccOption) /// Pops the warning stack. For use matched with an AZ_PUSH_DISABLE_WARNING -#define AZ_POP_DISABLE_WARNING +#define AZ_POP_DISABLE_WARNING _Pragma("GCC diagnostic pop") #endif // defined(AZ_COMPILER_CLANG) @@ -303,3 +303,10 @@ #if !defined(az_has_builtin_wmemmove) #define az_has_builtin_wmemmove false #endif + +// no unique address attribute support in C++17 +#if __has_cpp_attribute(no_unique_address) + #define AZ_NO_UNIQUE_ADDRESS [[no_unique_address]] +#else + #define AZ_NO_UNIQUE_ADDRESS +#endif diff --git a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl index bba79e36f7..af814fbd32 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl +++ b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl @@ -13,6 +13,7 @@ #include #include #include +#include #ifndef AZ_USE_CUSTOM_SCRIPT_BIND struct lua_State; @@ -47,10 +48,6 @@ namespace AZStd class intrusive_ptr; template class shared_ptr; - - // Wrapper types - template - class optional; } namespace AZ diff --git a/Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h b/Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h index 2cff17a638..0f292140dc 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h +++ b/Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -89,9 +90,6 @@ namespace AZStd template class function; - template - class optional; - struct monostate; template @@ -150,7 +148,7 @@ namespace AZ template