Browse Source

GSG::is_hardware()

David Rose 17 years ago
parent
commit
bed33fb763

+ 12 - 0
panda/src/display/graphicsStateGuardian.I

@@ -141,6 +141,18 @@ get_threading_model() const {
   return _threading_model;
   return _threading_model;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::is_hardware
+//       Access: Published
+//  Description: Returns true if this GSG appears to be
+//               hardware-accelerated, or false if it is known to be
+//               software only.
+////////////////////////////////////////////////////////////////////
+INLINE bool GraphicsStateGuardian::
+is_hardware() const {
+  return _is_hardware;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::prefers_triangle_strips
 //     Function: GraphicsStateGuardian::prefers_triangle_strips
 //       Access: Published, Virtual
 //       Access: Published, Virtual

+ 1 - 0
panda/src/display/graphicsStateGuardian.cxx

@@ -136,6 +136,7 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system,
   _prepared_objects = new PreparedGraphicsObjects;
   _prepared_objects = new PreparedGraphicsObjects;
   _stereo_buffer_mask = ~0;
   _stereo_buffer_mask = ~0;
 
 
+  _is_hardware = false;
   _prefers_triangle_strips = false;
   _prefers_triangle_strips = false;
   _max_vertices_per_array = INT_MAX;
   _max_vertices_per_array = INT_MAX;
   _max_vertices_per_primitive = INT_MAX;
   _max_vertices_per_primitive = INT_MAX;

+ 2 - 0
panda/src/display/graphicsStateGuardian.h

@@ -98,6 +98,7 @@ PUBLISHED:
   INLINE GraphicsEngine *get_engine() const;
   INLINE GraphicsEngine *get_engine() const;
   INLINE const GraphicsThreadingModel &get_threading_model() const;
   INLINE const GraphicsThreadingModel &get_threading_model() const;
 
 
+  INLINE bool is_hardware() const;
   virtual INLINE bool prefers_triangle_strips() const;
   virtual INLINE bool prefers_triangle_strips() const;
   virtual INLINE int get_max_vertices_per_array() const;
   virtual INLINE int get_max_vertices_per_array() const;
   virtual INLINE int get_max_vertices_per_primitive() const;
   virtual INLINE int get_max_vertices_per_primitive() const;
@@ -356,6 +357,7 @@ protected:
 
 
   PT(PreparedGraphicsObjects) _prepared_objects;
   PT(PreparedGraphicsObjects) _prepared_objects;
 
 
+  bool _is_hardware;
   bool _prefers_triangle_strips;
   bool _prefers_triangle_strips;
   int _max_vertices_per_array;
   int _max_vertices_per_array;
   int _max_vertices_per_primitive;
   int _max_vertices_per_primitive;

+ 4 - 0
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -85,6 +85,10 @@ DXGraphicsStateGuardian8::
 DXGraphicsStateGuardian8(GraphicsPipe *pipe) :
 DXGraphicsStateGuardian8(GraphicsPipe *pipe) :
   GraphicsStateGuardian(CS_yup_left, pipe)
   GraphicsStateGuardian(CS_yup_left, pipe)
 {
 {
+  // Assume that we will get a hardware-accelerated context, unless
+  // the window tells us otherwise.
+  _is_hardware = true;
+
   _screen = NULL;
   _screen = NULL;
   _d3d_device = NULL;
   _d3d_device = NULL;
 
 

+ 4 - 0
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -103,6 +103,10 @@ DXGraphicsStateGuardian9(GraphicsPipe *pipe) :
       << "DXGraphicsStateGuardian9 " << this << " constructing\n";
       << "DXGraphicsStateGuardian9 " << this << " constructing\n";
   }
   }
 
 
+  // Assume that we will get a hardware-accelerated context, unless
+  // the window tells us otherwise.
+  _is_hardware = true;
+
   _screen = NULL;
   _screen = NULL;
   _d3d_device = NULL;
   _d3d_device = NULL;
 
 

+ 4 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -254,6 +254,10 @@ CLP(GraphicsStateGuardian)(GraphicsPipe *pipe) :
   // performance benefit it gives us.
   // performance benefit it gives us.
   _prepared_objects->_support_released_buffer_cache = true;
   _prepared_objects->_support_released_buffer_cache = true;
 
 
+  // Assume that we will get a hardware-accelerated context, unless
+  // the window tells us otherwise.
+  _is_hardware = true;
+
 #ifdef DO_PSTATS
 #ifdef DO_PSTATS
   if (CLP(finish)) {
   if (CLP(finish)) {
     GLCAT.warning()
     GLCAT.warning()

+ 3 - 0
panda/src/mesadisplay/osMesaGraphicsStateGuardian.cxx

@@ -37,6 +37,9 @@ OSMesaGraphicsStateGuardian(GraphicsPipe *pipe,
   }
   }
 
 
   _context = OSMesaCreateContext(OSMESA_RGBA, share_context);
   _context = OSMesaCreateContext(OSMESA_RGBA, share_context);
+
+  // OSMesa is never hardware-accelerated.
+  _is_hardware = false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////