Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove calls to gl.getError in release builds #1583

Merged
merged 2 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/egui_demo_app_bg.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions eframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions egui_glow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions egui_glow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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!(), "")
}};
Expand Down
4 changes: 2 additions & 2 deletions egui_glow/src/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions egui_glow/src/post_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions sh/build_demo_web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
;;
Expand Down