Skip to content

Commit

Permalink
Merge pull request #534 from o3de/stabilization/2210
Browse files Browse the repository at this point in the history
Merge stabilization/2210 into main
Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>
  • Loading branch information
AMZN-alexpete authored Oct 12, 2022
2 parents fdef502 + 6e9e09c commit 9bcf25a
Show file tree
Hide file tree
Showing 292 changed files with 2,163 additions and 1,734 deletions.
1 change: 1 addition & 0 deletions Gem/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ly_add_target(
Gem::Atom_Component_DebugCamera.Static
Gem::AtomSampleViewer.Lib.Static
Gem::Profiler.Static
Gem::DiffuseProbeGrid.Static
)

ly_add_target(
Expand Down
10 changes: 10 additions & 0 deletions Gem/Code/Source/AssetLoadTestComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ namespace AtomSampleViewer

m_modelBrowser.ResetPinnedAssetsToDefault();
}

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

Base::Activate();
}
Expand Down
14 changes: 14 additions & 0 deletions Gem/Code/Source/AtomSampleComponent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 <AtomSampleComponent.h>

namespace AtomSampleViewer
{

}
36 changes: 36 additions & 0 deletions Gem/Code/Source/AtomSampleComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 <AzCore/Component/Component.h>

namespace AtomSampleViewer
{
class AtomSampleComponent
: public AZ::Component
{
public:
AZ_RTTI(AtomSampleComponent, "{2318DFD6-BC6B-4335-9F25-8E270A10CA81}", AZ::Component);

AtomSampleComponent() = default;
~AtomSampleComponent() override = default;

// Redefine this string in the sample component subclass to provide a sample-specific warning message.
// Any non-empty string will automatically cause a warning message to be displayed before opening the sample.
static constexpr const char* ContentWarning = "";

// If the above ContentWarning is overridden with a non-empty value, this string will be used as the message box's title.
// Redefine this string in the sample component subclass to provide a custom title.
static constexpr const char* ContentWarningTitle = "Content Warning";

// This is a common photosensitive/seizure warning that could be used for the above ContentWarning in specific samples as needed.
static constexpr const char CommonPhotosensitiveWarning[] = "This sample includes flashing images that could cause seizures or other adverse effects in photosensitive individuals.";
static constexpr const char CommonPhotosensitiveWarningTitle[] = "Photosensitive Seizure Warning";
};
} // namespace AtomSampleViewer
1 change: 0 additions & 1 deletion Gem/Code/Source/AtomSampleViewerSystemComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <Atom/RHI/Factory.h>
#include <Atom/RPI.Public/RPISystemInterface.h>
#include <Atom/RPI.Public/Shader/Metrics/ShaderMetricsSystem.h>

#include <ISystem.h>
#include <IConsole.h>
Expand Down
70 changes: 55 additions & 15 deletions Gem/Code/Source/Automation/ScriptManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <Atom/RHI/Factory.h>

#include <AzCore/Component/Entity.h>
#include <AzCore/Settings/SettingsRegistryScriptUtils.h>
#include <AzCore/Script/ScriptContext.h>
#include <AzCore/Script/ScriptSystemBus.h>
#include <AzCore/Script/ScriptAsset.h>
Expand Down Expand Up @@ -966,7 +967,8 @@ namespace AtomSampleViewer

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

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

// Utilities...
behaviorContext->Method("RunScript", &Script_RunScript);
Expand Down Expand Up @@ -1086,6 +1089,7 @@ namespace AtomSampleViewer
behaviorContext->Method("ShowTool", &Script_ShowTool);

// Screenshots...
behaviorContext->Method("SetTestEnvPath", &Script_SetTestEnvPath);
behaviorContext->Method("SelectImageComparisonToleranceLevel", &Script_SelectImageComparisonToleranceLevel);
behaviorContext->Method("CaptureScreenshot", &Script_CaptureScreenshot);
behaviorContext->Method("CaptureScreenshotWithImGui", &Script_CaptureScreenshotWithImGui);
Expand Down Expand Up @@ -1140,14 +1144,16 @@ namespace AtomSampleViewer
s_instance->m_scriptOperations.push(AZStd::move(func));
}

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

s_instance->m_scriptOperations.push(AZStd::move(func));
#endif
}

AZStd::string ScriptManager::Script_ResolvePath(const AZStd::string& path)
Expand Down Expand Up @@ -1370,7 +1376,7 @@ namespace AtomSampleViewer
{
auto operation = [command]()
{
AzFramework::ConsoleRequestBus::Broadcast(&AzFramework::ConsoleRequests::ExecuteConsoleCommand, command.c_str());
AZ::Interface<AZ::IConsole>::Get()->PerformCommand(command.c_str());
};

s_instance->m_scriptOperations.push(AZStd::move(operation));
Expand Down Expand Up @@ -1400,9 +1406,8 @@ namespace AtomSampleViewer
s_instance->m_scriptOperations.push(AZStd::move(operation));
}

bool ScriptManager::PrepareForScreenCapture(const AZStd::string& path)
bool ScriptManager::PrepareForScreenCapture(const AZStd::string& path, const AZStd::string& envPath)
{

if (!Utils::IsFileUnderFolder(Utils::ResolvePath(path), ScreenshotPaths::GetScreenshotsFolder(true)))
{
// 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.
Expand All @@ -1420,7 +1425,7 @@ namespace AtomSampleViewer
return false;
}

s_instance->m_scriptReporter.AddScreenshotTest(path);
s_instance->m_scriptReporter.AddScreenshotTest(path, envPath);

s_instance->m_isCapturePending = true;
s_instance->AZ::Render::FrameCaptureNotificationBus::Handler::BusConnect();
Expand All @@ -1429,6 +1434,11 @@ namespace AtomSampleViewer
return true;
}

