public IBorrowedDepthStencilTexture BorrowDepthStencil(string debugName, int width, int height, int samplesCount = 1, int samplesQuality = 0) { MyBorrowedTextureKey key = new MyBorrowedTextureKey { Width = width, Height = height, Format = Format.Unknown, SamplesCount = samplesCount, SamplesQuality = samplesQuality, }; if (!m_dictionaryDepthStencilTextures.ContainsKey(key)) { m_dictionaryDepthStencilTextures.Add(key, new List <MyBorrowedDepthStencilTexture>()); } foreach (var texIt in m_dictionaryDepthStencilTextures[key]) { if (!texIt.IsBorrowed) { texIt.SetBorrowed(debugName, m_currentFrameNum); return(texIt); } } MyBorrowedDepthStencilTexture createdTex = CreateDepthStencil(debugName, key); createdTex.SetBorrowed(debugName, m_currentFrameNum); return(createdTex); }
void DisposeTexture(MyBorrowedDepthStencilTexture depthStencil) { IDepthStencil customTexture = depthStencil.DepthStencilTexture; MyManagers.DepthStencils.DisposeTex(ref customTexture); MyBorrowedTextureKey key = depthStencil.Key; m_dictionaryDepthStencilTextures[key].Remove(depthStencil); m_objectPoolDepthStencil.Deallocate(depthStencil); }