public void Dispose() { outputPipeline.Dispose(); outputColorPipeline.Dispose(); glyphPipeline.Dispose(); textPropertiesSet.Dispose(); textTextureSet.Dispose(); dummyTextureSet.Dispose(); foreach (var shader in glyphShaders) { shader.Dispose(); } foreach (var shader in textShaders) { shader.Dispose(); } glyphTexture.Dispose(); glyphTextureView.Dispose(); glyphTextureFramebuffer.Dispose(); dummyTexture.Dispose(); dummyTextureView.Dispose(); glyphVertexBuffer.Dispose(); quadVertexBuffer.Dispose(); textVertexPropertiesBuffer.Dispose(); textFragmentPropertiesBuffer.Dispose(); }
protected override void DisposeManaged() { base.DisposeManaged(); foreach (var binding in Bindings) { binding.Dispose(); } resourceSet?.Dispose(); }
private void RecreateWindowFramebuffers(CommandList cl) { MainWindowColorTexture?.Dispose(); MainWindowFramebuffer?.Dispose(); MainWindowResourceSet?.Dispose(); var factory = _gd.ResourceFactory; _gd.GetPixelFormatSupport( PixelFormat.R8_G8_B8_A8_UNorm, TextureType.Texture2D, TextureUsage.RenderTarget, out PixelFormatProperties properties); TextureDescription mainColorDesc = TextureDescription.Texture2D( _gd.SwapchainFramebuffer.Width, _gd.SwapchainFramebuffer.Height, 1, 1, PixelFormat.R8_G8_B8_A8_UNorm, TextureUsage.RenderTarget | TextureUsage.Sampled, TextureSampleCount.Count1); MainWindowColorTexture = factory.CreateTexture(ref mainColorDesc); MainWindowFramebuffer = factory.CreateFramebuffer(new FramebufferDescription(null, MainWindowColorTexture)); //MainWindowResourceSet = factory.CreateResourceSet(new ResourceSetDescription(TextureSamplerResourceLayout, MainWindowResolvedColorView, _gd.PointSampler)); }
public void Dispose_ResourceSet() { ResourceLayout layout = RF.CreateResourceLayout(new ResourceLayoutDescription( new ResourceLayoutElementDescription("InfoBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex), new ResourceLayoutElementDescription("Ortho", ResourceKind.UniformBuffer, ShaderStages.Vertex))); DeviceBuffer ub0 = RF.CreateBuffer(new BufferDescription(256, BufferUsage.UniformBuffer)); DeviceBuffer ub1 = RF.CreateBuffer(new BufferDescription(256, BufferUsage.UniformBuffer)); ResourceSet rs = RF.CreateResourceSet(new ResourceSetDescription(layout, ub0, ub1)); rs.Dispose(); Assert.True(rs.IsDisposed); Assert.False(ub0.IsDisposed); Assert.False(ub1.IsDisposed); Assert.False(layout.IsDisposed); layout.Dispose(); Assert.True(layout.IsDisposed); Assert.False(ub0.IsDisposed); Assert.False(ub1.IsDisposed); ub0.Dispose(); Assert.True(ub0.IsDisposed); ub1.Dispose(); Assert.True(ub1.IsDisposed); }
public Building(RgbaFloat color) : base("Building") { Resources.OnInitialize = (factory, device) => { _model.Buffer.Initialize(factory, device); _color = new UniformColor(color); _color.Buffer.Initialize(factory, device); ResourceLayout = factory.CreateResourceLayout(new ResourceLayoutDescription( new ResourceLayoutElementDescription[] { UniformModelTransformation.ResourceLayout, UniformViewProjection.ResourceLayout, _color.LayoutDescription } )); ResourceSet = factory.CreateResourceSet(new ResourceSetDescription( ResourceLayout, _model.Buffer.DeviceBuffer, CameraViewProjection.DeviceBuffer, _color.Buffer.DeviceBuffer )); }; Resources.OnDispose = () => { _color.Buffer.Dispose(); ResourceLayout.Dispose(); ResourceSet.Dispose(); }; }
/// <summary> /// Função pra iterar sob os Resources e seus respectivos arquivos a serem minificados /// </summary> /// <param name="FileContentSB">StringBuilder esperado para mudança de estados, concatenação com os conteúdos minificados</param> internal void IterateOnResourceRepository(ref StringBuilder fileContentSB) { ResourceSet resourceSet = null; global::System.Resources.ResourceManager[] ResourceManagerArray = new global::System.Resources.ResourceManager[] { }; try { ResourceManagerArray = this._resourceManager.ToArray(); DictionaryEntry[] filesAndContents = null; for (int i = 0; i < ResourceManagerArray.Length; i++) { filesAndContents = new DictionaryEntry[] { }; resourceSet = ResourceManagerArray[i].GetResourceSet(CultureInfo.CurrentUICulture, true, true); filesAndContents = resourceSet.OfType <DictionaryEntry>().OrderBy(x => x.Key).ToArray(); for (int j = 0; j < filesAndContents.Length; j++) { _minifiedOperations.ConcatenateAndMinifieContent(ref fileContentSB, filesAndContents[j].Value.ToString(), true); } } } catch (Exception ex) { throw new Exception("Falha durante acesso ao arquivo de Resources.", ex); } finally { if (null != resourceSet) { resourceSet.Dispose(); } } }
public Surface() : base("UI Surface") { Resources.OnInitialize += (_, e) => { _device = e.GraphicsDevice; _size = new Size( (int)_device.SwapchainFramebuffer.Width, (int)_device.SwapchainFramebuffer.Height ); _sampler = _device.LinearSampler; ResourceLayout = e.ResourceFactory.CreateResourceLayout( new ResourceLayoutDescription( new ResourceLayoutElementDescription( "SurfaceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment), new ResourceLayoutElementDescription( "SurfaceSampler", ResourceKind.Sampler, ShaderStages.Fragment))); CreateTexture(); }; Resources.OnDispose += (_, __) => { _textureView.Dispose(); _texture.Dispose(); ResourceSet.Dispose(); }; }
public void GetStream_ResourceSet_Disposed() { Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; ResourceManager rm = ResourceManager. CreateFileBasedResourceManager("StreamTest", "Test/resources", null); ResourceSet rs = rm.GetResourceSet(new CultureInfo("ja-JP"), true, true); rs.Dispose(); try { rm.GetStream("test", new CultureInfo("ja-JP")); Assert.Fail("#1"); } catch (ObjectDisposedException ex) { // Cannot access a closed resource set Assert.AreEqual(typeof(ObjectDisposedException), ex.GetType(), "#2"); Assert.IsNull(ex.InnerException, "#3"); Assert.IsNotNull(ex.Message, "#4"); } finally { rm.ReleaseAllResources(); } }
private void CreateWindowSizedResources(ResourceFactory factory) { _computeTargetTexture?.Dispose(); _computeTargetTextureView?.Dispose(); _computeResourceSet?.Dispose(); _graphicsResourceSet?.Dispose(); _computeTargetTexture = factory.CreateTexture(TextureDescription.Texture2D( (uint)_window.Width, (uint)_window.Height, 1, 1, PixelFormat.R32_G32_B32_A32_Float, TextureUsage.Sampled | TextureUsage.Storage)); _computeTargetTextureView = factory.CreateTextureView(_computeTargetTexture); _computeResourceSet = factory.CreateResourceSet(new ResourceSetDescription( _computeLayout, _computeTargetTextureView, _screenSizeBuffer, _shiftBuffer)); _graphicsResourceSet = factory.CreateResourceSet(new ResourceSetDescription( _graphicsLayout, _computeTargetTextureView, _computeTargetTextureView, _computeTargetTextureView, _gd.PointSampler)); }
private void Resize(RenderContext context) { var vpw = Math.Max(1, _viewport.Width); var vph = Math.Max(1, _viewport.Height); if (_bitmap != null && vpw == _width && vph == _height) { return; } _width = vpw; _height = vph; _set?.Dispose(); _view?.Dispose(); _texture?.Dispose(); _bitmap?.Dispose(); _bitmap = new Bitmap(_width, _height, PixelFormat.Format32bppArgb); _texture = context.Device.ResourceFactory.CreateTexture(TextureDescription.Texture2D( (uint)_width, (uint)_height, 1, 1, Veldrid.PixelFormat.B8_G8_R8_A8_UNorm, TextureUsage.Sampled )); _view = context.Device.ResourceFactory.CreateTextureView(_texture); _set = context.Device.ResourceFactory.CreateResourceSet(new ResourceSetDescription( context.ResourceLoader.TextureLayout, _view, context.ResourceLoader.OverlaySampler )); }
public void GetString_ResourceSet_Disposed() { Thread.CurrentThread.CurrentUICulture = new CultureInfo("de"); ResourceManager rm = ResourceManager. CreateFileBasedResourceManager("MyResources", "Test/resources", null); ResourceSet rs = rm.GetResourceSet(new CultureInfo("de"), true, true); rs.Dispose(); try { rm.GetString("deHelloWorld"); Assert.Fail("#1"); #if NET_2_0 } catch (ObjectDisposedException ex) { // Cannot access a closed resource set Assert.AreEqual(typeof(ObjectDisposedException), ex.GetType(), "#2"); Assert.IsNull(ex.InnerException, "#3"); Assert.IsNotNull(ex.Message, "#4"); #else } catch (InvalidOperationException ex) { // ResourceSet is closed Assert.AreEqual(typeof(InvalidOperationException), ex.GetType(), "#2"); Assert.IsNull(ex.InnerException, "#3"); Assert.IsNotNull(ex.Message, "#4"); #endif } finally { rm.ReleaseAllResources(); } }
internal static void smethod_0(ResourceManager resourceManager_0) { ResourceSet set = null; try { set = resourceManager_0.GetResourceSet(CultureInfo.CurrentCulture, true, true); IDictionaryEnumerator enumerator = set.GetEnumerator(); while (enumerator.MoveNext()) { dictionary_0[enumerator.Key.ToString()] = enumerator.Value; } } catch (Exception exception) { ilog_0.Error("加载资源文件异常:" + resourceManager_0.BaseName, exception); } finally { if (resourceManager_0 != null) { resourceManager_0.ReleaseAllResources(); } if (set != null) { set.Dispose(); } } }
public void Dispose() { _rs.Dispose(); if (_ownsFramebuffer) { _fb.Dispose(); } }
private void Dispose() { graphicsPipeline.Dispose(); graphicsSet.Dispose(); textureView.Dispose(); transferTexture.Dispose(); commandList.Dispose(); }
public void DisposeOfGpuResources() { _pipeline?.Dispose(); _weightsAndOffsetsDeviceBuffer?.Dispose(); _weightsAndOffsetsResourceSet?.Dispose(); _gaussianFactorsUniformBlockBuffer?.Dispose(); _gaussianFactorsUniformBlockResourceSet?.Dispose(); }
public void Dispose() { _projectionResourceSet?.Dispose(); _projectionBuffer?.Dispose(); _pipeline?.Dispose(); _vertex?.Dispose(); _fragment?.Dispose(); }
public void Dispose() { _rl.Dispose(); _pipeline.Dispose(); _sampleRegionUB.Dispose(); _sampleRegionSet.Dispose(); _sampleRegionLayout.Dispose(); }
public void Dispose() { Lightmap.Dispose(); for (var i = 0; i < Textures.Length; ++i) { Textures[i].Dispose(); } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { _worldTextureResourceSet.Dispose(); Owner.Game.Renderer.RemoveSprite(this); } }
//调整其子界面的大小 public void ResizeWindow(uint width, uint height) { lock (BitmapLock) { //触发host的resize _windowsHeight = height; _windowsWidth = width; if (_host != null) { _host.WasResized(); } //同时重建渲染管线 if (_screenPipeline != null) { _screenPipeline.Dispose(); } if (_textureView != null) { _textureView.Dispose(); } if (_texture != null) { _texture.Dispose(); } if (_screenResourceSet != null) { _screenResourceSet.Dispose(); } _texture = _gd.ResourceFactory.CreateTexture(TextureDescription.Texture2D((uint)_windowsWidth, (uint)_windowsHeight, 1, 1, PixelFormat.B8_G8_R8_A8_UNorm, TextureUsage.Sampled)); _textureView = _gd.ResourceFactory.CreateTextureView(_texture); //重建resourceSet _screenResourceSet = _gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription( _screenResourceLayout, _textureView, _gd.Aniso4xSampler )); var rasterizer = RasterizerStateDescription.Default; rasterizer.FillMode = PolygonFillMode.Solid; rasterizer.FrontFace = FrontFace.CounterClockwise; rasterizer.CullMode = FaceCullMode.Front; _screenPipeline = _gd.ResourceFactory.CreateGraphicsPipeline(new GraphicsPipelineDescription( BlendStateDescription.SingleOverrideBlend, DepthStencilStateDescription.DepthOnlyLessEqual, rasterizer, PrimitiveTopology.TriangleList, _shaderset, //共享View和prj的buffer new ResourceLayout[] { _screenResourceLayout }, _gd.MainSwapchain.Framebuffer.OutputDescription)); } }
public void GetString_ResourceSet_Disposed() { ResourceManager rm = ResourceManager. CreateFileBasedResourceManager("MyResources", TestResourceHelper.GetFullPathOfResource("Test/resources"), null); ResourceSet rs = rm.GetResourceSet(new CultureInfo("de"), true, true); rs.Dispose(); Assert.IsNull(rm.GetString("deHelloWorld")); rm.ReleaseAllResources(); }
public void DestroyResources() { _transformsResourceSet?.Dispose(); _transformsBuffer?.Dispose(); _frozenTransformsResourceSet?.Dispose(); _frozenTransformsBuffer?.Dispose(); _transformsResourceSet = null; _transformsBuffer = null; _frozenTransformsResourceSet = null; _frozenTransformsBuffer = null; }
protected override void Dispose(bool disposeManagedResources) { base.Dispose(disposeManagedResources); ResourceSet.Dispose(); ResourceSet = null; TextureLayout.Dispose(); TextureLayout = null; ProjectionBuffer.Dispose(); ProjectionBuffer = null; WorldBuffer.Dispose(); WorldBuffer = null; }
public void Dispose() { foreach (IDisposable disposable in _disposables) { disposable.Dispose(); } foreach (KeyValuePair <OutputDescription, TextureBlitter> kvp in _blitters) { kvp.Value.Dispose(); } _leftSet?.Dispose(); _rightSet?.Dispose(); }
public void Dispose() { _pipeline.Dispose(); foreach (var shader in _shaders) { shader.Dispose(); } _resourceSet.Dispose(); _skeletonTexture.Dispose(); _skeletonTextureView.Dispose(); _vertexBuffer.Dispose(); }
public void Dispose() { if (_disposed) { return; } foreach (var pipeline in _pipelines.Values) { pipeline.Dispose(); } foreach (var t in _textureResourceSets) { t?.Dispose(); } foreach (var t in _textureViews) { t?.Dispose(); } _textureLayout.Dispose(); _wvpSet.Dispose(); _wvpBuffer.Dispose(); _wvpLayout.Dispose(); foreach (var s in _samplerResourceSets) { if (s.IsValueCreated) { s.Value.Dispose(); } } _linearClamp?.Dispose(); _pointClamp?.Dispose(); _anisotropicClamp?.Dispose(); _samplerLayout.Dispose(); _vertexShader.Dispose(); _fragmentShader.Dispose(); _commandList.Dispose(); _vertexBuffer.Dispose(); _indexBuffer.Dispose(); _disposed = true; }
public void DisposeResources() { Pipeline.Dispose(); foreach (Shader shader in Shaders) { shader.Dispose(); } CommandList.Dispose(); VertexBuffer.Dispose(); IndexBuffer.Dispose(); GraphicsDevice.Dispose(); ProjectionBuffer.Dispose(); WorldBuffer.Dispose(); ResourceSet.Dispose(); ResourceLayout.Dispose(); }
// Private method in framework, had to be re-implemented here. private static void AddResourceSet(Hashtable localResourceSets, CultureInfo culture, ref ResourceSet resourceSet) { lock (localResourceSets) { ResourceSet localResourceSet = (ResourceSet)localResourceSets[culture]; if (localResourceSet != null) { if (!Equals(localResourceSet, resourceSet)) { resourceSet.Dispose(); resourceSet = localResourceSet; } } else { localResourceSets.Add(culture, resourceSet); } } }
//private method in framework, had to be re-specified private static void AddResourceSet(Hashtable localResourceSets, CultureInfo culture, ref ResourceSet rs) { lock (localResourceSets) { ResourceSet objA = (ResourceSet)localResourceSets[culture]; if (objA != null) { if (!object.Equals(objA, rs)) { rs.Dispose(); rs = objA; } } else { localResourceSets.Add(culture, rs); } } }
protected override void Dispose(bool disposeManagedResources) { base.Dispose(disposeManagedResources); if (_vertexBuffer != null && _indexBuffer != null) { _vertexBuffer.Dispose(); _vertexBuffer = null; _indexBuffer.Dispose(); _indexBuffer = null; } textureSet.Dispose(); textureSet = null; textureView.Dispose(); textureView = null; texture.Dispose(); texture = null; }