Esempio n. 1
0
        //释放资源
        public void Dispose()
        {
            //等待GPU处理完所有的资源
            WaitForPreviousFrame();

            //释放所有资源
            foreach (var target in renderTargets)
            {
                target.Dispose();
            }
            commandAllocator.Dispose();
            bundleAllocator.Dispose();
            commandQueue.Dispose();
            rootSignature.Dispose();
            pipelineState.Dispose();
            vertexBuffer.Dispose();
            texture.Dispose();
            indexBuffer.Dispose();
            renderTargetViewHeap.Dispose();
            commandList.Dispose();
            bundle.Dispose();
            fence.Dispose();
            swapChain.Dispose();
            device.Dispose();
        }
Esempio n. 2
0
        protected override void Destroy()
        {
            RootSignature?.Dispose();
            RootSignature = null;

            base.Destroy();
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _rootSignature.Dispose();
         _srvDescriptorHeap?.Dispose();
         foreach (Texture texture in _textures.Values)
         {
             texture.Dispose();
         }
         foreach (FrameResource frameResource in _frameResources)
         {
             frameResource.Dispose();
         }
         foreach (MeshGeometry geometry in _geometries.Values)
         {
             geometry.Dispose();
         }
         foreach (PipelineState pso in _psos.Values)
         {
             pso.Dispose();
         }
     }
     base.Dispose(disposing);
 }
Esempio n. 4
0
        protected override void Destroy()
        {
            RootSignature?.Dispose();
            RootSignature = null;

            bufferUploader.Clear();

            base.Destroy();
        }
Esempio n. 5
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _rootSignature?.Dispose();
                _cbvHeap?.Dispose();
                _objectCB?.Dispose();
                _boxGeo?.Dispose();
                _pso?.Dispose();
            }

            base.Dispose(disposing);
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _rootSignature?.Dispose();
         _opaquePso?.Dispose();
         foreach (FrameResource frameResource in _frameResources)
         {
             frameResource.Dispose();
         }
         foreach (MeshGeometry geometry in _geometries.Values)
         {
             geometry.Dispose();
         }
     }
     base.Dispose(disposing);
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _readBackBuffer.Dispose();
         _outputBuffer.Dispose();
         _inputUploadBufferB.Dispose();
         _inputBufferB.Dispose();
         _inputUploadBufferA.Dispose();
         _inputBufferA.Dispose();
         _rootSignature.Dispose();
         foreach (PipelineState pso in _psos.Values)
         {
             pso.Dispose();
         }
     }
     base.Dispose(disposing);
 }
        public void Dispose()
        {
            WaitForPreviousFrame();

            foreach (var target in renderTargets)
            {
                target.Dispose();
            }
            commandAllocator.Dispose();
            commandQueue.Dispose();
            rootSignature.Dispose();
            renderTargetViewHeap.Dispose();
            pipelineState.Dispose();
            commandList.Dispose();
            vertexBuffer.Dispose();
            fence.Dispose();
            swapChain.Dispose();
            device.Dispose();
        }
Esempio n. 9
0
        public void Dispose()
        {
            // Wait for the GPU to be done with all resources.
            WaitForPreviousFrame();

            foreach (var target in _renderTargets)
            {
                target.Dispose();
            }
            _commandAllocator.Dispose();
            _graphicsQueue.Dispose();
            _rootSignature.Dispose();
            _renderTargetViewHeap.Dispose();
            _pipelineState.Dispose();
            _commandList.Dispose();
            _fence.Dispose();
            _swapChain.Dispose();
            _device.Dispose();
        }
Esempio n. 10
0
        /// <summary>
        /// Compiles or recompiles the effect if necesssary.
        /// </summary>
        /// <param name="graphicsDevice"></param>
        /// <returns>True if the effect was recompiled, false otherwise.</returns>
        public bool UpdateEffect(GraphicsDevice graphicsDevice)
        {
            if (effect == null || permutationCounter != Parameters.PermutationCounter || (effect != null && effect.SourceChanged))
            {
                permutationCounter = Parameters.PermutationCounter;

                var oldEffect = effect;
                ChooseEffect(graphicsDevice);

                // Early exit: same effect, and already initialized
                if (oldEffect == effect && descriptorReflection != null)
                {
                    return(false);
                }

                // Update reflection and rearrange buffers/resources
                var layoutNames = effect.Bytecode.Reflection.ResourceBindings.Select(x => x.ResourceGroup ?? "Globals").Distinct().ToList();
                descriptorReflection = EffectDescriptorSetReflection.New(graphicsDevice, effect.Bytecode, layoutNames, "Globals");

                RootSignature?.Dispose();
                RootSignature = RootSignature.New(graphicsDevice, descriptorReflection);

                bufferUploader.Clear();
                bufferUploader.Compile(graphicsDevice, descriptorReflection, effect.Bytecode);

                // Create parameter updater
                var layouts = new DescriptorSetLayoutBuilder[descriptorReflection.Layouts.Count];
                for (int i = 0; i < descriptorReflection.Layouts.Count; ++i)
                {
                    layouts[i] = descriptorReflection.Layouts[i].Layout;
                }
                var parameterUpdaterLayout = new EffectParameterUpdaterLayout(graphicsDevice, effect, layouts);
                parameterUpdater = new EffectParameterUpdater(parameterUpdaterLayout, Parameters);

                descriptorSets = new DescriptorSet[parameterUpdater.ResourceGroups.Length];

                return(true);
            }

            return(false);
        }