Exemplo n.º 1
0
    public IEnumerator Run(GraphicsTestCase testCase)
    {
        SceneManager.LoadScene(testCase.ScenePath);

        // Always wait one frame for scene load
        yield return(null);

        var cameras  = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent <Camera>());
        var settings = Object.FindObjectOfType <UniversalGraphicsTestSettings>();

        Assert.IsNotNull(settings, "Invalid test scene, couldn't find UniversalGraphicsTestSettings");

        Scene scene = SceneManager.GetActiveScene();

        yield return(null);

        for (int i = 0; i < settings.WaitFrames; i++)
        {
            yield return(null);
        }

#if UNITY_ANDROID
        // On Android first scene often needs a bit more frames to load all the assets
        // otherwise the screenshot is just a black screen
        if (!wasFirstSceneRan)
        {
            for (int i = 0; i < firstSceneAdditionalFrames; i++)
            {
                yield return(null);
            }
            wasFirstSceneRan = true;
        }
#endif

        ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), settings.ImageComparisonSettings);

        // Does it allocate memory when it renders what's on the main camera?
        bool allocatesMemory = false;
        var  mainCamera      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        // 2D Renderer is currently allocating memory, skip it as it will always fail GC alloc tests.
        var  additionalCameraData = mainCamera.GetUniversalAdditionalCameraData();
        bool is2DRenderer         = additionalCameraData.scriptableRenderer is Renderer2D;

        if (!is2DRenderer)
        {
            try
            {
                ImageAssert.AllocatesMemory(mainCamera, settings?.ImageComparisonSettings);
            }
            catch (AssertionException)
            {
                allocatesMemory = true;
            }
            if (allocatesMemory)
            {
                Assert.Fail("Allocated memory when rendering what is on main camera");
            }
        }
    }
Exemplo n.º 2
0
    public IEnumerator Run(GraphicsTestCase testCase)
    {
#if ENABLE_VR && ENABLE_XR_MODULE
        // XRTODO: Fix XR tests on macOS or disable them from Yamato directly
        if (XRSystem.testModeEnabled && (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer))
        {
            Assert.Ignore("Universal XR tests do not run on macOS.");
        }
#endif
        SceneManager.LoadScene(testCase.ScenePath);

        // Always wait one frame for scene load
        yield return(null);

        var cameras  = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent <Camera>());
        var settings = Object.FindObjectOfType <UniversalGraphicsTestSettings>();
        Assert.IsNotNull(settings, "Invalid test scene, couldn't find UniversalGraphicsTestSettings");

#if ENABLE_VR && ENABLE_XR_MODULE
        if (XRSystem.testModeEnabled)
        {
            if (settings.XRCompatible)
            {
                XRSystem.automatedTestRunning = true;
            }
            else
            {
                Assert.Ignore("Test scene is not compatible with XR and will be skipped.");
            }
        }
#endif

        Scene scene = SceneManager.GetActiveScene();

        yield return(null);

        int waitFrames = settings.WaitFrames;

        if (settings.ImageComparisonSettings.UseBackBuffer && settings.WaitFrames < 1)
        {
            waitFrames = 1;
        }
        for (int i = 0; i < waitFrames; i++)
        {
            yield return(new WaitForEndOfFrame());
        }

#if UNITY_ANDROID
        // On Android first scene often needs a bit more frames to load all the assets
        // otherwise the screenshot is just a black screen
        if (!wasFirstSceneRan)
        {
            for (int i = 0; i < firstSceneAdditionalFrames; i++)
            {
                yield return(null);
            }
            wasFirstSceneRan = true;
        }
