Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid extra blit for GL->D3D. #133

Merged
merged 1 commit into from
Mar 5, 2020
Merged

Avoid extra blit for GL->D3D. #133

merged 1 commit into from
Mar 5, 2020

Conversation

jdm
Copy link
Member

@jdm jdm commented Feb 27, 2020

Copy link
Member

@asajeffrey asajeffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, mostly LGTM, though I think I'd like to revisit this if/when servo/surfman-chains#8 happens.

}

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "ipc", derive(Deserialize, Serialize))]
pub struct SessionId(pub(crate) u32);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, why do we need a swap chain id and a session id? Aren't they always going to be 1:1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know they will, but we create an XR session before we end up creating a swapchain, and the code in create_webxr_swap_chain needs to associated the new swapchain with the session's surface provider if it exists.

webxr/Cargo.toml Outdated
@@ -29,11 +29,12 @@ headless = []
ipc = ["webxr-api/ipc", "serde"]
googlevr = ["gvr-sys", "android_injected_glue", "gles"]
magicleap = ["egl"]
openxr-api = ["angle", "openxr", "winapi", "wio"]
openxr-api = ["angle", "openxr", "winapi", "wio", "surfman/sm-angle-default"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment that sm-angle-default only sets the default on windows?

let _ = provider_rx.recv();
}));
// Get the D3D11 device pointer from the webgl thread.
let device = device_rx.recv().unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably be unnecessary in surfmanup, since the openxr device will own the d3d11 device.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fundamental point of these changes is to ensure that OpenXR uses the WebGL thread's d3d device, rather than an independent one. Without that sharing, the WebGL thread can't share the OpenXR textures.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do it the other way round, where WebGL uses the device provided by OpenXR?

// XXXManishearth what if the recommended widths are different?
width: left_view_configuration.recommended_image_rect_width,
width: left_view_configuration.recommended_image_rect_width
+ right_view_configuration.recommended_image_rect_width,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, HL lets you do this? And it doesn't produce an extra blit inside openxr? Hooray!

Copy link
Member Author

@jdm jdm Feb 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still blits internally. We weren't on the fast path before this change though, either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh boo for the extra blit. It would be sooooo nice if we could do this and hit HL's fast path.

self.gl.bind_framebuffer(gl::FRAMEBUFFER, old_framebuffer);

self.left_swapchain.release_image().unwrap();
self.right_swapchain.release_image().unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goodbye horrible GL code! \o/

@jdm
Copy link
Member Author

jdm commented Mar 2, 2020

Pushed the updated changes that fix the d3d threading issues in babylon demos.

@jdm jdm force-pushed the invert branch 2 times, most recently from ae07c08 to 66eaf7d Compare March 4, 2020 17:42
@jdm
Copy link
Member Author

jdm commented Mar 4, 2020

The latest changes in this branch fix #113 as well, which boosts us from 50fps to 60fps on the three.js paint, ball shooter, and lorenz attractor demos!

@asajeffrey
Copy link
Member

You can r=me when it's ready to land.

@jdm
Copy link
Member Author

jdm commented Mar 5, 2020

@bors-servo r=asajeffrey,Manishearth

@bors-servo
Copy link
Contributor

📌 Commit 400fbf5 has been approved by asajeffrey,Manishearth

@bors-servo
Copy link
Contributor

⌛ Testing commit 400fbf5 with merge 3ac3e83...

@bors-servo
Copy link
Contributor

☀️ Test successful - checks-travis
Approved by: asajeffrey,Manishearth
Pushing 3ac3e83 to master...

@bors-servo bors-servo merged commit 3ac3e83 into servo:master Mar 5, 2020
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 6, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 6, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 6, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 6, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 6, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 7, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 9, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 9, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 9, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 9, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
bors-servo pushed a commit to servo/servo that referenced this pull request Mar 9, 2020
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants