{"action":"created","comment":{"url":"https://api.github.com/repos/JayFoxRox/citra/pulls/comments/58195712","id":58195712,"diff_hunk":"@@ -875,10 +881,33 @@ void RasterizerOpenGL::SyncBlendEnabled() {\n \n void RasterizerOpenGL::SyncBlendFuncs() {\n     const auto& regs = Pica::g_state.regs;\n-    state.blend.src_rgb_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_source_rgb);\n-    state.blend.dst_rgb_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_dest_rgb);\n-    state.blend.src_a_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_source_a);\n-    state.blend.dst_a_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_dest_a);\n+\n+    // This function pretends the destination read was 0x00 if the reads are not allowed\n+    auto BlendAllowedFunc = [&](bool dest, Pica::Regs::BlendFactor factor) -> GLenum {\n+\n+        if (regs.framebuffer.allow_color_read == 0x0) {","path":"src/video_core/renderer_opengl/gl_rasterizer.cpp","position":99,"original_position":25,"commit_id":"27a56dd6323e0e971f4ddd08b277b2738af9d15e","original_commit_id":"46816a0850b0655b0a208c7b01fd54f2036f98c9","user":{"login":"JayFoxRox","id":360330,"avatar_url":"https://avatars.githubusercontent.com/u/360330?v=3","gravatar_id":"","url":"https://api.github.com/users/JayFoxRox","html_url":"https://github.com/JayFoxRox","followers_url":"https://api.github.com/users/JayFoxRox/followers","following_url":"https://api.github.com/users/JayFoxRox/following{/other_user}","gists_url":"https://api.github.com/users/JayFoxRox/gists{/gist_id}","starred_url":"https://api.github.com/users/JayFoxRox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JayFoxRox/subscriptions","organizations_url":"https://api.github.com/users/JayFoxRox/orgs","repos_url":"https://api.github.com/users/JayFoxRox/repos","events_url":"https://api.github.com/users/JayFoxRox/events{/privacy}","received_events_url":"https://api.github.com/users/JayFoxRox/received_events","type":"User","site_admin":false},"body":"Should be outside of the function","created_at":"2016-04-01T11:57:34Z","updated_at":"2016-04-01T11:57:34Z","html_url":"https://github.com/JayFoxRox/citra/pull/4#discussion_r58195712","pull_request_url":"https://api.github.com/repos/JayFoxRox/citra/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/JayFoxRox/citra/pulls/comments/58195712"},"html":{"href":"https://github.com/JayFoxRox/citra/pull/4#discussion_r58195712"},"pull_request":{"href":"https://api.github.com/repos/JayFoxRox/citra/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/JayFoxRox/citra/pulls/4","id":64815882,"html_url":"https://github.com/JayFoxRox/citra/pull/4","diff_url":"https://github.com/JayFoxRox/citra/pull/4.diff","patch_url":"https://github.com/JayFoxRox/citra/pull/4.patch","issue_url":"https://api.github.com/repos/JayFoxRox/citra/issues/4","number":4,"state":"open","locked":false,"title":"Implement buffer-allow registers","user":{"login":"JayFoxRox","id":360330,"avatar_url":"https://avatars.githubusercontent.com/u/360330?v=3","gravatar_id":"","url":"https://api.github.com/users/JayFoxRox","html_url":"https://github.com/JayFoxRox","followers_url":"https://api.github.com/users/JayFoxRox/followers","following_url":"https://api.github.com/users/JayFoxRox/following{/other_user}","gists_url":"https://api.github.com/users/JayFoxRox/gists{/gist_id}","starred_url":"https://api.github.com/users/JayFoxRox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JayFoxRox/subscriptions","organizations_url":"https://api.github.com/users/JayFoxRox/orgs","repos_url":"https://api.github.com/users/JayFoxRox/repos","events_url":"https://api.github.com/users/JayFoxRox/events{/privacy}","received_events_url":"https://api.github.com/users/JayFoxRox/received_events","type":"User","site_admin":false},"body":"This PR implements the \"allow\"-registers which are probably used for powergating (as suggested by @yuriks).\r\n\\- Some games such as Tappingo still depend on them for disabling depth/stencil writes.\r\n\r\nI've chosen the name \"allow\" myself and I'd be happy to change it to something more fitting.\r\nEssentially those are read/write-enable registers for the buffers.\r\nWhile the RGBA register field is 4 bits it will still control all channels at once, it's not a bitmask.\r\nStencil and depth fields are 1 bit each. They also act as a boolean to allow buffer access.\r\n\r\nTesting has shown that disallowed color reads will return zero (per channel) to blend ops.\r\n\r\nThis PR implements this fully in the SW-Rasterizer.\r\n\r\nAs OpenGL is not able to disable framebuffer reads a giant kludge had to be put in place.\r\nColor read operations (LogicOp and Blending) parameters will be modified to emulate 0x00-reads from the color buffer.\r\n\r\nFor depth operations the depth test is modified. If the result of the test is known to be constant the depth function is patched so the 0x00-read is emulated.\r\nFor stencil tests/operations this is somewhat more complex but works the same way as for depth tests.\r\n\r\nIf the result for depth and stencil is not static there is a [LOG_CRITICAL and UNIMPLEMENTED]//FIXME: link will be hit. Unless there is a GL extension for this we can't do much about it (There is slight bit of hope left in one specific case. This is outlined in the source code //FIXME: Link).\r\nThat being said, the conditions for this to happen are ridiculous.\r\n\r\n---\r\n\r\nThis PR was tested [using a HW-Test](https://github.com/JayFoxRox/3ds-tests/tree/master/buffer-allow) ([Results](https://docs.google.com/spreadsheets/d/113T3Grv5HXEBrXbtdSjFQXuXmb0IO7gETu55ka7djNA/edit#gid=0)).\r\nThere are no known regressions while this fixes some games.\r\n\r\nNote that for disallowed color-read **LogicOp was not tested** and **only one blend mode was tested**. More tests for this would be nice.\r\n\r\nHowever, this is a rarely used feature so we could also just review code and say: ship it!\r\n(logic ops are very rare, disallowed buffer reads probably even less popular and blending and doing logic ops on those disallowed buffers probably never happens with a properly written SDK)\r\n\r\nAlso worth noting that most GPUs don't allow write without without read so maybe this even produces undefined behaviour on a real 3DS under some circumstances.\r\n\r\n(I'd like to thank @JohnGodGames for testing)\r\n\r\n---\r\nTODO:\r\n* Rebase to master (currently on printf-fix+w-buffer stuff)\r\n* ~~hw-renderer color: Implement the allow bits for logic ops and blending~~\r\n* hw-renderer depth/stencil: LOG_ERROR if writes are enabled but reads aren't +  handle the writemask\r\n* ~~squash fixups~~\r\n* Fix PR description","created_at":"2016-03-31T16:05:11Z","updated_at":"2016-04-01T11:57:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"585b6775b739629b61d46cdcb2a88ef509b773a8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JayFoxRox/citra/pulls/4/commits","review_comments_url":"https://api.github.com/repos/JayFoxRox/citra/pulls/4/comments","review_comment_url":"https://api.github.com/repos/JayFoxRox/citra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JayFoxRox/citra/issues/4/comments","statuses_url":"https://api.github.com/repos/JayFoxRox/citra/statuses/27a56dd6323e0e971f4ddd08b277b2738af9d15e","head":{"label":"JayFoxRox:buffer-allow","ref":"buffer-allow","sha":"27a56dd6323e0e971f4ddd08b277b2738af9d15e","user":{"login":"JayFoxRox","id":360330,"avatar_url":"https://avatars.githubusercontent.com/u/360330?v=3","gravatar_id":"","url":"https://api.github.com/users/JayFoxRox","html_url":"https://github.com/JayFoxRox","followers_url":"https://api.github.com/users/JayFoxRox/followers","following_url":"https://api.github.com/users/JayFoxRox/following{/other_user}","gists_url":"https://api.github.com/users/JayFoxRox/gists{/gist_id}","starred_url":"https://api.github.com/users/JayFoxRox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JayFoxRox/subscriptions","organizations_url":"https://api.github.com/users/JayFoxRox/orgs","repos_url":"https://api.github.com/users/JayFoxRox/repos","events_url":"https://api.github.com/users/JayFoxRox/events{/privacy}","received_events_url":"https://api.github.com/users/JayFoxRox/received_events","type":"User","site_admin":false},"repo":{"id":53494649,"name":"citra","full_name":"JayFoxRox/citra","owner":{"login":"JayFoxRox","id":360330,"avatar_url":"https://avatars.githubusercontent.com/u/360330?v=3","gravatar_id":"","url":"https://api.github.com/users/JayFoxRox","html_url":"https://github.com/JayFoxRox","followers_url":"https://api.github.com/users/JayFoxRox/followers","following_url":"https://api.github.com/users/JayFoxRox/following{/other_user}","gists_url":"https://api.github.com/users/JayFoxRox/gists{/gist_id}","starred_url":"https://api.github.com/users/JayFoxRox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JayFoxRox/subscriptions","organizations_url":"https://api.github.com/users/JayFoxRox/orgs","repos_url":"https://api.github.com/users/JayFoxRox/repos","events_url":"https://api.github.com/users/JayFoxRox/events{/privacy}","received_events_url":"https://api.github.com/users/JayFoxRox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JayFoxRox/citra","description":"Nintendo 3DS Emulator","fork":true,"url":"https://api.github.com/repos/JayFoxRox/citra","forks_url":"https://api.github.com/repos/JayFoxRox/citra/forks","keys_url":"https://api.github.com/repos/JayFoxRox/citra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JayFoxRox/citra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JayFoxRox/citra/teams","hooks_url":"https://api.github.com/repos/JayFoxRox/citra/hooks","issue_events_url":"https://api.github.com/repos/JayFoxRox/citra/issues/events{/number}","events_url":"https://api.github.com/repos/JayFoxRox/citra/events","assignees_url":"https://api.github.com/repos/JayFoxRox/citra/assignees{/user}","branches_url":"https://api.github.com/repos/JayFoxRox/citra/branches{/branch}","tags_url":"https://api.github.com/repos/JayFoxRox/citra/tags","blobs_url":"https://api.github.com/repos/JayFoxRox/citra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JayFoxRox/citra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JayFoxRox/citra/git/refs{/sha}","trees_url":"https://api.github.com/repos/JayFoxRox/citra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JayFoxRox/citra/statuses/{sha}","languages_url":"https://api.github.com/repos/JayFoxRox/citra/languages","stargazers_url":"https://api.github.com/repos/JayFoxRox/citra/stargazers","contributors_url":"https://api.github.com/repos/JayFoxRox/citra/contributors","subscribers_url":"https://api.github.com/repos/JayFoxRox/citra/subscribers","subscription_url":"https://api.github.com/repos/JayFoxRox/citra/subscription","commits_url":"https://api.github.com/repos/JayFoxRox/citra/commits{/sha}","git_commits_url":"https://api.github.com/repos/JayFoxRox/citra/git/commits{/sha}","comments_url":"https://api.github.com/repos/JayFoxRox/citra/comments{/number}","issue_comment_url":"https://api.github.com/repos/JayFoxRox/citra/issues/comments{/number}","contents_url":"https://api.github.com/repos/JayFoxRox/citra/contents/{+path}","compare_url":"https://api.github.com/repos/JayFoxRox/citra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JayFoxRox/citra/merges","archive_url":"https://api.github.com/repos/JayFoxRox/citra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JayFoxRox/citra/downloads","issues_url":"https://api.github.com/repos/JayFoxRox/citra/issues{/number}","pulls_url":"https://api.github.com/repos/JayFoxRox/citra/pulls{/number}","milestones_url":"https://api.github.com/repos/JayFoxRox/citra/milestones{/number}","notifications_url":"https://api.github.com/repos/JayFoxRox/citra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JayFoxRox/citra/labels{/name}","releases_url":"https://api.github.com/repos/JayFoxRox/citra/releases{/id}","deployments_url":"https://api.github.com/repos/JayFoxRox/citra/deployments","created_at":"2016-03-09T12:06:53Z","updated_at":"2016-03-23T16:17:13Z","pushed_at":"2016-04-01T01:37:40Z","git_url":"git://github.com/JayFoxRox/citra.git","ssh_url":"git@github.com:JayFoxRox/citra.git","clone_url":"https://github.com/JayFoxRox/citra.git","svn_url":"https://github.com/JayFoxRox/citra","homepage":"https://citra-emu.org","size":12001,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"JayFoxRox:master","ref":"master","sha":"fc6f898e0bab7446df330bca3b0807e871520d32","user":{"login":"JayFoxRox","id":360330,"avatar_url":"https://avatars.githubusercontent.com/u/360330?v=3","gravatar_id":"","url":"https://api.github.com/users/JayFoxRox","html_url":"https://github.com/JayFoxRox","followers_url":"https://api.github.com/users/JayFoxRox/followers","following_url":"https://api.github.com/users/JayFoxRox/following{/other_user}","gists_url":"https://api.github.com/users/JayFoxRox/gists{/gist_id}","starred_url":"https://api.github.com/users/JayFoxRox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JayFoxRox/subscriptions","organizations_url":"https://api.github.com/users/JayFoxRox/orgs","repos_url":"https://api.github.com/users/JayFoxRox/repos","events_url":"https://api.github.com/users/JayFoxRox/events{/privacy}","received_events_url":"https://api.github.com/users/JayFoxRox/received_events","type":"User","site_admin":false},"repo":{"id":53494649,"name":"citra","full_name":"JayFoxRox/citra","owner":{"login":"JayFoxRox","id":360330,"avatar_url":"https://avatars.githubusercontent.com/u/360330?v=3","gravatar_id":"","url":"https://api.github.com/users/JayFoxRox","html_url":"https://github.com/JayFoxRox","followers_url":"https://api.github.com/users/JayFoxRox/followers","following_url":"https://api.github.com/users/JayFoxRox/following{/other_user}","gists_url":"https://api.github.com/users/JayFoxRox/gists{/gist_id}","starred_url":"https://api.github.com/users/JayFoxRox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JayFoxRox/subscriptions","organizations_url":"https://api.github.com/users/JayFoxRox/orgs","repos_url":"https://api.github.com/users/JayFoxRox/repos","events_url":"https://api.github.com/users/JayFoxRox/events{/privacy}","received_events_url":"https://api.github.com/users/JayFoxRox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JayFoxRox/citra","description":"Nintendo 3DS Emulator","fork":true,"url":"https://api.github.com/repos/JayFoxRox/citra","forks_url":"https://api.github.com/repos/JayFoxRox/citra/forks","keys_url":"https://api.github.com/repos/JayFoxRox/citra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JayFoxRox/citra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JayFoxRox/citra/teams","hooks_url":"https://api.github.com/repos/JayFoxRox/citra/hooks","issue_events_url":"https://api.github.com/repos/JayFoxRox/citra/issues/events{/number}","events_url":"https://api.github.com/repos/JayFoxRox/citra/events","assignees_url":"https://api.github.com/repos/JayFoxRox/citra/assignees{/user}","branches_url":"https://api.github.com/repos/JayFoxRox/citra/branches{/branch}","tags_url":"https://api.github.com/repos/JayFoxRox/citra/tags","blobs_url":"https://api.github.com/repos/JayFoxRox/citra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JayFoxRox/citra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JayFoxRox/citra/git/refs{/sha}","trees_url":"https://api.github.com/repos/JayFoxRox/citra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JayFoxRox/citra/statuses/{sha}","languages_url":"https://api.github.com/repos/JayFoxRox/citra/languages","stargazers_url":"https://api.github.com/repos/JayFoxRox/citra/stargazers","contributors_url":"https://api.github.com/repos/JayFoxRox/citra/contributors","subscribers_url":"https://api.github.com/repos/JayFoxRox/citra/subscribers","subscription_url":"https://api.github.com/repos/JayFoxRox/citra/subscription","commits_url":"https://api.github.com/repos/JayFoxRox/citra/commits{/sha}","git_commits_url":"https://api.github.com/repos/JayFoxRox/citra/git/commits{/sha}","comments_url":"https://api.github.com/repos/JayFoxRox/citra/comments{/number}","issue_comment_url":"https://api.github.com/repos/JayFoxRox/citra/issues/comments{/number}","contents_url":"https://api.github.com/repos/JayFoxRox/citra/contents/{+path}","compare_url":"https://api.github.com/repos/JayFoxRox/citra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JayFoxRox/citra/merges","archive_url":"https://api.github.com/repos/JayFoxRox/citra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JayFoxRox/citra/downloads","issues_url":"https://api.github.com/repos/JayFoxRox/citra/issues{/number}","pulls_url":"https://api.github.com/repos/JayFoxRox/citra/pulls{/number}","milestones_url":"https://api.github.com/repos/JayFoxRox/citra/milestones{/number}","notifications_url":"https://api.github.com/repos/JayFoxRox/citra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JayFoxRox/citra/labels{/name}","releases_url":"https://api.github.com/repos/JayFoxRox/citra/releases{/id}","deployments_url":"https://api.github.com/repos/JayFoxRox/citra/deployments","created_at":"2016-03-09T12:06:53Z","updated_at":"2016-03-23T16:17:13Z","pushed_at":"2016-04-01T01:37:40Z","git_url":"git://github.com/JayFoxRox/citra.git","ssh_url":"git@github.com:JayFoxRox/citra.git","clone_url":"https://github.com/JayFoxRox/citra.git","svn_url":"https://github.com/JayFoxRox/citra","homepage":"https://citra-emu.org","size":12001,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JayFoxRox/citra/pulls/4"},"html":{"href":"https://github.com/JayFoxRox/citra/pull/4"},"issue":{"href":"https://api.github.com/repos/JayFoxRox/citra/issues/4"},"comments":{"href":"https://api.github.com/repos/JayFoxRox/citra/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/JayFoxRox/citra/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/JayFoxRox/citra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JayFoxRox/citra/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/JayFoxRox/citra/statuses/27a56dd6323e0e971f4ddd08b277b2738af9d15e"}}}}