#endif

        ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), settings.ImageComparisonSettings);

        // Does it allocate memory when it renders what's on the main camera?
        bool allocatesMemory = false;
        var  mainCamera      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        try
        {
            ImageAssert.AllocatesMemory(mainCamera, settings?.ImageComparisonSettings);
        }
        catch (AssertionException)
        {
            allocatesMemory = true;
        }

        if (allocatesMemory)
        {
            Assert.Fail("Allocated memory when rendering what is on main camera");
        }
    }
    [Timeout(300 * 1000)] // Set timeout to 5 minutes to handle complex scenes with many shaders (default timeout is 3 minutes)
    public IEnumerator Run(GraphicsTestCase testCase)
    {
        SceneManager.LoadScene(testCase.ScenePath);

        // Arbitrary wait for 5 frames for the scene to load, and other stuff to happen (like Realtime GI to appear ...)
        for (int i = 0; i < 5; ++i)
        {
            yield return(null);
        }

        // Load the test settings
        var settings = GameObject.FindObjectOfType <HDRP_TestSettings>();

        var camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        if (camera == null)
        {
            camera = GameObject.FindObjectOfType <Camera>();
        }
        if (camera == null)
        {
            Assert.Fail("Missing camera for graphic tests.");
        }

        Time.captureFramerate = settings.captureFramerate;

        if (XRGraphicsAutomatedTests.enabled)
        {
            if (settings.xrCompatible)
            {
                XRGraphicsAutomatedTests.running = true;

                // Increase tolerance to account for slight changes due to float precision
                settings.ImageComparisonSettings.AverageCorrectnessThreshold  *= settings.xrThresholdMultiplier;
                settings.ImageComparisonSettings.PerPixelCorrectnessThreshold *= settings.xrThresholdMultiplier;

                // Increase number of volumetric slices to compensate for initial half-resolution due to XR single-pass optimization
                foreach (var volume in GameObject.FindObjectsOfType <Volume>())
                {
                    if (volume.profile.TryGet <Fog>(out Fog fog))
                    {
                        fog.volumeSliceCount.value *= 2;
                    }
                }
            }
            else
            {
                Assert.Ignore("Test scene is not compatible with XR and will be skipped.");
            }
        }

        if (settings.doBeforeTest != null)
        {
            settings.doBeforeTest.Invoke();

            // Wait again one frame, to be sure.
            yield return(null);
        }

        // Reset temporal effects on hdCamera
        HDCamera.GetOrCreate(camera).Reset();

        for (int i = 0; i < settings.waitFrames; ++i)
        {
            yield return(null);
        }

        var settingsSG = (GameObject.FindObjectOfType <HDRP_TestSettings>() as HDRP_ShaderGraph_TestSettings);

        if (settingsSG == null || !settingsSG.compareSGtoBI)
        {
            // Standard Test
            ImageAssert.AreEqual(testCase.ReferenceImage, camera, settings?.ImageComparisonSettings);

            // For some reason, tests on mac os have started failing with render graph enabled by default.
            // Some tests have 400+ gcalloc in them. Unfortunately it's not reproductible outside of command line so it's impossible to debug.
            // That's why we don't test on macos anymore.
            if (settings.checkMemoryAllocation && SystemInfo.graphicsDeviceType != GraphicsDeviceType.Metal)
            {
                // Does it allocate memory when it renders what's on camera?
                bool allocatesMemory = false;
                try
                {
                    // GC alloc from Camera.CustomRender (case 1206364)
                    int gcAllocThreshold = 2;

                    ImageAssert.AllocatesMemory(camera, settings?.ImageComparisonSettings, gcAllocThreshold);
                }
                catch (AssertionException)
                {
                    allocatesMemory = true;
                }
                if (allocatesMemory)
                {
                    Assert.Fail("Allocated memory when rendering what is on camera");
                }
            }
        }
        else
        {
            if (settingsSG.sgObjs == null)
            {
                Assert.Fail("Missing Shader Graph objects in test scene.");
            }
            if (settingsSG.biObjs == null)
            {
                Assert.Fail("Missing comparison objects in test scene.");
            }

            settingsSG.sgObjs.SetActive(true);
            settingsSG.biObjs.SetActive(false);
            yield return(null); // Wait a frame

            yield return(null);

            bool sgFail = false;
            bool biFail = false;

            // First test: Shader Graph
            try
            {
                ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null);
            }
            catch (AssertionException)
            {
                sgFail = true;
            }

            settingsSG.sgObjs.SetActive(false);
            settingsSG.biObjs.SetActive(true);
            settingsSG.biObjs.transform.position = settingsSG.sgObjs.transform.position; // Move to the same location.
            yield return(null);                                                          // Wait a frame

            yield return(null);

            // Second test: HDRP/Lit Materials
            try
            {
                ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null);
            }
            catch (AssertionException)
            {
                biFail = true;
            }

            // Informs which ImageAssert failed, if any.
            if (sgFail && biFail)
            {
                Assert.Fail("Both Shader Graph and Non-Shader Graph Objects failed to match the reference image");
            }
            else if (sgFail)
            {
                Assert.Fail("Shader Graph Objects failed.");
            }
            else if (biFail)
            {
                Assert.Fail("Non-Shader Graph Objects failed to match Shader Graph objects.");
            }
        }
    }
