Пример #1
0
 private void ShuddownShader()
 {
     // Release the Light constant buffer.
     ConstantLightBuffer?.Dispose();
     ConstantLightBuffer = null;
     // Release the Light2 constant buffer.
     ConstantLightBuffer2?.Dispose();
     ConstantLightBuffer2 = null;
     // Release the matrix constant buffer.
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     // Release the wrap sampler state.
     SamplerStateWrap?.Dispose();
     SamplerStateWrap = null;
     // Release the clamp sampler state.
     SamplerStateClamp?.Dispose();
     SamplerStateClamp = null;
     // Release the layout.
     Layout?.Dispose();
     Layout = null;
     // Release the pixel shader.
     PixelShader?.Dispose();
     PixelShader = null;
     // Release the vertex shader.
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #2
0
 public void Dispose()
 {
     vertex?.Dispose();
     pixel?.Dispose();
     compute?.Dispose();
     geometry?.Dispose();
 }
Пример #3
0
        public override void Dispose()
        {
            base.Dispose();

            if (Id > 0)
            {
                GL.DeleteProgram(Id);

                Id = 0;
            }

            VertexShader?.Dispose();
            FragmentShader?.Dispose();
            GeometryShader?.Dispose();

            VertexShader   = null;
            FragmentShader = null;
            GeometryShader = null;

            if (namePtr != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(namePtr);

                namePtr = IntPtr.Zero;
            }

            Name = null;
        }
Пример #4
0
 public void Dispose()
 {
     VertexShader?.Dispose();
     GeometryShader?.Dispose();
     PixelShader?.Dispose();
     Layout?.Dispose();
 }
 private void ShuddownShader()
 {
     // Release the first WRAP sampler state.
     SamplerState1Wrap?.Dispose();
     SamplerState1Wrap = null;
     // Release the Second CLAMP sampler state.
     SamplerState2Clamp?.Dispose();
     SamplerState2Clamp = null;
     // Release the matrix constant buffer.
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     // Release the distortion constant buffer.
     ConstantDistortionBuffer?.Dispose();
     ConstantDistortionBuffer = null;
     // Release the noise constant buffer.
     ConstantNoiseBuffer?.Dispose();
     ConstantNoiseBuffer = null;
     // Release the layout.
     Layout?.Dispose();
     Layout = null;
     // Release the pixel shader.
     PixelShader?.Dispose();
     PixelShader = null;
     // Release the vertex shader.
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #6
0
 public void Dispose()
 {
     VertexShader?.Dispose();
     PixelShader?.Dispose();
     GeometryShader?.Dispose();
     Signature?.Dispose();
     InputLayout?.Dispose();
 }
Пример #7
0
        public virtual void Dispose()
        {
            VertexShader?.Dispose();
            PixelShader?.Dispose();

            VertexShaderCompilationResult?.Dispose();
            PixelShaderCompilationResult?.Dispose();
        }
Пример #8
0
 public void Dispose()
 {
     VertexShader?.Dispose();
     PixelShader?.Dispose();
     RasterizerState?.Dispose();
     DepthStencilState?.Dispose();
     BlendState?.Dispose();
 }
Пример #9
0
 public override void Shutdown()
 {
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     Layout?.Dispose();
     Layout = null;
     PixelShader?.Dispose();
     PixelShader = null;
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #10
0
        public void Dispose()
        {
            mVertexShaderResult?.Dispose();
            mPixelShaderResult?.Dispose();

            mVertexShader?.Dispose();
            mPixelShader?.Dispose();

            mWVPConstantBuffer?.Dispose();
            mLightConstantBuffer?.Dispose();
        }
 private void ShuddownShader()
 {
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     Layout?.Dispose();
     Layout = null;
     PixelShader?.Dispose();
     PixelShader = null;
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #12
0
        public override void Dispose()
        {
            vertexShader?.Dispose();
            pixelShader?.Dispose();
            inputSignature?.Dispose();
            layout?.Dispose();
            ConstantsBuffer?.Dispose();
            Texture?.Dispose();
            Sampler?.Dispose();

            base.Dispose();
        }
Пример #13
0
        public override void Dispose()
        {
            geometryShader?.Dispose();
            vertexShader?.Dispose();
            pixelShader?.Dispose();
            layout?.Dispose();
            Texture?.Dispose();

            blendStateDepth?.Dispose();

            depthStencilStateNoDepth?.Dispose();
        }
Пример #14
0
 public void Dispose()
 {
     _renderForm?.Dispose();
     _swapChain?.Dispose();
     _device?.Dispose();
     _deviceContext?.Dispose();
     _renderTargetView?.Dispose();
     _triangleVertexBuffer?.Dispose();
     _vertexShader?.Dispose();
     _pixelShader?.Dispose();
     _inputSignature?.Dispose();
     _inputLayout?.Dispose();
 }
 private void ShutdownShader()
 {
     SamplerState?.Dispose();
     SamplerState = null;
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     Layout?.Dispose();
     Layout = null;
     PixelShader?.Dispose();
     PixelShader = null;
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #16
0
        public void Dispose()
        {
            ConstantMatrixBuffer?.Dispose();
            ConstantMatrixBuffer = null;

            Layout?.Dispose();
            Layout = null;

            PixelShader?.Dispose();
            PixelShader = null;

            VertexShader?.Dispose();
            VertexShader = null;
        }
Пример #17
0
        public void Dispose()
        {
            _vertexLayout?.Dispose();
            _vertexShader?.Dispose();

            _pixelShader?.Dispose();
            _blendState?.Dispose();

            _dynamicConstantBuffer?.Dispose();
            if (!_vertexBufferExternal)
            {
                _vertexBuffer?.Dispose();
            }
            _dx.RemoveRef();
        }
Пример #18
0
        private void ShutdownShader()
        {
            _matrixBuffer?.Dispose();
            _matrixBuffer = null;

            _layout?.Dispose();
            _layout = null;

            _pixelShader?.Dispose();
            _pixelShader = null;

            _vertexShader?.Dispose();
            _vertexShader = null;
            return;
        }
Пример #19
0
 private void ShuddownShader()
 {
     // Release the matrix constant buffer.
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     // Release the layout.
     Layout?.Dispose();
     Layout = null;
     // Release the pixel shader.
     PixelShader?.Dispose();
     PixelShader = null;
     // Release the vertex shader.
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #20
0
 public virtual void Shutdown()
 {
     ConstantLightBuffer?.Dispose();
     ConstantLightBuffer = null;
     ConstantCameraBuffer?.Dispose();
     ConstantCameraBuffer = null;
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     ConstantEditorParamsBuffer?.Dispose();
     ConstantEditorParamsBuffer = null;
     SamplerState?.Dispose();
     SamplerState = null;
     Layout?.Dispose();
     Layout = null;
     PixelShader?.Dispose();
     PixelShader = null;
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #21
0
 public override void Shutdown()
 {
     ConstantLightBuffer?.Dispose();
     ConstantLightBuffer = null;
     ConstantCameraBuffer?.Dispose();
     ConstantCameraBuffer = null;
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     ConstantShaderParamBuffer?.Dispose();
     ConstantShaderParamBuffer = null;
     SamplerState?.Dispose();
     SamplerState = null;
     Layout?.Dispose();
     Layout = null;
     PixelShader?.Dispose();
     PixelShader = null;
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #22
0
        public void Dispose()
        {
            ConstantLightBuffer?.Dispose();
            ConstantLightBuffer = null;

            SamplerState?.Dispose();
            SamplerState = null;

            ConstantMatrixBuffer?.Dispose();
            ConstantMatrixBuffer = null;

            Layout?.Dispose();
            Layout = null;

            PixelShader?.Dispose();
            PixelShader = null;

            VertexShader?.Dispose();
            VertexShader = null;
        }
Пример #23
0
        public static void InvalidateDeviceObjects()
        {
            if (_device == null)
            {
                return;
            }

            _fontSampler?.Dispose();
            _fontSampler = null;

            _fontResourceView?.Dispose();
            _fontResourceView = null;
            ImGui.GetIO().Fonts.SetTexID(IntPtr.Zero);

            _indexBuffer?.Dispose();
            _indexBuffer = null;

            _vertexBuffer?.Dispose();
            _vertexBuffer = null;

            _blendState?.Dispose();
            _blendState = null;

            _depthStencilState?.Dispose();
            _depthStencilState = null;

            _rasterizerState?.Dispose();
            _rasterizerState = null;

            _pixelShader?.Dispose();
            _pixelShader = null;

            _vertexConstantBuffer?.Dispose();
            _vertexConstantBuffer = null;

            _inputLayout?.Dispose();
            _inputLayout = null;

            _vertexShader?.Dispose();
            _vertexShader = null;
        }
 private void ShuddownShader()
 {
     // Release the sampler state.
     SamplerState?.Dispose();
     SamplerState = null;
     // Release the Texture Translation constant buffer.
     ConstantTranslateBuffer?.Dispose();
     ConstantTranslateBuffer = null;
     // Release the matrix constant buffer.
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     // Release the layout.
     Layout?.Dispose();
     Layout = null;
     // Release the pixel shader.
     PixelShader?.Dispose();
     PixelShader = null;
     // Release the vertex shader.
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #25
0
 public void Dispose()
 {
     // Release the pixel constant buffer.
     ConstantPixelBuffer?.Dispose();
     ConstantPixelBuffer = null;
     // Release the sampler state.
     SamplerState?.Dispose();
     SamplerState = null;
     // Release the matrix constant buffer.
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     // Release the layout.
     Layout?.Dispose();
     Layout = null;
     // Release the pixel shader.
     PixelShader?.Dispose();
     PixelShader = null;
     // Release the vertex shader.
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #26
0
 private void ShuddownShader()
 {
     // Release the sampler state.
     SamplerState?.Dispose();
     SamplerState = null;
     // Release the matrix constant buffer.
     ConstantPerFrameBuffer?.Dispose();
     ConstantPerFrameBuffer = null;
     // Release the fog constant buffer.
     ConstantFogBuffer?.Dispose();
     ConstantFogBuffer = null;
     // Release the layout.
     Layout?.Dispose();
     Layout = null;
     // Release the pixel shader.
     PixelShader?.Dispose();
     PixelShader = null;
     // Release the vertex shader.
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #27
0
        private void ShutdownShader()
        {
            _pixelBuffer?.Dispose();
            _pixelBuffer = null;

            _sampleState?.Dispose();
            _sampleState = null;

            _constantBuffer?.Dispose();
            _constantBuffer = null;

            _layout?.Dispose();
            _layout = null;

            _pixelShader?.Dispose();
            _pixelShader = null;

            _vertexShader?.Dispose();
            _vertexShader = null;
            return;
        }
Пример #28
0
 private void ShuddownShader()
 {
     // Release the sampler state.
     SamplerState?.Dispose();
     SamplerState = null;
     // Release the matrix constant buffer.
     ConstantMatrixBuffer?.Dispose();
     ConstantMatrixBuffer = null;
     // Release the screen size constant buffer.
     ConstantScreenSizeBuffer?.Dispose();
     ConstantScreenSizeBuffer = null;
     // Release the layout.
     Layout?.Dispose();
     Layout = null;
     // Release the pixel shader.
     PixelShader?.Dispose();
     PixelShader = null;
     // Release the vertex shader.
     VertexShader?.Dispose();
     VertexShader = null;
 }
Пример #29
0
        private void ShuddownShader()
        {
            // Release the sampler state.
            if (SampleState != null)
            {
                SampleState.Dispose();
                SampleState = null;
            }

            // Release the matrix constant buffer.
            if (ConstantMatrixBuffer != null)
            {
                ConstantMatrixBuffer.Dispose();
                ConstantMatrixBuffer = null;
            }

            // Release the layout.
            if (Layout != null)
            {
                Layout.Dispose();
                Layout = null;
            }

            // Release the pixel shader.
            if (PixelShader != null)
            {
                PixelShader.Dispose();
                PixelShader = null;
            }

            // Release the vertex shader.
            if (VertexShader != null)
            {
                VertexShader.Dispose();
                VertexShader = null;
            }
        }
Пример #30
0
        public void Dispose()
        {
            // TODO: Move this to GL_Cleanup
            if (ProgramID != 0)
            {
                // Make sure this program isn't being used
                if (GL.CurrentProgram == ProgramID)
                {
                    GL.UseProgram(0);
                }

                GL.DetachShader(ProgramID, VertexShader.ShaderID);
                GL.DetachShader(ProgramID, FragmentShader.ShaderID);
                GL.DeleteProgram(ProgramID);

                if (DisposeChildren)
                {
                    VertexShader.Dispose();
                    FragmentShader.Dispose();
                }

                this.ProgramID = 0;
            }
        }
Пример #31
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var form = new Form1();

            Device device;
            SwapChain swapChain;
            ShaderSignature inputSignature;
            VertexShader vertexShader;
            GeometryShader geometryShader;
            PixelShader pixelShader;

            var description = new SwapChainDescription()
            {
                BufferCount = 2,
                Usage = Usage.RenderTargetOutput,
                OutputHandle = form.Handle,
                IsWindowed = true,
                ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags = SwapChainFlags.AllowModeSwitch,
                SwapEffect = SwapEffect.Discard
            };

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

            // create a view of our render target, which is the backbuffer of the swap chain we just created
            RenderTargetView renderTarget;
            using (var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0))
                renderTarget = new RenderTargetView(device, resource);

            // setting a viewport is required if you want to actually see anything
            var context = device.ImmediateContext;
            var viewport = new Viewport(0.0f, 0.0f, form.ClientSize.Width, form.ClientSize.Height);
            context.OutputMerger.SetTargets(renderTarget);
            context.Rasterizer.SetViewports(viewport);

            // load and compile the vertex shader
            using (var bytecode = ShaderBytecode.CompileFromFile("Voxel.fx", "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None))
            {
                inputSignature = ShaderSignature.GetInputSignature(bytecode);
                vertexShader = new VertexShader(device, bytecode);
            }

            using (var bytecode = ShaderBytecode.CompileFromFile("Voxel.fx", "GS", "gs_4_0", ShaderFlags.None, EffectFlags.None))
            {
                geometryShader = new GeometryShader(device, bytecode);
            }

            // load and compile the pixel shader
            using (var bytecode = ShaderBytecode.CompileFromFile("Voxel.fx", "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None))
                pixelShader = new PixelShader(device, bytecode);

            // create test vertex data, making sure to rewind the stream afterward
            var vertices = new DataStream(12 * 3, true, true);
            vertices.Write(new Vector3(0.0f, 0.5f, 0.5f));
            vertices.Write(new Vector3(0.5f, -0.5f, 0.5f));
            vertices.Write(new Vector3(-0.5f, -0.5f, 0.5f));
            vertices.Position = 0;

            // create the vertex layout and buffer
            var elements = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0) };
            var layout = new InputLayout(device, inputSignature, elements);
            var vertexBuffer = new Buffer(device, vertices, 12 * 3, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);

            // configure the Input Assembler portion of the pipeline with the vertex data
            context.InputAssembler.InputLayout = layout;
            context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
            context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, 12, 0));

            // set the shaders
            context.VertexShader.Set(vertexShader);
            // context.GeometryShader.Set(geometryShader);
            context.PixelShader.Set(pixelShader);

            // prevent DXGI handling of alt+enter, which doesn't work properly with Winforms
            using (var factory = swapChain.GetParent<Factory>())
                factory.SetWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAltEnter);

            // handle alt+enter ourselves
            form.KeyDown += (o, e) =>
            {
                if (e.Alt && e.KeyCode == Keys.Enter)
                    swapChain.IsFullScreen = !swapChain.IsFullScreen;
            };

            // handle form size changes
            form.Resize += (o, e) =>
            {
                renderTarget.Dispose();

                swapChain.ResizeBuffers(2, 0, 0, Format.R8G8B8A8_UNorm, SwapChainFlags.AllowModeSwitch);
                using (var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0))
                    renderTarget = new RenderTargetView(device, resource);

                context.OutputMerger.SetTargets(renderTarget);
            };

            MessagePump.Run(form, () =>
            {
                // clear the render target to a soothing blue
                context.ClearRenderTargetView(renderTarget, new Color4(0.5f, 0.5f, 1.0f));

                // draw the triangle
                context.Draw(3, 0);
                swapChain.Present(0, PresentFlags.None);
            });

            // clean up all resources
            // anything we missed will show up in the debug output
            vertices.Close();
            vertexBuffer.Dispose();
            layout.Dispose();
            inputSignature.Dispose();
            vertexShader.Dispose();
            geometryShader.Dispose();
            pixelShader.Dispose();
            renderTarget.Dispose();
            swapChain.Dispose();
            device.Dispose();
        }