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

Implement new WebGL interfaces and methods #6293

Merged
merged 1 commit into from Jun 9, 2015
Merged

Conversation

@emilio
Copy link
Member

emilio commented Jun 5, 2015

This commit implements:

  • WebGLFramebuffer
  • WebGLRenderbuffer
  • WebGLTexture

And adds the following methods to WebGLRenderingContext:

  • create{Texture,Framebuffer,Renderbuffer}
  • bind{Texture,Framebuffer,Renderbuffer}
  • destroy{Buffer,Texture,Framebuffer,Renderbuffer}

Fixes:

  • WebGLUniform location shouldn't inherit from WebGLObject.

Known Issues:

  • WebGL objects have to be destroyed on drop, we may want to keep a reference to the context, or maybe a clone of the renderer to achieve this

Also refactors a huge part of the current implementation, to allow
failing on creation of different WebGL objects.

Blocked on servo/gleam#22

A reftest for most of the added functionality is not doable right now,
we need a few more functions in order to upload a texture, for example.

Review on Reviewable

@highfive
Copy link

highfive commented Jun 5, 2015

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
@hoppipolla-critic-bot
Copy link

hoppipolla-critic-bot commented Jun 5, 2015

Critic review: https://critic.hoppipolla.co.uk/r/5197

This is an external review system which you may optionally use for the code review of your pull request.

In order to help critic track your changes, please do not make in-place history rewrites (e.g. via git rebase -i or git commit --amend) when updating this pull request.

@emilio
Copy link
Member Author

emilio commented Jun 5, 2015

r? @jdm | @glennw | @nox

@nox
Copy link
Member

nox commented Jun 5, 2015

Are there any interfaces extending WebGLObject that won't have a get_id() helper? If not, could it be moved there?

-S-awaiting-review +S-awaiting-answer +S-needs-code-changes


Review status: all files reviewed, 3 unresolved discussions, all commit checks successful.
Reviewed files:

  • components/canvas/lib.rs @ r1
  • components/canvas/webgl_paint_task.rs @ r1
  • components/canvas_traits/lib.rs @ r1
  • components/script/dom/mod.rs @ r1
  • components/script/dom/webglframebuffer.rs @ r1
  • components/script/dom/webglrenderbuffer.rs @ r1
  • components/script/dom/webglrenderingcontext.rs @ r1
  • components/script/dom/webgltexture.rs @ r1
  • components/script/dom/webgluniformlocation.rs @ r1
  • components/script/dom/webidls/WebGLFramebuffer.webidl @ r1
  • components/script/dom/webidls/WebGLRenderbuffer.webidl @ r1
  • components/script/dom/webidls/WebGLRenderingContext.webidl @ r1
  • components/script/dom/webidls/WebGLTexture.webidl @ r1

components/canvas/webgl_paint_task.rs, line 258 [r1] (raw file):
"compliant".

Any harm in not including it, if it's not spec-compliant?


components/script/dom/webglrenderingcontext.rs, line 139 [r1] (raw file):
Is there more harm in not supporting it at all than making it return 0 unconditionally?


components/script/dom/webglrenderingcontext.rs, line 402 [r1] (raw file):
This looks like a gratuitous rewrite, I prefer the version without potentially-panicking calls (the unwrappings)


Comments from the review on Reviewable.io

@emilio
Copy link
Member Author

emilio commented Jun 6, 2015

Actually not, there's no interface extending WebGLObject that doesn't implement a method like that, but at this point I'm a bit sceptical about it, I don't know why neither Firefox/Chromium expose it to the window, and I'd prefer not to add functionality there until I discover why.

@emilio
Copy link
Member Author

emilio commented Jun 6, 2015

Review status: all files reviewed, 3 unresolved discussions, all commit checks successful.


components/canvas/webgl_paint_task.rs, line 258 [r1] (raw file):
This call is not totally spec compliant (yet), since we should ensure all the shaders conform with GLES Shading Language 1.00. Right now we don't do that check, but I think removing shaders from our WebGL implementation, even if it's temporary, is a too high price.