Exemplo n.º 4
0
    public IEnumerator Run(GraphicsTestCase testCase)
    {
        SceneManager.LoadScene(testCase.ScenePath);

        // Always wait one frame for scene load
        yield return(null);

        var cameras = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent <Camera>());

        Assert.True(cameras != null && cameras.Any(), "Invalid test scene, couldn't find a camera with MainCamera tag.");
        var settings = Object.FindObjectOfType <UniversalGraphicsTestSettings>();

        Assert.IsNotNull(settings, "Invalid test scene, couldn't find UniversalGraphicsTestSettings");

        int waitFrames = Unity.Testing.XR.Runtime.ConfigureMockHMD.SetupTest(settings.XRCompatible, settings.WaitFrames, settings.ImageComparisonSettings);

        Scene scene = SceneManager.GetActiveScene();

        yield return(null);

        if (settings.ImageComparisonSettings.UseBackBuffer && waitFrames < 1)
        {
            waitFrames = 1;
        }

        for (int i = 0; i < waitFrames; i++)
        {
            yield return(new WaitForEndOfFrame());
        }

#if UNITY_ANDROID
        // On Android first scene often needs a bit more frames to load all the assets
        // otherwise the screenshot is just a black screen
        if (!wasFirstSceneRan)
        {
            for (int i = 0; i < firstSceneAdditionalFrames; i++)
            {
                yield return(new WaitForEndOfFrame());
            }
            wasFirstSceneRan = true;
        }
#endif

        ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), settings.ImageComparisonSettings);

        // Does it allocate memory when it renders what's on the main camera?
        bool allocatesMemory = false;
        var  mainCamera      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        if (settings == null || settings.CheckMemoryAllocation)
        {
            try
            {
                ImageAssert.AllocatesMemory(mainCamera, settings?.ImageComparisonSettings);
            }
            catch (AssertionException)
            {
                allocatesMemory = true;
            }

            if (allocatesMemory)
            {
                Assert.Fail("Allocated memory when rendering what is on main camera");
            }
        }
    }
    public IEnumerator Run(GraphicsTestCase testCase)
    {
        SceneManager.LoadScene(testCase.ScenePath);

        // Always wait one frame for scene load
        yield return(null);

        var cameras  = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent <Camera>());
        var settings = Object.FindObjectOfType <UniversalGraphicsTestSettings>();

        Assert.IsNotNull(settings, "Invalid test scene, couldn't find UniversalGraphicsTestSettings");

        Scene scene = SceneManager.GetActiveScene();

        if (scene.name.Substring(3, 4).Equals("_xr_"))
        {
#if ENABLE_VR && ENABLE_VR_MODULE
            Assume.That((Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.OSXPlayer), "Stereo Universal tests do not run on MacOSX.");

            XRSettings.LoadDeviceByName("MockHMD");
            yield return(null);

            XRSettings.enabled = true;
            yield return(null);

            XRSettings.gameViewRenderMode = GameViewRenderMode.BothEyes;
            yield return(null);

            foreach (var camera in cameras)
            {
                camera.stereoTargetEye = StereoTargetEyeMask.Both;
            }
#else
            yield return(null);
#endif
        }
        else
        {
#if ENABLE_VR && ENABLE_VR_MODULE
            XRSettings.enabled = false;
#endif
            yield return(null);
        }

        for (int i = 0; i < settings.WaitFrames; i++)
        {
            yield return(null);
        }

#if UNITY_ANDROID
        // On Android first scene often needs a bit more frames to load all the assets
        // otherwise the screenshot is just a black screen
        if (!wasFirstSceneRan)
        {
            for (int i = 0; i < firstSceneAdditionalFrames; i++)
            {
                yield return(null);
            }
            wasFirstSceneRan = true;
        }
#endif

        ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), settings.ImageComparisonSettings);

        // Does it allocate memory when it renders what's on the main camera?
        bool allocatesMemory = false;
        var  mainCamera      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        // 2D Renderer is currently allocating memory, skip it as it will always fail GC alloc tests.
        var  additionalCameraData = mainCamera.GetUniversalAdditionalCameraData();
        bool is2DRenderer         = additionalCameraData.scriptableRenderer is Renderer2D;

        if (!is2DRenderer)
        {
            try
            {
                ImageAssert.AllocatesMemory(mainCamera, settings?.ImageComparisonSettings);
            }
            catch (AssertionException)
            {
                allocatesMemory = true;
            }
            if (allocatesMemory)
            {
                Assert.Fail("Allocated memory when rendering what is on main camera");
            }
        }
    }
    public IEnumerator Run(GraphicsTestCase testCase)
    {
        SceneManager.LoadScene(testCase.ScenePath);

        // Arbitrary wait for 5 frames for the scene to load, and other stuff to happen (like Realtime GI to appear ...)
        for (int i = 0; i < 5; ++i)
        {
            yield return(null);
        }

        // Load the test settings
        var settings = GameObject.FindObjectOfType <HDRP_TestSettings>();

        var camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        if (camera == null)
        {
            camera = GameObject.FindObjectOfType <Camera>();
        }
        if (camera == null)
        {
            Assert.Fail("Missing camera for graphic tests.");
        }

        Time.captureFramerate = settings.captureFramerate;

        // Skip incompatible XR tests (layout set to None in the scene)
        if (XRSystem.testModeEnabled && settings.xrLayout == XRLayoutOverride.None)
        {
            yield break;
        }

        if (settings.doBeforeTest != null)
        {
            settings.doBeforeTest.Invoke();

            // Wait again one frame, to be sure.
            yield return(null);
        }

        for (int i = 0; i < settings.waitFrames; ++i)
        {
            yield return(null);
        }

        var settingsSG = (GameObject.FindObjectOfType <HDRP_TestSettings>() as HDRP_ShaderGraph_TestSettings);

        if (settingsSG == null || !settingsSG.compareSGtoBI)
        {
            // Standard Test
            ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null);

#if CHECK_ALLOCATIONS_WHEN_RENDERING
            // Does it allocate memory when it renders what's on camera?
            bool allocatesMemory = false;
            try
            {
                ImageAssert.AllocatesMemory(camera, 512, 512); // 512 used for height and width to render
            }
            catch (AssertionException)
            {
                allocatesMemory = true;
            }
            if (allocatesMemory)
            {
                Assert.Fail("Allocated memory when rendering what is on camera");
            }
#endif
        }
        else
        {
            if (settingsSG.sgObjs == null)
            {
                Assert.Fail("Missing Shader Graph objects in test scene.");
            }
            if (settingsSG.biObjs == null)
            {
                Assert.Fail("Missing comparison objects in test scene.");
            }

            settingsSG.sgObjs.SetActive(true);
            settingsSG.biObjs.SetActive(false);
            yield return(null); // Wait a frame

            yield return(null);

            bool sgFail = false;
            bool biFail = false;

            // First test: Shader Graph
            try
            {
                ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null);
            }
            catch (AssertionException)
            {
                sgFail = true;
            }

            settingsSG.sgObjs.SetActive(false);
            settingsSG.biObjs.SetActive(true);
            settingsSG.biObjs.transform.position = settingsSG.sgObjs.transform.position; // Move to the same location.
            yield return(null);                                                          // Wait a frame

            yield return(null);

            // Second test: HDRP/Lit Materials
            try
            {
                ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null);
            }
            catch (AssertionException)
            {
                biFail = true;
            }

            // Informs which ImageAssert failed, if any.
            if (sgFail && biFail)
            {
                Assert.Fail("Both Shader Graph and Non-Shader Graph Objects failed to match the reference image");
            }
            else if (sgFail)
            {
                Assert.Fail("Shader Graph Objects failed.");
            }
            else if (biFail)
            {
                Assert.Fail("Non-Shader Graph Objects failed to match Shader Graph objects.");
            }
        }
    }
