-
Notifications
You must be signed in to change notification settings - Fork 1.2k
glsl: Handle BindingArray in global variable writing for Intel Arc GPU #8770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a panic in the GLSL backend when processing BindingArray types (e.g., texture arrays) during global variable generation. The panic occurred because BindingArray was not explicitly handled and would fall through to a default case that would then panic on AddressSpace::Handle types.
Key Changes:
- Added explicit handling for
TypeInner::BindingArrayin the global variable writing code - Generates GLSL uniform declarations for texture arrays with proper array syntax
- Handles sampler arrays by skipping them (consistent with regular sampler handling)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
naga/src/back/glsl/mod.rs
Outdated
| TypeInner::Image { | ||
| dim, | ||
| arrayed, | ||
| class, | ||
| } => { | ||
| write!(self.out, "uniform ")?; | ||
| self.write_image_type(dim, arrayed, class)?; | ||
| let global_name = self.get_global_name(handle, global); | ||
| write!(self.out, " {global_name}")?; | ||
| self.write_array_size(base, size)?; | ||
| writeln!(self.out, ";")?; | ||
| writeln!(self.out)?; | ||
|
|
||
| self.reflection_names_globals.insert(handle, global_name); | ||
| } |
Copilot
AI
Dec 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BindingArray Image handling is missing several critical features that are present in the regular Image handling (lines 916-956):
-
Storage image support: Missing format and access specifiers for storage images (lines 917-922, 943-949, 954-956). Storage images in binding arrays (e.g.,
binding_array<texture_storage_2d<rgba8unorm, write>>) require layout qualifiers that specify the storage format and access mode. -
Layout binding qualifiers: Missing explicit binding location handling (lines 930-935, 938-951). When the GLSL version supports explicit locations, binding arrays should include
layout(binding = N)qualifiers. -
OpenGL ES dimension conversion: Missing D1 to D2 conversion for ES targets (lines 925-927). OpenGL ES doesn't support 1D textures, so binding arrays of 1D images need to be converted to 2D.
Without these features, the generated GLSL for binding arrays will be incomplete or incorrect for storage images, missing required binding qualifiers, and will fail to compile for ES targets with 1D textures.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Connections
N/A (Fixes a panic observed in downstream Bevy 0.17 usage)
Description
This PR fixes a panic in the GLSL backend when encountering a
BindingArrayduring the global variable writing phase.write_globaldid not explicitly handleTypeInner::BindingArray. It would fall through to the default case, which attempts to callwrite_globalrecursively. Since the underlying type of a texture array isAddressSpace::Handle, this triggered theunreachable!panic inwrite_globalforAddressSpace::Handle.TypeInner::BindingArrayinwrite_global. It now correctly generates the GLSL uniform declaration for texture arrays (e.g.,uniform texture2D name[size];) and ignores sampler arrays.Testing
Tested locally with a Bevy 0.17 reproduction case on an Intel Core Ultra system with integrated Arc Graphics.
Hardware Context:
Results:
internal error: entered unreachable codeinnaga::back::glslwhen loading a scene withStandardMaterial.Squash or Rebase?
Rebase onto
trunk.Checklist
cargo fmt.taplo format.cargo clippy --tests.cargo xtask testto run testsCHANGELOG.mdentry.