PDA

View Full Version : float RTT on ATI



V-man
06-23-2004, 11:34 AM
Hello,

is it possible to create a float RTT on ATI?
I have created regular float texture, float p-buffer and those work fine.

If it's possible, I'd appreciate details as to what parameters are needed for the WGL functions.

If it's not possible, what do I do? Read back via glReadPixels?

TIA

NitroGL
06-23-2004, 01:53 PM
Sure is! Just make a floating point pbuffer as normal, and set the usual RTT attribs.


Attrib[0]=WGL_DRAW_TO_PBUFFER_ARB;
Attrib[1]=TRUE;
Attrib[2]=WGL_SUPPORT_OPENGL_ARB;
Attrib[3]=TRUE;
Attrib[4]=WGL_DOUBLE_BUFFER_ARB;
Attrib[5]=DoubleBuffer;
Attrib[6]=WGL_PIXEL_TYPE_ARB;
Attrib[7]=WGL_TYPE_RGBA_FLOAT_ATI;
Attrib[8]=WGL_COLOR_BITS_ARB;
Attrib[9]=128;
Attrib[10]=WGL_DEPTH_BITS_ARB;
Attrib[11]=24;
Attrib[12]=WGL_BIND_TO_TEXTURE_RGBA_ARB;
Attrib[13]=TRUE;
Attrib[14]=0;

V-man
06-23-2004, 02:52 PM
Originally posted by NitroGL:
Sure is! Just make a floating point pbuffer as normal, and set the usual RTT attribs.It's not that easy I guess.
wglChoosePixelFormatARB succeeds with a few formats but the problem is always at wglCreatePbufferARB.

It returns NULL and error is
DWORD errorVal=GetLastError() //ERROR_INVALID_DATA

I tried not asking for mipmaps, asking for mipmaps, 512x512, 256x256, 128x128, ....

This is my code

i=0;
attribList[i++]=WGL_TEXTURE_FORMAT_ARB;
attribList[i++]=WGL_TEXTURE_RGBA_ARB;
attribList[i++]=WGL_TEXTURE_TARGET_ARB;
attribList[i++]=WGL_TEXTURE_2D_ARB;
attribList[i++]=0;
attribList[i++]=0;
*hPBuffer=wglCreatePbufferARB(hDC, pixelFormat[0], width, height, attribList);What data is invalid?

non-float formats work fine with the same code, so I know my code is fine.

I downgraded to Cat 4.5 after seeing 3 bugs in 4.6

NitroGL
06-23-2004, 03:28 PM
Should work like that... That's more or less what I have for my pbuffer attribs.

V-man
06-24-2004, 06:10 AM
It doesn't work. I have switched off some stuff in the control panel like tripple buffering and extended deskop, FSAA, aniso, but nothing changes.

Can you test it?
http://www.geocities.com/vmelkon/pbuffercreator.html

From menu
Start -> Automatically Create a RTT and destroy it
(it will find good values by trying to create a non-float p-buffer)

and then
Render Testing -> Create a 2D RTT (ATI float)

or send me your demo so I can test it on mine.

NitroGL
06-24-2004, 07:34 AM
Hm... I get the same thing you do with your app.

Here's mine:
http://www.area3d.net/file.php?filename=nitrogl/RTTFloat.zip

Sorry if the OpenGL context framework is a bit of a mess, but you should be able to figure it out.

V-man
06-24-2004, 12:55 PM
Thanks for your thing, even though it has bugs, it worked.

You need to terminate the attrib list with a double zero


Attrib[i++]=0; <-------
Attrib[i++]=0; <-------and also

if(!wglChoosePixelFormatARB(hDCTemp, Attrib, NULL, 1, &PixelFormat, &Formats))
{
MessageBox(NULL, "wglChoosePixelFormatARB Failed!", NULL, MB_OK);
return 0;
}

//Formats might be 0!!!

My problem was a stupid bug on my part

</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">attribList[i++]=WGL_TEXTURE_FORMAT_ARB;
if(*pcolorBits==24)
attribList[i++]=WGL_TEXTURE_RGB_ARB;
else if(*pcolorBits==32)
attribList[i++]=WGL_TEXTURE_RGBA_ARB;


changed to

