Esempio n. 1
0
        public void TickLogic()
        {
            if (mSV_PickedSetUp == null)
            {
                return;
            }

            ScopeTickLogic.Begin();

            mSV_PickedSetUp.CookSpecRenderLayerDataToPass(mRHICtx, ERenderLayer.RL_Opaque, mCamera, mSE_PickedSetUp, PrebuildPassIndex.PPI_PickedEditor);
            mSV_PickedSetUp.CookSpecRenderLayerDataToPass(mRHICtx, ERenderLayer.RL_CustomOpaque, mCamera, mSE_PickedSetUp, PrebuildPassIndex.PPI_PickedEditor);
            mSV_PickedSetUp.CookSpecRenderLayerDataToPass(mRHICtx, ERenderLayer.RL_CustomTranslucent, mCamera, mSE_PickedSetUp, PrebuildPassIndex.PPI_PickedEditor);
            mSV_PickedSetUp.CookSpecRenderLayerDataToPass(mRHICtx, ERenderLayer.RL_Translucent, mCamera, mSE_PickedSetUp, PrebuildPassIndex.PPI_PickedEditor);
            mSV_PickedSetUp.CookSpecRenderLayerDataToPass(mRHICtx, ERenderLayer.RL_Gizmos, mCamera, mSE_PickedSetUp, PrebuildPassIndex.PPI_PickedEditor);

            var CmdList = mCLDB_Picked[0];

            mSV_PickedSetUp.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_Opaque);
            mSV_PickedSetUp.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_CustomOpaque);
            mSV_PickedSetUp.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_CustomTranslucent);
            mSV_PickedSetUp.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_Translucent);
            mSV_PickedSetUp.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_Gizmos);

            CmdList.BeginCommand();
            CmdList.BeginRenderPass(mRenderPassDesc_Picked, mSV_PickedSetUp.FrameBuffer);
            CmdList.BuildRenderPass(mDPLimitter);
            CmdList.EndRenderPass();

            mSV_PickedBlurH.CookViewportMeshToPassInMultiPassMode(mRHICtx, mSE_PickedBlurH, 0, mCamera, mScreenAlignedTriangle);
            mSV_PickedBlurH.PushPassToRHIInMultiPassMode(CmdList, 0);
            CmdList.BeginRenderPass(mRenderPassDesc_Picked, mSV_PickedBlurH.FrameBuffer);
            CmdList.BuildRenderPass();
            CmdList.EndRenderPass();

            mSV_PickedBlurV.CookViewportMeshToPass(mRHICtx, mSE_PickedBlurV, mCamera, mScreenAlignedTriangle);
            mSV_PickedBlurV.PushPassToRHI(CmdList);
            CmdList.BeginRenderPass(mRenderPassDesc_Picked, mSV_PickedBlurV.FrameBuffer);
            CmdList.BuildRenderPass();
            CmdList.EndRenderPass();
            CmdList.EndCommand();

            CmdList = mCLDB_DisableWarning[0];
            mSV_PickedBlurH.CookViewportMeshToPassInMultiPassMode(mRHICtx, mSE_PickedHollow, 1, mCamera, mScreenAlignedTriangle);
            mSV_PickedBlurH.PushPassToRHIInMultiPassMode(CmdList, 1);
            CmdList.BeginCommand();
            CmdList.BeginRenderPass(mRenderPassDesc_Picked, mSV_PickedBlurH.FrameBuffer);
            CmdList.BuildRenderPass();
            CmdList.EndRenderPass();
            CmdList.EndCommand();

            ScopeTickLogic.End();
        }
