{"action":"created","comment":{"url":"https://api.github.com/repos/Vita3K/Vita3K/pulls/comments/176573657","pull_request_review_id":106303562,"id":176573657,"diff_hunk":"@@ -1010,27 +1010,64 @@ EXPORT(int, sceGxmSetFragmentTexture, SceGxmContext *context, unsigned int textu\n \n     glActiveTexture((GLenum)(GL_TEXTURE0 + textureIndex));\n     glBindTexture(GL_TEXTURE_2D, context->texture[0]);\n+\n+    // Disable mip-maps\n     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);\n \n-    if (texture->format == SCE_GXM_TEXTURE_FORMAT_P8_ABGR) {\n+    if (texture::is_paletted_format(texture->format)) {\n+        const auto base_format = texture::get_base_format(texture->format);\n+        const auto is_byte_indexed = (base_format == SCE_GXM_TEXTURE_BASE_FORMAT_P8); // only altenative is SCE_GXM_TEXTURE_BASE_FORMAT_P4\n+        const auto palette_indexes = is_byte_indexed ? 256 : 16;\n+\n         glPixelTransferi(GL_MAP_COLOR, GL_TRUE);\n+\n+        // second dimension should be palette_indexes sized instead of 256, but prefer to keep it constant/stack-allocated\n+        // TODO: Cache palette map instead of calculating here every time\n         GLfloat map[4][256];\n+\n         const uint8_t(*const src)[4] = static_cast<uint8_t(*)[4]>(texture->palette.get(host.mem));\n-        for (size_t i = 0; i < 256; ++i) {\n+        for (size_t i = 0; i < palette_indexes; ++i) {\n             map[0][i] = src[i][0] / 255.0f;\n             map[1][i] = src[i][1] / 255.0f;\n             map[2][i] = src[i][2] / 255.0f;\n             map[3][i] = src[i][3] / 255.0f;\n         }\n-        glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 256, map[0]);\n-        glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 256, map[1]);\n-        glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 256, map[2]);\n-        glPixelMapfv(GL_PIXEL_MAP_I_TO_A, 256, map[3]);\n+\n+        // map channel indexes for each channel\n+        // A == A_max means alpha channel is unused (max)\n+        std::uint8_t R = 0, G = 0, B = 0, A = 0;\n+        constexpr auto A_max = std::numeric_limits<decltype(A)>::max();\n+\n+        switch (texture::get_swizzle(texture->format)) {\n+        case SCE_GXM_TEXTURE_SWIZZLE4_ABGR: R = 0; G = 1; B = 2; A = 3; break;\n+        case SCE_GXM_TEXTURE_SWIZZLE4_ARGB: R = 2; G = 1; B = 0; A = 3; break;\n+        case SCE_GXM_TEXTURE_SWIZZLE4_RGBA: R = 3; G = 2; B = 1; A = 0; break;\n+        case SCE_GXM_TEXTURE_SWIZZLE4_BGRA: R = 1; G = 2; B = 3; A = 0; break;\n+        case SCE_GXM_TEXTURE_SWIZZLE4_1BGR: R = 0; G = 1; B = 2; A = A_max; break;\n+        case SCE_GXM_TEXTURE_SWIZZLE4_1RGB: R = 2; G = 1; B = 0; A = A_max; break;\n+        case SCE_GXM_TEXTURE_SWIZZLE4_RGB1: R = 3; G = 2; B = 1; A = A_max; break;\n+        case SCE_GXM_TEXTURE_SWIZZLE4_BGR1: R = 1; G = 2; B = 3; A = A_max; break;\n+        default:\n+        {\n+            LOG_ERROR(\"Invalid swizzle for paletted texture foramt.\");\n+        }\n+        }\n+\n+        glPixelMapfv(GL_PIXEL_MAP_I_TO_R, palette_indexes, map[R]);\n+        glPixelMapfv(GL_PIXEL_MAP_I_TO_G, palette_indexes, map[G]);\n+        glPixelMapfv(GL_PIXEL_MAP_I_TO_B, palette_indexes, map[B]);\n+        if (A == A_max) {\n+            constexpr float max_alpha[1] = { 255.0 };","path":"src/emulator/modules/SceGxm/SceGxm.cpp","position":null,"original_position":97,"commit_id":"45f52b4588be5793cd757677ef955a60d0f966f1","original_commit_id":"0545c3a08b80d42f80b83f4ecb55be91fdfa9fb3","user":{"login":"VelocityRa","id":6632271,"avatar_url":"https://avatars2.githubusercontent.com/u/6632271?v=4","gravatar_id":"","url":"https://api.github.com/users/VelocityRa","html_url":"https://github.com/VelocityRa","followers_url":"https://api.github.com/users/VelocityRa/followers","following_url":"https://api.github.com/users/VelocityRa/following{/other_user}","gists_url":"https://api.github.com/users/VelocityRa/gists{/gist_id}","starred_url":"https://api.github.com/users/VelocityRa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VelocityRa/subscriptions","organizations_url":"https://api.github.com/users/VelocityRa/orgs","repos_url":"https://api.github.com/users/VelocityRa/repos","events_url":"https://api.github.com/users/VelocityRa/events{/privacy}","received_events_url":"https://api.github.com/users/VelocityRa/received_events","type":"User","site_admin":false},"body":"Pushed a fix.\r\nTurns out constexpr float array initialization is impossible without really hacky stuff, so I just used `std::fill`.","created_at":"2018-03-22T21:11:42Z","updated_at":"2018-03-22T21:11:42Z","html_url":"https://github.com/Vita3K/Vita3K/pull/105#discussion_r176573657","pull_request_url":"https://api.github.com/repos/Vita3K/Vita3K/pulls/105","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Vita3K/Vita3K/pulls/comments/176573657"},"html":{"href":"https://github.com/Vita3K/Vita3K/pull/105#discussion_r176573657"},"pull_request":{"href":"https://api.github.com/repos/Vita3K/Vita3K/pulls/105"}},"in_reply_to_id":176488783},"pull_request":{"url":"https://api.github.com/repos/Vita3K/Vita3K/pulls/105","id":176819126,"html_url":"https://github.com/Vita3K/Vita3K/pull/105","diff_url":"https://github.com/Vita3K/Vita3K/pull/105.diff","patch_url":"https://github.com/Vita3K/Vita3K/pull/105.patch","issue_url":"https://api.github.com/repos/Vita3K/Vita3K/issues/105","number":105,"state":"open","locked":false,"title":"Support all 16 paletted texture formats (fixes VitaDoom)","user":{"login":"VelocityRa","id":6632271,"avatar_url":"https://avatars2.githubusercontent.com/u/6632271?v=4","gravatar_id":"","url":"https://api.github.com/users/VelocityRa","html_url":"https://github.com/VelocityRa","followers_url":"https://api.github.com/users/VelocityRa/followers","following_url":"https://api.github.com/users/VelocityRa/following{/other_user}","gists_url":"https://api.github.com/users/VelocityRa/gists{/gist_id}","starred_url":"https://api.github.com/users/VelocityRa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VelocityRa/subscriptions","organizations_url":"https://api.github.com/users/VelocityRa/orgs","repos_url":"https://api.github.com/users/VelocityRa/repos","events_url":"https://api.github.com/users/VelocityRa/events{/privacy}","received_events_url":"https://api.github.com/users/VelocityRa/received_events","type":"User","site_admin":false},"body":"Fixes VitaDoom (**doom.wad**, **doom2.wad**, and some other fan .wads work).\r\nRuns at 35 fps for me, pretty playable. Only other issue at the moment is garbled audio.\r\n\r\nFrom commit message:\r\n\r\n- Extend current support of `SCE_GXM_TEXTURE_FORMAT_P8_ABGR` to the 15 more palleted formats.\r\n\r\n- Only tested ones are `SCE_GXM_TEXTURE_FORMAT_P8_ABGR` and `SCE_GXM_TEXTURE_FORMAT_P8_1BGR`.\r\n\r\n- A warning message is generated if one of the untested ones is used, just to be sure.\r\n  Can be removed in the future when more of them are tested.\r\n\r\n\r\n---\r\n#### To reviewers:\r\nI included a refactoring commit (VS does this automatically on Save for me and it was too anoying trying to separate the lines I wanted) so go [here](https://github.com/Vita3K/Vita3K/pull/105/commits/d754d9ce1a25327ab613640e0e8cd61a8d706608) to review main commit only, for convenience.","created_at":"2018-03-22T15:36:27Z","updated_at":"2018-03-22T21:11:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c50a64dfd0370ff8d5df1def8814a18d37870d2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":817873586,"url":"https://api.github.com/repos/Vita3K/Vita3K/labels/enhancement","name":"enhancement","color":"a2eeef","default":true},{"id":869530951,"url":"https://api.github.com/repos/Vita3K/Vita3K/labels/gxm","name":"gxm","color":"ea5419","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Vita3K/Vita3K/pulls/105/commits","review_comments_url":"https://api.github.com/repos/Vita3K/Vita3K/pulls/105/comments","review_comment_url":"https://api.github.com/repos/Vita3K/Vita3K/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Vita3K/Vita3K/issues/105/comments","statuses_url":"https://api.github.com/repos/Vita3K/Vita3K/statuses/45f52b4588be5793cd757677ef955a60d0f966f1","head":{"label":"VelocityRa:gxm-palette","ref":"gxm-palette","sha":"45f52b4588be5793cd757677ef955a60d0f966f1","user":{"login":"VelocityRa","id":6632271,"avatar_url":"https://avatars2.githubusercontent.com/u/6632271?v=4","gravatar_id":"","url":"https://api.github.com/users/VelocityRa","html_url":"https://github.com/VelocityRa","followers_url":"https://api.github.com/users/VelocityRa/followers","following_url":"https://api.github.com/users/VelocityRa/following{/other_user}","gists_url":"https://api.github.com/users/VelocityRa/gists{/gist_id}","starred_url":"https://api.github.com/users/VelocityRa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VelocityRa/subscriptions","organizations_url":"https://api.github.com/users/VelocityRa/orgs","repos_url":"https://api.github.com/users/VelocityRa/repos","events_url":"https://api.github.com/users/VelocityRa/events{/privacy}","received_events_url":"https://api.github.com/users/VelocityRa/received_events","type":"User","site_admin":false},"repo":{"id":120024298,"name":"Vita3K","full_name":"VelocityRa/Vita3K","owner":{"login":"VelocityRa","id":6632271,"avatar_url":"https://avatars2.githubusercontent.com/u/6632271?v=4","gravatar_id":"","url":"https://api.github.com/users/VelocityRa","html_url":"https://github.com/VelocityRa","followers_url":"https://api.github.com/users/VelocityRa/followers","following_url":"https://api.github.com/users/VelocityRa/following{/other_user}","gists_url":"https://api.github.com/users/VelocityRa/gists{/gist_id}","starred_url":"https://api.github.com/users/VelocityRa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VelocityRa/subscriptions","organizations_url":"https://api.github.com/users/VelocityRa/orgs","repos_url":"https://api.github.com/users/VelocityRa/repos","events_url":"https://api.github.com/users/VelocityRa/events{/privacy}","received_events_url":"https://api.github.com/users/VelocityRa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/VelocityRa/Vita3K","description":"Experimental PlayStation Vita emulator","fork":true,"url":"https://api.github.com/repos/VelocityRa/Vita3K","forks_url":"https://api.github.com/repos/VelocityRa/Vita3K/forks","keys_url":"https://api.github.com/repos/VelocityRa/Vita3K/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VelocityRa/Vita3K/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VelocityRa/Vita3K/teams","hooks_url":"https://api.github.com/repos/VelocityRa/Vita3K/hooks","issue_events_url":"https://api.github.com/repos/VelocityRa/Vita3K/issues/events{/number}","events_url":"https://api.github.com/repos/VelocityRa/Vita3K/events","assignees_url":"https://api.github.com/repos/VelocityRa/Vita3K/assignees{/user}","branches_url":"https://api.github.com/repos/VelocityRa/Vita3K/branches{/branch}","tags_url":"https://api.github.com/repos/VelocityRa/Vita3K/tags","blobs_url":"https://api.github.com/repos/VelocityRa/Vita3K/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VelocityRa/Vita3K/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VelocityRa/Vita3K/git/refs{/sha}","trees_url":"https://api.github.com/repos/VelocityRa/Vita3K/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VelocityRa/Vita3K/statuses/{sha}","languages_url":"https://api.github.com/repos/VelocityRa/Vita3K/languages","stargazers_url":"https://api.github.com/repos/VelocityRa/Vita3K/stargazers","contributors_url":"https://api.github.com/repos/VelocityRa/Vita3K/contributors","subscribers_url":"https://api.github.com/repos/VelocityRa/Vita3K/subscribers","subscription_url":"https://api.github.com/repos/VelocityRa/Vita3K/subscription","commits_url":"https://api.github.com/repos/VelocityRa/Vita3K/commits{/sha}","git_commits_url":"https://api.github.com/repos/VelocityRa/Vita3K/git/commits{/sha}","comments_url":"https://api.github.com/repos/VelocityRa/Vita3K/comments{/number}","issue_comment_url":"https://api.github.com/repos/VelocityRa/Vita3K/issues/comments{/number}","contents_url":"https://api.github.com/repos/VelocityRa/Vita3K/contents/{+path}","compare_url":"https://api.github.com/repos/VelocityRa/Vita3K/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VelocityRa/Vita3K/merges","archive_url":"https://api.github.com/repos/VelocityRa/Vita3K/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VelocityRa/Vita3K/downloads","issues_url":"https://api.github.com/repos/VelocityRa/Vita3K/issues{/number}","pulls_url":"https://api.github.com/repos/VelocityRa/Vita3K/pulls{/number}","milestones_url":"https://api.github.com/repos/VelocityRa/Vita3K/milestones{/number}","notifications_url":"https://api.github.com/repos/VelocityRa/Vita3K/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VelocityRa/Vita3K/labels{/name}","releases_url":"https://api.github.com/repos/VelocityRa/Vita3K/releases{/id}","deployments_url":"https://api.github.com/repos/VelocityRa/Vita3K/deployments","created_at":"2018-02-02T19:48:59Z","updated_at":"2018-03-16T01:10:00Z","pushed_at":"2018-03-22T21:11:37Z","git_url":"git://github.com/VelocityRa/Vita3K.git","ssh_url":"git@github.com:VelocityRa/Vita3K.git","clone_url":"https://github.com/VelocityRa/Vita3K.git","svn_url":"https://github.com/VelocityRa/Vita3K","homepage":"https://Vita3K.github.io/","size":25306,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"Vita3K:master","ref":"master","sha":"497d45352a1dfd37630140acc67a298d248b80ac","user":{"login":"Vita3K","id":34121543,"avatar_url":"https://avatars1.githubusercontent.com/u/34121543?v=4","gravatar_id":"","url":"https://api.github.com/users/Vita3K","html_url":"https://github.com/Vita3K","followers_url":"https://api.github.com/users/Vita3K/followers","following_url":"https://api.github.com/users/Vita3K/following{/other_user}","gists_url":"https://api.github.com/users/Vita3K/gists{/gist_id}","starred_url":"https://api.github.com/users/Vita3K/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vita3K/subscriptions","organizations_url":"https://api.github.com/users/Vita3K/orgs","repos_url":"https://api.github.com/users/Vita3K/repos","events_url":"https://api.github.com/users/Vita3K/events{/privacy}","received_events_url":"https://api.github.com/users/Vita3K/received_events","type":"Organization","site_admin":false},"repo":{"id":119111364,"name":"Vita3K","full_name":"Vita3K/Vita3K","owner":{"login":"Vita3K","id":34121543,"avatar_url":"https://avatars1.githubusercontent.com/u/34121543?v=4","gravatar_id":"","url":"https://api.github.com/users/Vita3K","html_url":"https://github.com/Vita3K","followers_url":"https://api.github.com/users/Vita3K/followers","following_url":"https://api.github.com/users/Vita3K/following{/other_user}","gists_url":"https://api.github.com/users/Vita3K/gists{/gist_id}","starred_url":"https://api.github.com/users/Vita3K/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vita3K/subscriptions","organizations_url":"https://api.github.com/users/Vita3K/orgs","repos_url":"https://api.github.com/users/Vita3K/repos","events_url":"https://api.github.com/users/Vita3K/events{/privacy}","received_events_url":"https://api.github.com/users/Vita3K/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Vita3K/Vita3K","description":"Experimental PlayStation Vita emulator","fork":false,"url":"https://api.github.com/repos/Vita3K/Vita3K","forks_url":"https://api.github.com/repos/Vita3K/Vita3K/forks","keys_url":"https://api.github.com/repos/Vita3K/Vita3K/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vita3K/Vita3K/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vita3K/Vita3K/teams","hooks_url":"https://api.github.com/repos/Vita3K/Vita3K/hooks","issue_events_url":"https://api.github.com/repos/Vita3K/Vita3K/issues/events{/number}","events_url":"https://api.github.com/repos/Vita3K/Vita3K/events","assignees_url":"https://api.github.com/repos/Vita3K/Vita3K/assignees{/user}","branches_url":"https://api.github.com/repos/Vita3K/Vita3K/branches{/branch}","tags_url":"https://api.github.com/repos/Vita3K/Vita3K/tags","blobs_url":"https://api.github.com/repos/Vita3K/Vita3K/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vita3K/Vita3K/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vita3K/Vita3K/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vita3K/Vita3K/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vita3K/Vita3K/statuses/{sha}","languages_url":"https://api.github.com/repos/Vita3K/Vita3K/languages","stargazers_url":"https://api.github.com/repos/Vita3K/Vita3K/stargazers","contributors_url":"https://api.github.com/repos/Vita3K/Vita3K/contributors","subscribers_url":"https://api.github.com/repos/Vita3K/Vita3K/subscribers","subscription_url":"https://api.github.com/repos/Vita3K/Vita3K/subscription","commits_url":"https://api.github.com/repos/Vita3K/Vita3K/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vita3K/Vita3K/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vita3K/Vita3K/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vita3K/Vita3K/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vita3K/Vita3K/contents/{+path}","compare_url":"https://api.github.com/repos/Vita3K/Vita3K/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vita3K/Vita3K/merges","archive_url":"https://api.github.com/repos/Vita3K/Vita3K/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vita3K/Vita3K/downloads","issues_url":"https://api.github.com/repos/Vita3K/Vita3K/issues{/number}","pulls_url":"https://api.github.com/repos/Vita3K/Vita3K/pulls{/number}","milestones_url":"https://api.github.com/repos/Vita3K/Vita3K/milestones{/number}","notifications_url":"https://api.github.com/repos/Vita3K/Vita3K/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vita3K/Vita3K/labels{/name}","releases_url":"https://api.github.com/repos/Vita3K/Vita3K/releases{/id}","deployments_url":"https://api.github.com/repos/Vita3K/Vita3K/deployments","created_at":"2018-01-26T22:45:05Z","updated_at":"2018-03-22T10:45:49Z","pushed_at":"2018-03-22T21:11:40Z","git_url":"git://github.com/Vita3K/Vita3K.git","ssh_url":"git@github.com:Vita3K/Vita3K.git","clone_url":"https://github.com/Vita3K/Vita3K.git","svn_url":"https://github.com/Vita3K/Vita3K","homepage":"https://Vita3K.github.io/","size":25258,"stargazers_count":386,"watchers_count":386,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"archived":false,"open_issues_count":21,"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"},"forks":40,"open_issues":21,"watchers":386,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Vita3K/Vita3K/pulls/105"},"html":{"href":"https://github.com/Vita3K/Vita3K/pull/105"},"issue":{"href":"https://api.github.com/repos/Vita3K/Vita3K/issues/105"},"comments":{"href":"https://api.github.com/repos/Vita3K/Vita3K/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/Vita3K/Vita3K/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/Vita3K/Vita3K/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Vita3K/Vita3K/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/Vita3K/Vita3K/statuses/45f52b4588be5793cd757677ef955a60d0f966f1"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"VelocityRa"}}