mesa: add _mesa_get_and_validate_attachment() helper