UEFI+BIOS bootloader combination

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: UEFI+BIOS bootloader combination

Post by rdos »

Antti wrote: If you had a graphical program and a console program and you switch focus between them, I would not like the constant video mode switches. It surely has some overhead too.
Those only happen when the user manually switches between applications. Also, only the application that has focus will write to the physical video memory, other applications will only update an in-memory buffer, providing much better performance than in a windowed solution where everything is competing for the display.

Another advantage is for debugging. In a typical GUI environment, the debugger usually need special hacks in order to work as a separate application in the GUI. In my solution, the debugger runs in it's own console, and automatically switches focus when executing the debugged application, which means that GUI code can be single-stepped and tested realisticallly.
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: UEFI+BIOS bootloader combination

Post by Casm »

Brendan wrote:Basically; the third type of computer (the "UEFI only") will start out as "UEFI only with legacy hardware" but will gradually move towards "legacy free UEFI".
Except that by then what today counts as modern will itself be "legacy", and the bane of anybody who regards backward compatibility is a pain in the posterior. The x86 family itself is permanently rooted in the past. AMD wanted to get rid of segmentation, but it couldn't get rid of the GDT.
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: UEFI+BIOS bootloader combination

Post by rdos »

Casm wrote:
Brendan wrote:Basically; the third type of computer (the "UEFI only") will start out as "UEFI only with legacy hardware" but will gradually move towards "legacy free UEFI".
Except that by then what today counts as modern will itself be "legacy", and the bane of anybody who regards backward compatibility is a pain in the posterior. The x86 family itself is permanently rooted in the past. AMD wanted to get rid of segmentation, but it couldn't get rid of the GDT.
AMD did a real bad job in breaking segmentation in 64-bit mode for no good reason. But this is how things go when lousy software designs dictate hardware design.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: UEFI+BIOS bootloader combination

Post by Brendan »

Hi,
rdos wrote:
Antti wrote:If you had a graphical program and a console program and you switch focus between them, I would not like the constant video mode switches. It surely has some overhead too.
Those only happen when the user manually switches between applications.
Sure - you hold down "alt+tab" to determine if you suffer from photosensitive epilepsy or not.

I better idea is to have a little "app switcher" consisting of thumb-nails in the middle of the screen (super-imposed on top of whatever was already on the screen). When "alt+tab" is first pressed the app switcher is displayed; and while "alt" is being held down each "tab" (including repeated tabs) just highlight the next thumbnail in the app switcher. When "alt" is released the app switcher disappears and the OS switches to the application whose thumbnail was highlighted/selected.

To make it stand out you'd make whatever was previously on the screen (whatever will be behind the app switcher) slightly less bright, and you'd want to display the name of the currently selected application in the app switcher, and when there's more than about 10 applications running you'd want to (smoothly) scroll through the list (rather than trying to jam too many thumbnails on the screen at once).

