Servo: Fully implement WebGL 1.0

Created on 26 Mar 2016  ·  40Comments  ·  Source: servo/servo

This is intended to be a meta-bug.

Some of the remaining methods are blocked on https://github.com/servo/servo/issues/5014 (those that receive ArrayBufferView or BufferDataSource and have overrides), but some others can be implemented without problems.

I'll try to file individual issues for each remaining deficiency, since some of them can be E-Easy.

General information for WebGL bugs

Click to expand

Spec

The WebGL 1.0 spec is here.

GLES 2.0 spec

WebGL is based on the GLES 2.0 spec, so the WebGL spec often leverages details to it. You can find a PDF version here.

Current Code

DOM

The DOM side of the WebGL code can be found in the following files:

  • components/script/dom/webglrenderingcontext.rs
  • components/script/dom/webglactiveinfo.rs
  • components/script/dom/webglbuffer.rs
  • components/script/dom/webglcontextevent.rs
  • components/script/dom/webglframebuffer.rs
  • components/script/dom/webglobject.rs
  • components/script/dom/webglprogram.rs
  • components/script/dom/webglrenderbuffer.rs
  • components/script/dom/webglrenderingcontext.rs
  • components/script/dom/webglshader.rs
  • components/script/dom/webglshaderprecisionformat.rs
  • components/script/dom/webgltexture.rs
  • components/script/dom/webgluniformlocation.rs

WebGL thread

The WebGL thread is the thread that receives the WebGL messages from the DOM, and either executes it or dispatchs it to the WebRender backend.

You probably don't need to touch anything here, but in case you want to take a look, the file is:

  • components/canvas/webgl_paint_thread.rs

WebGL command definition, execution, and other types

The rest of the WebGL definitions and the command implementations are in webrender_traits's webgl.rs file, in order to be shared by both Servo and WebRender.

You'll want to take a look to the WebGLCommand definition and to the apply function.

To work actively with it the best is to use a Cargo override.

