Welcome, Unregistered.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Reply
Old 09-Jul-2009, 16:04   #1
shuipi
Junior Member
 
Join Date: Mar 2004
Location: Beijing, China
Posts: 73
Default IDirect3DTexture9 assumes column major?

IDirect3DTexture9 *texture;

D3DXCreateTexture(d3dDevice, width, height, 1,
0, D3DFMT_R32F,
pool, &texture));

float Table[width * height];

for(unsigned int row = 0; row < height; row++)
{
for(unsigned int col = 0; col < width; col++)
{
Table[row * width + col] = (float)row / col;
}
}

D3DLOCKED_RECT lockedRect;
texture->LockRect(0, &lockedRect, NULL, 0);

for(int j = 0; j < height; j++)
{
MemCopy((byte*)(lockedRect.pBits) + j * lockedRect.Pitch, &Table[j * width], width * sizeof(float));
}

And then I look at the texels in PIX for Win, it appeard to be uv inverted.
shuipi is offline   Reply With Quote
Old 09-Jul-2009, 20:10   #2
Andrew Lauritzen
AndyTX
 
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,840
Default

They are "row"-major if you want to use that terminology. To be more general, texels are stored linearly along their X, Y then Z dimensions. (Arrays are similar, see docs.)

In your code, you should be computing it as:
data[col * width + row]
__________________
The content of this message is my personal opinion only.
Andrew Lauritzen is offline   Reply With Quote
Old 09-Jul-2009, 21:48   #3
Humus
Crazy coder
 
Join Date: Feb 2002
Location: Stockholm, Sweden
Posts: 3,216
Send a message via ICQ to Humus Send a message via MSN to Humus
Default

Quote:
Originally Posted by shuipi View Post
And then I look at the texels in PIX for Win, it appeard to be uv inverted.
Not sure what you expected to see in PIX, but the code you posted should generate values greater than 1.0 in the bottom-left and below 1.0 in upper right. What are you observing?

Quote:
Originally Posted by Andrew Lauritzen View Post
In your code, you should be computing it as:
data[col * width + row]
But "col" is x and "row" is y, so his code looks correct to me and yours look wrong.
__________________
[ Visit my site ]
I speak for myself and only myself.
Humus is offline   Reply With Quote
Old 10-Jul-2009, 16:55   #4
shuipi
Junior Member
 
Join Date: Mar 2004
Location: Beijing, China
Posts: 73
Default

Quote:
Originally Posted by Humus View Post
Not sure what you expected to see in PIX, but the code you posted should generate values greater than 1.0 in the bottom-left and below 1.0 in upper right. What are you observing?



But "col" is x and "row" is y, so his code looks correct to me and yours look wrong.
You're right. I got confused for a bit. Thanks.
shuipi is offline   Reply With Quote
Old 10-Jul-2009, 19:33   #5
Andrew Lauritzen
AndyTX
 
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,840
Default

Quote:
Originally Posted by Humus View Post
But "col" is x and "row" is y, so his code looks correct to me and yours look wrong.
Oh whoops, yup of course you're right. Misread that.
__________________
The content of this message is my personal opinion only.
Andrew Lauritzen is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:05.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.