mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #23226 - mmatyas:webgl_compressed_textures, r=jdm
Add initial support for WebGL compressed textures This patch is an initial implementation of WebGL compressed texture support, it contains - functions for registering and querying compressed texture extensions - initial implementation of `CompressedTexImage2D` and `CompressedTexSubImage2D` and their parameter validation - implementation of S3TC (DXT1, DXT3, DXT5) and ETC1 extensions as examples What's still missing: - some of the parameter validation steps are missing - the pixel comparison tests fail for more complex cases (I'm probably missing something trivial at the GL calls) Related: #10209 and #20594 cc @jdm @zakorgy --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] Related issues: #10209, #20594 - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23226) <!-- Reviewable:end -->
This commit is contained in:
commit
123f58592c
16 changed files with 792 additions and 37 deletions
|
@ -331,6 +331,22 @@ pub enum WebGLCommand {
|
|||
pixel_format: Option<PixelFormat>,
|
||||
data: TruncatedDebug<IpcSharedMemory>,
|
||||
},
|
||||
CompressedTexImage2D {
|
||||
target: u32,
|
||||
level: u32,
|
||||
internal_format: u32,
|
||||
size: Size2D<u32>,
|
||||
data: TruncatedDebug<IpcSharedMemory>,
|
||||
},
|
||||
CompressedTexSubImage2D {
|
||||
target: u32,
|
||||
level: i32,
|
||||
xoffset: i32,
|
||||
yoffset: i32,
|
||||
size: Size2D<u32>,
|
||||
format: u32,
|
||||
data: TruncatedDebug<IpcSharedMemory>,
|
||||
},
|
||||
DrawingBufferWidth(WebGLSender<i32>),
|
||||
DrawingBufferHeight(WebGLSender<i32>),
|
||||
Finish(WebGLSender<()>),
|
||||
|
@ -740,6 +756,25 @@ macro_rules! gl_enums {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: These should come from gleam
|
||||
mod gl_ext_constants {
|
||||
use gleam::gl::types::GLenum;
|
||||
|
||||
pub const COMPRESSED_RGB_S3TC_DXT1_EXT: GLenum = 0x83F0;
|
||||
pub const COMPRESSED_RGBA_S3TC_DXT1_EXT: GLenum = 0x83F1;
|
||||
pub const COMPRESSED_RGBA_S3TC_DXT3_EXT: GLenum = 0x83F2;
|
||||
pub const COMPRESSED_RGBA_S3TC_DXT5_EXT: GLenum = 0x83F3;
|
||||
pub const COMPRESSED_RGB_ETC1_WEBGL: GLenum = 0x8D64;
|
||||
|
||||
pub static COMPRESSIONS: &'static [GLenum] = &[
|
||||
COMPRESSED_RGB_S3TC_DXT1_EXT,
|
||||
COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
||||
COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
||||
COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
||||
COMPRESSED_RGB_ETC1_WEBGL,
|
||||
];
|
||||
}
|
||||
|
||||
gl_enums! {
|
||||
pub enum TexFormat {
|
||||
DepthComponent = gl::DEPTH_COMPONENT,
|
||||
|
@ -748,6 +783,11 @@ gl_enums! {
|
|||
RGBA = gl::RGBA,
|
||||
Luminance = gl::LUMINANCE,
|
||||
LuminanceAlpha = gl::LUMINANCE_ALPHA,
|
||||
CompressedRgbS3tcDxt1 = gl_ext_constants::COMPRESSED_RGB_S3TC_DXT1_EXT,
|
||||
CompressedRgbaS3tcDxt1 = gl_ext_constants::COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
||||
CompressedRgbaS3tcDxt3 = gl_ext_constants::COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
||||
CompressedRgbaS3tcDxt5 = gl_ext_constants::COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
||||
CompressedRgbEtc1 = gl_ext_constants::COMPRESSED_RGB_ETC1_WEBGL,
|
||||
}
|
||||
|
||||
pub enum TexDataType {
|
||||
|
@ -771,8 +811,14 @@ impl TexFormat {
|
|||
TexFormat::LuminanceAlpha => 2,
|
||||
TexFormat::RGB => 3,
|
||||
TexFormat::RGBA => 4,
|
||||
_ => 1,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns whether this format is a known texture compression format.
|
||||
pub fn is_compressed(&self) -> bool {
|
||||
gl_ext_constants::COMPRESSIONS.contains(&self.as_gl_constant())
|
||||
}
|
||||
}
|
||||
|
||||
impl TexDataType {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue