Selaa lähdekoodia

Screenshots stored from nightly Jenkins ASV "Test GPU Profile" only contain Vulkan versions, not DX12 versions (#496)

* Add suffix to screenshot file name

Signed-off-by: jiaweig <[email protected]>

* Update screenshot scripts

Signed-off-by: jiaweig <[email protected]>

* Remove duplicated function

Signed-off-by: jiaweig <[email protected]>

* Change to add the env info to a folder instead of the file name

Signed-off-by: jiaweig <[email protected]>

* Optimize code

Signed-off-by: jiaweig <[email protected]>

Signed-off-by: jiaweig <[email protected]>
jiaweig 2 vuotta sitten
vanhempi
commit
6634711124

+ 12 - 7
Gem/Code/Source/Automation/ScriptManager.cpp

@@ -1089,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);
@@ -1405,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.
@@ -1425,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();
@@ -1434,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]()
@@ -1451,7 +1456,7 @@ 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_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;
@@ -1484,7 +1489,7 @@ 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_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;
@@ -1514,7 +1519,7 @@ 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_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;
@@ -1611,7 +1616,7 @@ 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_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;

+ 5 - 1
Gem/Code/Source/Automation/ScriptManager.h

@@ -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".
@@ -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);
@@ -249,6 +251,8 @@ namespace AtomSampleViewer
 
         TestSuiteExecutionConfig m_testSuiteRunConfig;
 
+        AZStd::string m_envPath = "";
+
         static constexpr float DefaultPauseTimeout = 5.0f;
 
         int m_scriptIdleFrames = 0;

+ 18 - 10
Gem/Code/Source/Automation/ScriptReporter.cpp

@@ -45,7 +45,7 @@ namespace AtomSampleViewer
 
         AZStd::string GetLocalBaselineFolder(bool resolvePath)
         {
-            AZStd::string path = AZStd::string::format("@user@/scripts/screenshotslocalbaseline/%s", AZ::RHI::Factory::Get().GetName().GetCStr());
+            AZStd::string path = AZStd::string::format("@user@/scripts/screenshotslocalbaseline/");
 
             if (resolvePath)
             {
@@ -76,10 +76,10 @@ namespace AtomSampleViewer
             {
                 newPath = "";
             }
-            return newPath;
+            return Utils::ResolvePath(newPath);
         }
 
-        AZStd::string GetOfficialBaseline(const AZStd::string& forScreenshotFile)
+        AZStd::string GetOfficialBaseline(const AZStd::string& forScreenshotFile, const AZStd::string& envPath)
         {
             AZStd::string path = forScreenshotFile;
             const AZStd::string userPath = Utils::ResolvePath("@user@");
@@ -96,6 +96,10 @@ namespace AtomSampleViewer
                 return "";
             }
 
+            if (!AzFramework::StringFunc::Replace(path, envPath.c_str(), ""))
+            {
+                return "";
+            }
             // Turn it back into a full path
             path = Utils::ResolvePath("@projectroot@/" + path);
 
@@ -204,12 +208,18 @@ namespace AtomSampleViewer
         return !m_currentScriptIndexStack.empty();
     }
 
-    bool ScriptReporter::AddScreenshotTest(const AZStd::string& path)
+    ScriptReporter::ScreenshotTestInfo::ScreenshotTestInfo(const AZStd::string& screenshotFilePath, const AZStd::string& envPath)
+        : m_screenshotFilePath(Utils::ResolvePath(screenshotFilePath))
+    {
+        m_officialBaselineScreenshotFilePath = ScreenshotPaths::GetOfficialBaseline(m_screenshotFilePath, envPath);
+        m_localBaselineScreenshotFilePath = ScreenshotPaths::GetLocalBaseline(m_screenshotFilePath);
+    }
+
+    bool ScriptReporter::AddScreenshotTest(const AZStd::string& path, const AZStd::string& envPath)
     {
         AZ_Assert(GetCurrentScriptReport(), "There is no active script");
 
-        ScreenshotTestInfo screenshotTestInfo;
-        screenshotTestInfo.m_screenshotFilePath = path;
+        ScreenshotTestInfo screenshotTestInfo(path, envPath);
         GetCurrentScriptReport()->m_screenshotTests.push_back(AZStd::move(screenshotTestInfo));
 
         return true;
@@ -1000,7 +1010,7 @@ namespace AtomSampleViewer
     
     bool ScriptReporter::UpdateLocalBaselineImage(ScreenshotTestInfo& screenshotTest, bool showResultDialog)
     {
-        const AZStd::string destinationFile = ScreenshotPaths::GetLocalBaseline(screenshotTest.m_screenshotFilePath);
+        const AZStd::string destinationFile = screenshotTest.m_localBaselineScreenshotFilePath;
 
         AZStd::string destinationFolder = destinationFile;
         AzFramework::StringFunc::Path::StripFullName(destinationFolder);
@@ -1055,7 +1065,7 @@ namespace AtomSampleViewer
         }
 
         // Get official cache baseline file
-        const AZStd::string cacheFilePath = ScreenshotPaths::GetOfficialBaseline(screenshotTest.m_screenshotFilePath);
+        const AZStd::string cacheFilePath = screenshotTest.m_officialBaselineScreenshotFilePath;
 
         // Divide cache file path into components to we can access the file name and the parent folder
         AZStd::fixed_vector<AZ::IO::FixedMaxPathString, 16> reversePathComponents;
@@ -1160,7 +1170,6 @@ namespace AtomSampleViewer
 
         screenshotTestInfo.m_toleranceLevel = *toleranceLevel;
 
-        screenshotTestInfo.m_officialBaselineScreenshotFilePath = ScreenshotPaths::GetOfficialBaseline(screenshotTestInfo.m_screenshotFilePath);
         if (screenshotTestInfo.m_officialBaselineScreenshotFilePath.empty())
         {
             ReportScriptError(AZStd::string::format("Screenshot check failed. Could not determine expected screenshot path for '%s'", screenshotTestInfo.m_screenshotFilePath.c_str()));
@@ -1199,7 +1208,6 @@ namespace AtomSampleViewer
             }
         }
 
-        screenshotTestInfo.m_localBaselineScreenshotFilePath = ScreenshotPaths::GetLocalBaseline(screenshotTestInfo.m_screenshotFilePath);
         if (screenshotTestInfo.m_localBaselineScreenshotFilePath.empty())
         {
             ReportScriptWarning(AZStd::string::format("Screenshot check failed. Could not determine local baseline screenshot path for '%s'", screenshotTestInfo.m_screenshotFilePath.c_str()));

+ 4 - 2
Gem/Code/Source/Automation/ScriptReporter.h

@@ -38,7 +38,7 @@ namespace AtomSampleViewer
         AZStd::string GetLocalBaseline(const AZStd::string& forScreenshotFile);
 
         //! Returns the path to the official baseline image that corresponds to @forScreenshotFile
-        AZStd::string GetOfficialBaseline(const AZStd::string& forScreenshotFile);
+        AZStd::string GetOfficialBaseline(const AZStd::string& forScreenshotFile, const AZStd::string& envPath);
     }
 
     //! Collects data about each script run by the ScriptManager.
@@ -75,7 +75,7 @@ namespace AtomSampleViewer
         bool HasActiveScript() const;
 
         //! Indicates that a new screenshot is about to be captured.
-        bool AddScreenshotTest(const AZStd::string& path);
+        bool AddScreenshotTest(const AZStd::string& path, const AZStd::string& envPath);
 
         //! Check the latest screenshot using default thresholds.
         void CheckLatestScreenshot(const ImageComparisonToleranceLevel* comparisonPreset);
@@ -139,6 +139,8 @@ namespace AtomSampleViewer
             ImageComparisonToleranceLevel m_toleranceLevel;     //!< Tolerance for checking against the official baseline image
             ImageComparisonResult m_officialComparisonResult;   //!< Result of comparing against the official baseline image, for reporting test failure
             ImageComparisonResult m_localComparisonResult;      //!< Result of comparing against a local baseline, for reporting warnings
+
+            ScreenshotTestInfo(const AZStd::string& screenshotFilePath, const AZStd::string& envPath);
         };
 
         //! Records all the information about a single test script.

+ 3 - 1
Scripts/AreaLightTest.bv.lua

@@ -9,6 +9,8 @@
 --
 ----------------------------------------------------------------------------------------------------
 
+RunScript("scripts/TestEnvironment.luac")
+
 function SetupPointLights()
     SetImguiValue('AreaLightSample/LightType/Point', true)
     SetImguiValue('AreaLightSample/Position Offset', Vector3(0.0, 0.0, 0.0))
@@ -109,7 +111,7 @@ function VaryMetallicOnly()
     SetImguiValue('AreaLightSample/Min Max Metallic', Vector2(0.0, 1.0))
 end
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/AreaLights/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/AreaLights/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 SelectImageComparisonToleranceLevel("Level E")
 

+ 3 - 1
Scripts/AuxGeom.bv.lua

@@ -9,6 +9,8 @@
 --
 ----------------------------------------------------------------------------------------------------
 
+RunScript("scripts/TestEnvironment.luac")
+
 function TakeScreenShotBoxes()
 
     NoClipCameraController_SetFov(DegToRad(70))
@@ -29,7 +31,7 @@ function TakeScreenShotShapes()
     CaptureScreenshot(g_screenshotOutputFolder .. '/auxgeom_shapes.png')
 end
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/AuxGeom/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/AuxGeom/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/AuxGeom')

+ 3 - 1
Scripts/CheckerboardTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/Checkerboard/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/Checkerboard/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/Checkerboard')

+ 3 - 1
Scripts/CullingAndLod.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/CullingAndLod/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/CullingAndLod/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/CullingAndLod')

+ 3 - 1
Scripts/Decals.bv.lua

@@ -9,11 +9,13 @@
 --
 ----------------------------------------------------------------------------------------------------
 
+RunScript("scripts/TestEnvironment.luac")
+
 function TakeScreenshots()
     CaptureScreenshot(g_screenshotOutputFolder .. '/screenshot_decals.png')
 end
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/Decals/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/Decals/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/Decals')

+ 3 - 1
Scripts/DepthOfFieldTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/DepthOfFieldTest/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/DepthOfFieldTest/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/DepthOfField')

+ 3 - 1
Scripts/DiffuseGITest.bv.lua

@@ -9,10 +9,12 @@
 --
 ----------------------------------------------------------------------------------------------------
 
+RunScript("scripts/TestEnvironment.luac")
+
 if GetRenderApiName() == "vulkan" or GetRenderApiName() == "metal" then
     Warning("Vulkan or metal is not supported by this test.")
 else
-    g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/DiffuseGITest/')
+    g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/DiffuseGITest/')
     Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
     OpenSample('Features/DiffuseGI')

+ 3 - 1
Scripts/DynamicDraw.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/DynamicDraw/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/DynamicDraw/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/DynamicDraw')

+ 3 - 1
Scripts/DynamicMaterialTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/DynamicMaterialTest/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/DynamicMaterialTest/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/DynamicMaterialTest')

+ 3 - 1
Scripts/ExposureTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/ExposureTest/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/ExposureTest/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/Exposure')

+ 14 - 1
Scripts/EyeMaterialTest.bv.lua

@@ -1,4 +1,17 @@
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/EyeMaterial/')
+----------------------------------------------------------------------------------------------------
+--
+-- 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
+--
+--
+--
+----------------------------------------------------------------------------------------------------
+
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/EyeMaterial/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/EyeMaterial')

+ 3 - 1
Scripts/LightCulling.bv.lua

@@ -9,6 +9,8 @@
 --
 ----------------------------------------------------------------------------------------------------
 
+RunScript("scripts/TestEnvironment.luac")
+
 function ResetEntityCounts()
     SetImguiValue('Point Lights/Point light count', 0)
     SetImguiValue('Decals/Decal count', 0)
@@ -103,7 +105,7 @@ function EnableOnlyTestHeatmap()
     SetImguiValue('Heatmap/Opacity', 1.0)
 end
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/LightCulling/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/LightCulling/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 SelectImageComparisonToleranceLevel("Level E")
 

