Auto merge of #27232 - asajeffrey:webxr-depth-stencil, r=Manishearth

Support depth and stencil in webxr

<!-- Please describe your changes on the following line: -->

Creates a `DEPTH_STENCIL` attachment if one is provided by the webxr device.

---
<!-- 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 do not require tests because we don't reftest webxr

<!-- 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:
bors-servo 2020-07-10 19:36:45 -04:00 committed by GitHub
commit 242e7e2630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 19 deletions

View file

@ -240,7 +240,19 @@ impl XRWebGLLayer {
0,
)
.ok()?;
// TODO: depth/stencil
if let Some(id) = sub_images.sub_image.as_ref()?.depth_stencil_texture {
// TODO: Cache this texture
let depth_stencil_texture_id = WebGLTextureId::maybe_new(id)?;
let depth_stencil_texture = WebGLTexture::new(context, depth_stencil_texture_id);
framebuffer
.texture2d_even_if_opaque(
constants::DEPTH_STENCIL_ATTACHMENT,
constants::TEXTURE_2D,
Some(&depth_stencil_texture),
0,
)
.ok()?;
}
Some(())
}
@ -253,6 +265,14 @@ impl XRWebGLLayer {
framebuffer
.texture2d_even_if_opaque(constants::COLOR_ATTACHMENT0, self.texture_target(), None, 0)
.ok()?;
framebuffer
.texture2d_even_if_opaque(
constants::DEPTH_STENCIL_ATTACHMENT,
constants::DEPTH_STENCIL_ATTACHMENT,
None,
0,
)
.ok()?;
framebuffer.upcast::<WebGLObject>().context().Flush();
Some(())
}