wgpu: Don't create cacheAsBitmap for textures that are too large
This commit is contained in:
parent
0ca206ce4f
commit
fd4eaef2b6
|
@ -9,6 +9,9 @@ pub enum Error {
|
||||||
#[error("Bitmap texture is larger than the rendering device supports")]
|
#[error("Bitmap texture is larger than the rendering device supports")]
|
||||||
TooLarge,
|
TooLarge,
|
||||||
|
|
||||||
|
#[error("Bitmap texture has a size of 0 and is invalid")]
|
||||||
|
InvalidSize,
|
||||||
|
|
||||||
#[error("Unknown bitmap format")]
|
#[error("Unknown bitmap format")]
|
||||||
UnknownType,
|
UnknownType,
|
||||||
|
|
||||||
|
|
|
@ -928,6 +928,15 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<BitmapHandle, BitmapError> {
|
) -> Result<BitmapHandle, BitmapError> {
|
||||||
|
if width == 0 || height == 0 {
|
||||||
|
return Err(BitmapError::InvalidSize);
|
||||||
|
}
|
||||||
|
if width > self.descriptors.limits.max_texture_dimension_2d
|
||||||
|
|| height > self.descriptors.limits.max_texture_dimension_2d
|
||||||
|
{
|
||||||
|
return Err(BitmapError::TooLarge);
|
||||||
|
}
|
||||||
|
|
||||||
let extent = wgpu::Extent3d {
|
let extent = wgpu::Extent3d {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
|
Loading…
Reference in New Issue