Skip to content

Commit 9bcf25a

Browse files
Merge pull request #534 from o3de/stabilization/2210
Merge stabilization/2210 into main Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>
2 parents fdef502 + 6e9e09c commit 9bcf25a

File tree

292 files changed

+2163
-1734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+2163
-1734
lines changed

Gem/Code/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ ly_add_target(
4545
Gem::Atom_Component_DebugCamera.Static
4646
Gem::AtomSampleViewer.Lib.Static
4747
Gem::Profiler.Static
48+
Gem::DiffuseProbeGrid.Static
4849
)
4950

5051
ly_add_target(

Gem/Code/Source/AssetLoadTestComponent.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ namespace AtomSampleViewer
9494

9595
m_modelBrowser.ResetPinnedAssetsToDefault();
9696
}
97+
98+
// 25 was the original max before some changes that increased ENTITY_LATTEST_TEST_COMPONENT_MAX to 100.
99+
// AssetLoadTest was crashing (out of descriptors) at 50x50x42 so we put the limit back to 25^3.
100+
// Note that limiting to 40^3 will avoid the crash, but the sample doesn't work well at that scale, the UI
101+
// doesn't even show up because of a combination of low frame rate, the reload timers, and the time it takes
102+
// to load the models, and the fact that the UI is hidden while the models are loading.
103+
// So it would be good if we could work on increasing this limit.
104+
// (It would also be good if we could improve the design of this sample to make the UI persistent and more
105+
// responsive while the assets keep reloading).
106+
Base::SetLatticeMaxDimension(25);
97107

98108
Base::Activate();
99109
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) Contributors to the Open 3D Engine Project.
3+
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
4+
*
5+
* SPDX-License-Identifier: Apache-2.0 OR MIT
6+
*
7+
*/
8+
9+
#include <AtomSampleComponent.h>
10+
11+
namespace AtomSampleViewer
12+
{
13+
14+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) Contributors to the Open 3D Engine Project.
3+
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
4+
*
5+
* SPDX-License-Identifier: Apache-2.0 OR MIT
6+
*
7+
*/
8+
9+
#pragma once
10+
11+
#include <AzCore/Component/Component.h>
12+
13+
namespace AtomSampleViewer
14+
{
15+
class AtomSampleComponent
16+
: public AZ::Component
17+
{
18+
public:
19+
AZ_RTTI(AtomSampleComponent, "{2318DFD6-BC6B-4335-9F25-8E270A10CA81}", AZ::Component);
20+
21+
AtomSampleComponent() = default;
22+
~AtomSampleComponent() override = default;
23+
24+
// Redefine this string in the sample component subclass to provide a sample-specific warning message.
25+
// Any non-empty string will automatically cause a warning message to be displayed before opening the sample.
26+
static constexpr const char* ContentWarning = "";
27+
28+
// If the above ContentWarning is overridden with a non-empty value, this string will be used as the message box's title.
29+
// Redefine this string in the sample component subclass to provide a custom title.
30+
static constexpr const char* ContentWarningTitle = "Content Warning";
31+
32+
// This is a common photosensitive/seizure warning that could be used for the above ContentWarning in specific samples as needed.
33+
static constexpr const char CommonPhotosensitiveWarning[] = "This sample includes flashing images that could cause seizures or other adverse effects in photosensitive individuals.";
34+
static constexpr const char CommonPhotosensitiveWarningTitle[] = "Photosensitive Seizure Warning";
35+
};
36+
} // namespace AtomSampleViewer

Gem/Code/Source/AtomSampleViewerSystemComponent.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include <Atom/RHI/Factory.h>
3030
#include <Atom/RPI.Public/RPISystemInterface.h>
31-
#include <Atom/RPI.Public/Shader/Metrics/ShaderMetricsSystem.h>
3231

3332
#include <ISystem.h>
3433
#include <IConsole.h>

Gem/Code/Source/Automation/ScriptManager.cpp

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <Atom/RHI/Factory.h>
2222

