Beispiel #1
0
 private static void ResetStats()
 {
     foreach (var stats in m_passStats)
     {
         stats.Value.Clear();
     }
     m_passStatsTotals.Clear();
 }
        /// <param name="handleWindow">Handle function for window billboards: decides if
        /// keeping it in separate storage list</param>
        /// <returns>True if the transparent geometry bindings must be reset</returns>
        public static bool Gather()
        {
            m_stats.Clear();

            MyRender11.GetRenderProfiler().StartProfilingBlock("Gather");
            bool resetBindings = GatherInternal();

            MyRender11.GetRenderProfiler().EndProfilingBlock();
            return(resetBindings);
        }
Beispiel #3
0
        /// <param name="handleWindow">Handle function for window billboards: decides if
        /// keeping it in separate storage list</param>
        /// <returns>True if the transparent geometry bindings must be reset</returns>
        public static bool Gather(Func <MyBillboard, bool> handleWindow = null)
        {
            if (handleWindow == null)
            {
                handleWindow = DefaultWindowHanlder;
            }

            m_stats.Clear();

            MyRender11.GetRenderProfiler().StartProfilingBlock("Gather");
            bool resetBindings = GatherInternal(handleWindow);

            MyRender11.GetRenderProfiler().EndProfilingBlock();
            return(resetBindings);
        }
Beispiel #4
0
        internal virtual void Cleanup()
        {
            m_RC = null;
            if (Locals != null)
            {
                Locals.Clear();
            }
            Stats.Clear();
            m_joined = false;

            m_currentProfilingBlock_renderableType     = -1;
            m_currentProfilingBlock_renderableMaterial = string.Empty;

            m_isImmediate  = false;
            ViewProjection = default(Matrix);
            Viewport       = default(MyViewport);
            DebugName      = string.Empty;
            ProcessingMask = 0;
        }
 internal static void ResetStats()
 {
     MyImmediateRC.RC.Stats.Clear();
     m_rcStats.Clear();
     m_passStats.Clear();
 }
        internal unsafe static void Render(MyBindableResource dst, MyBindableResource depth, MyBindableResource depthRead)
        {
            m_stats.Clear();
            MyRender11.GetRenderProfiler().StartProfilingBlock("Gather");
            Gather();
            MyRender11.GetRenderProfiler().EndProfilingBlock();

            MyRender11.GetRenderProfiler().StartProfilingBlock("Draw");
            TransferData();

            RC.SetupScreenViewport();
            RC.BindDepthRT(depth, DepthStencilAccess.ReadOnly, dst);
            RC.SetBS(MyRender11.BlendAlphaPremult);
            RC.SetRS(MyRender11.m_nocullRasterizerState);
            RC.BindRawSRV(104, m_SB.Srv);
            RC.BindSRV(1, depthRead);
            RC.SetCB(2, MyCommon.GetObjectCB(sizeof(Matrix) * MaxCustomProjections));
            RC.SetDS(MyDepthStencilState.DefaultDepthState);

            RC.SetCB(4, MyRender11.DynamicShadows.ShadowCascades.CascadeConstantBuffer);
            RC.DeviceContext.VertexShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MyRender11.m_shadowmapSamplerState);
            RC.DeviceContext.VertexShader.SetShaderResource(MyCommon.CASCADES_SM_SLOT, MyRender11.DynamicShadows.ShadowCascades.CascadeShadowmapArray.ShaderView);
            RC.DeviceContext.VertexShader.SetSamplers(0, MyRender11.StandardSamplers);

            RC.DeviceContext.VertexShader.SetShaderResource(MyCommon.SKYBOX_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX2_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));

            RC.SetVB(0, m_VB.Buffer, m_VB.Stride);
            RC.SetIB(m_IB.Buffer, m_IB.Format);

            RC.SetIL(m_inputLayout);

            for (int i = 0; i < m_batches.Count; i++)
            {
                // first part of batches contain sorted billboards and they read depth
                // second part of batches contain unsorted billboards and they ignore depth
                // switch here:
                if (m_batches[i].Offset == m_sortedBillboardsNum)
                {
                    //RC.BindDepthRT(null, DepthStencilAccess.ReadOnly, dst);
                }

                if (m_batches[i].Lit)
                {
                    RC.SetVS(m_vsLit);

                    if (m_batches[i].AlphaCutout)
                    {
                        RC.SetPS(m_psAlphaCutoutAndLit);
                    }
                    else
                    {
                        RC.SetPS(m_psLit);
                    }
                }
                else
                if (m_batches[i].AlphaCutout)
                {
                    RC.SetVS(m_vs);
                    RC.SetPS(m_psAlphaCutout);
                }
                else
                {
                    RC.SetVS(m_vs);
                    RC.SetPS(m_ps);
                }

                RC.BindRawSRV(0, m_batches[i].Texture);
                RC.DeviceContext.DrawIndexed(m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                ++RC.Stats.BillboardDrawIndexed;
            }
            m_stats.Billboards += m_sorted + m_unsorted;

            RC.SetRS(null);
            RC.SetBS(null);
            m_batches.Clear();
            MyRender11.GatherStats(m_stats);
            MyRender11.GetRenderProfiler().EndProfilingBlock();
        }
