[PATCH 4/5] wined3d: Add a setting for the maximum OpenGL version to use.

Henri Verbeet hverbeet at gmail.com
Tue Jul 7 09:58:54 CDT 2015


On 6 July 2015 at 22:20, Matteo Bruni <mbruni at codeweavers.com> wrote:
>          if (context_debug_output_enabled(gl_info))
> +            ctx_flags = WGL_CONTEXT_DEBUG_BIT_ARB;
> +        ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
> +        ctx_attribs[ctx_attrib_idx++] = gl_info->selected_gl_version >> 16;
> +        ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_MINOR_VERSION_ARB;
> +        ctx_attribs[ctx_attrib_idx++] = gl_info->selected_gl_version & 0xffff;
> +        if (gl_info->selected_gl_version >= MAKEDWORD_VERSION(3, 2))
> +            ctx_flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
> +        if (ctx_flags)
>          {
>              ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_FLAGS_ARB;
> -            ctx_attribs[ctx_attrib_idx++] = WGL_CONTEXT_DEBUG_BIT_ARB;
> +            ctx_attribs[ctx_attrib_idx++] = ctx_flags;
>          }
>          ctx_attribs[ctx_attrib_idx] = 0;
>
>          if (!(ctx = gl_info->p_wglCreateContextAttribsARB(hdc, share_ctx, ctx_attribs)))
>          {
> -            ERR("Failed to create a WGL context.\n");
> -            context_release(ret);
> -            goto out;
> +            if (ctx_flags & WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB)
> +            {
> +                ctx_attribs[ctx_attrib_idx - 1] &= ~WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
> +                if (!(ctx = gl_info->p_wglCreateContextAttribsARB(hdc, share_ctx, ctx_attribs)))
> +                {
> +                    ERR("Failed to create a WGL context.\n");
> +                    context_release(ret);
> +                    goto out;
> +                }
> +            }
>          }
>      }
I think this is starting to become complex enough that we'd probably
benefit from a helper function to be able to share some of this with
wined3d_adapter_init().

> +    glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &context_profile);
> +    if (glGetError() != GL_NO_ERROR)
> +        context_profile = 0;
Should this perhaps just check for
gl_info->p_wglCreateContextAttribsARB instead of eating errors?

> +    for (i = 0; i < ARRAY_SIZE(supported_gl_versions); ++i)
> +    {
> +        if (supported_gl_versions[i] <= wined3d_settings.max_gl_version)
> +        {
> +            if (supported_gl_versions[i] != wined3d_settings.max_gl_version)
> +                ERR_(winediag)("Requested GL version %u.%u which is unsupported, trying version %u.%u instead.\n",
> +                        wined3d_settings.max_gl_version >> 16, wined3d_settings.max_gl_version & 0xffff,
> +                        supported_gl_versions[i] >> 16, supported_gl_versions[i] & 0xffff);
> +            break;
> +        }
> +    }
> +    if (i == ARRAY_SIZE(supported_gl_versions))
> +    {
> +        ERR_(winediag)("Requested invalid GL version %u.%u.\n",
> +                wined3d_settings.max_gl_version >> 16, wined3d_settings.max_gl_version & 0xffff);
> +        i = ARRAY_SIZE(supported_gl_versions) - 1;
> +    }
This is a bit different than what I had in mind. I think
max_gl_version should just be a maximum, and e.g. specifying 4.4
should just result in 3.2 at the moment. I think the winediag message
should just happen if the registry setting is set, regardless of its
actual value. (Except possibly if it's equal to the default value.)
I.e. we also want to know if someone sets e.g. 3.2 while the default
is currently 1.0 when reporting a bug.

> +        if (!get_config_key(hkey, appkey, "MaxGLVersion", buffer, size))
> +        {
> +            unsigned int major, minor;
> +
> +            if (sscanf(buffer, "%u.%u", &major, &minor) == 2)
> +                wined3d_settings.max_gl_version = MAKEDWORD_VERSION(major, minor);
> +            else
> +                ERR_(winediag)("Couldn't parse the requested maximum OpenGL version.\n");
> +        }
I'd make this a DWORD, if nothing else for consistency with
MaxShaderModelVS etc.
Perhaps "MaxVersionGL" would also more consistent for the naming, I'm not sure.



More information about the wine-devel mailing list