Software Rendering

Moderator
Posts: 3,570
Joined: 2003.06
Post: #1
I've been reading up on some more of the fundamentals of 3D rendering on and off for the last year or two. I haven't actually put anything into practice. It's just an interesting curiosity to me really. OpenGL is what we all use in reality. I have some time off right now and I was thinking about playing around with doing some software rendering for the fun of it. Feeling a bit adventurous and impractical I suppose.

Here's the question: I was thinking about setting up a couple of buffers as textures in OpenGL and just using glTexSubImage2D as the swap mechanism. It just seems to me there might be another way. Could I just rasterize straight into the color buffer? Any ideas?
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #2
No, you would have to rasterize into a texture. You would get decent results by setting up a DMA transfer directly to the texture memory buffer, though.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #3
I guess that's the conclusion to stick to then. Not that I'm complaining. Just checking to see if I was missing some other option. DMA is certainly fast enough for a quick texture swap. Thanks, Fenris.
Quote this message in a reply
Member
Posts: 145
Joined: 2002.06
Post: #4
It's not quite clear if you're actually using the textures as textures, or just a means of getting pixels on the screen. If you're justing getting pixels on the screen you can write directly into video memory, which probably be at least an order of magnitude faster than writing to a buffer, loading into a texture, and drawing on the screen. I think.

"He who breaks a thing to find out what it is, has left the path of wisdom."
- Gandalf the Gray-Hat

Bring Alistair Cooke's America to DVD!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
order of magnitude slower you mean Rasp

You can get DMA uploading a texture, which you can't get writing directly to VRAM...
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #6
Quote:Originally posted by inio
It's not quite clear if you're actually using the textures as textures, or just a means of getting pixels on the screen.
Getting pixels on the screen is what I'm doing with the textures. I don't even *have* textures in my rendering engine yet ( or lighting for that matter ). The only thing I am using OpenGL for is just to get hardware acceleration for the swap at the end of the rendering pipeline, right after rasterization. That's it. DMA texture uploading is really fast. It's just weird to render into a texture and call it a screen buffer.

With that out of the way, I should point out again that what I'm doing is an excellent example of sheer impracticality. How would I go about writing directly to video memory? I'd like to try that too just for the fun of it.

BTW, in case anyone is interested or, more importantly, has some other reference suggestions for me: one of the books that I'm reading through is "Tricks of the 3D Game Programming Gurus" by LaMothe. This is a really great book on software rendering with lots of info in plain language. It's like 1700 pages though -sheesh! Sucks that he's such a DirectX fan but whatever... "Real-Time Rendering" by Moller and Haines is also very good but it's usually waaaay over my head. http://pages.infinit.net/jstlouis/3dbhole/ is another nice, simple reference. None of them have anything to do with the Mac so I'm having to kind of make stuff up as I go along, but it's still a fun diversion.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
Code:
CGDisplayCapture(kCGDirectMainDisplay);
void *vram = CGDisplayBaseAddress(kCGDirectMainDisplay);
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #8
Thanks OSC. Speed isn't nearly as bad as I suspected it might be -about 23 fps at 1024x768x32 vs. about 82 fps for the same thing using DMA textures in OpenGL. Well, but the DMA textures got to run in a window so I guess that's not really a fair comparison, but interesting anyway. I can't figure out how to synch to VBL when drawing directly to VRAM, but that's not an issue anyway since I just wanted to check it out for kicks.

Edit: I should add that my method of blitting is slightly different between the two and they could both be improved.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #9
Quote:Originally posted by AnotherJake
DMA texture uploading is really fast. It's just weird to render into a texture and call it a screen buffer.

Off topic: It's not weird, it's a very common practice for special effects.
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #10
Quote:DMA texture uploading is really fast. It's just weird to render into a texture and call it a screen buffer.


I'm not a 100% on this, but I want to seem well-educated, so I'm going to make a run for it:

This isn't really what happens. DMA access means that the video board can access regular RAM extremely quickly. You still render into a buffer that resides in main RAM, and then call that a texture.

Quote:but it's still a fun diversion.

I suppose that you implying that you have free time on your hands. Now, saying this in proximity of my extremely stressed-out, time-is-short-as-hell life can prove to be lethal. I'm letting you off the hook this time. Wink
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #11
* OpenGL is much faster fullscreen than windowed.

* The only way to sync to VBL on Mac OS X is via OpenGL or the window manager.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #12
Quote:Originally posted by Fenris
I'm not a 100% on this, but I want to seem well-educated, so I'm going to make a run for it:

This isn't really what happens. DMA access means that the video board can access regular RAM extremely quickly. You still render into a buffer that resides in main RAM, and then call that a texture.



DMA is short for "Direct Memory Access", which basically means that the video card can access the RAM without having to shove the data through the CPU. You will still be limited by AGP bandwidth (though this limitation in itself probably wont matter for you), but at least no CPU cycles are used for the RAM->VRAM transfer.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #13
Quote:* OpenGL is much faster fullscreen than windowed.
That's what I meant by it not being a fair comparison. The OpenGL version would have been even faster running at fullscreen like the VRAM version was. I should have said that differently.

Quote:* The only way to sync to VBL on Mac OS X is via OpenGL or the window manager.
That would seem to be another disadvantage of writing directly to VRAM.

Quote:DMA access means that the video board can access regular RAM extremely quickly. You still render into a buffer that resides in main RAM, and then call that a texture.
Exactly. From the standpoint of a software rendering engine that "texture" is being used as a "screen buffer" to put the final rasterized image into. OpenGL isn't being used for anything else. At all. The software rendering engine does all the work. I'm simply using OpenGL as the mechanism to get the pixels pushed to the screen in the end in the form of an OpenGL texture just like you're saying. So I'm calling that texture a "screen buffer" in this instance.

Quote:I'm letting you off the hook this time.
Heeeheeee! Vacation rocks!
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #14
Quote:Originally posted by DoG
You will still be limited by AGP bandwidth (though this limitation in itself probably wont matter for you), but at least no CPU cycles are used for the RAM->VRAM transfer.
-Or PCI bandwidth. You're right, since software rendering is so processor intensive it's a major plus to get the processor out of the loop here.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #15
Hey, BTW, I have a Radeon on the PCI bus and a factory GeForce on the AGP bus. They both work really well when the window is mostly on one or the other, but you should see how the texture upload slows to a crawl when I drag the window in between the two. Pathetic.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Parallel OpenGL Library (software rendering) psyba 8 3,684 May 16, 2006 07:14 PM
Last Post: OneSadCookie