Skip to content

Commit

Permalink
Fix panic in the GLES backend when creating a pipeline with opaque ty… (
Browse files Browse the repository at this point in the history
#3361)

* Fix panic in the GLES backend when creating a pipeline with opaque types other than samplers.

* Add changelog entry for #3361.
  • Loading branch information
James2022-rgb authored Jan 10, 2023
1 parent 2252b12 commit e7ca171
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non

- Fixed WebGL not displaying srgb targets correctly if a non-screen filling viewport was previously set. By @Wumpf in [#3093](https://github.com/gfx-rs/wgpu/pull/3093)
- Fix disallowing multisampling for float textures if otherwise supported. By @Wumpf in [#3183](https://github.com/gfx-rs/wgpu/pull/3183)
- Fix a panic when creating a pipeline with opaque types other than samplers (images and atomic counters). By @James2022-rgb in [#3361](https://github.com/gfx-rs/wgpu/pull/3361)

#### Vulkan

Expand Down
48 changes: 47 additions & 1 deletion wgpu-hal/src/gles/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,52 @@ pub(super) fn is_sampler(glsl_uniform_type: u32) -> bool {
}
}

pub(super) fn is_image(glsl_uniform_type: u32) -> bool {
match glsl_uniform_type {
glow::INT_IMAGE_1D
| glow::INT_IMAGE_1D_ARRAY
| glow::INT_IMAGE_2D
| glow::INT_IMAGE_2D_ARRAY
| glow::INT_IMAGE_2D_MULTISAMPLE
| glow::INT_IMAGE_2D_MULTISAMPLE_ARRAY
| glow::INT_IMAGE_2D_RECT
| glow::INT_IMAGE_3D
| glow::INT_IMAGE_CUBE
| glow::INT_IMAGE_CUBE_MAP_ARRAY
| glow::UNSIGNED_INT_IMAGE_1D
| glow::UNSIGNED_INT_IMAGE_1D_ARRAY
| glow::UNSIGNED_INT_IMAGE_2D
| glow::UNSIGNED_INT_IMAGE_2D_ARRAY
| glow::UNSIGNED_INT_IMAGE_2D_MULTISAMPLE
| glow::UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
| glow::UNSIGNED_INT_IMAGE_2D_RECT
| glow::UNSIGNED_INT_IMAGE_3D
| glow::UNSIGNED_INT_IMAGE_CUBE
| glow::UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY
| glow::IMAGE_1D
| glow::IMAGE_1D_ARRAY
| glow::IMAGE_2D
| glow::IMAGE_2D_ARRAY
| glow::IMAGE_2D_MULTISAMPLE
| glow::IMAGE_2D_MULTISAMPLE_ARRAY
| glow::IMAGE_2D_RECT
| glow::IMAGE_3D
| glow::IMAGE_CUBE
| glow::IMAGE_CUBE_MAP_ARRAY => true,
_ => false,
}
}

pub(super) fn is_atomic_counter(glsl_uniform_type: u32) -> bool {
glsl_uniform_type == glow::UNSIGNED_INT_ATOMIC_COUNTER
}

pub(super) fn is_opaque_type(glsl_uniform_type: u32) -> bool {
is_sampler(glsl_uniform_type)
|| is_image(glsl_uniform_type)
|| is_atomic_counter(glsl_uniform_type)
}

pub(super) fn uniform_byte_size(glsl_uniform_type: u32) -> u32 {
match glsl_uniform_type {
glow::FLOAT | glow::INT => 4,
Expand All @@ -448,6 +494,6 @@ pub(super) fn uniform_byte_size(glsl_uniform_type: u32) -> u32 {
glow::FLOAT_MAT2 => 16,
glow::FLOAT_MAT3 => 36,
glow::FLOAT_MAT4 => 64,
_ => panic!("Unsupported uniform datatype!"),
_ => panic!("Unsupported uniform datatype! {glsl_uniform_type:#X}"),
}
}
2 changes: 1 addition & 1 deletion wgpu-hal/src/gles/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl super::Device {
let glow::ActiveUniform { utype, name, .. } =
unsafe { gl.get_active_uniform(program, uniform) }.unwrap();

if conv::is_sampler(utype) {
if conv::is_opaque_type(utype) {
continue;
}

Expand Down

0 comments on commit e7ca171

Please sign in to comment.