mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Support depth and stencil in webxr
This commit is contained in:
parent
714acb942c
commit
a9bb3f7181
3 changed files with 42 additions and 19 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -6778,7 +6778,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webxr"
|
name = "webxr"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/webxr#de60f3ebe01b1e829393c980a6126924b5f60075"
|
source = "git+https://github.com/servo/webxr#d9ec2263b017d9c415ce35e0f4417a454564bcf2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_injected_glue",
|
"android_injected_glue",
|
||||||
"bindgen",
|
"bindgen",
|
||||||
|
@ -6801,7 +6801,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webxr-api"
|
name = "webxr-api"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/webxr#de60f3ebe01b1e829393c980a6126924b5f60075"
|
source = "git+https://github.com/servo/webxr#d9ec2263b017d9c415ce35e0f4417a454564bcf2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"euclid",
|
"euclid",
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
|
|
|
@ -763,6 +763,19 @@ impl WebGLThread {
|
||||||
&self.contexts,
|
&self.contexts,
|
||||||
&mut self.bound_context_id,
|
&mut self.bound_context_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Destroy WebXR layers associated with this context
|
||||||
|
let webxr_context_id = WebXRContextId::from(context_id);
|
||||||
|
let mut webxr_contexts = WebXRBridgeContexts {
|
||||||
|
contexts: &mut self.contexts,
|
||||||
|
bound_context_id: &mut self.bound_context_id,
|
||||||
|
};
|
||||||
|
self.webxr_bridge.destroy_all_layers(
|
||||||
|
&mut self.device,
|
||||||
|
&mut webxr_contexts,
|
||||||
|
webxr_context_id,
|
||||||
|
);
|
||||||
|
|
||||||
// Release GL context.
|
// Release GL context.
|
||||||
let mut data = match self.contexts.remove(&context_id) {
|
let mut data = match self.contexts.remove(&context_id) {
|
||||||
Some(data) => data,
|
Some(data) => data,
|
||||||
|
@ -774,11 +787,6 @@ impl WebGLThread {
|
||||||
.destroy(context_id, &mut self.device, &mut data.ctx)
|
.destroy(context_id, &mut self.device, &mut data.ctx)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Destroy WebXR layers associated with this context
|
|
||||||
let webxr_context_id = WebXRContextId::from(context_id);
|
|
||||||
self.webxr_bridge
|
|
||||||
.destroy_all_layers(&mut self.device, &mut data.ctx, webxr_context_id);
|
|
||||||
|
|
||||||
// Destroy the context
|
// Destroy the context
|
||||||
self.device.destroy_context(&mut data.ctx).unwrap();
|
self.device.destroy_context(&mut data.ctx).unwrap();
|
||||||
|
|
||||||
|
@ -3193,10 +3201,7 @@ impl WebXRBridge {
|
||||||
.managers
|
.managers
|
||||||
.get_mut(&manager_id)
|
.get_mut(&manager_id)
|
||||||
.ok_or(WebXRError::NoMatchingDevice)?;
|
.ok_or(WebXRError::NoMatchingDevice)?;
|
||||||
let context = contexts
|
manager.create_layer(device, contexts, context_id, layer_init)
|
||||||
.context(device, context_id)
|
|
||||||
.ok_or(WebXRError::NoMatchingDevice)?;
|
|
||||||
manager.create_layer(device, context, context_id, layer_init)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destroy_layer(
|
fn destroy_layer(
|
||||||
|
@ -3208,22 +3213,20 @@ impl WebXRBridge {
|
||||||
layer_id: WebXRLayerId,
|
layer_id: WebXRLayerId,
|
||||||
) {
|
) {
|
||||||
if let Some(manager) = self.managers.get_mut(&manager_id) {
|
if let Some(manager) = self.managers.get_mut(&manager_id) {
|
||||||
if let Some(context) = contexts.context(device, context_id) {
|
manager.destroy_layer(device, contexts, context_id, layer_id);
|
||||||
manager.destroy_layer(device, context, context_id, layer_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destroy_all_layers(
|
fn destroy_all_layers(
|
||||||
&mut self,
|
&mut self,
|
||||||
device: &mut Device,
|
device: &mut Device,
|
||||||
context: &mut Context,
|
contexts: &mut dyn WebXRContexts<WebXRSurfman>,
|
||||||
context_id: WebXRContextId,
|
context_id: WebXRContextId,
|
||||||
) {
|
) {
|
||||||
for (_, manager) in &mut self.managers {
|
for (_, manager) in &mut self.managers {
|
||||||
for (other_id, layer_id) in manager.layers().to_vec() {
|
for (other_id, layer_id) in manager.layers().to_vec() {
|
||||||
if other_id == context_id {
|
if other_id == context_id {
|
||||||
manager.destroy_layer(device, context, context_id, layer_id);
|
manager.destroy_layer(device, contexts, context_id, layer_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3335,7 +3338,7 @@ impl<GL: WebXRTypes> WebXRLayerManagerAPI<GL> for WebXRBridgeManager {
|
||||||
fn create_layer(
|
fn create_layer(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &mut GL::Device,
|
_: &mut GL::Device,
|
||||||
_: &mut GL::Context,
|
_: &mut dyn WebXRContexts<GL>,
|
||||||
context_id: WebXRContextId,
|
context_id: WebXRContextId,
|
||||||
init: WebXRLayerInit,
|
init: WebXRLayerInit,
|
||||||
) -> Result<WebXRLayerId, WebXRError> {
|
) -> Result<WebXRLayerId, WebXRError> {
|
||||||
|
@ -3358,7 +3361,7 @@ impl<GL: WebXRTypes> WebXRLayerManagerAPI<GL> for WebXRBridgeManager {
|
||||||
fn destroy_layer(
|
fn destroy_layer(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &mut GL::Device,
|
_: &mut GL::Device,
|
||||||
_: &mut GL::Context,
|
_: &mut dyn WebXRContexts<GL>,
|
||||||
context_id: WebXRContextId,
|
context_id: WebXRContextId,
|
||||||
layer_id: WebXRLayerId,
|
layer_id: WebXRLayerId,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -240,7 +240,19 @@ impl XRWebGLLayer {
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
.ok()?;
|
.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(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +265,14 @@ impl XRWebGLLayer {
|
||||||
framebuffer
|
framebuffer
|
||||||
.texture2d_even_if_opaque(constants::COLOR_ATTACHMENT0, self.texture_target(), None, 0)
|
.texture2d_even_if_opaque(constants::COLOR_ATTACHMENT0, self.texture_target(), None, 0)
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
framebuffer
|
||||||
|
.texture2d_even_if_opaque(
|
||||||
|
constants::DEPTH_STENCIL_ATTACHMENT,
|
||||||
|
constants::DEPTH_STENCIL_ATTACHMENT,
|
||||||
|
None,
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
.ok()?;
|
||||||
framebuffer.upcast::<WebGLObject>().context().Flush();
|
framebuffer.upcast::<WebGLObject>().context().Flush();
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue