Panda3D
graphicsStateGuardian.I
1 // Filename: graphicsStateGuardian.I
2 // Created by: drose (24Sep99)
3 // Updated by: fperazzi, PandaSE (29Apr10) (added
4 // get_max_2d_texture_array_layers and related)
5 //
6 ////////////////////////////////////////////////////////////////////
7 //
8 // PANDA 3D SOFTWARE
9 // Copyright (c) Carnegie Mellon University. All rights reserved.
10 //
11 // All use of this software is subject to the terms of the revised BSD
12 // license. You should have received a copy of this license along
13 // with this source code in a file named "LICENSE."
14 //
15 ////////////////////////////////////////////////////////////////////
16 
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: GraphicsStateGuardian::release_all
20 // Access: Public
21 // Description: Releases all prepared objects.
22 ////////////////////////////////////////////////////////////////////
23 INLINE void GraphicsStateGuardian::
25  _prepared_objects->release_all();
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: GraphicsStateGuardian::release_all_textures
30 // Access: Public
31 // Description: Frees the resources for all textures associated with
32 // this GSG.
33 ////////////////////////////////////////////////////////////////////
34 INLINE int GraphicsStateGuardian::
36  return _prepared_objects->release_all_textures();
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: GraphicsStateGuardian::release_all_samplers
41 // Access: Public
42 // Description: Frees the resources for all samplers associated with
43 // this GSG.
44 ////////////////////////////////////////////////////////////////////
45 INLINE int GraphicsStateGuardian::
47  return _prepared_objects->release_all_samplers();
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: GraphicsStateGuardian::release_all_geoms
52 // Access: Public
53 // Description: Frees the resources for all geoms associated with
54 // this GSG.
55 ////////////////////////////////////////////////////////////////////
56 INLINE int GraphicsStateGuardian::
58  return _prepared_objects->release_all_geoms();
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: GraphicsStateGuardian::release_all_vertex_buffers
63 // Access: Public
64 // Description: Frees the resources for all vertex buffers associated
65 // with this GSG.
66 ////////////////////////////////////////////////////////////////////
67 INLINE int GraphicsStateGuardian::
69  return _prepared_objects->release_all_vertex_buffers();
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: GraphicsStateGuardian::release_all_index_buffers
74 // Access: Public
75 // Description: Frees the resources for all index buffers associated
76 // with this GSG.
77 ////////////////////////////////////////////////////////////////////
78 INLINE int GraphicsStateGuardian::
80  return _prepared_objects->release_all_index_buffers();
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: GraphicsStateGuardian::set_active
85 // Access: Published
86 // Description: Sets the active flag associated with the
87 // GraphicsStateGuardian. If the GraphicsStateGuardian
88 // is marked inactive, nothing is rendered. This is not
89 // normally turned off unless there is a problem with
90 // the rendering detected at a low level.
91 ////////////////////////////////////////////////////////////////////
92 INLINE void GraphicsStateGuardian::
93 set_active(bool active) {
94  _active = active;
95 }
96 
97 ////////////////////////////////////////////////////////////////////
98 // Function: GraphicsStateGuardian::is_active
99 // Access: Published
100 // Description: Returns the active flag associated with the
101 // GraphicsStateGuardian.
102 ////////////////////////////////////////////////////////////////////
103 INLINE bool GraphicsStateGuardian::
104 is_active() const {
105  return _active && _is_valid;
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: GraphicsStateGuardian::is_valid
110 // Access: Published
111 // Description: Returns true if the GSG has been correctly
112 // initialized within a graphics context, false if there
113 // has been some problem or it hasn't been initialized
114 // yet.
115 ////////////////////////////////////////////////////////////////////
116 INLINE bool GraphicsStateGuardian::
117 is_valid() const {
118  return _is_valid;
119 }
120 
121 ////////////////////////////////////////////////////////////////////
122 // Function: GraphicsStateGuardian::needs_reset
123 // Access: Public
124 // Description: Returns true if the gsg is marked as needing a
125 // reset.
126 ////////////////////////////////////////////////////////////////////
127 INLINE bool GraphicsStateGuardian::
128 needs_reset() const {
129  return _needs_reset;
130 }
131 
132 ////////////////////////////////////////////////////////////////////
133 // Function: GraphicsStateGuardian::set_incomplete_render
134 // Access: Public
135 // Description: Sets the incomplete_render flag. When this is
136 // true, the frame will be rendered even if some of the
137 // geometry or textures in the scene are not available
138 // (e.g. they have been temporarily paged out). When
139 // this is false, the frame will be held up while this
140 // data is reloaded.
141 //
142 // Setting this true allows for a smoother frame rate,
143 // but occasionally parts of the frame will be invisible
144 // or missing (they will generally come in within a
145 // second or two). Setting this false guarantees that
146 // every frame will be complete, but may cause more
147 // chugs as things are loaded up at runtime.
148 //
149 // You may want to set this false during loading
150 // screens, to guarantee that all of your assets are
151 // available by the time you take the loading screen
152 // down.
153 //
154 // This flag may also be set individually on each
155 // DisplayRegion. It will be considered true for a
156 // given DisplayRegion only if it is true on both the
157 // GSG and on the DisplayRegion.
158 ////////////////////////////////////////////////////////////////////
159 INLINE void GraphicsStateGuardian::
160 set_incomplete_render(bool incomplete_render) {
161  _incomplete_render = incomplete_render;
162 }
163 
164 ////////////////////////////////////////////////////////////////////
165 // Function: GraphicsStateGuardian::get_incomplete_render
166 // Access: Public, Virtual
167 // Description: Returns the incomplete_render flag. See
168 // set_incomplete_render().
169 ////////////////////////////////////////////////////////////////////
170 INLINE bool GraphicsStateGuardian::
172  return _incomplete_render;
173 }
174 
175 ////////////////////////////////////////////////////////////////////
176 // Function: GraphicsStateGuardian::get_effective_incomplete_render
177 // Access: Public, Virtual
178 // Description: Returns true if the GSG is effectively in
179 // incomplete_render state, considering both the GSG's
180 // incomplete_render and its current DisplayRegion's
181 // incomplete_render flags. It only makes sense to call
182 // this during the draw traversal; at other times this
183 // return value will be meaningless.
184 //
185 // See CullTraverser::get_effective_incomplete_render()
186 // for this same information during the cull traversal.
187 ////////////////////////////////////////////////////////////////////
188 INLINE bool GraphicsStateGuardian::
190  return _effective_incomplete_render;
191 }
192 
193 ////////////////////////////////////////////////////////////////////
194 // Function: GraphicsStateGuardian::set_loader
195 // Access: Public
196 // Description: Sets the Loader object that will be used by this GSG
197 // to load textures when necessary, if
198 // get_incomplete_render() is true.
199 ////////////////////////////////////////////////////////////////////
200 INLINE void GraphicsStateGuardian::
201 set_loader(Loader *loader) {
202  _loader = loader;
203 }
204 
205 ////////////////////////////////////////////////////////////////////
206 // Function: GraphicsStateGuardian::get_loader
207 // Access: Public
208 // Description: Returns the Loader object that will be used by this
209 // GSG to load textures when necessary, if
210 // get_incomplete_render() is true.
211 ////////////////////////////////////////////////////////////////////
213 get_loader() const {
214  return _loader;
215 }
216 
217 ////////////////////////////////////////////////////////////////////
218 // Function: GraphicsStateGuardian::set_shader_generator
219 // Access: Public
220 // Description: Sets the ShaderGenerator object that will be used
221 // by this GSG to generate shaders when necessary.
222 ////////////////////////////////////////////////////////////////////
223 INLINE void GraphicsStateGuardian::
225  _shader_generator = shader_generator;
226 }
227 
228 ////////////////////////////////////////////////////////////////////
229 // Function: GraphicsStateGuardian::get_shader_generator
230 // Access: Public
231 // Description: Returns the ShaderGenerator object that will be used
232 // by this GSG to generate shaders when necessary.
233 ////////////////////////////////////////////////////////////////////
236  return _shader_generator;
237 }
238 
239 ////////////////////////////////////////////////////////////////////
240 // Function: GraphicsStateGuardian::get_pipe
241 // Access: Published
242 // Description: Returns the graphics pipe on which this GSG was
243 // created.
244 ////////////////////////////////////////////////////////////////////
246 get_pipe() const {
247  return _pipe;
248 }
249 
250 ////////////////////////////////////////////////////////////////////
251 // Function: GraphicsStateGuardian::get_threading_model
252 // Access: Published
253 // Description: Returns the threading model that was used to create
254 // this GSG.
255 ////////////////////////////////////////////////////////////////////
258  return _threading_model;
259 }
260 
261 ////////////////////////////////////////////////////////////////////
262 // Function: GraphicsStateGuardian::is_hardware
263 // Access: Published
264 // Description: Returns true if this GSG appears to be
265 // hardware-accelerated, or false if it is known to be
266 // software only.
267 ////////////////////////////////////////////////////////////////////
268 INLINE bool GraphicsStateGuardian::
269 is_hardware() const {
270  return _is_hardware;
271 }
272 
273 ////////////////////////////////////////////////////////////////////
274 // Function: GraphicsStateGuardian::prefers_triangle_strips
275 // Access: Published, Virtual
276 // Description: Returns true if this GSG strongly prefers triangle
277 // strips to individual triangles (such as SGI), or
278 // false if it prefers to minimize the number of
279 // primitive batches, even at the expense of triangle
280 // strips (such as most PC hardware).
281 ////////////////////////////////////////////////////////////////////
282 INLINE bool GraphicsStateGuardian::
284  return _prefers_triangle_strips;
285 }
286 
287 ////////////////////////////////////////////////////////////////////
288 // Function: GraphicsStateGuardian::get_max_vertices_per_array
289 // Access: Published, Virtual
290 // Description: Returns the maximum number of vertices that should be
291 // put into any one GeomVertexData object for use with
292 // this GSG.
293 ////////////////////////////////////////////////////////////////////
294 INLINE int GraphicsStateGuardian::
296  return _max_vertices_per_array;
297 }
298 
299 ////////////////////////////////////////////////////////////////////
300 // Function: GraphicsStateGuardian::get_max_vertices_per_primitive
301 // Access: Published, Virtual
302 // Description: Returns the maximum number of vertex indices that
303 // should be put into any one GeomPrimitive object for
304 // use with this GSG.
305 ////////////////////////////////////////////////////////////////////
306 INLINE int GraphicsStateGuardian::
308  return _max_vertices_per_primitive;
309 }
310 
311 ////////////////////////////////////////////////////////////////////
312 // Function: GraphicsStateGuardian::get_max_texture_stages
313 // Access: Published
314 // Description: Returns the maximum number of simultaneous textures
315 // that may be applied to geometry with multitexturing,
316 // as supported by this particular GSG. If you exceed
317 // this number, the lowest-priority texture stages will
318 // not be applied. Use TextureStage::set_priority() to
319 // adjust the relative importance of the different
320 // texture stages.
321 //
322 // The value returned may not be meaningful until after
323 // the graphics context has been fully created (e.g. the
324 // window has been opened).
325 ////////////////////////////////////////////////////////////////////
326 INLINE int GraphicsStateGuardian::
328  if (max_texture_stages > 0) {
329  return min(_max_texture_stages, (int)max_texture_stages);
330  }
331  return _max_texture_stages;
332 }
333 
334 ////////////////////////////////////////////////////////////////////
335 // Function: GraphicsStateGuardian::get_max_texture_dimension
336 // Access: Published
337 // Description: Returns the largest possible texture size in any one
338 // dimension supported by the GSG, or -1 if there is no
339 // particular limit.
340 //
341 // The value returned may not be meaningful until after
342 // the graphics context has been fully created (e.g. the
343 // window has been opened).
344 ////////////////////////////////////////////////////////////////////
345 INLINE int GraphicsStateGuardian::
347  return _max_texture_dimension;
348 }
349 
350 ////////////////////////////////////////////////////////////////////
351 // Function: GraphicsStateGuardian::get_max_3d_texture_dimension
352 // Access: Published
353 // Description: Returns the largest possible texture size in any one
354 // dimension for a 3-d texture, or -1 if there is no
355 // particular limit. Returns 0 if 3-d textures are not
356 // supported.
357 //
358 // The value returned may not be meaningful until after
359 // the graphics context has been fully created (e.g. the
360 // window has been opened).
361 ////////////////////////////////////////////////////////////////////
362 INLINE int GraphicsStateGuardian::
364  return _max_3d_texture_dimension;
365 }
366 
367 ////////////////////////////////////////////////////////////////////
368 // Function: GraphicsStateGuardian::get_max_2d_texture_array_layers
369 // Access: Published
370 // Description: Returns the largest possible number of pages, or -1
371 // if there is no particular limit. Returns 0 if 2-d
372 // texture arrays not supported.
373 //
374 // The value returned may not be meaningful until after
375 // the graphics context has been fully created (e.g. the
376 // window has been opened).
377 ////////////////////////////////////////////////////////////////////
378 INLINE int GraphicsStateGuardian::
380  return _max_2d_texture_array_layers;
381 }
382 
383 ////////////////////////////////////////////////////////////////////
384 // Function: GraphicsStateGuardian::get_max_cube_map_dimension
385 // Access: Published
386 // Description: Returns the largest possible texture size in any one
387 // dimension for a cube map texture, or -1 if there is
388 // no particular limit. Returns 0 if cube map textures
389 // are not supported.
390 //
391 // The value returned may not be meaningful until after
392 // the graphics context has been fully created (e.g. the
393 // window has been opened).
394 ////////////////////////////////////////////////////////////////////
395 INLINE int GraphicsStateGuardian::
397  return _max_cube_map_dimension;
398 }
399 
400 ////////////////////////////////////////////////////////////////////
401 // Function: GraphicsStateGuardian::get_supports_texture_combine
402 // Access: Published
403 // Description: Returns true if this particular GSG can use the
404 // TextureStage::M_combine mode, which includes all of
405 // the texture blend modes specified by
406 // set_combine_rgb() and/or set_combine_alpha(). If
407 // this is false, you must limit yourself to using the
408 // simpler blend modes.
409 ////////////////////////////////////////////////////////////////////
410 INLINE bool GraphicsStateGuardian::
412  return _supports_texture_combine;
413 }
414 
415 ////////////////////////////////////////////////////////////////////
416 // Function: GraphicsStateGuardian::get_supports_texture_saved_result
417 // Access: Published
418 // Description: Returns true if this GSG can use the
419 // TextureStage::CS_last_saved_result source, which
420 // allows you to save the result of a TextureStage and
421 // re-use it for multiple inputs.
422 ////////////////////////////////////////////////////////////////////
423 INLINE bool GraphicsStateGuardian::
425  return _supports_texture_saved_result;
426 }
427 
428 ////////////////////////////////////////////////////////////////////
429 // Function: GraphicsStateGuardian::get_supports_texture_dot3
430 // Access: Published
431 // Description: Returns true if this GSG can use the
432 // TextureStage::CM_dot3_rgb or CM_dot3_rgba combine
433 // modes.
434 ////////////////////////////////////////////////////////////////////
435 INLINE bool GraphicsStateGuardian::
437  return _supports_texture_dot3;
438 }
439 
440 ////////////////////////////////////////////////////////////////////
441 // Function: GraphicsStateGuardian::get_supports_3d_texture
442 // Access: Published
443 // Description: Returns true if this GSG can render 3-d (volumetric)
444 // textures.
445 ////////////////////////////////////////////////////////////////////
446 INLINE bool GraphicsStateGuardian::
448  return _supports_3d_texture;
449 }
450 
451 ////////////////////////////////////////////////////////////////////
452 // Function: GraphicsStateGuardian::get_supports_2d_texture_array
453 // Access: Published
454 // Description: Returns true if this GSG can render 2-d textures
455 // array.
456 ////////////////////////////////////////////////////////////////////
457 INLINE bool GraphicsStateGuardian::
459  return _supports_2d_texture_array;
460 }
461 
462 ////////////////////////////////////////////////////////////////////
463 // Function: GraphicsStateGuardian::get_supports_cube_map
464 // Access: Published
465 // Description: Returns true if this GSG can render cube map textures.
466 ////////////////////////////////////////////////////////////////////
467 INLINE bool GraphicsStateGuardian::
469  return _supports_cube_map;
470 }
471 
472 ////////////////////////////////////////////////////////////////////
473 // Function: GraphicsStateGuardian::get_supports_tex_non_pow2
474 // Access: Published
475 // Description: Returns true if this GSG can handle non power of two
476 // sized textures.
477 ////////////////////////////////////////////////////////////////////
478 INLINE bool GraphicsStateGuardian::
480  return _supports_tex_non_pow2;
481 }
482 
483 ////////////////////////////////////////////////////////////////////
484 // Function: GraphicsStateGuardian::get_supports_texture_srgb
485 // Access: Published
486 // Description: Returns true if this GSG can handle sRGB textures.
487 ////////////////////////////////////////////////////////////////////
488 INLINE bool GraphicsStateGuardian::
490  return _supports_texture_srgb;
491 }
492 
493 ////////////////////////////////////////////////////////////////////
494 // Function: GraphicsStateGuardian::get_supports_compressed_texture
495 // Access: Published
496 // Description: Returns true if this GSG can compress textures as it
497 // loads them into texture memory, and/or accept
498 // pre-compressed textures for storing.
499 ////////////////////////////////////////////////////////////////////
500 INLINE bool GraphicsStateGuardian::
502  return _supports_compressed_texture;
503 }
504 
505 ////////////////////////////////////////////////////////////////////
506 // Function: GraphicsStateGuardian::get_supports_compressed_texture_format
507 // Access: Published, Virtual
508 // Description: Returns true if this GSG can accept textures
509 // pre-compressed in the indicated format.
510 // compression_mode may be any of the
511 // Texture::CompressionMode enums.
512 ////////////////////////////////////////////////////////////////////
513 INLINE bool GraphicsStateGuardian::
514 get_supports_compressed_texture_format(int compression_mode) const {
515  return _compressed_texture_formats.get_bit(compression_mode);
516 }
517 
518 ////////////////////////////////////////////////////////////////////
519 // Function: GraphicsStateGuardian::get_max_lights
520 // Access: Published
521 // Description: Returns the maximum number of simultaneous lights
522 // that may be rendered on geometry, or -1 if there is
523 // no particular limit.
524 //
525 // The value returned may not be meaningful until after
526 // the graphics context has been fully created (e.g. the
527 // window has been opened).
528 ////////////////////////////////////////////////////////////////////
529 INLINE int GraphicsStateGuardian::
530 get_max_lights() const {
531  return _max_lights;
532 }
533 
534 ////////////////////////////////////////////////////////////////////
535 // Function: GraphicsStateGuardian::get_max_clip_planes
536 // Access: Published
537 // Description: Returns the maximum number of simultaneous clip planes
538 // that may be applied to geometry, or -1 if there is
539 // no particular limit.
540 //
541 // The value returned may not be meaningful until after
542 // the graphics context has been fully created (e.g. the
543 // window has been opened).
544 ////////////////////////////////////////////////////////////////////
545 INLINE int GraphicsStateGuardian::
547  return _max_clip_planes;
548 }
549 
550 ////////////////////////////////////////////////////////////////////
551 // Function: GraphicsStateGuardian::get_max_vertex_transforms
552 // Access: Published
553 // Description: Returns the maximum number of transform matrices that
554 // may be simultaneously used to transform any one
555 // vertex by the graphics hardware. If this number is
556 // 0, then the hardware (or the graphics backend)
557 // doesn't support soft-skinned vertices (in which case
558 // Panda will animate the vertices in software).
559 //
560 // The value returned may not be meaningful until after
561 // the graphics context has been fully created (e.g. the
562 // window has been opened).
563 ////////////////////////////////////////////////////////////////////
564 INLINE int GraphicsStateGuardian::
566  return _max_vertex_transforms;
567 }
568 
569 ////////////////////////////////////////////////////////////////////
570 // Function: GraphicsStateGuardian::get_max_vertex_transform_indices
571 // Access: Published
572 // Description: Returns the maximum number of transforms there may be
573 // in a single TransformTable for this graphics
574 // hardware. If this number is 0 (but
575 // get_max_transforms() is nonzero), then the graphics
576 // hardware (or API) doesn't support indexed transforms,
577 // but can support direct transform references.
578 //
579 // The value returned may not be meaningful until after
580 // the graphics context has been fully created (e.g. the
581 // window has been opened).
582 ////////////////////////////////////////////////////////////////////
583 INLINE int GraphicsStateGuardian::
585  return _max_vertex_transform_indices;
586 }
587 
588 ////////////////////////////////////////////////////////////////////
589 // Function: GraphicsStateGuardian::get_copy_texture_inverted
590 // Access: Published
591 // Description: Returns true if this particular GSG has the property
592 // that any framebuffer-to-texture copy results in a
593 // texture that is upside-down and backwards from
594 // Panda's usual convention; that is, it copies into a
595 // texture from the bottom up instead of from the top
596 // down.
597 //
598 // If this is true, then on offscreen GraphicsBuffer
599 // created for the purposes of rendering into a texture
600 // should be created with the invert flag set true, to
601 // compensate. Panda will do this automatically if you
602 // create an offscreen buffer using
603 // GraphicsOutput::make_texture_buffer().
604 ////////////////////////////////////////////////////////////////////
605 INLINE bool GraphicsStateGuardian::
607  // If this is set from a Config variable, that overrides.
608  if (copy_texture_inverted.has_value()) {
609  return copy_texture_inverted;
610  }
611 
612  // Otherwise, use whatever behavior the GSG figured for itself.
613  return _copy_texture_inverted;
614 }
615 
616 ////////////////////////////////////////////////////////////////////
617 // Function: GraphicsStateGuardian::get_supports_generate_mipmap
618 // Access: Published
619 // Description: Returns true if this particular GSG can generate
620 // mipmaps for a texture automatically, or if they must
621 // be generated in software. If this is true, then
622 // mipmaps can safely be enabled for rendered textures
623 // (e.g. using the MultitexReducer).
624 ////////////////////////////////////////////////////////////////////
625 INLINE bool GraphicsStateGuardian::
627  return _supports_generate_mipmap;
628 }
629 
630 ////////////////////////////////////////////////////////////////////
631 // Function: GraphicsStateGuardian::get_supports_depth_texture
632 // Access: Published
633 // Description: Returns true if this particular GSG supports
634 // textures whose format is F_depth_stencil. This
635 // returns true if the GSG supports GL_DEPTH_COMPONENT
636 // textures, which are considered a limited but still
637 // valid case of F_depth_stencil.
638 ////////////////////////////////////////////////////////////////////
639 INLINE bool GraphicsStateGuardian::
641  return _supports_depth_texture;
642 }
643 
644 ////////////////////////////////////////////////////////////////////
645 // Function: GraphicsStateGuardian::get_supports_depth_stencil
646 // Access: Published
647 // Description: Returns true if this particular GSG supports
648 // textures whose format is F_depth_stencil. This
649 // only returns true if the GSG supports the full
650 // packed depth-stencil functionality.
651 ////////////////////////////////////////////////////////////////////
652 INLINE bool GraphicsStateGuardian::
654  return _supports_depth_stencil;
655 }
656 
657 ////////////////////////////////////////////////////////////////////
658 // Function: GraphicsStateGuardian::get_supports_shadow_filter
659 // Access: Published
660 // Description: Returns true if this particular GSG supports
661 // the filter mode FT_shadow for depth textures.
662 ////////////////////////////////////////////////////////////////////
663 INLINE bool GraphicsStateGuardian::
665  return _supports_shadow_filter;
666 }
667 
668 ////////////////////////////////////////////////////////////////////
669 // Function: GraphicsStateGuardian::get_supports_sampler_objects
670 // Access: Published
671 // Description: Returns true if this particular GSG supports the
672 // use of sampler objects to record texture sampling
673 // parameters separately from the texture objects.
674 // This doesn't really affect functionality, but if
675 // this is false, it may mean that using the same
676 // texture with different SamplerState objects will
677 // result in reduced performance.
678 ////////////////////////////////////////////////////////////////////
679 INLINE bool GraphicsStateGuardian::
681  return _supports_sampler_objects;
682 }
683 
684 ////////////////////////////////////////////////////////////////////
685 // Function: GraphicsStateGuardian::get_supports_basic_shaders
686 // Access: Published
687 // Description: Returns true if this particular GSG supports
688 // arbfp1+arbvp1 or above.
689 ////////////////////////////////////////////////////////////////////
690 INLINE bool GraphicsStateGuardian::
692  return _supports_basic_shaders;
693 }
694 
695 ////////////////////////////////////////////////////////////////////
696 // Function: GraphicsStateGuardian::get_supports_geometry_shaders
697 // Access: Published
698 // Description: Returns true if this particular GSG supports
699 // geometry shaders.
700 ////////////////////////////////////////////////////////////////////
701 INLINE bool GraphicsStateGuardian::
703  return _supports_geometry_shaders;
704 }
705 
706 ////////////////////////////////////////////////////////////////////
707 // Function: GraphicsStateGuardian::get_supports_tessellation_shaders
708 // Access: Published
709 // Description: Returns true if this particular GSG supports
710 // tesselation shaders.
711 ////////////////////////////////////////////////////////////////////
712 INLINE bool GraphicsStateGuardian::
714  return _supports_tessellation_shaders;
715 }
716 
717 ////////////////////////////////////////////////////////////////////
718 // Function: GraphicsStateGuardian::get_supports_compute_shaders
719 // Access: Published
720 // Description: Returns true if this particular GSG supports
721 // compute shaders.
722 ////////////////////////////////////////////////////////////////////
723 INLINE bool GraphicsStateGuardian::
725  return _supports_compute_shaders;
726 }
727 
728 ////////////////////////////////////////////////////////////////////
729 // Function: GraphicsStateGuardian::get_supports_glsl
730 // Access: Published
731 // Description: Returns true if this particular GSG supports
732 // GLSL shaders.
733 ////////////////////////////////////////////////////////////////////
734 INLINE bool GraphicsStateGuardian::
736  return _supports_glsl;
737 }
738 
739 ////////////////////////////////////////////////////////////////////
740 // Function: GraphicsStateGuardian::get_supports_stencil
741 // Access: Published
742 // Description: Returns true if this particular GSG supports
743 // stencil buffers at all.
744 ////////////////////////////////////////////////////////////////////
745 INLINE bool GraphicsStateGuardian::
747  return _supports_stencil;
748 }
749 
750 ////////////////////////////////////////////////////////////////////
751 // Function: GraphicsStateGuardian::get_supports_two_sided_stencil
752 // Access: Published
753 // Description: Returns true if this particular GSG supports
754 // two sided stencil: different stencil settings for the
755 // front and back side of the same polygon.
756 ////////////////////////////////////////////////////////////////////
757 INLINE bool GraphicsStateGuardian::
759  return _supports_two_sided_stencil;
760 }
761 
762 ////////////////////////////////////////////////////////////////////
763 // Function: GraphicsStateGuardian::get_supports_geometry_instancing
764 // Access: Published
765 // Description: Returns true if this particular GSG supports
766 // hardware geometry instancing: the ability to render
767 // multiple copies of a model. In OpenGL, this is
768 // done using the EXT_draw_instanced extension.
769 ////////////////////////////////////////////////////////////////////
770 INLINE bool GraphicsStateGuardian::
772  return _supports_geometry_instancing;
773 }
774 
775 ////////////////////////////////////////////////////////////////////
776 // Function: GraphicsStateGuardian::get_supports_occlusion_query
777 // Access: Published
778 // Description: Returns true if this GSG supports an occlusion query.
779 // If this is true, then begin_occlusion_query() and
780 // end_occlusion_query() may be called to bracket a
781 // sequence of draw_triangles() (or whatever) calls to
782 // measure pixels that pass the depth test.
783 ////////////////////////////////////////////////////////////////////
786  return _supports_occlusion_query;
787 }
788 
789 ////////////////////////////////////////////////////////////////////
790 // Function: GraphicsStateGuardian::get_supports_timer_query
791 // Access: Published
792 // Description: Returns true if this GSG supports a timer query.
793 ////////////////////////////////////////////////////////////////////
796  return _supports_timer_query;
797 }
798 
799 ////////////////////////////////////////////////////////////////////
800 // Function: GraphicsStateGuardian::get_timer_queries_active
801 // Access: Published
802 // Description: Returns true if timer queries are currently
803 // enabled on this GSG.
804 ////////////////////////////////////////////////////////////////////
807 #ifdef DO_PSTATS
808  return _timer_queries_active;
809 #else
810  return false;
811 #endif
812 }
813 
814 ////////////////////////////////////////////////////////////////////
815 // Function: GraphicsStateGuardian::get_max_color_targets
816 // Access: Published
817 // Description: Returns the maximum number of simultaneous color
818 // textures that may be attached for render-to-texture,
819 // as supported by this particular GSG. If you exceed
820 // this number, the lowest-priority render targets will
821 // not be applied. Use RenderTarget::set_priority() to
822 // adjust the relative importance of the different
823 // render targets.
824 //
825 // The value returned may not be meaningful until after
826 // the graphics context has been fully created (e.g. the
827 // window has been opened).
828 ////////////////////////////////////////////////////////////////////
829 INLINE int GraphicsStateGuardian::
831  if (max_color_targets > 0) {
832  return min(_max_color_targets, (int)max_color_targets);
833  }
834  return _max_color_targets;
835 }
836 
837 ////////////////////////////////////////////////////////////////////
838 // Function: GraphicsStateGuardian::get_maximum_simultaneous_render_targets
839 // Access: Published
840 // Description: Deprecated. Use get_max_color_targets() instead,
841 // which returns the exact same value.
842 ////////////////////////////////////////////////////////////////////
843 INLINE int GraphicsStateGuardian::
845  return get_max_color_targets();
846 }
847 
848 ////////////////////////////////////////////////////////////////////
849 // Function: GraphicsStateGuardian::get_shader_model
850 // Access: Published
851 // Description: Returns the ShaderModel
852 ////////////////////////////////////////////////////////////////////
853 INLINE int GraphicsStateGuardian::
855  return _shader_model;
856 }
857 
858 ////////////////////////////////////////////////////////////////////
859 // Function: GraphicsStateGuardian::set_shader_model
860 // Access: Published
861 // Description: Sets the ShaderModel. This will override the auto-
862 // detected shader model during GSG reset. Useful for
863 // testing lower-end shaders.
864 ////////////////////////////////////////////////////////////////////
865 INLINE void GraphicsStateGuardian::
866 set_shader_model(int shader_model) {
867  if (shader_model <= _auto_detect_shader_model) {
868  _shader_model = shader_model;
869  }
870 }
871 
872 ////////////////////////////////////////////////////////////////////
873 // Function: GraphicsStateGuardian::get_color_scale_via_lighting
874 // Access: Published
875 // Description: Returns true if this particular GSG can implement (or
876 // would prefer to implement) set color and/or color
877 // scale using materials and/or ambient lights, or
878 // false if we need to actually munge the color.
879 ////////////////////////////////////////////////////////////////////
880 INLINE bool GraphicsStateGuardian::
882  return _color_scale_via_lighting;
883 }
884 
885 ////////////////////////////////////////////////////////////////////
886 // Function: GraphicsStateGuardian::get_alpha_scale_via_texture
887 // Access: Published
888 // Description: Returns true if this particular GSG can implement (or
889 // would prefer to implement) an alpha scale via an
890 // additional Texture layer, or false if we need to
891 // actually munge the alpha.
892 ////////////////////////////////////////////////////////////////////
893 INLINE bool GraphicsStateGuardian::
895  return _alpha_scale_via_texture;
896 }
897 
898 ////////////////////////////////////////////////////////////////////
899 // Function: GraphicsStateGuardian::get_alpha_scale_via_texture
900 // Access: Published
901 // Description: This variant of get_alpha_scale_via_texture() answers
902 // the question of whether the GSG can implement an
903 // alpha scale via an additional Texture layer,
904 // considering the current TextureAttrib that will be in
905 // effect. This considers whether there is at least one
906 // additional texture slot available on the GSG.
907 ////////////////////////////////////////////////////////////////////
908 INLINE bool GraphicsStateGuardian::
909 get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const {
910  return _alpha_scale_via_texture &&
911  (tex_attrib == (const TextureAttrib *)NULL ||
912  tex_attrib->get_num_on_stages() < get_max_texture_stages());
913 }
914 
915 ////////////////////////////////////////////////////////////////////
916 // Function: GraphicsStateGuardian::get_alpha_scale_texture_stage
917 // Access: Published, Static
918 // Description: Returns the TextureStage that will be used to apply
919 // an alpha scale, if get_alpha_scale_via_texture()
920 // returns true.
921 ////////////////////////////////////////////////////////////////////
924  if (_alpha_scale_texture_stage == (TextureStage *)NULL) {
925  _alpha_scale_texture_stage = new TextureStage("alpha-scale");
926  _alpha_scale_texture_stage->set_sort(1000000000);
927  }
928  return _alpha_scale_texture_stage;
929 }
930 
931 ////////////////////////////////////////////////////////////////////
932 // Function: GraphicsStateGuardian::get_runtime_color_scale
933 // Access: Published
934 // Description: Returns true if this particular GSG can implement (or
935 // would prefer to implement) set color and/or color
936 // scale directly, without requiring any munging of
937 // vertices or tricks with lighting.
938 ////////////////////////////////////////////////////////////////////
939 INLINE bool GraphicsStateGuardian::
941  return _runtime_color_scale;
942 }
943 
944 ////////////////////////////////////////////////////////////////////
945 // Function: GraphicsStateGuardian::get_coordinate_system
946 // Access: Published
947 // Description: Returns the coordinate system in effect on this
948 // particular gsg. Normally, this will be the default
949 // coordinate system, but it might be set differently at
950 // runtime.
951 ////////////////////////////////////////////////////////////////////
952 INLINE CoordinateSystem GraphicsStateGuardian::
954  return _coordinate_system;
955 }
956 
957 ////////////////////////////////////////////////////////////////////
958 // Function: GraphicsStateGuardian::set_texture_quality_override
959 // Access: Published
960 // Description: Specifies the global quality_level to be imposed for
961 // all Textures rendered by this GSG. This overrides
962 // the value set on individual textures via
963 // Texture::set_quality_level(). Set this to
964 // Texture::QL_default in order to allow the individual
965 // texture quality levels to be respected.
966 //
967 // This is mainly useful for the tinydisplay software
968 // renderer. See Texture::set_quality_level().
969 ////////////////////////////////////////////////////////////////////
970 INLINE void GraphicsStateGuardian::
971 set_texture_quality_override(Texture::QualityLevel quality_level) {
972  _texture_quality_override = quality_level;
973 }
974 
975 ////////////////////////////////////////////////////////////////////
976 // Function: GraphicsStateGuardian::get_texture_quality_override
977 // Access: Published
978 // Description: Returns the global quality_level override specified
979 // by set_texture_quality_override.
980 //
981 // This is mainly useful for the tinydisplay software
982 // renderer. See Texture::set_quality_level().
983 ////////////////////////////////////////////////////////////////////
984 INLINE Texture::QualityLevel GraphicsStateGuardian::
986  return _texture_quality_override;
987 }
988 
989 ////////////////////////////////////////////////////////////////////
990 // Function: GraphicsStateGuardian::reset_if_new
991 // Access: Public
992 // Description: Calls reset() to initialize the GSG, but only if it
993 // hasn't been called yet. Returns true if the GSG was
994 // new, false otherwise.
995 ////////////////////////////////////////////////////////////////////
996 INLINE bool GraphicsStateGuardian::
998  if (_needs_reset) {
999  reset();
1000  return true;
1001  }
1002  return false;
1003 }
1004 
1005 ////////////////////////////////////////////////////////////////////
1006 // Function: GraphicsStateGuardian::mark_new
1007 // Access: Public
1008 // Description: Marks the GSG as "new", so that the next call to
1009 // reset_if_new() will be effective.
1010 ////////////////////////////////////////////////////////////////////
1011 INLINE void GraphicsStateGuardian::
1013  _needs_reset = true;
1014 }
1015 
1016 ////////////////////////////////////////////////////////////////////
1017 // Function: GraphicsStateGuardian::get_external_transform
1018 // Access: Public
1019 // Description: Fetches the external net transform. This
1020 // transform is generally only set when geometry is
1021 // about to be rendered. Therefore, this "get" function
1022 // is typically only meaningful during the geometry
1023 // rendering process.
1024 ////////////////////////////////////////////////////////////////////
1025 INLINE CPT(TransformState) GraphicsStateGuardian::
1026 get_external_transform() const {
1027  return _inv_cs_transform->compose(_internal_transform);
1028 }
1029 
1030 ////////////////////////////////////////////////////////////////////
1031 // Function: GraphicsStateGuardian::get_internal_transform
1032 // Access: Public
1033 // Description: Fetches the external net transform. This
1034 // transform is generally only set when geometry is
1035 // about to be rendered. Therefore, this "get" function
1036 // is typically only meaningful during the geometry
1037 // rendering process.
1038 ////////////////////////////////////////////////////////////////////
1039 INLINE CPT(TransformState) GraphicsStateGuardian::
1040 get_internal_transform() const {
1041  return _internal_transform;
1042 }
1043 
1044 ////////////////////////////////////////////////////////////////////
1045 // Function: GraphicsStateGuardian::get_current_display_region
1046 // Access: Public
1047 // Description: Returns the current display region being rendered to,
1048 // as set by the last call to prepare_display_region().
1049 ////////////////////////////////////////////////////////////////////
1050 INLINE const DisplayRegion *GraphicsStateGuardian::
1051 get_current_display_region() const {
1052  return _current_display_region;
1053 }
1054 
1055 ////////////////////////////////////////////////////////////////////
1056 // Function: GraphicsStateGuardian::get_current_stereo_channel
1057 // Access: Public
1058 // Description: Returns the current stereo channel being rendered to,
1059 // as set by the last call to prepare_display_region().
1060 ////////////////////////////////////////////////////////////////////
1061 INLINE Lens::StereoChannel GraphicsStateGuardian::
1062 get_current_stereo_channel() const {
1063  return _current_stereo_channel;
1064 }
1065 
1066 ////////////////////////////////////////////////////////////////////
1067 // Function: GraphicsStateGuardian::get_current_tex_view_offset
1068 // Access: Public
1069 // Description: Returns the current tex view offset, as set by the
1070 // last call to prepare_display_region(). This is read
1071 // from the current DisplayRegion.
1072 ////////////////////////////////////////////////////////////////////
1073 INLINE int GraphicsStateGuardian::
1074 get_current_tex_view_offset() const {
1075  return _current_tex_view_offset;
1076 }
1077 
1078 ////////////////////////////////////////////////////////////////////
1079 // Function: GraphicsStateGuardian::get_current_lens
1080 // Access: Public
1081 // Description: Returns the current lens being used to render,
1082 // according to the scene specified via the last call to
1083 // set_scene().
1084 ////////////////////////////////////////////////////////////////////
1085 INLINE const Lens *GraphicsStateGuardian::
1086 get_current_lens() const {
1087  return _current_lens;
1088 }
1089 
1090 ////////////////////////////////////////////////////////////////////
1091 // Function: GraphicsStateGuardian::get_inv_cs_transform
1092 // Access: Public
1093 // Description: Returns the inverse of the transform returned by
1094 // get_cs_transform().
1095 ////////////////////////////////////////////////////////////////////
1096 INLINE CPT(TransformState) GraphicsStateGuardian::
1097 get_inv_cs_transform() const {
1098  return _inv_cs_transform;
1099 }
1100 
1101 ////////////////////////////////////////////////////////////////////
1102 // Function: GraphicsStateGuardian::set_current_properties
1103 // Access: Protected
1104 // Description: Notifies the gsg that it is about to render into a
1105 // window/buffer with the given FrameBufferProperties
1106 ////////////////////////////////////////////////////////////////////
1107 INLINE void GraphicsStateGuardian::
1108 set_current_properties(const FrameBufferProperties *prop) {
1109  _current_properties = prop;
1110 }
1111 
void set_texture_quality_override(Texture::QualityLevel quality_level)
Specifies the global quality_level to be imposed for all Textures rendered by this GSG...
bool get_supports_depth_stencil() const
Returns true if this particular GSG supports textures whose format is F_depth_stencil.
bool get_supports_texture_combine() const
Returns true if this particular GSG can use the TextureStage::M_combine mode, which includes all of t...
virtual bool get_effective_incomplete_render() const
Returns true if the GSG is effectively in incomplete_render state, considering both the GSG&#39;s incompl...
virtual int get_max_texture_dimension() const
Returns the largest possible texture size in any one dimension supported by the GSG, or -1 if there is no particular limit.
bool get_supports_texture_saved_result() const
Returns true if this GSG can use the TextureStage::CS_last_saved_result source, which allows you to s...
bool get_runtime_color_scale() const
Returns true if this particular GSG can implement (or would prefer to implement) set color and/or col...
void set_loader(Loader *loader)
Sets the Loader object that will be used by this GSG to load textures when necessary, if get_incomplete_render() is true.
bool get_supports_geometry_instancing() const
Returns true if this particular GSG supports hardware geometry instancing: the ability to render mult...
int get_max_2d_texture_array_layers() const
Returns the largest possible number of pages, or -1 if there is no particular limit.
virtual bool prefers_triangle_strips() const
Returns true if this GSG strongly prefers triangle strips to individual triangles (such as SGI)...
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
bool get_color_scale_via_lighting() const
Returns true if this particular GSG can implement (or would prefer to implement) set color and/or col...
int get_maximum_simultaneous_render_targets() const
Deprecated.
GraphicsPipe * get_pipe() const
Returns the graphics pipe on which this GSG was created.
bool get_supports_shadow_filter() const
Returns true if this particular GSG supports the filter mode FT_shadow for depth textures.
bool get_supports_occlusion_query() const
Returns true if this GSG supports an occlusion query.
bool get_supports_glsl() const
Returns true if this particular GSG supports GLSL shaders.
virtual int get_max_vertices_per_primitive() const
Returns the maximum number of vertex indices that should be put into any one GeomPrimitive object for...
void release_all()
Releases all prepared objects.
bool get_supports_depth_texture() const
Returns true if this particular GSG supports textures whose format is F_depth_stencil.
bool reset_if_new()
Calls reset() to initialize the GSG, but only if it hasn&#39;t been called yet.
int release_all_textures()
Frees the resources for all textures associated with this GSG.
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
Definition: loader.h:47
ShaderGenerator * get_shader_generator() const
Returns the ShaderGenerator object that will be used by this GSG to generate shaders when necessary...
int get_max_lights() const
Returns the maximum number of simultaneous lights that may be rendered on geometry, or -1 if there is no particular limit.
void set_shader_model(int shader_model)
Sets the ShaderModel.
CoordinateSystem get_coordinate_system() const
Returns the coordinate system in effect on this particular gsg.
void set_active(bool active)
Sets the active flag associated with the GraphicsStateGuardian.
bool get_supports_compressed_texture() const
Returns true if this GSG can compress textures as it loads them into texture memory, and/or accept pre-compressed textures for storing.
bool get_supports_generate_mipmap() const
Returns true if this particular GSG can generate mipmaps for a texture automatically, or if they must be generated in software.
bool is_hardware() const
Returns true if this GSG appears to be hardware-accelerated, or false if it is known to be software o...
int get_shader_model() const
Returns the ShaderModel.
Loader * get_loader() const
Returns the Loader object that will be used by this GSG to load textures when necessary, if get_incomplete_render() is true.
bool get_alpha_scale_via_texture() const
Returns true if this particular GSG can implement (or would prefer to implement) an alpha scale via a...
int get_max_clip_planes() const
Returns the maximum number of simultaneous clip planes that may be applied to geometry, or -1 if there is no particular limit.
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
Definition: textureAttrib.h:34
bool get_supports_texture_srgb() const
Returns true if this GSG can handle sRGB textures.
int get_max_3d_texture_dimension() const
Returns the largest possible texture size in any one dimension for a 3-d texture, or -1 if there is n...
int get_max_vertex_transforms() const
Returns the maximum number of transform matrices that may be simultaneously used to transform any one...
bool get_bit(int index) const
Returns true if the nth bit is set, false if it is cleared.
Definition: bitMask.I:212
int get_max_texture_stages() const
Returns the maximum number of simultaneous textures that may be applied to geometry with multitexturi...
Texture::QualityLevel get_texture_quality_override() const
Returns the global quality_level override specified by set_texture_quality_override.
void set_incomplete_render(bool incomplete_render)
Sets the incomplete_render flag.
void mark_new()
Marks the GSG as "new", so that the next call to reset_if_new() will be effective.
int get_max_cube_map_dimension() const
Returns the largest possible texture size in any one dimension for a cube map texture, or -1 if there is no particular limit.
bool get_supports_geometry_shaders() const
Returns true if this particular GSG supports geometry shaders.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
The ShaderGenerator is a device that effectively replaces the classic fixed function pipeline with a ...
bool get_supports_timer_query() const
Returns true if this GSG supports a timer query.
This represents the user&#39;s specification of how a particular frame is handled by the various threads...
bool is_active() const
Returns the active flag associated with the GraphicsStateGuardian.
int get_max_color_targets() const
Returns the maximum number of simultaneous color textures that may be attached for render-to-texture...
bool get_supports_2d_texture_array() const
Returns true if this GSG can render 2-d textures array.
int release_all_geoms()
Frees the resources for all geoms associated with this GSG.
virtual bool get_supports_compressed_texture_format(int compression_mode) const
Returns true if this GSG can accept textures pre-compressed in the indicated format.
bool get_supports_tessellation_shaders() const
Returns true if this particular GSG supports tesselation shaders.
bool get_supports_sampler_objects() const
Returns true if this particular GSG supports the use of sampler objects to record texture sampling pa...
bool get_timer_queries_active() const
Returns true if timer queries are currently enabled on this GSG.
bool has_value() const
Returns true if this variable has an explicit value, either from a prc file or locally set...
bool get_supports_stencil() const
Returns true if this particular GSG supports stencil buffers at all.
void set_shader_generator(ShaderGenerator *shader_generator)
Sets the ShaderGenerator object that will be used by this GSG to generate shaders when necessary...
virtual bool get_incomplete_render() const
Returns the incomplete_render flag.
bool get_supports_basic_shaders() const
Returns true if this particular GSG supports arbfp1+arbvp1 or above.
bool is_valid() const
Returns true if the GSG has been correctly initialized within a graphics context, false if there has ...
int release_all_index_buffers()
Frees the resources for all index buffers associated with this GSG.
bool get_copy_texture_inverted() const
Returns true if this particular GSG has the property that any framebuffer-to-texture copy results in ...
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:61
bool needs_reset() const
Returns true if the gsg is marked as needing a reset.
int release_all_vertex_buffers()
Frees the resources for all vertex buffers associated with this GSG.
int release_all_samplers()
Frees the resources for all samplers associated with this GSG.
bool get_supports_compute_shaders() const
Returns true if this particular GSG supports compute shaders.
int get_max_vertex_transform_indices() const
Returns the maximum number of transforms there may be in a single TransformTable for this graphics ha...
virtual void reset()
Resets all internal state as if the gsg were newly created.
virtual int get_max_vertices_per_array() const
Returns the maximum number of vertices that should be put into any one GeomVertexData object for use ...
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:38
static TextureStage * get_alpha_scale_texture_stage()
Returns the TextureStage that will be used to apply an alpha scale, if get_alpha_scale_via_texture() ...
bool get_supports_two_sided_stencil() const
Returns true if this particular GSG supports two sided stencil: different stencil settings for the fr...
bool get_supports_texture_dot3() const
Returns true if this GSG can use the TextureStage::CM_dot3_rgb or CM_dot3_rgba combine modes...
const GraphicsThreadingModel & get_threading_model() const
Returns the threading model that was used to create this GSG.
bool get_supports_3d_texture() const
Returns true if this GSG can render 3-d (volumetric) textures.
bool get_supports_cube_map() const
Returns true if this GSG can render cube map textures.
bool get_supports_tex_non_pow2() const
Returns true if this GSG can handle non power of two sized textures.