Ejemplo n.º 1
0
        /// <summary>
        /// Bind the provided slot to SV_Target0. Useful for dual-source blending
        /// </summary>
        internal void BindGBufferForWrite(MyGBuffer gbuffer, MyGbufferSlot slot, DepthStencilAccess depthStencilFlags = DepthStencilAccess.ReadWrite)
        {
            m_tmpBinds1[0] = gbuffer.Get(slot);
            BindDepthRTInternal(gbuffer.Get(MyGbufferSlot.DepthStencil), depthStencilFlags, m_tmpBinds1);

            Array.Clear(m_tmpBinds1, 0, m_tmpBinds1.Length);
        }
Ejemplo n.º 2
0
        internal void BindDepthRT(MyBindableResource depthStencil, DepthStencilAccess dsAccess, MyBindableResource RT)
        {
            m_tmpBinds1[0] = RT;

            BindDepthRTInternal(depthStencil, dsAccess, m_tmpBinds1);

            Array.Clear(m_tmpBinds1, 0, m_tmpBinds1.Length);
        }
Ejemplo n.º 3
0
        internal void BindGBufferForWrite(MyGBuffer gbuffer, DepthStencilAccess depthStencilFlags = DepthStencilAccess.ReadWrite)
        {
            m_tmpBinds3[0] = gbuffer.Get(MyGbufferSlot.GBuffer0);
            m_tmpBinds3[1] = gbuffer.Get(MyGbufferSlot.GBuffer1);
            m_tmpBinds3[2] = gbuffer.Get(MyGbufferSlot.GBuffer2);
            BindDepthRTInternal(gbuffer.Get(MyGbufferSlot.DepthStencil), depthStencilFlags, m_tmpBinds3);

            Array.Clear(m_tmpBinds3, 0, m_tmpBinds3.Length);
        }
Ejemplo n.º 4
0
        internal void BindDepthRT(MyBindableResource depthStencil, DepthStencilAccess dsAccess, MyBindableResource bindable0, MyBindableResource bindable1)
        {
            m_tmpBinds2[0] = bindable0;
            m_tmpBinds2[1] = bindable1;

            BindDepthRTInternal(depthStencil, dsAccess, m_tmpBinds2);

            Array.Clear(m_tmpBinds2, 0, m_tmpBinds2.Length);
        }
Ejemplo n.º 5
0
        internal void BindDepthRT(MyBindableResource depthStencil, DepthStencilAccess dsAccess, MyBindableResource bindable0, MyBindableResource bindable1, MyBindableResource bindable2)
        {
            m_tmpBinds3[0] = bindable0;
            m_tmpBinds3[1] = bindable1;
            m_tmpBinds3[2] = bindable2;

            BindDepthRTInternal(depthStencil, dsAccess, m_tmpBinds3);

            Array.Clear(m_tmpBinds3, 0, m_tmpBinds3.Length);
        }
Ejemplo n.º 6
0
        private void BindDepthRTInternal(MyBindableResource depthStencil, DepthStencilAccess dsAccess, params MyBindableResource[] RTs)
        {
            DepthStencilView dsv = null;

            if (depthStencil != null)
            {
                var ds = depthStencil as MyDepthStencil;
                Debug.Assert(ds != null);

                // check conflicts
                if (dsAccess == DepthStencilAccess.ReadWrite)
                {
                    // for both
                    // check reads
                    UnbindSRVRead(ds.Depth.GetID());
                    UnbindSRVRead(ds.Stencil.GetID());
                    dsv = ds.m_DSV;
                }
                else if (dsAccess == DepthStencilAccess.DepthReadOnly)
                {
                    // check reads
                    UnbindSRVRead(ds.Depth.GetID());
                    dsv = (ds.Depth as IDepthStencilBindable).DSV;
                }
                else if (dsAccess == DepthStencilAccess.StencilReadOnly)
                {
                    // check reads
                    UnbindSRVRead(ds.Stencil.GetID());
                    dsv = (ds.Stencil as IDepthStencilBindable).DSV;
                }
                else if (dsAccess == DepthStencilAccess.ReadOnly)
                {
                    dsv = ds.m_DSV_ro;
                }
            }
            Array.Clear(State.m_RTVs, 0, State.m_RTVs.Length);
            if (RTs != null)
            {
                for (int i = 0; i < RTs.Length; i++)
                {
                    if (RTs[i] != null)
                    {
                        Debug.Assert(RTs[i] as IRenderTargetBindable != null);
                        UnbindSRVRead(RTs[i].GetID());
                        State.m_RTVs[i] = (RTs[i] as IRenderTargetBindable).RTV;
                    }
                    else
                    {
                        State.m_RTVs[i] = null;
                    }
                }
            }
            DeviceContext.OutputMerger.SetTargets(
                dsv,
                State.m_RTVs);

            ClearDsvRtvWriteBindings();

            if (depthStencil != null)
            {
                var ds = depthStencil as MyDepthStencil;
                if (dsAccess == DepthStencilAccess.ReadWrite)
                {
                    var binding = new MyBinding(MyWriteBindingEnum.DSV);
                    State.m_bindings[ds.Depth.GetID()] = binding;
                    State.m_slotToBindingKeys.Add(binding.UavSlot, ds.Depth.GetID());
                    State.m_bindings[ds.Stencil.GetID()] = binding;
                    State.m_slotToBindingKeys.Add(binding.UavSlot, ds.Stencil.GetID());
                }
                else if (dsAccess == DepthStencilAccess.DepthReadOnly)
                {
                    var depthBinding = new MyBinding(true);
                    State.m_bindings[ds.Depth.GetID()] = depthBinding;
                    State.m_slotToBindingKeys.Add(depthBinding.UavSlot, ds.Depth.GetID());

                    var stencilBinding = new MyBinding(MyWriteBindingEnum.DSV);
                    State.m_bindings[ds.Stencil.GetID()] = stencilBinding;
                    State.m_slotToBindingKeys.Add(stencilBinding.UavSlot, ds.Stencil.GetID());
                }
                else if (dsAccess == DepthStencilAccess.StencilReadOnly)
                {
                    var depthBinding = new MyBinding(MyWriteBindingEnum.DSV);
                    State.m_bindings[ds.Depth.GetID()] = depthBinding;
                    State.m_slotToBindingKeys.Add(depthBinding.UavSlot, ds.Depth.GetID());

                    var stencilBinding = new MyBinding(true);
                    State.m_bindings[ds.Stencil.GetID()] = stencilBinding;
                    State.m_slotToBindingKeys.Add(stencilBinding.UavSlot, ds.Stencil.GetID());
                }
                else if (dsAccess == DepthStencilAccess.ReadOnly)
                {
                    var binding = new MyBinding(true);
                    State.m_bindings[ds.Depth.GetID()]   = binding;
                    State.m_bindings[ds.Stencil.GetID()] = binding;

                    State.m_slotToBindingKeys.Add(binding.UavSlot, ds.Depth.GetID());
                    State.m_slotToBindingKeys.Add(binding.UavSlot, ds.Stencil.GetID());
                }
            }
            if (RTs != null)
            {
                for (int i = 0; i < RTs.Length; i++)
                {
                    if (RTs[i] != null)
                    {
                        var binding = new MyBinding(MyWriteBindingEnum.RTV);
                        State.m_bindings[RTs[i].GetID()] = binding;
                        State.m_slotToBindingKeys.Add(binding.UavSlot, RTs[i].GetID());
                    }
                }
            }
        }
