diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-05-13 18:33:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 18:33:37 -0400 |
commit | 329f081e6a8836f910d4f93bb1c01ba3e93e036a (patch) | |
tree | 2154fa2d80ae6489eece724c88f844a29bc0de88 /components/canvas_traits | |
parent | 9eee0482c0b60ecdcf5d8b367a642978b66b2c5d (diff) | |
parent | 7151ee25c899bcce74bc004da346af1a37d08caa (diff) | |
download | servo-329f081e6a8836f910d4f93bb1c01ba3e93e036a.tar.gz servo-329f081e6a8836f910d4f93bb1c01ba3e93e036a.zip |
Auto merge of #26513 - jdm:webgl2-formats, r=asajeffrey
Reject incompatible webgl texture pixel data
The tests that would make these changes most visibly correct unfortunately rely on texImage3D which isn't implemented yet, so they error out too soon. However, when I comment out that code, these changes avoid a bunch of panics in the webgl thread because of invalid data type combinations being accepted, and removing the incorrect non-filterable texture fallback behaviour for webgl 2 when more texture formats are supposed to be filterable.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes
Diffstat (limited to 'components/canvas_traits')
-rw-r--r-- | components/canvas_traits/webgl.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index 05a1da78b1f..c95fe603a35 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -1313,7 +1313,39 @@ impl TexFormat { } } +#[derive(PartialEq)] +pub enum SizedDataType { + Int8, + Int16, + Int32, + Uint8, + Uint16, + Uint32, + Float32, +} + impl TexDataType { + /// Returns the compatible sized data type for this texture data type. + pub fn sized_data_type(&self) -> SizedDataType { + match self { + TexDataType::Byte => SizedDataType::Int8, + TexDataType::UnsignedByte => SizedDataType::Uint8, + TexDataType::Short => SizedDataType::Int16, + TexDataType::UnsignedShort | + TexDataType::UnsignedShort4444 | + TexDataType::UnsignedShort5551 | + TexDataType::UnsignedShort565 => SizedDataType::Uint16, + TexDataType::Int => SizedDataType::Int32, + TexDataType::UnsignedInt | + TexDataType::UnsignedInt10f11f11fRev | + TexDataType::UnsignedInt2101010Rev | + TexDataType::UnsignedInt5999Rev | + TexDataType::UnsignedInt248 => SizedDataType::Uint32, + TexDataType::HalfFloat => SizedDataType::Uint16, + TexDataType::Float | TexDataType::Float32UnsignedInt248Rev => SizedDataType::Float32, + } + } + /// Returns the size in bytes of each element of data. pub fn element_size(&self) -> u32 { use self::*; |