{"action":"created","comment":{"url":"https://api.github.com/repos/RPCS3/rpcs3/pulls/comments/216954911","pull_request_review_id":154554141,"id":216954911,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNjk1NDkxMQ==","diff_hunk":"@@ -21,20 +21,34 @@\n #define IS_BE_MACHINE 0\n \n #ifdef _MSC_VER\n-#define ASSUME(cond) __assume(cond)\n+\n+#define ASSUME(cond) __assume(cond) // MSVC __assume ignores side-effects","path":"Utilities/types.h","position":6,"original_position":6,"commit_id":"b9db0d32fa4829ed77ccb4bf2998d4337788814d","original_commit_id":"b9db0d32fa4829ed77ccb4bf2998d4337788814d","user":{"login":"Nekotekina","id":6028184,"node_id":"MDQ6VXNlcjYwMjgxODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6028184?v=4","gravatar_id":"","url":"https://api.github.com/users/Nekotekina","html_url":"https://github.com/Nekotekina","followers_url":"https://api.github.com/users/Nekotekina/followers","following_url":"https://api.github.com/users/Nekotekina/following{/other_user}","gists_url":"https://api.github.com/users/Nekotekina/gists{/gist_id}","starred_url":"https://api.github.com/users/Nekotekina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nekotekina/subscriptions","organizations_url":"https://api.github.com/users/Nekotekina/orgs","repos_url":"https://api.github.com/users/Nekotekina/repos","events_url":"https://api.github.com/users/Nekotekina/events{/privacy}","received_events_url":"https://api.github.com/users/Nekotekina/received_events","type":"User","site_admin":false},"body":"Old problem, but most macro should use ... and __VA_ARGS__ instead of a single named arg.","created_at":"2018-09-12T09:15:42Z","updated_at":"2018-09-12T09:15:43Z","html_url":"https://github.com/RPCS3/rpcs3/pull/5115#discussion_r216954911","pull_request_url":"https://api.github.com/repos/RPCS3/rpcs3/pulls/5115","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/RPCS3/rpcs3/pulls/comments/216954911"},"html":{"href":"https://github.com/RPCS3/rpcs3/pull/5115#discussion_r216954911"},"pull_request":{"href":"https://api.github.com/repos/RPCS3/rpcs3/pulls/5115"}}},"pull_request":{"url":"https://api.github.com/repos/RPCS3/rpcs3/pulls/5115","id":214797066,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0Nzk3MDY2","html_url":"https://github.com/RPCS3/rpcs3/pull/5115","diff_url":"https://github.com/RPCS3/rpcs3/pull/5115.diff","patch_url":"https://github.com/RPCS3/rpcs3/pull/5115.patch","issue_url":"https://api.github.com/repos/RPCS3/rpcs3/issues/5115","number":5115,"state":"open","locked":false,"title":"[WIP] [Testing needed] Texture Cache cleanup/refactoring & fixes","user":{"login":"ruipin","id":11169970,"node_id":"MDQ6VXNlcjExMTY5OTcw","avatar_url":"https://avatars3.githubusercontent.com/u/11169970?v=4","gravatar_id":"","url":"https://api.github.com/users/ruipin","html_url":"https://github.com/ruipin","followers_url":"https://api.github.com/users/ruipin/followers","following_url":"https://api.github.com/users/ruipin/following{/other_user}","gists_url":"https://api.github.com/users/ruipin/gists{/gist_id}","starred_url":"https://api.github.com/users/ruipin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruipin/subscriptions","organizations_url":"https://api.github.com/users/ruipin/orgs","repos_url":"https://api.github.com/users/ruipin/repos","events_url":"https://api.github.com/users/ruipin/events{/privacy}","received_events_url":"https://api.github.com/users/ruipin/received_events","type":"User","site_admin":false},"body":"This PR is the result of over 4 weeks of significant effort to debug, cleanup and optimize the RSX Texture Cache.\r\n\r\n(Note that the texture cache is mostly a \"backend\" part of the emulator, so don't expect these changes to have a large impact on the number of bugs)\r\n\r\n**There are a significant amount of changes, which means this PR is high-risk**. I have tried to verify this as best as possible (having introduced the `AUDIT` macro for this exact purpose), however I am a single person and cannot test every single game. Things **will** break and performance could suffer.\r\n\r\nAlthough in my tests this PR shows a small performance improvement depending on the game, this might just be a coincidence. Please report any significant peformance differences (both improvements and losses), as well as any regressions you find.\r\n\r\nAs a final note, I'd like to thank @kd-11 for his invaluable help in the last couple of months.\r\n\r\n---------------------------\r\n\r\nNow for the (long) changelist:\r\n\r\n__General changes:__\r\n  - Adds a try/catch around the RSX violation handler so that crashes/verify failures inside it do not silently crash RPCS3\r\n  - Adds the `ASSERT` and `AUDIT` macros as wrappers around verify. `AUDIT` can be enabled selectively by defining `_DEBUG` or `_AUDIT` before including `types.h`.\r\n  - Changes ASSUME in clang to use __builtin_assume because it ignores side-effects\r\n    Justification:\r\n    - gcc/clang with `__builtin_unreachable`: https://gcc.godbolt.org/z/xYAtu6\r\n    - clang with `__builtin_assume`: https://gcc.godbolt.org/z/UIpAzB\r\n    - MSVC (with `__assume`): https://gcc.godbolt.org/z/vGP2I4\r\n\r\n__RSX/Texture Cache changes:__\r\n  - (debug) Add a significant number of `AUDIT` assertions, as well as texture cache sanity checks gated behind `TEXTURE_CACHE_DEBUG`\r\n  - (cleanup) Refactor all uses of `std::pair<u32,u32>` for address ranges into a dedicated `rsx::address_range` struct\r\n  - (optimization) Restructure `get_intersecting_set` and `unprotect_set` to avoid chaining into neighboring or unsynchronized sections unless necessary. Re-enable full-range protection by default even without SRM.  \r\n  - (optimization) Batch `memory_protect` calls when invalidating sections\r\n  - (cleanup) Refactor uses of `std::vector<section_storage_type*>` in the invalidation algorithm into a dedicated `address_range_vector` struct\r\n  - (optimization) Support exclusion of RO sections. If a NA section gets unprotected, and a RO section overlaps it (but is not in the set of textures to unprotect), the section will now be reprotected RO\r\n  - (bugfix) Implement automatic `ranged_storage` reference counting through callbacks, getting rid of the very common `texture_cache.h:301` verification failures forever\r\n  - (bugfix) Reset all cached section members when `reset()` is called and a section is going to be reused for something else\r\n  - (bugfix) Implement automatic `m_flush_always_cache` tracking through callbacks to avoid forgetting to remove sections (e.g. when they get reset/replaced)\r\n  - (cleanup) Refactor ranged storage from `std::unordered_map` into a dedicated class `ranged_storage`\r\n  - (optimization) Pre-allocate all ranged storage blocks at startup to have O(1) access and avoid expensive (de-)allocations during runtime. These structs are small anyway.\r\n  - (optimization) Maintain a list of unowned overlapping sections inside each ranged storage block to make iterating through all sections in a specified range cheaper (no longer necessary to iterate through all section blocks)\r\n  - (optimization) Ranged storage blocks now store their blocks using a \"list of constant-size arrays\" (`class ranged_storage_block_list`) instead of using `std::vector`. This prevents constant reallocations when the vector grows in size, while avoiding the slow (uncacheable) iterations common to a list of objects. After some testing I have chosen 32 sections per list element, as this seemed to show no performance loss compared to `std::vector`.\r\n  - (cleanup/optimization) Implement `range_iterator` for ranged storage. Given an address range, it will iterate automatically through all overlapping sections, using an optimized algorithm taking advantage the new \"unowned overlapping sections\" list mentioned above.\r\n  - (cleanup) Move all texture cache support code (such as `ranged_storage`, `cached_texture_section`, etc) from `RSX/Common/texture_cache.h` to `RSX/Common/texture_cache_utils.h`.\r\n\r\nOther than the above changes, I underwent a general review of the texture cache code, which resulted in various small bug fixes and tweaks I did not mention above (too many to list), some of which have already been merged in past PRs.","created_at":"2018-09-11T23:41:08Z","updated_at":"2018-09-12T09:15:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"553cbfdf735f1f140f7cbc5f48f3c741be75dee0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/RPCS3/rpcs3/pulls/5115/commits","review_comments_url":"https://api.github.com/repos/RPCS3/rpcs3/pulls/5115/comments","review_comment_url":"https://api.github.com/repos/RPCS3/rpcs3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RPCS3/rpcs3/issues/5115/comments","statuses_url":"https://api.github.com/repos/RPCS3/rpcs3/statuses/b9db0d32fa4829ed77ccb4bf2998d4337788814d","head":{"label":"ruipin:texture-cache-pr","ref":"texture-cache-pr","sha":"b9db0d32fa4829ed77ccb4bf2998d4337788814d","user":{"login":"ruipin","id":11169970,"node_id":"MDQ6VXNlcjExMTY5OTcw","avatar_url":"https://avatars3.githubusercontent.com/u/11169970?v=4","gravatar_id":"","url":"https://api.github.com/users/ruipin","html_url":"https://github.com/ruipin","followers_url":"https://api.github.com/users/ruipin/followers","following_url":"https://api.github.com/users/ruipin/following{/other_user}","gists_url":"https://api.github.com/users/ruipin/gists{/gist_id}","starred_url":"https://api.github.com/users/ruipin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruipin/subscriptions","organizations_url":"https://api.github.com/users/ruipin/orgs","repos_url":"https://api.github.com/users/ruipin/repos","events_url":"https://api.github.com/users/ruipin/events{/privacy}","received_events_url":"https://api.github.com/users/ruipin/received_events","type":"User","site_admin":false},"repo":{"id":133569071,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM1NjkwNzE=","name":"rpcs3","full_name":"ruipin/rpcs3","owner":{"login":"ruipin","id":11169970,"node_id":"MDQ6VXNlcjExMTY5OTcw","avatar_url":"https://avatars3.githubusercontent.com/u/11169970?v=4","gravatar_id":"","url":"https://api.github.com/users/ruipin","html_url":"https://github.com/ruipin","followers_url":"https://api.github.com/users/ruipin/followers","following_url":"https://api.github.com/users/ruipin/following{/other_user}","gists_url":"https://api.github.com/users/ruipin/gists{/gist_id}","starred_url":"https://api.github.com/users/ruipin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruipin/subscriptions","organizations_url":"https://api.github.com/users/ruipin/orgs","repos_url":"https://api.github.com/users/ruipin/repos","events_url":"https://api.github.com/users/ruipin/events{/privacy}","received_events_url":"https://api.github.com/users/ruipin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ruipin/rpcs3","description":"PS3 emulator/debugger","fork":true,"url":"https://api.github.com/repos/ruipin/rpcs3","forks_url":"https://api.github.com/repos/ruipin/rpcs3/forks","keys_url":"https://api.github.com/repos/ruipin/rpcs3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ruipin/rpcs3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ruipin/rpcs3/teams","hooks_url":"https://api.github.com/repos/ruipin/rpcs3/hooks","issue_events_url":"https://api.github.com/repos/ruipin/rpcs3/issues/events{/number}","events_url":"https://api.github.com/repos/ruipin/rpcs3/events","assignees_url":"https://api.github.com/repos/ruipin/rpcs3/assignees{/user}","branches_url":"https://api.github.com/repos/ruipin/rpcs3/branches{/branch}","tags_url":"https://api.github.com/repos/ruipin/rpcs3/tags","blobs_url":"https://api.github.com/repos/ruipin/rpcs3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ruipin/rpcs3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ruipin/rpcs3/git/refs{/sha}","trees_url":"https://api.github.com/repos/ruipin/rpcs3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ruipin/rpcs3/statuses/{sha}","languages_url":"https://api.github.com/repos/ruipin/rpcs3/languages","stargazers_url":"https://api.github.com/repos/ruipin/rpcs3/stargazers","contributors_url":"https://api.github.com/repos/ruipin/rpcs3/contributors","subscribers_url":"https://api.github.com/repos/ruipin/rpcs3/subscribers","subscription_url":"https://api.github.com/repos/ruipin/rpcs3/subscription","commits_url":"https://api.github.com/repos/ruipin/rpcs3/commits{/sha}","git_commits_url":"https://api.github.com/repos/ruipin/rpcs3/git/commits{/sha}","comments_url":"https://api.github.com/repos/ruipin/rpcs3/comments{/number}","issue_comment_url":"https://api.github.com/repos/ruipin/rpcs3/issues/comments{/number}","contents_url":"https://api.github.com/repos/ruipin/rpcs3/contents/{+path}","compare_url":"https://api.github.com/repos/ruipin/rpcs3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ruipin/rpcs3/merges","archive_url":"https://api.github.com/repos/ruipin/rpcs3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ruipin/rpcs3/downloads","issues_url":"https://api.github.com/repos/ruipin/rpcs3/issues{/number}","pulls_url":"https://api.github.com/repos/ruipin/rpcs3/pulls{/number}","milestones_url":"https://api.github.com/repos/ruipin/rpcs3/milestones{/number}","notifications_url":"https://api.github.com/repos/ruipin/rpcs3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ruipin/rpcs3/labels{/name}","releases_url":"https://api.github.com/repos/ruipin/rpcs3/releases{/id}","deployments_url":"https://api.github.com/repos/ruipin/rpcs3/deployments","created_at":"2018-05-15T20:22:09Z","updated_at":"2018-08-02T23:56:25Z","pushed_at":"2018-09-11T23:24:03Z","git_url":"git://github.com/ruipin/rpcs3.git","ssh_url":"git@github.com:ruipin/rpcs3.git","clone_url":"https://github.com/ruipin/rpcs3.git","svn_url":"https://github.com/ruipin/rpcs3","homepage":"https://rpcs3.net/","size":51570,"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":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RPCS3:master","ref":"master","sha":"efbd77deb4270a56543f4204d3fe22f4dd6d4539","user":{"login":"RPCS3","id":8070735,"node_id":"MDEyOk9yZ2FuaXphdGlvbjgwNzA3MzU=","avatar_url":"https://avatars3.githubusercontent.com/u/8070735?v=4","gravatar_id":"","url":"https://api.github.com/users/RPCS3","html_url":"https://github.com/RPCS3","followers_url":"https://api.github.com/users/RPCS3/followers","following_url":"https://api.github.com/users/RPCS3/following{/other_user}","gists_url":"https://api.github.com/users/RPCS3/gists{/gist_id}","starred_url":"https://api.github.com/users/RPCS3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RPCS3/subscriptions","organizations_url":"https://api.github.com/users/RPCS3/orgs","repos_url":"https://api.github.com/users/RPCS3/repos","events_url":"https://api.github.com/users/RPCS3/events{/privacy}","received_events_url":"https://api.github.com/users/RPCS3/received_events","type":"Organization","site_admin":false},"repo":{"id":6520784,"node_id":"MDEwOlJlcG9zaXRvcnk2NTIwNzg0","name":"rpcs3","full_name":"RPCS3/rpcs3","owner":{"login":"RPCS3","id":8070735,"node_id":"MDEyOk9yZ2FuaXphdGlvbjgwNzA3MzU=","avatar_url":"https://avatars3.githubusercontent.com/u/8070735?v=4","gravatar_id":"","url":"https://api.github.com/users/RPCS3","html_url":"https://github.com/RPCS3","followers_url":"https://api.github.com/users/RPCS3/followers","following_url":"https://api.github.com/users/RPCS3/following{/other_user}","gists_url":"https://api.github.com/users/RPCS3/gists{/gist_id}","starred_url":"https://api.github.com/users/RPCS3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RPCS3/subscriptions","organizations_url":"https://api.github.com/users/RPCS3/orgs","repos_url":"https://api.github.com/users/RPCS3/repos","events_url":"https://api.github.com/users/RPCS3/events{/privacy}","received_events_url":"https://api.github.com/users/RPCS3/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RPCS3/rpcs3","description":"PS3 emulator/debugger","fork":false,"url":"https://api.github.com/repos/RPCS3/rpcs3","forks_url":"https://api.github.com/repos/RPCS3/rpcs3/forks","keys_url":"https://api.github.com/repos/RPCS3/rpcs3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RPCS3/rpcs3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RPCS3/rpcs3/teams","hooks_url":"https://api.github.com/repos/RPCS3/rpcs3/hooks","issue_events_url":"https://api.github.com/repos/RPCS3/rpcs3/issues/events{/number}","events_url":"https://api.github.com/repos/RPCS3/rpcs3/events","assignees_url":"https://api.github.com/repos/RPCS3/rpcs3/assignees{/user}","branches_url":"https://api.github.com/repos/RPCS3/rpcs3/branches{/branch}","tags_url":"https://api.github.com/repos/RPCS3/rpcs3/tags","blobs_url":"https://api.github.com/repos/RPCS3/rpcs3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RPCS3/rpcs3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RPCS3/rpcs3/git/refs{/sha}","trees_url":"https://api.github.com/repos/RPCS3/rpcs3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RPCS3/rpcs3/statuses/{sha}","languages_url":"https://api.github.com/repos/RPCS3/rpcs3/languages","stargazers_url":"https://api.github.com/repos/RPCS3/rpcs3/stargazers","contributors_url":"https://api.github.com/repos/RPCS3/rpcs3/contributors","subscribers_url":"https://api.github.com/repos/RPCS3/rpcs3/subscribers","subscription_url":"https://api.github.com/repos/RPCS3/rpcs3/subscription","commits_url":"https://api.github.com/repos/RPCS3/rpcs3/commits{/sha}","git_commits_url":"https://api.github.com/repos/RPCS3/rpcs3/git/commits{/sha}","comments_url":"https://api.github.com/repos/RPCS3/rpcs3/comments{/number}","issue_comment_url":"https://api.github.com/repos/RPCS3/rpcs3/issues/comments{/number}","contents_url":"https://api.github.com/repos/RPCS3/rpcs3/contents/{+path}","compare_url":"https://api.github.com/repos/RPCS3/rpcs3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RPCS3/rpcs3/merges","archive_url":"https://api.github.com/repos/RPCS3/rpcs3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RPCS3/rpcs3/downloads","issues_url":"https://api.github.com/repos/RPCS3/rpcs3/issues{/number}","pulls_url":"https://api.github.com/repos/RPCS3/rpcs3/pulls{/number}","milestones_url":"https://api.github.com/repos/RPCS3/rpcs3/milestones{/number}","notifications_url":"https://api.github.com/repos/RPCS3/rpcs3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RPCS3/rpcs3/labels{/name}","releases_url":"https://api.github.com/repos/RPCS3/rpcs3/releases{/id}","deployments_url":"https://api.github.com/repos/RPCS3/rpcs3/deployments","created_at":"2012-11-03T15:16:18Z","updated_at":"2018-09-12T04:21:59Z","pushed_at":"2018-09-11T23:41:09Z","git_url":"git://github.com/RPCS3/rpcs3.git","ssh_url":"git@github.com:RPCS3/rpcs3.git","clone_url":"https://github.com/RPCS3/rpcs3.git","svn_url":"https://github.com/RPCS3/rpcs3","homepage":"https://rpcs3.net/","size":52554,"stargazers_count":5471,"watchers_count":5471,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":992,"mirror_url":null,"archived":false,"open_issues_count":394,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":992,"open_issues":394,"watchers":5471,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RPCS3/rpcs3/pulls/5115"},"html":{"href":"https://github.com/RPCS3/rpcs3/pull/5115"},"issue":{"href":"https://api.github.com/repos/RPCS3/rpcs3/issues/5115"},"comments":{"href":"https://api.github.com/repos/RPCS3/rpcs3/issues/5115/comments"},"review_comments":{"href":"https://api.github.com/repos/RPCS3/rpcs3/pulls/5115/comments"},"review_comment":{"href":"https://api.github.com/repos/RPCS3/rpcs3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RPCS3/rpcs3/pulls/5115/commits"},"statuses":{"href":"https://api.github.com/repos/RPCS3/rpcs3/statuses/b9db0d32fa4829ed77ccb4bf2998d4337788814d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Nekotekina"}}