I'd prefer to keep them, and add the sanity check after it, instead of removing the shader calls and rewrite them again later.

 A WebGL implementation must only accept shaders which conform to The OpenGL ES Shading Language, Version 1.00 [GLES20GLSL], and which do not exceed the minimum functionality mandated in Sections 4 and 5 of Appendix A. In particular: 

components/script/dom/webglrenderingcontext.rs, line 139 [r1] (raw file):
Well, that call is spec'd, and is totally legal not to have extension support, but I'll remove it if you want/


components/script/dom/webglrenderingcontext.rs, line 402 [r1] (raw file):
We check before and early return if any of those is None, it's safe to call unwrap there. I'll change it if you want, but I think it's cleaner this way.


Comments from the review on Reviewable.io

@nox
Copy link
Member

nox commented Jun 6, 2015

I didn't mean exposing it as a DOM method, but as a helper on WebGLObject directly, to avoid duplicating the field and the Rust method everywhere.


Review status: all files reviewed, 1 unresolved discussion, all commit checks successful.


components/script/dom/webglrenderingcontext.rs, line 402 [r1] (raw file):
The code flow is made less obvious and doesn't follows the shape of the Option type anymore. Pinging @Manishearth to decide because he like to discuss bikeshed paint.


Comments from the review on Reviewable.io

@emilio
Copy link
Member Author

emilio commented Jun 6, 2015

Yes, I supposed so, but what I was trying to say (sorry), is that gecko for example doesn't even have the interface (they have a base class for them, but not a DOM binding).

Anyways: The WebGL2 spec does spec some objects without id, like queries, so I think that even if now it could make sense to move it there, that change will have to be rolled back in the future.


Review status: all files reviewed, 1 unresolved discussion, all commit checks successful.


Comments from the review on Reviewable.io

@emilio emilio force-pushed the emilio:webgl-objects branch from c8638d0 to b84d494 Jun 6, 2015
@emilio
Copy link
Member Author

emilio commented Jun 6, 2015

I updated the tests and corrected the typo :)

@SimonSapin
Copy link
Member

SimonSapin commented Jun 6, 2015

Review status: 12 of 14 files reviewed, 1 unresolved discussion, all commit checks successful.


components/script/dom/webglrenderingcontext.rs, line 402 [r1] (raw file):
I also prefer the previous code, fwiw. Another option is to use the unwrap_or_return! macro from the mac crate. (That crate is already used by some of Servo’s dependencies.)


Comments from the review on Reviewable.io

@nox
Copy link
Member

nox commented Jun 6, 2015

Perfect, no other tests because we need to integrate Khronos test suite, right?

-S-awaiting-answer -S-awaiting-review

Update the bikeshed snippet and it can be merged.


Review status: all files reviewed, 1 unresolved discussion, all commit checks successful.
Reviewed files:

  • components/canvas/webgl_paint_task.rs @ r2
  • tests/wpt/mozilla/tests/mozilla/interfaces.html @ r2

Comments from the review on Reviewable.io

This commit implements:
* WebGLFramebuffer
* WebGLRenderbuffer
* WebGLTexture

And adds the following methods to `WebGLRenderingContext`:
* create{Texture,Framebuffer,Renderbuffer}
* bind{Texture,Framebuffer,Renderbuffer}
* destroy{Buffer,Texture,Framebuffer,Renderbuffer}

Fixes:
* WebGLUniform location shouldn't inherit from WebGLObject.

Known Issues:
* WebGL objects have to be destroyed on drop, we may want to keep a reference to the context, or maybe a clone of the renderer to achieve this

Also refactors a huge part of the current implementation, to allow
failing on creation of different WebGL objects.

Blocked on servo/gleam#22

A reftest for most of the added functionality is not doable right now,
we need a few more functions in order to upload a texture, for example.
@emilio emilio force-pushed the emilio:webgl-objects branch from b84d494 to 9f94d39 Jun 6, 2015
@emilio
Copy link
Member Author