Ejemplo n.º 7
0
        internal void BindDepthRT(MyBindableResource depthStencil, DepthStencilAccess dsAccess, params MyBindableResource[] RTs)
        {
            DepthStencilView dsv = null;
            if (depthStencil != null)
            {
                var ds = depthStencil as MyDepthStencil;
                Debug.Assert(ds != null);

                // check conflicts
                if (dsAccess == DepthStencilAccess.ReadWrite)
                {
                    // for both
                    // check reads
                    UnbindSRVRead(ds.Depth.GetID());
                    UnbindSRVRead(ds.Stencil.GetID());
                    dsv = ds.m_DSV;
                }
                else if (dsAccess == DepthStencilAccess.DepthReadOnly)
                {
                    // check reads
                    UnbindSRVRead(ds.Depth.GetID());
                    dsv = (ds.Depth as IDepthStencilBindable).DSV;
                }
                else if (dsAccess == DepthStencilAccess.StencilReadOnly)
                {
                    // check reads
                    UnbindSRVRead(ds.Stencil.GetID());
                    dsv = (ds.Stencil as IDepthStencilBindable).DSV;
                }
                else if (dsAccess == DepthStencilAccess.ReadOnly)
                {
                    dsv = ds.m_DSV_ro;
                }
            }
            Array.Clear(State.m_RTVs, 0, State.m_RTVs.Length);
            if (RTs != null)
            {
                for (int i = 0; i < RTs.Length; i++)
                {
                    if (RTs[i] != null)
                    {
                        Debug.Assert(RTs[i] as IRenderTargetBindable != null);
                        UnbindSRVRead(RTs[i].GetID());
                        State.m_RTVs[i] = (RTs[i] as IRenderTargetBindable).RTV;
                    }
                    else
                    {
                        State.m_RTVs[i] = null;
                    }
                }
            }
            Context.OutputMerger.SetTargets(
                dsv,
                State.m_RTVs);

            ClearDsvRtvWriteBindings();

            if (depthStencil != null)
            {
                var ds = depthStencil as MyDepthStencil;
                if (dsAccess == DepthStencilAccess.ReadWrite)
                {
                    State.m_bindings[ds.Depth.GetID()] = new MyBinding(MyWriteBindingEnum.DSV);
                    State.m_bindings[ds.Stencil.GetID()] = new MyBinding(MyWriteBindingEnum.DSV);
                }
                else if (dsAccess == DepthStencilAccess.DepthReadOnly)
                {
                    State.m_bindings[ds.Depth.GetID()] = new MyBinding(true);
                    State.m_bindings[ds.Stencil.GetID()] = new MyBinding(MyWriteBindingEnum.DSV);
                }
                else if (dsAccess == DepthStencilAccess.StencilReadOnly)
                {
                    State.m_bindings[ds.Depth.GetID()] = new MyBinding(MyWriteBindingEnum.DSV);
                    State.m_bindings[ds.Stencil.GetID()] = new MyBinding(true);
                }
                else if (dsAccess == DepthStencilAccess.ReadOnly)
                {
                    State.m_bindings[ds.Depth.GetID()] = new MyBinding(true);
                    State.m_bindings[ds.Stencil.GetID()] = new MyBinding(true);
                }
            }
            if (RTs != null)
            {
                for (int i = 0; i < RTs.Length; i++)
                {
                    if (RTs[i] != null)
                    {
                        State.m_bindings[RTs[i].GetID()] = new MyBinding(MyWriteBindingEnum.RTV);
                    }
                }
            }
        }