Esempio n. 2
0
        public void TickLogic()
        {
            if (mUpdateSelf == false || mEnabled == false)
            {
                return;
            }

            var RHICtx = EngineNS.CEngine.Instance.RenderContext;

            if (RHICtx == null || mHitProxyView == null)
            {
                return;
            }
            ScopeTickLogic.Begin();

            //int CurrDPNumber = 0;
            //CEngine.Instance.HitProxyManager.HitProxyIsNewest = false;

            //opaque render pass;
            mHitProxyView.CookSpecRenderLayerDataToPass(RHICtx, ERenderLayer.RL_Opaque, mCamera, mHitProxySE, PrebuildPassIndex.PPI_HitProxy);
            //custom opaque pass;
            mHitProxyView.CookSpecRenderLayerDataToPass(RHICtx, ERenderLayer.RL_CustomOpaque, mCamera, mHitProxySE, PrebuildPassIndex.PPI_HitProxy);
            //custom translucent render pass;
            mHitProxyView.CookSpecRenderLayerDataToPass(RHICtx, ERenderLayer.RL_CustomTranslucent, mCamera, mHitProxySE, PrebuildPassIndex.PPI_HitProxy);
            //translucent render pass;
            mHitProxyView.CookSpecRenderLayerDataToPass(RHICtx, ERenderLayer.RL_Translucent, mCamera, mHitProxySE, PrebuildPassIndex.PPI_HitProxy);
            //gizmos pass;the coordinary should be rendered in this pass;
            mHitProxyView.CookSpecRenderLayerDataToPass(RHICtx, ERenderLayer.RL_Gizmos, mCamera, mHitProxyAxisSE, PrebuildPassIndex.PPI_HitProxy);

            var CmdList = mCLDB_HitProxy[0];

            CmdList.BeginCommand();
            CmdList.BeginRenderPass(mRenderPassDesc_HitProxy, mHitProxyView.FrameBuffer);
            mHitProxyView.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_Opaque);
            mHitProxyView.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_CustomOpaque);
            mHitProxyView.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_CustomTranslucent);
            mHitProxyView.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_Translucent);
            mHitProxyView.PushSpecRenderLayerDataToRHI(CmdList, ERenderLayer.RL_Gizmos);
            CmdList.BuildRenderPass();
            CmdList.EndRenderPass();

            CmdList.CreateReadableTexture2D(ref HitProxyTex2D, mHitProxyView.FrameBuffer.GetSRV_RenderTarget(0), mHitProxyView.FrameBuffer);
            EngineNS.CEngine.Instance.GpuFetchManager.RegFetchTexture2D(HitProxyTex2D, (InSrv) =>
            {
                if (mHitProxyCPUTexture == null)
                {
                    mHitProxyCPUTexture = new CBlobObject();
                }
                if (CEngine.Instance.Desc.RHIType == ERHIType.RHT_OGL)
                {
                    var t1 = EngineNS.Support.Time.HighPrecision_GetTickCount();
                    unsafe
                    {
                        void *pData;
                        uint rowPitch;
                        uint depthPitch;
                        if (InSrv.Map(CEngine.Instance.RenderContext.ImmCommandList, 0, &pData, &rowPitch, &depthPitch))
                        {
                            lock (mHitProxyCPUTexture)
                            {
                                InSrv.BuildImageBlob(mHitProxyCPUTexture, pData, rowPitch);
                            }
                            InSrv.Unmap(CEngine.Instance.RenderContext.ImmCommandList, 0);
                        }
                        var t2 = EngineNS.Support.Time.HighPrecision_GetTickCount();
                        //System.Diagnostics.Debug.WriteLine($"Fetch hitproxy time : {t2 - t1}");
                    }
                }
                else
                {
                    CEngine.Instance.EventPoster.RunOn(() =>
                    {
                        var t1 = EngineNS.Support.Time.HighPrecision_GetTickCount();
                        unsafe
                        {
                            void *pData;
                            uint rowPitch;
                            uint depthPitch;
                            if (InSrv.Map(CEngine.Instance.RenderContext.ImmCommandList, 0, &pData, &rowPitch, &depthPitch))
                            {
                                lock (mHitProxyCPUTexture)
                                {
                                    InSrv.BuildImageBlob(mHitProxyCPUTexture, pData, rowPitch);
                                }
                                InSrv.Unmap(CEngine.Instance.RenderContext.ImmCommandList, 0);
                            }
                            var t2 = EngineNS.Support.Time.HighPrecision_GetTickCount();
                            //System.Diagnostics.Debug.WriteLine($"Fetch hitproxy time : {t2 - t1}");
                        }
                        return(null);
                    }, Thread.Async.EAsyncTarget.AsyncEditor);
                }
            });

            CmdList.EndCommand();

            ScopeTickLogic.End();
        }