diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 3a7cbcf97af..b3e6e2980d6 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -37,7 +37,7 @@ #endif namespace { -std::string g_current_render; +std::string g_current_renderer; } /*! @@ -51,16 +51,16 @@ void GLAPIENTRY opengl_error_callback(GLenum source, const GLchar* message, const void* /*userParam*/) { if (severity == GL_DEBUG_SEVERITY_NOTIFICATION) { - lg::debug("[{}] OpenGL notification 0x{:X} S{:X} T{:X}: {}", g_current_render, id, source, type, - message); + lg::debug("[{}] OpenGL notification 0x{:X} S{:X} T{:X}: {}", g_current_renderer, id, source, + type, message); } else if (severity == GL_DEBUG_SEVERITY_LOW) { - lg::info("[{}] OpenGL message 0x{:X} S{:X} T{:X}: {}", g_current_render, id, source, type, + lg::info("[{}] OpenGL message 0x{:X} S{:X} T{:X}: {}", g_current_renderer, id, source, type, message); } else if (severity == GL_DEBUG_SEVERITY_MEDIUM) { - lg::warn("[{}] OpenGL warn 0x{:X} S{:X} T{:X}: {}", g_current_render, id, source, type, + lg::warn("[{}] OpenGL warn 0x{:X} S{:X} T{:X}: {}", g_current_renderer, id, source, type, message); } else if (severity == GL_DEBUG_SEVERITY_HIGH) { - lg::error("[{}] OpenGL error 0x{:X} S{:X} T{:X}: {}", g_current_render, id, source, type, + lg::error("[{}] OpenGL error 0x{:X} S{:X} T{:X}: {}", g_current_renderer, id, source, type, message); // ASSERT(false); } @@ -72,10 +72,10 @@ OpenGLRenderer::OpenGLRenderer(std::shared_ptr texture_pool, : m_render_state(texture_pool, loader, version), m_collide_renderer(version), m_version(version) { - // setup OpenGL errors - glEnable(GL_DEBUG_OUTPUT); // requires OpenGL 4.3 #ifndef __APPLE__ + // setup OpenGL errors + glEnable(GL_DEBUG_OUTPUT); glDebugMessageCallback(opengl_error_callback, nullptr); // disable specific errors const GLuint gl_error_ignores_api_other[1] = {0x20071}; @@ -661,6 +661,7 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { m_render_state.offset_of_s7 = offset_of_s7(); { + g_current_renderer = "frame-setup"; auto prof = m_profiler.root()->make_scoped_child("frame-setup"); setup_frame(settings); if (settings.gpu_sync) { @@ -669,6 +670,7 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { } { + g_current_renderer = "loader"; auto prof = m_profiler.root()->make_scoped_child("loader"); if (m_last_pmode_alp == 0 && settings.pmode_alp_register != 0 && m_enable_fast_blackout_loads) { // blackout, load everything and don't worry about frame rate @@ -692,12 +694,14 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { // blit framebuffer so that it can be used as a texture by the game later { + g_current_renderer = "blit-display"; auto prof = m_profiler.root()->make_scoped_child("blit-display"); blit_display(); } // apply effects done with PCRTC registers { + g_current_renderer = "pcrtc"; auto prof = m_profiler.root()->make_scoped_child("pcrtc"); do_pcrtc_effects(settings.pmode_alp_register, &m_render_state, prof); if (settings.gpu_sync) { @@ -708,6 +712,7 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { m_last_pmode_alp = settings.pmode_alp_register; if (settings.save_screenshot) { + g_current_renderer = "screenshot"; auto prof = m_profiler.root()->make_scoped_child("screenshot"); int read_buffer; int x, y, w, h, fbo_id; @@ -740,6 +745,7 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { } if (settings.draw_render_debug_window) { + g_current_renderer = "render-window"; auto prof = m_profiler.root()->make_scoped_child("render-window"); draw_renderer_selection_window(); // add a profile bar for the imgui stuff @@ -750,6 +756,7 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { } if (settings.draw_loader_window) { + g_current_renderer = "loader-window"; m_render_state.loader->draw_debug_window(); } @@ -760,10 +767,12 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { // } if (settings.draw_profiler_window) { + g_current_renderer = "profiler-window"; m_profiler.draw(); } if (settings.draw_small_profiler_window) { + g_current_renderer = "small-profiler-window"; SmallProfilerStats stats; stats.draw_calls = m_profiler.root()->stats().draw_calls; stats.triangles = m_profiler.root()->stats().triangles; @@ -774,6 +783,7 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { } if (settings.draw_subtitle_editor_window) { + g_current_renderer = "subtitle-editor-window"; if (m_subtitle_editor == nullptr) { m_subtitle_editor = new SubtitleEditor(); } @@ -781,11 +791,16 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { } if (settings.draw_filters_window) { + g_current_renderer = "filters-window"; m_filters_menu.draw_window(); } + if (settings.gpu_sync) { + g_current_renderer = "gpu-sync"; glFinish(); } + + g_current_renderer = "end"; } /*! @@ -972,15 +987,15 @@ void OpenGLRenderer::dispatch_buckets_jak1(DmaFollower dma, for (size_t bucket_id = 0; bucket_id < m_bucket_renderers.size(); bucket_id++) { auto& renderer = m_bucket_renderers[bucket_id]; auto bucket_prof = prof.make_scoped_child(renderer->name_and_id()); - g_current_render = renderer->name_and_id(); - // lg::info("Render: {} start", g_current_render); + g_current_renderer = renderer->name_and_id(); + // lg::info("Render: {} start", g_current_renderer); renderer->render(dma, &m_render_state, bucket_prof); if (sync_after_buckets) { auto pp = scoped_prof("finish"); glFinish(); } - // lg::info("Render: {} end", g_current_render); + // lg::info("Render: {} end", g_current_renderer); // should have ended at the start of the next chain ASSERT(dma.current_tag_offset() == m_render_state.next_bucket); m_render_state.next_bucket += 16; @@ -993,7 +1008,6 @@ void OpenGLRenderer::dispatch_buckets_jak1(DmaFollower dma, m_collide_renderer.render(&m_render_state, p); } } - g_current_render = ""; // TODO ending data. } @@ -1013,15 +1027,15 @@ void OpenGLRenderer::dispatch_buckets_jak2(DmaFollower dma, for (size_t bucket_id = 0; bucket_id < m_bucket_renderers.size(); bucket_id++) { auto& renderer = m_bucket_renderers[bucket_id]; auto bucket_prof = prof.make_scoped_child(renderer->name_and_id()); - g_current_render = renderer->name_and_id(); - // lg::info("Render: {} start", g_current_render); + g_current_renderer = renderer->name_and_id(); + // lg::info("Render: {} start", g_current_renderer); renderer->render(dma, &m_render_state, bucket_prof); if (sync_after_buckets) { auto pp = scoped_prof("finish"); glFinish(); } - // lg::info("Render: {} end", g_current_render); + // lg::info("Render: {} end", g_current_renderer); // should have ended at the start of the next chain ASSERT(dma.current_tag_offset() == m_render_state.next_bucket); m_render_state.next_bucket += 16; @@ -1046,6 +1060,8 @@ void OpenGLRenderer::dispatch_buckets_jak2(DmaFollower dma, void OpenGLRenderer::dispatch_buckets(DmaFollower dma, ScopedProfilerNode& prof, bool sync_after_buckets) { + g_current_renderer = "dispatch-buckets pre"; + m_render_state.version = m_version; m_render_state.frame_idx++; switch (m_version) { @@ -1058,6 +1074,8 @@ void OpenGLRenderer::dispatch_buckets(DmaFollower dma, default: ASSERT(false); } + + g_current_renderer = "dispatch-buckets post"; } #ifdef _WIN32 @@ -1178,7 +1196,7 @@ void OpenGLRenderer::finish_screenshot(const std::string& output_name, glReadBuffer(read_buffer); glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data()); - // set alpha. For some reason, image viewers do weird stuff with alpha. + // set alpha. our renderers mess this up in a way that isn't relevant to the final framebuffer. for (auto& px : buffer) { px |= 0xff000000; } @@ -1190,6 +1208,7 @@ void OpenGLRenderer::finish_screenshot(const std::string& output_name, } #else (void)quick_screenshot; + lg::error("screenshot to clipboard NYI non-Windows"); #endif // flip upside down in place diff --git a/game/graphics/opengl_renderer/sprite/GlowRenderer.cpp b/game/graphics/opengl_renderer/sprite/GlowRenderer.cpp index 36da432a4ae..90a9d1e8d80 100644 --- a/game/graphics/opengl_renderer/sprite/GlowRenderer.cpp +++ b/game/graphics/opengl_renderer/sprite/GlowRenderer.cpp @@ -527,7 +527,7 @@ void GlowRenderer::blit_depth(SharedRenderState* render_state) { glBindTexture(GL_TEXTURE_2D, m_ogl.probe_fbo_depth_tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, m_ogl.probe_fbo_w, m_ogl.probe_fbo_h, 0, - GL_DEPTH_COMPONENT, GL_FLOAT, NULL); + GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); glBindTexture(GL_TEXTURE_2D, 0); }