• Create Account

# Predict the pitch of a texture before creation?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1Headkaze  Members   -  Reputation: 548

Like
0Likes
Like

Posted 20 August 2013 - 03:28 AM

I want to create a texture of D3DFMT_A8R8G8B8 format. If I already know the width and height is there any way I can predict the pitch before calling CreateTexture?

### #2Tom KQT  Members   -  Reputation: 1183

Like
0Likes
Like

Posted 20 August 2013 - 04:44 AM

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.

### #3Migi0027  Members   -  Reputation: 1028

Like
-1Likes
Like

Posted 20 August 2013 - 04:50 AM

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

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

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?

My Blog - Cuboid Zone

“C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.” Bjarne Stroustrup

### #4Nik02  Crossbones+   -  Reputation: 2370

Like
2Likes
Like

Posted 20 August 2013 - 04:51 AM

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.

Niko Suni

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS