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 the basic WebGL2 buffer data operations #24473

Merged
merged 1 commit into from Nov 5, 2019

Conversation

@mmatyas
Copy link
Contributor

mmatyas commented Oct 17, 2019

Adds support for the WebGL2 calls bufferData, bufferSubData, copyBufferSubData and getBufferSubData.

Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.3


This patch depends on servo/sparkle#8. Some tests cause a crash for me at the moment, as they depend on other, not yet implemented buffer calls and transform feedback objects.

As for the code, there are a few parts I'm not sure about:

  • To get the element byte size of a TypedArray I've wrote a simple match, as the relevant field is not published in rust-mozjs. Is that okay or there's some other way to get this already?
  • The WebGL1 BufferData implementations were copied into the WebGL2 code as a workaround, due to the difference in the available buffer slots (ie. self.bound_buffer). An alternative could be is to pass this function and self as parameters to an internal buffer data implementation function, but personally I found that code to be quite ugly.

cc @jdm @zakorgy


  • ./mach build -d does not report any errors (with the sparkle patch)
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because ___
@highfive
Copy link

highfive commented Oct 17, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/webidls/WebGL2RenderingContext.webidl, components/script/dom/webglrenderingcontext.rs, components/script/dom/webgl2renderingcontext.rs, components/script/dom/webglbuffer.rs
  • @jgraham: tests/wpt/webgl/meta/conformance2/buffers/buffer-copying-contents.html.ini, tests/wpt/webgl/meta/conformance2/buffers/get-buffer-sub-data-validity.html.ini, tests/wpt/webgl/meta/conformance2/buffers/get-buffer-sub-data.html.ini, tests/wpt/webgl/meta/conformance2/buffers/buffer-data-and-buffer-sub-data-sub-source.html.ini, tests/wpt/webgl/meta/conformance2/buffers/buffer-copying-restrictions.html.ini
  • @KiChjang: components/script/dom/webidls/WebGL2RenderingContext.webidl, components/script/dom/webglrenderingcontext.rs, components/script/dom/webgl2renderingcontext.rs, components/script/dom/webglbuffer.rs
@highfive
Copy link

highfive commented Oct 17, 2019

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
Copy link
Member

jdm left a comment

Looks pretty good! I'm curious about the new failing test results, though.

@mmatyas mmatyas force-pushed the mmatyas:webgl_fns_buffer branch from 1e4bf8d to 31aff06 Oct 18, 2019
@mmatyas mmatyas force-pushed the mmatyas:webgl_fns_buffer branch from 31aff06 to f4f9e57 Oct 18, 2019
@mmatyas
Copy link
Contributor Author

mmatyas commented Oct 18, 2019

Took a fresh look on the tests, and I've managed to fix the crashes. pass the rest and also reduce the code code duplication between the WebGL1 and 2 code.

@mmatyas mmatyas force-pushed the mmatyas:webgl_fns_buffer branch 2 times, most recently from 97ff135 to 374fd88 Oct 18, 2019
@jdm
Copy link
Member

jdm commented Oct 24, 2019

r? @nox
Can you take a look at these changes?

@highfive highfive assigned nox and unassigned jdm Oct 24, 2019
Copy link
Member

nox left a comment

Seems ok to me, just a couple of questions.

Cargo.toml Outdated
@@ -33,3 +33,4 @@ rand_core = { git = "https://github.com/servo/rand", branch = "servo-rand_os-0.1
autocfg = { git = "https://github.com/servo/autocfg", branch = "rustflags" }
# https://github.com/retep998/winapi-rs/pull/816
winapi = { git = "https://github.com/servo/winapi-rs", branch = "patch-1" }
sparkle = { git = "https://github.com/servo/sparkle", branch = "master" }

This comment has been minimized.

@nox

nox Oct 24, 2019

Member

Why?

This comment has been minimized.

@mmatyas

mmatyas Oct 25, 2019

Author Contributor

There have been a few new commits since the last published version of sparkle (ie. servo/sparkle#8 has landed). I can remove it when @jdm increases the version.

This comment has been minimized.

@jdm

jdm Oct 28, 2019

Member

Published 0.1.7.

@jdm jdm assigned jdm and unassigned nox Oct 28, 2019
@mmatyas mmatyas force-pushed the mmatyas:webgl_fns_buffer branch from 374fd88 to 1e11e3e Oct 29, 2019
@mmatyas
Copy link
Contributor Author

mmatyas commented Oct 29, 2019

Updated with the sparkle version bump.

@jdm
Copy link
Member

jdm commented Oct 29, 2019

@bors-servo r=nox,jdm

@bors-servo
Copy link
Contributor

bors-servo commented Oct 29, 2019

📌 Commit 1e11e3e has been approved by nox,jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

💔 Test failed - linux-rel-wpt

Adds support for `bufferData`, `bufferSubData`, `copyBufferSubData`
and `getBufferSubData`.

Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.3
@mmatyas mmatyas force-pushed the mmatyas:webgl_fns_buffer branch from 77fdd2b to 4050b7f Nov 5, 2019
@highfive highfive removed the S-tests-failed label Nov 5, 2019
@community-tc-integration

This comment has been minimized.

Copy link

community-tc-integration bot commented on 4050b7f Nov 5, 2019

Submitting the task to Taskcluster failed. Details

Taskcluster-GitHub attempted to create a task for this event with the following scopes:

[
  "assume:repo:github.com/servo/servo:pull-request",
  "queue:route:statuses",
  "queue:scheduler-id:taskcluster-github"
]

The expansion of these scopes is not sufficient to create the task, leading to the following:

Client ID static/taskcluster/github does not have sufficient scopes and is missing the following scopes:

{
  "AnyOf": [
    {
      "AnyOf": [
        "queue:create-task:highest:aws-provisioner-v1/servo-docker-untrusted",
        "queue:create-task:very-high:aws-provisioner-v1/servo-docker-untrusted",
        "queue:create-task:high:aws-provisioner-v1/servo-docker-untrusted",
        "queue:create-task:medium:aws-provisioner-v1/servo-docker-untrusted",
        "queue:create-task:low:aws-provisioner-v1/servo-docker-untrusted",
        "queue:create-task:very-low:aws-provisioner-v1/servo-docker-untrusted",
        "queue:create-task:lowest:aws-provisioner-v1/servo-docker-untrusted"
      ]
    },
    {
      "AnyOf": [
        "queue:create-task:aws-provisioner-v1/servo-docker-untrusted",
        {
          "AllOf": [
            "queue:define-task:aws-provisioner-v1/servo-docker-untrusted",
            "queue:task-group-id:taskcluster-github/CybUaT64RIe8YSwjvjtSFQ",
            "queue:schedule-task:taskcluster-github/CybUaT64RIe8YSwjvjtSFQ/CybUaT64RIe8YSwjvjtSFQ"
          ]
        }
      ]
    }
  ]
}

This request requires the client to satisfy the following scope expression:

{
  "AllOf": [
    "assume:repo:github.com/servo/servo:pull-request",
    "queue:route:tc-treeherder.v2._/servo-prs.4050b7f9eca4c581d100fed778fa09f21d7e09dd",
    "queue:route:tc-treeherder-staging.v2._/servo-prs.4050b7f9eca4c581d100fed778fa09f21d7e09dd",
    "queue:route:statuses",
    {
      "AnyOf": [
        {
          "AllOf": [
            "queue:scheduler-id:taskcluster-github",
            {
              "AnyOf": [
                "queue:create-task:highest:aws-provisioner-v1/servo-docker-untrusted",
                "queue:create-task:very-high:aws-provisioner-v1/servo-docker-untrusted",
                "queue:create-task:high:aws-provisioner-v1/servo-docker-untrusted",
                "queue:create-task:medium:aws-provisioner-v1/servo-docker-untrusted",
                "queue:create-task:low:aws-provisioner-v1/servo-docker-untrusted",
                "queue:create-task:very-low:aws-provisioner-v1/servo-docker-untrusted",
                "queue:create-task:lowest:aws-provisioner-v1/servo-docker-untrusted"
              ]
            }
          ]
        },
        {
          "AnyOf": [
            "queue:create-task:aws-provisioner-v1/servo-docker-untrusted",
            {
              "AllOf": [
                "queue:define-task:aws-provisioner-v1/servo-docker-untrusted",
                "queue:task-group-id:taskcluster-github/CybUaT64RIe8YSwjvjtSFQ",
                "queue:schedule-task:taskcluster-github/CybUaT64RIe8YSwjvjtSFQ/CybUaT64RIe8YSwjvjtSFQ"
              ]
            }
          ]
        }
      ]
    }
  ]
}

  • method: createTask
  • errorCode: InsufficientScopes
  • statusCode: 403
  • time: 2019-11-05T10:35:21.647Z
@mmatyas
Copy link
Contributor Author

mmatyas commented Nov 5, 2019

Well I've looked into the issue but I'm not sure whether it's related to the buffers or not. Like the other one, this test also goes further with copyBufferSubData available, then checks the result of drawElements, but the canvas doesn't have the expected colors in headless mode. The buffer operations seem to be working fine though and the test does pass in non-headless mode. Because of that I'm not sure where the error comes from; I've updated the test expectations for now.

@jdm
Copy link
Member

jdm commented Nov 5, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2019

📌 Commit 4050b7f has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2019

Testing commit 4050b7f with merge 42aecf5...

bors-servo added a commit that referenced this pull request Nov 5, 2019
Implement the basic WebGL2 buffer data operations

Adds support for the WebGL2 calls `bufferData`, `bufferSubData`, `copyBufferSubData` and `getBufferSubData`.

Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.3

---

<!-- Please describe your changes on the following line: -->

This patch depends on servo/sparkle#8. Some tests cause a crash for me at the moment, as they depend on other, not yet implemented buffer calls and transform feedback objects.

As for the code, there are a few parts I'm not sure about:

- To get the element byte size of a TypedArray I've wrote a simple `match`, as the relevant field is not published in `rust-mozjs`. Is that okay or there's some other way to get this already?
- The WebGL1 BufferData implementations were copied into the WebGL2 code as a workaround, due to the difference in the available buffer slots (ie. `self.bound_buffer`). An alternative could be is to pass this function and self as parameters to an internal buffer data implementation function, but personally I found that code to be quite ugly.

cc @jdm @zakorgy

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors (with the sparkle patch)
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Nov 5, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2019

💣 Failed to start rebuilding: Unknown error

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2019

Testing commit 4050b7f with merge afbcbf7...

bors-servo added a commit that referenced this pull request Nov 5, 2019
Implement the basic WebGL2 buffer data operations

Adds support for the WebGL2 calls `bufferData`, `bufferSubData`, `copyBufferSubData` and `getBufferSubData`.

Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.3

---

<!-- Please describe your changes on the following line: -->

This patch depends on servo/sparkle#8. Some tests cause a crash for me at the moment, as they depend on other, not yet implemented buffer calls and transform feedback objects.

As for the code, there are a few parts I'm not sure about:

- To get the element byte size of a TypedArray I've wrote a simple `match`, as the relevant field is not published in `rust-mozjs`. Is that okay or there's some other way to get this already?
- The WebGL1 BufferData implementations were copied into the WebGL2 code as a workaround, due to the difference in the available buffer slots (ie. `self.bound_buffer`). An alternative could be is to pass this function and self as parameters to an internal buffer data implementation function, but personally I found that code to be quite ugly.

cc @jdm @zakorgy

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors (with the sparkle patch)
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: jdm
Pushing afbcbf7 to master...

@bors-servo bors-servo merged commit 4050b7f into servo:master Nov 5, 2019
2 checks passed
2 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Nov 5, 2019
3 of 3 tasks complete
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

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