That looks useful for debugging, but how would you rewrite this code so that it doesn't cause the assert to fail?GraphicsDevice device; Texture* texture1 = device.CreateTexture(...); device.SetTexture(texture1); delete texture1; Texture* texture2 = device.CreateTexture(...); // device dereferences dangling pointer; crash
This is problematic. Best way to deal with this is to let GraphicsDevice to deallocate the texture (instead of leaving it to Texture). If deallocating currently bound texture, then just reset the texture pointer to NULL.
There's also the option of using one texture unit as a temporary unit for all those things like creating textures. This is less pretty, and leaves you with one unit less, but it'll help minimize the amount of rebinds.