{"action":"created","comment":{"url":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/58419455","id":58419455,"diff_hunk":"@@ -0,0 +1,109 @@\n+//\n+//  Created by Bradley Austin Davis on 2016/04/03\n+//  Copyright 2013-2016 High Fidelity, Inc.\n+//\n+//  Distributed under the Apache License, Version 2.0.\n+//  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html\n+//\n+\n+#include \"GLBackendTextureTransfer.h\"\n+\n+#include \"GLBackendShared.h\"\n+#include \"GLTexelFormat.h\"\n+\n+#ifdef THREADED_TEXTURE_TRANSFER\n+#include <gl/OffscreenGLCanvas.h>\n+#include <gl/OglplusHelpers.h>\n+#include <gl/QOpenGLContextWrapper.h>\n+#endif\n+\n+using namespace gpu;\n+\n+static ProgramPtr _program;\n+static ProgramPtr _cubeProgram;\n+static ShapeWrapperPtr _plane;\n+static ShapeWrapperPtr _skybox;\n+static BasicFramebufferWrapperPtr _framebuffer;\n+\n+GLTextureTransferHelper::GLTextureTransferHelper() {\n+#ifdef THREADED_TEXTURE_TRANSFER\n+    _canvas = std::make_shared<OffscreenGLCanvas>();\n+    _canvas->create(QOpenGLContextWrapper::currentContext());\n+    if (!_canvas->makeCurrent()) {\n+        qFatal(\"Unable to create texture transfer context\");\n+    }\n+    _canvas->doneCurrent();\n+    initialize(true, QThread::LowPriority);\n+    _canvas->moveToThreadWithContext(_thread);\n+#endif\n+}\n+\n+void GLTextureTransferHelper::transferTexture(const gpu::TexturePointer& texturePointer) {\n+    GLBackend::GLTexture* object = Backend::getGPUObject<GLBackend::GLTexture>(*texturePointer);\n+#ifdef THREADED_TEXTURE_TRANSFER\n+    TextureTransferPackage package { texturePointer, glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0) };","path":"libraries/gpu/src/gpu/GLBackendTextureTransfer.cpp","position":44,"original_position":44,"commit_id":"d98abbc7df5d05b72a29a5015c81445df4f89499","original_commit_id":"d98abbc7df5d05b72a29a5015c81445df4f89499","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":"we've issued a `glTexStorage` (or `glTexImage` if storage isn't available) on the main context, but because we do the `glTexSubImage` to transfer the mip data on another context, we need to know that the storage / image command has actually executed.  The flush is required to ensure the `glFenceSync` command has been pushed to the driver before we try to start using it in another tread. ","created_at":"2016-04-04T18:04:07Z","updated_at":"2016-04-04T18:04:07Z","html_url":"https://github.com/highfidelity/hifi/pull/7554#discussion_r58419455","pull_request_url":"https://api.github.com/repos/highfidelity/hifi/pulls/7554","_links":{"self":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/58419455"},"html":{"href":"https://github.com/highfidelity/hifi/pull/7554#discussion_r58419455"},"pull_request":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/7554"}}},"pull_request":{"url":"https://api.github.com/repos/highfidelity/hifi/pulls/7554","id":65098564,"html_url":"https://github.com/highfidelity/hifi/pull/7554","diff_url":"https://github.com/highfidelity/hifi/pull/7554.diff","patch_url":"https://github.com/highfidelity/hifi/pull/7554.patch","issue_url":"https://api.github.com/repos/highfidelity/hifi/issues/7554","number":7554,"state":"open","locked":false,"title":"Working on addressing stuttering in the frame while loading content - Part 2","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":"This moves the job of transferring of image data across the CPU/GPU boundary to a background thread / rendering context.\r\n\r\n","created_at":"2016-04-04T05:48:58Z","updated_at":"2016-04-04T18:04:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0034b3ee13fa76f96e36fb7b04748e36c9a07a22","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/highfidelity/hifi/pulls/7554/commits","review_comments_url":"https://api.github.com/repos/highfidelity/hifi/pulls/7554/comments","review_comment_url":"https://api.github.com/repos/highfidelity/hifi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/highfidelity/hifi/issues/7554/comments","statuses_url":"https://api.github.com/repos/highfidelity/hifi/statuses/d98abbc7df5d05b72a29a5015c81445df4f89499","head":{"label":"jherico:load_stutter2","ref":"load_stutter2","sha":"d98abbc7df5d05b72a29a5015c81445df4f89499","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}","deployments_url":"https://api.github.com/repos/jherico/hifi/deployments","created_at":"2015-01-21T02:11:03Z","updated_at":"2016-01-11T07:24:31Z","pushed_at":"2016-04-04T17:23:07Z","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":194360,"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":"2dd1b14b323dc15a6d956f494fa5b3207d359e71","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}","deployments_url":"https://api.github.com/repos/highfidelity/hifi/deployments","created_at":"2012-08-10T18:26:22Z","updated_at":"2016-04-02T09:36:07Z","pushed_at":"2016-04-04T18:00:51Z","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":238508,"stargazers_count":363,"watchers_count":363,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":216,"mirror_url":null,"open_issues_count":59,"forks":216,"open_issues":59,"watchers":363,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/7554"},"html":{"href":"https://github.com/highfidelity/hifi/pull/7554"},"issue":{"href":"https://api.github.com/repos/highfidelity/hifi/issues/7554"},"comments":{"href":"https://api.github.com/repos/highfidelity/hifi/issues/7554/comments"},"review_comments":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/7554/comments"},"review_comment":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/7554/commits"},"statuses":{"href":"https://api.github.com/repos/highfidelity/hifi/statuses/d98abbc7df5d05b72a29a5015c81445df4f89499"}}}}