{"action":"created","comment":{"url":"https://api.github.com/repos/citra-emu/citra/pulls/comments/30459249","id":30459249,"diff_hunk":"@@ -0,0 +1,73 @@\n+// Copyright 2015 Citra Emulator Project\n+// Licensed under GPLv2 or any later version\n+// Refer to the license.txt file included.\n+\n+#include \"core/memory.h\"\n+#include \"video_core/renderer_opengl/gl_pica_to_gl.h\"\n+#include \"video_core/renderer_opengl/gl_rasterizer_cache.h\"\n+#include \"video_core/debug_utils/debug_utils.h\"\n+#include \"video_core/math.h\"\n+\n+RasterizerCacheOpenGL::~RasterizerCacheOpenGL() {\n+    FullFlush();\n+}\n+\n+void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, int texture_unit, const Pica::Regs::FullTextureConfig& config) {\n+    PAddr texture_addr = config.config.GetPhysicalAddress();\n+\n+    const auto cached_texture = texture_cache.find(texture_addr);\n+\n+    if (cached_texture != texture_cache.end()) {\n+        state.texture_units[texture_unit].texture_2d = cached_texture->second->texture.GetHandle();\n+        state.Apply();\n+    } else {\n+        std::unique_ptr<CachedTexture> new_texture(new CachedTexture());\n+\n+        new_texture->texture.Create();\n+        state.texture_units[texture_unit].texture_2d = new_texture->texture.GetHandle();\n+        state.Apply();\n+\n+        // TODO: Need to choose filters that correspond to PICA once register is declared\n+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n+\n+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, PicaToGL::WrapMode(config.config.wrap_s.Value()));\n+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, PicaToGL::WrapMode(config.config.wrap_t.Value()));\n+\n+        const auto info = Pica::DebugUtils::TextureInfo::FromPicaRegister(config.config, config.format);\n+\n+        new_texture->width = info.width;\n+        new_texture->height = info.height;\n+        new_texture->size = info.width * info.height * Pica::Regs::NibblesPerPixel(info.format);\n+\n+        std::unique_ptr<Math::Vec4<u8>[]> temp_texture_buffer_rgba(new Math::Vec4<u8>[info.width * info.height]);\n+\n+        for (int y = 0; y < info.height; ++y) {\n+            for (int x = 0; x < info.width; ++x) {\n+                temp_texture_buffer_rgba[x + info.width * y] = Pica::DebugUtils::LookupTexture(Memory::GetPhysicalPointer(texture_addr), x, info.height - 1 - y, info);\n+            }\n+        }\n+\n+        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, info.width, info.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp_texture_buffer_rgba.get());\n+\n+        texture_cache.emplace(texture_addr, std::move(new_texture));\n+    }\n+}\n+\n+void RasterizerCacheOpenGL::NotifyFlush(PAddr addr, u32 size) {\n+    // Flush any texture that falls in the flushed region\n+    for (auto it = texture_cache.begin(); it != texture_cache.end();) {","path":"src/video_core/renderer_opengl/gl_rasterizer_cache.cpp","position":59,"original_position":59,"commit_id":"47d0ca8f3253d218dc66d9aaadcd99fa04bfdcc1","original_commit_id":"47d0ca8f3253d218dc66d9aaadcd99fa04bfdcc1","user":{"login":"yuriks","id":341401,"avatar_url":"https://avatars.githubusercontent.com/u/341401?v=3","gravatar_id":"","url":"https://api.github.com/users/yuriks","html_url":"https://github.com/yuriks","followers_url":"https://api.github.com/users/yuriks/followers","following_url":"https://api.github.com/users/yuriks/following{/other_user}","gists_url":"https://api.github.com/users/yuriks/gists{/gist_id}","starred_url":"https://api.github.com/users/yuriks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuriks/subscriptions","organizations_url":"https://api.github.com/users/yuriks/orgs","repos_url":"https://api.github.com/users/yuriks/repos","events_url":"https://api.github.com/users/yuriks/events{/privacy}","received_events_url":"https://api.github.com/users/yuriks/received_events","type":"User","site_admin":false},"body":"Instead of iterating through the whole map, you can instead use `std::map::lower_bound` and `std::map::upper_bound` to get both bounds in log time.","created_at":"2015-05-16T07:26:20Z","updated_at":"2015-05-16T07:26:20Z","html_url":"https://github.com/citra-emu/citra/pull/753#discussion_r30459249","pull_request_url":"https://api.github.com/repos/citra-emu/citra/pulls/753","_links":{"self":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/comments/30459249"},"html":{"href":"https://github.com/citra-emu/citra/pull/753#discussion_r30459249"},"pull_request":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/753"}}},"pull_request":{"url":"https://api.github.com/repos/citra-emu/citra/pulls/753","id":35172304,"html_url":"https://github.com/citra-emu/citra/pull/753","diff_url":"https://github.com/citra-emu/citra/pull/753.diff","patch_url":"https://github.com/citra-emu/citra/pull/753.patch","issue_url":"https://api.github.com/repos/citra-emu/citra/issues/753","number":753,"state":"open","locked":false,"title":"[RFC] OpenGL Hardware Renderer","user":{"login":"tfarley","id":5193758,"avatar_url":"https://avatars.githubusercontent.com/u/5193758?v=3","gravatar_id":"","url":"https://api.github.com/users/tfarley","html_url":"https://github.com/tfarley","followers_url":"https://api.github.com/users/tfarley/followers","following_url":"https://api.github.com/users/tfarley/following{/other_user}","gists_url":"https://api.github.com/users/tfarley/gists{/gist_id}","starred_url":"https://api.github.com/users/tfarley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfarley/subscriptions","organizations_url":"https://api.github.com/users/tfarley/orgs","repos_url":"https://api.github.com/users/tfarley/repos","events_url":"https://api.github.com/users/tfarley/events{/privacy}","received_events_url":"https://api.github.com/users/tfarley/received_events","type":"User","site_admin":false},"body":"This implements an OpenGL renderer that currently only performs the drawing and rasterizing stages using output vertices from the existing vertex shader interpreter.\r\n\r\nThe components of this with primary source files are:\r\n* OpenGL rasterizer (gl_rasterizer, command_processor)\r\n  * Receives geometry and draws it, manages OpenGL state, syncs with 3ds framebuffers\r\n* Rasterizer fragment shader (gl_shaders)\r\n  * Emulates texture environment stages, alpha testing, etc. with dummy vertex shader\r\n* Rasterizer cache (gl_rasterizer_cache)\r\n  * Loads and holds 3ds textures in OGL VRAM, receives flushes\r\n* Caching/flush management (gsp_gpu + gpu)\r\n  * Notifies rasterizer and cache when 3ds memory changes so they may flush caches\r\n* OpenGL state management (gl_state)\r\n  * Encasulates OpenGL state values, applies when requested with minimal state changes\r\n* OpenGL resource management (gl_resource_manager)\r\n  * Auto-deletion of resources when out of scope, copy prevention\r\n* INI setting for sw/hw rasterizer toggle\r\n\r\nI'd like comments on any/all of these!\r\nIn particular, how reasonable the state and resource management parts are.","created_at":"2015-05-11T21:37:04Z","updated_at":"2015-05-16T07:26:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd366a637c67903e18f0c272ac7f572bf07315ff","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/citra-emu/citra/pulls/753/commits","review_comments_url":"https://api.github.com/repos/citra-emu/citra/pulls/753/comments","review_comment_url":"https://api.github.com/repos/citra-emu/citra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/citra-emu/citra/issues/753/comments","statuses_url":"https://api.github.com/repos/citra-emu/citra/statuses/47d0ca8f3253d218dc66d9aaadcd99fa04bfdcc1","head":{"label":"tfarley:ogl-renderer2-rfc","ref":"ogl-renderer2-rfc","sha":"47d0ca8f3253d218dc66d9aaadcd99fa04bfdcc1","user":{"login":"tfarley","id":5193758,"avatar_url":"https://avatars.githubusercontent.com/u/5193758?v=3","gravatar_id":"","url":"https://api.github.com/users/tfarley","html_url":"https://github.com/tfarley","followers_url":"https://api.github.com/users/tfarley/followers","following_url":"https://api.github.com/users/tfarley/following{/other_user}","gists_url":"https://api.github.com/users/tfarley/gists{/gist_id}","starred_url":"https://api.github.com/users/tfarley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfarley/subscriptions","organizations_url":"https://api.github.com/users/tfarley/orgs","repos_url":"https://api.github.com/users/tfarley/repos","events_url":"https://api.github.com/users/tfarley/events{/privacy}","received_events_url":"https://api.github.com/users/tfarley/received_events","type":"User","site_admin":false},"repo":{"id":31484883,"name":"citra","full_name":"tfarley/citra","owner":{"login":"tfarley","id":5193758,"avatar_url":"https://avatars.githubusercontent.com/u/5193758?v=3","gravatar_id":"","url":"https://api.github.com/users/tfarley","html_url":"https://github.com/tfarley","followers_url":"https://api.github.com/users/tfarley/followers","following_url":"https://api.github.com/users/tfarley/following{/other_user}","gists_url":"https://api.github.com/users/tfarley/gists{/gist_id}","starred_url":"https://api.github.com/users/tfarley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfarley/subscriptions","organizations_url":"https://api.github.com/users/tfarley/orgs","repos_url":"https://api.github.com/users/tfarley/repos","events_url":"https://api.github.com/users/tfarley/events{/privacy}","received_events_url":"https://api.github.com/users/tfarley/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tfarley/citra","description":"Nintendo 3DS emulator/debugger","fork":true,"url":"https://api.github.com/repos/tfarley/citra","forks_url":"https://api.github.com/repos/tfarley/citra/forks","keys_url":"https://api.github.com/repos/tfarley/citra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tfarley/citra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tfarley/citra/teams","hooks_url":"https://api.github.com/repos/tfarley/citra/hooks","issue_events_url":"https://api.github.com/repos/tfarley/citra/issues/events{/number}","events_url":"https://api.github.com/repos/tfarley/citra/events","assignees_url":"https://api.github.com/repos/tfarley/citra/assignees{/user}","branches_url":"https://api.github.com/repos/tfarley/citra/branches{/branch}","tags_url":"https://api.github.com/repos/tfarley/citra/tags","blobs_url":"https://api.github.com/repos/tfarley/citra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tfarley/citra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tfarley/citra/git/refs{/sha}","trees_url":"https://api.github.com/repos/tfarley/citra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tfarley/citra/statuses/{sha}","languages_url":"https://api.github.com/repos/tfarley/citra/languages","stargazers_url":"https://api.github.com/repos/tfarley/citra/stargazers","contributors_url":"https://api.github.com/repos/tfarley/citra/contributors","subscribers_url":"https://api.github.com/repos/tfarley/citra/subscribers","subscription_url":"https://api.github.com/repos/tfarley/citra/subscription","commits_url":"https://api.github.com/repos/tfarley/citra/commits{/sha}","git_commits_url":"https://api.github.com/repos/tfarley/citra/git/commits{/sha}","comments_url":"https://api.github.com/repos/tfarley/citra/comments{/number}","issue_comment_url":"https://api.github.com/repos/tfarley/citra/issues/comments{/number}","contents_url":"https://api.github.com/repos/tfarley/citra/contents/{+path}","compare_url":"https://api.github.com/repos/tfarley/citra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tfarley/citra/merges","archive_url":"https://api.github.com/repos/tfarley/citra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tfarley/citra/downloads","issues_url":"https://api.github.com/repos/tfarley/citra/issues{/number}","pulls_url":"https://api.github.com/repos/tfarley/citra/pulls{/number}","milestones_url":"https://api.github.com/repos/tfarley/citra/milestones{/number}","notifications_url":"https://api.github.com/repos/tfarley/citra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tfarley/citra/labels{/name}","releases_url":"https://api.github.com/repos/tfarley/citra/releases{/id}","created_at":"2015-03-01T02:54:02Z","updated_at":"2015-04-15T01:12:08Z","pushed_at":"2015-05-16T05:42:47Z","git_url":"git://github.com/tfarley/citra.git","ssh_url":"git@github.com:tfarley/citra.git","clone_url":"https://github.com/tfarley/citra.git","svn_url":"https://github.com/tfarley/citra","homepage":null,"size":10607,"stargazers_count":17,"watchers_count":17,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":17,"default_branch":"master"}},"base":{"label":"citra-emu:master","ref":"master","sha":"ba2fe7f795ebc8da4acd247436afeefb900645d3","user":{"login":"citra-emu","id":7605670,"avatar_url":"https://avatars.githubusercontent.com/u/7605670?v=3","gravatar_id":"","url":"https://api.github.com/users/citra-emu","html_url":"https://github.com/citra-emu","followers_url":"https://api.github.com/users/citra-emu/followers","following_url":"https://api.github.com/users/citra-emu/following{/other_user}","gists_url":"https://api.github.com/users/citra-emu/gists{/gist_id}","starred_url":"https://api.github.com/users/citra-emu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citra-emu/subscriptions","organizations_url":"https://api.github.com/users/citra-emu/orgs","repos_url":"https://api.github.com/users/citra-emu/repos","events_url":"https://api.github.com/users/citra-emu/events{/privacy}","received_events_url":"https://api.github.com/users/citra-emu/received_events","type":"Organization","site_admin":false},"repo":{"id":19866730,"name":"citra","full_name":"citra-emu/citra","owner":{"login":"citra-emu","id":7605670,"avatar_url":"https://avatars.githubusercontent.com/u/7605670?v=3","gravatar_id":"","url":"https://api.github.com/users/citra-emu","html_url":"https://github.com/citra-emu","followers_url":"https://api.github.com/users/citra-emu/followers","following_url":"https://api.github.com/users/citra-emu/following{/other_user}","gists_url":"https://api.github.com/users/citra-emu/gists{/gist_id}","starred_url":"https://api.github.com/users/citra-emu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citra-emu/subscriptions","organizations_url":"https://api.github.com/users/citra-emu/orgs","repos_url":"https://api.github.com/users/citra-emu/repos","events_url":"https://api.github.com/users/citra-emu/events{/privacy}","received_events_url":"https://api.github.com/users/citra-emu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/citra-emu/citra","description":"Nintendo 3DS emulator/debugger","fork":false,"url":"https://api.github.com/repos/citra-emu/citra","forks_url":"https://api.github.com/repos/citra-emu/citra/forks","keys_url":"https://api.github.com/repos/citra-emu/citra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/citra-emu/citra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/citra-emu/citra/teams","hooks_url":"https://api.github.com/repos/citra-emu/citra/hooks","issue_events_url":"https://api.github.com/repos/citra-emu/citra/issues/events{/number}","events_url":"https://api.github.com/repos/citra-emu/citra/events","assignees_url":"https://api.github.com/repos/citra-emu/citra/assignees{/user}","branches_url":"https://api.github.com/repos/citra-emu/citra/branches{/branch}","tags_url":"https://api.github.com/repos/citra-emu/citra/tags","blobs_url":"https://api.github.com/repos/citra-emu/citra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/citra-emu/citra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/citra-emu/citra/git/refs{/sha}","trees_url":"https://api.github.com/repos/citra-emu/citra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/citra-emu/citra/statuses/{sha}","languages_url":"https://api.github.com/repos/citra-emu/citra/languages","stargazers_url":"https://api.github.com/repos/citra-emu/citra/stargazers","contributors_url":"https://api.github.com/repos/citra-emu/citra/contributors","subscribers_url":"https://api.github.com/repos/citra-emu/citra/subscribers","subscription_url":"https://api.github.com/repos/citra-emu/citra/subscription","commits_url":"https://api.github.com/repos/citra-emu/citra/commits{/sha}","git_commits_url":"https://api.github.com/repos/citra-emu/citra/git/commits{/sha}","comments_url":"https://api.github.com/repos/citra-emu/citra/comments{/number}","issue_comment_url":"https://api.github.com/repos/citra-emu/citra/issues/comments{/number}","contents_url":"https://api.github.com/repos/citra-emu/citra/contents/{+path}","compare_url":"https://api.github.com/repos/citra-emu/citra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/citra-emu/citra/merges","archive_url":"https://api.github.com/repos/citra-emu/citra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/citra-emu/citra/downloads","issues_url":"https://api.github.com/repos/citra-emu/citra/issues{/number}","pulls_url":"https://api.github.com/repos/citra-emu/citra/pulls{/number}","milestones_url":"https://api.github.com/repos/citra-emu/citra/milestones{/number}","notifications_url":"https://api.github.com/repos/citra-emu/citra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/citra-emu/citra/labels{/name}","releases_url":"https://api.github.com/repos/citra-emu/citra/releases{/id}","created_at":"2014-05-16T18:33:15Z","updated_at":"2015-05-15T09:30:30Z","pushed_at":"2015-05-16T06:31:23Z","git_url":"git://github.com/citra-emu/citra.git","ssh_url":"git@github.com:citra-emu/citra.git","clone_url":"https://github.com/citra-emu/citra.git","svn_url":"https://github.com/citra-emu/citra","homepage":null,"size":23467,"stargazers_count":828,"watchers_count":828,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":207,"mirror_url":null,"open_issues_count":55,"forks":207,"open_issues":55,"watchers":828,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/753"},"html":{"href":"https://github.com/citra-emu/citra/pull/753"},"issue":{"href":"https://api.github.com/repos/citra-emu/citra/issues/753"},"comments":{"href":"https://api.github.com/repos/citra-emu/citra/issues/753/comments"},"review_comments":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/753/comments"},"review_comment":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/753/commits"},"statuses":{"href":"https://api.github.com/repos/citra-emu/citra/statuses/47d0ca8f3253d218dc66d9aaadcd99fa04bfdcc1"}}}}