当前位置: 首页>>代码示例>>C#>>正文


C# Effect.Dispose方法代码示例

本文整理汇总了C#中Effect.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.Dispose方法的具体用法?C# Effect.Dispose怎么用?C# Effect.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Effect的用法示例。


在下文中一共展示了Effect.Dispose方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    public static void Main(string[] args)
    {
        Device device;
        Effect effect;

        device = new Device(DriverType.Hardware, DeviceCreationFlags.None);

        if (args.Length < 1)
        {
            Console.WriteLine("Usage: dumptech.exe <effect file>");
            return;
        }

        string effect_file = args[0];

        if (! File.Exists(effect_file))
        {
            Console.WriteLine("File not found: " + effect_file);
            return;
        }
        try
        {
            var shader_bytecode = ShaderBytecode.FromFile(effect_file);
            effect = new Effect(device, shader_bytecode);
        }
        catch (SharpDX.CompilationException e)
        {
            Console.WriteLine(e.Message + ": " + effect_file);
            return;
        }

        //Console.WriteLine("technique count {0}", effect.Description.TechniqueCount);
        for (int i = 0; i < effect.Description.TechniqueCount; i++)
        {
            var technique = effect.GetTechniqueByIndex(i);
            Console.WriteLine("{0}\t{1}", i, technique.Description.Name);
        }

        if (effect != null)
            effect.Dispose();
        if (device != null)
            device.Dispose();
    }
开发者ID:3dcustom,项目名称:tsoview-fx,代码行数:43,代码来源:dumptech.cs

示例2: DestroyInstance

 public override void DestroyInstance(Effect fx)
 {
     fx.Dispose();
 }
开发者ID:yuri410,项目名称:lrvbsvnicg,代码行数:4,代码来源:TailEffect.cs

示例3: Main

        static void Main()
        {
            var form = new RenderForm("SlimDX - MiniTri Direct3D 11 Sample");
            var desc = new SwapChainDescription()
            {
                BufferCount = 1,
                ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed = true,
                OutputHandle = form.Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput
            };

            Device device;
            SwapChain swapChain;
            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.Debug, desc, out device, out swapChain);

            device.Factory.SetWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);

            Texture2D backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
            var renderView = new RenderTargetView(device, backBuffer);
            var bytecode = ShaderBytecode.CompileFromFile("MiniTri.fx", "fx_5_0", ShaderFlags.None, EffectFlags.None);
            var effect = new Effect(device, bytecode);
            var technique = effect.GetTechniqueByIndex(0);
            var pass = technique.GetPassByIndex(0);
            var layout = new InputLayout(device, pass.Description.Signature, new[] {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) 
            });

            var stream = new DataStream(3 * 32, true, true);
            stream.WriteRange(new[] {
                new Vector4(0.0f, 0.5f, 0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                new Vector4(0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
                new Vector4(-0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)
            });
            stream.Position = 0;

            var vertices = new SlimDX.Direct3D11.Buffer(device, stream, new BufferDescription()
            {
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags = ResourceOptionFlags.None,
                SizeInBytes = 3 * 32,
                Usage = ResourceUsage.Default
            });
            stream.Dispose();

            device.ImmediateContext.OutputMerger.SetTargets(renderView);
            device.ImmediateContext.Rasterizer.SetViewports(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f));

            MessagePump.Run(form, () =>
            {
                device.ImmediateContext.ClearRenderTargetView(renderView, Color.Black);

                device.ImmediateContext.InputAssembler.InputLayout = layout;
                device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
                device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertices, 32, 0));

                for (int i = 0; i < technique.Description.PassCount; ++i)
                {
                    pass.Apply(device.ImmediateContext);
                    device.ImmediateContext.Draw(3, 0);
                }

                swapChain.Present(0, PresentFlags.None);
            });

            bytecode.Dispose();
            vertices.Dispose();
            layout.Dispose();
            effect.Dispose();
            renderView.Dispose();
            backBuffer.Dispose();
            device.Dispose();
            swapChain.Dispose();
        }
开发者ID:zhandb,项目名称:slimdx,代码行数:78,代码来源:Program.cs

示例4: Main


//.........这里部分代码省略.........
            // Load effect from file. It is a basic effect that renders a full screen quad through
            // an ortho projectio=n matrix
            effect = Effect.FromFile(device, "Texture.fx", "fx_4_0", ShaderFlags.Debug, EffectFlags.None);
            EffectTechnique technique = effect.GetTechniqueByIndex(0);
            EffectPass pass = technique.GetPassByIndex(0);
            InputLayout layout = new InputLayout(device, pass.Description.Signature, new[]
                                                                                         {
                                                                                             new InputElement(
                                                                                                 "POSITION", 0,
                                                                                                 Format.
                                                                                                     R32G32B32A32_Float,
                                                                                                 0, 0),
                                                                                             new InputElement(
                                                                                                 "TEXCOORD", 0,
                                                                                                 Format.
                                                                                                     R32G32_Float,
                                                                                                 16, 0)
                                                                                         });
            //effect.GetVariableByName("mWorld").AsMatrix().SetMatrix(
            //    Matrix.Translation(Layout.OrthographicTransform(Vector2.Zero, 99, size)));
            //effect.GetVariableByName("mView").AsMatrix().SetMatrix(qCam.View);
            //effect.GetVariableByName("mProjection").AsMatrix().SetMatrix(qCam.OrthoProjection);
            //effect.GetVariableByName("tDiffuse").AsResource().SetResource(srv);

            // Set RT and Viewports
            device.OutputMerger.SetTargets(renderView);
            device.Rasterizer.SetViewports(new Viewport(0, 0, size.Width, size.Height, 0.0f, 1.0f));

            // Create solid rasterizer state
            RasterizerStateDescription rDesc = new RasterizerStateDescription()
                                                   {
                                                       CullMode = CullMode.None,
                                                       IsDepthClipEnabled = true,
                                                       FillMode = FillMode.Solid,
                                                       IsAntialiasedLineEnabled = false,
                                                       IsFrontCounterclockwise = true,
                                                       //IsMultisampleEnabled = true,
                                                   };
            RasterizerState rState = RasterizerState.FromDescription(device, rDesc);
            device.Rasterizer.State = rState;

            Texture2DDescription rtDesc = new Texture2DDescription
                                              {
                                                  ArraySize = 1,
                                                  Width = size.Width,
                                                  Height = size.Height,
                                                  BindFlags = BindFlags.RenderTarget,
                                                  CpuAccessFlags = CpuAccessFlags.None,
                                                  Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm,
                                                  OptionFlags = ResourceOptionFlags.None,
                                                  Usage = ResourceUsage.Default,
                                                  MipLevels = 1,
                                                  SampleDescription = new SampleDescription(1, 0)
                                              };
            rtTex = new Texture2D(device, rtDesc);

            rv = new RenderTargetView(device, rtTex);

            stereoizedTexture = Make3D(sourceTexture);
            //ResizeDevice(new Size(1920, 1080), true);
            Console.WriteLine(form.ClientSize);
            // Main Loop
            MessagePump.Run(form, () =>
            {
            device.ClearRenderTargetView(renderView, Color.Cyan);

            //device.InputAssembler.SetInputLayout(layout);
            //device.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.TriangleList);
            //device.OutputMerger.SetTargets(rv);
            //device.InputAssembler.SetVertexBuffers(0,
            //                                new VertexBufferBinding(vertices, 24, 0));
            //device.InputAssembler.SetIndexBuffer(indices, Format.R16_UInt, 0);
            //for (int i = 0; i < technique.Description.PassCount; ++i)
            //{
            //    // Render the full screen quad
            //    pass.Apply();
            //    device.DrawIndexed(6, 0, 0);
            //}
            ResourceRegion stereoSrcBox = new ResourceRegion { Front = 0, Back = 1, Top = 0, Bottom = size.Height, Left = 0, Right = size.Width };
            device.CopySubresourceRegion(stereoizedTexture, 0, stereoSrcBox, backBuffer, 0, 0, 0, 0);
            //device.CopyResource(rv.Resource, backBuffer);

            swapChain.Present(0, PresentFlags.None);
            });

            // Dispose resources
            vertices.Dispose();
            layout.Dispose();
            effect.Dispose();
            renderView.Dispose();
            backBuffer.Dispose();
            device.Dispose();
            swapChain.Dispose();

            rState.Dispose();
            stereoizedTexture.Dispose();
            sourceTexture.Dispose();
            indices.Dispose();
            srv.Dispose();
        }
