{"action":"created","comment":{"url":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/40032493","id":40032493,"diff_hunk":"@@ -206,39 +199,89 @@ uint32_t toCompactColor(const glm::vec4& color) {\n     return compactColor;\r\n }\r\n \r\n-void DeferredLightingEffect::renderSolidCubeInstance(gpu::Batch& batch, const Transform& xfm, const glm::vec4& color) {\r\n-    static const std::string INSTANCE_NAME = __FUNCTION__;\r\n-    static const size_t TRANSFORM_BUFFER = 0;\r\n-    static const size_t COLOR_BUFFER = 1;\r\n+static const size_t INSTANCE_TRANSFORM_BUFFER = 0;\r\n+static const size_t INSTANCE_COLOR_BUFFER = 1;\r\n+\r\n+template <typename F>\r\n+void renderInstances(const std::string& name, gpu::Batch& batch, const Transform& xfm, const glm::vec4& color, F f) {\r\n     {\r\n-        gpu::BufferPointer instanceTransformBuffer = batch.getNamedBuffer(INSTANCE_NAME, TRANSFORM_BUFFER);\r\n+        gpu::BufferPointer instanceTransformBuffer = batch.getNamedBuffer(name, INSTANCE_TRANSFORM_BUFFER);\r\n         glm::mat4 xfmMat4;\r\n         instanceTransformBuffer->append(xfm.getMatrix(xfmMat4));\r\n \r\n-        gpu::BufferPointer instanceColorBuffer = batch.getNamedBuffer(INSTANCE_NAME, COLOR_BUFFER);\r\n+        gpu::BufferPointer instanceColorBuffer = batch.getNamedBuffer(name, INSTANCE_COLOR_BUFFER);\r\n         auto compactColor = toCompactColor(color);\r\n         instanceColorBuffer->append(compactColor);\r\n     }\r\n \r\n-    batch.setupNamedCalls(INSTANCE_NAME, [=](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {\r\n-        auto pipeline = bindSimpleProgram(batch);\r\n+    auto that = DependencyManager::get<DeferredLightingEffect>();\r\n+    batch.setupNamedCalls(name, [=](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {\r\n+        auto pipeline = that->bindSimpleProgram(batch);\r\n         auto location = pipeline->getProgram()->getUniforms().findLocation(\"Instanced\");\r\n \r\n         batch._glUniform1i(location, 1);\r\n-        DependencyManager::get<GeometryCache>()->renderSolidCubeInstances(batch, data._count,\r\n-            data._buffers[TRANSFORM_BUFFER], data._buffers[COLOR_BUFFER]);\r\n+        f(batch, data);\r\n         batch._glUniform1i(location, 0);\r\n     });\r\n }\r\n \r\n-void DeferredLightingEffect::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) {\r\n-    bindSimpleProgram(batch);\r\n-    DependencyManager::get<GeometryCache>()->renderSolidCube(batch, size, color);\r\n+void DeferredLightingEffect::renderSolidSphereInstance(gpu::Batch& batch, const Transform& xfm, const glm::vec4& color) {\r\n+    static const std::string INSTANCE_NAME = __FUNCTION__;\r\n+    renderInstances(INSTANCE_NAME, batch, xfm, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {\r\n+        DependencyManager::get<GeometryCache>()->renderSphereInstances(batch, data._count,\r\n+            data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]);\r\n+    });\r\n }\r\n \r\n-void DeferredLightingEffect::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) {\r\n-    bindSimpleProgram(batch);\r\n-    DependencyManager::get<GeometryCache>()->renderWireCube(batch, size, color);\r\n+static auto startTime = usecTimestampNow();\r\n+\r\n+void DeferredLightingEffect::renderSolidCubeInstance(gpu::Batch& batch, const Transform& xfm, const glm::vec4& color) {\r\n+    static const std::string INSTANCE_NAME = __FUNCTION__;\r\n+\r\n+#ifdef DEBUG_SHAPES\r\n+    renderInstances(INSTANCE_NAME, batch, xfm, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {\r\n+\r\n+        auto usecs = usecTimestampNow();\r\n+        usecs -= startTime;\r\n+        auto msecs = usecs / USECS_PER_MSEC;\r\n+        float seconds = msecs;\r\n+        seconds /= MSECS_PER_SECOND;\r\n+        float fractionalSeconds = seconds - floor(seconds);\r\n+        int shapeIndex = (int)seconds;\r\n+\r\n+        GeometryCache::Shape shapes[] = {\r\n+            GeometryCache::Cube,\r\n+            GeometryCache::Tetrahedron,\r\n+            GeometryCache::Sphere,\r\n+            GeometryCache::Icosahedron,\r\n+            GeometryCache::Line,\r\n+        };\r\n+\r\n+        shapeIndex %= 5;\r","path":"libraries/render-utils/src/DeferredLightingEffect.cpp","position":95,"original_position":95,"commit_id":"84cea1ffd4ae13cd03c8c29db3721495d39f5063","original_commit_id":"0c0af812c27f1a6ce36599a37a74f6ef3a8e23ff","user":{"login":"jherico","id":1533642,"avatar_url":"https://avatars.githubusercontent.com/u/1533642?v=3","gravatar_id":"","url":"https://api.github.com/users/jherico","html_url":"https://github.com/jherico","followers_url":"https://api.github.com/users/jherico/followers","following_url":"https://api.github.com/users/jherico/following{/other_user}","gists_url":"https://api.github.com/users/jherico/gists{/gist_id}","starred_url":"https://api.github.com/users/jherico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jherico/subscriptions","organizations_url":"https://api.github.com/users/jherico/orgs","repos_url":"https://api.github.com/users/jherico/repos","events_url":"https://api.github.com/users/jherico/events{/privacy}","received_events_url":"https://api.github.com/users/jherico/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2015-09-21T22:04:07Z","updated_at":"2015-09-21T22:04:07Z","html_url":"https://github.com/highfidelity/hifi/pull/5865#discussion_r40032493","pull_request_url":"https://api.github.com/repos/highfidelity/hifi/pulls/5865","_links":{"self":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/40032493"},"html":{"href":"https://github.com/highfidelity/hifi/pull/5865#discussion_r40032493"},"pull_request":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/5865"}}},"pull_request":{"url":"https://api.github.com/repos/highfidelity/hifi/pulls/5865","id":45586918,"html_url":"https://github.com/highfidelity/hifi/pull/5865","diff_url":"https://github.com/highfidelity/hifi/pull/5865.diff","patch_url":"https://github.com/highfidelity/hifi/pull/5865.patch","issue_url":"https://api.github.com/repos/highfidelity/hifi/issues/5865","number":5865,"state":"open","locked":false,"title":"Instancing work, second pass","user":{"login":"jherico","id":1533642,"avatar_url":"https://avatars.githubusercontent.com/u/1533642?v=3","gravatar_id":"","url":"https://api.github.com/users/jherico","html_url":"https://github.com/jherico","followers_url":"https://api.github.com/users/jherico/followers","following_url":"https://api.github.com/users/jherico/following{/other_user}","gists_url":"https://api.github.com/users/jherico/gists{/gist_id}","starred_url":"https://api.github.com/users/jherico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jherico/subscriptions","organizations_url":"https://api.github.com/users/jherico/orgs","repos_url":"https://api.github.com/users/jherico/repos","events_url":"https://api.github.com/users/jherico/events{/privacy}","received_events_url":"https://api.github.com/users/jherico/received_events","type":"User","site_admin":false},"body":"* Fixes some of the overlay color issues by using the deferred lighting class to render overlay boxes and spheres (previously they just used geometry cache without first setting a pipeline, hence the rendering bugs)\r\n* Creates a new mechanism in geometry cache for rendering primitive shapes.  All supported primitives are now stored in a single vertex buffer, with a single index buffer for all wire and solid indices.  This should result in fewer vertex buffer changes over time.\r\n* Removes the concept of NFLOAT and NHALF.  Only fixed point types can be normalized.\r\n* Allows clients to generate more than one instance at a time without having to make multiple calls to `setupNamedDrawCalls`.  \r\n","created_at":"2015-09-21T19:08:08Z","updated_at":"2015-09-21T22:04:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ec9d9801f98d428060a6f5c7318c06b4fd14207b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/highfidelity/hifi/pulls/5865/commits","review_comments_url":"https://api.github.com/repos/highfidelity/hifi/pulls/5865/comments","review_comment_url":"https://api.github.com/repos/highfidelity/hifi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/highfidelity/hifi/issues/5865/comments","statuses_url":"https://api.github.com/repos/highfidelity/hifi/statuses/84cea1ffd4ae13cd03c8c29db3721495d39f5063","head":{"label":"jherico:bart","ref":"bart","sha":"84cea1ffd4ae13cd03c8c29db3721495d39f5063","user":{"login":"jherico","id":1533642,"avatar_url":"https://avatars.githubusercontent.com/u/1533642?v=3","gravatar_id":"","url":"https://api.github.com/users/jherico","html_url":"https://github.com/jherico","followers_url":"https://api.github.com/users/jherico/followers","following_url":"https://api.github.com/users/jherico/following{/other_user}","gists_url":"https://api.github.com/users/jherico/gists{/gist_id}","starred_url":"https://api.github.com/users/jherico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jherico/subscriptions","organizations_url":"https://api.github.com/users/jherico/orgs","repos_url":"https://api.github.com/users/jherico/repos","events_url":"https://api.github.com/users/jherico/events{/privacy}","received_events_url":"https://api.github.com/users/jherico/received_events","type":"User","site_admin":false},"repo":{"id":29566286,"name":"hifi","full_name":"jherico/hifi","owner":{"login":"jherico","id":1533642,"avatar_url":"https://avatars.githubusercontent.com/u/1533642?v=3","gravatar_id":"","url":"https://api.github.com/users/jherico","html_url":"https://github.com/jherico","followers_url":"https://api.github.com/users/jherico/followers","following_url":"https://api.github.com/users/jherico/following{/other_user}","gists_url":"https://api.github.com/users/jherico/gists{/gist_id}","starred_url":"https://api.github.com/users/jherico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jherico/subscriptions","organizations_url":"https://api.github.com/users/jherico/orgs","repos_url":"https://api.github.com/users/jherico/repos","events_url":"https://api.github.com/users/jherico/events{/privacy}","received_events_url":"https://api.github.com/users/jherico/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jherico/hifi","description":"Open, decentralized virtual worlds using sensors to control avatars and dynamically assigned devices as servers.  San Francisco based startup, we are hiring: http://highfidelity.io/jobs  Documentation at http://docs.highfidelity.io  Contribute by reporting bugs & doing jobs on http://worklist.net","fork":true,"url":"https://api.github.com/repos/jherico/hifi","forks_url":"https://api.github.com/repos/jherico/hifi/forks","keys_url":"https://api.github.com/repos/jherico/hifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jherico/hifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jherico/hifi/teams","hooks_url":"https://api.github.com/repos/jherico/hifi/hooks","issue_events_url":"https://api.github.com/repos/jherico/hifi/issues/events{/number}","events_url":"https://api.github.com/repos/jherico/hifi/events","assignees_url":"https://api.github.com/repos/jherico/hifi/assignees{/user}","branches_url":"https://api.github.com/repos/jherico/hifi/branches{/branch}","tags_url":"https://api.github.com/repos/jherico/hifi/tags","blobs_url":"https://api.github.com/repos/jherico/hifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jherico/hifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jherico/hifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/jherico/hifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jherico/hifi/statuses/{sha}","languages_url":"https://api.github.com/repos/jherico/hifi/languages","stargazers_url":"https://api.github.com/repos/jherico/hifi/stargazers","contributors_url":"https://api.github.com/repos/jherico/hifi/contributors","subscribers_url":"https://api.github.com/repos/jherico/hifi/subscribers","subscription_url":"https://api.github.com/repos/jherico/hifi/subscription","commits_url":"https://api.github.com/repos/jherico/hifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/jherico/hifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/jherico/hifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/jherico/hifi/issues/comments{/number}","contents_url":"https://api.github.com/repos/jherico/hifi/contents/{+path}","compare_url":"https://api.github.com/repos/jherico/hifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jherico/hifi/merges","archive_url":"https://api.github.com/repos/jherico/hifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jherico/hifi/downloads","issues_url":"https://api.github.com/repos/jherico/hifi/issues{/number}","pulls_url":"https://api.github.com/repos/jherico/hifi/pulls{/number}","milestones_url":"https://api.github.com/repos/jherico/hifi/milestones{/number}","notifications_url":"https://api.github.com/repos/jherico/hifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jherico/hifi/labels{/name}","releases_url":"https://api.github.com/repos/jherico/hifi/releases{/id}","created_at":"2015-01-21T02:11:03Z","updated_at":"2015-05-08T17:48:46Z","pushed_at":"2015-09-21T21:33:39Z","git_url":"git://github.com/jherico/hifi.git","ssh_url":"git@github.com:jherico/hifi.git","clone_url":"https://github.com/jherico/hifi.git","svn_url":"https://github.com/jherico/hifi","homepage":"","size":178194,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"highfidelity:master","ref":"master","sha":"25f506f3dce43af528024ccba119942318a67f6b","user":{"login":"highfidelity","id":1565370,"avatar_url":"https://avatars.githubusercontent.com/u/1565370?v=3","gravatar_id":"","url":"https://api.github.com/users/highfidelity","html_url":"https://github.com/highfidelity","followers_url":"https://api.github.com/users/highfidelity/followers","following_url":"https://api.github.com/users/highfidelity/following{/other_user}","gists_url":"https://api.github.com/users/highfidelity/gists{/gist_id}","starred_url":"https://api.github.com/users/highfidelity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/highfidelity/subscriptions","organizations_url":"https://api.github.com/users/highfidelity/orgs","repos_url":"https://api.github.com/users/highfidelity/repos","events_url":"https://api.github.com/users/highfidelity/events{/privacy}","received_events_url":"https://api.github.com/users/highfidelity/received_events","type":"Organization","site_admin":false},"repo":{"id":5372872,"name":"hifi","full_name":"highfidelity/hifi","owner":{"login":"highfidelity","id":1565370,"avatar_url":"https://avatars.githubusercontent.com/u/1565370?v=3","gravatar_id":"","url":"https://api.github.com/users/highfidelity","html_url":"https://github.com/highfidelity","followers_url":"https://api.github.com/users/highfidelity/followers","following_url":"https://api.github.com/users/highfidelity/following{/other_user}","gists_url":"https://api.github.com/users/highfidelity/gists{/gist_id}","starred_url":"https://api.github.com/users/highfidelity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/highfidelity/subscriptions","organizations_url":"https://api.github.com/users/highfidelity/orgs","repos_url":"https://api.github.com/users/highfidelity/repos","events_url":"https://api.github.com/users/highfidelity/events{/privacy}","received_events_url":"https://api.github.com/users/highfidelity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/highfidelity/hifi","description":"Open source software for shared virtual worlds using HMDs and dynamically assigned devices as servers.  San Francisco based startup, we are hiring: http://highfidelity.com/jobs  Documentation at http://docs.highfidelity.com  Contribute by reporting bugs & doing jobs on http://worklist.net","fork":false,"url":"https://api.github.com/repos/highfidelity/hifi","forks_url":"https://api.github.com/repos/highfidelity/hifi/forks","keys_url":"https://api.github.com/repos/highfidelity/hifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/highfidelity/hifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/highfidelity/hifi/teams","hooks_url":"https://api.github.com/repos/highfidelity/hifi/hooks","issue_events_url":"https://api.github.com/repos/highfidelity/hifi/issues/events{/number}","events_url":"https://api.github.com/repos/highfidelity/hifi/events","assignees_url":"https://api.github.com/repos/highfidelity/hifi/assignees{/user}","branches_url":"https://api.github.com/repos/highfidelity/hifi/branches{/branch}","tags_url":"https://api.github.com/repos/highfidelity/hifi/tags","blobs_url":"https://api.github.com/repos/highfidelity/hifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/highfidelity/hifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/highfidelity/hifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/highfidelity/hifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/highfidelity/hifi/statuses/{sha}","languages_url":"https://api.github.com/repos/highfidelity/hifi/languages","stargazers_url":"https://api.github.com/repos/highfidelity/hifi/stargazers","contributors_url":"https://api.github.com/repos/highfidelity/hifi/contributors","subscribers_url":"https://api.github.com/repos/highfidelity/hifi/subscribers","subscription_url":"https://api.github.com/repos/highfidelity/hifi/subscription","commits_url":"https://api.github.com/repos/highfidelity/hifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/highfidelity/hifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/highfidelity/hifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/highfidelity/hifi/issues/comments{/number}","contents_url":"https://api.github.com/repos/highfidelity/hifi/contents/{+path}","compare_url":"https://api.github.com/repos/highfidelity/hifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/highfidelity/hifi/merges","archive_url":"https://api.github.com/repos/highfidelity/hifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/highfidelity/hifi/downloads","issues_url":"https://api.github.com/repos/highfidelity/hifi/issues{/number}","pulls_url":"https://api.github.com/repos/highfidelity/hifi/pulls{/number}","milestones_url":"https://api.github.com/repos/highfidelity/hifi/milestones{/number}","notifications_url":"https://api.github.com/repos/highfidelity/hifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/highfidelity/hifi/labels{/name}","releases_url":"https://api.github.com/repos/highfidelity/hifi/releases{/id}","created_at":"2012-08-10T18:26:22Z","updated_at":"2015-09-21T20:31:57Z","pushed_at":"2015-09-21T21:44:02Z","git_url":"git://github.com/highfidelity/hifi.git","ssh_url":"git@github.com:highfidelity/hifi.git","clone_url":"https://github.com/highfidelity/hifi.git","svn_url":"https://github.com/highfidelity/hifi","homepage":"","size":237404,"stargazers_count":306,"watchers_count":306,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":178,"mirror_url":null,"open_issues_count":65,"forks":178,"open_issues":65,"watchers":306,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/5865"},"html":{"href":"https://github.com/highfidelity/hifi/pull/5865"},"issue":{"href":"https://api.github.com/repos/highfidelity/hifi/issues/5865"},"comments":{"href":"https://api.github.com/repos/highfidelity/hifi/issues/5865/comments"},"review_comments":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/5865/comments"},"review_comment":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/5865/commits"},"statuses":{"href":"https://api.github.com/repos/highfidelity/hifi/statuses/84cea1ffd4ae13cd03c8c29db3721495d39f5063"}}}}