Note that WebGLCommand is re-exported from canvas_traits as CanvasWebGLMessage for legacy reasons (to avoid extra rebase pain while webrender hadn't merged yet).

Missing safety checks

  • [ ] Properly implement "Enabled Vertex Attributes and Range Checking" (#20599)
  • [ ] Check that we implement all GLSL constraints properly (#20601)
  • [ ] Properly implement "Completeness of Cube Map Framebuffer Attachments" (#20654)
  • [ ] Implement WebGL checks against feedback loops (#21288)
  • [ ] Properly implement stencil checks (#20555)
  • [ ] Initialize textures to transparent black in some cases (#21716)
  • [ ] Validate source passed to gl.shaderSource() (#21754)

Pending implementations

  • [ ] Support antialiasing's WebGL context option (#21285)
  • [ ] Support discarding and recreating WebGL contexts (#15266)
  • [ ] Implement compressed textures in WebGL (#20594)
  • [ ] Implement drawing a WebGL canvas into a 2D canvas (#21556)
  • [ ] Implement ImageBitmap (#20650)
  • [ ] Create smaller-than-requested drawing buffer when necessary (#21718)
  • [ ] WebGL canvas is scaled when made fullscreen (#21290)
  • [ ] Properly defend against overflows in WebGLRenderingContext.bufferSubData (#20558)

Other pending things and improvements

  • [ ] Steal Firefox knowledge about WebGL context robustness (#21144)
  • [ ] Properly support WebIDL extended attribute [AllowShared] (#20515)
  • [ ] Cache drawingBufferWidth/drawingBufferHeight in WebGLRenderingContext (#20530)
  • [ ] Cache result of WebGLRenderingContext.getContextAttributes (#20532)
  • [ ] Don't allocate an empty buffer for nothing in WebGLRenderingContext.bufferData (#20557)
  • [ ] Remove indirections for WebGL texture parameters (#20596)
  • [ ] Clean up the WebGL extension infrastructure (#20642)
  • [ ] Maybe introduce a new task source specific to WebGL (#20643)
  • [ ] Khronos tests for WebGL shouldn't use an index in the test name (#20668)
  • [ ] [Throws] does not apply per-overload (#20516)
  • [ ] Crash when loading shader on html5test.com (#21191)
  • [ ] WebGL water demo doesn't display anything (#21173)
  • [ ] Firefox reports larger "max varying vectors", "max color buffer", and "max combined texture units" limits than Servo (#21172)
  • [ ] Investigate real webgl-based apps (#21151)
  • [ ] Build a WebGL profiler (#21150)

Done stuff

  • [x] Check for invalid characters in WebGL location and attrib names (#21287)
  • [x] Audit the behaviour of WebGLRenderingContext.getProgramInfoLog (#20561)
  • [x] handle_object_deletion may be wrong (#21352)
  • [x] Clear the framebuffer when initializing and resizing WebGL canvas (#21475)
  • [x] Support unions as distinguishing WebIDL parameter (#20513)
  • [x] Implement the pending texImage2D overload (#10443)
  • [x] Implement copyTexImage2D (#11147)
  • [x] Implement copyTexSubImage2D (#11147)
  • [x] Implement detachShader (#10215)
  • [x] Implement finish (#10212, #10215)
  • [x] Implement flush (#10213, #10215)
  • [x] Implement framebufferRenderbuffer (#13639)
  • [x] Implement framebufferTexture2D (#13639)
  • [x] Implement generateMipmap (#10215)
  • [x] Implement getActiveAttrib (#10379)
  • [x] Implement getActiveUniform (#10397)
  • [x] Implement getAttachedShaders (#20411)
  • [x] Implement getFramebufferAttachmentParameter (#20317)
  • [x] Implement getProgramInfoLog (#13199)
  • [x] Implement getRenderbufferParameter (#20514)
  • [x] Implement getTexParameter (#20144)
  • [x] Implement getShaderPrecisionFormat (#16544)
  • [x] Implement getUniform (#21202)
  • [x] Implement getVertexAttrib
  • [x] Implement getVertexAttribOffset (#16893)
  • [x] Implement isBuffer (#11357)
  • [x] Implement isEnabled (#13040)
  • [x] Implement isFramebuffer (#11357)
  • [x] Implement isRenderBuffer (#11357)
  • [x] Implement isShader (#11072)
  • [x] Implement isTexture (#11072)
  • [x] Implement readPixels (#10668)
  • [x] Implement renderbufferStorage (#13872)
  • [x] Implement sampleCoverage
  • [x] Implement stencilFunc (#10659)
  • [x] Implement stencilFuncSeparate (#10659)
  • [x] Implement stencilMask (#10659)
  • [x] Implement stencilMaskSeparate (#10659)
  • [x] Implement stencilOp (#10659)
  • [x] Implement stencilOpSeparate (#10659)
  • [x] Implement texSubImage2D (#11168)
  • [x] Implement uniform1i (#10417)
  • [x] Implement uniform1iv (#10417)
  • [x] Implement uniform2f (#10356)
  • [x] Implement uniform2fv (#10417)
  • [x] Implement uniform2i (#10417)
  • [x] Implement uniform2iv (#10417)
  • [x] Implement uniform3f (#10417)
  • [x] Implement uniform3fv (#10417)
  • [x] Implement uniform3i (#10417)
  • [x] Implement uniform3iv (#10417)
  • [x] Implement uniform4i (#10368)
  • [x] Implement uniform4iv (#10368)
  • [x] Implement uniformMatrix2fv (#10671)
  • [x] Implement uniformMatrix3fv (#10671)
  • [x] Implement uniformMatrix4fv (#10671)
  • [x] Implement validateProgram (#13199)
  • [x] Properly check for limit in WebGLRenderingContext.activeTexture (#20531)
  • [x] Implement gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE) (#20535)
  • [x] Implement gl.getParameter(gl.BLEND_COLOR) (#20536)
  • [x] Implement gl.getParameter(gl.COLOR_CLEAR_VALUE) (#20537)
  • [x] Implement gl.getParameter(gl.COLOR_WRITEMASK) (#20538)
  • [x] Implement gl.getParameter(gl.COMPRESSED_TEXTURE_FORMATS) (#20544)
  • [x] Implement gl.getParameter(gl.DEPTH_RANGE) (#20545)
  • [x] Implement gl.getParameter(gl.GENERATE_MIPMAP_HINT) (#20546)
  • [x] Support IMPLEMENTATION_COLOR_READ_FORMAT and IMPLEMENTATION_COLOR_READ_TYPE (#20547)
  • [x] Support MAX_FRAGMENT_UNIFORM_VECTORS and MAX_VERTEX_UNIFORM_VECTORS (#20548)
  • [x] Implement gl.getParameter(gl.MAX_VARYING_VECTORS) (#20549)
  • [x] Support SCISSOR_TEST and SCISSOR_BOX (#20551)
  • [x] Implement gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL) (#20552)
  • [x] Implement gl.getParameter(gl.UNPACK_FLIP_Y_WEBGL) (#20553)
  • [x] Implement gl.getParameter(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL) (#20554)
  • [x] Properly implement WebGLRenderingContext.bindBuffer checks (#20556)
  • [x] Properly implement the checks for gl.renderbufferStorage (#20563)
  • [x] Audit the checks in WebGLRenderingContext.getFramebufferAttachmentParameter (#20593)
  • [x] Properly check the argument of WebGLRenderingContext.clear (#20623)
  • [x] Check whether we bind GLclampf correctly (#20652)
  • [x] Return the correct types in gl.getParameter and friends (#20655)
  • [x] Properly check that WebGL objects are passed to the right WebGL context (#21133)
  • [x] Implement attribute aliasing check in WebGL (#21136)
  • [x] Fix uninitialized data leak from renderbufferStorage (#13710)
  • [x] WebGLShader destructor frequently asserts when closing webgl pages (#21177)
  • [x] Re-check our validations when there are multiple WebGLRenderingContexts in the same page.
  • [x] Create tests for the changes in #20598 (#20607)
  • [x] Make our validations strongly-typed (#10693)
  • [x] Remove indirections for some WebGL parameters (#20550)
  • [x] Stop re-exporting WebGLCommand as CanvasWebGLMessage (https://github.com/servo/servo/issues/10211)
  • [x] Update our angle dependency
  • [x] Test using the WebGL conformance test suite (#10373)
  • [x] Update our interpretation of the spec to match other browser engines (#8753)
  • [x] Cache which server-side GL capabilities are enabled (#20534)
  • [x] Remove indirections for WebGL program parameters (#20560)
  • [x] Remove indirections for WebGL shader parameters (#20562)
  • [x] Audit that the framebuffer status is properly updated in WebGL (#20570)
  • [x] Cache the info needed for gl.getActiveAttrib and gl.getActiveUniform (#20600)
  • [x] Cache info needed for gl.getVertexAttrib and gl.getVertexAttribOffset (#20608)
  • [x] Only mark canvas as dirty when no framebuffer is bound (#21691)
  • [x] Check for renderbuffer storage exceeding max renderbuffer size (#21485)
  • [x] gl-pointcoord.html doesn't draw anything (#21719)
  • [x] oes-texture-half-float.html panics with a GL error when running in desktop mode (#21663)
  • [x] Implement component check in Image2D methods (#20595)
  • [x] Support preserveDrawingBuffer's WebGL context option (#21132)
A-contenwebgl B-meta

Most helpful comment

I plan to attempt glGetTexParameter.

All 40 comments

cc @dmarcos

I will be working on implementing generateMipmap

@ConnorGBrewster I opened https://github.com/servo/servo/issues/10226, let's discuss there :)

I'd like to work on getActiveUniform

@saurvs I opened https://github.com/servo/servo/issues/10397 for you, feel free to ask any question you might have there :)

I'd like to work on all of the remaining uniform methods, if that's okay

@autrilla They're yours! I've opened https://github.com/servo/servo/issues/10417 to keep track of them, feel free to leave any questions there :)

I'm looking at the stencil* functions.

I'm taking a crack at copyTex* and texSubImage2D

Attempting

Implement isShader
Implement isTexture

I would like to help texSubImage2D

@daoshengmu: sounds great!

@danlrobertson, are you still working on texSubImage2D?

@danlrobertson Sorry for I didn't notice you are working on texSubImage2D. I just want to help some implementation of WebGL. If you are still working on it, I can pick copyTexImage2D and copyTexSubImage2D @emilio

@daoshengmu No problem! It's totally okay! It's my bad for taking so long to get a PR in, but alas life happens :smile:...

Are you okay with taking texSubImage2D? I already implemented the necesary components in wr_traits. I should have a PR in shortly for copyTex*, but I actually hadn't started on texSubImage2D. If you want texSubImage2D, go for it! I have no particular attachment to it. Just wanted to learn a bit about webgl code...

@danlrobertson Sure. I will take texSubImage2D. Thanks! 😄

If it's okay I am going to work on
Implement isFramebuffer
and
Implement isRenderBuffer

@DDEFISHER go for it! Mind opening an issue for those so I can assign you there?

I am going to also work on isBuffer since it is similar to the other 2

Please make a comment here if you intend to work on this issue. Thank you!

Separate issues for individual APIs are E-easy material; not this one.

Can anyone point to an E-easy(ish) implementation I can work on? Thanks :)

@ofekd isEnabled might be a good choice, since enable and disable are already implemented!

@jdm I'll take it

@ofekd isEnabled might be tricky as a new contributor, because you need to change things across modules. Some of the testcases in webgl-specific.html, like the blending func or stencil func ones, should be really good starting points. invalid-passed-params.html likely also has good easy tasks.

@anholt As long as it's not significantly complicated I don't mind having to work some more. I didn't start working on this yet, but for starters it looks like I need to change:

webrender_traits/src/webgl.rs
servo/components/script/dom/webglrenderingcontext.rs
servo/components/script/dom/webidls/WebGLRenderingContext.webidl

Unless it somehow hinders other efforts, I would continue working on isEnabled

I'll be working on implementing validateProgram and getProgramInfoLog

I'll be working at uniformMatrix2fv, uniformMatrix3fv, uniformMatrix4fv and framebufferRenderbuffer, framebufferTexture2D, renderbufferStorage.

I'm going to run more demanding webgl demos and measure perf on servo and I need those functions ;)

@MortimerGoro I've been working on FBO support (see a couple of recent merges, and https://github.com/anholt/servo/tree/webgl-fbo). I also put together https://github.com/anholt/servo/tree/webgl-uniform-matrix-v for uniformmatrix, but the testing needs to get debugged.

@anholt awesome! do you need any help with the uniformmatrix testing?

@MortimerGoro just figuring out what's going on with the unreliable results.

I've opened #13639 for tracking FBO support. Want to add that to framebufferRenderbuffer/framebufferTexture2D?

@shravan-achar might be interested in working on the remaining ones here.

It looks like misisng toDataURL() for WebGL is the cause of a whole lot of remaining testcase issues (like asin_001_to_006.html)

Only 5 missing APIs now.

me, @taki-jaro, @mrowqa and @xanewok will work on this issue as a student project
cc @KiChjang

I plan to attempt glGetTexParameter.

Working on getFramebufferAttachmentParameter().

I'd like to do getRenderbufferParameter

This issue no longer seems to be keeping a record of edits anymore for some reason.

Edit: It looks to be working now.

I added a bunch of issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CYBAI picture CYBAI  ·  3Comments

jdm picture jdm  ·  3Comments

larsbergstrom picture larsbergstrom  ·  3Comments

mrobinson picture mrobinson  ·  3Comments

shinglyu picture shinglyu  ·  4Comments