Moving the Graphics Card Base Addres instead of buffering

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Moving the Graphics Card Base Addres instead of buffering

Post by ~ »

How common and how possible would the following be in a standard way?
I have been thinking that drawing in a screen could be done extremely fast if the base address of the graphics card (the BAR) could be moved to arbitrary regions of memory at runtime instead of relying on double/multiple buffering.

In this way, we could implement a high level stack of buffer pointers, and also a heap of such buffers.

Then, we could start pushing just the address of certain screen-sized buffer and pass it as a parameter for a drawing function.

When we finish drawing, we could, instead of copying the secondary buffer to the screen's frame buffer, just pop it directly into the PCI Base Address Register (BAR) and thus updating the current screen immediately?

If the hardware supported it, we could also move, free up and even page the frame buffer region and probably use it for other purposes (for example when the screen is turned off or when there's a long time away from the computer).
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Moving the Graphics Card Base Addres instead of bufferin

Post by neon »

Most modern video devices support page flipping which can be used to alternate between multiple buffers without the need to copy data. I am not aware of any standard protocol (not even firmware interfaces) that provides these facilities though. In other words, you may need to write custom drivers for these devices. Copying the back buffer is slower but more portable.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: Moving the Graphics Card Base Addres instead of bufferin

Post by FallenAvatar »

Seeing as hardware sees physical memory (and not paged/linear/whats the other one called?) this is already "easy" to do.

- Monk
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: Moving the Graphics Card Base Addres instead of bufferin

Post by ~ »

tjmonk15 wrote:Seeing as hardware sees physical memory (and not paged/linear/whats the other one called?) this is already "easy" to do.

- Monk
Segmented?
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Moving the Graphics Card Base Addres instead of bufferin

Post by alexfru »

neon wrote:Most modern video devices support page flipping which can be used to alternate between multiple buffers without the need to copy data. I am not aware of any standard protocol (not even firmware interfaces) that provides these facilities though. In other words, you may need to write custom drivers for these devices. Copying the back buffer is slower but more portable.
VESA VBE. If you have enough video memory, you can make a virtual screen larger than the physical screen and organize scrolling or flipping by setting the address of the beginning of the visible portion and drawing in the invisible.
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Moving the Graphics Card Base Addres instead of bufferin

Post by Octocontrabass »

~ wrote:instead of copying the secondary buffer to the screen's frame buffer, just pop it directly into the PCI Base Address Register (BAR) and thus updating the current screen immediately?
The video card's frame buffer is located in the video card's RAM, not in main RAM. Changing the BAR only changes where the video card's RAM is located in the CPU address space; it does not cause the video card to use main RAM as the frame buffer.

(Integrated graphics controllers that use main RAM as the video card's RAM may support these kinds of shenanigans, but it won't be as simple as messing with the PCI configuration.)
Post Reply