Of course acquiring the thumbnails is simple - whenever the app switcher is started, you'd take a copy of the current application's graphics, scale it down and insert it into your list of thumbnails. That way an application's thumbnail will represent what the application looked like when the user saw it last (which may be different to how the application currently looks), which makes it easier for the user to recognise what they're looking for. Displaying the application's icon as its thumbnail doesn't work (e.g. displaying 10 identical "web browser" icons isn't going to help the user figure out which thumbnail represents the web browser they want); although it would make sense to include the application's icon in the thumbnail (e.g. a small version of the application's icon in the bottom right corner of the thumbnail).
rdos wrote:Also, only the application that has focus will write to the physical video memory, other applications will only update an in-memory buffer, providing much better performance than in a windowed solution where everything is competing for the display.
That's excessively poor design. Applications should create a list of commands describing what to draw, and shouldn't draw anything themselves or have access to display memory. That way:
  • the OS can avoid wasting CPU time drawing graphics for applications that can't be seen; including:
    • badly written applications that keep generating their graphics even when they're running in the background
    • doing clipping for "partially obscured" windows on the list of commands, instead of drawing unnecessary graphics and then clipping
    • respecting the monitor's refresh rate (e.g. if the application is sending 500 frames per second but the monitor only displays 60 frames per second, then only actually draw 60 frames per second and discard/ignore the other 440 frames the application is sending
  • it avoids the need for graphics drawing code for every possible colour depth/pixel format to exist in every single application; including things like font data caches (e.g. when multiple applications are using "size 9 mono-spaced font" and you can cache each letter/character separately, it's better to have one cache rather than multiple duplicate caches)
  • it allows potential future native video drivers to support hardware acceleration (without any changes to any existing applications)
  • it allows applications to be resolution and colour depth/pixel format independent; including:
    • allowing application/s to be displayed across 2 or more monitors running in different video modes
    • allowing application/s to be displayed in windows (e.g. GUI) where the application's window can be minimised/maximised and moved without the application itself knowing/caring (or even knowing if it's running full screen or in a window).
  • it provides device independence; which means that:
    • the exact same "list of commands describing what to draw" that was used to create the current screen of graphics can be sent to something like a printer without the application knowing/caring (where the printer would draw the "list of commands" in a different resolution and maybe using CMYK instead of RGB).
    • it makes it easy to support remote applications (e.g. by sending the "list of commands describing what to draw" across the network for a different computer to draw)
    • you can append the "list of commands" to a file, and then convert the final "file containing many lists of commands" into MPEG format or something
    • for all of this, you could do extremely expensive "photo-realistic ray tracing" in the background to get exceptionally high quality images that wouldn't have been possible with real-time rendering.
rdos wrote:Another advantage is for debugging. In a typical GUI environment, the debugger usually need special hacks in order to work as a separate application in the GUI. In my solution, the debugger runs in it's own console, and automatically switches focus when executing the debugged application, which means that GUI code can be single-stepped and tested realisticallly.
That's lame. Make it so that the application or GUI being debugged sends its "list of commands describing what to draw" to the debugger. The debugger could scale the application/GUI's "list of commands" and insert the (scaled) commands into its own "list of commands"; so that you end up a small box in the top right of the debugger's screen showing the output of the application/GUI being debugged. Of course the debugger could do much more - e.g. while the application/GUI being debugged is "stopped" (not running), the debugger could allow you to zoom in on a specific area of the application/GUI's graphics, or show it as "almost full screen", or convert the application/GUI's "list of commands" into plain text and display that instead. You'd even be able to use one debugger to debug another debugger; or have an application inside a debugger inside a GUI inside a debugger.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: UEFI+BIOS bootloader combination

Post by rdos »

Brendan wrote:
rdos wrote: Those only happen when the user manually switches between applications.
Sure - you hold down "alt+tab" to determine if you suffer from photosensitive epilepsy or not.
Not, as that is a real bad design. "ctl" + Function key will switch directly to an app. ctr-F1 is the first app, ctr-F2 the second. ctl-F8 always is the kernel debugger. That means you can directly switch to up to 11 applications + the kernel debugger. That is enough in any practical situation.
Brendan wrote: I better idea is to have a little "app switcher" consisting of thumb-nails in the middle of the screen (super-imposed on top of whatever was already on the screen). When "alt+tab" is first pressed the app switcher is displayed; and while "alt" is being held down each "tab" (including repeated tabs) just highlight the next thumbnail in the app switcher. When "alt" is released the app switcher disappears and the OS switches to the application whose thumbnail was highlighted/selected.
Yes, and then when your little app switcher dies for whatever reason, you are out of luck because your system is locked-up. In addition to that, it potentially requires many more video-mode switches. For instance, when switching between the command line (text mode) and the kernel debugger (text mode), you will first switch to graphics mode and then back to text mode when you don't need any mode switches at all.
Brendan wrote: To make it stand out you'd make whatever was previously on the screen (whatever will be behind the app switcher) slightly less bright, and you'd want to display the name of the currently selected application in the app switcher, and when there's more than about 10 applications running you'd want to (smoothly) scroll through the list (rather than trying to jam too many thumbnails on the screen at once).
That would be a nice idea when many applications are running. The idea have occurred to me (using alt-tab or something), but I haven't implemented yet.
Brendan wrote:
rdos wrote:Also, only the application that has focus will write to the physical video memory, other applications will only update an in-memory buffer, providing much better performance than in a windowed solution where everything is competing for the display.
That's excessively poor design. Applications should create a list of commands describing what to draw, and shouldn't draw anything themselves or have access to display memory.
I disagree. While they currently don't have direct access to display-memory, but rather call kernel to draw, I will change this design in 64-bit mode and implement the graphics API in the user library directly using LFB. That would provide superior performance when not using native drivers.
Brendan wrote: badly written applications that keep generating their graphics even when they're running in the background
So a compiler running in the background should not output errors to screen? A performance monitor should stop generating it's performance charts in the background?
Brendan wrote: it allows potential future native video drivers to support hardware acceleration (without any changes to any existing applications)
The current solution allows it, but the 64-bit will not (unless it can alter between user-library and calling kernel)
Brendan wrote: it allows applications to be resolution and colour depth/pixel format independent; including:
  • allowing application/s to be displayed across 2 or more monitors running in different video modes
Same thing. Today the graphics API is implemented in kernel space, and the application doesn't deal directly with LFB. But it might do in 64-bit to reduce syscall overhead, which today is a major problem with the graphics API.

Besides, I would never implement the graphics API as command lists. It's extremely slow and wasteful. If some particular accelerator requires that, it can build them itself from the API.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: UEFI+BIOS bootloader combination

Post by Brendan »

Hi,
rdos wrote:
Brendan wrote:
rdos wrote:Those only happen when the user manually switches between applications.
Sure - you hold down "alt+tab" to determine if you suffer from photosensitive epilepsy or not.
Not, as that is a real bad design. "ctl" + Function key will switch directly to an app. ctr-F1 is the first app, ctr-F2 the second. ctl-F8 always is the kernel debugger. That means you can directly switch to up to 11 applications + the kernel debugger. That is enough in any practical situation.
As long as "any practical situation" doesn't include having more than 11 applications (!).

rdos wrote:
Brendan wrote:I better idea is to have a little "app switcher" consisting of thumb-nails in the middle of the screen (super-imposed on top of whatever was already on the screen). When "alt+tab" is first pressed the app switcher is displayed; and while "alt" is being held down each "tab" (including repeated tabs) just highlight the next thumbnail in the app switcher. When "alt" is released the app switcher disappears and the OS switches to the application whose thumbnail was highlighted/selected.
Yes, and then when your little app switcher dies for whatever reason, you are out of luck because your system is locked-up.
I find that it's usually a good idea to at least try to avoid bugs.
rdos wrote:In addition to that, it potentially requires many more video-mode switches. For instance, when switching between the command line (text mode) and the kernel debugger (text mode), you will first switch to graphics mode and then back to text mode when you don't need any mode switches at all.
Um, what? Obviously you wouldn't want to bother with text mode, and therefore you wouldn't have any video mode switches at all.
rdos wrote:
Brendan wrote:To make it stand out you'd make whatever was previously on the screen (whatever will be behind the app switcher) slightly less bright, and you'd want to display the name of the currently selected application in the app switcher, and when there's more than about 10 applications running you'd want to (smoothly) scroll through the list (rather than trying to jam too many thumbnails on the screen at once).
That would be a nice idea when many applications are running. The idea have occurred to me (using alt-tab or something), but I haven't implemented yet.
To be honest, it's not my idea - Windows does most of what I described (complete with the application's icon in the bottom right of the thumbnail). The only difference is that Window's "app switcher" doesn't scroll (you get multiple rows of thumbnails if there's too many for one row, rather than one scrolling row).
rdos wrote:
Brendan wrote:That's excessively poor design. Applications should create a list of commands describing what to draw, and shouldn't draw anything themselves or have access to display memory.
I disagree. While they currently don't have direct access to display-memory, but rather call kernel to draw, I will change this design in 64-bit mode and implement the graphics API in the user library directly using LFB. That would provide superior performance when not using native drivers.
You mean you're just going to make it worse?
rdos wrote:
Brendan wrote:badly written applications that keep generating their graphics even when they're running in the background
So a compiler running in the background should not output errors to screen? A performance monitor should stop generating it's performance charts in the background?
Um, what? Obviously the compiler would continue running and the performance monitor would continue collecting data - you just wouldn't bother wasting CPU time to generate video data that will never be seen. If/when the performance monitor actually becomes visible, then you spend CPU time drawing the previous "list of commands" that it sent (not before).
rdos wrote:
Brendan wrote:it allows potential future native video drivers to support hardware acceleration (without any changes to any existing applications)
The current solution allows it, but the 64-bit will not (unless it can alter between user-library and calling kernel)
I'd do the reverse (e.g. make things better instead of making things worse).
rdos wrote:
Brendan wrote:it allows applications to be resolution and colour depth/pixel format independent; including:
  • allowing application/s to be displayed across 2 or more monitors running in different video modes
Same thing. Today the graphics API is implemented in kernel space, and the application doesn't deal directly with LFB. But it might do in 64-bit to reduce syscall overhead, which today is a major problem with the graphics API.

Besides, I would never implement the graphics API as command lists. It's extremely slow and wasteful. If some particular accelerator requires that, it can build them itself from the API.
It's faster (especially when you take into account scaling/transformations and avoiding wasting time on things that can't be seen). It's also a lot more efficient because everything between the application and the video driver only needs to work on (small) "commands" rather than (huge) arrays of pixels. In addition, it's also extremely flexible. Basically, it's superior to "retarded LFB access mess" in every possible way.

If I were writing an application and had to deal with "retarded LFB access mess", I'd start by implementing a "main rendering thread" (with none or more "worker rendering threads") that does all the rendering/drawing and send some sort of description of what to draw to that "main rendering thread"; partly so that the application's code isn't polluted with device specific puke, partly so I can improve the rendering/drawing code without touching the rest of the application's code, and partly because it's "low hanging fruit" when you're trying to make use of multiple CPUs.

Also note that there's no reason you can't have a graphics API (e.g. implemented as a library or something) where most of the functions just add commands to a list, and where the list of commands is sent to the video driver (or GUI or whatever) when the "glFlush()" function is called.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: UEFI+BIOS bootloader combination

Post by rdos »

Brendan wrote:
rdos wrote: Yes, and then when your little app switcher dies for whatever reason, you are out of luck because your system is locked-up.
I find that it's usually a good idea to at least try to avoid bugs.
An example: You are checking some new video-card which happens to work in text-mode but not in graphics mode. Ok, so you launch your graphics test application, and it dies, then you switch to your little app switcher and it dies, and you never are able to figure out what is wrong because your system is locked-up. In fact, your setup will fail even when you only run text-mode applications because as soon as you want to switch your system dies as your little switcher changes to graphics mode. And this in not unusual. I have several computers were I'm unable to use graphics mode for various reasons.
Brendan wrote:Um, what? Obviously you wouldn't want to bother with text mode, and therefore you wouldn't have any video mode switches at all.
And some systems that would not run at all.
Brendan wrote:
rdos wrote: I disagree. While they currently don't have direct access to display-memory, but rather call kernel to draw, I will change this design in 64-bit mode and implement the graphics API in the user library directly using LFB. That would provide superior performance when not using native drivers.
You mean you're just going to make it worse?
How is that making anything worse? The API will remain the same, but when the class library for RDOS detects that the kernel will be using LFB to implement the graphics API through syscalls to kernel-space, it would decide it is better to move those functions to user-space to avoid the syscall overhead. The class library would have a copy of the LFB interface for some popular formats, and use it directly with no overhead. That's about 50-100k in kernel space, and hardly much more in 64-bit user-space.
Brendan wrote:
rdos wrote: So a compiler running in the background should not output errors to screen? A performance monitor should stop generating it's performance charts in the background?
Um, what? Obviously the compiler would continue running and the performance monitor would continue collecting data - you just wouldn't bother wasting CPU time to generate video data that will never be seen. If/when the performance monitor actually becomes visible, then you spend CPU time drawing the previous "list of commands" that it sent (not before).
I decided against using the GUI drawing technique used in for instance Windows where the system will use messages in order to redraw content. My graphics API instead works on a memory-buffer, and when it has focus, also copies the content to the display. This double-buffering technique is not uncommon. What the switcher does is that it copies the entire buffer to video memory when the new application gets focus. The application doesn't need to know if it has focus or not, but can of course check if it likes to.

And if you just postpone huge amount of commands, it would mean that it would take almost forever until your new focused application went through all those, most of which would be overwritten again multiple times. Your system would look as lousy as Windows or worse. Windows at least have sense enough to use VM_PAINT messages to the application when it wants it to redraw itself.
Brendan wrote:
rdos wrote:
Brendan wrote:it allows applications to be resolution and colour depth/pixel format independent; including:
  • allowing application/s to be displayed across 2 or more monitors running in different video modes
Same thing. Today the graphics API is implemented in kernel space, and the application doesn't deal directly with LFB. But it might do in 64-bit to reduce syscall overhead, which today is a major problem with the graphics API.

Besides, I would never implement the graphics API as command lists. It's extremely slow and wasteful. If some particular accelerator requires that, it can build them itself from the API.
It's faster (especially when you take into account scaling/transformations and avoiding wasting time on things that can't be seen). It's also a lot more efficient because everything between the application and the video driver only needs to work on (small) "commands" rather than (huge) arrays of pixels. In addition, it's also extremely flexible. Basically, it's superior to "retarded LFB access mess" in every possible way.
So if I blit pixels from a huge png-file you mean you can do that with a small command and no pixels? Because blit is the only operating that uses pixels. And scalings, clipping and transformations need to be performed regardless if LFB is used directly or though command lists.
Brendan wrote:If I were writing an application and had to deal with "retarded LFB access mess", I'd start by implementing a "main rendering thread" (with none or more "worker rendering threads") that does all the rendering/drawing and send some sort of description of what to draw to that "main rendering thread"; partly so that the application's code isn't polluted with device specific puke, partly so I can improve the rendering/drawing code without touching the rest of the application's code, and partly because it's "low hanging fruit" when you're trying to make use of multiple CPUs.
The application doesn't deal directly with LFB. This code is either in kernel (slow), or in a library linked to the application (fast).
Brendan wrote:Also note that there's no reason you can't have a graphics API (e.g. implemented as a library or something) where most of the functions just add commands to a list, and where the list of commands is sent to the video driver (or GUI or whatever) when the "glFlush()" function is called.
There is one huge reason not to do that. Using commands means allocating memory, and if you also buffer them, it means you can and will run out of physical memory if something stops working. Allocating memory is extremely slow. Both allocating memory in user-space, and then using syscalls to kernel space is about the slowest solution there is.

Another huge disadvantage of your approach is that allocating memory is not guaranteed to work, which means that all the GUI functions must have an extra error code for "out-of-memory". And most GUI functions needs no error code return at all.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: UEFI+BIOS bootloader combination

Post by Antti »

If we had ten back buffers (e.g. ten programs running) and we used 4 bytes for each pixel, the memory needed would be quite big:

Code: Select all

HugeNumber = 10 * 4 * 1920 * 1080;
If we look at a "normal application", the screen content is not usually very complicate. It does not require much memory (when compared to back buffers) to store information like:

Code: Select all

DrawLine
DrawLine
DrawBox
DrawBox
DrawText
...
...
I tried to create a "video driver draws everything" model but I did not fully succeeded yet. I got stuck wondering what would be a good "virtual resolution" range. What would it be? For example, if I wanted to draw a line that goes from the upper-left corner to the lower-right corner. Would it be (for example):

Code: Select all

DrawLine(0, 0, 799, 599);        /* 800 x 600 */

DrawLine(0, 0, 0xFFFF, 0xFFFF);  /* 65536 x 65536 */

DrawLine(-1.0, -1.0, 1.0, 1.0);  /* Floating point */
Now that the discussion is very hot, this offtopic might be lost. Perhaps it will be worth another topic somewhere in the future.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: UEFI+BIOS bootloader combination

