Repository: brendanzab/gl-rs (language: rust)

Issue:
Missing `UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER`
It is defined as a valid enum here:
https://www.opengl.org/sdk/docs/man3/xhtml/glGetActiveUniformBlock.xml

Is it a bug in the GL spec that you parse?

My glxinfo: https://gist.github.com/kvark/fe9f69f1dc84d3ff9621
Reports that OpenGL Core 3.3 is supported, and I see `GL_ARB_uniform_buffer_object` in the extension list.



Discussion / hints:
It's parsed from here https://raw.githubusercontent.com/bjz/khronos-api/master/gl.xml and it is defined at line 6015. So it must be a bug in the generator.

@csherratt Thanks for checking this out! It's good news, since fixing the spec would take a while :)

o_o

Weird.

Do you think it is supported in the version of the spec your are generating for? See [_custom loader configuration_](https://github.com/bjz/gl-rs#custom-loader-configuration) part of the README for details

@bjz I didn't change the defaults in gl-rs. Dunno what version it compiles for (don't have access here).
However, I verified that UBOs are core since [GL-3.1](http://www.opengl.org/wiki/GLAPI/glGetActiveUniformBlock), and geometry shaders appear only in [GL-3.2](http://www.opengl.org/wiki/Geometry_Shader), so theoretically this situation is possible if the bindings were generated for GL-3.1...

Judging by the command line, GL-4.3 is the binding target:

> bin/glrsgen --namespace gl --api gl --profile core --version 4.3 --xml deps/khronos-api/gl.xml   > src/gl.rs

Hence, missing definition is still a bug.

It could also be a bug in sax-rs?

Are the other symbols in the extension generated? Here is the definition from the xml:

``` xml
    <enums namespace="GL" start="0x8A00" end="0x8A7F" vendor="APPLE">
        <enum value="0x8A00" name="GL_VERTEX_ATTRIB_MAP1_APPLE"/>
        <enum value="0x8A01" name="GL_VERTEX_ATTRIB_MAP2_APPLE"/>
        <enum value="0x8A02" name="GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE"/>
        <enum value="0x8A03" name="GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE"/>
        <enum value="0x8A04" name="GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE"/>
        <enum value="0x8A05" name="GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE"/>
        <enum value="0x8A06" name="GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE"/>
        <enum value="0x8A07" name="GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE"/>
        <enum value="0x8A08" name="GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE"/>
        <enum value="0x8A09" name="GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE"/>
        <enum value="0x8A0A" name="GL_DRAW_PIXELS_APPLE"/>
        <enum value="0x8A0B" name="GL_FENCE_APPLE"/>
        <enum value="0x8A0C" name="GL_ELEMENT_ARRAY_APPLE"/>
        <enum value="0x8A0D" name="GL_ELEMENT_ARRAY_TYPE_APPLE"/>
        <enum value="0x8A0E" name="GL_ELEMENT_ARRAY_POINTER_APPLE"/>
        <enum value="0x8A0F" name="GL_COLOR_FLOAT_APPLE"/>
            <unused start="0x8A10" comment="Unknown extension (Khronos bug 632)"/>
            <!-- <enum value="0x8A10" name="GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE"/> -->
        <enum value="0x8A11" name="GL_UNIFORM_BUFFER"/>
        <enum value="0x8A12" name="GL_BUFFER_SERIALIZED_MODIFY_APPLE"/>
        <enum value="0x8A13" name="GL_BUFFER_FLUSHING_UNMAP_APPLE"/>
        <enum value="0x8A14" name="GL_AUX_DEPTH_STENCIL_APPLE"/>
        <enum value="0x8A15" name="GL_PACK_ROW_BYTES_APPLE"/>
        <enum value="0x8A16" name="GL_UNPACK_ROW_BYTES_APPLE"/>
            <unused start="0x8A17" end="0x8A18"/>
        <enum value="0x8A19" name="GL_RELEASED_APPLE"/>
        <enum value="0x8A1A" name="GL_VOLATILE_APPLE"/>
        <enum value="0x8A1B" name="GL_RETAINED_APPLE"/>
        <enum value="0x8A1C" name="GL_UNDEFINED_APPLE"/>
        <enum value="0x8A1D" name="GL_PURGEABLE_APPLE"/>
            <unused start="0x8A1E"/>
        <enum value="0x8A1F" name="GL_RGB_422_APPLE"/>
            <unused start="0x8A20" end="0x8A27"/>
        <enum value="0x8A28" name="GL_UNIFORM_BUFFER_BINDING"/>
        <enum value="0x8A29" name="GL_UNIFORM_BUFFER_START"/>
        <enum value="0x8A2A" name="GL_UNIFORM_BUFFER_SIZE"/>
        <enum value="0x8A2B" name="GL_MAX_VERTEX_UNIFORM_BLOCKS"/>
        <enum value="0x8A2C" name="GL_MAX_GEOMETRY_UNIFORM_BLOCKS"/>
        <enum value="0x8A2D" name="GL_MAX_FRAGMENT_UNIFORM_BLOCKS"/>
        <enum value="0x8A2E" name="GL_MAX_COMBINED_UNIFORM_BLOCKS"/>
        <enum value="0x8A2F" name="GL_MAX_UNIFORM_BUFFER_BINDINGS"/>
        <enum value="0x8A30" name="GL_MAX_UNIFORM_BLOCK_SIZE"/>
        <enum value="0x8A31" name="GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS"/>
        <enum value="0x8A32" name="GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS"/>
        <enum value="0x8A33" name="GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS"/>
        <enum value="0x8A34" name="GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT"/>
        <enum value="0x8A35" name="GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH"/>
        <enum value="0x8A36" name="GL_ACTIVE_UNIFORM_BLOCKS"/>
        <enum value="0x8A37" name="GL_UNIFORM_TYPE"/>
        <enum value="0x8A38" name="GL_UNIFORM_SIZE"/>
        <enum value="0x8A39" name="GL_UNIFORM_NAME_LENGTH"/>
        <enum value="0x8A3A" name="GL_UNIFORM_BLOCK_INDEX"/>
        <enum value="0x8A3B" name="GL_UNIFORM_OFFSET"/>
        <enum value="0x8A3C" name="GL_UNIFORM_ARRAY_STRIDE"/>
        <enum value="0x8A3D" name="GL_UNIFORM_MATRIX_STRIDE"/>
        <enum value="0x8A3E" name="GL_UNIFORM_IS_ROW_MAJOR"/>
        <enum value="0x8A3F" name="GL_UNIFORM_BLOCK_BINDING"/>
        <enum value="0x8A40" name="GL_UNIFORM_BLOCK_DATA_SIZE"/>
        <enum value="0x8A41" name="GL_UNIFORM_BLOCK_NAME_LENGTH"/>
        <enum value="0x8A42" name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS"/>
        <enum value="0x8A43" name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"/>
        <enum value="0x8A44" name="GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"/>
        <enum value="0x8A45" name="GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER"/>
        <enum value="0x8A46" name="GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"/>
            <unused start="0x8A47"/>
        <enum value="0x8A48" name="GL_TEXTURE_SRGB_DECODE_EXT"/>
        <enum value="0x8A49" name="GL_DECODE_EXT"/>
        <enum value="0x8A4A" name="GL_SKIP_DECODE_EXT"/>
            <unused start="0x8A4B" end="0x8A4E"/>
        <enum value="0x8A4F" name="GL_PROGRAM_PIPELINE_OBJECT_EXT"/>
            <unused start="0x8A50"/>
        <enum value="0x8A51" name="GL_RGB_RAW_422_APPLE"/>
        <enum value="0x8A52" name="GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT"/>
        <enum value="0x8A53" name="GL_SYNC_OBJECT_APPLE"/>
        <enum value="0x8A54" name="GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT"/>
        <enum value="0x8A55" name="GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT"/>
        <enum value="0x8A56" name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT"/>
        <enum value="0x8A57" name="GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT"/>
            <unused start="0x8A58" end="0x8A7F"/>
    </enums>
```

``` xml
        <extension name="GL_ARB_uniform_buffer_object" supported="gl|glcore">
            <require>
                <enum name="GL_UNIFORM_BUFFER"/>
                <enum name="GL_UNIFORM_BUFFER_BINDING"/>
                <enum name="GL_UNIFORM_BUFFER_START"/>
                <enum name="GL_UNIFORM_BUFFER_SIZE"/>
                <enum name="GL_MAX_VERTEX_UNIFORM_BLOCKS"/>
                <enum name="GL_MAX_GEOMETRY_UNIFORM_BLOCKS"/>
                <enum name="GL_MAX_FRAGMENT_UNIFORM_BLOCKS"/>
                <enum name="GL_MAX_COMBINED_UNIFORM_BLOCKS"/>
                <enum name="GL_MAX_UNIFORM_BUFFER_BINDINGS"/>
                <enum name="GL_MAX_UNIFORM_BLOCK_SIZE"/>
                <enum name="GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS"/>
                <enum name="GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS"/>
                <enum name="GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS"/>
                <enum name="GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT"/>
                <enum name="GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH"/>
                <enum name="GL_ACTIVE_UNIFORM_BLOCKS"/>
                <enum name="GL_UNIFORM_TYPE"/>
                <enum name="GL_UNIFORM_SIZE"/>
                <enum name="GL_UNIFORM_NAME_LENGTH"/>
                <enum name="GL_UNIFORM_BLOCK_INDEX"/>
                <enum name="GL_UNIFORM_OFFSET"/>
                <enum name="GL_UNIFORM_ARRAY_STRIDE"/>
                <enum name="GL_UNIFORM_MATRIX_STRIDE"/>
                <enum name="GL_UNIFORM_IS_ROW_MAJOR"/>
                <enum name="GL_UNIFORM_BLOCK_BINDING"/>
                <enum name="GL_UNIFORM_BLOCK_DATA_SIZE"/>
                <enum name="GL_UNIFORM_BLOCK_NAME_LENGTH"/>
                <enum name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS"/>
                <enum name="GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"/>
                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"/>
                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER"/>
                <enum name="GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"/>
                <enum name="GL_INVALID_INDEX"/>
                <command name="glGetUniformIndices"/>
                <command name="glGetActiveUniformsiv"/>
                <command name="glGetActiveUniformName"/>
                <command name="glGetUniformBlockIndex"/>
                <command name="glGetActiveUniformBlockiv"/>
                <command name="glGetActiveUniformBlockName"/>
                <command name="glUniformBlockBinding"/>
            </require>
        </extension>
```

The uniform buffer object functions are definitely there (see our `device::dev::shade` implementation in gfx-rs). As for the definitions, `GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER` works fine, and so does the `GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER`.

I can confirm that when using the default settings `GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER`  is not generated for me either:

``` rust
// ...
pub static UNIFORM_BLOCK_NAME_LENGTH: GLenum = 0x8A41;
pub static UNIFORM_BLOCK_ACTIVE_UNIFORMS: GLenum = 0x8A42;
pub static UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: GLenum = 0x8A43;
pub static UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: GLenum = 0x8A44;
pub static UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: GLenum = 0x8A46;
// ...
```

It's unlikely that the issue came from sax, but we should check again now that it has been replaced by another parser.

I just checked and it's still not defined.
(you can easily check by running `cargo doc`)

I think that this issue comes from the git repository of `khronos-api` (which is not official).

If you search for `GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER` in [this file](https://raw.githubusercontent.com/scoopr/khronos-api/master/gl.xml) coming from the git repo, you get 2 references.

If you search the same string in [this official file](https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml), you get 3 references. The additional reference is the missing one, as it is in the `<feature api="gl" name="GL_VERSION_3_1" number="3.1">` element.


Fix patch:
diff --git a/.gitmodules b/.gitmodules
index 94c27c05..ce95f69c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
 [submodule "deps/khronos-api"]
 	path = deps/khronos-api
-	url = https://github.com/bjz/khronos-api.git
+	url = https://github.com/capnm/Khronos_XML_API
diff --git a/deps/khronos-api b/deps/khronos-api
index 95c43bdb..31765e5b 160000
--- a/deps/khronos-api
+++ b/deps/khronos-api
@@ -1,1 +1,1 @@
-Subproject commit 95c43bdb7dd4e69145fa0025d142cec7cae89349
+Subproject commit 31765e5b0d656812d4f700cbedaa09baf10a7c5a
diff --git a/src/gl/lib.rs b/src/gl/lib.rs
index 93ad093f..ce7eb049 100644
--- a/src/gl/lib.rs
+++ b/src/gl/lib.rs
@@ -32,4 +32,4 @@ extern crate libc;
 use std::mem;
 use self::types::*;
 
-generate_gl_bindings!("gl", "core", "4.3", "static", [ "GL_EXT_texture_filter_anisotropic" ])
+generate_gl_bindings!("gl", "core", "4.5", "static", [ "GL_EXT_texture_filter_anisotropic" ])
diff --git a/src/gl_generator/registry.rs b/src/gl_generator/registry.rs
index 4ffe3649..fc8cf780 100644
--- a/src/gl_generator/registry.rs
+++ b/src/gl_generator/registry.rs
@@ -591,7 +591,18 @@ impl<'a> RegistryBuilder {
                     params.push(
                         self.consume_binding(get_attribute(attributes.as_slice(), "group"))
                     );
-                    self.expect_end_element("param");
+
+                    // FIXME: command `glPathGlyphIndexRangeNV` contains a [2] right before </param>
+                    //  we are ignoring this right now (let's hope no-one uses glPathGlyphIndexRangeNV)
+                    // original line is: self.expect_end_element("param");
+                    loop {
+                        match self.recv() {
+                            events::EndElement{ref name}
+                                if name.local_name.as_slice() == "param" => break,
+                            events::Characters(ref value) if value.as_slice() == "[2]" => (),
+                            msg => fail!("Expected </param>, found: {}", msg.to_string()),
+                        }
+                    }
                 }
                 events::StartElement{ref name, ref attributes, ref namespace} if name.local_name.as_slice() == "alias" => {
                     alias = get_attribute(attributes.as_slice(), "alias");
diff --git a/src/gl_generator/ty.rs b/src/gl_generator/ty.rs
index 7afe7d3c..5194b327 100644
--- a/src/gl_generator/ty.rs
+++ b/src/gl_generator/ty.rs
@@ -86,6 +86,7 @@ pub fn to_rust_ty(ty: &str) -> &'static str {
         "const GLdouble *"          => "*const GLdouble",
         "const GLenum *"            => "*const GLenum",
         "const GLfixed *"           => "*const GLfixed",
+        "const GLfloat"             => "GLfloat",
         "const GLfloat *"           => "*const GLfloat",
         "const GLhalfNV *"          => "*const GLhalfNV",
         "const GLint *"             => "*const GLint",


Test patch:
diff --git a/tests/symbols.rs b/tests/symbols.rs
index 06b2b708..b7b32819 100644
--- a/tests/symbols.rs
+++ b/tests/symbols.rs
@@ -11,5 +11,10 @@ fn test() {
 	gl::Clear(gl::COLOR_BUFFER_BIT);
 	let _: libc::c_uint = gl::CreateProgram();
 	gl::CompileShader(5);
+
+    unsafe {
+        gl::GetActiveUniformBlockiv(0, 0, gl::UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER,
+            std::ptr::mut_null());
+    }
 }