2323
#include <AzCore/Component/Entity.h>
24+
#include <AzCore/Settings/SettingsRegistryScriptUtils.h>
2425
#include <AzCore/Script/ScriptContext.h>
2526
#include <AzCore/Script/ScriptSystemBus.h>
2627
#include <AzCore/Script/ScriptAsset.h>
@@ -966,7 +967,8 @@ namespace AtomSampleViewer
966967

967968
s_instance->m_executingScripts.insert(scriptAsset.GetId());
968969

969-
if (!s_instance->m_scriptContext->Execute(scriptAsset->GetScriptBuffer().data(), scriptFilePath.c_str(), scriptAsset->GetScriptBuffer().size()))
970+
auto& scriptData = scriptAsset->m_data;
971+
if (!s_instance->m_scriptContext->Execute(scriptData.GetScriptBuffer().data(), scriptFilePath.c_str(), scriptData.GetScriptBuffer().size()))
970972
{
971973
// Push an error operation on the back of the queue instead of reporting it immediately so it doesn't get lost
972974
// in front of a bunch of queued m_scriptOperations.
@@ -1057,6 +1059,7 @@ namespace AtomSampleViewer
10571059
void ScriptManager::ReflectScriptContext(AZ::BehaviorContext* behaviorContext)
10581060
{
10591061
AZ::MathReflect(behaviorContext);
1062+
AZ::SettingsRegistryScriptUtils::ReflectSettingsRegistryToBehaviorContext(*behaviorContext);
10601063

10611064
// Utilities...
10621065
behaviorContext->Method("RunScript", &Script_RunScript);
@@ -1086,6 +1089,7 @@ namespace AtomSampleViewer
10861089
behaviorContext->Method("ShowTool", &Script_ShowTool);
10871090

10881091
// Screenshots...
1092+
behaviorContext->Method("SetTestEnvPath", &Script_SetTestEnvPath);
10891093
behaviorContext->Method("SelectImageComparisonToleranceLevel", &Script_SelectImageComparisonToleranceLevel);
10901094
behaviorContext->Method("CaptureScreenshot", &Script_CaptureScreenshot);
10911095
behaviorContext->Method("CaptureScreenshotWithImGui", &Script_CaptureScreenshotWithImGui);
@@ -1140,14 +1144,16 @@ namespace AtomSampleViewer
11401144
s_instance->m_scriptOperations.push(AZStd::move(func));
11411145
}
11421146

1143-
void ScriptManager::Script_Print(const AZStd::string& message)
1147+
void ScriptManager::Script_Print(const AZStd::string& message [[maybe_unused]])
11441148
{
1149+
#ifndef RELEASE // AZ_TracePrintf is a no-op in release builds
11451150
auto func = [message]()
11461151
{
11471152
AZ_TracePrintf("Automation", "Script: %s\n", message.c_str());
11481153
};
11491154

11501155
s_instance->m_scriptOperations.push(AZStd::move(func));
1156+
#endif
11511157
}
11521158

11531159
AZStd::string ScriptManager::Script_ResolvePath(const AZStd::string& path)
@@ -1370,7 +1376,7 @@ namespace AtomSampleViewer
13701376
{
13711377
auto operation = [command]()
13721378
{
1373-
AzFramework::ConsoleRequestBus::Broadcast(&AzFramework::ConsoleRequests::ExecuteConsoleCommand, command.c_str());
1379+
AZ::Interface<AZ::IConsole>::Get()->PerformCommand(command.c_str());
13741380
};
13751381

13761382
s_instance->m_scriptOperations.push(AZStd::move(operation));
@@ -1400,9 +1406,8 @@ namespace AtomSampleViewer
14001406
s_instance->m_scriptOperations.push(AZStd::move(operation));
14011407
}
14021408

1403-
bool ScriptManager::PrepareForScreenCapture(const AZStd::string& path)
1409+
bool ScriptManager::PrepareForScreenCapture(const AZStd::string& path, const AZStd::string& envPath)
14041410
{
1405-
14061411
if (!Utils::IsFileUnderFolder(Utils::ResolvePath(path), ScreenshotPaths::GetScreenshotsFolder(true)))
14071412
{
14081413
// The main reason we require screenshots to be in a specific folder is to ensure we don't delete or replace some other important file.
@@ -1420,7 +1425,7 @@ namespace AtomSampleViewer
14201425
return false;
14211426
}
14221427

1423-
s_instance->m_scriptReporter.AddScreenshotTest(path);
1428+
s_instance->m_scriptReporter.AddScreenshotTest(path, envPath);
14241429

14251430
s_instance->m_isCapturePending = true;
14261431
s_instance->AZ::Render::FrameCaptureNotificationBus::Handler::BusConnect();
@@ -1429,6 +1434,11 @@ namespace AtomSampleViewer
14291434
return true;
14301435
}
14311436

1437+
void ScriptManager::Script_SetTestEnvPath(const AZStd::string& envPath)
1438+
{
1439+
s_instance->m_envPath = envPath;
1440+
}
1441+
14321442
void ScriptManager::Script_SelectImageComparisonToleranceLevel(const AZStd::string& presetName)
14331443
{
14341444
auto operation = [presetName]()
@@ -1446,9 +1456,15 @@ namespace AtomSampleViewer
14461456
auto operation = [filePath]()
14471457
{
14481458
// Note this will pause the script until the capture is complete
1449-
if (PrepareForScreenCapture(filePath))
1459+
if (PrepareForScreenCapture(filePath, s_instance->m_envPath))
14501460
{
1451-
AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshot, filePath);
1461+
AZ_Assert(s_instance->m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId, "Attempting to start a capture while one is in progress");
1462+
uint32_t frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
1463+
AZ::Render::FrameCaptureRequestBus::BroadcastResult(frameCaptureId, &AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshot, filePath);
1464+
if (frameCaptureId != AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId)
1465+
{
1466+
s_instance->m_frameCaptureId = frameCaptureId;
1467+
}
14521468
}
14531469
};
14541470

@@ -1473,9 +1489,15 @@ namespace AtomSampleViewer
14731489
auto operation = [filePath]()
14741490
{
14751491
// Note this will pause the script until the capture is complete
1476-
if (PrepareForScreenCapture(filePath))
1492+
if (PrepareForScreenCapture(filePath, s_instance->m_envPath))
14771493
{
1478-
AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshot, filePath);
1494+
AZ_Assert(s_instance->m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId, "Attempting to start a capture while one is in progress");
1495+
uint32_t frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
1496+
AZ::Render::FrameCaptureRequestBus::BroadcastResult(frameCaptureId, &AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshot, filePath);
1497+
if (frameCaptureId != AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId)
1498+
{
1499+
s_instance->m_frameCaptureId = frameCaptureId;
1500+
}
14791501
}
14801502
};
14811503

@@ -1497,9 +1519,15 @@ namespace AtomSampleViewer
14971519
auto operation = [filePath]()
14981520
{
14991521
// Note this will pause the script until the capture is complete
1500-
if (PrepareForScreenCapture(filePath))
1522+
if (PrepareForScreenCapture(filePath, s_instance->m_envPath))
15011523
{
1502-
AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshotWithPreview, filePath);
1524+
AZ_Assert(s_instance->m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId, "Attempting to start a capture while one is in progress");
1525+
uint32_t frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
1526+
AZ::Render::FrameCaptureRequestBus::BroadcastResult(frameCaptureId, &AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshotWithPreview, filePath);
1527+
if (frameCaptureId != AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId)
1528+
{
1529+
s_instance->m_frameCaptureId = frameCaptureId;
1530+
}
15031531
}
15041532
};
15051533

@@ -1588,9 +1616,15 @@ namespace AtomSampleViewer
15881616
auto operation = [passHierarchy, slot, outputFilePath, readbackOption]()
15891617
{
15901618
// Note this will pause the script until the capture is complete
1591-
if (PrepareForScreenCapture(outputFilePath))
1619+
if (PrepareForScreenCapture(outputFilePath, s_instance->m_envPath))
15921620
{
1593-
AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment, passHierarchy, slot, outputFilePath, readbackOption);
1621+
AZ_Assert(s_instance->m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId, "Attempting to start a capture while one is in progress");
1622+
uint32_t frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
1623+
AZ::Render::FrameCaptureRequestBus::BroadcastResult(frameCaptureId, &AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment, passHierarchy, slot, outputFilePath, readbackOption);
1624+
if (frameCaptureId != AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId)
1625+
{
1626+
s_instance->m_frameCaptureId = frameCaptureId;
1627+
}
15941628
}
15951629
};
15961630

