This is often the issue in Virtual reality stories, and it’s one I don’t patrticularly care for. On the whole, I’m gladc that The Matrix mostly avboided it. Except for a few brief and well-circumscribed events (like the Training Program with the Woman in the Red Dress), you always knew if you were in Reality or a Virtual Reality.
But the point of the two VR movies that came out at the same time was the confusion between VR and Real Life (RL). David Cronenberg’s eXistenZ spends the whole film switching between different realities, as you try to figure out which one is Real.
I really liked The 13th Floor, which did a great job of the “Is it Live or is it VR?” theme. It’s based on what has been claijmed to be the first VR novel, Simulacron-3 by Daniel F. Galouye, which came out in 1964 (!).
The works of Philip K. Dick have been cited as cases of “Is this Reality?”, and Hollywood has made much more of this aspect than Dick himself did. The “Is it Reakl?” ending of Minority Report that needscoffee (and others) like is, for instance, wholly lacking in the original story. I, for one, don’t think Spielberg intended it in the film, either. In Total Recall, the “Am I in a Dream or Not?” theme that seems to be the core of the film isn’t at all the same as in the original story We Can Remember it for you Wholesale, where the point is that they implanted memories, not VVR experiences (although that would not have made for as exciting a film).
I didn’t particularly care for the rreality-shifting of Vanilla Sky. I think I may jusdt dislike ambiguos reality movies with Tom Cruise in them.
Then there are the movies with individuals whose minds seem to be slightly tipped, and who make their own rreality. Fight Club and Black Swan come to mind
And then there are the daydream/dream/imagination played out as reality, and then we’re yanked back to reality at the end. Ambrose Bierce’s An Occurrence at Owl Creek Bridge is the classic in this case. The recent episode of The Big Bang Theory that did this handled it extremely well, I thought. But the “It was Only a Dream” meme has been done to death in sitcoms, and has become a disliked cliche. Even ages ago, they played with the idea and had multiple levels of dreaming. I liked the riffs they played on this (at least twice) on the old Dick Van Dyke Show (especially the Kolak of Twilo episode).
Speaking of which, the whole “stories-within-stories-within-stories” meme is a pretty old one. as TVtropes says, it’s older than dirt. In the original Arabian Nights, there are places where the “stories-within-stories” goes at least seven levels deep. Douglas Hofstadter played with this (nefariously not emerging back up to the level of “reality”) in one of the “Fables of Achilles and the Tortoise” in his book Godel, Escher, Bach.