When I use bumblebee optirun command to start a program , Google Chrome for example, my laptop indicates that it switched to nvidia GPU. My question is: Is then whole desktop rendered by nvidia or just the program I started with optirun ? I can't imagine that some parts of screen are rendered by one graphic card and other parts by another, but the way optirun command is used (in combination with specific program)makes me wonder.
optirun is an abstraction for VirtualGL. This runs a headless X screen with your Nvidia card and renders the application on that screen. The result is copied over to your visible screen. VGL also allows you to send the result over a network which is pretty cool.
Everything that isn't being
optirun'd is directly rendered through your Intel device. That includes the desktop (by default - I'm certain you could hack everything to be optirun if you really wanted - but I wouldn't recommend it).
I can't imagine that some parts of screen are rendered by one graphic card and other parts by another […]
That's exactly what happens, though. Bumblebee uses a second "display" (technically, it's an X server) to render programs started with
optirun, then displays the windows of that program on your primary (that is, the one you see) display.
The official Bumblebee FAQ provides a more technical explanation.