attribList[i++]=WGL_TEXTURE_FORMAT_ARB;
if(*pcolorBits==24)
attribList[i++]=WGL_TEXTURE_RGB_ARB;
else if((*pcolorBits==32)

V-man
06-24-2004, 12:57 PM
---------Repost----------------

Thanks for your thing, even though it has bugs, it worked.

You need to terminate the attrib list with a double zero


Attrib[i++]=0; <-------
Attrib[i++]=0; <-------and also

</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">if(!wglChoosePixelFormatARB(hDCTemp, Attrib, NULL, 1, &PixelFormat, &Formats))
{
MessageBox(NULL, "wglChoosePixelFormatARB Failed!", NULL, MB_OK);
return 0;
}

//Formats might be 0!!!


My problem was a stupid bug on my part


attribList[i++]=WGL_TEXTURE_FORMAT_ARB;
if(*pcolorBits==24)
attribList[i++]=WGL_TEXTURE_RGB_ARB;
else if(*pcolorBits==32)
attribList[i++]=WGL_TEXTURE_RGBA_ARB;


changed to

attribList[i++]=WGL_TEXTURE_FORMAT_ARB;
if(*pcolorBits==24)
attribList[i++]=WGL_TEXTURE_RGB_ARB;
else if((*pcolorBits==32)

V-man
06-24-2004, 01:01 PM
Thanks for your thing, even though it has bugs, it worked.

You need to terminate the attrib list with a double zero


Attrib[i++]=0; <-------
Attrib[i++]=0; <-------and also


if(!wglChoosePixelFormatARB(hDCTemp, Attrib, NULL, 1, &amp;PixelFormat, &amp;Formats))
{
MessageBox(NULL, "wglChoosePixelFormatARB Failed!", NULL, MB_OK);
return 0;
}

//Formats might be 0!!!My problem was a stupid bug on my part

</font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">attribList[i++]=WGL_TEXTURE_FORMAT_ARB;
if(*pcolorBits==24)
attribList[i++]=WGL_TEXTURE_RGB_ARB;
else if(*pcolorBits==32)
attribList[i++]=WGL_TEXTURE_RGBA_ARB;


changed to

attribList[i++]=WGL_TEXTURE_FORMAT_ARB;
if(*pcolorBits==24)
attribList[i++]=WGL_TEXTURE_RGB_ARB;
else if((*pcolorBits==32)

V-man
06-24-2004, 01:09 PM
Thanks for your thing, even though it has bugs, it worked.

You need to terminate the attrib list with a double zero
Attrib i++=0; <-------
Attrib i++=0; <-------

and also

if !wglChoosePixelFormatARB hDCTemp, Attrib, NULL, 1, &PixelFormat, &Formats

MessageBox NULL, "wglChoosePixelFormatARB Failed!", NULL, MB_OK ;
return 0;

//Formats might be 0!!!

My problem was a stupid bug on my part

attribList i++ =WGL_TEXTURE_FORMAT_ARB;
if *pcolorBits==24
attribList i++ =WGL_TEXTURE_RGB_ARB;
else if *pcolorBits==32
attribList i++ =WGL_TEXTURE_RGBA_ARB;


changed to

attribList i++ =WGL_TEXTURE_FORMAT_ARB;
if *pcolorBits==24
attribList i++ =WGL_TEXTURE_RGB_ARB;
else if *pcolorBits==32 &#0124;&#0124; *pcolorBits==128
attribList i++ =WGL_TEXTURE_RGBA_ARB;

Ouch!

Another thing that pisses me off is that sometimes I can't detach the p-buffer, but I think this is because of MessageBox

NitroGL
06-24-2004, 01:44 PM
If there aren't any formats found, it'll just fail. So I don't need to handle it if Formats is 0, because PixelFormat should be invalid. It works on all the hardware I can find, so I don't see a reason to do it otherwise.

Also I don't see anything in the pixel format extension spec that says the attrib list needs to be terminated with two 0s, though I might have missed something. It's always worked with just one, and on other implementations too.

V-man
06-25-2004, 02:52 AM
This is from the spec

"If no matching formats are found then nNumFormats
is set to zero and the function returns TRUE."

I think the function only returns FALSE when hdc is invalid or some of the attrib list has bogus values.

As for the double zero termination, that comes from a NVidia pdf, I think it's pbuffer.pdf or p-buffer.pdf .... search for their earliest docs.

NitroGL
06-25-2004, 08:17 AM
I ment CreatePbuffer will fail

V-man
06-26-2004, 06:21 AM
Following wglChoosePixelFormatARB, wglCreatePbufferARB will be called and whatever happens to be in PixelFormat will be used, which will contain uninitialized data.

NitroGL
06-26-2004, 09:07 AM
Not if PixelFormat is an invalid format number (negative or 0)

bobvodka
07-02-2004, 08:50 PM
hmm i've been looking around for some examples of using RTT with floating point textures and pbuffers, now from what I can gather with NV cards you have to tell it that the pbuffer is bound with a floating point texture with the WGL_TEXTURE_FORMAT_ARB token, however as thats done via an NV extension ATI doesnt have I was wondering how that worked with ATI cards?

do you just set WGL_TEXTURE_FORMAT_ARB to WGL_TEXTURE_RGBA_ARB, bind your floating point texture of the same type as the pbuffers context was created with and go from there?
or is there some other black magic you have to work?
i assume if the above is true there are no clamping issue?

NitroGL
07-02-2004, 10:08 PM
Yup, just create a normal RGBA render texture pbuffer. Difference is that it's a floating point pixel type and is 64bit or 128bit color depth.

No need for anything special.

edwinz
07-03-2004, 08:19 PM
hi NitroGL!
i was wondering if u could provide a very simple usage of ur floating pbuffer using RTT on ATI cards, showing the 32bit results of the RTT, on Mark Harris's Image Debugger.

currently, i have a floating pbuffer working but the RTT outputs clamped values on Image Debugger.

thx!
Edwinz

NitroGL
07-03-2004, 11:40 PM
http://www.area3d.net/file.php?filename=nitrogl/RTT.zip

About as simple as I can get it.

The output on this is clamped if you read the displayed buffer, because that's only 32bit color. You would have to read back from the pbuffer or use a fragment program to make use of the floating point precision.

edwinz
07-04-2004, 04:19 PM
Hio NitroGL!
thx fer replying!

i am trying to add this into the simple RTT u did:
http://www.cs.unc.edu/~baxter/projects/imdebug/

got some nasty code clashes right now...brb

thx!
Edwinz