ITADN

Crashes with `texture_format: wgpu::TextureFormat::Rgba16Float`

#109Openjulcst 创建于 2024-08-02
bug
J
julcstcommented
## Description When building a `RendererConfig` with `texture_format: wgpu::TextureFormat::Rgba16Float` (to output to HDR): ```rs let renderer_config = imgui_wgpu::RendererConfig { texture_format: wgpu::TextureFormat::Rgba16Float, ..Default::default() }; ``` wgpu panics: ``` ERROR wgpu::backend::wgpu_core > Handling wgpu errors as fatal by default thread 'main' panicked at /Users/???/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:2996:5: wgpu error: Validation Error Caused by: In Queue::write_texture Number of bytes per row is less than the number of bytes in a complete row stack backtrace: 0: rust_begin_unwind at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/std/src/panicking.rs:652:5 1: core::panicking::panic_fmt at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/panicking.rs:72:14 2: wgpu::backend::wgpu_core::default_error_handler at /Users/???/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:2996:5 3: core::ops::function::Fn::call at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ops/function.rs:79:5 4: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/alloc/src/boxed.rs:2077:9 5: wgpu::backend::wgpu_core::ErrorSinkRaw::handle_error at /Users/???/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:2982:17 6: wgpu::backend::wgpu_core::ContextWgpuCore::handle_error at /Users/???/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:293:9 7: wgpu::backend::wgpu_core::ContextWgpuCore::handle_error_nolabel at /Users/???/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:305:9 8: <wgpu::backend::wgpu_core::ContextWgpuCore as wgpu::context::Context>::queue_write_texture at /Users/???/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:2221:17 9: <T as wgpu::context::DynContext>::queue_write_texture at /Users/???/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/context.rs:2995:9 10: wgpu::Queue::write_texture at /Users/???/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/lib.rs:4937:9 11: imgui_wgpu::Texture::write at /Users/???/.cargo/git/checkouts/imgui-wgpu-rs-c1628ce4915bf3bb/bb0cbc2/src/lib.rs:220:9 12: imgui_wgpu::Renderer::reload_font_texture at /Users/???/.cargo/git/checkouts/imgui-wgpu-rs-c1628ce4915bf3bb/bb0cbc2/src/lib.rs:791:9 13: imgui_wgpu::Renderer::new at /Users/???/.cargo/git/checkouts/imgui-wgpu-rs-c1628ce4915bf3bb/bb0cbc2/src/lib.rs:515:9 ... ``` The panic occurs in this method: ```rs /// Write `data` to the texture. /// /// - `data`: 32-bit RGBA bitmap data. /// - `width`: The width of the source bitmap (`data`) in pixels. /// - `height`: The height of the source bitmap (`data`) in pixels. pub fn write(&self, queue: &Queue, data: &[u8], width: u32, height: u32) { queue.write_texture( // destination (sub)texture ImageCopyTexture { texture: &self.texture, mip_level: 0, origin: Origin3d { x: 0, y: 0, z: 0 }, aspect: TextureAspect::All, }, // source bitmap data data, // layout of the source bitmap ImageDataLayout { offset: 0, bytes_per_row: Some(width * 4), rows_per_image: Some(height), }, // size of the source bitmap Extent3d { width, height, depth_or_array_layers: 1, }, ); } ``` I am using: ```toml imgui = "0.12.0" imgui-wgpu = "0.24.0" wgpu = "0.20.1" ```
2 条评论