{"action":"created","comment":{"url":"https://api.github.com/repos/xbmc/xbmc/pulls/comments/35682894","id":35682894,"diff_hunk":"@@ -0,0 +1,128 @@\n+/*\n+ *      Copyright (C) 2011-2015 Hendrik Leppkes\n+ *      http://www.1f0.de\n+ *\n+ *  This program is free software; you can redistribute it and/or modify\n+ *  it under the terms of the GNU General Public License as published by\n+ *  the Free Software Foundation; either version 2 of the License, or\n+ *  (at your option) any later version.\n+ *\n+ *  This program is distributed in the hope that it will be useful,\n+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ *  GNU General Public License for more details.\n+ *\n+ *  You should have received a copy of the GNU General Public License along\n+ *  with this program; if not, write to the Free Software Foundation, Inc.,\n+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n+ *\n+ *  Taken from the QuickSync decoder by Eric Gur\n+ */\n+\n+#include <emmintrin.h>\n+\n+// gpu_memcpy is a memcpy style function that copied data very fast from a\n+// GPU tiled memory (write back)\n+// Performance tip: page offset (12 lsb) of both addresses should be different\n+//  optimally use a 2K offset between them.\n+inline void* gpu_memcpy(void* d, const void* s, size_t size)\n+{\n+    static const size_t regsInLoop = sizeof(size_t) * 2; // 8 or 16\n+\n+    if (d == nullptr || s == nullptr) return nullptr;\n+\n+    // If memory is not aligned, use memcpy\n+    bool isAligned = (((size_t)(s) | (size_t)(d)) & 0xF) == 0;\n+    if (!isAligned)\n+    {\n+        return memcpy(d, s, size);\n+    }\n+\n+    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n+#ifdef _M_X64\n+    __m128i xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15;\n+#endif\n+\n+    size_t reminder = size & (regsInLoop * sizeof(xmm0) - 1); // Copy 128 or 256 bytes every loop\n+    size_t end = 0;\n+\n+    __m128i* pTrg = (__m128i*)d;\n+    __m128i* pTrgEnd = pTrg + ((size - reminder) >> 4);\n+    __m128i* pSrc = (__m128i*)s;\n+    \n+    // Make sure source is synced - doesn't hurt if not needed.\n+    _mm_sfence();\n+\n+    while (pTrg < pTrgEnd)\n+    {\n+        // _mm_stream_load_si128 emits the Streaming SIMD Extensions 4 (SSE4.1) instruction MOVNTDQA\n+        // Fastest method for copying GPU RAM. Available since Penryn (45nm Core 2 Duo/Quad)\n+        xmm0  = _mm_stream_load_si128(pSrc);\n+        xmm1  = _mm_stream_load_si128(pSrc + 1);\n+        xmm2  = _mm_stream_load_si128(pSrc + 2);\n+        xmm3  = _mm_stream_load_si128(pSrc + 3);\n+        xmm4  = _mm_stream_load_si128(pSrc + 4);\n+        xmm5  = _mm_stream_load_si128(pSrc + 5);\n+        xmm6  = _mm_stream_load_si128(pSrc + 6);\n+        xmm7  = _mm_stream_load_si128(pSrc + 7);\n+#ifdef _M_X64 // Use all 16 xmm registers\n+        xmm8  = _mm_stream_load_si128(pSrc + 8);\n+        xmm9  = _mm_stream_load_si128(pSrc + 9);\n+        xmm10 = _mm_stream_load_si128(pSrc + 10);\n+        xmm11 = _mm_stream_load_si128(pSrc + 11);\n+        xmm12 = _mm_stream_load_si128(pSrc + 12);\n+        xmm13 = _mm_stream_load_si128(pSrc + 13);\n+        xmm14 = _mm_stream_load_si128(pSrc + 14);\n+        xmm15 = _mm_stream_load_si128(pSrc + 15);\n+#endif","path":"xbmc/utils/win32/gpu_memcpy_sse4.h","position":77,"original_position":77,"commit_id":"e5b3e9d2393f830ab8fd05e604637c9606ab8d3c","original_commit_id":"e5b3e9d2393f830ab8fd05e604637c9606ab8d3c","user":{"login":"afedchin","id":2063885,"avatar_url":"https://avatars.githubusercontent.com/u/2063885?v=3","gravatar_id":"","url":"https://api.github.com/users/afedchin","html_url":"https://github.com/afedchin","followers_url":"https://api.github.com/users/afedchin/followers","following_url":"https://api.github.com/users/afedchin/following{/other_user}","gists_url":"https://api.github.com/users/afedchin/gists{/gist_id}","starred_url":"https://api.github.com/users/afedchin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afedchin/subscriptions","organizations_url":"https://api.github.com/users/afedchin/orgs","repos_url":"https://api.github.com/users/afedchin/repos","events_url":"https://api.github.com/users/afedchin/events{/privacy}","received_events_url":"https://api.github.com/users/afedchin/received_events","type":"User","site_admin":false},"body":"thanks for detailed explanation.","created_at":"2015-07-28T18:32:19Z","updated_at":"2015-07-28T18:32:19Z","html_url":"https://github.com/xbmc/xbmc/pull/7637#discussion_r35682894","pull_request_url":"https://api.github.com/repos/xbmc/xbmc/pulls/7637","_links":{"self":{"href":"https://api.github.com/repos/xbmc/xbmc/pulls/comments/35682894"},"html":{"href":"https://github.com/xbmc/xbmc/pull/7637#discussion_r35682894"},"pull_request":{"href":"https://api.github.com/repos/xbmc/xbmc/pulls/7637"}}},"pull_request":{"url":"https://api.github.com/repos/xbmc/xbmc/pulls/7637","id":40910828,"html_url":"https://github.com/xbmc/xbmc/pull/7637","diff_url":"https://github.com/xbmc/xbmc/pull/7637.diff","patch_url":"https://github.com/xbmc/xbmc/pull/7637.patch","issue_url":"https://api.github.com/repos/xbmc/xbmc/issues/7637","number":7637,"state":"open","locked":false,"title":"[RFC] DX11 several optimizations of copying frames to/from gpu.","user":{"login":"afedchin","id":2063885,"avatar_url":"https://avatars.githubusercontent.com/u/2063885?v=3","gravatar_id":"","url":"https://api.github.com/users/afedchin","html_url":"https://github.com/afedchin","followers_url":"https://api.github.com/users/afedchin/followers","following_url":"https://api.github.com/users/afedchin/following{/other_user}","gists_url":"https://api.github.com/users/afedchin/gists{/gist_id}","starred_url":"https://api.github.com/users/afedchin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afedchin/subscriptions","organizations_url":"https://api.github.com/users/afedchin/orgs","repos_url":"https://api.github.com/users/afedchin/repos","events_url":"https://api.github.com/users/afedchin/events{/privacy}","received_events_url":"https://api.github.com/users/afedchin/received_events","type":"User","site_admin":false},"body":"Set of improvements. For more info please see commit messages.\r\n\r\n1. CopyDXVA2Picture - here is a comparsion between different methods of copying dxva FHD frame into sysmem.\r\n![gpucopy](https://cloud.githubusercontent.com/assets/2063885/8908853/0bfaf4bc-3487-11e5-8023-97995d6a5a6f.jpg)\r\n\r\n2. CProcessorHD::Convert  - here is a comparsion between old memcpy and new sse2 method (used FHD frame).\r\n![dxvacopy](https://cloud.githubusercontent.com/assets/2063885/8908884/28334af8-3487-11e5-8601-2d9ad16873e1.jpg)\r\n\r\n@fritsch @FernetMenta please take a look.","created_at":"2015-07-27T14:46:20Z","updated_at":"2015-07-28T18:32:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc14c4e9d3b19e15a31523a564541f0d740f02f6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/xbmc/xbmc/pulls/7637/commits","review_comments_url":"https://api.github.com/repos/xbmc/xbmc/pulls/7637/comments","review_comment_url":"https://api.github.com/repos/xbmc/xbmc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xbmc/xbmc/issues/7637/comments","statuses_url":"https://api.github.com/repos/xbmc/xbmc/statuses/e5b3e9d2393f830ab8fd05e604637c9606ab8d3c","head":{"label":"afedchin:dx11_optimize3","ref":"dx11_optimize3","sha":"e5b3e9d2393f830ab8fd05e604637c9606ab8d3c","user":{"login":"afedchin","id":2063885,"avatar_url":"https://avatars.githubusercontent.com/u/2063885?v=3","gravatar_id":"","url":"https://api.github.com/users/afedchin","html_url":"https://github.com/afedchin","followers_url":"https://api.github.com/users/afedchin/followers","following_url":"https://api.github.com/users/afedchin/following{/other_user}","gists_url":"https://api.github.com/users/afedchin/gists{/gist_id}","starred_url":"https://api.github.com/users/afedchin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afedchin/subscriptions","organizations_url":"https://api.github.com/users/afedchin/orgs","repos_url":"https://api.github.com/users/afedchin/repos","events_url":"https://api.github.com/users/afedchin/events{/privacy}","received_events_url":"https://api.github.com/users/afedchin/received_events","type":"User","site_admin":false},"repo":{"id":8306898,"name":"xbmc","full_name":"afedchin/xbmc","owner":{"login":"afedchin","id":2063885,"avatar_url":"https://avatars.githubusercontent.com/u/2063885?v=3","gravatar_id":"","url":"https://api.github.com/users/afedchin","html_url":"https://github.com/afedchin","followers_url":"https://api.github.com/users/afedchin/followers","following_url":"https://api.github.com/users/afedchin/following{/other_user}","gists_url":"https://api.github.com/users/afedchin/gists{/gist_id}","starred_url":"https://api.github.com/users/afedchin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afedchin/subscriptions","organizations_url":"https://api.github.com/users/afedchin/orgs","repos_url":"https://api.github.com/users/afedchin/repos","events_url":"https://api.github.com/users/afedchin/events{/privacy}","received_events_url":"https://api.github.com/users/afedchin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/afedchin/xbmc","description":"XBMC Main Repository","fork":true,"url":"https://api.github.com/repos/afedchin/xbmc","forks_url":"https://api.github.com/repos/afedchin/xbmc/forks","keys_url":"https://api.github.com/repos/afedchin/xbmc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/afedchin/xbmc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/afedchin/xbmc/teams","hooks_url":"https://api.github.com/repos/afedchin/xbmc/hooks","issue_events_url":"https://api.github.com/repos/afedchin/xbmc/issues/events{/number}","events_url":"https://api.github.com/repos/afedchin/xbmc/events","assignees_url":"https://api.github.com/repos/afedchin/xbmc/assignees{/user}","branches_url":"https://api.github.com/repos/afedchin/xbmc/branches{/branch}","tags_url":"https://api.github.com/repos/afedchin/xbmc/tags","blobs_url":"https://api.github.com/repos/afedchin/xbmc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/afedchin/xbmc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/afedchin/xbmc/git/refs{/sha}","trees_url":"https://api.github.com/repos/afedchin/xbmc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/afedchin/xbmc/statuses/{sha}","languages_url":"https://api.github.com/repos/afedchin/xbmc/languages","stargazers_url":"https://api.github.com/repos/afedchin/xbmc/stargazers","contributors_url":"https://api.github.com/repos/afedchin/xbmc/contributors","subscribers_url":"https://api.github.com/repos/afedchin/xbmc/subscribers","subscription_url":"https://api.github.com/repos/afedchin/xbmc/subscription","commits_url":"https://api.github.com/repos/afedchin/xbmc/commits{/sha}","git_commits_url":"https://api.github.com/repos/afedchin/xbmc/git/commits{/sha}","comments_url":"https://api.github.com/repos/afedchin/xbmc/comments{/number}","issue_comment_url":"https://api.github.com/repos/afedchin/xbmc/issues/comments{/number}","contents_url":"https://api.github.com/repos/afedchin/xbmc/contents/{+path}","compare_url":"https://api.github.com/repos/afedchin/xbmc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/afedchin/xbmc/merges","archive_url":"https://api.github.com/repos/afedchin/xbmc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/afedchin/xbmc/downloads","issues_url":"https://api.github.com/repos/afedchin/xbmc/issues{/number}","pulls_url":"https://api.github.com/repos/afedchin/xbmc/pulls{/number}","milestones_url":"https://api.github.com/repos/afedchin/xbmc/milestones{/number}","notifications_url":"https://api.github.com/repos/afedchin/xbmc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/afedchin/xbmc/labels{/name}","releases_url":"https://api.github.com/repos/afedchin/xbmc/releases{/id}","created_at":"2013-02-20T05:37:45Z","updated_at":"2015-06-20T14:40:05Z","pushed_at":"2015-07-28T15:13:11Z","git_url":"git://github.com/afedchin/xbmc.git","ssh_url":"git@github.com:afedchin/xbmc.git","clone_url":"https://github.com/afedchin/xbmc.git","svn_url":"https://github.com/afedchin/xbmc","homepage":"http://xbmc.org","size":520435,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"xbmc:master","ref":"master","sha":"60bfc58e17e037d1eac28ce057fd0943973932c9","user":{"login":"xbmc","id":199122,"avatar_url":"https://avatars.githubusercontent.com/u/199122?v=3","gravatar_id":"","url":"https://api.github.com/users/xbmc","html_url":"https://github.com/xbmc","followers_url":"https://api.github.com/users/xbmc/followers","following_url":"https://api.github.com/users/xbmc/following{/other_user}","gists_url":"https://api.github.com/users/xbmc/gists{/gist_id}","starred_url":"https://api.github.com/users/xbmc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xbmc/subscriptions","organizations_url":"https://api.github.com/users/xbmc/orgs","repos_url":"https://api.github.com/users/xbmc/repos","events_url":"https://api.github.com/users/xbmc/events{/privacy}","received_events_url":"https://api.github.com/users/xbmc/received_events","type":"Organization","site_admin":false},"repo":{"id":1217614,"name":"xbmc","full_name":"xbmc/xbmc","owner":{"login":"xbmc","id":199122,"avatar_url":"https://avatars.githubusercontent.com/u/199122?v=3","gravatar_id":"","url":"https://api.github.com/users/xbmc","html_url":"https://github.com/xbmc","followers_url":"https://api.github.com/users/xbmc/followers","following_url":"https://api.github.com/users/xbmc/following{/other_user}","gists_url":"https://api.github.com/users/xbmc/gists{/gist_id}","starred_url":"https://api.github.com/users/xbmc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xbmc/subscriptions","organizations_url":"https://api.github.com/users/xbmc/orgs","repos_url":"https://api.github.com/users/xbmc/repos","events_url":"https://api.github.com/users/xbmc/events{/privacy}","received_events_url":"https://api.github.com/users/xbmc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xbmc/xbmc","description":"Kodi Main Repository - By using this code you agree with our policy and will follow the GPLv2 license as included","fork":false,"url":"https://api.github.com/repos/xbmc/xbmc","forks_url":"https://api.github.com/repos/xbmc/xbmc/forks","keys_url":"https://api.github.com/repos/xbmc/xbmc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xbmc/xbmc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xbmc/xbmc/teams","hooks_url":"https://api.github.com/repos/xbmc/xbmc/hooks","issue_events_url":"https://api.github.com/repos/xbmc/xbmc/issues/events{/number}","events_url":"https://api.github.com/repos/xbmc/xbmc/events","assignees_url":"https://api.github.com/repos/xbmc/xbmc/assignees{/user}","branches_url":"https://api.github.com/repos/xbmc/xbmc/branches{/branch}","tags_url":"https://api.github.com/repos/xbmc/xbmc/tags","blobs_url":"https://api.github.com/repos/xbmc/xbmc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xbmc/xbmc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xbmc/xbmc/git/refs{/sha}","trees_url":"https://api.github.com/repos/xbmc/xbmc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xbmc/xbmc/statuses/{sha}","languages_url":"https://api.github.com/repos/xbmc/xbmc/languages","stargazers_url":"https://api.github.com/repos/xbmc/xbmc/stargazers","contributors_url":"https://api.github.com/repos/xbmc/xbmc/contributors","subscribers_url":"https://api.github.com/repos/xbmc/xbmc/subscribers","subscription_url":"https://api.github.com/repos/xbmc/xbmc/subscription","commits_url":"https://api.github.com/repos/xbmc/xbmc/commits{/sha}","git_commits_url":"https://api.github.com/repos/xbmc/xbmc/git/commits{/sha}","comments_url":"https://api.github.com/repos/xbmc/xbmc/comments{/number}","issue_comment_url":"https://api.github.com/repos/xbmc/xbmc/issues/comments{/number}","contents_url":"https://api.github.com/repos/xbmc/xbmc/contents/{+path}","compare_url":"https://api.github.com/repos/xbmc/xbmc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xbmc/xbmc/merges","archive_url":"https://api.github.com/repos/xbmc/xbmc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xbmc/xbmc/downloads","issues_url":"https://api.github.com/repos/xbmc/xbmc/issues{/number}","pulls_url":"https://api.github.com/repos/xbmc/xbmc/pulls{/number}","milestones_url":"https://api.github.com/repos/xbmc/xbmc/milestones{/number}","notifications_url":"https://api.github.com/repos/xbmc/xbmc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xbmc/xbmc/labels{/name}","releases_url":"https://api.github.com/repos/xbmc/xbmc/releases{/id}","created_at":"2011-01-03T21:18:51Z","updated_at":"2015-07-28T15:12:31Z","pushed_at":"2015-07-28T18:19:25Z","git_url":"git://github.com/xbmc/xbmc.git","ssh_url":"git@github.com:xbmc/xbmc.git","clone_url":"https://github.com/xbmc/xbmc.git","svn_url":"https://github.com/xbmc/xbmc","homepage":"http://kodi.wiki/view/Official:Trademark_Policy","size":1868389,"stargazers_count":4028,"watchers_count":4028,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2944,"mirror_url":null,"open_issues_count":207,"forks":2944,"open_issues":207,"watchers":4028,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xbmc/xbmc/pulls/7637"},"html":{"href":"https://github.com/xbmc/xbmc/pull/7637"},"issue":{"href":"https://api.github.com/repos/xbmc/xbmc/issues/7637"},"comments":{"href":"https://api.github.com/repos/xbmc/xbmc/issues/7637/comments"},"review_comments":{"href":"https://api.github.com/repos/xbmc/xbmc/pulls/7637/comments"},"review_comment":{"href":"https://api.github.com/repos/xbmc/xbmc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xbmc/xbmc/pulls/7637/commits"},"statuses":{"href":"https://api.github.com/repos/xbmc/xbmc/statuses/e5b3e9d2393f830ab8fd05e604637c9606ab8d3c"}}}}