From 351ca3ea3d28fe065f7d4d1f90f2e8f28f910d8c Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 11 Oct 2022 20:04:06 +0200 Subject: [PATCH] Fix webgl srgb blit not setting the viewport correctly (#3093) * Fix webgl srgb blit not setting the viewport correctly * Add changelog notes --- CHANGELOG.md | 6 +++++- wgpu-hal/src/gles/web.rs | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 622fbb48fe..55f93aaf66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,7 +56,7 @@ Bottom level categories: #### GLES -- Surfaces support now `TextureFormat::Rgba8Unorm` and (non-web only) `TextureFormat::Bgra8Unorm` +- Surfaces support now `TextureFormat::Rgba8Unorm` and (non-web only) `TextureFormat::Bgra8Unorm`. By @Wumpf in [#3070](https://github.com/gfx-rs/wgpu/pull/3070) ### Bug Fixes @@ -69,6 +69,10 @@ Bottom level categories: #### WebGPU - Use `log` instead of `println` in hello example by @JolifantoBambla in [#2858](https://github.com/gfx-rs/wgpu/pull/2858) +#### GLES + +- Fixed WebGL not displaying srgb targets correctly if a non-screen filling viewport was previously set. By @Wumpf in [#3093](https://github.com/gfx-rs/wgpu/pull/3093) + ### Examples - Log adapter info in hello example on wasm target by @JolifantoBambla in [#2858](https://github.com/gfx-rs/wgpu/pull/2858) diff --git a/wgpu-hal/src/gles/web.rs b/wgpu-hal/src/gles/web.rs index 130da483e6..648fd70877 100644 --- a/wgpu-hal/src/gles/web.rs +++ b/wgpu-hal/src/gles/web.rs @@ -171,6 +171,13 @@ impl Surface { ))?; if swapchain.format.describe().srgb { + // Important to set the viewport since we don't know in what state the user left it. + gl.viewport( + 0, + 0, + swapchain.extent.width as _, + swapchain.extent.height as _, + ); gl.bind_framebuffer(glow::DRAW_FRAMEBUFFER, None); gl.bind_sampler(0, None); gl.active_texture(glow::TEXTURE0);