aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/textures/workers.cpp
blob: 6922634e3071fce8ffb54a6fc6dc748089c8ac80 (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
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include <cstdlib>

#include "video_core/textures/workers.h"

namespace Tegra::Texture {

Common::ThreadWorker& GetThreadWorkers() {
    // An eighth of the hardware threads (at least 2): with half, re-compressing streamed ASTC
    // textures took ~3.5 cores from the emulated CPU cores and the GPU thread on an 8-core
    // laptop. EDEN_NX2_TRANSCODE_THREADS=<n> overrides.
    static Common::ThreadWorker workers{[] {
        if (const char* text = std::getenv("EDEN_NX2_TRANSCODE_THREADS")) {
            return (std::max)(static_cast<u32>(std::strtoul(text, nullptr, 10)), 1U);
        }
        return (std::max)(std::thread::hardware_concurrency() / 8, 2U);
    }(), "ImageTranscode"};
    return workers;
}

} // namespace Tegra::Texture