SynthesisPipeline.h 1.76 KB
Newer Older
Nianchen Deng's avatar
Nianchen Deng committed
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
#pragma once
#include "Common.h"
#include "InferPipeline.h"
#include "View.h"
#include "Enhancement.h"

class SynthesisPipeline
{
public:
    SynthesisPipeline(const std::string &netDir, bool isNmsl,
                      uint batchSize, uint samples);

    void run(View& view);

    GLuint getGlResultTexture(int index);

protected:
    uint _batchSize;
    uint _samples;
    std::vector<GLuint> _glResultTextures;
    GLuint _glResultBuffer;
    sptr<InferPipeline> _inferPipeline;
    sptr<CudaArray<glm::vec3>> _rays;
    sptr<CudaArray<glm::vec4>> _colors;

    virtual void _genRays(View& view) = 0;
    virtual void _enhance() = 0;
    virtual void _uploadResultToTextures() = 0;

    GLuint _createGlResultTexture(glm::uvec2 res);
    GLuint _createGlResultBuffer(uint elements);

};

class FoveaSynthesisPipeline : public SynthesisPipeline
{
public:
    FoveaSynthesisPipeline(glm::uvec2 res, float fov, uint samples);

protected:
    virtual void _genRays(View& view);
    virtual void _enhance();
    virtual void _uploadResultToTextures();

private:
    Camera _foveaCamera;
    sptr<Enhancement> _enhancement;
};

class PeriphSynthesisPipeline : public SynthesisPipeline
{
public:
    PeriphSynthesisPipeline(glm::uvec2 midRes, float midFov,
                            glm::uvec2 periphRes, float periphFov,
                            uint samples);

protected:
    virtual void _genRays(View& view);
    virtual void _enhance();
    virtual void _uploadResultToTextures();

private:
    Camera _midCamera;
    Camera _periphCamera;
    sptr<CudaArray<glm::vec3>> _midRays;
    sptr<CudaArray<glm::vec3>> _periphRays;
    sptr<CudaArray<glm::vec4>> _midColors;
    sptr<CudaArray<glm::vec4>> _periphColors;
    sptr<Enhancement> _midEnhancement;
    sptr<Enhancement> _periphEnhancement;
};