Esempio n. 1
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            foreach (var cam in allGPUDRPCamera.Values)
            {
                cam.Clear();
            }

            allGPUDRPCamera.Clear();

            GPUCull.GPUCullSystem.Destroy();
            MCRResourcesSystem.Destroy();
            ComputeBufferPool.Destroy();
            CommandBufferPool.Destroy();
            GlobalMaterial.Destroy();
        }
Esempio n. 2
0
        protected override void Render(ScriptableRenderContext context, Camera[] cameras)
        {
            if (!bFirstCall)
            {
                if (Application.isPlaying)
                {
                    MCRResourcesSystem.Init();
                    GlobalMaterial.Init();
                    GPUCull.GPUCullSystem.Init();
                }

                bFirstCall = true;
            }

            foreach (Camera cam in cameras)
            {
                GPUDRPCamera gpudrpCamera = null;

                if (!allGPUDRPCamera.TryGetValue(cam, out gpudrpCamera))
                {
                    gpudrpCamera = cam.GetComponent <GPUDRPCamera>();

                    if (!gpudrpCamera)
                    {
                        gpudrpCamera = cam.gameObject.AddComponent <GPUDRPCamera>();
                        allGPUDRPCamera.Add(cam, gpudrpCamera);
                    }
                }

                //设置pipelinecontext
                PipelineContext.mainCmdBuffer = CommandBufferPool.Get("MainCommandBuffer");
                PipelineContext.renderContext = context;
                PipelineContext.gpuCamera     = gpudrpCamera;

                if (PipelineContext.gpuCamera.BeginRender())
                {
                    PipelineContext.gpuCamera.Render();
                }

                context.Submit();

                PipelineContext.gpuCamera.EndRender();

                ComputeBufferPool.EndOfRender();
                CommandBufferPool.Release(PipelineContext.mainCmdBuffer);
            }
        }