Jump to content
  • Advertisement
Sign in to follow this  
peterbone

Slow software renderer blitting

This topic is 3834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have written a software rasterizer (a 3D software renderer). I rasterize to an off-screen bitmap by writing to the bitmap scanlines and then blit the bitmap to the screen. The problem is that the blitting is slow because I have to set the pixel format of the bitmap to a 32 bit DIB in order to write to the scanlines - it then has to convert to the pixel format of the device (monitor) when blitting. If I set the bitmap pixel format to device dependant it will blit very quickly but then I can't write to the scanlines correctly - even if my screen colour depth settings are 32 bit. Is it possible to write to the scanlines of a device dependant bitmap without using hardware? The GDI routines in Windows are capable of doing this so how do they do it? Are they using hardware? Thanks Peter Bone

Share this post


Link to post
Share on other sites
Advertisement
Someone must know about this. Why can't I access the raw data in a DDB when GDI can. Is it the device that does the actual drawing and GDI is just the interface between the application and the device?
Peter

Share this post


Link to post
Share on other sites
The reason why the blit is slow is because you're doing a color conversion during the blit. The DDB is the same format as the primary display so the blit is fast and is basically a hardware accelerated memcpy.

The DDB is created by the display driver and its contents are opaque outside of the driver. The GDI calls made by applications, translate to DDI calls into the display driver and then the display hardware draws to the DDB.

Share this post


Link to post
Share on other sites
Thanks. This is what I suspected but I'm not exactly sure what you mean by 'opaque'. Does this mean there's no way to write to the DDB data from outside of the device? I assume this means there's no way to write a software renderer that blits quickly.
Pete

Share this post


Link to post
Share on other sites
I wouldn't dig up DirectDraw from the grave for this, but I would draw to a texture and draw a quad onto the screen, having the GPU do the format conversion.

Share this post


Link to post
Share on other sites
This sounds like a good idea enabling me to draw to the off-screen bitmap with the CPU and use the GPU for blitting. How would I go about drawing my bitmap to a texture?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!