GitHub PullRequestReviewCommentEvent at 2014-08-26 02:38:21
Repository: gfx-rs
Actor: bjz
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/comments/16693185","id":16693185,"diff_hunk":"@@ -0,0 +1,181 @@\n+// Copyright 2014 The Gfx-rs Developers.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+//! Batches are structures containing all the data required for the draw call,\n+//! except for the target frame. Here we define the `Batch` trait as well as\n+//! `LightBatch` and `HeavyBatch` implementations.\n+\n+use device::ProgramHandle;\n+use mesh::{Mesh, Slice};\n+use shade::{ParameterError, ShaderParam};\n+use state::DrawState;\n+\n+struct MeshLink; //TODO\n+\n+/// An error occurring at batch creation\n+#[deriving(Clone, Show)]\n+pub enum BatchError {\n+    /// Error connecting shader parameters\n+    ErrorParameters(ParameterError),\n+}\n+\n+/// Abstract batch trait\n+pub trait Batch {\n+    /// Obtain information about the mesh, program, and state\n+    fn get_data(&self) -> (&Mesh, Slice, &ProgramHandle, &DrawState);\n+    /// Fill shader parameter values\n+    fn fill_params(&self, ::shade::ParamValues);\n+}\n+\n+/// Heavy Batch - self-contained, but has heap-allocated data\n+pub struct HeavyBatch<L, T> {\n+    mesh: Mesh,\n+    mesh_link: MeshLink,\n+    /// Mesh slice\n+    pub slice: Slice,\n+    program: ProgramHandle,\n+    param: T,\n+    param_link: L,\n+    /// Draw state\n+    pub state: DrawState,\n+}\n+\n+impl<L, T: ShaderParam<L>> HeavyBatch<L, T> {\n+    /// Create a new heavy batch\n+    pub fn new(mesh: Mesh, program: ProgramHandle, param: T)\n+           -> Result<HeavyBatch<L, T>, BatchError> {\n+        let slice = mesh.get_slice(::device::TriangleList);\n+        let link = match ShaderParam::create_link(None::<T>, program.get_info()) {\n+            Ok(l) => l,\n+            Err(e) => return Err(ErrorParameters(e))\n+        };\n+        Ok(HeavyBatch {\n+            mesh: mesh,\n+            mesh_link: MeshLink,\n+            slice: slice,\n+            program: program,\n+            param: param,\n+            param_link: link,\n+            state: DrawState::new(),\n+        })\n+    }\n+}\n+\n+impl<'a, L, T: ShaderParam<L>> Batch for &'a HeavyBatch<L, T> {\n+    fn get_data(&self) -> (&Mesh, Slice, &ProgramHandle, &DrawState) {\n+        (&self.mesh, self.slice, &self.program, &self.state)\n+    }\n+\n+    fn fill_params(&self, values: ::shade::ParamValues) {\n+        self.param.fill_params(&self.param_link, values);\n+    }\n+}\n+\n+type Index = u16;\n+\n+struct Id<T>(Index);\n+\n+struct Array<T> {\n+    data: Vec<T>,\n+    //generation: u16,\n+}\n+\n+impl<T> Array<T> {\n+    fn new() -> Array<T> {\n+        Array {\n+            data: Vec::new(),\n+            //generation: 0,\n+        }\n+    }\n+\n+    fn get(&self, id: Id<T>) -> &T {\n+        let Id(i) = id;\n+        &self.data[i as uint]\n+    }\n+}\n+\n+impl<T: Clone + PartialEq> Array<T> {\n+    fn find_or_insert(&mut self, value: &T) -> Id<T> {\n+        let i = self.data.iter().position(|v| v == value).unwrap_or_else(|| {\n+            let i = self.data.len();\n+            self.data.push(value.clone());\n+            i\n+        });\n+        Id(i as Index)\n+    }\n+}\n+\n+\n+/// Light Batch - copyable and smaller, but depends on the Context","path":"src/render/batch.rs","position":120,"original_position":120,"commit_id":"3b28cb52b6e2f4105cb4b02719311f554e6c544f","original_commit_id":"3b28cb52b6e2f4105cb4b02719311f554e6c544f","user":{"login":"bjz","id":695077,"avatar_url":"https://avatars.githubusercontent.com/u/695077?v=2","gravatar_id":"e52a48f76fc911d40711f788d74773a0","url":"https://api.github.com/users/bjz","html_url":"https://github.com/bjz","followers_url":"https://api.github.com/users/bjz/followers","following_url":"https://api.github.com/users/bjz/following{/other_user}","gists_url":"https://api.github.com/users/bjz/gists{/gist_id}","starred_url":"https://api.github.com/users/bjz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjz/subscriptions","organizations_url":"https://api.github.com/users/bjz/orgs","repos_url":"https://api.github.com/users/bjz/repos","events_url":"https://api.github.com/users/bjz/events{/privacy}","received_events_url":"https://api.github.com/users/bjz/received_events","type":"User","site_admin":false},"body":"Could you expand on what `depends on the Context` means? Also, enclose all identifiers with back-ticks as a general rule.","created_at":"2014-08-26T02:38:21Z","updated_at":"2014-08-26T02:38:21Z","html_url":"https://github.com/gfx-rs/gfx-rs/pull/285#discussion_r16693185","pull_request_url":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/285","_links":{"self":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/comments/16693185"},"html":{"href":"https://github.com/gfx-rs/gfx-rs/pull/285#discussion_r16693185"},"pull_request":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/285"}}},"pull_request":{"url":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/285","id":20283967,"html_url":"https://github.com/gfx-rs/gfx-rs/pull/285","diff_url":"https://github.com/gfx-rs/gfx-rs/pull/285.diff","patch_url":"https://github.com/gfx-rs/gfx-rs/pull/285.patch","issue_url":"https://api.github.com/repos/gfx-rs/gfx-rs/issues/285","number":285,"state":"open","locked":false,"title":"[WIP] Batching","user":{"login":"sectopod","id":8523093,"avatar_url":"https://avatars.githubusercontent.com/u/8523093?v=2","gravatar_id":"ce2f43baff6d9e7079e78f04b17f34f2","url":"https://api.github.com/users/sectopod","html_url":"https://github.com/sectopod","followers_url":"https://api.github.com/users/sectopod/followers","following_url":"https://api.github.com/users/sectopod/following{/other_user}","gists_url":"https://api.github.com/users/sectopod/gists{/gist_id}","starred_url":"https://api.github.com/users/sectopod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sectopod/subscriptions","organizations_url":"https://api.github.com/users/sectopod/orgs","repos_url":"https://api.github.com/users/sectopod/repos","events_url":"https://api.github.com/users/sectopod/events{/privacy}","received_events_url":"https://api.github.com/users/sectopod/received_events","type":"User","site_admin":false},"body":"Closes #282","created_at":"2014-08-26T02:01:46Z","updated_at":"2014-08-26T02:38:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"483e19b2c19431ac01f3461a36cc0bc718150dc1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/285/commits","review_comments_url":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/285/comments","review_comment_url":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/gfx-rs/gfx-rs/issues/285/comments","statuses_url":"https://api.github.com/repos/gfx-rs/gfx-rs/statuses/3b28cb52b6e2f4105cb4b02719311f554e6c544f","head":{"label":"sectopod:batch","ref":"batch","sha":"3b28cb52b6e2f4105cb4b02719311f554e6c544f","user":{"login":"sectopod","id":8523093,"avatar_url":"https://avatars.githubusercontent.com/u/8523093?v=2","gravatar_id":"ce2f43baff6d9e7079e78f04b17f34f2","url":"https://api.github.com/users/sectopod","html_url":"https://github.com/sectopod","followers_url":"https://api.github.com/users/sectopod/followers","following_url":"https://api.github.com/users/sectopod/following{/other_user}","gists_url":"https://api.github.com/users/sectopod/gists{/gist_id}","starred_url":"https://api.github.com/users/sectopod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sectopod/subscriptions","organizations_url":"https://api.github.com/users/sectopod/orgs","repos_url":"https://api.github.com/users/sectopod/repos","events_url":"https://api.github.com/users/sectopod/events{/privacy}","received_events_url":"https://api.github.com/users/sectopod/received_events","type":"User","site_admin":false},"repo":{"id":23224769,"name":"gfx-rs","full_name":"sectopod/gfx-rs","owner":{"login":"sectopod","id":8523093,"avatar_url":"https://avatars.githubusercontent.com/u/8523093?v=2","gravatar_id":"ce2f43baff6d9e7079e78f04b17f34f2","url":"https://api.github.com/users/sectopod","html_url":"https://github.com/sectopod","followers_url":"https://api.github.com/users/sectopod/followers","following_url":"https://api.github.com/users/sectopod/following{/other_user}","gists_url":"https://api.github.com/users/sectopod/gists{/gist_id}","starred_url":"https://api.github.com/users/sectopod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sectopod/subscriptions","organizations_url":"https://api.github.com/users/sectopod/orgs","repos_url":"https://api.github.com/users/sectopod/repos","events_url":"https://api.github.com/users/sectopod/events{/privacy}","received_events_url":"https://api.github.com/users/sectopod/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sectopod/gfx-rs","description":"A high-performance, bindless graphics API for Rust.","fork":true,"url":"https://api.github.com/repos/sectopod/gfx-rs","forks_url":"https://api.github.com/repos/sectopod/gfx-rs/forks","keys_url":"https://api.github.com/repos/sectopod/gfx-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sectopod/gfx-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sectopod/gfx-rs/teams","hooks_url":"https://api.github.com/repos/sectopod/gfx-rs/hooks","issue_events_url":"https://api.github.com/repos/sectopod/gfx-rs/issues/events{/number}","events_url":"https://api.github.com/repos/sectopod/gfx-rs/events","assignees_url":"https://api.github.com/repos/sectopod/gfx-rs/assignees{/user}","branches_url":"https://api.github.com/repos/sectopod/gfx-rs/branches{/branch}","tags_url":"https://api.github.com/repos/sectopod/gfx-rs/tags","blobs_url":"https://api.github.com/repos/sectopod/gfx-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sectopod/gfx-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sectopod/gfx-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/sectopod/gfx-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sectopod/gfx-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/sectopod/gfx-rs/languages","stargazers_url":"https://api.github.com/repos/sectopod/gfx-rs/stargazers","contributors_url":"https://api.github.com/repos/sectopod/gfx-rs/contributors","subscribers_url":"https://api.github.com/repos/sectopod/gfx-rs/subscribers","subscription_url":"https://api.github.com/repos/sectopod/gfx-rs/subscription","commits_url":"https://api.github.com/repos/sectopod/gfx-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/sectopod/gfx-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/sectopod/gfx-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/sectopod/gfx-rs/issues/comments/{number}","contents_url":"https://api.github.com/repos/sectopod/gfx-rs/contents/{+path}","compare_url":"https://api.github.com/repos/sectopod/gfx-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sectopod/gfx-rs/merges","archive_url":"https://api.github.com/repos/sectopod/gfx-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sectopod/gfx-rs/downloads","issues_url":"https://api.github.com/repos/sectopod/gfx-rs/issues{/number}","pulls_url":"https://api.github.com/repos/sectopod/gfx-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/sectopod/gfx-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/sectopod/gfx-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sectopod/gfx-rs/labels{/name}","releases_url":"https://api.github.com/repos/sectopod/gfx-rs/releases{/id}","created_at":"2014-08-22T12:36:06Z","updated_at":"2014-08-20T19:26:24Z","pushed_at":"2014-08-26T02:24:35Z","git_url":"git://github.com/sectopod/gfx-rs.git","ssh_url":"git@github.com:sectopod/gfx-rs.git","clone_url":"https://github.com/sectopod/gfx-rs.git","svn_url":"https://github.com/sectopod/gfx-rs","homepage":"http://gfx-rs.github.io/","size":832,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gfx-rs:master","ref":"master","sha":"13e1a873ba41532e92f6f5b53ae29947d830f1b6","user":{"login":"gfx-rs","id":8213174,"avatar_url":"https://avatars.githubusercontent.com/u/8213174?v=2","gravatar_id":null,"url":"https://api.github.com/users/gfx-rs","html_url":"https://github.com/gfx-rs","followers_url":"https://api.github.com/users/gfx-rs/followers","following_url":"https://api.github.com/users/gfx-rs/following{/other_user}","gists_url":"https://api.github.com/users/gfx-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/gfx-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfx-rs/subscriptions","organizations_url":"https://api.github.com/users/gfx-rs/orgs","repos_url":"https://api.github.com/users/gfx-rs/repos","events_url":"https://api.github.com/users/gfx-rs/events{/privacy}","received_events_url":"https://api.github.com/users/gfx-rs/received_events","type":"Organization","site_admin":false},"repo":{"id":13847975,"name":"gfx-rs","full_name":"gfx-rs/gfx-rs","owner":{"login":"gfx-rs","id":8213174,"avatar_url":"https://avatars.githubusercontent.com/u/8213174?v=2","gravatar_id":null,"url":"https://api.github.com/users/gfx-rs","html_url":"https://github.com/gfx-rs","followers_url":"https://api.github.com/users/gfx-rs/followers","following_url":"https://api.github.com/users/gfx-rs/following{/other_user}","gists_url":"https://api.github.com/users/gfx-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/gfx-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfx-rs/subscriptions","organizations_url":"https://api.github.com/users/gfx-rs/orgs","repos_url":"https://api.github.com/users/gfx-rs/repos","events_url":"https://api.github.com/users/gfx-rs/events{/privacy}","received_events_url":"https://api.github.com/users/gfx-rs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gfx-rs/gfx-rs","description":"A high-performance, bindless graphics API for Rust.","fork":false,"url":"https://api.github.com/repos/gfx-rs/gfx-rs","forks_url":"https://api.github.com/repos/gfx-rs/gfx-rs/forks","keys_url":"https://api.github.com/repos/gfx-rs/gfx-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gfx-rs/gfx-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gfx-rs/gfx-rs/teams","hooks_url":"https://api.github.com/repos/gfx-rs/gfx-rs/hooks","issue_events_url":"https://api.github.com/repos/gfx-rs/gfx-rs/issues/events{/number}","events_url":"https://api.github.com/repos/gfx-rs/gfx-rs/events","assignees_url":"https://api.github.com/repos/gfx-rs/gfx-rs/assignees{/user}","branches_url":"https://api.github.com/repos/gfx-rs/gfx-rs/branches{/branch}","tags_url":"https://api.github.com/repos/gfx-rs/gfx-rs/tags","blobs_url":"https://api.github.com/repos/gfx-rs/gfx-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gfx-rs/gfx-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gfx-rs/gfx-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/gfx-rs/gfx-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gfx-rs/gfx-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/gfx-rs/gfx-rs/languages","stargazers_url":"https://api.github.com/repos/gfx-rs/gfx-rs/stargazers","contributors_url":"https://api.github.com/repos/gfx-rs/gfx-rs/contributors","subscribers_url":"https://api.github.com/repos/gfx-rs/gfx-rs/subscribers","subscription_url":"https://api.github.com/repos/gfx-rs/gfx-rs/subscription","commits_url":"https://api.github.com/repos/gfx-rs/gfx-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/gfx-rs/gfx-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/gfx-rs/gfx-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/gfx-rs/gfx-rs/issues/comments/{number}","contents_url":"https://api.github.com/repos/gfx-rs/gfx-rs/contents/{+path}","compare_url":"https://api.github.com/repos/gfx-rs/gfx-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gfx-rs/gfx-rs/merges","archive_url":"https://api.github.com/repos/gfx-rs/gfx-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gfx-rs/gfx-rs/downloads","issues_url":"https://api.github.com/repos/gfx-rs/gfx-rs/issues{/number}","pulls_url":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/gfx-rs/gfx-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/gfx-rs/gfx-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gfx-rs/gfx-rs/labels{/name}","releases_url":"https://api.github.com/repos/gfx-rs/gfx-rs/releases{/id}","created_at":"2013-10-25T00:35:35Z","updated_at":"2014-08-25T18:35:35Z","pushed_at":"2014-08-25T14:30:59Z","git_url":"git://github.com/gfx-rs/gfx-rs.git","ssh_url":"git@github.com:gfx-rs/gfx-rs.git","clone_url":"https://github.com/gfx-rs/gfx-rs.git","svn_url":"https://github.com/gfx-rs/gfx-rs","homepage":"http://gfx-rs.github.io/","size":4811,"stargazers_count":49,"watchers_count":49,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":22,"mirror_url":null,"open_issues_count":37,"forks":22,"open_issues":37,"watchers":49,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/285"},"html":{"href":"https://github.com/gfx-rs/gfx-rs/pull/285"},"issue":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/issues/285"},"comments":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/issues/285/comments"},"review_comments":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/285/comments"},"review_comment":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/pulls/285/commits"},"statuses":{"href":"https://api.github.com/repos/gfx-rs/gfx-rs/statuses/3b28cb52b6e2f4105cb4b02719311f554e6c544f"}}}}