14#ifndef GRAPHICSENGINE_H
15#define GRAPHICSENGINE_H
78 const std::string &name,
int sort,
82 GraphicsOutput *host =
nullptr);
85 INLINE GraphicsOutput *
make_buffer(GraphicsOutput *host,
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);
95 bool add_window(GraphicsOutput *window,
int sort);
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 {
298 RenderThread(
const std::string &name, GraphicsEngine *engine);
299 virtual void thread_main();
301 GraphicsEngine *_engine;
303 ConditionVar _cv_start;
304 ConditionVar _cv_done;
305 ThreadState _thread_state;
308 GraphicsStateGuardian *_gsg;
309 PT(Texture) _texture;
310 const RenderState *_state;
311 DisplayRegion *_region;
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;
325 pvector<PT(GraphicsOutput)> _new_windows;
328 typedef pmap<std::string, PT(RenderThread) > Threads;
330 GraphicsThreadingModel _threading_model;
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;
346 ReMutex _public_lock;
348 class LoadedTexture {
351 UpdateSeq _image_modified;
353 typedef pvector<LoadedTexture> LoadedTextures;
354 LoadedTextures _loaded_textures;
355 Mutex _loaded_textures_lock;
357 static PT(GraphicsEngine) _global_ptr;
359 static PStatCollector _wait_pcollector;
360 static PStatCollector _cycle_pcollector;
361 static PStatCollector _app_pcollector;
362 static PStatCollector _render_frame_pcollector;
363 static PStatCollector _do_frame_pcollector;
364 static PStatCollector _yield_pcollector;
365 static PStatCollector _cull_pcollector;
366 static PStatCollector _cull_setup_pcollector;
367 static PStatCollector _cull_sort_pcollector;
368 static PStatCollector _draw_pcollector;
369 static PStatCollector _sync_pcollector;
370 static PStatCollector _flip_pcollector;
371 static PStatCollector _flip_begin_pcollector;
372 static PStatCollector _flip_end_pcollector;
373 static PStatCollector _transform_states_pcollector;
374 static PStatCollector _transform_states_unused_pcollector;
375 static PStatCollector _render_states_pcollector;
376 static PStatCollector _render_states_unused_pcollector;
377 static PStatCollector _cyclers_pcollector;
378 static PStatCollector _dirty_cyclers_pcollector;
379 static PStatCollector _delete_pcollector;
381 static PStatCollector _sw_sprites_pcollector;
382 static PStatCollector _vertex_data_small_pcollector;
383 static PStatCollector _vertex_data_independent_pcollector;
384 static PStatCollector _vertex_data_pending_pcollector;
385 static PStatCollector _vertex_data_resident_pcollector;
386 static PStatCollector _vertex_data_compressed_pcollector;
387 static PStatCollector _vertex_data_used_disk_pcollector;
388 static PStatCollector _vertex_data_unused_disk_pcollector;
390 static PStatCollector _cnode_volume_pcollector;
391 static PStatCollector _gnode_volume_pcollector;
392 static PStatCollector _geom_volume_pcollector;
393 static PStatCollector _node_volume_pcollector;
394 static PStatCollector _volume_pcollector;
395 static PStatCollector _test_pcollector;
396 static PStatCollector _volume_polygon_pcollector;
397 static PStatCollector _test_polygon_pcollector;
398 static PStatCollector _volume_plane_pcollector;
399 static PStatCollector _test_plane_pcollector;
400 static PStatCollector _volume_sphere_pcollector;
401 static PStatCollector _test_sphere_pcollector;
402 static PStatCollector _volume_box_pcollector;
403 static PStatCollector _test_box_pcollector;
404 static PStatCollector _volume_capsule_pcollector;
405 static PStatCollector _test_capsule_pcollector;
406 static PStatCollector _volume_inv_sphere_pcollector;
407 static PStatCollector _test_inv_sphere_pcollector;
408 static PStatCollector _volume_geom_pcollector;
409 static PStatCollector _test_geom_pcollector;
411 static PStatCollector _occlusion_untested_pcollector;
412 static PStatCollector _occlusion_passed_pcollector;
413 static PStatCollector _occlusion_failed_pcollector;
414 static PStatCollector _occlusion_tests_pcollector;
416 friend class WindowRenderer;
417 friend class GraphicsOutput;
This defines the abstract interface for an object that receives Geoms identified by the CullTraverser...
This stores the result of a BinCullHandler traversal: an ordered collection of CullBins,...
Encapsulates the data from a DisplayRegion, pre-fetched for one stage of the pipeline.
A rectangular subregion within a window for rendering into.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
This class is the main interface to controlling the render process.
get_portal_cull
Returns the current setting for the portal culling flag.
get_threading_model
Returns the threading model that will be applied to future objects.
get_window
Returns the nth window or buffers managed by the engine, in sorted order.
void reset_all_windows(bool swapchain)
Resets the framebuffer of the current window.
GraphicsOutput * make_parasite(GraphicsOutput *host, const std::string &name, int sort, int x_size, int y_size)
Syntactic shorthand for make_buffer.
void remove_all_windows()
Removes and closes all windows from the engine.
bool add_window(GraphicsOutput *window, int sort)
This can be used to add a newly-created GraphicsOutput object (and its GSG) to the engine's list of w...
void ready_flip()
Waits for all the threads that started drawing their last frame to finish drawing.
void open_windows()
Fully opens (or closes) any windows that have recently been requested open or closed,...
void flip_frame()
Waits for all the threads that started drawing their last frame to finish drawing,...
set_default_loader
Sets the Loader object that will be assigned to every GSG created with this GraphicsEngine.
bool extract_texture_data(Texture *tex, GraphicsStateGuardian *gsg)
Asks the indicated GraphicsStateGuardian to retrieve the texture memory image of the indicated textur...
get_default_loader
Returns the Loader object that will be assigned to every GSG created with this GraphicsEngine.
get_render_lock
Returns a ReMutex object that is held by the GraphicsEngine during the entire call to render_frame().
bool is_empty() const
Returns true if there are no windows or buffers managed by the engine, false if there is at least one...
bool remove_window(GraphicsOutput *window)
Removes the indicated window or offscreen buffer from the set of windows that will be processed when ...
set_threading_model
Specifies how future objects created via make_gsg(), make_buffer(), and make_output() will be threade...
GraphicsOutput * make_buffer(GraphicsOutput *host, const std::string &name, int sort, int x_size, int y_size)
Syntactic shorthand for make_output.
get_auto_flip
Returns the current setting for the auto-flip flag.
set_auto_flip
Set this flag true to indicate the GraphicsEngine should automatically cause windows to sync and flip...
GraphicsOutput * make_output(GraphicsPipe *pipe, const std::string &name, int sort, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg=nullptr, GraphicsOutput *host=nullptr)
Creates a new window (or buffer) and returns it.
void render_frame()
Renders the next frame in all the registered windows, and flips all of the frame buffers.
set_portal_cull
Set this flag true to indicate the GraphicsEngine should start portal culling.
GraphicsEngine(Pipeline *pipeline=nullptr)
Creates a new GraphicsEngine object.
void sync_frame()
Waits for all the threads that started drawing their last frame to finish drawing.
get_num_windows
Returns the number of windows (or buffers) managed by the engine.
void dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, GraphicsStateGuardian *gsg)
Asks the indicated GraphicsStateGuardian to dispatch the compute shader in the given ShaderAttrib usi...
This is a base class for the various different classes that represent the result of a frame of render...
An object to create GraphicsOutputs that share a particular 3-D API.
Encapsulates all the communication with a particular instance of a given rendering backend.
This represents the user's specification of how a particular frame is handled by the various threads.
An STL function object class, this is intended to be used on any ordered collection of pointers to cl...
A lightweight reentrant mutex.
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
A basic node of the scene graph or data graph.
This class manages a staged pipeline of data, for instance the render pipeline, so that each stage of...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
This object holds the camera position, etc., and other general setup information for rendering a part...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
A thread; that is, a lightweight process.
TypeHandle is the identifier used to differentiate C++ class types.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.