Sign in to follow this  

G16R16F readback woes

This topic is 4301 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

hi there! I am trying to get the readback for a surface with format G16R16F to work... still couldnt figure out how to adjust the code properly to suit a 16bit float format. I could do readbacks for formats like A32B32G32R32F, R32F, R16F, and other 8bit formats but couldnt get the readback G16R16F to work. Below is a sample of some part of my code (which is partially wrong though)
if(format == D3DFMT_G16R16F)
{
	for(int y=0; y<desc.Height; y++)
	{
		DWORD* pPixel = (DWORD*)(((BYTE*)theRect.pBits) + (y*theRect.Pitch));
		for(int x=0; x<desc.Width; x++) 
		{
			short red = (*pPixel&0xffff);
			//short green = (*pPixel&0xffff);
                        pPixel++;
		}
	}
}
could someone enlighten me on how to do readbacks for G16R16F? thx! Edwin

Share this post


Link to post
Share on other sites
You could use D3DXFloat16To32Array() to decode the values. If you create an array of D3DXFLOAT16's and write to it as you go through the texture you can then make a single call to the aforementioned function once you're done.

Alternately, you could try and decode them manually - off the top of my head, FP16 is in S1E5M10 format.

hth
Jack

Share this post


Link to post
Share on other sites
I haven't tried it yet, but how about this? I'm using a "short" pointer here because they are 16-bits. That fact lets my indexing be less complicated. Once the pointer is at the appropriate location, I cast the bits to be floats.

if(format == D3DFMT_G16R16F)
{
for(int y = 0; y < desc.Height; y++)
{
short *pTexArray = (ushort)theRect.pBits;
DWORD dwRow = y * theRect.Pitch;

for(int x = 0; x < desc.Width; x++)
{
DWORD dwCol = x * 2
float red = (float)(pTexArray + dwRow + dwCol + 0);
float green = (float)(pTexArray + dwRow + dwCol + 1);
}
}
}


Hope this helps,
neneboricua

Share this post


Link to post
Share on other sites

This topic is 4301 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.

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