Ejemplo n.º 1
0
/// Swap buffers (render frame)
void RendererOpenGL::SwapBuffers() {
    render_window->MakeCurrent();

    for(int i : {0, 1}) {
        const auto& framebuffer = GPU::g_regs.framebuffer_config[i];

        if (textures[i].width != (GLsizei)framebuffer.width || textures[i].height != (GLsizei)framebuffer.height) {
            // Reallocate texture if the framebuffer size has changed.
            // This is expected to not happen very often and hence should not be a
            // performance problem.
            glBindTexture(GL_TEXTURE_2D, textures[i].handle);
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, framebuffer.width, framebuffer.height, 0,
                GL_BGR, GL_UNSIGNED_BYTE, nullptr);
            textures[i].width = framebuffer.width;
            textures[i].height = framebuffer.height;
        }

        LoadFBToActiveGLTexture(GPU::g_regs.framebuffer_config[i], textures[i]);
    }

    DrawScreens();

    // Swap buffers
    render_window->PollEvents();
    render_window->SwapBuffers();
}
Ejemplo n.º 2
0
/// Swap buffers (render frame)
void RendererOpenGL::SwapBuffers() {
    render_window->MakeCurrent();

    for(int i : {0, 1}) {
        const auto& framebuffer = GPU::g_regs.framebuffer_config[i];

        // Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04
        u32 lcd_color_addr = (i == 0) ? LCD_REG_INDEX(color_fill_top) : LCD_REG_INDEX(color_fill_bottom);
        lcd_color_addr = HW::VADDR_LCD + 4 * lcd_color_addr;
        LCD::Regs::ColorFill color_fill = {0};
        LCD::Read(color_fill.raw, lcd_color_addr);

        if (color_fill.is_enabled) {
            LoadColorToActiveGLTexture(color_fill.color_r, color_fill.color_g, color_fill.color_b, textures[i]);

            // Resize the texture in case the framebuffer size has changed
            textures[i].width = 1;
            textures[i].height = 1;
        } else {
            if (textures[i].width != (GLsizei)framebuffer.width ||
                textures[i].height != (GLsizei)framebuffer.height ||
                textures[i].format != framebuffer.color_format) {
                // Reallocate texture if the framebuffer size has changed.
                // This is expected to not happen very often and hence should not be a
                // performance problem.
                ConfigureFramebufferTexture(textures[i], framebuffer);
            }
            LoadFBToActiveGLTexture(framebuffer, textures[i]);

            // Resize the texture in case the framebuffer size has changed
            textures[i].width = framebuffer.width;
            textures[i].height = framebuffer.height;
        }
    }

    DrawScreens();

    auto& profiler = Common::Profiling::GetProfilingManager();
    profiler.FinishFrame();
    {
        auto aggregator = Common::Profiling::GetTimingResultsAggregator();
        aggregator->AddFrame(profiler.GetPreviousFrameResults());
    }

    // Swap buffers
    render_window->PollEvents();
    render_window->SwapBuffers();

    profiler.BeginFrame();
}
Ejemplo n.º 3
0
/// Swap buffers (render frame)
void RendererOpenGL::SwapBuffers() {
    // Maintain the rasterizer's state as a priority
    OpenGLState prev_state = OpenGLState::GetCurState();
    state.Apply();

    for(int i : {0, 1}) {
        const auto& framebuffer = GPU::g_regs.framebuffer_config[i];

        // Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04
        u32 lcd_color_addr = (i == 0) ? LCD_REG_INDEX(color_fill_top) : LCD_REG_INDEX(color_fill_bottom);
        lcd_color_addr = HW::VADDR_LCD + 4 * lcd_color_addr;
        LCD::Regs::ColorFill color_fill = {0};
        LCD::Read(color_fill.raw, lcd_color_addr);

        if (color_fill.is_enabled) {
            LoadColorToActiveGLTexture(color_fill.color_r, color_fill.color_g, color_fill.color_b, textures[i]);

            // Resize the texture in case the framebuffer size has changed
            textures[i].width = 1;
            textures[i].height = 1;
        } else {
            if (textures[i].width != (GLsizei)framebuffer.width ||
                textures[i].height != (GLsizei)framebuffer.height ||
                textures[i].format != framebuffer.color_format) {
                // Reallocate texture if the framebuffer size has changed.
                // This is expected to not happen very often and hence should not be a
                // performance problem.
                ConfigureFramebufferTexture(textures[i], framebuffer);
            }
            LoadFBToActiveGLTexture(framebuffer, textures[i]);

            // Resize the texture in case the framebuffer size has changed
            textures[i].width = framebuffer.width;
            textures[i].height = framebuffer.height;
        }
    }

    DrawScreens();

    auto& profiler = Common::Profiling::GetProfilingManager();
    profiler.FinishFrame();
    {
        auto aggregator = Common::Profiling::GetTimingResultsAggregator();
        aggregator->AddFrame(profiler.GetPreviousFrameResults());
    }

    // Swap buffers
    render_window->PollEvents();
    render_window->SwapBuffers();

    prev_state.Apply();

    profiler.BeginFrame();

    bool hw_renderer_enabled = VideoCore::g_hw_renderer_enabled;
    if (Settings::values.use_hw_renderer != hw_renderer_enabled) {
        // TODO: Save new setting value to config file for next startup
        Settings::values.use_hw_renderer = hw_renderer_enabled;

        if (Settings::values.use_hw_renderer) {
            hw_rasterizer->Reset();
        }
    }

    if (Pica::g_debug_context && Pica::g_debug_context->recorder) {
        Pica::g_debug_context->recorder->FrameFinished();
    }
}