-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathresources_gl.hpp
134 lines (102 loc) · 3.33 KB
/
resources_gl.hpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-FileCopyrightText: Copyright (c) 2016-2022 NVIDIA CORPORATION
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "resources.hpp"
#include <nvgl/base_gl.hpp>
#include <nvgl/profiler_gl.hpp>
#include <nvgl/programmanager_gl.hpp>
#include "cadscene_gl.hpp"
namespace meshlettest {
class ResourcesGL : public Resources
{
public:
static const int CYCLED_FRAMES = 4;
struct ProgramIDs
{
nvgl::ProgramID draw_object_tris;
nvgl::ProgramID draw_bboxes;
nvgl::ProgramID draw_object_mesh;
nvgl::ProgramID draw_object_mesh_task;
nvgl::ProgramID draw_object_cull_mesh;
nvgl::ProgramID draw_object_cull_mesh_task;
};
struct Programs
{
GLuint draw_object_tris = 0;
GLuint draw_bboxes = 0;
GLuint draw_object_mesh = 0;
GLuint draw_object_mesh_task = 0;
GLuint draw_object_cull_mesh = 0;
GLuint draw_object_cull_mesh_task = 0;
};
struct FrameBuffer
{
bool useResolve{};
int renderWidth{};
int renderHeight{};
int supersample{};
GLuint fboScene = 0;
GLuint texSceneColor = 0;
GLuint texSceneDepthStencil = 0;
};
struct Common
{
GLuint standardVao{};
nvgl::Buffer viewBuffer;
nvgl::Buffer statsBuffer;
nvgl::Buffer statsReadBuffer;
};
struct DrawSetup
{
nvgl::Buffer geometryBindings;
};
nvgl::ProfilerGL m_profilerGL;
nvgl::ProgramManager m_progManager;
ProgramIDs m_programids;
Programs m_programs;
Common m_common;
DrawSetup m_setup;
CadSceneGL m_scene;
FrameBuffer m_framebuffer;
void synchronize() override { glFinish(); }
bool init(const nvgl::ContextWindow* window, nvh::Profiler* profiler) override;
void deinit() override;
bool initPrograms(const std::string& path, const std::string& prepend) override;
void reloadPrograms(const std::string& prepend) override;
void updatedPrograms();
void deinitPrograms();
bool initFramebuffer(int width, int height, int supersample, bool vsync) override;
void deinitFramebuffer();
bool initScene(const CadScene&) override;
void deinitScene() override;
void drawBoundingBoxes(const class RenderList* NV_RESTRICT list) const;
void blitFrame(const FrameConfig& global) override;
glm::mat4 perspectiveProjection(float fovy, float aspect, float nearPlane, float farPlane) const override;
void getStats(CullStats& stats) override;
void copyStats() const;
static uvec2 storeU64(GLuint64 address) { return {address & 0xFFFFFFFF, address >> 32}; }
void enableVertexFormat() const;
void disableVertexFormat() const;
static ResourcesGL* get()
{
static ResourcesGL resGL;
return &resGL;
}
};
} // namespace meshlettest