invalidate only if necessary
Another part that should have been done in the master branch instead of Optix