Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement WebGL2 Uniform Buffer Objects #19250
Conversation
highfive
commented
Nov 16, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
Nov 16, 2017
|
Wait, we're using the compat profile? That seems like a mistake -- do we definitely need compat functionality, or is it something where OSMesa just doesn't have an interface for asking for core profiles? |
|
I think the reason we're using compat profile is because otherwise we can't support the webgl1 fixed function requirements? (drive by comment - could be missing something completely) |
|
I mean, I guess we could emulate them, if that is the reason we're using compat. |
|
It's just for WebGL 1.0 backwards compatibility. If we use a core context we'll need to emulate some compatibility stuff required in WebGL 1.0. For example WebGL 1 should work without creating any VAO and a core context triggers a errors if VAOs are not created. There might be another issues like this one. I tried to pass all the WebGL tests using a 3.2 core context and there were a bunch of errors that wold require some time to research. |
|
I don't see any fixed function GL in webgl 1, though. No TexEnv, no Begin/End, no user vertex arrays. |
| gl::TRANSFORM_FEEDBACK_BUFFER_SIZE | | ||
| gl::UNIFORM_BUFFER_SIZE => | ||
| Ok(WebGLParameter::Int64(gl.get_integer_64iv(name, index))), | ||
| // Invalid parameters |
This comment has been minimized.
This comment has been minimized.
anholt
Nov 27, 2017
Contributor
Possibly drop a comment here that the _BINDING enums are handled in the front end?
|
Looks good! Only a couple of little bugs I think I found. |
| _ => return self.base.BindBuffer(target, buffer), | ||
| }; | ||
|
|
||
| if let Some(buffer) = buffer { |
This comment has been minimized.
This comment has been minimized.
anholt
Nov 27, 2017
Contributor
I think you still want to call down to self.base.BindBuffer() here -- you've lost the validation of the enum to be either array or element_array.
| fn BufferData_(&self, target: u32, size: i64, usage: u32) -> Fallible<()> { | ||
| self.base.BufferData_(target, size, usage) | ||
| let bound_buffer = match target { |
This comment has been minimized.
This comment has been minimized.
anholt
Nov 27, 2017
Contributor
It would be nice if we could have a single helper function that returned the binding point (not the bound buffer) given the target enum.
| self.base.DeleteBuffer(buffer) | ||
| self.base.DeleteBuffer(buffer); | ||
| if let Some(buffer) = buffer { | ||
| handle_object_deletion!(self, self.bound_uniform_buffer, buffer, |
This comment has been minimized.
This comment has been minimized.
anholt
Nov 27, 2017
Contributor
You've added the TFB buffer elsewhere in the patch, want to do so here as well?
| let value = match target { | ||
| constants::TRANSFORM_FEEDBACK_BUFFER_BINDING => | ||
| return object_binding_to_js_or_null!(cx, &self.bound_transform_feedback_buffer), | ||
| constants::UNIFORM_BUFFER_BINDING => |
This comment has been minimized.
This comment has been minimized.
anholt
Nov 27, 2017
Contributor
These should be returning the indexed bound buffer, not the non-indexed binding's buffer. We would need to track a vec of bindings in BindBufferBase/Range according to the context limits, and also validate that the index is not greater than that array size, and then return them here.
| self.currently_bound.get() | ||
| } | ||
|
|
||
| pub fn set_currently_bound(&self, value: bool) { |
This comment has been minimized.
This comment has been minimized.
anholt
Nov 27, 2017
Contributor
I don't think this quite works. Bind a buffer to COPY_READ, then COPY_WRITE, then unbind from COPY_WRITE, and now it's "not currently bound" and we would allow it to be bound to TFB, right?
| @@ -1156,6 +1111,111 @@ impl WebGLRenderingContext { | |||
| } | |||
| } | |||
| } | |||
|
|
|||
This comment has been minimized.
This comment has been minimized.
anholt
Nov 27, 2017
Contributor
It would be nice if the refactors were split out from the functional content of the commit.
|
The typical process for handling core GL's VAO requirement is that you just have a single VAO that you bind when you're not otherwise doing VAO-based rendering (this is also essentially what Mesa does internally for the compat path). We could allocate a VAO at context creation, and bind it when the JS side hasn't bound one. If there's a branch you could share where you started this work, I might be interested in following up on it. |
|
|
|
Is this PR still relevant? |
|
This has been superseded by recent WebGL 2 work. |
MortimerGoro commentedNov 16, 2017
•
edited
Implement WebGL2 Uniform Buffer Objects.
Note: Currently OSMesa compat profiles only support OpenGL 3.0 (GLSL 130). Some UBO shaders used in WPT can't be compiled with GLSL 130, so part of the implementation is not fully tested (e.g.
Could not compile shader with uniform blocks without errorerrors in uniform-buffers.html test). All uniform-buffers.html render tests pass using the native GPU. I'll open an follow-up issue about that../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is