Ejemplo n.º 1
0
        public void Clear()
        {
            var p = new RenderTargetPool(_graphicsService);
              var r0 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));
              var r1 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));

              p.Recycle(r0);
              p.Recycle(r1);

              //Assert.IsFalse(r0.IsDisposed);      // Not disposing RT anymore because of XNA bug.
              //Assert.IsFalse(r1.IsDisposed);

              p.Clear();

              //Assert.IsTrue(r0.IsDisposed);
              //Assert.IsTrue(r1.IsDisposed);
              Assert.AreEqual(0, p.RenderTargets2D.Count);
              Assert.AreEqual(0, p.Counters2D.Count);
        }
Ejemplo n.º 2
0
        public void Clear()
        {
            var p  = new RenderTargetPool(_graphicsService);
            var r0 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));
            var r1 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));

            p.Recycle(r0);
            p.Recycle(r1);

            //Assert.IsFalse(r0.IsDisposed);      // Not disposing RT anymore because of XNA bug.
            //Assert.IsFalse(r1.IsDisposed);

            p.Clear();

            //Assert.IsTrue(r0.IsDisposed);
            //Assert.IsTrue(r1.IsDisposed);
            Assert.AreEqual(0, p.RenderTargets2D.Count);
            Assert.AreEqual(0, p.Counters2D.Count);
        }
Ejemplo n.º 3
0
        public void FrameLimit()
        {
            var p = new RenderTargetPool(_graphicsService);

            p.FrameLimit = 5;

            var r0 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));
            var r1 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));

            Assert.IsFalse(r0.IsDisposed);
            Assert.IsFalse(r1.IsDisposed);

            p.Recycle(r0);

            p.Update();
            p.Update();

            p.Recycle(r1);

            p.Update();
            p.Update();

            Assert.IsFalse(r0.IsDisposed);
            Assert.IsFalse(r1.IsDisposed);
            Assert.AreEqual(2, p.Counters2D.Count);

            p.Update();
            p.Update();

            Assert.IsTrue(r0.IsDisposed);
            Assert.IsFalse(r1.IsDisposed);
            Assert.AreEqual(1, p.Counters2D.Count);

            p.Update();
            p.Update();

            Assert.IsTrue(r0.IsDisposed);
            Assert.IsTrue(r1.IsDisposed);
            Assert.AreEqual(0, p.Counters2D.Count);
        }
Ejemplo n.º 4
0
        public void FrameLimit()
        {
            var p = new RenderTargetPool(_graphicsService);
              p.FrameLimit = 5;

              var r0 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));
              var r1 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));

              Assert.IsFalse(r0.IsDisposed);
              Assert.IsFalse(r1.IsDisposed);

              p.Recycle(r0);

              p.Update();
              p.Update();

              p.Recycle(r1);

              p.Update();
              p.Update();

              Assert.IsFalse(r0.IsDisposed);
              Assert.IsFalse(r1.IsDisposed);
              Assert.AreEqual(2, p.Counters2D.Count);

              p.Update();
              p.Update();

              Assert.IsTrue(r0.IsDisposed);
              Assert.IsFalse(r1.IsDisposed);
              Assert.AreEqual(1, p.Counters2D.Count);

              p.Update();
              p.Update();

              Assert.IsTrue(r0.IsDisposed);
              Assert.IsTrue(r1.IsDisposed);
              Assert.AreEqual(0, p.Counters2D.Count);
        }
Ejemplo n.º 5
0
        public void ValidateDuplicateRecycle2D()
        {
            GlobalSettings.ValidationLevel = 0;
            var p  = new RenderTargetPool(_graphicsService);
            var r0 = p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.None));

            p.Recycle(r0);
            p.Recycle(r0);

            GlobalSettings.ValidationLevel = 0xff;
            p = new RenderTargetPool(_graphicsService);
            p.Recycle(r0);
            Assert.Throws <InvalidOperationException>(() => p.Recycle(r0));
        }
