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

WebGl workaround for drawing single instance #3597

Merged

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Mar 16, 2023

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
fixes #3578
backport: #3596

Description
Whenever there is any instance attribute, we need to need use an instanced draw call on ANGLE. Otherwise, the following error will be (potentially spuriously) generated and may render incorrectly:

[.WebGL-0000554C38753500] GL_INVALID_OPERATION: Error: 0x00000502, in ..\..\third_party\angle\src\libANGLE\renderer\d3d\VertexDataManager.cpp, reserveSpaceForAttrib:520. Internal error: 0x00000502: Vertex buffer is not big enough for the draw call.

Testing
Tested the backport to v0.15 on https://github.com/rerun-io/rerun

@Wumpf Wumpf changed the title Fix webgl workaround draw single instance WebGl workaround for drawing single instance Mar 16, 2023
@Wumpf Wumpf force-pushed the fix-webgl-workaround-draw-single-instance branch from fda5e48 to 855b4e8 Compare March 16, 2023 18:04
Copy link
Collaborator

@grovesNL grovesNL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I think we need this for both C::Draw and C::DrawIndexed, so we could probably remove the instance_count == 1/draw_arrays branch in C::Draw entirely

wgpu-hal/src/gles/queue.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/mod.rs Outdated Show resolved Hide resolved
@Wumpf
Copy link
Member Author

Wumpf commented Mar 18, 2023

@grovesNL Given that Firefox just uses DrawArraysInstanced anyways in all circumstances (it's enabled for WebGL2 support which is a requirement for us), maybe we should simplify this entire PR down to just that and leave a comment? Is there any drawback to not always use the instanced version(s) in our hal layer?

Otherwise, only checking on is_angle sounds good! I thought this wouldn't work on the web correctly, but seems we get that information just fine.

@grovesNL
Copy link
Collaborator

grovesNL commented Mar 18, 2023

maybe we should simplify this entire PR down to just that and leave a comment

That sounds good to me. I think originally we were considering these fall back paths whenever we don't have instancing support, but our minimum requirements have been raised a bit since then.

@Wumpf Wumpf force-pushed the fix-webgl-workaround-draw-single-instance branch from 855b4e8 to d67ee29 Compare March 18, 2023 15:50
@Wumpf
Copy link
Member Author

Wumpf commented Mar 18, 2023

Done! Much simpler now, applied the same to the v0.15 backport :)

Copy link
Collaborator

@grovesNL grovesNL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@grovesNL grovesNL merged commit f183140 into gfx-rs:master Mar 20, 2023
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.

WebGL Internal error: 0x00000502: Vertex buffer is not big enough for the draw call
2 participants