开发者ID:yong-ja,项目名称:starodyssey,代码行数:101,代码来源:Program.cs

示例5: Main


//.........这里部分代码省略.........

            device.Factory.SetWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);

            Texture2D backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
            var renderView = new RenderTargetView(device, backBuffer);
            var bytecode = ShaderBytecode.CompileFromFile("Render.fx", "fx_5_0", ShaderFlags.None, EffectFlags.None);
            var effect = new Effect(device, bytecode);
            var technique = effect.GetTechniqueByIndex(0);
            var pass = technique.GetPassByIndex(0);
            String errors;
            var computeByteCode = ShaderBytecode.CompileFromFile("compute.fx", "CS", "cs_5_0", ShaderFlags.None, EffectFlags.None, null, null, out errors);
            var compute = new ComputeShader(device, computeByteCode);

            // shader variable handles
            var conwayResourceH = effect.GetVariableByName("tex").AsResource();
            var resolutionInvH = effect.GetVariableByName("resolutionInv").AsVector();
            resolutionInvH.Set(new Vector2(1.0f / form.ClientSize.Width, 1.0f / form.ClientSize.Height));
            EffectVectorVariable lightPosSSH = effect.GetVariableByName("lightPosSS").AsVector();

            // create texture, fill it with random data
            Texture2DDescription textureDesc = new Texture2DDescription()
            {
                Width = form.ClientSize.Width,
                Height = form.ClientSize.Height,
                MipLevels = 1,
                ArraySize = 1,
                CpuAccessFlags = CpuAccessFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Default,
                OptionFlags = ResourceOptionFlags.None,
                BindFlags = BindFlags.UnorderedAccess | BindFlags.ShaderResource,
                Format = Format.R32_Float
            };

            var random = new Random();
            var data = new float[form.ClientSize.Width * form.ClientSize.Height];
            for (int i = 0; i < form.ClientSize.Width; ++i)
            {
                for (int j = 0; j < form.ClientSize.Height; ++j)
                    data[i * form.ClientSize.Height + j] = (float)random.Next(2);
            }

            DataStream ds = new DataStream(data, true, false);
            DataRectangle dataRect = new DataRectangle(4 * form.ClientSize.Width, ds);

            Texture2D conwayTex = new Texture2D(device, textureDesc, dataRect);

            // Create SRV and UAV over the same texture
            UnorderedAccessView conwayUAV = new UnorderedAccessView(device, conwayTex);
            ShaderResourceView conwaySRV = new ShaderResourceView(device, conwayTex);

            // On the more typical setup where you switch shaders, 
            // you will have to set the texture after every
            conwayResourceH.SetResource(conwaySRV);

            device.ImmediateContext.OutputMerger.SetTargets(renderView);
            device.ImmediateContext.Rasterizer.SetViewports(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f));
            device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;

            Vector2 lightPosSS;
            float angle = 0;

            MessagePump.Run(form, () =>
            {
                // this does the light rotation
                angle += 0.002f;
                lightPosSS = new Vector2((float)Math.Sin(angle) * 0.5f + 0.5f, (float)Math.Cos(angle) * 0.5f + 0.5f);
                lightPosSSH.Set(lightPosSS);

                device.ImmediateContext.ComputeShader.Set(compute);
                device.ImmediateContext.ComputeShader.SetUnorderedAccessView(conwayUAV, 0);
                device.ImmediateContext.Dispatch(form.ClientSize.Width / 16 + 1, form.ClientSize.Height / 16 + 1, 1);

                // After running the CS you have to unset UAV from the shader, so you can use it as SRV
                device.ImmediateContext.ComputeShader.SetUnorderedAccessView(null, 0);

                device.ImmediateContext.ClearRenderTargetView(renderView, Color.Black);

                for (int i = 0; i < technique.Description.PassCount; ++i)
                {
                    pass.Apply(device.ImmediateContext);
                    // No vertices are send as they are created in the vertex shader on the fly.
                    device.ImmediateContext.Draw(4, 0);
                }

                swapChain.Present(0, PresentFlags.None);
            });

            computeByteCode.Dispose();
            conwayUAV.Dispose();
            conwaySRV.Dispose();
            conwayTex.Dispose();
            ds.Dispose();
            bytecode.Dispose();
            effect.Dispose();
            renderView.Dispose();
            backBuffer.Dispose();
            device.Dispose();
            swapChain.Dispose();
        }
