diff --git a/blade-graphics/src/gles/egl.rs b/blade-graphics/src/gles/egl.rs index 41c14518..f387c075 100644 --- a/blade-graphics/src/gles/egl.rs +++ b/blade-graphics/src/gles/egl.rs @@ -543,28 +543,8 @@ impl ContextInner { .swap_interval(self.egl.display, sc.swap_interval) .unwrap(); - let gl = &self.glow; unsafe { - gl.disable(glow::SCISSOR_TEST); - gl.color_mask(true, true, true, true); - gl.bind_framebuffer(glow::DRAW_FRAMEBUFFER, None); - gl.bind_framebuffer(glow::READ_FRAMEBUFFER, Some(wsi.framebuf)); - // Note the Y-flipping here. GL's presentation is not flipped, - // but main rendering is. Therefore, we Y-flip the output positions - // in the shader, and also this blit. - gl.blit_framebuffer( - 0, - sc.extent.height as i32, - sc.extent.width as i32, - 0, - 0, - 0, - sc.extent.width as i32, - sc.extent.height as i32, - glow::COLOR_BUFFER_BIT, - glow::NEAREST, - ); - gl.bind_framebuffer(glow::READ_FRAMEBUFFER, None); + super::present_blit(&self.glow, wsi.framebuf, sc.extent); } self.egl diff --git a/blade-graphics/src/gles/mod.rs b/blade-graphics/src/gles/mod.rs index f2fcbe1e..585ff71e 100644 --- a/blade-graphics/src/gles/mod.rs +++ b/blade-graphics/src/gles/mod.rs @@ -560,3 +560,25 @@ fn map_compare_func(fun: crate::CompareFunction) -> u32 { Cf::Always => glow::ALWAYS, } } + +unsafe fn present_blit(gl: &glow::Context, source: glow::Framebuffer, size: crate::Extent) { + use glow::HasContext as _; + + gl.disable(glow::SCISSOR_TEST); + gl.color_mask(true, true, true, true); + gl.bind_framebuffer(glow::DRAW_FRAMEBUFFER, None); + gl.bind_framebuffer(glow::READ_FRAMEBUFFER, Some(source)); + gl.blit_framebuffer( + 0, + 0, + size.width as i32, + size.height as i32, + 0, + 0, + size.width as i32, + size.height as i32, + glow::COLOR_BUFFER_BIT, + glow::NEAREST, + ); + gl.bind_framebuffer(glow::READ_FRAMEBUFFER, None); +} diff --git a/blade-graphics/src/gles/pipeline.rs b/blade-graphics/src/gles/pipeline.rs index 291f658e..c118c67d 100644 --- a/blade-graphics/src/gles/pipeline.rs +++ b/blade-graphics/src/gles/pipeline.rs @@ -35,7 +35,7 @@ impl super::Context { version: if force_explicit_bindings { 320 } else { 300 }, is_webgl: cfg!(target_arch = "wasm32"), }, - writer_flags: extra_flags | glsl::WriterFlags::ADJUST_COORDINATE_SPACE, + writer_flags: extra_flags, binding_map: Default::default(), zero_initialize_workgroup_memory: false, }; diff --git a/blade-graphics/src/gles/web.rs b/blade-graphics/src/gles/web.rs index 53282bf5..975d2e9f 100644 --- a/blade-graphics/src/gles/web.rs +++ b/blade-graphics/src/gles/web.rs @@ -142,29 +142,8 @@ impl Context { pub(super) fn present(&self) { let sc = &self.swapchain; - let size = sc.extent.get(); - let gl = &self.glow; unsafe { - gl.disable(glow::SCISSOR_TEST); - gl.color_mask(true, true, true, true); - gl.bind_framebuffer(glow::DRAW_FRAMEBUFFER, None); - gl.bind_framebuffer(glow::READ_FRAMEBUFFER, Some(sc.framebuf)); - // Note the Y-flipping here. GL's presentation is not flipped, - // but main rendering is. Therefore, we Y-flip the output positions - // in the shader, and also this blit. - gl.blit_framebuffer( - 0, - size.height as i32, - size.width as i32, - 0, - 0, - 0, - size.width as i32, - size.height as i32, - glow::COLOR_BUFFER_BIT, - glow::NEAREST, - ); - gl.bind_framebuffer(glow::READ_FRAMEBUFFER, None); + super::present_blit(&self.glow, sc.framebuf, sc.extent.get()); } } }