Post by dozniak »

Antti wrote:stuck wondering what would be a good "virtual resolution" range.
Perhaps

Code: Select all

SetViewport(0, 0, 800, 600);

or

SetViewport(-1.0, -1.0, 1.0, 1.0);

or

SetViewport(-512, -1024, 512, 1024); // depending on what resolution you actually need
Learn to read.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: UEFI+BIOS bootloader combination

Post by Antti »

@dozniak: Thank you. All the viewport things look familiar. I did some OpenGL/Direct3D experiments when I started programming. However, I did not understand everything back then. This topic must be well thought out already and I have to study it more.
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: UEFI+BIOS bootloader combination

Post by rdos »

Antti wrote:If we had ten back buffers (e.g. ten programs running) and we used 4 bytes for each pixel, the memory needed would be quite big:

Code: Select all

HugeNumber = 10 * 4 * 1920 * 1080;
Yes, but that assumes they run in the highest resolution video mode. In a model were video-mode is switched, a text-mode application would need a buffer of a few kbs, while a application using something like 800 x 600 would use much less than the highest resolution as well. In an UEFI-solution, the OS can either waste a lot of memory on text-mode applications and store the screen in highest resolution, or do the text-to-graphics conversion as it switches focus and prints characters. But for graphics mode, there is no way out of needing the full buffer though. The application is even forced to use the highest resolution even if it would work much better in a lower resolution.
Antti wrote: If we look at a "normal application", the screen content is not usually very complicate. It does not require much memory (when compared to back buffers) to store information like:

Code: Select all

DrawLine
DrawLine
DrawBox
DrawBox
DrawText
...
...
The complexity comes when the application overwrites it's own display with slightly different information. Maybe it updates time, or switches the load curve in case of a load presenter.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: UEFI+BIOS bootloader combination

Post by Brendan »

Hi,
rdos wrote:
Brendan wrote:
rdos wrote: Yes, and then when your little app switcher dies for whatever reason, you are out of luck because your system is locked-up.
I find that it's usually a good idea to at least try to avoid bugs.
An example: You are checking some new video-card which happens to work in text-mode but not in graphics mode. Ok, so you launch your graphics test application, and it dies, then you switch to your little app switcher and it dies, and you never are able to figure out what is wrong because your system is locked-up. In fact, your setup will fail even when you only run text-mode applications because as soon as you want to switch your system dies as your little switcher changes to graphics mode. And this in not unusual. I have several computers were I'm unable to use graphics mode for various reasons.
You may have several computers where you are unable to use graphics mode for various reasons; but nobody else has any computers where everyone else can't use graphics mode/s. I suggest the problem may not be related to hardware or firmware.

More specifically, I'd suggest that your problems are either caused by bugs in your virtual8086 support, or caused by a failure to provide adequate device independence (e.g. an application that is "hard coded" for a specific video mode that fails when that specific video mode isn't available); and in both cases a sane design wouldn't have had any problems to begin with.
rdos wrote:
Brendan wrote:Um, what? Obviously you wouldn't want to bother with text mode, and therefore you wouldn't have any video mode switches at all.
And some systems that would not run at all.
Because your code is bad, or because you think it's impossible to setup any graphics mode during boot on some systems?
rdos wrote:
Brendan wrote:
rdos wrote: I disagree. While they currently don't have direct access to display-memory, but rather call kernel to draw, I will change this design in 64-bit mode and implement the graphics API in the user library directly using LFB. That would provide superior performance when not using native drivers.
You mean you're just going to make it worse?
How is that making anything worse? The API will remain the same, but when the class library for RDOS detects that the kernel will be using LFB to implement the graphics API through syscalls to kernel-space, it would decide it is better to move those functions to user-space to avoid the syscall overhead. The class library would have a copy of the LFB interface for some popular formats, and use it directly with no overhead. That's about 50-100k in kernel space, and hardly much more in 64-bit user-space.
Go back to the list of advantages I posted earlier, and see how many of those things your LFB mess can do better.
rdos wrote:
Brendan wrote:
rdos wrote: So a compiler running in the background should not output errors to screen? A performance monitor should stop generating it's performance charts in the background?
Um, what? Obviously the compiler would continue running and the performance monitor would continue collecting data - you just wouldn't bother wasting CPU time to generate video data that will never be seen. If/when the performance monitor actually becomes visible, then you spend CPU time drawing the previous "list of commands" that it sent (not before).
I decided against using the GUI drawing technique used in for instance Windows where the system will use messages in order to redraw content. My graphics API instead works on a memory-buffer, and when it has focus, also copies the content to the display. This double-buffering technique is not uncommon. What the switcher does is that it copies the entire buffer to video memory when the new application gets focus. The application doesn't need to know if it has focus or not, but can of course check if it likes to.
Your stupid applications (e.g. the ones that don't bother to check if they're visible) waste massive amounts of CPU time constantly drawing things in their memory buffers; and the OS itself is unable to do anything to prevent such a massive waste of CPU time.

My stupid applications (e.g. the ones that don't bother to check if they're visible) waste a small amount of CPU time generating lists of commands; but the OS is able to prevent all of the expensive "drawing" work (that typically involves pounding millions of bytes of data into pretty pictures), including avoiding drawing things that are obscured by other windows and/or past an edge of the screen when the application actually is visible.
rdos wrote:And if you just postpone huge amount of commands, it would mean that it would take almost forever until your new focused application went through all those, most of which would be overwritten again multiple times. Your system would look as lousy as Windows or worse. Windows at least have sense enough to use VM_PAINT messages to the application when it wants it to redraw itself.
You only keep the most recent list of commands, not every list of commands that the application created since the dawn of time. The problem with WM_PAINT is that there's no guarantee that the application won't be busy doing other things at the time, and no guarantee that you'll be able to redraw the screen quickly.
rdos wrote:
Brendan wrote:
rdos wrote:Besides, I would never implement the graphics API as command lists. It's extremely slow and wasteful. If some particular accelerator requires that, it can build them itself from the API.
It's faster (especially when you take into account scaling/transformations and avoiding wasting time on things that can't be seen). It's also a lot more efficient because everything between the application and the video driver only needs to work on (small) "commands" rather than (huge) arrays of pixels. In addition, it's also extremely flexible. Basically, it's superior to "retarded LFB access mess" in every possible way.
So if I blit pixels from a huge png-file you mean you can do that with a small command and no pixels?
The normal approach is to pre-load the huge PNG file into a texture with one command, and once it's loaded into a texture you can display it with a single command as many times as you like. For the pre-loading, I'd tell the video driver which file name and let the video driver load the file itself. Sadly other systems (e.g. OpenGL) don't work like that and the application would have to load the file and then transfer the data (which is extra work).

