Remove calls to gl.getError in release builds (#1583)

This slows down the web version a lot, especially on some browsers

Publish new web demo
This commit is contained in:
Emil Ernerfeldt 2022-05-05 23:17:33 +02:00 committed by GitHub
parent cb2298e98b
commit e82b87ca73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 4 deletions

Binary file not shown.

View file

@ -5,6 +5,7 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C
## Unreleased
* `egui_glow`: remove calls to `gl.get_error` in release builds to speed up rendering ([#1583](https://github.com/emilk/egui/pull/1583)).
## 0.18.0 - 2022-04-30

View file

@ -3,6 +3,7 @@ All notable changes to the `egui_glow` integration will be noted in this file.
## Unreleased
* Remove calls to `gl.get_error` in release builds to speed up rendering ([#1583](https://github.com/emilk/egui/pull/1583)).
## 0.18.0 - 2022-04-30

View file

@ -22,6 +22,8 @@ pub use winit::*;
/// Check for OpenGL error and report it using `tracing::error`.
///
/// Only active in debug builds!
///
/// ``` no_run
/// # let glow_context = todo!();
/// use egui_glow::check_for_gl_error;
@ -30,6 +32,30 @@ pub use winit::*;
/// ```
#[macro_export]
macro_rules! check_for_gl_error {
($gl: expr) => {{
if cfg!(debug_assertions) {
$crate::check_for_gl_error_impl($gl, file!(), line!(), "")
}
}};
($gl: expr, $context: literal) => {{
if cfg!(debug_assertions) {
$crate::check_for_gl_error_impl($gl, file!(), line!(), $context)
}
}};
}
/// Check for OpenGL error and report it using `tracing::error`.
///
/// WARNING: slow! Only use during setup!
///
/// ``` no_run
/// # let glow_context = todo!();
/// use egui_glow::check_for_gl_error_even_in_release;
/// check_for_gl_error_even_in_release!(glow_context);
/// check_for_gl_error_even_in_release!(glow_context, "during painting");
/// ```
#[macro_export]
macro_rules! check_for_gl_error_even_in_release {
($gl: expr) => {{
$crate::check_for_gl_error_impl($gl, file!(), line!(), "")
}};

View file

@ -96,7 +96,7 @@ impl Painter {
shader_prefix: &str,
) -> Result<Painter, String> {
crate::profile_function!();
check_for_gl_error!(&gl, "before Painter::new");
crate::check_for_gl_error_even_in_release!(&gl, "before Painter::new");
let max_texture_side = unsafe { gl.get_parameter_i32(glow::MAX_TEXTURE_SIZE) } as usize;
@ -204,7 +204,7 @@ impl Painter {
let element_array_buffer = gl.create_buffer()?;
check_for_gl_error!(&gl, "after Painter::new");
crate::check_for_gl_error_even_in_release!(&gl, "after Painter::new");
Ok(Painter {
gl,

View file

@ -75,7 +75,7 @@ impl PostProcess {
glow::UNSIGNED_BYTE,
None,
);
check_for_gl_error!(&gl, "post process texture initialization");
crate::check_for_gl_error_even_in_release!(&gl, "post process texture initialization");
gl.framebuffer_texture_2d(
glow::FRAMEBUFFER,
@ -160,7 +160,7 @@ impl PostProcess {
gl.buffer_data_u8_slice(glow::ELEMENT_ARRAY_BUFFER, &indices, glow::STATIC_DRAW);
gl.bind_buffer(glow::ELEMENT_ARRAY_BUFFER, None);
check_for_gl_error!(&gl, "post process initialization");
crate::check_for_gl_error_even_in_release!(&gl, "post process initialization");
Ok(PostProcess {
gl,

View file

@ -17,14 +17,19 @@ while test $# -gt 0; do
echo " --open: open the result in a browser"
exit 0
;;
# Skip running `wasm-opt`.
# --fast also preserves debug symbols, which is great for profiling.
--fast)
shift
FAST=true
;;
--open)
shift
OPEN=true
;;
*)
break
;;