Skip to content

Commit e82b87c

Browse files
authoredMay 5, 2022
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
1 parent cb2298e commit e82b87c

File tree

7 files changed

+37
-4
lines changed

7 files changed

+37
-4
lines changed
 

‎docs/egui_demo_app_bg.wasm

1.61 KB
Binary file not shown.

‎eframe/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C
55

66

77
## Unreleased
8+
* `egui_glow`: remove calls to `gl.get_error` in release builds to speed up rendering ([#1583](https://github.com/emilk/egui/pull/1583)).
89

910

1011
## 0.18.0 - 2022-04-30

‎egui_glow/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ All notable changes to the `egui_glow` integration will be noted in this file.
33

44

55
## Unreleased
6+
* Remove calls to `gl.get_error` in release builds to speed up rendering ([#1583](https://github.com/emilk/egui/pull/1583)).
67

78

89
## 0.18.0 - 2022-04-30

‎egui_glow/src/lib.rs

+26
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub use winit::*;
2222

2323
/// Check for OpenGL error and report it using `tracing::error`.
2424
///
25+
/// Only active in debug builds!
26+
///
2527
/// ``` no_run
2628
/// # let glow_context = todo!();
2729
/// use egui_glow::check_for_gl_error;
@@ -30,6 +32,30 @@ pub use winit::*;
3032
/// ```
3133
#[macro_export]
3234
macro_rules! check_for_gl_error {
35+
($gl: expr) => {{
36+
if cfg!(debug_assertions) {
37+
$crate::check_for_gl_error_impl($gl, file!(), line!(), "")
38+
}
39+
}};
40+
($gl: expr, $context: literal) => {{
41+
if cfg!(debug_assertions) {
42+
$crate::check_for_gl_error_impl($gl, file!(), line!(), $context)
43+
}
44+
}};
45+
}
46+
47+
/// Check for OpenGL error and report it using `tracing::error`.
48+
///
49+
/// WARNING: slow! Only use during setup!
50+
///
51+
/// ``` no_run
52+
/// # let glow_context = todo!();
53+
/// use egui_glow::check_for_gl_error_even_in_release;
54+
/// check_for_gl_error_even_in_release!(glow_context);
55+
/// check_for_gl_error_even_in_release!(glow_context, "during painting");
56+
/// ```
57+
#[macro_export]
58+
macro_rules! check_for_gl_error_even_in_release {
3359
($gl: expr) => {{
3460
$crate::check_for_gl_error_impl($gl, file!(), line!(), "")
3561
}};

‎egui_glow/src/painter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl Painter {
9696
shader_prefix: &str,
9797
) -> Result<Painter, String> {
9898
crate::profile_function!();
99-
check_for_gl_error!(&gl, "before Painter::new");
99+
crate::check_for_gl_error_even_in_release!(&gl, "before Painter::new");
100100

101101
let max_texture_side = unsafe { gl.get_parameter_i32(glow::MAX_TEXTURE_SIZE) } as usize;
102102

@@ -204,7 +204,7 @@ impl Painter {
204204

205205
let element_array_buffer = gl.create_buffer()?;
206206

207-
check_for_gl_error!(&gl, "after Painter::new");
207+
crate::check_for_gl_error_even_in_release!(&gl, "after Painter::new");
208208

209209
Ok(Painter {
210210
gl,

‎egui_glow/src/post_process.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl PostProcess {
7575
glow::UNSIGNED_BYTE,
7676
None,
7777
);
78-
check_for_gl_error!(&gl, "post process texture initialization");
78+
crate::check_for_gl_error_even_in_release!(&gl, "post process texture initialization");
7979

8080
gl.framebuffer_texture_2d(
8181
glow::FRAMEBUFFER,
@@ -160,7 +160,7 @@ impl PostProcess {
160160
gl.buffer_data_u8_slice(glow::ELEMENT_ARRAY_BUFFER, &indices, glow::STATIC_DRAW);
161161

162162
gl.bind_buffer(glow::ELEMENT_ARRAY_BUFFER, None);
163-
check_for_gl_error!(&gl, "post process initialization");
163+
crate::check_for_gl_error_even_in_release!(&gl, "post process initialization");
164164

165165
Ok(PostProcess {
166166
gl,

‎sh/build_demo_web.sh

+5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ while test $# -gt 0; do
1717
echo " --open: open the result in a browser"
1818
exit 0
1919
;;
20+
21+
# Skip running `wasm-opt`.
22+
# --fast also preserves debug symbols, which is great for profiling.
2023
--fast)
2124
shift
2225
FAST=true
2326
;;
27+
2428
--open)
2529
shift
2630
OPEN=true
2731
;;
32+
2833
*)
2934
break
3035
;;

0 commit comments

Comments
 (0)
Please sign in to comment.