Ejemplo n.º 1
0
        static void TestDynamicVertexBuffer(D3DDevice device)
        {
            string info = "";

            try
            {
                var vb = new DynamicVertexBuffer(ref device);

                var vertices0 = new[] { new Vector4(1, 2, 3, 4) };
                var vertices1 = new[] { new Vector4(5, 6, 7, 8) };
                var vertices2 = new[] { new Vector4(9, 10, 11, 12) };
                vb.Init(vertices0);
                vb.Update(vertices1);
                vb.Update(vertices2);

                vb.Dispose();
            }
            catch (Exception e)
            {
                info += "----------- Global Exception -----------\r\n";
                info += e.ToString();
            }
            finally
            {
                var mb = new ScrollableMessageBox();
                mb.showText.Text = info;
                mb.Show();
                Application.Run(mb);
            }
        }
Ejemplo n.º 2
0
        static void TestVB_MaxBufNum(D3DDevice device, int bufSize, int maxNum)
        {
            string info = "";

            try
            {
                var buf    = new byte[bufSize];
                var vbList = new List <DynamicVertexBuffer>();
                for (int i = 0; i < maxNum; ++i)
                {
                    var vb = new DynamicVertexBuffer(ref device);
                    vb.Init(buf);
                    vbList.Add(vb);
                }

                for (int i = 0; i < maxNum; ++i)
                {
                    vbList[i].Dispose();
                }
            }
            catch (Exception e)
            {
                info += "----------- Global Exception -----------\r\n";
                info += e.ToString();
            }
            finally
            {
                var mb = new ScrollableMessageBox();
                mb.showText.Text = info;
                mb.Show();
                Application.Run(mb);
            }
        }
Ejemplo n.º 3
0
        static void TestParameters(Form mainWnd, D3DDevice device, SwapChain swapChain)
        {
            string info = "";

            try
            {
                // Possible combination
                // Create
                //  {Immutable, Default, Dynamic, Staging} x {none, read, write, read_write}
                // CPU side operations
                //  {read, write, read_write, write_discard, write_no_override}
                Tuple <string, ResourceUsage>[] usageList =
                {
                    new Tuple <string, ResourceUsage>("Default",   ResourceUsage.Default),
                    new Tuple <string, ResourceUsage>("Dynamic",   ResourceUsage.Dynamic),
                    new Tuple <string, ResourceUsage>("Immutable", ResourceUsage.Immutable),
                    new Tuple <string, ResourceUsage>("Staging",   ResourceUsage.Staging),
                };
                Tuple <string, CpuAccessFlags>[] cpuFlagList =
                {
                    new Tuple <string, CpuAccessFlags>("None",  CpuAccessFlags.None),
                    new Tuple <string, CpuAccessFlags>("Read",  CpuAccessFlags.Read),
                    new Tuple <string, CpuAccessFlags>("Write", CpuAccessFlags.Write),
                    new Tuple <string, CpuAccessFlags>("RW",    CpuAccessFlags.Read | CpuAccessFlags.Write),
                };

                // Correct combination
                // Create
                //  1. Default + none
                //  2. Dynamic + write
                //  3. Immutable + none
                // CPU side operations
                //  2. write_discard
                foreach (var usage in usageList)
                {
                    foreach (var cpuFlag in cpuFlagList)
                    {
                        info += "----------- " + usage.Item1 + " + " + cpuFlag.Item1 + " -----------\r\n";
                        try
                        {
                            var vertexData  = new[] { new Vector4(1, 2, 3, 4) };
                            var vertexData2 = new[] { new Vector4(11, 22, 33, 44) };
                            info += "Create:\r\n";
                            var vertexBuffer = CreateVertexBuffer(ref device, vertexData, usage.Item2, cpuFlag.Item2);
                            info += "  Success.\r\n";
                            var context = device.ImmediateContext;
                            info += ProfileBuffer(ref context, ref vertexBuffer, vertexData2);
                            vertexBuffer.Dispose();
                        }
                        catch (Exception e)
                        {
                            info += e.Message;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                info += "----------- Global Exception -----------\r\n";
                info += e.ToString();
            }
            finally
            {
                var mb = new ScrollableMessageBox();
                mb.showText.Text = info;
                mb.Show();
                Application.Run(mb);
            }
        }