mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Auto merge of #27316 - asajeffrey:webxr-save-restore-gl-state, r=Manishearth
Save / restore state when updating opaque framebuffer bindings <!-- Please describe your changes on the following line: --> This saves and restores the WebGL bindings for texture and framebuffer when beginning a webxr frame. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #27286 - [x] These changes do not require tests because we don't reftest hololens (it would be nice if we did!) <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
48bf169101
2 changed files with 31 additions and 4 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -6790,7 +6790,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webxr"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/servo/webxr#3e731eac4180f739e85f8b6b9dacbc5a2015aec8"
|
||||
source = "git+https://github.com/servo/webxr#53c07f787d882c1b0dede5f4bb645a3bcf38d676"
|
||||
dependencies = [
|
||||
"android_injected_glue",
|
||||
"bindgen",
|
||||
|
@ -6813,7 +6813,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webxr-api"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/servo/webxr#3e731eac4180f739e85f8b6b9dacbc5a2015aec8"
|
||||
source = "git+https://github.com/servo/webxr#53c07f787d882c1b0dede5f4bb645a3bcf38d676"
|
||||
dependencies = [
|
||||
"euclid",
|
||||
"ipc-channel",
|
||||
|
|
|
@ -229,9 +229,27 @@ impl XRWebGLLayer {
|
|||
WebGLTextureId::maybe_new(sub_images.sub_image.as_ref()?.color_texture)?;
|
||||
let color_texture = WebGLTexture::new(context, color_texture_id);
|
||||
let target = self.texture_target();
|
||||
// TODO: rebind the current bindings
|
||||
|
||||
// Save the current bindings
|
||||
let saved_framebuffer = context.get_draw_framebuffer_slot().get();
|
||||
let saved_framebuffer_target = framebuffer.target();
|
||||
let saved_texture_id = context
|
||||
.textures()
|
||||
.active_texture_slot(target, context.webgl_version())
|
||||
.ok()
|
||||
.and_then(|slot| slot.get().map(|texture| texture.id()));
|
||||
|
||||
// We have to pick a framebuffer target.
|
||||
// If there is a draw framebuffer, we use its target,
|
||||
// otherwise we just use DRAW_FRAMEBUFFER.
|
||||
let framebuffer_target = saved_framebuffer
|
||||
.as_ref()
|
||||
.and_then(|fb| fb.target())
|
||||
.unwrap_or(constants::DRAW_FRAMEBUFFER);
|
||||
|
||||
// Update the attachments
|
||||
context.send_command(WebGLCommand::BindTexture(target, Some(color_texture_id)));
|
||||
framebuffer.bind(constants::FRAMEBUFFER);
|
||||
framebuffer.bind(framebuffer_target);
|
||||
framebuffer
|
||||
.texture2d_even_if_opaque(
|
||||
constants::COLOR_ATTACHMENT0,
|
||||
|
@ -253,6 +271,15 @@ impl XRWebGLLayer {
|
|||
)
|
||||
.ok()?;
|
||||
}
|
||||
|
||||
// Restore the old bindings
|
||||
context.send_command(WebGLCommand::BindTexture(target, saved_texture_id));
|
||||
if let Some(framebuffer_target) = saved_framebuffer_target {
|
||||
framebuffer.bind(framebuffer_target);
|
||||
}
|
||||
if let Some(framebuffer) = saved_framebuffer {
|
||||
framebuffer.bind(framebuffer_target);
|
||||
}
|
||||
Some(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue