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

Matteo Bruni matteo.mystral at gmail.com
Tue Jul 7 11:37:16 CDT 2015


2015-07-07 16:58 GMT+02:00 Henri Verbeet <hverbeet at gmail.com>:
> 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?

You mean just check whether wglCreateContextAttribsARB succeeded for a
GL version >= 3.2? That should work, although it might be a bit
awkward (but not necessarily more than the current code).

>> +    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.

Yeah, I was unsure here and I like your suggestion.

>> +        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.

Hmm, how would you expect the (major, minor) version to be encoded in
the registry DWORD? Same as MAKEDWORD_VERSION()?

> Perhaps "MaxVersionGL" would also more consistent for the naming, I'm not sure.

I'm not sure that's better overall but I'm not attached to
"MaxGLVersion" either. I'll go with "MaxVersionGL" unless I'll find it
to particularly hurt my eyes ;)



More information about the wine-devel mailing list