Revert "Use surfman with glow bindings (#34328)" (#35402)

This reverts commit 503bb10c5b.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2025-02-10 18:20:27 +01:00 committed by GitHub
parent 90130315a7
commit 0fed99590a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 97 additions and 69 deletions

View file

@ -570,9 +570,15 @@ macro_rules! define_resource_id {
pub struct $name(nonzero_type!($type));
impl $name {
#[allow(unsafe_code)]
#[inline]
pub fn new(id: nonzero_type!($type)) -> Self {
Self(id)
/// Create a new $name.
///
/// # Safety
///
/// Using an invalid OpenGL id may result in undefined behavior.
pub unsafe fn new(id: $type) -> Self {
$name(<nonzero_type!($type)>::new_unchecked(id))
}
#[inline]
@ -593,10 +599,10 @@ macro_rules! define_resource_id {
D: ::serde::Deserializer<'de>,
{
let id = <$type>::deserialize(deserializer)?;
if let Some(id) = <nonzero_type!($type)>::new(id) {
Ok($name(id))
} else {
if id == 0 {
Err(::serde::de::Error::custom("expected a non-zero value"))
} else {
Ok(unsafe { $name::new(id) })
}
}
}

View file

@ -180,8 +180,7 @@ impl RenderingContext for SurfmanRenderingContext {
fn framebuffer_object(&self) -> u32 {
self.context_surface_info()
.unwrap_or(None)
.and_then(|info| info.framebuffer_object)
.map(|fbo| fbo.0.get())
.map(|info| info.framebuffer_object)
.unwrap_or(0)
}
#[allow(unsafe_code)]
@ -218,10 +217,7 @@ impl RenderingContext for SurfmanRenderingContext {
} = device.surface_info(&surface);
debug!("... getting texture for surface {:?}", front_buffer_id);
let surface_texture = device.create_surface_texture(context, surface).unwrap();
let gl_texture = device
.surface_texture_object(&surface_texture)
.map(|tex| tex.0.get())
.unwrap_or(0);
let gl_texture = device.surface_texture_object(&surface_texture);
Some((surface_texture, gl_texture, size))
}
@ -429,10 +425,7 @@ impl SurfmanRenderingContext {
pub fn surface_texture_object(&self, surface: &SurfaceTexture) -> u32 {
let device = &self.0.device.borrow();
device
.surface_texture_object(surface)
.map(|t| t.0.get())
.unwrap_or_default()
device.surface_texture_object(surface)
}
pub fn get_proc_address(&self, name: &str) -> *const c_void {

View file

@ -3,7 +3,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::fmt::Debug;
use std::num::NonZeroU32;
use std::sync::atomic::{AtomicUsize, Ordering};
use euclid::{Rect, Size2D};
@ -287,8 +286,9 @@ pub struct SubImages {
#[derive(Clone, Debug)]
#[cfg_attr(feature = "ipc", derive(Deserialize, Serialize))]
pub struct SubImage {
pub color_texture: Option<NonZeroU32>,
pub depth_stencil_texture: Option<NonZeroU32>,
pub color_texture: u32,
// TODO: make this Option<NonZeroU32>
pub depth_stencil_texture: Option<u32>,
pub texture_array_index: Option<u32>,
pub viewport: Rect<i32, Viewport>,
}