Long before Dick wrote on this subject,
https://ancillary-proxy.atarimworker.io?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2F...
Simulacron-3 (1964) (also published as Counterfeit World), by Daniel F. Galouye, is an American science fiction novel featuring an early literary description of a simulated reality
This was required reading for everyone connected with The Matrix. I read it when it came out.
There is an amusing history related to this novel. At the Artificial Life conference in 1986, Hans Moravec was talking to me between sessions, waving around a manuscript copy of Mind Children and rapping about the ever-falling cost of computation. I stopped him and said, "Hans do you realize how unlikely it is that this is the first time we have had this conversation?"
Hans looked totally blank, so I explained that eventually we could simulate the past and like the SCA or the Civil War enactors, we would do it over and over, making it most unlikely that this was the the first time for this conversation. Hans went away sandbagged by the idea and a few years later wrote "Pigs in Cyberspace" (a takeoff on the Muppet show). I think (without any proof) that that's where Nick Bostrom picked up the idea.
I intended the comment to Hans as a joke because there is no way to tell if you are in a simulation.