internal void BindUAV(int slot, MyBindableResource UAV, int initialCount = -1) { if (UAV != null) { var ua = UAV as IUnorderedAccessBindable; Debug.Assert(ua != null); UnbindSRVRead(UAV.GetID()); //UnbindDSVReadOnly(UAVs[i].ResId); necessary? List <int> keyList = State.m_slotToBindingKeys.GetList(slot); if (keyList != null) { keyList.Sort(KeyListComparer.Comparer); State.m_bindings.Remove(keyList[0]); State.m_slotToBindingKeys.Remove(slot); } var binding = new MyBinding(MyWriteBindingEnum.UAV, slot); State.m_bindings[UAV.GetID()] = binding; State.m_slotToBindingKeys.Add(slot, UAV.GetID()); ComputeShaderId.TmpUav[0] = ua.UAV; } ComputeShaderId.TmpCount[0] = initialCount; DeviceContext.ComputeShader.SetUnorderedAccessViews(slot, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount); ComputeShaderId.TmpCount[0] = -1; MyRender11.ProcessDebugOutput(); }
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()); } } } }