Skip to content
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

Fix panic in the GLES backend when creating a pipeline with opaque ty… #3361

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,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