Sign in to follow this  
Headkaze

Predict the pitch of a texture before creation?

Recommended Posts

In my experience it always coresponded to the width of the nearest higher power of two (256, 512, 1024, 2048 etc.).

So a texture 800x600 would have pitch 4*1024, the same as it if was 1024x600.

 

But I have no idea how reliable this is! That's just my experince, not based on any documentation or something.

Share this post


Link to post
Share on other sites

if I'm not stupid, you want the dot pitch?

 

Well if that's the case, then you should look at this:

 

triangle_thumb.png?imgmax=800

 

So that would be:

float d = sqrt(width^2 + height^2);

Then we can calculate the ppi (pixels per inch) using the ratio of pixels/inches:

float ppi = 1639.2 / 20; // = 81.96 ppi

Sometimes the marketing is different, so they use millimeters, soo:

float dPitch = 25.4 / ppi

I found an example with javascript:

function calcDotPitch(hPixels, vPixels, diagonal)
{
    var d = Math.sqrt(hPixels * hPixels + vPixels * vPixels);
    var ppi = d/diagonal;
    var dotPitch = 25.4 / ppi;
    return dotPitch;
}

PS. I have never done this, this was something that I just read, so can somebody please confirm that this is not bullshit?

Share this post


Link to post
Share on other sites

The driver is free to give you any pitch greater than or equal to (width * bytesperpixel). The documentation specifically says that you can't rely on a particular pitch, even in subsequent locks to the same surface. This is because the driver can reallocate GPU memory internally (usually to defragment it). With Vista and up, the physical GPU memory reallocation is potentially very frequent because of the video memory virtualization.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this