Exemplo n.º 7
0
    public IEnumerator Run(GraphicsTestCase testCase)
    {
        SceneManager.LoadScene(testCase.ScenePath);

        // Arbitrary wait for 5 frames for the scene to load, and other stuff to happen (like Realtime GI to appear ...)
        for (int i = 0; i < 5; ++i)
        {
            yield return(null);
        }

        // Load the test settings
        var settings = GameObject.FindObjectOfType <HDRP_TestSettings>();

        var camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        if (camera == null)
        {
            camera = GameObject.FindObjectOfType <Camera>();
        }
        if (camera == null)
        {
            Assert.Fail("Missing camera for graphic tests.");
        }

        Time.captureFramerate = settings.captureFramerate;

        if (XRSystem.testModeEnabled)
        {
            if (settings.xrCompatible)
            {
                XRSystem.automatedTestRunning = true;

                // Increase tolerance to account for slight changes due to float precision
                settings.ImageComparisonSettings.AverageCorrectnessThreshold  *= settings.xrThresholdMultiplier;
                settings.ImageComparisonSettings.PerPixelCorrectnessThreshold *= settings.xrThresholdMultiplier;
            }
            else
            {
                // Skip incompatible XR tests
                yield break;
            }
        }

        if (settings.doBeforeTest != null)
        {
            settings.doBeforeTest.Invoke();

            // Wait again one frame, to be sure.
            yield return(null);
        }

        for (int i = 0; i < settings.waitFrames; ++i)
        {
            yield return(null);
        }

        var settingsSG = (GameObject.FindObjectOfType <HDRP_TestSettings>() as HDRP_ShaderGraph_TestSettings);

        if (settingsSG == null || !settingsSG.compareSGtoBI)
        {
            // Standard Test
            ImageAssert.AreEqual(testCase.ReferenceImage, camera, settings?.ImageComparisonSettings);

            if (settings.checkMemoryAllocation)
            {
                // Does it allocate memory when it renders what's on camera?
                bool allocatesMemory = false;
                try
                {
                    // GC alloc from Camera.CustomRender (case 1206364)
                    int gcAllocThreshold = 2;

#if UNITY_2019_3
                    // In case playmode tests for XR are enabled in 2019.3 we allow one GC alloc from XRSystem:120
                    if (XRSystem.testModeEnabled)
                    {
                        gcAllocThreshold += 1;
                    }
#endif

                    ImageAssert.AllocatesMemory(camera, settings?.ImageComparisonSettings, gcAllocThreshold);
                }
                catch (AssertionException)
                {
                    allocatesMemory = true;
                }
                if (allocatesMemory)
                {
                    Assert.Fail("Allocated memory when rendering what is on camera");
                }
            }
        }
        else
        {
            if (settingsSG.sgObjs == null)
            {
                Assert.Fail("Missing Shader Graph objects in test scene.");
            }
            if (settingsSG.biObjs == null)
            {
                Assert.Fail("Missing comparison objects in test scene.");
            }

            settingsSG.sgObjs.SetActive(true);
            settingsSG.biObjs.SetActive(false);
            yield return(null); // Wait a frame

            yield return(null);

            bool sgFail = false;
            bool biFail = false;

            // First test: Shader Graph
            try
            {
                ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null);
            }
            catch (AssertionException)
            {
                sgFail = true;
            }

            settingsSG.sgObjs.SetActive(false);
            settingsSG.biObjs.SetActive(true);
            settingsSG.biObjs.transform.position = settingsSG.sgObjs.transform.position; // Move to the same location.
            yield return(null);                                                          // Wait a frame

            yield return(null);

            // Second test: HDRP/Lit Materials
            try
            {
                ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null);
            }
            catch (AssertionException)
            {
                biFail = true;
            }

            // Informs which ImageAssert failed, if any.
            if (sgFail && biFail)
            {
                Assert.Fail("Both Shader Graph and Non-Shader Graph Objects failed to match the reference image");
            }
            else if (sgFail)
            {
                Assert.Fail("Shader Graph Objects failed.");
            }
            else if (biFail)
            {
                Assert.Fail("Non-Shader Graph Objects failed to match Shader Graph objects.");
            }
        }
    }