Of course for most things (e.g. icons, menus, fonts, etc) you'd want to use scalable/vector graphics rather than pixel data.
rdos wrote:Because blit is the only operating that uses pixels. And scalings, clipping and transformations need to be performed regardless if LFB is used directly or though command lists.
Here's a very simple multiple choice question. It's faster to:
  • a) set thousands of pixels in a rectangle to "blue", then scale all those pixels, then rotate all those pixels 90 degrees, then blit the final result; or
    b) describe the blue rectangle with "(x1, y1) (x2, y2) colour", scale and rotate the description at the same time (multiply co-ords by a matrix), then draw the final result
Hint: The correct answer is not "a)".

Of course the same applies to more complex things (like windows containing characters/text, icons, menus, etc).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: UEFI+BIOS bootloader combination

Post by Owen »

Antti wrote:If we had ten back buffers (e.g. ten programs running) and we used 4 bytes for each pixel, the memory needed would be quite big:

Code: Select all

HugeNumber = 10 * 4 * 1920 * 1080;
83MB. How many apps do you run on the average system? Even assuming that you're running an obsolete system with only 2GB of RAM, that's only 3%. If they're all double buffered, 6%

What do you care more about, saving minute proportions of RAM, or performance? What do you think is going to deliver better performance, encoding the commands into a buffer, piping that to a server, then executing them there, or invoking functions which can directly insert operations into buffers ready to be handed off to the GPU (yes, this is how every graphics driver has worked for over a decade)

The overriding rules in any GUI system should be
  1. Every frame is perfect, no tears
  2. Frames should never be dropped
  3. Latency should be the minimum possible
  4. Resource usage should be minimized
It will probably be no surprise to hear that these are the same rules employed by iOS, OS X, Android, Wayland and pretty much every other modern graphics system, and not for no reason: It's been shown time and time again that people care about them. Whats the biggest ongoing complaint about Android? Dropped frames and stutter (tearing was eliminated in 4.1 by forcing vsync)
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: UEFI+BIOS bootloader combination

Post by rdos »

Brendan wrote: You may have several computers where you are unable to use graphics mode for various reasons; but nobody else has any computers where everyone else can't use graphics mode/s. I suggest the problem may not be related to hardware or firmware.

