Skip to content

Fix mip_level bug in frame_texture causing crash#223

Open
alekslovesonome wants to merge 1 commit intol1npengtul:0.10from
alekslovesonome:fix-mip-level-bug
Open

Fix mip_level bug in frame_texture causing crash#223
alekslovesonome wants to merge 1 commit intol1npengtul:0.10from
alekslovesonome:fix-mip-level-bug

Conversation

@alekslovesonome
Copy link
Copy Markdown

Problem

The frame_texture method in nokhwa-core 0.1.8 crashes with a wgpu validation error:

Unable to select texture mip level 1 out of 1

Root Cause

In nokhwa-core/src/traits.rs line 228, the code writes to mip_level: 1 but the texture is created with mip_level_count: 1 (line 213), meaning only mip level 0 exists.

Fix

Changed mip_level: 1 to mip_level: 0 to match the texture descriptor.

Impact

This is a one-line fix for a crash that affects anyone using the output-wgpu feature with frame_texture method in the 0.10.x release.

Tested on macOS with wgpu 27.0.1.

The frame_texture method was trying to write to mip_level 1 when the
texture only has 1 mip level (index 0). This causes a crash because of the validation error:
'Unable to select texture mip level 1 out of 1'

Changed mip_level from 1 to 0 to match the texture descriptor which
sets mip_level_count to 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants