G16R16F readback woes

Started by
1 comment, last by neneboricua19 18 years, 1 month ago
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
Advertisement
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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

This topic is closed to new replies.

Advertisement