More specifically, I'd suggest that your problems are either caused by bugs in your virtual8086 support, or caused by a failure to provide adequate device independence (e.g. an application that is "hard coded" for a specific video mode that fails when that specific video mode isn't available); and in both cases a sane design wouldn't have had any problems to begin with.
That's correct. Most of them are related to VBE. However, on UEFI, they might just as well be related to the graphics system not being able to draw pixels because of unknown video mode organizations. With VBE, you can filter out unwanted video-modes in the driver based on what the driver knows about. This is not the case for UEFI, which potentially could require a native video-driver, but since the boot loader doesn't (and shouldn't) know which driver support is available, it would have to setup some mode and hope it could be used.
Brendan wrote: Because your code is bad, or because you think it's impossible to setup any graphics mode during boot on some systems?
I don't think it is impossible, rather unwanted and a bad practice.
Brendan wrote: Um, what? Obviously the compiler would continue running and the performance monitor would continue collecting data - you just wouldn't bother wasting CPU time to generate video data that will never be seen. If/when the performance monitor actually becomes visible, then you spend CPU time drawing the previous "list of commands" that it sent (not before).
The previous list of commands was 10,000,000 lines of text that were generated during 12 hours, and all but the last 25 lines have been scrolled-off the display. Your switcher will spend minutes or hours in scrolling text that the user cannot read and ending up with 25 lines of visible text. How user-friendly and effective is that?
Brendan wrote: You only keep the most recent list of commands, not every list of commands that the application created since the dawn of time.
Not possible
Example:

Code: Select all

  DrawText(0, 0, "my app")
  DrawText(10, 0, "2013-07-27 09.00.00")
  DrawText(10, 0, "2013-07-27 09.00.01")
  DrawText(10, 0, "2013-07-27 09.00.02")
  DrawText(10, 0, "2013-07-27 09.00.03")
  DrawText(10, 0, "2013-07-27 09.00.04")
  DrawText(10, 0, "2013-07-27 09.00.05")
 ...
Your code determines (after some time) that DrawText("my app") is no longer recent, so throws it away and now you only see the clock, not the name of the app.
Brendan wrote: The normal approach is to pre-load the huge PNG file into a texture with one command, and once it's loaded into a texture you can display it with a single command as many times as you like. For the pre-loading, I'd tell the video driver which file name and let the video driver load the file itself. Sadly other systems (e.g. OpenGL) don't work like that and the application would have to load the file and then transfer the data (which is extra work).
My PNG-loader creates a memory-based bitmap which is then blitted to the display. Bitmaps are referred to with handles and thus doesn't send pixel data when referred to. The physical display is also a bitmap, as is a printout on a printer. All graphics primitives operates on bitmaps and gives the application an uniform interface independent of type of bitmap (memory, display, printer) and memory organization.
Brendan wrote: Of course for most things (e.g. icons, menus, fonts, etc) you'd want to use scalable/vector graphics rather than pixel data.
You don't want to have icons or menus in you graphics API at all. These are things that should be constructed at a higher level when needed only. For fonts, you want to have a TrueType font renderer or similar.
Brendan wrote: Here's a very simple multiple choice question. It's faster to:
  • a) set thousands of pixels in a rectangle to "blue", then scale all those pixels, then rotate all those pixels 90 degrees, then blit the final result; or
    b) describe the blue rectangle with "(x1, y1) (x2, y2) colour", scale and rotate the description at the same time (multiply co-ords by a matrix), then draw the final result
Hint: The correct answer is not "a)".
What does poor programming skills have to do with performance of a GUI?

Naturally all coordinate scaling is done before working on pixels. This is independent of working with commands or directly with LFB. Or do you think that the user program needs to use "plot" in order to fill a rectangle with blue? There are both ellipse and rectangle (filled and non-filled styles) primitives available.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: UEFI+BIOS bootloader combination

Post by Antti »

Owen wrote:What do you care more about, saving minute proportions of RAM, or performance?
I think it is much more flexible to store information like "Drawline" and "DrawBox". It is like a high-level description of what we would like to draw. If it is faster to keep a backbuffer copy of the application working area (pixels) when doing focus switches, nothing would stop doing that. We can do whatever we wanted when we have a "high-level" description of what to draw. There could even be different levels of rendering quality, e.g. fast = poor, slow = excellent.

I admit that it does not matter if we are saving minute proportions of RAM today. I just took fright at the absolute number of bytes that are needed for keeping multiple backbuffers. Maybe you are right.
Post Reply