public void Dispose() { vertexShaderByteCode.Dispose(); vertexShader.Dispose(); pixelShaderByteCode.Dispose(); pixelShader.Dispose(); layout.Dispose(); }
protected override void DisposeData() { DisposeSamplerStates(); compiledVertexShader.Dispose(); compiledPixelShader.Dispose(); vertexShader.Dispose(); pixelShader.Dispose(); shaderBuffer.Dispose(); inputLayout.Dispose(); }
public void Dispose() { mVertexShaderResult?.Dispose(); mPixelShaderResult?.Dispose(); mVertexShader?.Dispose(); mPixelShader?.Dispose(); mWVPConstantBuffer?.Dispose(); mLightConstantBuffer?.Dispose(); }
protected override void EndPhase1() { base.EndPhase1(); mSignature.Dispose(); mVertexShaderResult.Dispose(); mVertexShader.Dispose(); mPixelShaderResult.Dispose(); mPixelShader.Dispose(); mVertices.Dispose(); mLayout.Dispose(); mConstantBuffer.Dispose(); mDepthBuffer.Dispose(); mRenderView.Dispose(); mBackBuffer.Dispose(); }
public Fragment LoadFragment(string fileName, InputElement[] inputElements) { Fragment result = new Fragment(); CompilationResult vertexShaderByteCode = null; CompilationResult pixelShaderByteCode = null; Assembly assembly = Assembly.GetExecutingAssembly(); using (Stream stream = assembly.GetManifestResourceStream("Profiler.DirectX." + fileName)) { using (StreamReader reader = new StreamReader(stream)) { //string data = reader.ReadToEnd(); byte[] data = new byte[stream.Length]; stream.Read(data, 0, data.Length); vertexShaderByteCode = ShaderBytecode.Compile(data, "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None); pixelShaderByteCode = ShaderBytecode.Compile(data, "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None); } } if (!String.IsNullOrEmpty(vertexShaderByteCode.Message)) { Debug.WriteLine(vertexShaderByteCode.Message); } result.VS = new VertexShader(RenderDevice, vertexShaderByteCode); if (!String.IsNullOrEmpty(pixelShaderByteCode.Message)) { Debug.WriteLine(pixelShaderByteCode.Message); } result.PS = new PixelShader(RenderDevice, pixelShaderByteCode); result.Layout = new InputLayout(RenderDevice, ShaderSignature.GetInputSignature(vertexShaderByteCode), inputElements); vertexShaderByteCode.Dispose(); pixelShaderByteCode.Dispose(); return(result); }
protected override void OnClosing(CancelEventArgs e) { // Release all resources vertexShaderByteCode.Dispose(); vertexShader.Dispose(); pixelShaderByteCode.Dispose(); pixelShader.Dispose(); vertices.Dispose(); layout.Dispose(); renderView.Dispose(); backBuffer.Dispose(); context.ClearState(); context.Flush(); device.Dispose(); context.Dispose(); swapChain.Dispose(); factory.Dispose(); base.OnClosing(e); }
public D3DShader(Device device, IShaderEffect shaderEffect, ShaderName shader) { this.device = device; this.shader = shader; try { vertexShaderByteCode = ShaderBytecode.CompileFromFile(shaderEffect.EffectShaderFileName, shaderEffect.VsFunctionName, shaderEffect.VsVersion.ToString()); } catch (Exception ex) { throw new Exception("vertexShaderByteCode: " + ex); } try { pixelShaderByteCode = ShaderBytecode.CompileFromFile(shaderEffect.EffectShaderFileName, shaderEffect.PsFunctionName, shaderEffect.PsVersion.ToString()); } catch (Exception ex) { throw new Exception("vertexShaderByteCode: " + ex); } try { vertexShader = new VertexShader(device, vertexShaderByteCode); } catch (Exception ex) { throw new Exception("vertexShader: " + ex); } try { pixelShader = new PixelShader(device, pixelShaderByteCode); } catch (Exception ex) { throw new Exception("pixelShader: " + ex); } // Now setup the layout of the data that goes into the shader. // It needs to match the VertexType structure in the Model and in the shader. InputElement[] inputElementDesc = InputLayoutFactory.Create(shaderEffect.VertexType); CreateInputLayout(inputElementDesc); vertexShaderByteCode.Dispose(); pixelShaderByteCode.Dispose(); constantMatrixBuffer = GetConstantMatrixBuffer <BufferTypes.WorldViewProj>(device); //is there any differnece between loading one shader wih multiple effects //and more shaders with only one effect? if (shader != ShaderName.Color) { LoadTextureShader(); } //shader.GetPerObjectBufferType<DiffuseLightBufferType> if (shader == ShaderName.ParallaxMapping || shader == ShaderName.Diffuse || shader == ShaderName.Bumpmaping || shader == ShaderName.LightingEffect) { constantLightBuffer = GetConstantMatrixBuffer <BufferTypes.DiffuseLightBufferType>(device); } if (shader == ShaderName.Ambient) { constantLightBuffer = GetConstantMatrixBuffer <BufferTypes.AmbientLightBufferType>(device); } if (shader == ShaderName.Specular || shader == ShaderName.DirectionalLightingParallaxMapping) { constantLightBuffer = GetConstantMatrixBuffer <BufferTypes.SpecularLightBufferType>(device); } if (shader == ShaderName.ParallaxMapping || shader == ShaderName.Bumpmaping || shader == ShaderName.Specular || shader == ShaderName.ParallaxMapping || shader == ShaderName.DirectionalLightingParallaxMapping) { constantCameraBuffer = GetConstantMatrixBuffer <BufferTypes.CameraBufferType>(device); } }