Direct surface is funny!!

Started by
1 comment, last by jimywang 20 years ago
i recently did a directX program which has several off screen surface holding sprite.i know that for some video card video memory isnt linear,and when you want to move from line to line,lpitch is needed to get the correct address.the funny thing is one of my off screen is 64x64 while another one is 72x80,and 64x64 one is linear on the other hand the 72x80 needs lpitch!!can somebody tell me what the hell is wrong with that thing please?
Advertisement
Maybe your videocard could fit a 64x64 chunk into memory properly without requiring a pitch. Who knows. Maybe one chunk gets loaded into the video card and the other into system mem. Just be safe and use lpitch all the time.
Very probably this is due to texture cache alignment (powers of two fill the cache completely, while otherwise the data needs to be padded to start the next scanline on a clean cache block).

Note that there''s no "standard" as to how the pitch is realized, but this is the most common way.

What is standardized is that the pitch always equals two consecutive scanline''s distance in memory, measured in bytes, and when manipulating texture data directly, you should use it always.

-Nik

Niko Suni

This topic is closed to new replies.

Advertisement