summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am/system_buffer_manager.cpp
blob: 7211ef488afd0a2b4f713d79ec8d9548315bc417 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "core/hle/service/am/system_buffer_manager.h"
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
#include "core/hle/service/nvnflinger/nvnflinger.h"

namespace Service::AM {

SystemBufferManager::SystemBufferManager() = default;

SystemBufferManager::~SystemBufferManager() {
    if (!m_nvnflinger) {
        return;
    }

    // Clean up shared layers.
    if (m_buffer_sharing_enabled) {
    }
}

bool SystemBufferManager::Initialize(Nvnflinger::Nvnflinger* nvnflinger, Kernel::KProcess* process,
                                     AppletId applet_id) {
    if (m_nvnflinger) {
        return m_buffer_sharing_enabled;
    }

    m_process = process;
    m_nvnflinger = nvnflinger;
    m_buffer_sharing_enabled = false;
    m_system_shared_buffer_id = 0;
    m_system_shared_layer_id = 0;

    if (applet_id <= AppletId::Application) {
        return false;
    }

    const auto display_id = m_nvnflinger->OpenDisplay("Default").value();
    const auto res = m_nvnflinger->GetSystemBufferManager().Initialize(
        &m_system_shared_buffer_id, &m_system_shared_layer_id, display_id);

    if (res.IsSuccess()) {
        m_buffer_sharing_enabled = true;
    }

    return m_buffer_sharing_enabled;
}

} // namespace Service::AM