Exemplo n.º 8
0
    public IEnumerator Run(GraphicsTestCase testCase)
    {
        SceneManager.LoadScene(testCase.ScenePath);

        // Always wait one frame for scene load
        yield return(null);

        var cameras  = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent <Camera>());
        var settings = Object.FindObjectOfType <UniversalGraphicsTestSettings>();

        Assert.IsNotNull(settings, "Invalid test scene, couldn't find UniversalGraphicsTestSettings");

        Scene scene = SceneManager.GetActiveScene();

        if (scene.name.Substring(3, 4).Equals("_xr_"))
        {
            Assume.That((Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.OSXPlayer), "Stereo Universal tests do not run on MacOSX.");

            XRSettings.LoadDeviceByName("MockHMD");
            yield return(null);

            XRSettings.enabled = true;
            yield return(null);

            XRSettings.gameViewRenderMode = GameViewRenderMode.BothEyes;
            yield return(null);

            foreach (var camera in cameras)
            {
                camera.stereoTargetEye = StereoTargetEyeMask.Both;
            }
        }
        else
        {
            XRSettings.enabled = false;
            yield return(null);
        }

        for (int i = 0; i < settings.WaitFrames; i++)
        {
            yield return(null);
        }

        ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), settings.ImageComparisonSettings);

#if CHECK_ALLOCATIONS_WHEN_RENDERING
        // Does it allocate memory when it renders what's on the main camera?
        bool allocatesMemory = false;
        var  mainCamera      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
        try
        {
            ImageAssert.AllocatesMemory(mainCamera, 512, 512); // 512 used for height and width to render
        }
        catch (AssertionException)
        {
            allocatesMemory = true;
        }
        if (allocatesMemory)
        {
            Assert.Fail("Allocated memory when rendering what is on main camera");
        }
#endif
    }
        public IEnumerator Run(GraphicsTestCase testCase)
        {
            SceneManager.LoadScene(testCase.ScenePath);

            // Always wait one frame for scene load
            yield return(null);

            var cameras  = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent <Camera>());
            var settings = Object.FindObjectOfType <HDRPUTS_GraphicsTestSettings>();

            Assert.IsNotNull(settings, "Invalid test scene, couldn't find HDRPyUTS_GraphicsTestSettings");

            Scene scene = SceneManager.GetActiveScene();


            if (scene.name.Substring(3, 4).Equals("_xr_"))
            {
#if ENABLE_VR && ENABLE_VR_MODULE
                Assume.That((Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.OSXPlayer), "Stereo HDRP tests do not run on MacOSX.");

                XRSettings.LoadDeviceByName("MockHMD");
                yield return(null);

                XRSettings.enabled = true;
                yield return(null);

                XRSettings.gameViewRenderMode = GameViewRenderMode.BothEyes;
                yield return(null);

                foreach (var camera in cameras)
                {
                    camera.stereoTargetEye = StereoTargetEyeMask.Both;
                }
#else
                yield return(null);
#endif
            }
            else
            {
#if ENABLE_VR && ENABLE_VR_MODULE
                XRSettings.enabled = false;
#endif
                yield return(null);
            }

            int waitFrames = settings.WaitFrames;

            if (settings.ImageComparisonSettings.UseBackBuffer && settings.WaitFrames < 1)
            {
                waitFrames = 1;
            }


            for (int i = 0; i < waitFrames; i++)
            {
                yield return(new WaitForEndOfFrame());
            }

            ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), settings.ImageComparisonSettings);

            // Does it allocate memory when it renders what's on the main camera?
            bool allocatesMemory = false;
            var  mainCamera      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

            // 2D Renderer is currently allocating memory, skip it as it will always fail GC alloc tests.
            //var additionalCameraData = mainCamera.GetHDRPAdditionalCameraData();
            bool is2DRenderer = false; // additionalCameraData.scriptableRenderer is Renderer2D;

            if (!is2DRenderer)
            {
                try
                {
                    ImageAssert.AllocatesMemory(mainCamera, settings.ImageComparisonSettings);
                }
                catch (AssertionException)
                {
                    allocatesMemory = true;
                }
                if (allocatesMemory)
                {
                    Assert.Fail("Allocated memory when rendering what is on main camera");
                }
            }
        }