aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/post_processing/fx_chain.h
blob: 066f7e428d4469832cfb7173fa832846abc2023a (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <array>
#include <atomic>
#include <map>
#include <mutex>
#include <span>
#include <string>
#include <string_view>
#include <vector>

#include "common/common_types.h"

namespace VideoCore {

struct FxChainEntry {
    std::string file;
    std::string technique;
    std::map<std::string, std::array<f32, 4>> values;

    bool operator==(const FxChainEntry&) const = default;
};

struct FxChainSnapshot {
    std::vector<FxChainEntry> entries;
    u64 generation{};
};

std::vector<FxChainEntry> ParseFxChain(std::string_view value);

std::string SerializeFxChain(std::span<const FxChainEntry> entries);

void UseGlobalFxSettings();

void UsePerGameFxSettings();

class FxChain {
public:
    static FxChain& Instance();

    FxChainSnapshot Snapshot() const;

    std::vector<FxChainEntry> Entries() const;

    size_t Size() const;

    void Append(std::string_view file, std::string_view technique);

    void Replace(size_t index, std::string_view file, std::string_view technique);

    void Remove(size_t index);

    void Move(size_t index, int delta);

    void Clear();

    void SetEntries(std::vector<FxChainEntry> next);

    void SetValue(size_t index, std::string_view uniform, const std::array<f32, 4>& value);

    std::array<f32, 4> GetValue(size_t index, std::string_view uniform) const;

    std::map<std::string, std::array<f32, 4>> EntryValues(size_t index) const;

    bool HasValue(size_t index, std::string_view uniform) const;

    void ResetValues(size_t index);

    void LoadFromSettings();

    void StoreToSettings() const;

    void DropUnknownEntries();

private:
    FxChain() = default;

    mutable std::mutex mutex;
    std::vector<FxChainEntry> entries;
    std::atomic<u64> generation{1};
};

} // namespace VideoCore