servo / sparkle Goto Github PK
View Code? Open in Web Editor NEWGL bindings for Servo's WebGL implementation (alternative to the `gleam` crate)
GL bindings for Servo's WebGL implementation (alternative to the `gleam` crate)
Methods Gl::buffer_data
and Gl::sub_buffer_data
pass slices of arbitrary T
values to the GL system, but those T
s may have padding, which is uninitialised, which means we are passing uninitialised data to the GL system that may be read back by Rust later. The T
type parameter should be constrained by some sort of unsafe trait to prevent that.
Cargo.toml says it's MIT / Apache-2.0 but lib.rs says it's MPL2.0.
One thing we hit in webxr was that gleam doesn't provide a standard API for a GlFactory
, that would implement Send
and Clone
, and would build new Rc<dyn Gl>
objects. Servo rolls its own, but there's no way to have those be used by webxr without having webxr depend on servo. It might be nice to put that API in sparkle.
08:55 <nox> jdm: And read_pixels_into_buffer is unsound, cf all the params in https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glPixelStore.xhtml
08:58 <nox> Like, IIRC, if you set GL_PACK_ROW_LENGTH to a bigger value than the natural one, GL will write stuff outside of dst_buffer.
Those methods take a buffer, pass it to a GL API as a pointer, and let GL decide how many bytes it should read from it through a combination of other inputs (for example, width
and height
), these methods should be unsafe:
Furthermore, the GL functions for compressed textures also specify that undefined results can occur "if data
is not encoded in a manner consistent with the extension specification defining the internal compression format", so the two methods using them should probably marked as unsafe too:
Method Gl::get_tex_parameter_iv
when passed GL_TEXTURE_BORDER_COLOR
will try to write four integer values in a &mut GLint
which is obviously not large enough.
The same thing can happen with Gl::get_tex_parameter_fv
.
For now, it can't happen with Gl::get_framebuffer_attachment_parameter_iv
and Gl::get_renderbuffer_parameter_iv
because all framebuffer attachment and renderbuffer parameters are single-valued, but nothing guarantees us that this will be true of all GL extensions in the future, so I would make it unsafe too.
Cc @kvark with whom I had debated about that in the past when it was a problem in gleam
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.