Beispiel #7
0
 internal static void ResetStats()
 {
     MyRenderContext.Immediate.Stats.Clear();
     m_rcStats.Clear();
     m_passStats.Clear();
 }
 internal static void ResetStats()
 {
     m_passStats.Clear();
 }
        internal unsafe static void Render(MyBindableResource depthRead)
        {
            if (!MyRender11.DebugOverrides.BillboardsDynamic && !MyRender11.DebugOverrides.BillboardsStatic)
            {
                return;
            }

            m_stats.Clear();

            MyRender11.GetRenderProfiler().StartProfilingBlock("Gather");
            Gather();
            MyRender11.GetRenderProfiler().EndProfilingBlock();

            if (m_batches.Count == 0)
            {
                return;
            }

            MyRender11.GetRenderProfiler().StartProfilingBlock("Draw");
            TransferDataCustomProjections();
            TransferDataBillboards(BillboardCountSafe, ref m_arrayDataBillboards);

            RC.BindSRV(1, depthRead);
            BindResourcesCommon();

            for (int i = 0; i < m_batches.Count; i++)
            {
                // first part of batches contain sorted billboards and they read depth
                // second part of batches contain unsorted billboards and they ignore depth
                // switch here:
                if (m_batches[i].Offset == m_sortedCount)
                {
                    //RC.BindDepthRT(null, DepthStencilAccess.ReadOnly, dst);
                }

                if (m_batches[i].Lit)
                {
                    RC.SetVS(m_vsLit);

                    if (m_batches[i].AlphaCutout)
                    {
                        RC.SetPS(MyRender11.DebugOverrides.OIT ? m_psAlphaCutoutAndLitOIT : m_psAlphaCutoutAndLit);
                    }
                    else
                    {
                        RC.SetPS(MyRender11.DebugOverrides.OIT ? m_psLitOIT : m_psLit);
                    }
                }
                else if (m_batches[i].AlphaCutout)
                {
                    RC.SetVS(m_vs);
                    RC.SetPS(MyRender11.DebugOverrides.OIT ? m_psAlphaCutoutOIT : m_psAlphaCutout);
                }
                else
                {
                    RC.SetVS(m_vs);
                    RC.SetPS(MyRender11.DebugOverrides.OIT ? m_psOIT : m_ps);
                }

                RC.BindRawSRV(0, m_batches[i].Texture);
                if (!MyStereoRender.Enable)
                {
                    RC.DeviceContext.DrawIndexed(m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                }
                else
                {
                    MyStereoRender.DrawIndexedBillboards(RC, m_batches[i].Num * 6, m_batches[i].Offset * 6, 0);
                }
                ++RC.Stats.BillboardDrawIndexed;
            }

            m_stats.Billboards += BillboardCountSafe;

            RC.SetRS(null);
            MyRender11.GatherStats(m_stats);
            MyRender11.GetRenderProfiler().EndProfilingBlock();
        }