I'm getting the same problem under Monterey 12.5 when using opengl - I have a benq pd3200u monitor and a AMD Radeon Pro W5700X 16 GB graphics card.
Runs fine for 5-6 minutes then the screen starts to turn on and off and I get errors like
2022-08-10 14:17:57.037419+0200 SST21C[1177:19159] [default] invalid display identifier 31EBB120-1E27-7718-4A29-2AEE86D9CEA2
2022-08-10 14:17:57.116883+0200 SST21C[1177:19159] [default] Invalid display 0x74605d04
2022-08-10 14:17:57.463807+0200 SST21C[1177:19159] [default] Invalid display 0x41dc9d00