An investor can invest the gross amount of his gains in a Qualified Opportunity Fund (QOF) in any year (not the net amount). In your example, yes, the 2021 gains can be invested in a QOF, regardless of the availability of losses (even if they were 2021 losses and not just carried over losses from 2020).