| Summary: | Setting GL_ACCELERATED_VISUAL to 1 forces software rendering in Windows XP | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jesse Anders <jesseanders> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | jesseanders |
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | Windows (XP) | ||
Just to provide some additional info, here's a couple of threads I found that seem to refer to the same issue: http://forums.libsdl.org/viewtopic.php?t=1611&highlight=sdlglacceleratedvisual http://www.dsource.org/forums/viewtopic.php?t=4524&sid=0485609470a131937c876271f4d88125 Fixed, thanks! http://hg.libsdl.org/SDL/rev/6ac8b0ac645e Great, works perfectly :) On a related note, it looks like querying the SDL_GL_ACCELERATED_VISUAL isn't implemented yet. You probably already know all this, but I think in Windows it can be determined whether hardware acceleration is available by using wglGetPixelFormatAttribivARB() (if the function is available). Alternatively, I think it also works to get the pixel format using DescribePixelFormat(), and then check the dwFlags field of the returned pixel format descriptor. If neither the PFD_GENERIC_FORMAT nor the PFD_GENERIC_ACCELERATED flag is set, then hardware acceleration is available. (I don't know conclusively that this is correct, but I tried it and it seems to return the correct results.) Thanks! Do you want to write up a new bug and patch for the query side of it? Sure - I didn't file a bug report 'cause it seemed like more of an unimplemented feature than a bug, but I'll go ahead and file one for tracking purposes. As for a patch, I haven't attempted to modify the SDL source code to that degree as of yet (I'm guessing the query would need to go through the same sort of platform-specific dispatch system that's used elsewhere), but I'll certainly give it a go and see if I can come up with anything :) (It's certainly not a critical feature by any means - it was just something I happened to notice.) Well, you can certainly query the attribute now, but there's a comment:
case SDL_GL_ACCELERATED_VISUAL:
{
/* FIXME: How do we get this information? */
*value = (_this->gl_config.accelerated != 0);
We can just make sure the 'accelerated' member is correct after creating the context, and then remove the FIXME. :)
Right, of course. You can query the attribute if you want; it's just not implemented internally. But yeah, just setting the value of 'accelerated' after the context is created should do it. Unless someone beats me to it, I'll see if I can put together a patch :) Thanks! |
It seems that in Windows XP, setting SDL_GL_ACCELERATED_VISUAL to 1 actually disables hardware acceleration and puts OpenGL in software mode. In the source code, the corresponding WGL attribute is first set here: *iAttr++ = WGL_ACCELERATION_ARB; *iAttr++ = WGL_FULL_ACCELERATION_ARB; Later, this code: if (_this->gl_config.accelerated >= 0) { *iAttr++ = WGL_ACCELERATION_ARB; *iAttr++ = (_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB : WGL_NO_ACCELERATION_ARB); } Sets it again if SDL_GL_ACCELERATED_VISUAL has a value other than the default. Is it ok to set the same attribute multiple times like this? Or would it be better to set it only once? E.g. (untested): *iAttr++ = WGL_ACCELERATION_ARB; if (_this->gl_config.accelerated == -1) { *iAttr++ = WGL_FULL_ACCELERATION_ARB; } else if (_this->gl_config.accelerated == 0) { *iAttr++ = WGL_NO_ACCELERATION_ARB; } else { *iAttr++ = WGL_GENERIC_ACCELERATION_ARB; } Regarding the attributes that are assigned, the SDL docs say that leaving SDL_GL_ACCELERATED_VISUAL at its default allows either hardware or software rendering to be used, but as it is now, it looks like hardware acceleration is requested in this case. More importantly, the documentation I found states that WGL_GENERIC_ACCELERATION_ARB asks for an MDC driver, which, although I don't know much about this topic, doesn't seem like the correct choice here. As mentioned previously, the end effect is that requesting hardware acceleration in Windows XP actually forces the renderer into software mode (on my system at least), which I'm guessing isn't the desired behavior.