From bed33fb7637fd3ca0643f44833e6909caa3f0753 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 14 May 2008 00:57:36 +0000 Subject: [PATCH] GSG::is_hardware() --- panda/src/display/graphicsStateGuardian.I | 12 ++++++++++++ panda/src/display/graphicsStateGuardian.cxx | 1 + panda/src/display/graphicsStateGuardian.h | 2 ++ panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 4 ++++ panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 4 ++++ panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 4 ++++ .../src/mesadisplay/osMesaGraphicsStateGuardian.cxx | 3 +++ 7 files changed, 30 insertions(+) diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 1df6adbc55..d9eaa17461 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -141,6 +141,18 @@ get_threading_model() const { 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 // Access: Published, Virtual diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index feaa6d4b9a..8ec0213e4b 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -136,6 +136,7 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, _prepared_objects = new PreparedGraphicsObjects; _stereo_buffer_mask = ~0; + _is_hardware = false; _prefers_triangle_strips = false; _max_vertices_per_array = INT_MAX; _max_vertices_per_primitive = INT_MAX; diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index ef29c1c1c6..baa5ea7594 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -98,6 +98,7 @@ PUBLISHED: INLINE GraphicsEngine *get_engine() const; INLINE const GraphicsThreadingModel &get_threading_model() const; + INLINE bool is_hardware() const; virtual INLINE bool prefers_triangle_strips() const; virtual INLINE int get_max_vertices_per_array() const; virtual INLINE int get_max_vertices_per_primitive() const; @@ -356,6 +357,7 @@ protected: PT(PreparedGraphicsObjects) _prepared_objects; + bool _is_hardware; bool _prefers_triangle_strips; int _max_vertices_per_array; int _max_vertices_per_primitive; diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index fd2e74b0b3..db0ced7941 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -85,6 +85,10 @@ DXGraphicsStateGuardian8:: DXGraphicsStateGuardian8(GraphicsPipe *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; _d3d_device = NULL; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index bd30df94f1..5e97d93105 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -103,6 +103,10 @@ DXGraphicsStateGuardian9(GraphicsPipe *pipe) : << "DXGraphicsStateGuardian9 " << this << " constructing\n"; } + // Assume that we will get a hardware-accelerated context, unless + // the window tells us otherwise. + _is_hardware = true; + _screen = NULL; _d3d_device = NULL; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index ace32c4bbf..90316a84d1 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -254,6 +254,10 @@ CLP(GraphicsStateGuardian)(GraphicsPipe *pipe) : // performance benefit it gives us. _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 if (CLP(finish)) { GLCAT.warning() diff --git a/panda/src/mesadisplay/osMesaGraphicsStateGuardian.cxx b/panda/src/mesadisplay/osMesaGraphicsStateGuardian.cxx index 19559e57d9..3a7066686c 100644 --- a/panda/src/mesadisplay/osMesaGraphicsStateGuardian.cxx +++ b/panda/src/mesadisplay/osMesaGraphicsStateGuardian.cxx @@ -37,6 +37,9 @@ OSMesaGraphicsStateGuardian(GraphicsPipe *pipe, } _context = OSMesaCreateContext(OSMESA_RGBA, share_context); + + // OSMesa is never hardware-accelerated. + _is_hardware = false; } ////////////////////////////////////////////////////////////////////