Sfoglia il codice sorgente

Add interface and abstract representation for shader models.

aignacio_sf 19 anni fa
parent
commit
f15e24ed3e

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

@@ -536,6 +536,30 @@ get_supports_two_sided_stencil() const {
   return _supports_two_sided_stencil;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::get_shader_model
+//       Access: Published
+//  Description: Returns the ShaderModel
+////////////////////////////////////////////////////////////////////
+INLINE int GraphicsStateGuardian::
+get_shader_model() const {
+  return _shader_model;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::set_shader_model
+//       Access: Published
+//  Description: Sets the ShaderModel.  This will override the auto-
+//               detected shader model during GSG reset.  Useful for
+//               testing lower-end shaders.
+////////////////////////////////////////////////////////////////////
+INLINE void GraphicsStateGuardian::
+set_shader_model(int shader_model) {
+  if (shader_model <= _auto_detect_shader_model) {
+    _shader_model = shader_model;
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::get_color_scale_via_lighting
 //       Access: Published

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

@@ -164,6 +164,10 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system,
   _color_scale_via_lighting = color_scale_via_lighting;
 
   _stencil_render_states = 0;
+
+  // The default is no shader support.
+  _auto_detect_shader_model = SM_00;
+  _shader_model = SM_00;
 }
 
 ////////////////////////////////////////////////////////////////////

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

@@ -72,6 +72,17 @@ public:
   virtual ~GraphicsStateGuardian();
 
 PUBLISHED:
+
+  enum ShaderModel
+  {
+    SM_00,
+    SM_11,
+    SM_20,
+    SM_2X,
+    SM_30,
+    SM_40,
+  };
+
   INLINE void release_all();
   INLINE int release_all_textures();
   INLINE int release_all_geoms();
@@ -122,6 +133,9 @@ PUBLISHED:
   INLINE bool get_supports_basic_shaders() const;
   INLINE bool get_supports_two_sided_stencil() const;
 
+  INLINE int get_shader_model() const;
+  INLINE void set_shader_model(int shader_model);
+
   virtual int get_supported_geom_rendering() const;
 
   INLINE bool get_color_scale_via_lighting() const;
@@ -374,6 +388,9 @@ protected:
 
   StencilRenderStates *_stencil_render_states;
 
+  int _auto_detect_shader_model;
+  int _shader_model;
+
 public:
   // Statistics
   static PStatCollector _vertex_buffer_switch_pcollector;