14 #ifndef GRAPHICSENGINE_H
15 #define GRAPHICSENGINE_H
60 MAKE_PROPERTY(threading_model, get_threading_model, set_threading_model);
62 INLINE
const ReMutex &get_render_lock()
const;
63 MAKE_PROPERTY(render_lock, get_render_lock);
65 INLINE
void set_auto_flip(
bool auto_flip);
66 INLINE
bool get_auto_flip()
const;
67 MAKE_PROPERTY(auto_flip, get_auto_flip, set_auto_flip);
69 INLINE
void set_portal_cull(
bool value);
70 INLINE
bool get_portal_cull()
const;
71 MAKE_PROPERTY(portal_cull, get_portal_cull, set_portal_cull);
73 INLINE
void set_default_loader(
Loader *loader);
74 INLINE
Loader *get_default_loader()
const;
75 MAKE_PROPERTY(default_loader, get_default_loader, set_default_loader);
78 const std::string &name,
int sort,
86 const std::string &name,
int sort,
87 int x_size,
int y_size);
89 const std::string &name,
int sort,
90 int x_size,
int y_size);
92 const std::string &name,
int sort,
93 int x_size,
int y_size);
97 BLOCKING
void remove_all_windows();
98 void reset_all_windows(
bool swapchain);
100 bool is_empty()
const;
101 int get_num_windows()
const;
103 MAKE_SEQ(get_windows, get_num_windows, get_window);
104 MAKE_SEQ_PROPERTY(windows, get_num_windows, get_window);
106 BLOCKING
void render_frame();
107 BLOCKING
void open_windows();
108 BLOCKING
void sync_frame();
109 BLOCKING
void ready_flip();
110 BLOCKING
void flip_frame();
113 void dispatch_compute(
const LVecBase3i &work_groups,
133 void texture_uploaded(
Texture *tex);
144 static bool scene_root_func(
const PandaNode *node);
145 bool is_scene_root(
const PandaNode *node);
149 void cull_and_draw_together(Windows wlist,
Thread *current_thread);
153 void cull_to_bins(Windows wlist,
Thread *current_thread);
157 void draw_bins(
const Windows &wlist,
Thread *current_thread);
158 void make_contexts(
const Windows &wlist,
Thread *current_thread);
160 void process_events(
const Windows &wlist,
Thread *current_thread);
161 void ready_flip_windows(
const Windows &wlist,
Thread *current_thread);
162 void flip_windows(
const Windows &wlist,
Thread *current_thread);
163 void do_sync_frame(
Thread *current_thread);
164 void do_ready_flip(
Thread *current_thread);
165 void do_flip_frame(
Thread *current_thread);
176 void do_resort_windows();
177 void terminate_threads(
Thread *current_thread);
181 typedef std::map<TypeHandle, PStatCollector> CyclerTypeCounters;
182 CyclerTypeCounters _all_cycler_types;
183 CyclerTypeCounters _dirty_cycler_types;
184 static void pstats_count_cycler_type(
TypeHandle type,
int count,
void *data);
185 static void pstats_count_dirty_cycler_type(
TypeHandle type,
int count,
void *data);
188 static const RenderState *get_invert_polygon_state();
265 class WindowRenderer {
267 WindowRenderer(
const std::string &name);
272 void resort_windows();
280 bool any_done_gsgs()
const;
289 Windows _pending_close;
296 class RenderThread :
public Thread,
public WindowRenderer {
299 virtual void thread_main();
305 ThreadState _thread_state;
312 LVecBase3i _work_groups;
316 WindowRenderer *get_window_renderer(
const std::string &name,
int pipeline_stage);
320 bool _windows_sorted;
323 Mutex _new_windows_lock;
324 unsigned int _window_sort_index;
328 typedef pmap<std::string, PT(RenderThread) > Threads;
332 bool _portal_enabled;
333 PT(
Loader) _default_loader;
340 FlipState _flip_state;
342 bool _singular_warning_last_frame;
343 bool _singular_warning_this_frame;
348 class LoadedTexture {
354 LoadedTextures _loaded_textures;
355 Mutex _loaded_textures_lock;
416 friend class WindowRenderer;