File: pass.hpp

package info (click to toggle)
openmw 0.49.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,992 kB
  • sloc: cpp: 372,479; xml: 2,149; sh: 1,403; python: 797; makefile: 26
file content (82 lines) | stat: -rw-r--r-- 1,790 bytes parent folder | download
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
#ifndef OPENMW_COMPONENTS_FX_PASS_H
#define OPENMW_COMPONENTS_FX_PASS_H

#include <array>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_set>

#include <osg/BlendEquation>
#include <osg/BlendFunc>
#include <osg/Shader>
#include <osg/Vec4f>
#include <osg/ref_ptr>

namespace osg
{
    class StateSet;
}

namespace fx
{
    class Technique;

    class Pass
    {
    public:
        enum class Order
        {
            Forward,
            Post
        };

        enum class Type
        {
            None,
            Pixel,
            Compute
        };

        friend class Technique;

        Pass(Type type = Type::Pixel, Order order = Order::Post, bool ubo = false);

        void compile(Technique& technique, std::string_view preamble);

        std::string getTarget() const { return mTarget; }

        const std::array<std::string, 3>& getRenderTargets() const { return mRenderTargets; }

        void prepareStateSet(osg::StateSet* stateSet, const std::string& name) const;

        std::string getName() const { return mName; }

        void dirty();

    private:
        std::string getPassHeader(Technique& technique, std::string_view preamble, bool fragOut = false);

        bool mCompiled;

        osg::ref_ptr<osg::Shader> mVertex;
        osg::ref_ptr<osg::Shader> mFragment;
        osg::ref_ptr<osg::Shader> mCompute;

        Type mType;
        Order mOrder;
        std::string mName;
        bool mLegacyGLSL;
        bool mUBO;

        std::array<std::string, 3> mRenderTargets;

        std::string mTarget;

        std::optional<osg::BlendFunc::BlendFuncMode> mBlendSource;
        std::optional<osg::BlendFunc::BlendFuncMode> mBlendDest;
        std::optional<osg::BlendEquation::Equation> mBlendEq;
    };
}

#endif