private static MyMapping MapRead(MyRenderContext rc, IResource resource, int bufferSize) { MyMapping mapping; mapping.m_rc = rc; mapping.m_resource = resource.Resource; mapping.m_bufferSize = bufferSize; mapping.m_dataBox = rc.MapSubresource(resource, 0, MapMode.Read, MapFlags.None); if (mapping.m_dataBox.IsEmpty) { throw new MyRenderException("Resource mapping failed!"); } mapping.m_dataPointer = mapping.m_dataBox.DataPointer; return(mapping); }
private static MyMapping MapDiscard(MyRenderContext rc, Resource buffer, int bufferSize) { MyMapping mapping; mapping.m_rc = rc; mapping.m_buffer = buffer; mapping.m_bufferSize = bufferSize; mapping.m_dataBox = rc.MapSubresource(buffer, 0, MapMode.WriteDiscard, MapFlags.None); if (mapping.m_dataBox.IsEmpty) { throw new MyRenderException("Resource mapping failed!"); } mapping.m_dataPointer = mapping.m_dataBox.DataPointer; return(mapping); }