Use surfman with glow bindings (#34328)

* Use glowing surfman

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Port https://github.com/servo/webxr/pull/255

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* fixups rebase

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* fmt

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Update surfman

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Fix stale TODO

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2025-02-05 07:13:21 +01:00 committed by GitHub
parent fdbfecf7dd
commit 503bb10c5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 70 additions and 97 deletions

View file

@ -3,7 +3,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use core::slice;
use std::num::NonZeroU32;
use std::rc::Rc;
use euclid::{
@ -25,7 +24,6 @@ use webxr_api::{
VIEWER,
};
use crate::gl_utils::framebuffer;
use crate::{SurfmanGL, SurfmanLayerManager};
// How far off the ground are the viewer's eyes?
@ -222,11 +220,10 @@ impl DeviceAPI for GlWindowDevice {
.device
.context_surface_info(&self.context)
.unwrap()
.map(|info| info.framebuffer_object)
.unwrap_or(0);
.and_then(|info| info.framebuffer_object);
unsafe {
self.gl
.bind_framebuffer(gl::FRAMEBUFFER, framebuffer(framebuffer_object));
.bind_framebuffer(gl::FRAMEBUFFER, framebuffer_object);
debug_assert_eq!(
(
self.gl.get_error(),
@ -254,10 +251,9 @@ impl DeviceAPI for GlWindowDevice {
.device
.create_surface_texture(&mut self.context, surface)
.unwrap();
let raw_texture_id = self.device.surface_texture_object(&surface_texture);
let texture_id = NonZeroU32::new(raw_texture_id).map(gl::NativeTexture);
let texture_id = self.device.surface_texture_object(&surface_texture);
let texture_target = self.device.surface_gl_texture_target();
log::debug!("Presenting texture {}", raw_texture_id);
log::debug!("Presenting texture {:?}", texture_id);
if let Some(ref shader) = self.shader {
shader.draw_texture(
@ -392,9 +388,8 @@ impl GlWindowDevice {
let framebuffer_object = device
.context_surface_info(&context)
.unwrap()
.map(|info| info.framebuffer_object)
.unwrap_or(0);
gl.bind_framebuffer(gl::FRAMEBUFFER, framebuffer(framebuffer_object));
.and_then(|info| info.framebuffer_object);
gl.bind_framebuffer(gl::FRAMEBUFFER, framebuffer_object);
debug_assert_eq!(
(gl.get_error(), gl.check_framebuffer_status(gl::FRAMEBUFFER)),
(gl::NO_ERROR, gl::FRAMEBUFFER_COMPLETE)