On Tue Jun 18 14:03:37 2024 +0000, Alexandros Frantzis wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/5844/diffs?diff_id=118349&start_sha=ac8befedea21efd15141d61f5ae0059c72756c60#50d0467261bda62e69cb439805b6af18beaf754b_533_545)
I created a small test program to check the edge cases: https://gitlab.collabora.com/alf/wglgetattrib
The results are: [wgl-get-attrib.txt](/uploads/223777137b7c8ce6d7b67f5b6538f7b9/wgl-get-attrib.txt) (taken from both https://testbot.winehq.org/JobDetails.pl?Key=146370 and local runs).
Here are my notes:
if (!attributes || !values) return GL_FALSE;
The results indicate that drivers access the attributes/values on an as-needed basis and assume they are valid if they do access them, so I haven't included the check.
/* should index be checked after or before? */
NVIDIA seems to check before, whereas AMD, Intel and winex11 master check after. I have left the check after (which I think is the spec-compliant approach anyway).
I also checked the layer value handling, where AMD/NVIDIA seem to be overly strict and I think non-compliant (they don't ignore invalid layer values even if the attributes queried don't need them, see last test in wglgetattrib). Intel is more compliant, and I chose to go this way too (since this direction is generally safe).
call SetLastError?
The drivers consistently set `0xC007000D` on error (if they set something, AMD doesn't for example), which, from what I could figure out, seems to be NTSTATUS created with the win32 error `ERROR_INVALID_DATA` ( `= STATUS_SEVERITY_ERROR << 30 | FACILITY_NTWIN32 << 16 | ERROR_INVALID_DATA`). The other option would be that this comes from `STATUS_INVALID_PARAMETER | FACILITY_NTWIN32 << 16` but I am not sure if this is a valid construction. In any case, I updated the code in v2 to set this error value.