diff --git a/Cargo.toml b/Cargo.toml index ee0e443..918aaf4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,6 +60,7 @@ features = [ "WebGl2RenderingContext", "WebGlSampler", "WebGlShader", + "WebGlShaderPrecisionFormat", "WebGlSync", "WebGlTexture", "WebGlTransformFeedback", diff --git a/generate-native.sh b/generate-native.sh index b0e92c0..84b3bcc 100755 --- a/generate-native.sh +++ b/generate-native.sh @@ -38,6 +38,7 @@ gl_extensions=( GL_ARB_parallel_shader_compile GL_OES_vertex_array_object GL_APPLE_vertex_array_object + GL_EXT_disjoint_timer_query ) printf -v gl_extensions_comma_joined '%s,' "${gl_extensions[@]}" diff --git a/src/gl46.rs b/src/gl46.rs index 0593b53..1792d41 100644 --- a/src/gl46.rs +++ b/src/gl46.rs @@ -30,6 +30,7 @@ //! * `GL_ARB_uniform_buffer_object` //! * `GL_ARB_vertex_array_object` //! * `GL_EXT_buffer_storage` +//! * `GL_EXT_disjoint_timer_query` //! * `GL_EXT_draw_buffers2` //! * `GL_EXT_texture_filter_anisotropic` //! * `GL_KHR_debug` @@ -1016,6 +1017,8 @@ pub mod enums { #[doc = "`GL_CURRENT_QUERY: GLenum = 0x8865`"] #[doc = "* **Group:** QueryParameterName"] pub const GL_CURRENT_QUERY: GLenum = 0x8865; + #[doc = "`GL_CURRENT_QUERY_EXT: GLenum = 0x8865`"] + pub const GL_CURRENT_QUERY_EXT: GLenum = 0x8865; #[doc = "`GL_CURRENT_VERTEX_ATTRIB: GLenum = 0x8626`"] #[doc = "* **Groups:** VertexAttribEnum, VertexAttribPropertyARB"] pub const GL_CURRENT_VERTEX_ATTRIB: GLenum = 0x8626; @@ -1669,6 +1672,8 @@ pub mod enums { #[doc = "`GL_GET_TEXTURE_IMAGE_TYPE: GLenum = 0x8292`"] #[doc = "* **Group:** InternalFormatPName"] pub const GL_GET_TEXTURE_IMAGE_TYPE: GLenum = 0x8292; + #[doc = "`GL_GPU_DISJOINT_EXT: GLenum = 0x8FBB`"] + pub const GL_GPU_DISJOINT_EXT: GLenum = 0x8FBB; #[doc = "`GL_GREATER: GLenum = 0x0204`"] #[doc = "* **Groups:** StencilFunction, IndexFunctionEXT, AlphaFunction, DepthFunction"] pub const GL_GREATER: GLenum = 0x0204; @@ -2880,6 +2885,8 @@ pub mod enums { #[doc = "`GL_QUERY_COUNTER_BITS: GLenum = 0x8864`"] #[doc = "* **Group:** QueryParameterName"] pub const GL_QUERY_COUNTER_BITS: GLenum = 0x8864; + #[doc = "`GL_QUERY_COUNTER_BITS_EXT: GLenum = 0x8864`"] + pub const GL_QUERY_COUNTER_BITS_EXT: GLenum = 0x8864; #[doc = "`GL_QUERY_KHR: GLenum = 0x82E3`"] pub const GL_QUERY_KHR: GLenum = 0x82E3; #[doc = "`GL_QUERY_NO_WAIT: GLenum = 0x8E14`"] @@ -2894,6 +2901,10 @@ pub mod enums { #[doc = "`GL_QUERY_RESULT_AVAILABLE: GLenum = 0x8867`"] #[doc = "* **Group:** QueryObjectParameterName"] pub const GL_QUERY_RESULT_AVAILABLE: GLenum = 0x8867; + #[doc = "`GL_QUERY_RESULT_AVAILABLE_EXT: GLenum = 0x8867`"] + pub const GL_QUERY_RESULT_AVAILABLE_EXT: GLenum = 0x8867; + #[doc = "`GL_QUERY_RESULT_EXT: GLenum = 0x8866`"] + pub const GL_QUERY_RESULT_EXT: GLenum = 0x8866; #[doc = "`GL_QUERY_RESULT_NO_WAIT: GLenum = 0x9194`"] #[doc = "* **Group:** QueryObjectParameterName"] pub const GL_QUERY_RESULT_NO_WAIT: GLenum = 0x9194; @@ -3989,9 +4000,13 @@ pub mod enums { #[doc = "`GL_TIMESTAMP: GLenum = 0x8E28`"] #[doc = "* **Groups:** QueryCounterTarget, GetPName"] pub const GL_TIMESTAMP: GLenum = 0x8E28; + #[doc = "`GL_TIMESTAMP_EXT: GLenum = 0x8E28`"] + pub const GL_TIMESTAMP_EXT: GLenum = 0x8E28; #[doc = "`GL_TIME_ELAPSED: GLenum = 0x88BF`"] #[doc = "* **Group:** QueryTarget"] pub const GL_TIME_ELAPSED: GLenum = 0x88BF; + #[doc = "`GL_TIME_ELAPSED_EXT: GLenum = 0x88BF`"] + pub const GL_TIME_ELAPSED_EXT: GLenum = 0x88BF; #[doc = "`GL_TOP_LEVEL_ARRAY_SIZE: GLenum = 0x930C`"] #[doc = "* **Group:** ProgramResourceProperty"] pub const GL_TOP_LEVEL_ARRAY_SIZE: GLenum = 0x930C; @@ -4862,6 +4877,9 @@ pub mod struct_commands { self.AttachShader_load_with_dyn(get_proc_address); self.BeginConditionalRender_load_with_dyn(get_proc_address); self.BeginQuery_load_with_dyn(get_proc_address); + { + self.BeginQueryEXT_load_with_dyn(get_proc_address); + } self.BeginQueryIndexed_load_with_dyn(get_proc_address); self.BeginTransformFeedback_load_with_dyn(get_proc_address); self.BindAttribLocation_load_with_dyn(get_proc_address); @@ -5002,6 +5020,9 @@ pub mod struct_commands { self.DeleteProgram_load_with_dyn(get_proc_address); self.DeleteProgramPipelines_load_with_dyn(get_proc_address); self.DeleteQueries_load_with_dyn(get_proc_address); + { + self.DeleteQueriesEXT_load_with_dyn(get_proc_address); + } self.DeleteRenderbuffers_load_with_dyn(get_proc_address); self.DeleteSamplers_load_with_dyn(get_proc_address); self.DeleteShader_load_with_dyn(get_proc_address); @@ -5065,6 +5086,9 @@ pub mod struct_commands { self.Enablei_load_with_dyn(get_proc_address); self.EndConditionalRender_load_with_dyn(get_proc_address); self.EndQuery_load_with_dyn(get_proc_address); + { + self.EndQueryEXT_load_with_dyn(get_proc_address); + } self.EndQueryIndexed_load_with_dyn(get_proc_address); self.EndTransformFeedback_load_with_dyn(get_proc_address); self.FenceSync_load_with_dyn(get_proc_address); @@ -5084,6 +5108,9 @@ pub mod struct_commands { self.GenFramebuffers_load_with_dyn(get_proc_address); self.GenProgramPipelines_load_with_dyn(get_proc_address); self.GenQueries_load_with_dyn(get_proc_address); + { + self.GenQueriesEXT_load_with_dyn(get_proc_address); + } self.GenRenderbuffers_load_with_dyn(get_proc_address); self.GenSamplers_load_with_dyn(get_proc_address); self.GenTextures_load_with_dyn(get_proc_address); @@ -5140,6 +5167,9 @@ pub mod struct_commands { self.GetGraphicsResetStatus_load_with_dyn(get_proc_address); self.GetInteger64i_v_load_with_dyn(get_proc_address); self.GetInteger64v_load_with_dyn(get_proc_address); + { + self.GetInteger64vEXT_load_with_dyn(get_proc_address); + } { self.GetIntegerIndexedvEXT_load_with_dyn(get_proc_address); } @@ -5185,10 +5215,25 @@ pub mod struct_commands { self.GetQueryBufferObjectuiv_load_with_dyn(get_proc_address); self.GetQueryIndexediv_load_with_dyn(get_proc_address); self.GetQueryObjecti64v_load_with_dyn(get_proc_address); + { + self.GetQueryObjecti64vEXT_load_with_dyn(get_proc_address); + } self.GetQueryObjectiv_load_with_dyn(get_proc_address); + { + self.GetQueryObjectivEXT_load_with_dyn(get_proc_address); + } self.GetQueryObjectui64v_load_with_dyn(get_proc_address); + { + self.GetQueryObjectui64vEXT_load_with_dyn(get_proc_address); + } self.GetQueryObjectuiv_load_with_dyn(get_proc_address); + { + self.GetQueryObjectuivEXT_load_with_dyn(get_proc_address); + } self.GetQueryiv_load_with_dyn(get_proc_address); + { + self.GetQueryivEXT_load_with_dyn(get_proc_address); + } self.GetRenderbufferParameteriv_load_with_dyn(get_proc_address); self.GetSamplerParameterIiv_load_with_dyn(get_proc_address); self.GetSamplerParameterIuiv_load_with_dyn(get_proc_address); @@ -5265,6 +5310,9 @@ pub mod struct_commands { self.IsProgram_load_with_dyn(get_proc_address); self.IsProgramPipeline_load_with_dyn(get_proc_address); self.IsQuery_load_with_dyn(get_proc_address); + { + self.IsQueryEXT_load_with_dyn(get_proc_address); + } self.IsRenderbuffer_load_with_dyn(get_proc_address); self.IsSampler_load_with_dyn(get_proc_address); self.IsShader_load_with_dyn(get_proc_address); @@ -5398,6 +5446,9 @@ pub mod struct_commands { self.PushDebugGroupKHR_load_with_dyn(get_proc_address); } self.QueryCounter_load_with_dyn(get_proc_address); + { + self.QueryCounterEXT_load_with_dyn(get_proc_address); + } self.ReadBuffer_load_with_dyn(get_proc_address); self.ReadPixels_load_with_dyn(get_proc_address); self.ReadnPixels_load_with_dyn(get_proc_address); @@ -5794,6 +5845,38 @@ pub mod struct_commands { pub fn BeginQuery_is_loaded(&self) -> bool { !self.glBeginQuery_p.load(RELAX).is_null() } + /// [glBeginQueryEXT](http://docs.gl/gl4/glBeginQueryEXT)(target, id) + /// * `target` group: QueryTarget + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn BeginQueryEXT(&self, target: GLenum, id: GLuint) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!("calling gl.BeginQueryEXT({:#X}, {:?});", target, id); + } + let out = call_atomic_ptr_2arg("glBeginQueryEXT", &self.glBeginQueryEXT_p, target, id); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glBeginQueryEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn BeginQueryEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glBeginQueryEXT\0", + &self.glBeginQueryEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn BeginQueryEXT_is_loaded(&self) -> bool { + !self.glBeginQueryEXT_p.load(RELAX).is_null() + } /// [glBeginQueryIndexed](http://docs.gl/gl4/glBeginQueryIndexed)(target, index, id) /// * `target` group: QueryTarget #[cfg_attr(feature = "inline", inline)] @@ -11316,6 +11399,39 @@ pub mod struct_commands { pub fn DeleteQueries_is_loaded(&self) -> bool { !self.glDeleteQueries_p.load(RELAX).is_null() } + /// [glDeleteQueriesEXT](http://docs.gl/gl4/glDeleteQueriesEXT)(n, ids) + /// * `ids` len: n + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn DeleteQueriesEXT(&self, n: GLsizei, ids: *const GLuint) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!("calling gl.DeleteQueriesEXT({:?}, {:p});", n, ids); + } + let out = + call_atomic_ptr_2arg("glDeleteQueriesEXT", &self.glDeleteQueriesEXT_p, n, ids); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glDeleteQueriesEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn DeleteQueriesEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glDeleteQueriesEXT\0", + &self.glDeleteQueriesEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn DeleteQueriesEXT_is_loaded(&self) -> bool { + !self.glDeleteQueriesEXT_p.load(RELAX).is_null() + } /// [glDeleteRenderbuffers](http://docs.gl/gl4/glDeleteRenderbuffers)(n, renderbuffers) /// * `renderbuffers` len: n #[cfg_attr(feature = "inline", inline)] @@ -13368,6 +13484,34 @@ pub mod struct_commands { pub fn EndQuery_is_loaded(&self) -> bool { !self.glEndQuery_p.load(RELAX).is_null() } + /// [glEndQueryEXT](http://docs.gl/gl4/glEndQueryEXT)(target) + /// * `target` group: QueryTarget + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn EndQueryEXT(&self, target: GLenum) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!("calling gl.EndQueryEXT({:#X});", target); + } + let out = call_atomic_ptr_1arg("glEndQueryEXT", &self.glEndQueryEXT_p, target); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glEndQueryEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn EndQueryEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr(get_proc_address, b"glEndQueryEXT\0", &self.glEndQueryEXT_p) + } + #[inline] + #[doc(hidden)] + pub fn EndQueryEXT_is_loaded(&self) -> bool { + !self.glEndQueryEXT_p.load(RELAX).is_null() + } /// [glEndQueryIndexed](http://docs.gl/gl4/glEndQueryIndexed)(target, index) /// * `target` group: QueryTarget #[cfg_attr(feature = "inline", inline)] @@ -14155,6 +14299,38 @@ pub mod struct_commands { pub fn GenQueries_is_loaded(&self) -> bool { !self.glGenQueries_p.load(RELAX).is_null() } + /// [glGenQueriesEXT](http://docs.gl/gl4/glGenQueriesEXT)(n, ids) + /// * `ids` len: n + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn GenQueriesEXT(&self, n: GLsizei, ids: *mut GLuint) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!("calling gl.GenQueriesEXT({:?}, {:p});", n, ids); + } + let out = call_atomic_ptr_2arg("glGenQueriesEXT", &self.glGenQueriesEXT_p, n, ids); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glGenQueriesEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn GenQueriesEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glGenQueriesEXT\0", + &self.glGenQueriesEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn GenQueriesEXT_is_loaded(&self) -> bool { + !self.glGenQueriesEXT_p.load(RELAX).is_null() + } /// [glGenRenderbuffers](http://docs.gl/gl4/glGenRenderbuffers)(n, renderbuffers) /// * `renderbuffers` len: n #[cfg_attr(feature = "inline", inline)] @@ -16236,6 +16412,45 @@ pub mod struct_commands { pub fn GetInteger64v_is_loaded(&self) -> bool { !self.glGetInteger64v_p.load(RELAX).is_null() } + /// [glGetInteger64vEXT](http://docs.gl/gl4/glGetInteger64vEXT)(pname, data) + /// * `pname` group: GetPName + /// * `data` len: COMPSIZE(pname) + /// * alias of: [`glGetInteger64v`] + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn GetInteger64vEXT(&self, pname: GLenum, data: *mut GLint64) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!("calling gl.GetInteger64vEXT({:#X}, {:p});", pname, data); + } + let out = call_atomic_ptr_2arg( + "glGetInteger64vEXT", + &self.glGetInteger64vEXT_p, + pname, + data, + ); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glGetInteger64vEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn GetInteger64vEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glGetInteger64vEXT\0", + &self.glGetInteger64vEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn GetInteger64vEXT_is_loaded(&self) -> bool { + !self.glGetInteger64vEXT_p.load(RELAX).is_null() + } /// [glGetIntegerIndexedvEXT](http://docs.gl/gl4/glGetIntegerIndexedvEXT)(target, index, data) /// * `target` group: GetPName /// * `data` len: COMPSIZE(target) @@ -18067,6 +18282,56 @@ pub mod struct_commands { pub fn GetQueryObjecti64v_is_loaded(&self) -> bool { !self.glGetQueryObjecti64v_p.load(RELAX).is_null() } + /// [glGetQueryObjecti64vEXT](http://docs.gl/gl4/glGetQueryObjecti64vEXT)(id, pname, params) + /// * `pname` group: QueryObjectParameterName + /// * `params` len: COMPSIZE(pname) + /// * alias of: [`glGetQueryObjecti64v`] + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn GetQueryObjecti64vEXT( + &self, + id: GLuint, + pname: GLenum, + params: *mut GLint64, + ) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!( + "calling gl.GetQueryObjecti64vEXT({:?}, {:#X}, {:p});", + id, + pname, + params + ); + } + let out = call_atomic_ptr_3arg( + "glGetQueryObjecti64vEXT", + &self.glGetQueryObjecti64vEXT_p, + id, + pname, + params, + ); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glGetQueryObjecti64vEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn GetQueryObjecti64vEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glGetQueryObjecti64vEXT\0", + &self.glGetQueryObjecti64vEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn GetQueryObjecti64vEXT_is_loaded(&self) -> bool { + !self.glGetQueryObjecti64vEXT_p.load(RELAX).is_null() + } /// [glGetQueryObjectiv](http://docs.gl/gl4/glGetQueryObject)(id, pname, params) /// * `pname` group: QueryObjectParameterName /// * `params` len: COMPSIZE(pname) @@ -18111,6 +18376,51 @@ pub mod struct_commands { pub fn GetQueryObjectiv_is_loaded(&self) -> bool { !self.glGetQueryObjectiv_p.load(RELAX).is_null() } + /// [glGetQueryObjectivEXT](http://docs.gl/gl4/glGetQueryObjectivEXT)(id, pname, params) + /// * `pname` group: QueryObjectParameterName + /// * `params` len: COMPSIZE(pname) + /// * alias of: [`glGetQueryObjectiv`] + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn GetQueryObjectivEXT(&self, id: GLuint, pname: GLenum, params: *mut GLint) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!( + "calling gl.GetQueryObjectivEXT({:?}, {:#X}, {:p});", + id, + pname, + params + ); + } + let out = call_atomic_ptr_3arg( + "glGetQueryObjectivEXT", + &self.glGetQueryObjectivEXT_p, + id, + pname, + params, + ); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glGetQueryObjectivEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn GetQueryObjectivEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glGetQueryObjectivEXT\0", + &self.glGetQueryObjectivEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn GetQueryObjectivEXT_is_loaded(&self) -> bool { + !self.glGetQueryObjectivEXT_p.load(RELAX).is_null() + } /// [glGetQueryObjectui64v](http://docs.gl/gl4/glGetQueryObjectu)(id, pname, params) /// * `pname` group: QueryObjectParameterName /// * `params` len: COMPSIZE(pname) @@ -18155,6 +18465,56 @@ pub mod struct_commands { pub fn GetQueryObjectui64v_is_loaded(&self) -> bool { !self.glGetQueryObjectui64v_p.load(RELAX).is_null() } + /// [glGetQueryObjectui64vEXT](http://docs.gl/gl4/glGetQueryObjectui64vEXT)(id, pname, params) + /// * `pname` group: QueryObjectParameterName + /// * `params` len: COMPSIZE(pname) + /// * alias of: [`glGetQueryObjectui64v`] + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn GetQueryObjectui64vEXT( + &self, + id: GLuint, + pname: GLenum, + params: *mut GLuint64, + ) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!( + "calling gl.GetQueryObjectui64vEXT({:?}, {:#X}, {:p});", + id, + pname, + params + ); + } + let out = call_atomic_ptr_3arg( + "glGetQueryObjectui64vEXT", + &self.glGetQueryObjectui64vEXT_p, + id, + pname, + params, + ); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glGetQueryObjectui64vEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn GetQueryObjectui64vEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glGetQueryObjectui64vEXT\0", + &self.glGetQueryObjectui64vEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn GetQueryObjectui64vEXT_is_loaded(&self) -> bool { + !self.glGetQueryObjectui64vEXT_p.load(RELAX).is_null() + } /// [glGetQueryObjectuiv](http://docs.gl/gl4/glGetQueryObject)(id, pname, params) /// * `pname` group: QueryObjectParameterName /// * `params` len: COMPSIZE(pname) @@ -18199,6 +18559,50 @@ pub mod struct_commands { pub fn GetQueryObjectuiv_is_loaded(&self) -> bool { !self.glGetQueryObjectuiv_p.load(RELAX).is_null() } + /// [glGetQueryObjectuivEXT](http://docs.gl/gl4/glGetQueryObjectuivEXT)(id, pname, params) + /// * `pname` group: QueryObjectParameterName + /// * `params` len: COMPSIZE(pname) + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn GetQueryObjectuivEXT(&self, id: GLuint, pname: GLenum, params: *mut GLuint) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!( + "calling gl.GetQueryObjectuivEXT({:?}, {:#X}, {:p});", + id, + pname, + params + ); + } + let out = call_atomic_ptr_3arg( + "glGetQueryObjectuivEXT", + &self.glGetQueryObjectuivEXT_p, + id, + pname, + params, + ); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glGetQueryObjectuivEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn GetQueryObjectuivEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glGetQueryObjectuivEXT\0", + &self.glGetQueryObjectuivEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn GetQueryObjectuivEXT_is_loaded(&self) -> bool { + !self.glGetQueryObjectuivEXT_p.load(RELAX).is_null() + } /// [glGetQueryiv](http://docs.gl/gl4/glGetQuery)(target, pname, params) /// * `target` group: QueryTarget /// * `pname` group: QueryParameterName @@ -18235,6 +18639,51 @@ pub mod struct_commands { pub fn GetQueryiv_is_loaded(&self) -> bool { !self.glGetQueryiv_p.load(RELAX).is_null() } + /// [glGetQueryivEXT](http://docs.gl/gl4/glGetQueryivEXT)(target, pname, params) + /// * `target` group: QueryTarget + /// * `pname` group: QueryParameterName + /// * `params` len: COMPSIZE(pname) + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn GetQueryivEXT(&self, target: GLenum, pname: GLenum, params: *mut GLint) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!( + "calling gl.GetQueryivEXT({:#X}, {:#X}, {:p});", + target, + pname, + params + ); + } + let out = call_atomic_ptr_3arg( + "glGetQueryivEXT", + &self.glGetQueryivEXT_p, + target, + pname, + params, + ); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glGetQueryivEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn GetQueryivEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glGetQueryivEXT\0", + &self.glGetQueryivEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn GetQueryivEXT_is_loaded(&self) -> bool { + !self.glGetQueryivEXT_p.load(RELAX).is_null() + } /// [glGetRenderbufferParameteriv](http://docs.gl/gl4/glGetRenderbufferParameter)(target, pname, params) /// * `target` group: RenderbufferTarget /// * `pname` group: RenderbufferParameterName @@ -21645,6 +22094,33 @@ pub mod struct_commands { pub fn IsQuery_is_loaded(&self) -> bool { !self.glIsQuery_p.load(RELAX).is_null() } + /// [glIsQueryEXT](http://docs.gl/gl4/glIsQueryEXT)(id) + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn IsQueryEXT(&self, id: GLuint) -> GLboolean { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!("calling gl.IsQueryEXT({:?});", id); + } + let out = call_atomic_ptr_1arg("glIsQueryEXT", &self.glIsQueryEXT_p, id); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glIsQueryEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn IsQueryEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr(get_proc_address, b"glIsQueryEXT\0", &self.glIsQueryEXT_p) + } + #[inline] + #[doc(hidden)] + pub fn IsQueryEXT_is_loaded(&self) -> bool { + !self.glIsQueryEXT_p.load(RELAX).is_null() + } /// [glIsRenderbuffer](http://docs.gl/gl4/glIsRenderbuffer)(renderbuffer) #[cfg_attr(feature = "inline", inline)] #[cfg_attr(feature = "inline_always", inline(always))] @@ -26952,6 +27428,40 @@ pub mod struct_commands { pub fn QueryCounter_is_loaded(&self) -> bool { !self.glQueryCounter_p.load(RELAX).is_null() } + /// [glQueryCounterEXT](http://docs.gl/gl4/glQueryCounterEXT)(id, target) + /// * `target` group: QueryCounterTarget + /// * alias of: [`glQueryCounter`] + #[cfg_attr(feature = "inline", inline)] + #[cfg_attr(feature = "inline_always", inline(always))] + pub unsafe fn QueryCounterEXT(&self, id: GLuint, target: GLenum) { + #[cfg(all(debug_assertions, feature = "debug_trace_calls"))] + { + trace!("calling gl.QueryCounterEXT({:?}, {:#X});", id, target); + } + let out = + call_atomic_ptr_2arg("glQueryCounterEXT", &self.glQueryCounterEXT_p, id, target); + #[cfg(all(debug_assertions, feature = "debug_automatic_glGetError"))] + { + self.automatic_glGetError("glQueryCounterEXT"); + } + out + } + #[doc(hidden)] + pub unsafe fn QueryCounterEXT_load_with_dyn( + &self, + get_proc_address: &mut dyn FnMut(*const c_char) -> *mut c_void, + ) -> bool { + load_dyn_name_atomic_ptr( + get_proc_address, + b"glQueryCounterEXT\0", + &self.glQueryCounterEXT_p, + ) + } + #[inline] + #[doc(hidden)] + pub fn QueryCounterEXT_is_loaded(&self) -> bool { + !self.glQueryCounterEXT_p.load(RELAX).is_null() + } /// [glReadBuffer](http://docs.gl/gl4/glReadBuffer)(src) /// * `src` group: ReadBufferMode #[cfg_attr(feature = "inline", inline)] @@ -36578,6 +37088,7 @@ pub mod struct_commands { glAttachShader_p: APcv, glBeginConditionalRender_p: APcv, glBeginQuery_p: APcv, + glBeginQueryEXT_p: APcv, glBeginQueryIndexed_p: APcv, glBeginTransformFeedback_p: APcv, glBindAttribLocation_p: APcv, @@ -36696,6 +37207,7 @@ pub mod struct_commands { glDeleteProgram_p: APcv, glDeleteProgramPipelines_p: APcv, glDeleteQueries_p: APcv, + glDeleteQueriesEXT_p: APcv, glDeleteRenderbuffers_p: APcv, glDeleteSamplers_p: APcv, glDeleteShader_p: APcv, @@ -36747,6 +37259,7 @@ pub mod struct_commands { glEnablei_p: APcv, glEndConditionalRender_p: APcv, glEndQuery_p: APcv, + glEndQueryEXT_p: APcv, glEndQueryIndexed_p: APcv, glEndTransformFeedback_p: APcv, glFenceSync_p: APcv, @@ -36766,6 +37279,7 @@ pub mod struct_commands { glGenFramebuffers_p: APcv, glGenProgramPipelines_p: APcv, glGenQueries_p: APcv, + glGenQueriesEXT_p: APcv, glGenRenderbuffers_p: APcv, glGenSamplers_p: APcv, glGenTextures_p: APcv, @@ -36812,6 +37326,7 @@ pub mod struct_commands { glGetGraphicsResetStatus_p: APcv, glGetInteger64i_v_p: APcv, glGetInteger64v_p: APcv, + glGetInteger64vEXT_p: APcv, glGetIntegerIndexedvEXT_p: APcv, glGetIntegeri_v_p: APcv, glGetIntegerv_p: APcv, @@ -36849,10 +37364,15 @@ pub mod struct_commands { glGetQueryBufferObjectuiv_p: APcv, glGetQueryIndexediv_p: APcv, glGetQueryObjecti64v_p: APcv, + glGetQueryObjecti64vEXT_p: APcv, glGetQueryObjectiv_p: APcv, + glGetQueryObjectivEXT_p: APcv, glGetQueryObjectui64v_p: APcv, + glGetQueryObjectui64vEXT_p: APcv, glGetQueryObjectuiv_p: APcv, + glGetQueryObjectuivEXT_p: APcv, glGetQueryiv_p: APcv, + glGetQueryivEXT_p: APcv, glGetRenderbufferParameteriv_p: APcv, glGetSamplerParameterIiv_p: APcv, glGetSamplerParameterIuiv_p: APcv, @@ -36927,6 +37447,7 @@ pub mod struct_commands { glIsProgram_p: APcv, glIsProgramPipeline_p: APcv, glIsQuery_p: APcv, + glIsQueryEXT_p: APcv, glIsRenderbuffer_p: APcv, glIsSampler_p: APcv, glIsShader_p: APcv, @@ -37044,6 +37565,7 @@ pub mod struct_commands { glPushDebugGroup_p: APcv, glPushDebugGroupKHR_p: APcv, glQueryCounter_p: APcv, + glQueryCounterEXT_p: APcv, glReadBuffer_p: APcv, glReadPixels_p: APcv, glReadnPixels_p: APcv, diff --git a/src/lib.rs b/src/lib.rs index 2b1c286..5731332 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,45 @@ pub struct ActiveTransformFeedback { pub name: String, } +#[derive(Debug)] +pub struct ShaderPrecisionFormat { + /// The base 2 log of the absolute value of the minimum value that can be represented + pub range_min: i32, + /// The base 2 log of the absolute value of the maximum value that can be represented. + pub range_max: i32, + /// The number of bits of precision that can be represented. + /// For integer formats this value is always 0. + pub precision: i32, +} + +impl ShaderPrecisionFormat { + /// Returns OpenGL standard precision that most desktop hardware support + pub fn common_desktop_hardware(precision_type: u32, is_embedded: bool) -> Self { + let (range_min, range_max, precision) = match precision_type { + LOW_INT | MEDIUM_INT | HIGH_INT => { + // Precision: For integer formats this value is always 0 + if is_embedded { + // These values are for a 32-bit twos-complement integer format. + (31, 30, 0) + } else { + // Range: from -2^24 to 2^24 + (24, 24, 0) + } + } + // IEEE 754 single-precision floating-point + // Range: from -2^127 to 2^127 + // Significand precision: 23 bits + LOW_FLOAT | MEDIUM_FLOAT | HIGH_FLOAT => (127, 127, 23), + _ => unreachable!("invalid precision"), + }; + Self { + range_min, + range_max, + precision, + } + } +} + #[allow(dead_code)] #[derive(Debug)] pub struct DebugMessageLogEntry { @@ -156,6 +195,12 @@ pub trait HasContext: __private::Sealed { unsafe fn get_shader_info_log(&self, shader: Self::Shader) -> String; + unsafe fn get_shader_precision_format( + &self, + shader_type: u32, + precision_mode: u32, + ) -> Option; + unsafe fn get_tex_image( &self, target: u32, @@ -1070,7 +1115,7 @@ pub trait HasContext: __private::Sealed { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ); unsafe fn compressed_tex_image_1d( @@ -1094,7 +1139,7 @@ pub trait HasContext: __private::Sealed { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ); unsafe fn tex_image_2d_multisample( @@ -1130,7 +1175,7 @@ pub trait HasContext: __private::Sealed { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ); unsafe fn compressed_tex_image_3d( @@ -1855,7 +1900,7 @@ pub trait HasContext: __private::Sealed { unsafe fn bind_image_texture( &self, unit: u32, - texture: Self::Texture, + texture: Option, level: i32, layered: bool, layer: i32, diff --git a/src/native.rs b/src/native.rs index a9d52aa..832b100 100644 --- a/src/native.rs +++ b/src/native.rs @@ -248,7 +248,11 @@ impl HasContext for Context { unsafe fn create_query(&self) -> Result { let gl = &self.raw; let mut name = 0; - gl.GenQueries(1, &mut name); + if gl.GenQueries_is_loaded() { + gl.GenQueries(1, &mut name); + } else { + gl.GenQueriesEXT(1, &mut name); + } NonZeroU32::new(name) .map(NativeQuery) .ok_or_else(|| String::from("Unable to create Query object")) @@ -366,6 +370,36 @@ impl HasContext for Context { } } + unsafe fn get_shader_precision_format( + &self, + shader_type: u32, + precision_type: u32, + ) -> Option { + let gl = &self.raw; + + if gl.GetShaderPrecisionFormat_is_loaded() { + let mut range = [0, 0]; + let mut precision = 0; + gl.GetShaderPrecisionFormat( + shader_type, + precision_type, + range.as_mut_ptr(), + &mut precision, + ); + // In some cases GetShaderPrecisionFormat exists but it's just a stub + // so we return only if variables got populated + if range[1] != 0 { + return Some(ShaderPrecisionFormat { + range_min: range[0], + range_max: range[1], + precision, + }); + } + } + + None + } + unsafe fn get_tex_image( &self, target: u32, @@ -1701,7 +1735,11 @@ impl HasContext for Context { unsafe fn delete_query(&self, query: Self::Query) { let gl = &self.raw; - gl.DeleteQueries(1, &query.0.get()); + if gl.DeleteQueries_is_loaded() { + gl.DeleteQueries(1, &query.0.get()); + } else { + gl.DeleteQueriesEXT(1, &query.0.get()); + } } unsafe fn delete_renderbuffer(&self, renderbuffer: Self::Renderbuffer) { @@ -2456,7 +2494,7 @@ impl HasContext for Context { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ) { let gl = &self.raw; gl.TexImage1D( @@ -2467,7 +2505,10 @@ impl HasContext for Context { border, format, ty, - pixels.map(|p| p.as_ptr()).unwrap_or(std::ptr::null()) as *const std::ffi::c_void, + match pixels { + PixelUnpackData::BufferOffset(offset) => offset as *const std::ffi::c_void, + PixelUnpackData::Slice(data) => data.as_ptr() as *const std::ffi::c_void, + }, ); } @@ -2503,7 +2544,7 @@ impl HasContext for Context { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ) { let gl = &self.raw; gl.TexImage2D( @@ -2515,7 +2556,10 @@ impl HasContext for Context { border, format, ty, - pixels.map(|p| p.as_ptr()).unwrap_or(std::ptr::null()) as *const std::ffi::c_void, + match pixels { + PixelUnpackData::BufferOffset(offset) => offset as *const std::ffi::c_void, + PixelUnpackData::Slice(data) => data.as_ptr() as *const std::ffi::c_void, + }, ); } @@ -2574,7 +2618,7 @@ impl HasContext for Context { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ) { let gl = &self.raw; gl.TexImage3D( @@ -2587,7 +2631,10 @@ impl HasContext for Context { border, format, ty, - pixels.map(|p| p.as_ptr()).unwrap_or(std::ptr::null()) as *const std::ffi::c_void, + match pixels { + PixelUnpackData::BufferOffset(offset) => offset as *const std::ffi::c_void, + PixelUnpackData::Slice(data) => data.as_ptr() as *const std::ffi::c_void, + }, ); } @@ -4151,23 +4198,39 @@ impl HasContext for Context { unsafe fn begin_query(&self, target: u32, query: Self::Query) { let gl = &self.raw; - gl.BeginQuery(target, query.0.get()); + if gl.BeginQuery_is_loaded() { + gl.BeginQuery(target, query.0.get()); + } else { + gl.BeginQueryEXT(target, query.0.get()); + } } unsafe fn end_query(&self, target: u32) { let gl = &self.raw; - gl.EndQuery(target); + if gl.EndQuery_is_loaded() { + gl.EndQuery(target); + } else { + gl.EndQueryEXT(target); + } } unsafe fn query_counter(&self, query: Self::Query, target: u32) { let gl = &self.raw; - gl.QueryCounter(query.0.get(), target); + if gl.QueryCounter_is_loaded() { + gl.QueryCounter(query.0.get(), target); + } else { + gl.QueryCounterEXT(query.0.get(), target); + } } unsafe fn get_query_parameter_u32(&self, query: Self::Query, parameter: u32) -> u32 { let gl = &self.raw; let mut value = 0; - gl.GetQueryObjectuiv(query.0.get(), parameter, &mut value); + if gl.GetQueryBufferObjectiv_is_loaded() { + gl.GetQueryObjectuiv(query.0.get(), parameter, &mut value); + } else { + gl.GetQueryObjectuivEXT(query.0.get(), parameter, &mut value); + } value } @@ -4178,7 +4241,11 @@ impl HasContext for Context { offset: usize, ) { let gl = &self.raw; - gl.GetQueryObjectui64v(query.0.get(), parameter, offset as *mut _); + if gl.GetQueryObjectui64v_is_loaded() { + gl.GetQueryObjectui64v(query.0.get(), parameter, offset as *mut _); + } else { + gl.GetQueryObjectui64vEXT(query.0.get(), parameter, offset as *mut _); + } } unsafe fn create_transform_feedback(&self) -> Result { @@ -4296,7 +4363,7 @@ impl HasContext for Context { unsafe fn bind_image_texture( &self, unit: u32, - texture: Self::Texture, + texture: Option, level: i32, layered: bool, layer: i32, @@ -4306,7 +4373,7 @@ impl HasContext for Context { let gl = &self.raw; gl.BindImageTexture( unit, - texture.0.get(), + texture.map(|tex| tex.0.get()).unwrap_or(0), level, layered as u8, layer, diff --git a/src/web_sys.rs b/src/web_sys.rs index 42c9cdf..1d21c8d 100644 --- a/src/web_sys.rs +++ b/src/web_sys.rs @@ -1825,6 +1825,26 @@ impl HasContext for Context { .unwrap_or_else(|| String::from("")) } + unsafe fn get_shader_precision_format( + &self, + shader_type: u32, + precision_mode: u32, + ) -> Option { + match self.raw { + RawRenderingContext::WebGl1(ref gl) => { + gl.get_shader_precision_format(shader_type, precision_mode) + } + RawRenderingContext::WebGl2(ref gl) => { + gl.get_shader_precision_format(shader_type, precision_mode) + } + } + .map(|spf| ShaderPrecisionFormat { + range_min: spf.range_min(), + range_max: spf.range_max(), + precision: spf.precision(), + }) + } + unsafe fn get_tex_image( &self, _target: u32, @@ -3940,7 +3960,7 @@ impl HasContext for Context { _border: i32, _format: u32, _ty: u32, - _pixels: Option<&[u8]>, + _pixels: PixelUnpackData, ) { panic!("Tex image 1D is not supported"); } @@ -3968,39 +3988,59 @@ impl HasContext for Context { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ) { - let pixels = pixels.map(|bytes| texture_data_view(ty, bytes)); match self.raw { RawRenderingContext::WebGl1(ref gl) => { - // TODO: Handle return value? - gl.tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_opt_array_buffer_view( - target, - level, - internal_format, - width, - height, - border, - format, - ty, - pixels.as_ref(), - ) - .unwrap(); + match pixels { + PixelUnpackData::BufferOffset(_offset) => panic!("Tex image 2D with offset is not supported"), + PixelUnpackData::Slice(data) => { + let data = texture_data_view(ty, data); + gl.tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_opt_array_buffer_view( + target, + level, + internal_format, + width, + height, + border, + format, + ty, + Some(&data), + ) + } + } + .unwrap(); // TODO: Handle return value? } RawRenderingContext::WebGl2(ref gl) => { - // TODO: Handle return value? - gl.tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_opt_array_buffer_view( - target, - level, - internal_format, - width, - height, - border, - format, - ty, - pixels.as_ref(), - ) - .unwrap(); + match pixels { + PixelUnpackData::BufferOffset(offset) => gl + .tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_i32( + target, + level, + internal_format, + width, + height, + border, + format, + ty, + offset as i32, + ), + PixelUnpackData::Slice(data) => { + let data = texture_data_view(ty, data); + gl.tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_opt_array_buffer_view( + target, + level, + internal_format, + width, + height, + border, + format, + ty, + Some(&data), + ) + } + } + .unwrap(); // TODO: Handle return value? } } } @@ -4064,26 +4104,41 @@ impl HasContext for Context { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ) { match self.raw { RawRenderingContext::WebGl1(ref _gl) => panic!("3d textures are not supported"), RawRenderingContext::WebGl2(ref gl) => { - let pixels = pixels.map(|bytes| texture_data_view(ty, bytes)); - // TODO: Handle return value? - gl.tex_image_3d_with_opt_array_buffer_view( - target, - level, - internal_format, - width, - height, - depth, - border, - format, - ty, - pixels.as_ref(), - ) - .unwrap(); + match pixels { + PixelUnpackData::BufferOffset(offset) => gl.tex_image_3d_with_i32( + target, + level, + internal_format, + width, + height, + border, + depth, + format, + ty, + offset as i32, + ), + PixelUnpackData::Slice(data) => { + let data = texture_data_view(ty, data); + gl.tex_image_3d_with_opt_array_buffer_view( + target, + level, + internal_format, + width, + height, + border, + depth, + format, + ty, + Some(&data), + ) + } + } + .unwrap(); // TODO: Handle return value? } } } @@ -5980,7 +6035,7 @@ impl HasContext for Context { unsafe fn bind_image_texture( &self, _unit: u32, - _texture: Self::Texture, + _texture: Option, _level: i32, _layered: bool, _layer: i32,