Ejemplo n.º 6
0
        public void ObtainRecycle()
        {
            var p = new RenderTargetPool(_graphicsService);
              p.FrameLimit = 5;

              var r0 = p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.None));
              var r1 = p.Obtain2D(new RenderTargetFormat(32, 64, false, SurfaceFormat.Color, DepthFormat.None));
              var r2 = p.Obtain2D(new RenderTargetFormat(32, 32, true, SurfaceFormat.Color, DepthFormat.None));
              var r3 = p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Single, DepthFormat.None));
              var r4 = p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8));

              p.Recycle(r0);
              p.Recycle(r1);
              p.Recycle(r2);
              p.Recycle(r3);
              p.Recycle(r4);

              Assert.AreEqual(r0, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.None)));
              Assert.AreNotEqual(r0, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.None)));
              p.Recycle(r0);

              Assert.AreEqual(r2, p.Obtain2D(new RenderTargetFormat(32, 32, true, SurfaceFormat.Color, DepthFormat.None)));
              Assert.AreNotEqual(r2, p.Obtain2D(new RenderTargetFormat(32, 32, true, SurfaceFormat.Color, DepthFormat.None)));
              p.Recycle(r2);

              Assert.AreEqual(r3, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Single, DepthFormat.None)));
              Assert.AreNotEqual(r3, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Single, DepthFormat.None)));
              p.Recycle(r3);

              Assert.AreEqual(r1, p.Obtain2D(new RenderTargetFormat(32, 64, false, SurfaceFormat.Color, DepthFormat.None)));
              Assert.AreNotEqual(r1, p.Obtain2D(new RenderTargetFormat(32, 64, false, SurfaceFormat.Color, DepthFormat.None)));
              p.Recycle(r1);

              Assert.AreEqual(r4, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)));
              Assert.AreNotEqual(r4, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)));
              p.Recycle(r4);
        }
Ejemplo n.º 7
0
        public void ValidateDuplicateRecycle2D()
        {
            GlobalSettings.ValidationLevel = 0;
              var p = new RenderTargetPool(_graphicsService);
              var r0 = p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.None));
              p.Recycle(r0);
              p.Recycle(r0);

              GlobalSettings.ValidationLevel = 0xff;
              p = new RenderTargetPool(_graphicsService);
              p.Recycle(r0);
              Assert.Throws<InvalidOperationException>(() => p.Recycle(r0));
        }
Ejemplo n.º 8
0
        public void ObtainRecycle()
        {
            var p = new RenderTargetPool(_graphicsService);

            p.FrameLimit = 5;

            var r0 = p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.None));
            var r1 = p.Obtain2D(new RenderTargetFormat(32, 64, false, SurfaceFormat.Color, DepthFormat.None));
            var r2 = p.Obtain2D(new RenderTargetFormat(32, 32, true, SurfaceFormat.Color, DepthFormat.None));
            var r3 = p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Single, DepthFormat.None));
            var r4 = p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8));

            p.Recycle(r0);
            p.Recycle(r1);
            p.Recycle(r2);
            p.Recycle(r3);
            p.Recycle(r4);

            Assert.AreEqual(r0, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.None)));
            Assert.AreNotEqual(r0, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.None)));
            p.Recycle(r0);

            Assert.AreEqual(r2, p.Obtain2D(new RenderTargetFormat(32, 32, true, SurfaceFormat.Color, DepthFormat.None)));
            Assert.AreNotEqual(r2, p.Obtain2D(new RenderTargetFormat(32, 32, true, SurfaceFormat.Color, DepthFormat.None)));
            p.Recycle(r2);

            Assert.AreEqual(r3, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Single, DepthFormat.None)));
            Assert.AreNotEqual(r3, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Single, DepthFormat.None)));
            p.Recycle(r3);

            Assert.AreEqual(r1, p.Obtain2D(new RenderTargetFormat(32, 64, false, SurfaceFormat.Color, DepthFormat.None)));
            Assert.AreNotEqual(r1, p.Obtain2D(new RenderTargetFormat(32, 64, false, SurfaceFormat.Color, DepthFormat.None)));
            p.Recycle(r1);

            Assert.AreEqual(r4, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)));
            Assert.AreNotEqual(r4, p.Obtain2D(new RenderTargetFormat(32, 32, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)));
            p.Recycle(r4);
        }