OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Dec 06, 2019 6:00 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: How does graphics work in protected mode?
PostPosted: Wed Nov 27, 2019 3:57 am 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 50
Hello.

I use grub2 to boot, boot into graphics mode like this:
Code:
multiboot_header:
    dd MULTIBOOT_MAGIC
    dd MULTIBOOT_FLAGS
    dd -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
    dd 0
    dd 0
    dd 0
    dd 0
    dd 0
    dd 0
    dd 800 ; width
    dd 600 ; height
    dd 32 ; bbp


Then using the resulting multibootinfo, I take the address of the video buffer and record the pixels.

I have such questions:
1. What's it? Is it VESA or SVGA or something else? What is the name of this mechanism?
2. What draws this graphic? Video card or processor?
3. How universal is this method? On what systems will it work and on what not?
4. I want to write a system of rendering 3D scenes, polygons, cubes. Something like OpenGL. Is this a good way to display graphics? Or should I choose something more powerful?

Thanks.


Top
 Profile  
 
 Post subject: Re: How does graphics work in protected mode?
PostPosted: Wed Nov 27, 2019 4:24 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3589
Location: Chichester, UK
https://wiki.osdev.org/Drawing_In_Protected_Mode


Top
 Profile  
 
 Post subject: Re: How does graphics work in protected mode?
PostPosted: Thu Nov 28, 2019 5:20 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 1697
mrjbom wrote:
1. What's it? Is it VESA or SVGA or something else? What is the name of this mechanism?

Linear frame buffer. GRUB uses the firmware to configure the LFB, so it might use VBE or UGA or GOP depending on what's available.

mrjbom wrote:
2. What draws this graphic? Video card or processor?

The processor puts pixels into the buffer. The video card puts the buffer on the screen.

mrjbom wrote:
3. How universal is this method? On what systems will it work and on what not?

GRUB can set up a LFB on pretty much any PC GRUB can run on. On very old computers, the LFB won't be very nice, but it will be linear and it will be a frame buffer.

On any PC from the past 20 years, GRUB will be able to set up at least 800x600 with at least 15 bits per pixel (though firmware limitations may prevent you from getting exactly the mode you request).

mrjbom wrote:
4. I want to write a system of rendering 3D scenes, polygons, cubes. Something like OpenGL. Is this a good way to display graphics? Or should I choose something more powerful?

If you want to offload any of the 3D rendering work to the graphics card, you'll need to write a driver for it. Different graphics cards will require different drivers.


Top
 Profile  
 
 Post subject: Re: How does graphics work in protected mode?
PostPosted: Thu Nov 28, 2019 7:33 am 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 50
Octocontrabass wrote:
mrjbom wrote:
4. I want to write a system of rendering 3D scenes, polygons, cubes. Something like OpenGL. Is this a good way to display graphics? Or should I choose something more powerful?

If you want to offload any of the 3D rendering work to the graphics card, you'll need to write a driver for it. Different graphics cards will require different drivers.


Thanks for the answers. About the fourth question. You said that me will need write driver for each video card, but I think you me not correctly understood. I suppose you thought I wanted to use the built-in OpenGL graphics card for this task, but it's not, I want to write everything from scratch and I'm wondering if there's enough performance for this. Since you said that the graphics card is engaged in rendering, it is obvious that it is enough. Right? I don't have to write a driver for each video card because I don't want to use the built-in OpenGL specification, right?


Top
 Profile  
 
 Post subject: Re: How does graphics work in protected mode?
PostPosted: Thu Nov 28, 2019 9:09 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3589
Location: Chichester, UK
If you want good performance you need the video card to do the work. This means that you need to write a driver for it - not a simple task.


Top
 Profile  
 
 Post subject: Re: How does graphics work in protected mode?
PostPosted: Thu Nov 28, 2019 9:12 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 1697
If you don't want to offload any of the 3D rendering work to the graphics card, you don't need to write a driver for it.

Typical 3D rendering algorithms are much faster on a GPU than on the CPU. If you're only creating a new API on top of existing rendering algorithms, you will most likely see higher speeds once you write a graphics driver. On the other hand, if you're also coming up with new rendering algorithms, you might not be able to use a graphics driver to increase the speed.


Top
 Profile  
 
 Post subject: Re: How does graphics work in protected mode?
PostPosted: Fri Nov 29, 2019 12:59 am 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 632
OpenGL is a library-level interface. At runtime, OpenGL calls and shaders are translated to the register interface and ISA that your GPU understands (for the open source drivers in Linux, this translation layer sits inside Mesa; it uses vendor-specific ioctl()s in libdrm to communicate with the GPU). Those interfaces are GPU-specific (usually, even GPU model-specific) and require a driver for your GPU.

_________________
managarm: Microkernel-based OS that is capable of running a Wayland desktop
My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions]


Top
 Profile  
 
 Post subject: Re: How does graphics work in protected mode?
PostPosted: Fri Nov 29, 2019 3:21 am 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 50
Okay, I get it. I guess I'll have to work with the video card and make it vicelat.
But it is difficult to write a driver for each video card model. Can I use code from Mesa? How hard is it to embed it in my kernel?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group