+ 3 - 1
Scripts/MSAA_RPI_Test.bv.lua

@@ -9,6 +9,8 @@
 --
 ----------------------------------------------------------------------------------------------------
 
+RunScript("scripts/TestEnvironment.luac")
+
 function TakeScreenShot4xCylinder()
 
     SetImguiValue('Mode/MSAA 4x', true)
@@ -18,7 +20,7 @@ function TakeScreenShot4xCylinder()
     CaptureScreenshot(g_screenshotOutputFolder .. '/screenshot_msaa4x_cylinder.png')
 end
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/MSAA_RPI/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/MSAA_RPI/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/MSAA')

+ 3 - 1
Scripts/MaterialHotReloadTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/MaterialHotReloadTest/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/MaterialHotReloadTest/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 g_assetFolder = "materials/hotreloadtest/temp/";

+ 7 - 6
Scripts/MaterialScreenshotTests.bv.lua

@@ -9,6 +9,7 @@
 --
 ----------------------------------------------------------------------------------------------------
 
+RunScript("scripts/TestEnvironment.luac")
 
 g_shaderballModel = 'materialeditor/viewportmodels/shaderball.azmodel'
 g_cubeModel = 'materialeditor/viewportmodels/cube.azmodel'
@@ -92,7 +93,7 @@ SetImguiValue('Show Ground Plane', false)
 -- StandardPBR Materials...
 
 g_testMaterialsFolder = 'testdata/materials/standardpbrtestcases/'
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/StandardPBR/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/StandardPBR/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 GenerateMaterialScreenshot('Level C', '001_DefaultWhite')
@@ -161,7 +162,7 @@ GenerateMaterialScreenshot('Level H', '105_DetailMaps_BlendMaskUsingDetailUVs',
 -- StandardMultilayerPBR Materials...
 
 g_testMaterialsFolder = 'testdata/materials/standardmultilayerpbrtestcases/'
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/StandardMultilayerPBR/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/StandardMultilayerPBR/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 GenerateMaterialScreenshot('Level I', '001_ManyFeatures', {model=g_cubeModel, cameraHeading=-125.0, cameraPitch=-16.0, cameraZ=0.12})
@@ -185,7 +186,7 @@ GenerateMaterialScreenshot('Level I', '005_UseDisplacement_With_BlendMaskTexture
 -- Skin Materials...
 
 g_testMaterialsFolder = 'testdata/materials/skintestcases/'
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/Skin/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/Skin/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 -- We should eventually replace this with realistic skin test cases, these are just placeholders for regression testing
@@ -196,7 +197,7 @@ GenerateMaterialScreenshot('Level G', '002_wrinkle_regression_test', {model=g_mo
 -- MinimalPBR Materials...
 
 g_testMaterialsFolder = 'materials/minimalpbr/'
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/MinimalPBR/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/MinimalPBR/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 GenerateMaterialScreenshot('Level B', 'MinimalPbr_Default')
@@ -208,7 +209,7 @@ GenerateMaterialScreenshot('Level D', 'MinimalPbr_RedDielectric')
 -- This test is here only temporarily for regression testing until StandardMultilayerPBR is refactored to use reused nested property groups.
 
 g_testMaterialsFolder = 'materials/types/'
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/MinimalPBR/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/MinimalPBR/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 GenerateMaterialScreenshot('Level G', 'MinimalMultilayerExample')
@@ -216,7 +217,7 @@ GenerateMaterialScreenshot('Level G', 'MinimalMultilayerExample')
 ----------------------------------------------------------------------
 -- AutoBrick Materials...
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/AutoBrick/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/AutoBrick/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 g_testMaterialsFolder = 'testdata/materials/autobrick/'

+ 3 - 1
Scripts/MultiRenderPipeline.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/MultiRenderPipeline/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/MultiRenderPipeline/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 function TakeScreenShotForWindow1(fileName)

+ 3 - 1
Scripts/MultiScene.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/MultiScene/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/MultiScene/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 function TakeScreenShotFromPrimaryWindow(fileName)

+ 3 - 1
Scripts/ParallaxDepthArtifacts.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/ParallaxDepthArtifacts/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/ParallaxDepthArtifacts/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/Parallax')

+ 3 - 1
Scripts/ParallaxTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/ParallaxTest/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/ParallaxTest/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/Parallax')

+ 3 - 1
Scripts/PassTree.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/PassTree/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/PassTree/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 -- Select an attachment; take a screenshot with preview output (used for screenshot comparison); capture and save the attachment.

+ 3 - 1
Scripts/ReadbackTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/Readback')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/Readback')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/Readback')

+ 3 - 1
Scripts/RenderTargetTexture.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/RenderTargetTexture/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/RenderTargetTexture/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/RenderTargetTexture')

+ 3 - 1
Scripts/SceneReloadSoakTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/SceneReloadSoakTest/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/SceneReloadSoakTest/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 -- First we capture a screenshot to make sure everything is rendering correctly...

+ 2 - 0
Scripts/ShaderReloadSoakTest.bv.lua

@@ -12,6 +12,8 @@
 -- WARNING: This is a soak test, do not add this test to the fully automated
 -- test suites.
 
+RunScript("scripts/TestEnvironment.luac")
+
 OpenSample('RPI/ShaderReloadTest')
 ResizeViewport(500, 500)
 

+ 4 - 2
Scripts/ShadowTest.bv.lua

@@ -9,6 +9,8 @@
 --
 ----------------------------------------------------------------------------------------------------
 
+RunScript("scripts/TestEnvironment.luac")
+
 function EnablePositionalLights()
     SetImguiValue('Red', true)
     SetImguiValue('Intensity##Positional', 500.0)
@@ -98,7 +100,7 @@ function TestDirectionalLight()
     -- Directional Light ESM+PCF
     SetImguiValue('Filter Method##Directional', 'ESM+PCF')
     IdleFrames(1)
-    CaptureScreenshot(g_screenshotOutputFolder .. '/directional_esm_pcf.png')    
+    CaptureScreenshot(g_screenshotOutputFolder .. '/directional_esm_pcf.png')
 end
 
 function TestDiskLights()
@@ -161,7 +163,7 @@ function TestPointLights()
     CaptureScreenshot(g_screenshotOutputFolder .. '/point_lights.png')
 end
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/Shadow/')
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/Shadow/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/Shadow')

+ 3 - 1
Scripts/ShadowedSponzaTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/ShadowedSponza/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/ShadowedSponza/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 

+ 3 - 1
Scripts/SkinnedMesh.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/SkinnedMesh/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/SkinnedMesh/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/SkinnedMesh')

+ 3 - 1
Scripts/StreamingImageTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/StreamingImage/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/StreamingImage/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('RPI/StreamingImage')

+ 8 - 0
Scripts/TestEnvironment.lua

@@ -0,0 +1,8 @@
+g_renderApiName = GetRenderApiName()
+
+-- surround the actual env so that it won't match other part of the path when IO is operating the file path.
+stringCollisionProtector = '___'
+
+g_testEnv = stringCollisionProtector .. g_renderApiName .. stringCollisionProtector;
+
+SetTestEnvPath(g_testEnv)

+ 3 - 1
Scripts/TransparentTest.bv.lua

@@ -9,7 +9,9 @@
 --
 ----------------------------------------------------------------------------------------------------
 
-g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/TransparentTest/')
+RunScript("scripts/TestEnvironment.luac")
+
+g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/' .. g_testEnv .. '/TransparentTest/')
 Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
 
 OpenSample('Features/Transparency')

+ 1 - 0
atomsampleviewer_asset_files.cmake

@@ -56,6 +56,7 @@ set(FILES
     Scripts/ShadowTest.bv.lua
     Scripts/SkinnedMesh.bv.lua
     Scripts/StreamingImageTest.bv.lua
+    Scripts/TestEnvironment.lua
     Scripts/TransparentTest.bv.lua
     Scripts/_AutomatedPeriodicBenchmarkSuite_.bv.lua
     Scripts/_FullTestSuite_.bv.lua