eliemichel / LearnWebGPU-Code

The accompanying code of the Learn WebGPU C++ programming guide
https://eliemichel.github.io/LearnWebGPU
MIT License
106 stars 28 forks source link

maxTextureDimension of 2048 is not enough to go full screen on 3000x2000 resolution laptop #30

Closed dennisferron closed 10 months ago

dennisferron commented 10 months ago

I encountered this using the step095-emscripten branch configured for native build target, but I assume it affects most of the examples.

My Huawei laptop has a screen resolution of 3000x2000. When I try to go full screen with the application, it has an error. I put an #ifdef to change the requested limits to 4096, except for Emscripten build proper keep at 2048. (This does not prevent going fullscreen from the web version, nevertheless.)

Alternatively perhaps you could detect that the window is about to go above 2048 in a dimension and either pop an informative error message or limit the maximized side of the window.

#ifdef __EMSCRIPTEN__
    // Allow textures up to 2K
    requiredLimits.limits.maxTextureDimension1D = 2048;
    requiredLimits.limits.maxTextureDimension2D = 2048;
#else
    // (My laptop has horizontal resolution of 3000.)
    // Allow textures up to 4K
    requiredLimits.limits.maxTextureDimension1D = 4096;
    requiredLimits.limits.maxTextureDimension2D = 4096;
#endif
eliemichel commented 10 months ago

You could indeed use glfwGetMonitors and then glfwGetMonitorWorkarea when initializing WebGPU limits to set them to at least the size of your biggest monitor!

I'll add a note in the "Resizing the window" chapter