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   void update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg);
00080   void disable_shader_texture_bindings(GSG *gsg);
00081   void update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg);
00082 
00083   class VertexElementArray *_vertex_element_array;
00084 
00085   // FOR DEBUGGING
00086   int _vertex_size;
00087   string _name;
00088   
00089 private:
00090 
00091 #ifdef HAVE_CG
00092   CGcontext _cg_context;
00093   CGprogram _cg_vprogram;
00094   CGprogram _cg_fprogram;
00095 
00096   // BEGIN CG2 CHANGE
00097   CGprogram _cg_gprogram;   // Geometry program
00098   // END CG2 CHANGE
00099 
00100   pvector <CGparameter> _cg_parameter_map;
00101 #endif
00102 
00103 private:
00104 
00105   void release_resources(void);
00106 
00107 public:
00108   static TypeHandle get_class_type() {
00109     return _type_handle;
00110   }
00111   static void init_type() {
00112     TypedObject::init_type();
00113     register_type(_type_handle, CLASSPREFIX_QUOTED "ShaderContext",
00114                   TypedObject::get_class_type());
00115   }
00116   virtual TypeHandle get_type() const {
00117     return get_class_type();
00118   }
00119   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00120 
00121 private:
00122   static TypeHandle _type_handle;
00123 };
00124 
00125 #include "dxShaderContext9.I"
00126 
00127 #endif
 All Classes Functions Variables Enumerations