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] Fix index buffer usage #3682

Merged
merged 2 commits into from
Mar 24, 2021
Merged

Conversation

Gordon-F
Copy link
Contributor

Fixes #3669
PR checklist:

  • make succeeds (on *nix)
  • make reftests succeeds
  • tested examples with the following backends: WebGL/OpenGL

Currently, the problem is not fully resolved:
image

@kvark
Copy link
Member

kvark commented Mar 17, 2021

At least the index buffer works now? 🎉

@Gordon-F
Copy link
Contributor Author

At least the index buffer works now?

Yes, now we can allocate an index buffer and send data to it. But I don't know why this buffer also used for other data even if it doesn't have Usage::TRANSFER_SRC flag.

@Gordon-F Gordon-F marked this pull request as ready for review March 23, 2021 21:35
@Gordon-F
Copy link
Contributor Author

@kvark Texture problem seems unrelated to buffer usage. I'm trying to investigate what's wrong. Anyway index buffer fix should be ready to merge.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Looks great!
A few nits I commented are not too important.
One question in the end is perhaps good to resolve before merging.

@@ -115,7 +114,7 @@ pub enum Command {
SetBlendSlot(ColorSlot, Option<pso::BlendState>),
BindAttribute(n::AttributeDesc, n::RawBuffer, i32, u32),
//UnbindAttribute(n::AttributeDesc),
CopyBufferToBuffer(n::RawBuffer, n::RawBuffer, command::BufferCopy),
CopyBufferToBuffer(n::RawBuffer, n::RawBuffer, u32, u32, command::BufferCopy),
Copy link
Member

Choose a reason for hiding this comment

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

note for the future: we should refactor this an other variants to have named fields. A bare number is too ambiguous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this one, and added TODO to fix others.

src/backend/gl/src/device.rs Outdated Show resolved Hide resolved
src/backend/gl/src/native.rs Outdated Show resolved Hide resolved
@@ -233,10 +233,11 @@ impl Device {
gl.use_program(Some(program));
}
for (name, &(register, slot)) in name_binding_map.iter() {
log::trace!("Get binding {:?} from program {:?}", name, program);
Copy link
Member

Choose a reason for hiding this comment

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

nit: the backend currently imports the macros from log, so it can be just trace! here.
At the end of the day, I'd prefer all the code to use the style you used here with fully-qualified log, but it's not very important to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in separate commit. I'm also prefer log:: style.

&& dst_target == glow::ELEMENT_ARRAY_BUFFER;

let copy_src_target = glow::COPY_READ_BUFFER;
let copy_dst_target = if is_index_buffer_only_element_dst {
Copy link
Member

Choose a reason for hiding this comment

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

why not just use the dst_target directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved comment higher

// WebGL not allowed to copy data from other targets to element buffer and can't copy element data to other buffers

Copy link
Member

@kvark kvark 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, this is high quality code!
bors r+

@bors
Copy link
Contributor

bors bot commented Mar 24, 2021

Merge conflict.

@kvark
Copy link
Member

kvark commented Mar 24, 2021

Still CI errors

@Gordon-F
Copy link
Contributor Author

Still CI errors

Sorry, should be fixed now! But looks like CI is stuck 🤔

@kvark
Copy link
Member

kvark commented Mar 24, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 24, 2021

@bors bors bot merged commit f3df513 into gfx-rs:master Mar 24, 2021
@Gordon-F Gordon-F deleted the webgl_index_buffer branch March 24, 2021 16:59
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.

[GL] Rebind buffer to another target panic on WebGL
2 participants