emilio commented Jun 6, 2015

Reverted the changes then :P

You're right, I can't do reftests with this until I implement the tex* set of functions, and making simple html tests when we have to integrate more serious tests is not worth it I think.

@emilio
Copy link
Member Author

emilio commented Jun 6, 2015

By the way it's still blocked on servo/gleam#22, I don't know if you can review it.

@nox nox removed the S-awaiting-review label Jun 6, 2015
@nox
Copy link
Member

nox commented Jun 6, 2015

Review status: all files reviewed, 1 unresolved discussion, all commit checks successful.
Reviewed files:

  • components/script/dom/webglrenderingcontext.rs @ r3

Comments from the review on Reviewable.io

@nox nox self-assigned this Jun 6, 2015
@nox
Copy link
Member

nox commented Jun 8, 2015

@nox
Copy link
Member

nox commented Jun 8, 2015

@bors-servo: r+

-S-blocked-on-external

#6305 got merged.


Review status: all files reviewed, 1 unresolved discussion, all commit checks successful.


Comments from the review on Reviewable.io

@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2015

📌 Commit 9f94d39 has been approved by nox

@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2015

Testing commit 9f94d39 with merge d01d962...

bors-servo pushed a commit that referenced this pull request Jun 8, 2015
This commit implements:
* WebGLFramebuffer
* WebGLRenderbuffer
* WebGLTexture

And adds the following methods to `WebGLRenderingContext`:
* create{Texture,Framebuffer,Renderbuffer}
* bind{Texture,Framebuffer,Renderbuffer}
* destroy{Buffer,Texture,Framebuffer,Renderbuffer}

Fixes:
* WebGLUniform location shouldn't inherit from WebGLObject.

Known Issues:
* WebGL objects have to be destroyed on drop, we may want to keep a reference to the context, or maybe a clone of the renderer to achieve this

Also refactors a huge part of the current implementation, to allow
failing on creation of different WebGL objects.

Blocked on servo/gleam#22

A reftest for most of the added functionality is not doable right now,
we need a few more functions in order to upload a texture, for example.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6293)
<!-- Reviewable:end -->
@nox nox added the S-awaiting-merge label Jun 8, 2015
@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2015

💔 Test failed - linux2

@nox
Copy link
Member

nox commented Jun 9, 2015

@bors-servo: retry

@bors-servo
Copy link
Contributor

bors-servo commented Jun 9, 2015

Testing commit 9f94d39 with merge e09c555...

bors-servo pushed a commit that referenced this pull request Jun 9, 2015
This commit implements:
* WebGLFramebuffer
* WebGLRenderbuffer
* WebGLTexture

And adds the following methods to `WebGLRenderingContext`:
* create{Texture,Framebuffer,Renderbuffer}
* bind{Texture,Framebuffer,Renderbuffer}
* destroy{Buffer,Texture,Framebuffer,Renderbuffer}

Fixes:
* WebGLUniform location shouldn't inherit from WebGLObject.

Known Issues:
* WebGL objects have to be destroyed on drop, we may want to keep a reference to the context, or maybe a clone of the renderer to achieve this

Also refactors a huge part of the current implementation, to allow
failing on creation of different WebGL objects.

Blocked on servo/gleam#22

A reftest for most of the added functionality is not doable right now,
we need a few more functions in order to upload a texture, for example.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6293)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 9, 2015

☀️ Test successful - android, gonk, linux1, linux2, linux3, mac1, mac2

@bors-servo bors-servo merged commit 9f94d39 into servo:master Jun 9, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@emilio emilio deleted the emilio:webgl-objects branch Jun 9, 2015
@emilio
Copy link
Member Author

emilio commented Jun 9, 2015

@nox Thanks for taking the time to update gleam and merge this, I'm in my final exams period so I couldn't take the time :)

@nox
Copy link
Member

nox commented Jun 9, 2015

@ecoal95 Thanks for your contribution, I hope you'll have good marks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.