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

Specify and test how texture upload should work with video elements #3309

Open
kimmok opened this issue Aug 9, 2021 · 2 comments
Open

Specify and test how texture upload should work with video elements #3309

kimmok opened this issue Aug 9, 2021 · 2 comments

Comments

@kimmok
Copy link

kimmok commented Aug 9, 2021

Specify and test how texture upload should work with video elements.

https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.9

The obvious expectation would be that the texture would be the size of HTMLVideoElement.videoWidth/videoHeight.

However, texture-corner-case-videos.html does not catch this expectation.

In fact, the test was modified to pass the inverse of this, e.g. behavior where the texture might be smaller.

Also, texture-corner-case-videos seems to contain hidden errors for the texSubImage2D case. The logic is that the texture is created with HTMLVideoElement.videoWidth/videoHeight but then uploaded with texSubImage2D. The upload might be smaller than videoWidth, videoHeight, but this is not caught by the test.

So the ideal intention in #2464 was to let the browser upload video data unscaled 1:1. However, this is problematic as:

  1. it is not specified how it works
  2. tests about it have bugs
  3. it is not possible to use it after it is specified, as the needed property (video data size) is not available in HTMLVideoElement. E.g. you can upload unscaled, but using texSubImage2D to update is impossible as we have no way of knowing what parameters pass as x,y,w,h.

Here's a small tester to print rudimentary cases of how the current browsers work:
webgl-video-element-texture-size-tester.zip

WebCodecs expose the needed data, but that behavior is not specified in WebGL either.

@kdashg
Copy link
Contributor

kdashg commented Aug 12, 2021

Here's a jsfiddle with a src-less Image upload:
https://jsfiddle.net/w25r0b1k/

Behavior is different between Firefox and Chrome.

@kdashg
Copy link
Contributor

kdashg commented Jul 14, 2022

I agree that it feels like we should map:

texImage2D(GLenum target, GLint level, GLint internalformat, GLenum format, GLenum type,
                       HTMLVideoElement video); {
    texImage2D(target, level, internalformat, video.videoWidth, video.videoHeight, 0, format, type, video); // webgl2 entrypoint
}

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

No branches or pull requests

2 participants