At a very basic level you could just increase all framebuffer resolutions for a frame (or however long you need for the screenshot), but this may cause a handful of issues for resolutions higher than “standard” ones like 4k:
- Your device may not support framebuffers / textures at that high of a resolution
- You may run out of memory allocating such high-resolution framebuffers (a single 6400x6400 rgba8 texture is 156 MiB, now imagine a g-buffer with a bunch of channels…)
I can't speak to how other engines work, but the engine I work with takes high-res screenshots over multiple frames by pausing the game clock, switching to a supported, standard screen resolution (e.g. 1080p), and taking 1 screenshot per frame over multiple frames. Each frame the camera is shifted by a single pixel and then the resulting images are composited by interleaving the pixels to form the higher-res image. For example, to create a 4k screenshot we take 4 1080p screenshots and combine them like so:
Frame 1 Frame 2 Frame 3 Frame 4 Result
1 1 2 2 3 3 4 4 1 2 1 2
1 1 2 2 3 3 4 4 3 4 3 4
1 2 1 2
3 4 3 4
I'll admit that this is fairly complex and our renderer needs to account for this type of screenshot in a handful of places (temporal effects, etc. that could get confused) but it means we can take very high-res screenshots without needing to use higher-resolution framebuffers.