{"action":"created","comment":{"url":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/comments/178231161","pull_request_review_id":108261380,"id":178231161,"diff_hunk":"@@ -126,8 +126,93 @@ static std::string GenerateFragmentShader(int layer_count) {\n   return fragment_shader_stream.str();\n }\n \n+static GLint LoadPreBuiltBinary(GLint gl_program,\n+                                void *binary, long size) {\n+  GLint status;\n+\n+  std::string extensions((const char *)glGetString(GL_EXTENSIONS));\n+  std::string mesa_prog_bin_fmts(\"GL_MESA_program_binary_formats\");\n+  std::string::size_type pos;\n+\n+  /* check if glProgramBinaryOES exists */\n+  if (!glProgramBinaryOES)\n+    return 0;\n+\n+  pos = extensions.find(mesa_prog_bin_fmts);\n+\n+  /* check GL_MESA_program_binary_formats exists */\n+  if (pos == std::string::npos)\n+    return 0;\n+\n+  /* TODO: we should check whether GL_MESA_program_binary_formats are\n+   * supported here: however, this extension is not currently exposed now\n+   * in MESA tip. Once it's fixed we will add a check routine here\n+   */\n+  glProgramBinaryOES(gl_program, GL_PROGRAM_BINARY_FORMAT_MESA, binary,\n+                     size);\n+\n+  glGetProgramiv(gl_program, GL_LINK_STATUS, &status);\n+  if (status)\n+      return gl_program;\n+\n+  return 0;\n+}\n+\n static GLint GenerateProgram(unsigned num_textures,\n                              std::ostringstream *shader_log) {\n+  GLint status;\n+  GLint program = glCreateProgram();\n+  void *binary_prog;\n+  long binary_sz;\n+\n+  if (!program) {\n+    if (shader_log)\n+      *shader_log << \"Failed to create program.\"\n+                  << \"\\n\";\n+    return 0;\n+  }\n+\n+  /* try to load prebuilt shader program from files */\n+  std::ostringstream shader_program_fname;\n+  shader_program_fname << PREBUILT_SHADER_FILE_PATH\"hwc_shader_prog_\"\n+                       << num_textures\n+                       <<\".shader_test.bin\";\n+\n+  FILE *shader_prog_fp;\n+\n+  shader_prog_fp = fopen(shader_program_fname.str().c_str(), \"rb\");\n+\n+  if (shader_prog_fp) {\n+    /* check the size of file */\n+    fseek(shader_prog_fp, 0, SEEK_END);\n+    binary_sz = ftell(shader_prog_fp);\n+    rewind(shader_prog_fp);\n+\n+    char *binary_prog = (char *)malloc(binary_sz);\n+    if (binary_prog) {\n+      if (fread(binary_prog, 1, binary_sz, shader_prog_fp) == binary_sz) {","path":"common/compositor/gl/glprogram.cpp","position":91,"original_position":68,"commit_id":"2e031d47bf2b41fba865f5ad67e0f5b1f1dda63b","original_commit_id":"a673a7361c1a9066b4224d5405aee06ece0d1883","user":{"login":"strassek","id":758621,"avatar_url":"https://avatars1.githubusercontent.com/u/758621?v=4","gravatar_id":"","url":"https://api.github.com/users/strassek","html_url":"https://github.com/strassek","followers_url":"https://api.github.com/users/strassek/followers","following_url":"https://api.github.com/users/strassek/following{/other_user}","gists_url":"https://api.github.com/users/strassek/gists{/gist_id}","starred_url":"https://api.github.com/users/strassek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strassek/subscriptions","organizations_url":"https://api.github.com/users/strassek/orgs","repos_url":"https://api.github.com/users/strassek/repos","events_url":"https://api.github.com/users/strassek/events{/privacy}","received_events_url":"https://api.github.com/users/strassek/received_events","type":"User","site_admin":false},"body":"Given that we generate shaders on-demand, I don't think it is such a great idea to block on disk access. @kalyankondapally have you considered generating all shaders in bulk during initialization?\r\n","created_at":"2018-03-30T04:30:19Z","updated_at":"2018-03-30T04:40:01Z","html_url":"https://github.com/intel/IA-Hardware-Composer/pull/310#discussion_r178231161","pull_request_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/310","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/comments/178231161"},"html":{"href":"https://github.com/intel/IA-Hardware-Composer/pull/310#discussion_r178231161"},"pull_request":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/310"}}},"pull_request":{"url":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/310","id":178425004,"html_url":"https://github.com/intel/IA-Hardware-Composer/pull/310","diff_url":"https://github.com/intel/IA-Hardware-Composer/pull/310.diff","patch_url":"https://github.com/intel/IA-Hardware-Composer/pull/310.patch","issue_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/issues/310","number":310,"state":"open","locked":false,"title":"Pre-built shader support (NEW)","user":{"login":"downor","id":9060211,"avatar_url":"https://avatars0.githubusercontent.com/u/9060211?v=4","gravatar_id":"","url":"https://api.github.com/users/downor","html_url":"https://github.com/downor","followers_url":"https://api.github.com/users/downor/followers","following_url":"https://api.github.com/users/downor/following{/other_user}","gists_url":"https://api.github.com/users/downor/gists{/gist_id}","starred_url":"https://api.github.com/users/downor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/downor/subscriptions","organizations_url":"https://api.github.com/users/downor/orgs","repos_url":"https://api.github.com/users/downor/repos","events_url":"https://api.github.com/users/downor/events{/privacy}","received_events_url":"https://api.github.com/users/downor/received_events","type":"User","site_admin":false},"body":"This pull request replaces the previous pull request (#292).\r\n\r\nNow there are three changes under this pull request, which basically make build process now takes care of pre-building of shaders automatically if provided this new configuration option:\r\n\r\n--prebuilt-shader-pci-id=<PCI ID in hex number form (e.g 0x1234) >\r\n\r\nAND\r\n\r\nshader-db library and executable (intel_stub.so, run) exist under common/compositor/gl/gl_shader_pre_built/shader-db/\r\n\r\nOnce binary data (shader program binary) is generated, it will be added to the HWC source as header files and compiled together with it.\r\n\r\nglprogram.cpp tries to load this static data first. If it does not exist or fail to load it, it tries to get load this binary data from files at /vendor/etc if available. Then it goes to run-time compilation path if none of those prebuilt shaders are available or functional.\r\n\r\nJira: None.\r\nTest: \r\nA. built in binary test\r\n\r\n0. Place <shader-db> project under ./common/compositor/gl/gl_shader_pre_built/\r\n\r\n1. Build HWC:\r\n./autogen.sh --prefix=$WLD --prebuilt-shader-pci-id=<current GPU's PCI-ID>\r\nmake && make install\r\n\r\n2. Verify testlayer works with built-in pre-built shaders\r\n\r\nB. shader program files test\r\n\r\n1. Build HWC:\r\n  ./autogen.sh --prefix=$WLD\r\n  make && make install\r\n\r\n2. run ./common/compositor/gl/gl_shader_pre_built/generate_shader_test.sh\r\n    use shader-db to build shader program binaries from generated shader-test files \r\n    move *.shader_test.bin over to under /vendor/etc\r\n   \r\n3. Verify testlayer works with built-in pre-built shaders\r\n\r\nSigned-off-by: Dongwon Kim dongwon.kim@intel.com","created_at":"2018-03-29T19:52:01Z","updated_at":"2018-03-30T04:40:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a5dcc9361b242373f94f42ab8f78533b49675919","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[{"name":"graphics-userspace write","id":2408740,"slug":"graphics-userspace-write","description":"","privacy":"closed","url":"https://api.github.com/teams/2408740","members_url":"https://api.github.com/teams/2408740/members{/member}","repositories_url":"https://api.github.com/teams/2408740/repos","permission":"pull"}],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/310/commits","review_comments_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/310/comments","review_comment_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/issues/310/comments","statuses_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/statuses/2e031d47bf2b41fba865f5ad67e0f5b1f1dda63b","head":{"label":"downor:master","ref":"master","sha":"2e031d47bf2b41fba865f5ad67e0f5b1f1dda63b","user":{"login":"downor","id":9060211,"avatar_url":"https://avatars0.githubusercontent.com/u/9060211?v=4","gravatar_id":"","url":"https://api.github.com/users/downor","html_url":"https://github.com/downor","followers_url":"https://api.github.com/users/downor/followers","following_url":"https://api.github.com/users/downor/following{/other_user}","gists_url":"https://api.github.com/users/downor/gists{/gist_id}","starred_url":"https://api.github.com/users/downor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/downor/subscriptions","organizations_url":"https://api.github.com/users/downor/orgs","repos_url":"https://api.github.com/users/downor/repos","events_url":"https://api.github.com/users/downor/events{/privacy}","received_events_url":"https://api.github.com/users/downor/received_events","type":"User","site_admin":false},"repo":{"id":127200784,"name":"IA-Hardware-Composer","full_name":"downor/IA-Hardware-Composer","owner":{"login":"downor","id":9060211,"avatar_url":"https://avatars0.githubusercontent.com/u/9060211?v=4","gravatar_id":"","url":"https://api.github.com/users/downor","html_url":"https://github.com/downor","followers_url":"https://api.github.com/users/downor/followers","following_url":"https://api.github.com/users/downor/following{/other_user}","gists_url":"https://api.github.com/users/downor/gists{/gist_id}","starred_url":"https://api.github.com/users/downor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/downor/subscriptions","organizations_url":"https://api.github.com/users/downor/orgs","repos_url":"https://api.github.com/users/downor/repos","events_url":"https://api.github.com/users/downor/events{/privacy}","received_events_url":"https://api.github.com/users/downor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/downor/IA-Hardware-Composer","description":null,"fork":true,"url":"https://api.github.com/repos/downor/IA-Hardware-Composer","forks_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/forks","keys_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/teams","hooks_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/hooks","issue_events_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/issues/events{/number}","events_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/events","assignees_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/assignees{/user}","branches_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/branches{/branch}","tags_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/tags","blobs_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/git/refs{/sha}","trees_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/statuses/{sha}","languages_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/languages","stargazers_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/stargazers","contributors_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/contributors","subscribers_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/subscribers","subscription_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/subscription","commits_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/commits{/sha}","git_commits_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/git/commits{/sha}","comments_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/comments{/number}","issue_comment_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/issues/comments{/number}","contents_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/contents/{+path}","compare_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/merges","archive_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/downloads","issues_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/issues{/number}","pulls_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/pulls{/number}","milestones_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/milestones{/number}","notifications_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/labels{/name}","releases_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/releases{/id}","deployments_url":"https://api.github.com/repos/downor/IA-Hardware-Composer/deployments","created_at":"2018-03-28T21:29:38Z","updated_at":"2018-03-29T19:19:14Z","pushed_at":"2018-03-29T19:19:13Z","git_url":"git://github.com/downor/IA-Hardware-Composer.git","ssh_url":"git@github.com:downor/IA-Hardware-Composer.git","clone_url":"https://github.com/downor/IA-Hardware-Composer.git","svn_url":"https://github.com/downor/IA-Hardware-Composer","homepage":null,"size":33392,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"intel:master","ref":"master","sha":"e4e6e4200ffcc86f0614ec8dd6986a94249b2530","user":{"login":"intel","id":17888862,"avatar_url":"https://avatars3.githubusercontent.com/u/17888862?v=4","gravatar_id":"","url":"https://api.github.com/users/intel","html_url":"https://github.com/intel","followers_url":"https://api.github.com/users/intel/followers","following_url":"https://api.github.com/users/intel/following{/other_user}","gists_url":"https://api.github.com/users/intel/gists{/gist_id}","starred_url":"https://api.github.com/users/intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intel/subscriptions","organizations_url":"https://api.github.com/users/intel/orgs","repos_url":"https://api.github.com/users/intel/repos","events_url":"https://api.github.com/users/intel/events{/privacy}","received_events_url":"https://api.github.com/users/intel/received_events","type":"Organization","site_admin":false},"repo":{"id":81935252,"name":"IA-Hardware-Composer","full_name":"intel/IA-Hardware-Composer","owner":{"login":"intel","id":17888862,"avatar_url":"https://avatars3.githubusercontent.com/u/17888862?v=4","gravatar_id":"","url":"https://api.github.com/users/intel","html_url":"https://github.com/intel","followers_url":"https://api.github.com/users/intel/followers","following_url":"https://api.github.com/users/intel/following{/other_user}","gists_url":"https://api.github.com/users/intel/gists{/gist_id}","starred_url":"https://api.github.com/users/intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intel/subscriptions","organizations_url":"https://api.github.com/users/intel/orgs","repos_url":"https://api.github.com/users/intel/repos","events_url":"https://api.github.com/users/intel/events{/privacy}","received_events_url":"https://api.github.com/users/intel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intel/IA-Hardware-Composer","description":null,"fork":false,"url":"https://api.github.com/repos/intel/IA-Hardware-Composer","forks_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/forks","keys_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/teams","hooks_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/hooks","issue_events_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/issues/events{/number}","events_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/events","assignees_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/assignees{/user}","branches_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/branches{/branch}","tags_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/tags","blobs_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/git/refs{/sha}","trees_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/statuses/{sha}","languages_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/languages","stargazers_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/stargazers","contributors_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/contributors","subscribers_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/subscribers","subscription_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/subscription","commits_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/commits{/sha}","git_commits_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/git/commits{/sha}","comments_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/comments{/number}","issue_comment_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/issues/comments{/number}","contents_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/contents/{+path}","compare_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/merges","archive_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/downloads","issues_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/issues{/number}","pulls_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls{/number}","milestones_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/milestones{/number}","notifications_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/labels{/name}","releases_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/releases{/id}","deployments_url":"https://api.github.com/repos/intel/IA-Hardware-Composer/deployments","created_at":"2017-02-14T10:45:35Z","updated_at":"2018-03-30T03:58:15Z","pushed_at":"2018-03-30T04:19:15Z","git_url":"git://github.com/intel/IA-Hardware-Composer.git","ssh_url":"git@github.com:intel/IA-Hardware-Composer.git","clone_url":"https://github.com/intel/IA-Hardware-Composer.git","svn_url":"https://github.com/intel/IA-Hardware-Composer","homepage":null,"size":33400,"stargazers_count":15,"watchers_count":15,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":52,"mirror_url":null,"archived":false,"open_issues_count":19,"license":null,"forks":52,"open_issues":19,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/310"},"html":{"href":"https://github.com/intel/IA-Hardware-Composer/pull/310"},"issue":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/issues/310"},"comments":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/issues/310/comments"},"review_comments":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/310/comments"},"review_comment":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/pulls/310/commits"},"statuses":{"href":"https://api.github.com/repos/intel/IA-Hardware-Composer/statuses/2e031d47bf2b41fba865f5ad67e0f5b1f1dda63b"}},"author_association":"NONE"}}
{"actor":{"display_login":"strassek"}}