mirror of
https://github.com/servo/servo.git
synced 2025-08-01 03:30:33 +01:00
webgl: Reject incompatible 2d texture pixel data based on texture data type.
This commit is contained in:
parent
3abaff85f3
commit
7151ee25c8
2 changed files with 56 additions and 18 deletions
|
@ -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::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue