External gles framebuffer (#7671)

This commit is contained in:
Doublonmousse 2025-05-30 21:16:47 +02:00 committed by GitHub
parent 70b06b19a1
commit 1da7cd4811
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 0 deletions

View File

@ -523,6 +523,8 @@ impl crate::CommandEncoder for super::CommandEncoder {
.any(|at| match at.target.view.inner {
#[cfg(webgl)]
super::TextureInner::ExternalFramebuffer { .. } => true,
#[cfg(native)]
super::TextureInner::ExternalNativeFramebuffer { .. } => true,
_ => false,
});

View File

@ -969,6 +969,8 @@ impl crate::Device for super::Device {
}
#[cfg(webgl)]
super::TextureInner::ExternalFramebuffer { .. } => {}
#[cfg(native)]
super::TextureInner::ExternalNativeFramebuffer { .. } => {}
}
}

View File

@ -366,9 +366,21 @@ pub enum TextureInner {
target: BindTarget,
},
#[cfg(webgl)]
/// Render to a `WebGLFramebuffer`
///
/// This is a web feature
ExternalFramebuffer {
inner: web_sys::WebGlFramebuffer,
},
#[cfg(native)]
/// Render to a `glow::NativeFramebuffer`
/// Useful when the framebuffer to draw to
/// has a non-zero framebuffer ID
///
/// This is a native feature
ExternalNativeFramebuffer {
inner: glow::NativeFramebuffer,
},
}
#[cfg(send_sync)]
@ -385,6 +397,8 @@ impl TextureInner {
Self::Texture { raw, target } => (raw, target),
#[cfg(webgl)]
Self::ExternalFramebuffer { .. } => panic!("Unexpected external framebuffer"),
#[cfg(native)]
Self::ExternalNativeFramebuffer { .. } => panic!("unexpected external framebuffer"),
}
}
}

View File

@ -158,6 +158,10 @@ impl super::Queue {
super::TextureInner::ExternalFramebuffer { ref inner } => unsafe {
gl.bind_external_framebuffer(glow::FRAMEBUFFER, inner);
},
#[cfg(native)]
super::TextureInner::ExternalNativeFramebuffer { ref inner } => unsafe {
gl.bind_framebuffer(glow::FRAMEBUFFER, Some(*inner));
},
}
}