Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apparent misfire (wrong extension loaded) when generating GL_EXT_texture_filter_minmax #126

Closed
mcclure opened this issue Jan 11, 2018 · 6 comments

Comments

@mcclure
Copy link

mcclure commented Jan 11, 2018

Short version: Requesting EXT_texture_filter_minmax gave me EXT_raster_multisample instead?

Long version:
I ran GLAD off the webservice. The comment block in glad.c was

/*

    OpenGL, OpenGL ES loader generated by glad 0.1.16a0 on Wed Jan 10 20:23:31 2018.

    Language/Generator: C/C++
    Specification: gl
    APIs: gl=3.3, gles2=3.0
    Profile: core
    Extensions:
        GL_ARB_texture_storage,
        GL_EXT_texture_compression_s3tc,
        GL_EXT_texture_filter_anisotropic,
        GL_EXT_texture_filter_minmax,
        GL_EXT_texture_sRGB,
        GL_OVR_multiview
    Loader: False
    Local files: False
    Omit khrplatform: False

    Commandline:
        --profile="core" --api="gl=3.3,gles2=3.0" --generator="c" --spec="gl" --no-loader --extensions="GL_ARB_texture_storage,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_filter_minmax,GL_EXT_texture_sRGB,GL_OVR_multiview"
    Online:
        http://glad.dav1d.de/#profile=core&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.0&extensions=GL_ARB_texture_storage&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_filter_minmax&extensions=GL_EXT_texture_sRGB&extensions=GL_OVR_multiview
*/

The generated files replaced, in version control, a version of glad.c and glad.h produced by exactly the same arguments except no GL_EXT_texture_filter_minmax. The diff was as follows:
(This diff has been slightly hand edited for example I added some printfs.)

addminmax.zip
)

The following issues are seen:

  1. By code inspection, the expected symbols for GL_EXT_texture_filter_minmax are not generated by GLAD. The docs for the extension are here. I expect TEXTURE_REDUCTION_MODE_EXT and WEIGHTED_AVERAGE_EXT symbols. These are not in the diff, however in the diff for GLAD I do find symbols such as glRasterSamplesEXT, RASTER_SAMPLES_EXT and MULTISAMPLE_RASTERIZATION_ALLOWED_EXT being defined AND LOADED IN load_GL_EXT_texture_filter_minmax(). In fact GLAD appears to be creating exactly those symbols used in EXT_raster_multisample, which I did not request (docs here).
  2. When the code is compiled, GLAD_GL_EXT_texture_filter_minmax is a true value, yet the code:
#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366
#define GL_WEIGHTED_AVERAGE_EXT 0x9367
glTexParameteri(canvas->texture.id, GL_TEXTURE_REDUCTION_MODE_EXT, result);

Results in the OpenGL error 1280 Invalid Enum being generated.

Conclusion: GLAD appears to be reading the wrong extension out of the spec and mislabeling it as GL_EXT_texture_filter_minmax.

@Dav1dde Dav1dde added the bug label Jan 11, 2018
@mcclure
Copy link
Author

mcclure commented Jan 11, 2018

Note: I've identified my glTexParameteri call is incorrect, so it is unsurprising that fails (ie: issue "2" above is not an issue). However, GLAD should still be generating the GL_TEXTURE_REDUCTION_MODE_EXT and GL_WEIGHTED_AVERAGE_EXT constants.

@Dav1dde
Copy link
Owner

Dav1dde commented Jan 11, 2018

Thanks for the report, I'll dig into it when I find some time this weekend.

@Dav1dde
Copy link
Owner

Dav1dde commented Jan 14, 2018

This looks like a bug in the specifications, looking into gl.xml:

Definition for TEXTURE_FILTER_MINIMAX:

        <extension name="GL_EXT_texture_filter_minmax" supported="gl|glcore|gles2">
            <require>
                <enum name="GL_RASTER_MULTISAMPLE_EXT"/>
                <enum name="GL_RASTER_SAMPLES_EXT"/>
                <enum name="GL_MAX_RASTER_SAMPLES_EXT"/>
                <enum name="GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT"/>
                <enum name="GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT"/>
                <enum name="GL_EFFECTIVE_RASTER_SAMPLES_EXT"/>
                <command name="glRasterSamplesEXT"/>
            </require>
        </extension>

And the one for RASTER_MULTISAMPLE:

        <extension name="GL_EXT_raster_multisample" supported="gl|glcore|gles2">
            <require>
                <enum name="GL_RASTER_MULTISAMPLE_EXT"/>
                <enum name="GL_RASTER_SAMPLES_EXT"/>
                <enum name="GL_MAX_RASTER_SAMPLES_EXT"/>
                <enum name="GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT"/>
                <enum name="GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT"/>
                <enum name="GL_EFFECTIVE_RASTER_SAMPLES_EXT"/>
                <command name="glRasterSamplesEXT"/>
            </require>
        </extension>

Looking at GL_ARB_texture_filter_minmax, these definitions appear to be correct:

        <extension name="GL_ARB_texture_filter_minmax" supported="gl|glcore">
            <require>
                <enum name="GL_TEXTURE_REDUCTION_MODE_ARB"/>
                <enum name="GL_WEIGHTED_AVERAGE_ARB"/>
            </require>
        </extension>

I'll report it to Khronos.

@Dav1dde
Copy link
Owner

Dav1dde commented Jan 14, 2018

Once the bug is fixed in the registry glad will automatically pull in the changes and everything should work as it should (gonna leave the issue open for now).

Good find!

@Dav1dde
Copy link
Owner

Dav1dde commented Jan 14, 2018

Khronos fixed the bug, I am closing it here as well. Everything should be fine after the specification reset on the website in ~12 Hours.

@Dav1dde Dav1dde closed this as completed Jan 14, 2018
@mcclure
Copy link
Author

mcclure commented Jan 16, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants