mesa/genmipmap: Added a function to check if the target is valid