From f15e24ed3eb2b6b089a7046f5a09bdacd92e8adb Mon Sep 17 00:00:00 2001 From: aignacio_sf <> Date: Fri, 16 Jun 2006 22:31:36 +0000 Subject: [PATCH] Add interface and abstract representation for shader models. --- panda/src/display/graphicsStateGuardian.I | 24 +++++++++++++++++++++ panda/src/display/graphicsStateGuardian.cxx | 4 ++++ panda/src/display/graphicsStateGuardian.h | 17 +++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 7eeba7d601..573898f48e 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/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 diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 9cc9c2d666..408931d1cc 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/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; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index a0ce1ef89f..d818a12709 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/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;