summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_manager.h
blob: 852d8c88e810e8037a48fdd75c64838df58281eb (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
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <array>
#include <span>

#include "video_core/renderer_opengl/gl_device.h"
#include "video_core/renderer_opengl/gl_resource_manager.h"

namespace OpenGL {

class ProgramManager {
    static constexpr size_t NUM_STAGES = 5;

public:
    explicit ProgramManager(const Device& device);

    void BindComputeProgram(GLuint program);

    void BindComputeAssemblyProgram(GLuint program);

    void BindSourcePrograms(std::span<const OGLProgram, NUM_STAGES> programs);

    void BindPresentPrograms(GLuint vertex, GLuint fragment);

    void BindAssemblyPrograms(std::span<const OGLAssemblyProgram, NUM_STAGES> programs,
                              u32 stage_mask);

    void RestoreGuestCompute();

    void LocalMemoryWarmup();

private:
    void BindPipeline();

    void UnbindPipeline();

    void UnbindCompute();

    OGLPipeline pipeline;
    bool is_pipeline_bound{};
    bool is_compute_bound{};

    u32 current_stage_mask = 0;
    std::array<GLuint, NUM_STAGES> current_programs{};
    GLuint current_assembly_compute_program = 0;
    OGLProgram lmem_warmup_program;
};

} // namespace OpenGL