void ScriptManager::Script_SetTestEnvPath(const AZStd::string& envPath)
{
s_instance->m_envPath = envPath;
}

void ScriptManager::Script_SelectImageComparisonToleranceLevel(const AZStd::string& presetName)
{
auto operation = [presetName]()
Expand All @@ -1446,9 +1456,15 @@ namespace AtomSampleViewer
auto operation = [filePath]()
{
// Note this will pause the script until the capture is complete
if (PrepareForScreenCapture(filePath))
if (PrepareForScreenCapture(filePath, s_instance->m_envPath))
{
AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshot, filePath);
AZ_Assert(s_instance->m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId, "Attempting to start a capture while one is in progress");
uint32_t frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
AZ::Render::FrameCaptureRequestBus::BroadcastResult(frameCaptureId, &AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshot, filePath);
if (frameCaptureId != AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId)
{
s_instance->m_frameCaptureId = frameCaptureId;
}
}
};

Expand All @@ -1473,9 +1489,15 @@ namespace AtomSampleViewer
auto operation = [filePath]()
{
// Note this will pause the script until the capture is complete
if (PrepareForScreenCapture(filePath))
if (PrepareForScreenCapture(filePath, s_instance->m_envPath))
{
AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshot, filePath);
AZ_Assert(s_instance->m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId, "Attempting to start a capture while one is in progress");
uint32_t frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
AZ::Render::FrameCaptureRequestBus::BroadcastResult(frameCaptureId, &AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshot, filePath);
if (frameCaptureId != AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId)
{
s_instance->m_frameCaptureId = frameCaptureId;
}
}
};

Expand All @@ -1497,9 +1519,15 @@ namespace AtomSampleViewer
auto operation = [filePath]()
{
// Note this will pause the script until the capture is complete
if (PrepareForScreenCapture(filePath))
if (PrepareForScreenCapture(filePath, s_instance->m_envPath))
{
AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshotWithPreview, filePath);
AZ_Assert(s_instance->m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId, "Attempting to start a capture while one is in progress");
uint32_t frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
AZ::Render::FrameCaptureRequestBus::BroadcastResult(frameCaptureId, &AZ::Render::FrameCaptureRequestBus::Events::CaptureScreenshotWithPreview, filePath);
if (frameCaptureId != AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId)
{
s_instance->m_frameCaptureId = frameCaptureId;
}
}
};

Expand Down Expand Up @@ -1588,9 +1616,15 @@ namespace AtomSampleViewer
auto operation = [passHierarchy, slot, outputFilePath, readbackOption]()
{
// Note this will pause the script until the capture is complete
if (PrepareForScreenCapture(outputFilePath))
if (PrepareForScreenCapture(outputFilePath, s_instance->m_envPath))
{
AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment, passHierarchy, slot, outputFilePath, readbackOption);
AZ_Assert(s_instance->m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId, "Attempting to start a capture while one is in progress");
uint32_t frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
AZ::Render::FrameCaptureRequestBus::BroadcastResult(frameCaptureId, &AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment, passHierarchy, slot, outputFilePath, readbackOption);
if (frameCaptureId != AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId)
{
s_instance->m_frameCaptureId = frameCaptureId;
}
}
};

Expand All @@ -1601,9 +1635,15 @@ namespace AtomSampleViewer
});
}

void ScriptManager::OnCaptureFinished(AZ::Render::FrameCaptureResult result, const AZStd::string &info)
void ScriptManager::OnCaptureFinished(uint32_t frameCaptureId, AZ::Render::FrameCaptureResult result, const AZStd::string &info)
{
// ignore captures that are not triggered by the script manager
if (m_frameCaptureId == AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId || frameCaptureId != m_frameCaptureId)
{
return;
}
m_isCapturePending = false;
m_frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
AZ::Render::FrameCaptureNotificationBus::Handler::BusDisconnect();
ResumeScript();

Expand Down
9 changes: 7 additions & 2 deletions Gem/Code/Source/Automation/ScriptManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ namespace AtomSampleViewer
static void Script_ShowTool(const AZStd::string& toolName, bool enable);

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

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

// FrameCaptureNotificationBus overrides...
void OnCaptureFinished(AZ::Render::FrameCaptureResult result, const AZStd::string& info) override;
void OnCaptureFinished(uint32_t frameCaptureId, AZ::Render::FrameCaptureResult result, const AZStd::string& info) override;

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

static bool PrepareForScreenCapture(const AZStd::string& path);
static bool PrepareForScreenCapture(const AZStd::string& path, const AZStd::string& envPath);

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

TestSuiteExecutionConfig m_testSuiteRunConfig;

AZStd::string m_envPath = "";

static constexpr float DefaultPauseTimeout = 5.0f;

int m_scriptIdleFrames = 0;
Expand Down Expand Up @@ -338,6 +342,7 @@ namespace AtomSampleViewer
bool m_showPrecommitWizard = false;
PrecommitWizardSettings m_wizardSettings;

uint32_t m_frameCaptureId = AZ::Render::FrameCaptureRequests::s_InvalidFrameCaptureId;
bool m_showScriptRunnerDialog = false;
bool m_isCapturePending = false;
bool m_frameTimeIsLocked = false;
Expand Down
Loading

0 comments on commit 9bcf25a

Please sign in to comment.