Only use the default SetPixelFormat function if the format is unset and the window is private. If the window isn't private, use wglSetPixelFormatWINE, which allows for another application to change the pixel format.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- I'm not sure if this is the correct way to do this, so you'll have to let me know if there's a better way. Currently, the application I'm trying to get work sets the pixel format after wined3d's initial format set. So, in this case, I'm assuming it'd make sense to only use the default SetPixelFormat if we know the window is private to wined3d. --- dlls/wined3d/context_gl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 123214afd5d..bbed7f46875 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -1196,7 +1196,7 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte current = gl_info->gl_ops.wgl.p_wglGetPixelFormat(dc); if (current == format) goto success;
- if (!current) + if (!current && private) { if (!SetPixelFormat(dc, format, NULL)) {
Add the ability to check if the pixel format was changed by wined3d, and if it was, allow the application to change it with a regular SetPixelFormat call.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- I have no clue why certain lines I didn't edit are in this patch. Not sure if it was something I did, but I couldn't see a difference between them. --- dlls/winex11.drv/opengl.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index c44c587bf14..e2643a9f37d 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -249,6 +249,7 @@ struct gl_drawable SIZE pixmap_size; /* pixmap size for GLXPixmap drawables */ int swap_interval; BOOL refresh_swap_interval; + BOOL mutable_pf; };
enum glx_swap_control_method @@ -532,7 +533,7 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) done: if(vis) XFree(vis); if(ctx) { - pglXMakeCurrent(gdi_display, None, NULL); + pglXMakeCurrent(gdi_display, None, NULL); pglXDestroyContext(gdi_display, ctx); } if (win != root) XDestroyWindow( gdi_display, win ); @@ -751,7 +752,7 @@ static const char *debugstr_fbconfig( GLXFBConfig fbconfig )
static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, struct wgl_pbuffer* pbuf) { int nAttribs = 0; - unsigned cur = 0; + unsigned cur = 0; int attr, pop; int drawattrib = 0; int nvfloatattrib = GLX_DONT_CARE; @@ -815,7 +816,7 @@ static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, struct wgl_ case WGL_TYPE_RGBA_FLOAT_ATI: pixelattrib = GLX_RGBA_FLOAT_BIT; break ; case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT: pixelattrib = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT; break ; default: - ERR("unexpected PixelType(%x)\n", pop); + ERR("unexpected PixelType(%x)\n", pop); } break;
@@ -924,7 +925,7 @@ static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, struct wgl_ case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV: case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV: case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV: - /** cannot be converted, see direct handling on + /** cannot be converted, see direct handling on * - wglGetPixelFormatAttribivARB * TODO: wglChoosePixelFormat */ @@ -1306,7 +1307,8 @@ static GLXContext create_glxcontext(Display *display, struct wgl_context *contex /*********************************************************************** * create_gl_drawable */ -static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel_format *format, BOOL known_child ) +static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel_format *format, BOOL known_child, + BOOL mutable_pf ) { struct gl_drawable *gl, *prev; XVisualInfo *visual = format->visual; @@ -1326,6 +1328,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel gl->refresh_swap_interval = TRUE; gl->format = format; gl->ref = 1; + gl->mutable_pf = mutable_pf;
if (!known_child && !GetWindow( hwnd, GW_CHILD ) && GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow()) /* childless top-level window */ { @@ -1384,13 +1387,13 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel /*********************************************************************** * set_win_format */ -static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format ) +static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format, BOOL mutable_pf ) { struct gl_drawable *gl;
if (!format->visual) return FALSE;
- if (!(gl = create_gl_drawable( hwnd, format, FALSE ))) return FALSE; + if (!(gl = create_gl_drawable( hwnd, format, FALSE, mutable_pf ))) return FALSE;
TRACE( "created GL drawable %lx for win %p %s\n", gl->drawable, hwnd, debugstr_fbconfig( format->fbconfig )); @@ -1437,12 +1440,14 @@ static BOOL set_pixel_format(HDC hdc, int format, BOOL allow_change) if ((gl = get_gl_drawable( hwnd, hdc ))) { int prev = pixel_format_index( gl->format ); + BOOL mutable_pf = gl->mutable_pf; release_gl_drawable( gl ); - return prev == format; /* cannot change it if already set */ + if (!mutable_pf) + return prev == format; /* cannot change it if already set */ } }
- return set_win_format( hwnd, fmt ); + return set_win_format( hwnd, fmt, allow_change ); }
@@ -1461,7 +1466,7 @@ void sync_gl_drawable( HWND hwnd, BOOL known_child ) if (!known_child) break; /* Still a childless top-level window */ /* fall through */ case DC_GL_PIXMAP_WIN: - if (!(new = create_gl_drawable( hwnd, old->format, known_child ))) break; + if (!(new = create_gl_drawable( hwnd, old->format, known_child, FALSE ))) break; mark_drawable_dirty( old, new ); XFlush( gdi_display ); TRACE( "Recreated GL drawable %lx to replace %lx\n", new->drawable, old->drawable ); @@ -1498,7 +1503,7 @@ void set_gl_drawable_parent( HWND hwnd, HWND parent ) return; }
- if ((new = create_gl_drawable( hwnd, old->format, FALSE ))) + if ((new = create_gl_drawable( hwnd, old->format, FALSE, FALSE ))) { mark_drawable_dirty( old, new ); release_gl_drawable( new ); @@ -2140,7 +2145,7 @@ static struct wgl_pbuffer *X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat object->fmt = fmt;
PUSH2(attribs, GLX_PBUFFER_WIDTH, iWidth); - PUSH2(attribs, GLX_PBUFFER_HEIGHT, iHeight); + PUSH2(attribs, GLX_PBUFFER_HEIGHT, iHeight); while (piAttribList && 0 != *piAttribList) { int attr_v; switch (*piAttribList) { @@ -2686,7 +2691,7 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int continue;
case WGL_SUPPORT_OPENGL_ARB: - piValues[i] = GL_TRUE; + piValues[i] = GL_TRUE; continue;
case WGL_ACCELERATION_ARB: @@ -2734,14 +2739,14 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int case WGL_BIND_TO_TEXTURE_RGBA_ARB: if (!use_render_texture_emulation) { piValues[i] = GL_FALSE; - continue; + continue; } curGLXAttr = GLX_RENDER_TYPE; if (!fmt) goto pix_error; hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp); if (hTest) goto get_error; if (GLX_COLOR_INDEX_BIT == tmp) { - piValues[i] = GL_FALSE; + piValues[i] = GL_FALSE; continue; } hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &tmp); @@ -2896,8 +2901,8 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, piValues + i); if (hTest) goto get_error; curGLXAttr = 0; - } else { - piValues[i] = GL_FALSE; + } else { + piValues[i] = GL_FALSE; } } return GL_TRUE;
On 4/16/21 3:01 PM, Connor McAdams wrote:
Add the ability to check if the pixel format was changed by wined3d, and if it was, allow the application to change it with a regular SetPixelFormat call.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com
I have no clue why certain lines I didn't edit are in this patch. Not sure if it was something I did, but I couldn't see a difference between them.
Your editor seems to have automatically stripped trailing spaces from lines. While trailing spaces are undesirable, we prefer leaving them alone unless already changing the line, so as not to introduce extra noise into git-blame.
On Fri, Apr 16, 2021 at 04:01:25PM -0400, Connor McAdams wrote:
Only use the default SetPixelFormat function if the format is unset and the window is private. If the window isn't private, use wglSetPixelFormatWINE, which allows for another application to change the pixel format.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com
I'm not sure if this is the correct way to do this, so you'll have to let me know if there's a better way. Currently, the application I'm trying to get work sets the pixel format after wined3d's initial format set. So, in this case, I'm assuming it'd make sense to only use the default SetPixelFormat if we know the window is private to wined3d.
dlls/wined3d/context_gl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 123214afd5d..bbed7f46875 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -1196,7 +1196,7 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte current = gl_info->gl_ops.wgl.p_wglGetPixelFormat(dc); if (current == format) goto success;
- if (!current)
- if (!current && private) { if (!SetPixelFormat(dc, format, NULL)) {
-- 2.25.1
Actually, I think this is a bad idea, it'd be better to check for private inside of the 'if (!current)' check and switch between the two functions there. I'll fix it and send a v2.