开发者ID:zhandb,项目名称:slimdx,代码行数:101,代码来源:Program.cs

示例6: Run


//.........这里部分代码省略.........
            // ---------------------------------------------------------------------------------------------------
            // Acquire the mutexes. These are needed to assure the device in use has exclusive access to the surface
            // ---------------------------------------------------------------------------------------------------

            var device10Mutex = textureD3D10.QueryInterface<KeyedMutex>();
            var device11Mutex = textureD3D11.QueryInterface<KeyedMutex>();

            // ---------------------------------------------------------------------------------------------------
            // Main rendering loop
            // ---------------------------------------------------------------------------------------------------

            bool first = true;

            RenderLoop
                .Run(form,
                     () =>
                         {
                             if(first)
                             {
                                 form.Activate();
                                 first = false;
                             }

                             // clear the render target to black
                             context.ClearRenderTargetView(renderTargetView, Colors.DarkSlateGray);

                             // Draw the triangle
                             context.InputAssembler.InputLayout = layoutColor;
                             context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
                             context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBufferColor, VertexPositionColor.SizeInBytes, 0));
                             context.OutputMerger.BlendState = null;
                             var currentTechnique = effect.GetTechniqueByName("Color");
                             for (var pass = 0; pass < currentTechnique.Description.PassCount; ++pass)
                             {
                                 using (var effectPass = currentTechnique.GetPassByIndex(pass))
                                 {
                                     System.Diagnostics.Debug.Assert(effectPass.IsValid, "Invalid EffectPass");
                                     effectPass.Apply(context);
                                 }
                                 context.Draw(3, 0);
                             };

                             // Draw Ellipse on the shared Texture2D
                             device10Mutex.Acquire(0, 100);
                             renderTarget2D.BeginDraw();
                             renderTarget2D.Clear(Colors.Black);
                             renderTarget2D.DrawGeometry(tesselatedGeometry, solidColorBrush);
                             renderTarget2D.DrawEllipse(new Ellipse(center, 200, 200), solidColorBrush, 20, null);
                             renderTarget2D.EndDraw();
                             device10Mutex.Release(0);

                             // Draw the shared texture2D onto the screen, blending the 2d content in
                             device11Mutex.Acquire(0, 100);
                             var srv = new ShaderResourceView(device11, textureD3D11);
                             effect.GetVariableByName("g_Overlay").AsShaderResource().SetResource(srv);
                             context.InputAssembler.InputLayout = layoutOverlay;
                             context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
                             context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBufferOverlay, VertexPositionTexture.SizeInBytes, 0));
                             context.OutputMerger.BlendState = blendStateTransparent;
                             currentTechnique = effect.GetTechniqueByName("Overlay");

                             for (var pass = 0; pass < currentTechnique.Description.PassCount; ++pass)
                             {
                                 using (var effectPass = currentTechnique.GetPassByIndex(pass))
                                 {
                                     System.Diagnostics.Debug.Assert(effectPass.IsValid, "Invalid EffectPass");
                                     effectPass.Apply(context);
                                 }
                                 context.Draw(4, 0);
                             }
                             srv.Dispose();
                             device11Mutex.Release(0);

                             swapChain.Present(0, PresentFlags.None);
                         });

            // dispose everything
            vertexBufferColor.Dispose();
            vertexBufferOverlay.Dispose();
            layoutColor.Dispose();
            layoutOverlay.Dispose();
            effect.Dispose();
            shaderByteCode.Dispose();
            renderTarget2D.Dispose();
            swapChain.Dispose();
            device11.Dispose();
            device10.Dispose();
            textureD3D10.Dispose();
            textureD3D11.Dispose();
            factory1.Dispose();
            adapter1.Dispose();
            sharedResource.Dispose();
            factory2D.Dispose();
            surface.Dispose();
            solidColorBrush.Dispose();
            blendStateTransparent.Dispose();

            device10Mutex.Dispose();
            device11Mutex.Dispose();
        }
开发者ID:ernstnaezer,项目名称:SharpDXSharedResources,代码行数:101,代码来源:Program.cs

示例7: TestFloats

        public void TestFloats()
        {
            var device = GraphicsDevice.New();

            // Compile a toolkit effect from a file
            var result = new EffectCompiler().CompileFromFile("TestEffectValueArray.fx");

            // Check that we don't have any errors
            Assert.False(result.HasErrors);

            var bytecode = result.EffectData;

            var effect = new Effect(device, bytecode);

            // Test for floats
            // When uploading a float[16], each float in the array will be aligned to the closest float4
            // So it is actually as using a float4[16] array. The toolkit is managing this to avoid a 
            // user to have to remap to a float4. For efficiency, It is recommended to directly use float4
            // whenever possible.
            var floats = new float[16];
            for (int i = 0; i < floats.Length; i++)
            {
                floats[i] = i;
            }
            effect.Parameters["Floats"].SetValue(floats);
            var localFloats = effect.Parameters["Floats"].GetValueArray<float>(floats.Length);
            Assert.That(Utilities.Compare(floats, localFloats), Is.True);

            var buffer = Buffer.Structured.New<float>(device, floats.Length, true);
            effect.Parameters["FloatsOut"].SetResource(buffer);

            effect.CurrentTechnique = effect.Techniques["TestFloats"];

            effect.CurrentTechnique.Passes[0].Apply();
            device.Dispatch(floats.Length, 1, 1);
            var computeFloats = buffer.GetData<float>();
            Assert.That(Utilities.Compare(floats, computeFloats), Is.True);

            // Test with float2 array
            var floats2 = new Vector2[8];
            for (int i = 0; i < floats2.Length; i++)
            {
                floats2[i] = new Vector2(i * 2, i * 2 + 1);
            }
            effect.Parameters["Floats2"].SetValue(floats2);

            var localFloats2 = effect.Parameters["Floats2"].GetValueArray<Vector2>(floats2.Length);
            Assert.That(Utilities.Compare(floats2, localFloats2), Is.True);

            var bufferFloats2 = Buffer.Structured.New<Vector2>(device, floats2.Length, true);
            effect.Parameters["Floats2Out"].SetResource(bufferFloats2);

            effect.CurrentTechnique.Passes[1].Apply();
            device.Dispatch(floats2.Length, 1, 1);
            var computeFloats2 = buffer.GetData<Vector2>();
            Assert.That(Utilities.Compare(floats2, computeFloats2), Is.True);

            // Test with float4 array
            var floats4 = new Vector4[4];
            for (int i = 0; i < floats4.Length; i++)
            {
                floats4[i] = new Vector4(i * 4, i * 4 + 1, i * 4 + 2, i * 4 + 3);
            }
            effect.Parameters["Floats4"].SetValue(floats4);

            var localFloats4 = effect.Parameters["Floats4"].GetValueArray<Vector4>(floats4.Length);
            Assert.That(Utilities.Compare(floats4, localFloats4), Is.True);

            var bufferFloats4 = Buffer.Structured.New<Vector2>(device, floats4.Length, true);
            effect.Parameters["Floats4Out"].SetResource(bufferFloats4);

            effect.CurrentTechnique.Passes[2].Apply();
            device.Dispatch(floats4.Length, 1, 1);
            var computeFloats4 = buffer.GetData<Vector4>();
            Assert.That(Utilities.Compare(floats4, computeFloats4), Is.True);

            effect.Dispose();
            device.Dispose();
        }
开发者ID:chantsunman,项目名称:Toolkit,代码行数:79,代码来源:TestEffectValueArray.cs

示例8: TestMatrix

        public void TestMatrix()
        {
            var device = GraphicsDevice.New();

            // Compile a toolkit effect from a file
            var result = new EffectCompiler().CompileFromFile("TestEffectValueArray.fx");

            // Check that we don't have any errors
            Assert.False(result.HasErrors);

            var bytecode = result.EffectData;

            var effect = new Effect(device, bytecode);

            
            var matrices = new Matrix[4];
            for (int i = 0; i < matrices.Length; i++)
            {
                matrices[i] = new Matrix();
                for (int j = 0; j < 16; j++)
                {
                    matrices[i][j] = (j + i * 16);
                }
            }

            effect.Parameters["Matrices4x4"].SetValue(matrices);
            effect.Parameters["Matrices4x3"].SetValue(matrices);
            effect.Parameters["Matrices3x3"].SetValue(matrices);
            effect.Parameters["Matrices3x4"].SetValue(matrices);

            var locals4x4 = effect.Parameters["Matrices4x4"].GetMatrixArray(4);
            var locals4x3 = effect.Parameters["Matrices4x3"].GetMatrixArray(4);
            var locals3x3 = effect.Parameters["Matrices3x3"].GetMatrixArray(4);
            var locals3x4 = effect.Parameters["Matrices3x4"].GetMatrixArray(4);

            Assert.That(CompareMatrixArray(matrices, locals4x4, 4, 4), Is.True);
            Assert.That(CompareMatrixArray(matrices, locals4x3, 4, 3), Is.True);
            Assert.That(CompareMatrixArray(matrices, locals3x3, 3, 3), Is.True);
            Assert.That(CompareMatrixArray(matrices, locals3x4, 3, 4), Is.True);

            var local4x4 = effect.Parameters["Matrices4x4"].GetMatrix(3);
            var local4x3 = effect.Parameters["Matrices4x3"].GetMatrix(3);
            var local3x3 = effect.Parameters["Matrices3x3"].GetMatrix(3);
            var local3x4 = effect.Parameters["Matrices3x4"].GetMatrix(3);

            Assert.That(CompareMatrix(ref local4x4, ref matrices[3], 4, 4));
            Assert.That(CompareMatrix(ref local4x3, ref matrices[3], 4, 3));
            Assert.That(CompareMatrix(ref local3x3, ref matrices[3], 3, 3));
            Assert.That(CompareMatrix(ref local3x4, ref matrices[3], 3, 4));

            var buffer = Buffer.Structured.New<Matrix>(device, 4, true);
            effect.Parameters["MatrixOut"].SetResource(buffer);

            effect.CurrentTechnique = effect.Techniques["TestMatrices"];

            effect.CurrentTechnique.Passes[0].Apply();
            device.Dispatch(4, 1, 1);
            var compute4x4 = Transpose(buffer.GetData<Matrix>());
            Assert.That(CompareMatrixArray(matrices, compute4x4, 4, 4), Is.True);

            effect.CurrentTechnique.Passes[1].Apply();
            device.Dispatch(4, 1, 1);
            var compute4x3 = Transpose(buffer.GetData<Matrix>());
            Assert.That(CompareMatrixArray(matrices, compute4x3, 4, 3), Is.True);

            effect.CurrentTechnique.Passes[2].Apply();
            device.Dispatch(4, 1, 1);
            var compute3x3 = Transpose(buffer.GetData<Matrix>());
            Assert.That(CompareMatrixArray(matrices, compute3x3, 3, 3), Is.True);

            effect.CurrentTechnique.Passes[3].Apply();
            device.Dispatch(4, 1, 1);
            var compute3x4 = Transpose(buffer.GetData<Matrix>());
            Assert.That(CompareMatrixArray(matrices, compute3x4, 3, 4), Is.True);

            effect.Dispose();
            device.Dispose();
        }
开发者ID:chantsunman,项目名称:Toolkit,代码行数:78,代码来源:TestEffectValueArray.cs


注:本文中的Effect.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。