@@ -1601,9 +1635,15 @@ namespace AtomSampleViewer
16011635
});
16021636
}
16031637

1604-
void ScriptManager::OnCaptureFinished(AZ::Render::FrameCaptureResult result, const AZStd::string &info)
1638+
void ScriptManager::OnCaptureFinished(uint32_t frameCaptureId, AZ::Render::FrameCaptureResult result, const AZStd::string &info)
16051639
{
1640+
// ignore captures that are not triggered by the script manager
1641+
if (m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId || frameCaptureId != m_frameCaptureId)
1642+
{
1643+
return;
1644+
}
16061645
m_isCapturePending = false;
1646+
m_frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
16071647
AZ::Render::FrameCaptureNotificationBus::Handler::BusDisconnect();
16081648
ResumeScript();
16091649

Gem/Code/Source/Automation/ScriptManager.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ namespace AtomSampleViewer
124124
static void Script_ShowTool(const AZStd::string& toolName, bool enable);
125125

126126
// Screenshots...
127+
// Store the test environment path of the screenshots. It will be used to figure out the baseline path.
128+
static void Script_SetTestEnvPath(const AZStd::string& envPath);
127129

128130
// Call this function before capturing screenshots to indicate which comparison tolerance level should be used.
129131
// The list of available tolerance levels can be found in "AtomSampleViewer/Config/ImageComparisonToleranceLevels.azasset".
@@ -217,7 +219,7 @@ namespace AtomSampleViewer
217219
void OnCameraMoveEnded(AZ::TypeId controllerTypeId, uint32_t channels) override;
218220

219221
// FrameCaptureNotificationBus overrides...
220-
void OnCaptureFinished(AZ::Render::FrameCaptureResult result, const AZStd::string& info) override;
222+
void OnCaptureFinished(uint32_t frameCaptureId, AZ::Render::FrameCaptureResult result, const AZStd::string& info) override;
221223

222224
// ProfilingCaptureNotificationBus overrides...
223225
void OnCaptureQueryTimestampFinished(bool result, const AZStd::string& info) override;
@@ -233,7 +235,7 @@ namespace AtomSampleViewer
233235
// Validates the ScriptDataContext for ProfilingCapture script requests
234236
static bool ValidateProfilingCaptureScripContexts(AZ::ScriptDataContext& dc, AZStd::string& outputFilePath);
235237

236-
static bool PrepareForScreenCapture(const AZStd::string& path);
238+
static bool PrepareForScreenCapture(const AZStd::string& path, const AZStd::string& envPath);
237239

238240
// show/hide imgui
239241
void SetShowImGui(bool show);
@@ -249,6 +251,8 @@ namespace AtomSampleViewer
249251

250252
TestSuiteExecutionConfig m_testSuiteRunConfig;
251253

254+
AZStd::string m_envPath = "";
255+
252256
static constexpr float DefaultPauseTimeout = 5.0f;
253257

254258
int m_scriptIdleFrames = 0;
@@ -338,6 +342,7 @@ namespace AtomSampleViewer
338342
bool m_showPrecommitWizard = false;
339343
PrecommitWizardSettings m_wizardSettings;
340344

345+
uint32_t m_frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
341346
bool m_showScriptRunnerDialog = false;
342347
bool m_isCapturePending = false;
343348
bool m_frameTimeIsLocked = false;

0 commit comments

Comments
 (0)