17 #ifndef GRAPHICSSTATEGUARDIAN_H 18 #define GRAPHICSSTATEGUARDIAN_H 85 INLINE
void release_all();
86 INLINE
int release_all_textures();
87 INLINE
int release_all_samplers();
88 INLINE
int release_all_geoms();
89 INLINE
int release_all_vertex_buffers();
90 INLINE
int release_all_index_buffers();
91 INLINE
int release_all_shader_buffers();
93 INLINE
void set_active(
bool active);
94 INLINE
bool is_active()
const;
95 INLINE
bool is_valid()
const;
96 INLINE
bool needs_reset()
const;
97 MAKE_PROPERTY(active, is_active, set_active);
98 MAKE_PROPERTY(valid, is_valid);
100 INLINE
void set_incomplete_render(
bool incomplete_render);
101 virtual INLINE
bool get_incomplete_render()
const;
102 virtual INLINE
bool get_effective_incomplete_render()
const;
103 MAKE_PROPERTY(incomplete_render, get_incomplete_render, set_incomplete_render);
104 MAKE_PROPERTY(effective_incomplete_render, get_effective_incomplete_render);
106 INLINE
void set_loader(
Loader *loader);
107 INLINE
Loader *get_loader()
const;
108 MAKE_PROPERTY(loader, get_loader, set_loader);
112 MAKE_PROPERTY(shader_generator, get_shader_generator, set_shader_generator);
117 MAKE_PROPERTY(pipe, get_pipe);
119 INLINE
bool is_hardware()
const;
120 virtual INLINE
bool prefers_triangle_strips()
const;
121 virtual INLINE
int get_max_vertices_per_array()
const;
122 virtual INLINE
int get_max_vertices_per_primitive()
const;
124 INLINE
int get_max_texture_stages()
const;
125 virtual INLINE
int get_max_texture_dimension()
const;
126 INLINE
int get_max_3d_texture_dimension()
const;
127 INLINE
int get_max_2d_texture_array_layers()
const;
128 INLINE
int get_max_cube_map_dimension()
const;
129 INLINE
int get_max_buffer_texture_size()
const;
131 INLINE
bool get_supports_texture_combine()
const;
132 INLINE
bool get_supports_texture_saved_result()
const;
133 INLINE
bool get_supports_texture_dot3()
const;
135 INLINE
bool get_supports_3d_texture()
const;
136 INLINE
bool get_supports_2d_texture_array()
const;
137 INLINE
bool get_supports_cube_map()
const;
138 INLINE
bool get_supports_buffer_texture()
const;
139 INLINE
bool get_supports_cube_map_array()
const;
140 INLINE
bool get_supports_tex_non_pow2()
const;
141 INLINE
bool get_supports_texture_srgb()
const;
143 INLINE
bool get_supports_compressed_texture()
const;
144 virtual INLINE
bool get_supports_compressed_texture_format(
int compression_mode)
const;
146 INLINE
int get_max_lights()
const;
147 INLINE
int get_max_clip_planes()
const;
149 INLINE
int get_max_vertex_transforms()
const;
150 INLINE
int get_max_vertex_transform_indices()
const;
152 INLINE
bool get_copy_texture_inverted()
const;
153 virtual bool get_supports_multisample()
const;
154 INLINE
bool get_supports_generate_mipmap()
const;
155 INLINE
bool get_supports_depth_texture()
const;
156 INLINE
bool get_supports_depth_stencil()
const;
157 INLINE
bool get_supports_luminance_texture()
const;
158 INLINE
bool get_supports_shadow_filter()
const;
159 INLINE
bool get_supports_sampler_objects()
const;
160 INLINE
bool get_supports_basic_shaders()
const;
161 INLINE
bool get_supports_geometry_shaders()
const;
162 INLINE
bool get_supports_tessellation_shaders()
const;
163 INLINE
bool get_supports_compute_shaders()
const;
164 INLINE
bool get_supports_glsl()
const;
165 INLINE
bool get_supports_hlsl()
const;
166 INLINE
bool get_supports_stencil()
const;
167 INLINE
bool get_supports_two_sided_stencil()
const;
168 INLINE
bool get_supports_geometry_instancing()
const;
169 INLINE
bool get_supports_indirect_draw()
const;
171 INLINE
bool get_supports_occlusion_query()
const;
172 INLINE
bool get_supports_timer_query()
const;
173 INLINE
bool get_timer_queries_active()
const;
175 INLINE
int get_max_color_targets()
const;
176 INLINE
int get_maximum_simultaneous_render_targets()
const;
177 INLINE
bool get_supports_dual_source_blending()
const;
179 MAKE_PROPERTY(max_vertices_per_array, get_max_vertices_per_array);
180 MAKE_PROPERTY(max_vertices_per_primitive, get_max_vertices_per_primitive);
181 MAKE_PROPERTY(max_texture_stages, get_max_texture_stages);
182 MAKE_PROPERTY(max_texture_dimension, get_max_texture_dimension);
183 MAKE_PROPERTY(max_3d_texture_dimension, get_max_3d_texture_dimension);
184 MAKE_PROPERTY(max_2d_texture_array_layers, get_max_2d_texture_array_layers);
185 MAKE_PROPERTY(max_cube_map_dimension, get_max_cube_map_dimension);
186 MAKE_PROPERTY(max_buffer_texture_size, get_max_buffer_texture_size);
187 MAKE_PROPERTY(supports_texture_combine, get_supports_texture_combine);
188 MAKE_PROPERTY(supports_texture_saved_result, get_supports_texture_saved_result);
189 MAKE_PROPERTY(supports_texture_dot3, get_supports_texture_dot3);
190 MAKE_PROPERTY(supports_3d_texture, get_supports_3d_texture);
191 MAKE_PROPERTY(supports_2d_texture_array, get_supports_2d_texture_array);
192 MAKE_PROPERTY(supports_cube_map, get_supports_cube_map);
193 MAKE_PROPERTY(supports_buffer_texture, get_supports_buffer_texture);
194 MAKE_PROPERTY(supports_cube_map_array, get_supports_cube_map_array);
195 MAKE_PROPERTY(supports_tex_non_pow2, get_supports_tex_non_pow2);
196 MAKE_PROPERTY(supports_texture_srgb, get_supports_texture_srgb);
197 MAKE_PROPERTY(supports_compressed_texture, get_supports_compressed_texture);
198 MAKE_PROPERTY(max_lights, get_max_lights);
199 MAKE_PROPERTY(max_clip_planes, get_max_clip_planes);
200 MAKE_PROPERTY(max_vertex_transforms, get_max_vertex_transforms);
201 MAKE_PROPERTY(max_vertex_transform_indices, get_max_vertex_transform_indices);
202 MAKE_PROPERTY(copy_texture_inverted, get_copy_texture_inverted);
203 MAKE_PROPERTY(supports_multisample, get_supports_multisample);
204 MAKE_PROPERTY(supports_generate_mipmap, get_supports_generate_mipmap);
205 MAKE_PROPERTY(supports_depth_texture, get_supports_depth_texture);
206 MAKE_PROPERTY(supports_depth_stencil, get_supports_depth_stencil);
207 MAKE_PROPERTY(supports_luminance_texture, get_supports_luminance_texture);
208 MAKE_PROPERTY(supports_shadow_filter, get_supports_shadow_filter);
209 MAKE_PROPERTY(supports_sampler_objects, get_supports_sampler_objects);
210 MAKE_PROPERTY(supports_basic_shaders, get_supports_basic_shaders);
211 MAKE_PROPERTY(supports_geometry_shaders, get_supports_geometry_shaders);
212 MAKE_PROPERTY(supports_tessellation_shaders, get_supports_tessellation_shaders);
213 MAKE_PROPERTY(supports_compute_shaders, get_supports_compute_shaders);
214 MAKE_PROPERTY(supports_glsl, get_supports_glsl);
215 MAKE_PROPERTY(supports_hlsl, get_supports_hlsl);
216 MAKE_PROPERTY(supports_stencil, get_supports_stencil);
217 MAKE_PROPERTY(supports_two_sided_stencil, get_supports_two_sided_stencil);
218 MAKE_PROPERTY(supports_geometry_instancing, get_supports_geometry_instancing);
219 MAKE_PROPERTY(supports_indirect_draw, get_supports_indirect_draw);
220 MAKE_PROPERTY(supports_occlusion_query, get_supports_occlusion_query);
221 MAKE_PROPERTY(supports_timer_query, get_supports_timer_query);
222 MAKE_PROPERTY(timer_queries_active, get_timer_queries_active);
223 MAKE_PROPERTY(max_color_targets, get_max_color_targets);
224 MAKE_PROPERTY(supports_dual_source_blending, get_supports_dual_source_blending);
226 INLINE ShaderModel get_shader_model()
const;
227 INLINE
void set_shader_model(ShaderModel shader_model);
228 MAKE_PROPERTY(shader_model, get_shader_model, set_shader_model);
230 virtual int get_supported_geom_rendering()
const;
231 virtual bool get_supports_cg_profile(
const std::string &name)
const;
233 INLINE
bool get_color_scale_via_lighting()
const;
234 INLINE
bool get_alpha_scale_via_texture()
const;
235 INLINE
bool get_alpha_scale_via_texture(
const TextureAttrib *tex_attrib)
const;
236 INLINE
bool get_runtime_color_scale()
const;
238 INLINE
static TextureStage *get_alpha_scale_texture_stage();
240 void set_coordinate_system(CoordinateSystem cs);
241 INLINE CoordinateSystem get_coordinate_system()
const;
242 virtual CoordinateSystem get_internal_coordinate_system()
const;
243 MAKE_PROPERTY(coordinate_system, get_coordinate_system, set_coordinate_system);
246 MAKE_PROPERTY(prepared_objects, get_prepared_objects);
248 virtual bool set_gamma(PN_stdfloat gamma);
249 PN_stdfloat get_gamma()
const;
250 virtual void restore_gamma();
251 MAKE_PROPERTY(gamma, get_gamma, set_gamma);
253 INLINE
void set_texture_quality_override(Texture::QualityLevel quality_level);
254 INLINE Texture::QualityLevel get_texture_quality_override()
const;
255 MAKE_PROPERTY(texture_quality_override, get_texture_quality_override,
256 set_texture_quality_override);
258 EXTENSION(PyObject *get_prepared_textures()
const);
259 typedef bool TextureCallback(
TextureContext *tc,
void *callback_arg);
260 void traverse_prepared_textures(TextureCallback *func,
void *callback_arg);
263 void set_flash_texture(
Texture *tex);
264 void clear_flash_texture();
265 Texture *get_flash_texture()
const;
266 MAKE_PROPERTY(flash_texture, get_flash_texture, set_flash_texture);
270 virtual bool has_extension(
const std::string &extension)
const;
272 virtual std::string get_driver_vendor();
273 virtual std::string get_driver_renderer();
274 virtual std::string get_driver_version();
275 virtual int get_driver_version_major();
276 virtual int get_driver_version_minor();
277 virtual int get_driver_shader_version_major();
278 virtual int get_driver_shader_version_minor();
280 MAKE_PROPERTY(driver_vendor, get_driver_vendor);
281 MAKE_PROPERTY(driver_renderer, get_driver_renderer);
282 MAKE_PROPERTY(driver_version, get_driver_version);
283 MAKE_PROPERTY(driver_version_major, get_driver_version_major);
284 MAKE_PROPERTY(driver_version_minor, get_driver_version_minor);
285 MAKE_PROPERTY(driver_shader_version_major, get_driver_shader_version_major);
286 MAKE_PROPERTY(driver_shader_version_minor, get_driver_shader_version_minor);
290 MAKE_PROPERTY(scene, get_scene, set_scene);
296 virtual
bool extract_texture_data(
Texture *tex);
316 virtual
void begin_occlusion_query();
321 virtual
void dispatch_compute(
int size_x,
int size_y,
int size_z);
328 virtual
void set_state_and_transform(const
RenderState *state,
331 PN_stdfloat compute_distance_to(const LPoint3 &point) const;
335 const LMatrix4 *fetch_specified_value(
Shader::ShaderMatSpec &spec,
int altered);
336 const LMatrix4 *fetch_specified_part(
Shader::ShaderMatInput input,
InternalName *name,
337 LMatrix4 &t,
int index);
339 PT(
Texture) fetch_specified_texture(
Shader::ShaderTexSpec &spec,
341 const
Shader::ShaderPtrData *fetch_ptr_parameter(const
Shader::ShaderPtrSpec& spec);
344 virtual
void clear_before_callback();
345 virtual
void clear_state_and_transform();
350 virtual
bool prepare_lens();
352 virtual
bool begin_frame(
Thread *current_thread);
354 virtual
bool begin_scene();
355 virtual
void end_scene();
357 virtual
void end_frame(
Thread *current_thread);
359 void flush_timer_queries();
363 virtual
bool depth_offset_decals();
366 virtual CPT(
RenderState) begin_decal_base_second();
367 virtual
void finish_decal();
394 virtual
void end_draw_primitives();
396 INLINE
bool reset_if_new();
397 INLINE
void mark_new();
398 virtual
void reset();
405 INLINE const
DisplayRegion *get_current_display_region() const;
406 INLINE
Lens::StereoChannel get_current_stereo_channel() const;
407 INLINE
int get_current_tex_view_offset() const;
408 INLINE const
Lens *get_current_lens() const;
410 virtual CPT(
TransformState) get_cs_transform_for(CoordinateSystem cs) const;
414 void do_issue_clip_plane();
415 void do_issue_color();
416 void do_issue_color_scale();
417 virtual
void do_issue_light();
419 virtual
bool framebuffer_copy_to_texture
421 virtual
bool framebuffer_copy_to_ram
431 static
void create_gamma_table (PN_stdfloat gamma,
unsigned short *red_table,
unsigned short *green_table,
unsigned short *blue_table);
434 PT(
Texture) get_dummy_shadow_map(
Texture::TextureType texture_type) const;
437 virtual
void ensure_generated_shader(const
RenderState *state);
440 static void init_frame_pstats();
444 virtual void reissue_transforms();
446 virtual void enable_lighting(
bool enable);
447 virtual void set_ambient_light(
const LColor &color);
448 virtual void enable_light(
int light_id,
bool enable);
449 virtual void begin_bind_lights();
450 virtual void end_bind_lights();
452 virtual void enable_clip_planes(
bool enable);
453 virtual void enable_clip_plane(
int plane_id,
bool enable);
454 virtual void begin_bind_clip_planes();
455 virtual void bind_clip_plane(
const NodePath &plane,
int plane_id);
456 virtual void end_bind_clip_planes();
458 void determine_target_texture();
459 void determine_target_shader();
461 virtual void free_pointers();
462 virtual void close_gsg();
463 void panic_deactivate();
465 void determine_light_color_scale();
513 unsigned int _color_write_mask;
516 Lens::StereoChannel _current_stereo_channel;
517 int _current_tex_view_offset;
518 CPT(
Lens) _current_lens;
523 CoordinateSystem _coordinate_system;
524 CoordinateSystem _internal_coordinate_system;
528 LColor _scene_graph_color;
529 bool _has_scene_graph_color;
530 bool _transform_stale;
531 bool _color_blend_involves_color_scale;
532 bool _texture_involves_color_scale;
533 bool _vertex_colors_enabled;
534 bool _lighting_enabled;
535 bool _clip_planes_enabled;
536 bool _color_scale_enabled;
537 LVecBase4 _current_color_scale;
539 bool _has_material_force_color;
540 LColor _material_force_color;
541 LVecBase4 _light_color_scale;
542 bool _has_texture_alpha_scale;
544 bool _tex_gen_modifies_mat;
545 bool _tex_gen_point_sprite;
546 int _last_max_stage_index;
552 bool _incomplete_render;
553 bool _effective_incomplete_render;
559 bool _prefers_triangle_strips;
560 int _max_vertices_per_array;
561 int _max_vertices_per_primitive;
563 int _max_texture_stages;
564 int _max_texture_dimension;
565 int _max_3d_texture_dimension;
566 int _max_2d_texture_array_layers;
567 int _max_cube_map_dimension;
568 int _max_buffer_texture_size;
570 bool _supports_texture_combine;
571 bool _supports_texture_saved_result;
572 bool _supports_texture_dot3;
574 bool _supports_3d_texture;
575 bool _supports_2d_texture_array;
576 bool _supports_cube_map;
577 bool _supports_buffer_texture;
578 bool _supports_cube_map_array;
579 bool _supports_tex_non_pow2;
580 bool _supports_texture_srgb;
582 bool _supports_compressed_texture;
586 int _max_clip_planes;
588 int _max_vertex_transforms;
589 int _max_vertex_transform_indices;
591 bool _supports_occlusion_query;
594 bool _supports_timer_query;
596 int _pstats_gpu_thread;
597 bool _timer_queries_active;
600 int _last_query_frame;
601 int _last_num_queried;
604 TimerQueryQueue _pending_timer_queries;
607 bool _copy_texture_inverted;
608 bool _supports_multisample;
609 bool _supports_generate_mipmap;
610 bool _supports_depth_texture;
611 bool _supports_depth_stencil;
612 bool _supports_luminance_texture;
613 bool _supports_shadow_filter;
614 bool _supports_sampler_objects;
615 bool _supports_basic_shaders;
616 bool _supports_geometry_shaders;
617 bool _supports_tessellation_shaders;
618 bool _supports_compute_shaders;
621 bool _supports_framebuffer_multisample;
622 bool _supports_framebuffer_blit;
624 bool _supports_stencil;
625 bool _supports_stencil_wrap;
626 bool _supports_two_sided_stencil;
627 bool _supports_geometry_instancing;
628 bool _supports_indirect_draw;
630 int _max_color_targets;
631 bool _supports_dual_source_blending;
633 int _supported_geom_rendering;
634 bool _color_scale_via_lighting;
635 bool _alpha_scale_via_texture;
636 bool _runtime_color_scale;
638 int _stereo_buffer_mask;
640 ShaderModel _auto_detect_shader_model;
641 ShaderModel _shader_model;
648 Texture::QualityLevel _texture_quality_override;
720 static PStatCollector _draw_set_state_shader_parameters_pcollector;
731 int _num_lights_enabled;
732 int _num_clip_planes_enabled;
744 static void init_type() {
745 GraphicsStateGuardianBase::init_type();
747 GraphicsStateGuardianBase::get_class_type());
750 return get_class_type();
752 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
762 EXPCL_PANDA_DISPLAY std::ostream &operator << (std::ostream &out, GraphicsStateGuardian::ShaderModel sm);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A light shining from infinitely far away in a particular direction, like sunlight.
Encapsulates the data from a DisplayRegion, pre-fetched for one stage of the pipeline.
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
This is a special class object that holds all the information returned by a particular GSG to indicat...
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
This is a base class for GraphicsWindow (actually, GraphicsOutput) and DisplayRegion,...
This is a generic buffer object that lives in graphics memory.
A base class for any number of different kinds of lenses, linear and otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
This is a special class object that holds all the information returned by a particular GSG to indicat...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
This is a special class object that holds all the information returned by a particular GSG to indicat...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Encapsulates the data from a Geom, pre-fetched for one stage of the pipeline.
A table of objects that are saved within the graphics context for reference by handle later.
This is our own Panda specialization on the default STL deque.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
The ShaderContext is meant to contain the compiled version of a shader string.
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight class that represents a single element that may be timed and/or counted via stats.
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.
Contains the raw timing and level data for a single frame.
An object to create GraphicsOutputs that share a particular 3-D API.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A container for geometry primitives.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A light originating from a single point in space, and shining in a particular direction,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for the various different classes that represent the result of a frame of render...
This represents the user's specification of how a particular frame is handled by the various threads.
Encodes a string name in a hash table, mapping it to a pointer.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Represents a set of settings that indicate how a texture is sampled.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a special class object that holds a handle to the sampler state object given by the graphics ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A thread; that is, a lightweight process.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A derivative of Light and of Camera.
This is a special class object that holds all the information returned by a particular GSG to indicat...
Encapsulates all the communication with a particular instance of a given rendering backend.
A rectangular subregion within a window for rendering into.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An abstract base class for GraphicsOutput, for all the usual reasons.
Returned from a GSG in response to begin_occlusion_query() .
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object holds the camera position, etc., and other general setup information for rendering a part...
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
Defines the properties of a named stage of the multitexture pipeline.
Computes texture coordinates for geometry automatically based on vertex position and/or normal.
A RenderBuffer is an arbitrary subset of the various layers (depth buffer, color buffer,...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A light originating from a single point in space, and shining in all directions.
This is the data for one array of a GeomVertexData structure.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.