Panda3D

dxShaderContext9.h

00001 // Filename: dxShaderContext9.h
00002 // Created by: aignacio (Jan06)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef DXSHADERCONTEXT9_H
00016 #define DXSHADERCONTEXT9_H
00017 
00018 #include "dtool_config.h"
00019 #include "pandabase.h"
00020 #include "string_utils.h"
00021 #include "internalName.h"
00022 #include "shader.h"
00023 #include "shaderContext.h"
00024 
00025 
00026 #define CLP(name) DX##name##9
00027 #define CLASSPREFIX_QUOTED "DX"
00028 
00029 
00030 class VertexElementArray;
00031 class CLP(GraphicsStateGuardian);
00032 
00033 // Caution: adding HLSL support is going to be tricky, as the parsing needs
00034 // to be done in the cull thread, which cannot use the DX API.  - Josh
00035 //
00036 //
00037 // typedef struct
00038 // {
00039 //   int vertex_shader;
00040 //   int total_constant_descriptions;
00041 //   D3DXCONSTANT_DESC *constant_description_array;
00042 // }
00043 // DX_PARAMETER;
00044 // 
00045 // typedef struct
00046 // {
00047 //   int state;
00048 //   union
00049 //   {
00050 //     DIRECT_3D_VERTEX_SHADER direct_3d_vertex_shader;
00051 //     DIRECT_3D_PIXEL_SHADER direct_3d_pixel_shader;
00052 //   };
00053 //   LPD3DXCONSTANTTABLE constant_table;
00054 //   D3DXCONSTANTTABLE_DESC constant_table_description;
00055 // 
00056 //   int total_semantics;
00057 //   D3DXSEMANTIC *semantic_array;
00058 // }
00059 // DIRECT_3D_SHADER;
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //       Class : DXShaderContext9
00063 // Description : xyz
00064 ////////////////////////////////////////////////////////////////////
00065 
00066 class EXPCL_PANDADX CLP(ShaderContext): public ShaderContext {
00067 public:
00068   typedef CLP(GraphicsStateGuardian) GSG;
00069   
00070   CLP(ShaderContext)(Shader *s, GSG *gsg);
00071   ~CLP(ShaderContext)();
00072 
00073   INLINE bool valid(GSG *gsg);
00074   bool bind(GSG *gsg);
00075   void unbind(GSG *gsg);
00076   void issue_parameters(GSG *gsg, int altered);
00077   void issue_transform(GSG *gsg);
00078   void disable_shader_vertex_arrays(GSG *gsg);
00079   bool update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg,
00080                                    bool force);
00081   void disable_shader_texture_bindings(GSG *gsg);
00082   void update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg);
00083 
00084   class VertexElementArray* _vertex_element_array;
00085   LPDIRECT3DVERTEXDECLARATION9 _vertex_declaration;
00086 
00087   int _num_bound_streams;
00088 
00089   // FOR DEBUGGING
00090   string _name;
00091   
00092 private:
00093 
00094 #ifdef HAVE_CG
00095   CGcontext _cg_context;
00096   CGprogram _cg_vprogram;
00097   CGprogram _cg_fprogram;
00098 
00099   // BEGIN CG2 CHANGE
00100   CGprogram _cg_gprogram;   // Geometry program
00101   // END CG2 CHANGE
00102 
00103   pvector <CGparameter> _cg_parameter_map;
00104 #endif
00105 
00106 private:
00107 
00108   void release_resources(void);
00109 
00110 public:
00111   static TypeHandle get_class_type() {
00112     return _type_handle;
00113   }
00114   static void init_type() {
00115     TypedObject::init_type();
00116     register_type(_type_handle, CLASSPREFIX_QUOTED "ShaderContext",
00117                   TypedObject::get_class_type());
00118   }
00119   virtual TypeHandle get_type() const {
00120     return get_class_type();
00121   }
00122   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00123 
00124 private:
00125   static TypeHandle _type_handle;
00126 };
00127 
00128 #include "dxShaderContext9.I"
00129 
00130 #endif
 All Classes Functions Variables Enumerations