From: Keith W. <ke...@va...> - 2001-02-15 17:50:15
|
Gareth, Here's a braindump regarding runtime installation of the api of a tnl module into the libGL dispatch table. There are two tricks to this; efficiency and correctness... Correctness is complicated by the fact that it is anticipated that drivers may not know which tnl module they want to use until after a call to 'gl_update_state()' has completed. If we wait until we are inside the tnl code before triggering gl_update_state(), it becomes necessary to detect if the tnl function that called gl_update_state() is still attached to the dispatch table, and if not to invoke the new one. This is ugly, and actually quite complex to get right. All in all it would be preferable to ensure 'gl_update_state()' is called prior to entering the tnl code, and to ensure that the correct tnl module is always invoked. Efficiency concerns are that installing 20 or 30 function pointers on a potentially very frequent basis is likely to be a performance issue in itself. My basic idea was to perform the installation in a lazy fashion, as individual entrypoints are invoked by clients. A set of stub functions would be initially installed into dispatch, which: 1) determine whether it is necessary to call gl_update_state(), and if so, do so. 2) install the 'real' version of the function, eg _tnl_Begin(), into the dispatch table, and pass control to that function. Consider this invarient: When inside any tnl api function, ASSERT(ctx->NewState == 0). The question then is how/when to uninstall driver tnl functions and restore the stubs. It seems at least two triggers are required: - A directive from the driver to install a new tnl module. - Any statechange (!!) This seems like overkill -- there are a lot of statechanges. It may be necessary instead to require that drivers only swap tnl modules in statechange callbacks, rather than from ctx->Driver.UpdateState(). Then the calls to gl_update_state() can remain in things like _tnl_DrawElements(), but they will be guarenteed to never alter the dispatch tables, or require forwarding of the call back to dispatch. ... But ... As I said above, the driver may not know until gl_update_state() is called whether it is able to use an accelerated tnl module. Specifically it may need to reference one of the values computed in gl_update_state() to make it's choice. Thus drivers would have to swap to the neutral tnl module in response to any dangerous state change callbacks, and have the neutral vertex format specifically ask the driver to choose (validate) the installed tnl module, after calling gl_update_state(). An equivalent strategy would be to have the driver register a bitmask of 'dangerous' statechanges, and only swap to the neutral tnl module on those statechanges. However this seems to introduce unnecessary overhead into each core statechange operation. ====================================================================== So, a second attempt: - Forbid swapping tnl modules inside ctx->Driver.UpdateState(). - Keep calls to gl_update_state() inside tnl modules. - Add a new 'ctx->Driver.ValidateTnlModule()' callback. - Create a neutral tnl module which contains functions which: - check if gl_update_state() needs to be called. - check if ctx->Driver.ValidateTnlModule() needs to be called. - installs the appropriate driver tnl function into dispatch. - finally forwards the call to the newly installed driver function. - Experiment with bitmask vs. callback strategies for swapping back to the neutral tnl module. Then the mechanism of swapping back to the neutral tnl module needs to be explored. As I've outlined a lazy method for swapping the driver tnl module in, a function at a time, it should be possible to keep track of which dispatch entries have been modified (from the neutral baseline), and only swap back in the portions of the neutral tnl module which have been swapped out. This might typically amount to 5 entries or so. As you can see, there's a fair bit of experimentation left to get this right... There may be yet another approach which bypasses some of these issues. I haven't given much thought to it, but it may be possible to allow the driver to swap dispatch entries from gl_update_state(), even when called from inside a tnl module, providing that the lost data is somehow rescued later on, perhaps by calling a special 'fallback' routine. I guess DrawArrays etc would still need to forward... Keith |
From: Gareth H. <ga...@va...> - 2001-02-16 15:05:37
|
Keith Whitwell wrote: > > As you can see, there's a fair bit of experimentation left to get this > right... > > There may be yet another approach which bypasses some of these issues. > I haven't given much thought to it, but it may be possible to allow > the driver to swap dispatch entries from gl_update_state(), even when > called from inside a tnl module, providing that the lost data is > somehow rescued later on, perhaps by calling a special 'fallback' > routine. I guess DrawArrays etc would still need to forward... Thanks, Keith. This is all really great information. So, if you guys have other things to do, I'd be more than happy to tackle this problem in the short term (ie. to get a 3.5 release out). The standalone FX driver should work with a V5, right? -- Gareth |
From: Brian P. <br...@va...> - 2001-02-16 15:22:01
|
Gareth Hughes wrote: > > Keith Whitwell wrote: > > > > As you can see, there's a fair bit of experimentation left to get this > > right... > > > > There may be yet another approach which bypasses some of these issues. > > I haven't given much thought to it, but it may be possible to allow > > the driver to swap dispatch entries from gl_update_state(), even when > > called from inside a tnl module, providing that the lost data is > > somehow rescued later on, perhaps by calling a special 'fallback' > > routine. I guess DrawArrays etc would still need to forward... > > Thanks, Keith. This is all really great information. > > So, if you guys have other things to do, I'd be more than happy to > tackle this problem in the short term (ie. to get a 3.5 release out). > The standalone FX driver should work with a V5, right? I've never tried. It would require a special Glide library. I guess you'd have to go to the Glide project on sourceforge and build it w/out DRI. -Brian |
From: Daryll S. <da...@va...> - 2001-02-16 15:30:30
|
On Sat, Feb 17, 2001 at 02:05:38AM +1100, Gareth Hughes wrote: > Thanks, Keith. This is all really great information. > > So, if you guys have other things to do, I'd be more than happy to > tackle this problem in the short term (ie. to get a 3.5 release out). > The standalone FX driver should work with a V5, right? No it won't. There is no Glide for it. - |Daryll |
From: Gareth H. <ga...@va...> - 2001-02-16 15:42:16
|
Daryll Strauss wrote: > > No it won't. There is no Glide for it. You mean Glide 3 doesn't work with the V5? Or is it that Glide 3 doesn't work with the FX driver? -- Gareth |
From: Daryll S. <da...@va...> - 2001-02-16 15:59:00
|
On Sat, Feb 17, 2001 at 02:42:10AM +1100, Gareth Hughes wrote: > Daryll Strauss wrote: > > > > No it won't. There is no Glide for it. > > You mean Glide 3 doesn't work with the V5? Or is it that Glide 3 > doesn't work with the FX driver? Here's the long story: The original VB/V3 version of Glide was something of a hack. The X server only used PIO and and Glide only used MMIO. The X server would always setup the card in an easily predictable memory layout and Glide took advantage of that. You'd start the X server, it would do it's thing. You'd start a glide app, which would start MMIO and that caused the card to ignore PIO. Glide would just take over the card and keep working. XFree 4.0 comes out, and the X driver uses MMIO for better performance. It also lays out the board dynamically. Now you really need cooperation between Glide and XFree. Glide would have to be written to use the DRI to do that cooperation. That was done as an experiment, but it required making some behavior modifications to Glide/X which meant older Glide programs wouldn't run. So 3dfx decided it wasn't worth persuing. So, the only stand alone Glide that works is V1/V2 and VB/V3. The V5 version was never ported for anything other than running under Mesa in DRI mode. - |Daryll |
From: Klaus N. <kl...@ma...> - 2001-02-16 16:37:45
|
Hi, I have compared again the software-fog in the 'fire'-demo with Mesa-3.4 and Mesa-3.5 and in Mesa-3.5 it is still a lot denser than in the old one. I don't know if this is important or not and if was a bug, I have no idea if it is now or it was before. I haven't try though Mesa-3.4.1. Klaus |
From: Keith W. <ke...@va...> - 2001-02-16 17:13:47
|
Klaus Niederkrueger wrote: > > Hi, > > I have compared again the software-fog in the 'fire'-demo with Mesa-3.4 > and Mesa-3.5 and in Mesa-3.5 it is still a lot denser than in the old one. > > I don't know if this is important or not and if was a bug, I have no idea > if it is now or it was before. > > I haven't try though Mesa-3.4.1. On what driver? I've got the two X11 drivers running side by side & they look identical. Keith |
From: Klaus N. <kl...@ma...> - 2001-02-16 17:26:21
|
On Fri, 16 Feb 2001, Keith Whitwell wrote: > Klaus Niederkrueger wrote: > > > > Hi, > > > > I have compared again the software-fog in the 'fire'-demo with Mesa-3.4 > > and Mesa-3.5 and in Mesa-3.5 it is still a lot denser than in the old one. > > > > I don't know if this is important or not and if was a bug, I have no idea > > if it is now or it was before. > > > > I haven't try though Mesa-3.4.1. > > On what driver? > > I've got the two X11 drivers running side by side & they look identical. > > Keith > Just normal software-rendering. 24bit TrueColor Frame buffer: 24bit R8:G8:B8:A0 I don't know what else could help. Klaus |
From: Brian P. <br...@va...> - 2001-02-16 18:09:14
|
Klaus Niederkrueger wrote: > > On Fri, 16 Feb 2001, Keith Whitwell wrote: > > > Klaus Niederkrueger wrote: > > > > > > Hi, > > > > > > I have compared again the software-fog in the 'fire'-demo with Mesa-3.4 > > > and Mesa-3.5 and in Mesa-3.5 it is still a lot denser than in the old one. > > > > > > I don't know if this is important or not and if was a bug, I have no idea > > > if it is now or it was before. > > > > > > I haven't try though Mesa-3.4.1. > > > > On what driver? > > > > I've got the two X11 drivers running side by side & they look identical. > > > > Keith > > > > Just normal software-rendering. > 24bit TrueColor > Frame buffer: 24bit R8:G8:B8:A0 > > I don't know what else could help. I'm seeing denser fog with 3.5 than 3.4.x too. Strange thing is, I think it looked OK the first time I ran it but subsequent runs look different. Might be an uninitialized variable somewhere. I'm looking into it. The fire demo seems to be the only demo w/ fog that looks different. Tunnel, for example, looks identical with 3.5 and 3.4.x. -Brian |
From: Keith W. <ke...@va...> - 2001-02-16 18:16:15
|
Brian Paul wrote: > > Klaus Niederkrueger wrote: > > > > On Fri, 16 Feb 2001, Keith Whitwell wrote: > > > > > Klaus Niederkrueger wrote: > > > > > > > > Hi, > > > > > > > > I have compared again the software-fog in the 'fire'-demo with Mesa-3.4 > > > > and Mesa-3.5 and in Mesa-3.5 it is still a lot denser than in the old one. > > > > > > > > I don't know if this is important or not and if was a bug, I have no idea > > > > if it is now or it was before. > > > > > > > > I haven't try though Mesa-3.4.1. > > > > > > On what driver? > > > > > > I've got the two X11 drivers running side by side & they look identical. > > > > > > Keith > > > > > > > Just normal software-rendering. > > 24bit TrueColor > > Frame buffer: 24bit R8:G8:B8:A0 > > > > I don't know what else could help. > > I'm seeing denser fog with 3.5 than 3.4.x too. Strange thing is, > I think it looked OK the first time I ran it but subsequent runs > look different. Might be an uninitialized variable somewhere. > I'm looking into it. > > The fire demo seems to be the only demo w/ fog that looks different. > Tunnel, for example, looks identical with 3.5 and 3.4.x. The difference is usually because vertex fog is being used instead of per-pixel. A lot of the DRI drivers show this, but it isn't a bug there as that's what the hardware supports. Keith |
From: Brian P. <br...@va...> - 2001-02-16 18:16:45
|
Brian Paul wrote: > > Klaus Niederkrueger wrote: > > > > On Fri, 16 Feb 2001, Keith Whitwell wrote: > > > > > Klaus Niederkrueger wrote: > > > > > > > > Hi, > > > > > > > > I have compared again the software-fog in the 'fire'-demo with Mesa-3.4 > > > > and Mesa-3.5 and in Mesa-3.5 it is still a lot denser than in the old one. > > > > > > > > I don't know if this is important or not and if was a bug, I have no idea > > > > if it is now or it was before. > > > > > > > > I haven't try though Mesa-3.4.1. > > > > > > On what driver? > > > > > > I've got the two X11 drivers running side by side & they look identical. > > > > > > Keith > > > > > > > Just normal software-rendering. > > 24bit TrueColor > > Frame buffer: 24bit R8:G8:B8:A0 > > > > I don't know what else could help. > > I'm seeing denser fog with 3.5 than 3.4.x too. Strange thing is, > I think it looked OK the first time I ran it but subsequent runs > look different. Might be an uninitialized variable somewhere. > I'm looking into it. > > The fire demo seems to be the only demo w/ fog that looks different. > Tunnel, for example, looks identical with 3.5 and 3.4.x. There's a call to glHint(GL_FOG_HINT, GL_NICEST) which is only compiled in if FX is defined. If the hint is GL_NICEST fog is OK. But if the hint is GL_FASTEST or GL_DONT_CARE the fog is extra dense. That narrows it down... -Brian |
From: Keith W. <ke...@va...> - 2001-02-16 18:20:46
|
Brian Paul wrote: > > Brian Paul wrote: > > > > Klaus Niederkrueger wrote: > > > > > > On Fri, 16 Feb 2001, Keith Whitwell wrote: > > > > > > > Klaus Niederkrueger wrote: > > > > > > > > > > Hi, > > > > > > > > > > I have compared again the software-fog in the 'fire'-demo with Mesa-3.4 > > > > > and Mesa-3.5 and in Mesa-3.5 it is still a lot denser than in the old one. > > > > > > > > > > I don't know if this is important or not and if was a bug, I have no idea > > > > > if it is now or it was before. > > > > > > > > > > I haven't try though Mesa-3.4.1. > > > > > > > > On what driver? > > > > > > > > I've got the two X11 drivers running side by side & they look identical. > > > > > > > > Keith > > > > > > > > > > Just normal software-rendering. > > > 24bit TrueColor > > > Frame buffer: 24bit R8:G8:B8:A0 > > > > > > I don't know what else could help. > > > > I'm seeing denser fog with 3.5 than 3.4.x too. Strange thing is, > > I think it looked OK the first time I ran it but subsequent runs > > look different. Might be an uninitialized variable somewhere. > > I'm looking into it. > > > > The fire demo seems to be the only demo w/ fog that looks different. > > Tunnel, for example, looks identical with 3.5 and 3.4.x. > > There's a call to glHint(GL_FOG_HINT, GL_NICEST) which is only > compiled in if FX is defined. If the hint is GL_NICEST fog is OK. > But if the hint is GL_FASTEST or GL_DONT_CARE the fog is extra > dense. That narrows it down... One change is that swrast (in 3.5) now respects (or tries to respect) that hint -- previously the software rasterizer *always* did pixel fog, now it has the choice. The driver can additionally configure swrast to match what the hardware is doing with _swrast_allow_vertex_fog() and _swrast_allow_pixel_fog(). I'll look over this functionality for unitialized values now. Keith |
From: Brian P. <br...@va...> - 2001-02-16 21:25:18
|
Keith Whitwell wrote: > > Brian Paul wrote: > > > > Brian Paul wrote: > > > > > > Klaus Niederkrueger wrote: > > > > > > > > On Fri, 16 Feb 2001, Keith Whitwell wrote: > > > > > > > > > Klaus Niederkrueger wrote: > > > > > > > > > > > > Hi, > > > > > > > > > > > > I have compared again the software-fog in the 'fire'-demo with Mesa-3.4 > > > > > > and Mesa-3.5 and in Mesa-3.5 it is still a lot denser than in the old one. > > > > > > > > > > > > I don't know if this is important or not and if was a bug, I have no idea > > > > > > if it is now or it was before. > > > > > > > > > > > > I haven't try though Mesa-3.4.1. > > > > > > > > > > On what driver? > > > > > > > > > > I've got the two X11 drivers running side by side & they look identical. > > > > > > > > > > Keith > > > > > > > > > > > > > Just normal software-rendering. > > > > 24bit TrueColor > > > > Frame buffer: 24bit R8:G8:B8:A0 > > > > > > > > I don't know what else could help. > > > > > > I'm seeing denser fog with 3.5 than 3.4.x too. Strange thing is, > > > I think it looked OK the first time I ran it but subsequent runs > > > look different. Might be an uninitialized variable somewhere. > > > I'm looking into it. > > > > > > The fire demo seems to be the only demo w/ fog that looks different. > > > Tunnel, for example, looks identical with 3.5 and 3.4.x. > > > > There's a call to glHint(GL_FOG_HINT, GL_NICEST) which is only > > compiled in if FX is defined. If the hint is GL_NICEST fog is OK. > > But if the hint is GL_FASTEST or GL_DONT_CARE the fog is extra > > dense. That narrows it down... > > One change is that swrast (in 3.5) now respects (or tries to respect) that > hint -- previously the software rasterizer *always* did pixel fog, now it has > the choice. > > The driver can additionally configure swrast to match what the hardware is > doing with _swrast_allow_vertex_fog() and _swrast_allow_pixel_fog(). I'll > look over this functionality for unitialized values now. I think I've gotten to the bottom of this. GL_NICEST mode causes the fog factor to be computed per-fragment from the fragment Z coordinate. It works fine. GL_FASTEST/DONT_CARE computes the fog factor per vertex then linearly interpolates the factor across the triangle. Thing about fire.c is it draws one large polygon for the ground, most of which gets clipped away. We're just linearly interpolating the fog factor in the polygon clipper. Doing a perspective-corrected interpolation would probably improve things. OpenGL doesn't require perspective correct interpolation during clipping and adding it to Mesa in this case could be a bit complicated. By subdividing the ground polygon into smaller quads the problem effectively goes away. I think I'll just clean up fire.c a bit and let it go at that. -Brian |
From: Gareth H. <ga...@va...> - 2001-02-17 18:26:14
|
Gareth Hughes wrote: > > So, if you guys have other things to do, I'd be more than happy to > tackle this problem in the short term (ie. to get a 3.5 release out). I will do this work with the Radeon driver on the mesa-3-5 branch of DRI CVS. This will be the fastest way, otherwise I'd have to go and buy a V3 or port another driver over... -- Gareth |
From: Keith W. <ke...@va...> - 2001-02-17 19:15:20
|
Gareth Hughes wrote: > > Gareth Hughes wrote: > > > > So, if you guys have other things to do, I'd be more than happy to > > tackle this problem in the short term (ie. to get a 3.5 release out). > > I will do this work with the Radeon driver on the mesa-3-5 branch of DRI > CVS. This will be the fastest way, otherwise I'd have to go and buy a > V3 or port another driver over... Of course, to get it working you can simply use the X11 driver... Keith |
From: Gareth H. <ga...@va...> - 2001-02-18 01:41:32
|
Keith Whitwell wrote: > > Of course, to get it working you can simply use the X11 driver... Not a bad idea at all, actually. That *would* be the simplest solution... -- Gareth |
From: Gareth H. <ga...@va...> - 2001-02-21 16:16:33
|
I've been working on this a bit lately, and the biggest stumbling block at the moment is my lack of intimate knowledge of the X11 driver. I will change this at some point perhaps, but in an effort to get this done I'll probably move my work over to a hardware driver. As it stands, there seem to be some inconsistencies between the latest 3.5 sources and the mesa-3-5-branch of DRI CVS (notably swrast/s_quads.[ch] and tnl/t_vb_materials.[ch] have gone). It looks like the i810 still needs t_vb_materials.c, as it uses _tnl_update_material_stage. Keith? -- Gareth |
From: Keith W. <ke...@va...> - 2001-02-21 18:29:53
|
Gareth Hughes wrote: > > I've been working on this a bit lately, and the biggest stumbling block > at the moment is my lack of intimate knowledge of the X11 driver. I > will change this at some point perhaps, but in an effort to get this > done I'll probably move my work over to a hardware driver. > > As it stands, there seem to be some inconsistencies between the latest > 3.5 sources and the mesa-3-5-branch of DRI CVS (notably > swrast/s_quads.[ch] and tnl/t_vb_materials.[ch] have gone). It looks > like the i810 still needs t_vb_materials.c, as it uses > _tnl_update_material_stage. Keith? I've found the vb_materials changes in radeon_context.c and i810_context.c, but I'm pretty sure the Imakefile changes have been committed. Keith |
From: Keith W. <ke...@va...> - 2001-02-21 18:42:34
|
Keith Whitwell wrote: > > Gareth Hughes wrote: > > > > I've been working on this a bit lately, and the biggest stumbling block > > at the moment is my lack of intimate knowledge of the X11 driver. I > > will change this at some point perhaps, but in an effort to get this > > done I'll probably move my work over to a hardware driver. > > > > As it stands, there seem to be some inconsistencies between the latest > > 3.5 sources and the mesa-3-5-branch of DRI CVS (notably > > swrast/s_quads.[ch] and tnl/t_vb_materials.[ch] have gone). It looks > > like the i810 still needs t_vb_materials.c, as it uses > > _tnl_update_material_stage. Keith? > > I've found the vb_materials changes in radeon_context.c and i810_context.c, > but I'm pretty sure the Imakefile changes have been committed. The OSmesa makefile still uses ../swrast/?*.o to reference objects; you may need to remove those .o files to proceed. Keith |