PDA

View Full Version : GLX_ATI_pixel_format_float under linux



roffe
01-24-2004, 01:12 PM
Hey

Anyone tried to create a floating point pbuffer using ATI/GLX with the above mentioned extension?

In the glxATI.h installed with the drivers
GLX_ATI_RGBA_FLOAT_ATI_BIT is defined but I can't find any reference on how to use it with fbconfig. All tries so far have failed miserably.

Any help,docs or sample code greatly appreciated.

/Mathias

:wumpus:
01-24-2004, 04:52 PM
Use the GLX_ATI_pixel_format_float extension.

Example code should be here (http://web.sfc.keio.ac.jp/~syoyo/opengl/floatbuffer/)

I tried some messing around myself and now understand your problem; how to use GLX_RGBA_FLOAT_ATI_BIT?
I think it's a GLX_RENDER_TYPE flag like GLX_RGBA_BIT .


[This message has been edited by :wumpus: (edited 01-24-2004).]

roffe
01-24-2004, 05:29 PM
Originally posted by :wumpus::
Use the GLX_ATI_pixel_format_float extension.

Yes that was my question, how do I use it?
Did you read the subject line?

Example code should be here (http://web.sfc.keio.ac.jp/~syoyo/opengl/floatbuffer/)

This link is useless to me. I was asking for GLX/ATI code, not NVIDIA/WGL or Apple/MacOS X code. But thanks for playing...

roffe
01-24-2004, 05:33 PM
Originally posted by :wumpus::
I think it's a GLX_RENDER_TYPE flag like GLX_RGBA_BIT .


Thought so too, but no. Even found a GLX_RGBA_TYPE token in the glx1.3 specs but that didn't work either. I'm clueless.

EDIT:
It seems like GLX_RGBA_TYPE is suppose to be used in glXCreateNewContext(). I guess that was a dead end.



[This message has been edited by roffe (edited 01-24-2004).]

:wumpus:
01-24-2004, 05:40 PM
Got it to work:



int attrib_float_ati[] = {
GLX_DOUBLEBUFFER, False,
GLX_RED_SIZE,32,
GLX_GREEN_SIZE,32,
GLX_BLUE_SIZE,32,
GLX_ALPHA_SIZE,32,
GLX_DEPTH_SIZE,24,
GLX_STENCIL_SIZE,8,
GLX_RENDER_TYPE, GLX_RGBA_FLOAT_ATI_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
0
};
.
.
.
config = glXChooseFBConfig(display,screen,attrib_float_ati, &count);



[This message has been edited by :wumpus: (edited 01-24-2004).]

roffe
01-24-2004, 06:03 PM
Wow, it did, thanks a million. Forever grateful!!

I was editing the fgl_glxgears demo and they
OR GLX_PBUFFER_BIT and GLX_WINDOW_BIT used for the GLX_DRAWABLE_TYPE property. I realize now that the GLX_WINDOW_BIT bit cancels out all formats not meant for 'window rendering', duh. For some reason I thought it was the other way around.

Anyways, thanks again.

:wumpus:
01-25-2004, 08:54 AM
Hm, one problem though: it won't share state with the normal GLX context.
This means copying through a texture is not possible. It also looks like it is incredibly slow.
Possibly, rendering is done in software mode. (no proof for this though)

[This message has been edited by :wumpus: (edited 01-25-2004).]

roffe
01-25-2004, 12:13 PM
What exactly do you mean by sharing state?
Sharing gl state(using same ctx) or sharing display lists/texture objects etc?
I wouldn't expect a pbuffer with a floating point pixel format to use the same context as a 'normal' window. Haven't tested it that much, but my glXCreateNewContext doesn't fail, neither does glXMakeCurrent.




pbuf_ctx = glXCreateNewContext(dpy,fbconfig[0],GLX_RGBA_TYPE,win_ctx,GL_TRUE);


Regarding performance. Is it slow as in 4 times the bandwidth slow or slow as in software rendering? I'll do some testing on my own and report back.

:wumpus:
01-25-2004, 01:41 PM
I mean share state as in 'sharing display list, textures and objects'. Not context, of course.
All float pbuffer examples I stumbled on use a texture as 'pastebin' between the float and integer context. This does not work currently.
So it's not possible to actually display the floatbuffer without a AGP full roundtrip of the data.

Another indication it is software-based: ATI extensions don't work in the alternate context.

[This message has been edited by :wumpus: (edited 01-25-2004).]

roffe
01-25-2004, 04:16 PM
Originally posted by :wumpus::
All float pbuffer examples I stumbled on use a texture as 'pastebin' between the float and integer context. This does not work currently.

That is strange, because I've done some testing now and sharing both textures and fragment programs seems to work fine.

What I did was this, with assert(!glGetError()) after every operation:
- Create window ctx
- Create pbuffer ctx and share with window ctx
- Define float texture in window ctx
- Switch to pbuffer ctx
- Render into pbuffer
- Bind float texture in pbuffer ctx
- glCopyTexSubImage to float texture
- switch back to window ctx
- verify texture contents against pbuffer

Sometimes I make the mistake of defining objects BEFORE sharing the ctx, and then sharing of those objects wont work. This behaviour is similiar on Windows. wglShareLists() docs mentions this but glXCreateNewContext docs says 'will share all objects except them named 0'.

BTW what do you mean by "ATI extensions don't work in the alternate context"? I used GL_ATI_texture_float in both contexts and that work fine.

FYI: ATI Radeon 9800(non-pro),Redhat7.3 XFree86 4.2, Latest official ATI drivers

:wumpus:
01-25-2004, 05:53 PM
pbuf_ctx = glXCreateNewContext(dpy,fbconfig[0],GLX_RGBA_TYPE,win_ctx,GL_TRUE);


I was using glXCreateContext. That could be the problem.

No. It just doesn't work here. If you want, please quote or upload the code you use to set it up, so I can see what I'm doing wrong.

FYI: Slackware 9.1, Xfree 4.3.0, ATI 3.7.0, Radeon 9600XT






[This message has been edited by :wumpus: (edited 01-25-2004).]

roffe
01-26-2004, 09:39 PM
Sure. Here is my pbuffer creation code.It should be pretty straightforward.




bool glpbuffer::initialize(Display *dpy,bool ownContext,bool shareContext,GLXContext glxrc) {
int attrib[] = {
GLX_DOUBLEBUFFER, (doublebuffer) ? 1:0,
GLX_RED_SIZE, colorbits[0],
GLX_GREEN_SIZE, colorbits[1],
GLX_BLUE_SIZE, colorbits[2],
GLX_ALPHA_SIZE, colorbits[3],
GLX_DEPTH_SIZE, depthbits,
GLX_STENCIL_SIZE,stencilbits,
GLX_RENDER_TYPE, (floatcomponents) ? GLX_RGBA_FLOAT_ATI_BIT:GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
None
};

int pbufAttrib[] = {
GLX_PBUFFER_WIDTH, width,
GLX_PBUFFER_HEIGHT, height,
GLX_LARGEST_PBUFFER, False,
None
};
int nitems=9;

// check connection to x server
if(dpy == NULL) return false;
this->dpy = dpy;

// find pixel format
int scrnum = DefaultScreen( dpy );
fbconfig = glXChooseFBConfig(dpy,scrnum,attrib,&nitems);
if (fbconfig == NULL) {
return false;
}

// create pbuffer
pbuf = glXCreatePbuffer(dpy, fbconfig[0], pbufAttrib);

visinfo = glXGetVisualFromFBConfig(dpy, fbconfig[0]);
if (visinfo == NULL) {
XFree(fbconfig);
glXDestroyPbuffer(dpy,pbuf);
}

if(ownContext) {
if(shareContext)
pbuf_ctx = glXCreateNewContext(dpy,fbconfig[0],GLX_RGBA_TYPE,glxrc,GL_TRUE);
else
pbuf_ctx = glXCreateNewContext(dpy,fbconfig[0],GLX_RGBA_TYPE,NULL,GL_TRUE);

if(pbuf_ctx == NULL) {
XFree(fbconfig);
glXDestroyPbuffer(dpy,pbuf);
XFree(visinfo);
return false;
}
}
else {
pbuf_ctx = glxrc;
shared_ctx = true;
}

pbuf_created = true;
return true;
}