From 94743234fcf4852f5002eacc6f02bd95015571cc Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:36:21 +0100 Subject: [PATCH 1/4] Add ShaderPrecisionFormat and get_shader_precision_format (#320) * Add ShaderPrecisionFormat and get_shader_precision_format Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * common_desktop_hardware Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- Cargo.toml | 1 + src/lib.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/native.rs | 30 ++++++++++++++++++++++++++++++ src/web_sys.rs | 20 ++++++++++++++++++++ 4 files changed, 96 insertions(+) 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/src/lib.rs b/src/lib.rs index 2b1c286..e06c7ac 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, diff --git a/src/native.rs b/src/native.rs index 967e311..adbe111 100644 --- a/src/native.rs +++ b/src/native.rs @@ -366,6 +366,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, diff --git a/src/web_sys.rs b/src/web_sys.rs index 42c9cdf..95d8821 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, From a0ba3b756a46f39f0c7410af3e8cc18ca12352ff Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:38:48 +0100 Subject: [PATCH 2/4] Use `PixelUnpackData` in tex_image_{1,2,3}d (#322) * Use PixelUnpackData in tex_image_2d Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Use PixelUnpackData in tex_image_1d Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Use PixelUnpackData for tex_image_3d Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- src/lib.rs | 6 +-- src/native.rs | 21 ++++++--- src/web_sys.rs | 125 +++++++++++++++++++++++++++++++------------------ 3 files changed, 98 insertions(+), 54 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e06c7ac..d2d0318 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1115,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( @@ -1139,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( @@ -1175,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( diff --git a/src/native.rs b/src/native.rs index adbe111..85f839f 100644 --- a/src/native.rs +++ b/src/native.rs @@ -2465,7 +2465,7 @@ impl HasContext for Context { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ) { let gl = &self.raw; gl.TexImage1D( @@ -2476,7 +2476,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, + }, ); } @@ -2512,7 +2515,7 @@ impl HasContext for Context { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ) { let gl = &self.raw; gl.TexImage2D( @@ -2524,7 +2527,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, + }, ); } @@ -2583,7 +2589,7 @@ impl HasContext for Context { border: i32, format: u32, ty: u32, - pixels: Option<&[u8]>, + pixels: PixelUnpackData, ) { let gl = &self.raw; gl.TexImage3D( @@ -2596,7 +2602,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, + }, ); } diff --git a/src/web_sys.rs b/src/web_sys.rs index 95d8821..d819174 100644 --- a/src/web_sys.rs +++ b/src/web_sys.rs @@ -3960,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"); } @@ -3988,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? } } } @@ -4084,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? } } } From 62cfeee3417eacee49dc3c4cc4a56acc6f70c0a6 Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:39:52 +0100 Subject: [PATCH 3/4] Add and use GL_EXT_disjoint_timer_query as fallback (#323) Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- generate-native.sh | 1 + src/gl46.rs | 522 +++++++++++++++++++++++++++++++++++++++++++++ src/native.rs | 42 +++- 3 files changed, 558 insertions(+), 7 deletions(-) diff --git a/generate-native.sh b/generate-native.sh index 7e24f8e..c354660 100755 --- a/generate-native.sh +++ b/generate-native.sh @@ -36,6 +36,7 @@ gl_extensions=( GL_ARB_sync GL_KHR_parallel_shader_compile GL_ARB_parallel_shader_compile + 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 77757b8..0f9f1b8 100644 --- a/src/gl46.rs +++ b/src/gl46.rs @@ -29,6 +29,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` @@ -1014,6 +1015,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; @@ -1667,6 +1670,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; @@ -2878,6 +2883,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`"] @@ -2892,6 +2899,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; @@ -3987,9 +3998,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; @@ -4856,6 +4871,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); @@ -4990,6 +5008,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); @@ -5047,6 +5068,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); @@ -5066,6 +5090,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); @@ -5116,6 +5143,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); } @@ -5161,10 +5191,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); @@ -5241,6 +5286,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); @@ -5368,6 +5416,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); @@ -5764,6 +5815,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)] @@ -11218,6 +11301,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)] @@ -13194,6 +13310,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)] @@ -13981,6 +14125,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)] @@ -15986,6 +16162,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) @@ -17817,6 +18032,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) @@ -17861,6 +18126,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) @@ -17905,6 +18215,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) @@ -17949,6 +18309,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 @@ -17985,6 +18389,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 @@ -21395,6 +21844,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))] @@ -26637,6 +27113,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)] @@ -36263,6 +36773,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, @@ -36379,6 +36890,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, @@ -36428,6 +36940,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, @@ -36447,6 +36960,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, @@ -36491,6 +37005,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, @@ -36528,10 +37043,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, @@ -36606,6 +37126,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, @@ -36721,6 +37242,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/native.rs b/src/native.rs index 85f839f..4941f98 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")) @@ -1710,7 +1714,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) { @@ -4169,23 +4177,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 } @@ -4196,7 +4220,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 { From 36dc9f46538592a260bde2e48bff780de4584697 Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:41:06 +0100 Subject: [PATCH 4/4] Make `bind_image_texture` take `Option` (#325) Fix https://github.com/grovesNL/glow/issues/259 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- src/lib.rs | 2 +- src/native.rs | 4 ++-- src/web_sys.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d2d0318..5731332 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1900,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 4941f98..373bbd1 100644 --- a/src/native.rs +++ b/src/native.rs @@ -4342,7 +4342,7 @@ impl HasContext for Context { unsafe fn bind_image_texture( &self, unit: u32, - texture: Self::Texture, + texture: Option, level: i32, layered: bool, layer: i32, @@ -4352,7 +4352,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 d819174..1d21c8d 100644 --- a/src/web_sys.rs +++ b/src/web_sys.rs @@ -6035,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,