소스 검색

Modifications to eliminate class ShaderExpansion

Josh Yelon 18 년 전
부모
커밋
d8e6dc13a3

+ 1 - 1
doc/makepanda/makepanda.py

@@ -1603,7 +1603,7 @@ TargetAdd('pgraph_composite1.obj', opts=OPTS, input='pgraph_composite1.cxx')
 TargetAdd('pgraph_composite2.obj', opts=OPTS, input='pgraph_composite2.cxx')
 TargetAdd('pgraph_composite2.obj', opts=OPTS, input='pgraph_composite2.cxx')
 TargetAdd('pgraph_composite3.obj', opts=OPTS, input='pgraph_composite3.cxx')
 TargetAdd('pgraph_composite3.obj', opts=OPTS, input='pgraph_composite3.cxx')
 TargetAdd('pgraph_composite4.obj', opts=OPTS, input='pgraph_composite4.cxx')
 TargetAdd('pgraph_composite4.obj', opts=OPTS, input='pgraph_composite4.cxx')
-IGATEFILES=GetDirectoryContents('panda/src/pgraph', ["*.h", "*_composite.cxx"])
+IGATEFILES=GetDirectoryContents('panda/src/pgraph', ["*.h", "nodePath.cxx", "*_composite.cxx"])
 # IGATEFILES.remove("antialiasAttrib.h")
 # IGATEFILES.remove("antialiasAttrib.h")
 TargetAdd('libpgraph.in', opts=OPTS, input=IGATEFILES)
 TargetAdd('libpgraph.in', opts=OPTS, input=IGATEFILES)
 TargetAdd('libpgraph.in', opts=['IMOD:panda', 'ILIB:libpgraph', 'SRCDIR:panda/src/pgraph'])
 TargetAdd('libpgraph.in', opts=['IMOD:panda', 'ILIB:libpgraph', 'SRCDIR:panda/src/pgraph'])

+ 31 - 31
panda/src/display/graphicsStateGuardian.cxx

@@ -523,7 +523,7 @@ release_geom(GeomContext *) {
 //  Description: Compile a vertex/fragment shader body.
 //  Description: Compile a vertex/fragment shader body.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 ShaderContext *GraphicsStateGuardian::
 ShaderContext *GraphicsStateGuardian::
-prepare_shader(ShaderExpansion *shader) {
+prepare_shader(Shader *shader) {
   return (ShaderContext *)NULL;
   return (ShaderContext *)NULL;
 }
 }
 
 
@@ -819,7 +819,7 @@ clear(DrawableRegion *clearable) {
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 const LMatrix4f *GraphicsStateGuardian::
 const LMatrix4f *GraphicsStateGuardian::
-fetch_specified_value(ShaderExpansion::ShaderMatSpec &spec, bool altered) {
+fetch_specified_value(Shader::ShaderMatSpec &spec, bool altered) {
   static LMatrix4f acc;
   static LMatrix4f acc;
   const LMatrix4f *val1;
   const LMatrix4f *val1;
   const LMatrix4f *val2;
   const LMatrix4f *val2;
@@ -827,26 +827,26 @@ fetch_specified_value(ShaderExpansion::ShaderMatSpec &spec, bool altered) {
   static LMatrix4f t2;
   static LMatrix4f t2;
 
 
   switch(spec._func) {
   switch(spec._func) {
-  case ShaderExpansion::SMF_compose:
+  case Shader::SMF_compose:
     val1 = fetch_specified_part(spec._part[0], spec._arg[0], t1);
     val1 = fetch_specified_part(spec._part[0], spec._arg[0], t1);
     val2 = fetch_specified_part(spec._part[1], spec._arg[1], t2);
     val2 = fetch_specified_part(spec._part[1], spec._arg[1], t2);
     acc.multiply(*val1, *val2);
     acc.multiply(*val1, *val2);
     return &acc;
     return &acc;
-  case ShaderExpansion::SMF_compose_cache_first:
+  case Shader::SMF_compose_cache_first:
     if (altered) {
     if (altered) {
       spec._cache = *fetch_specified_part(spec._part[0], spec._arg[0], t1);
       spec._cache = *fetch_specified_part(spec._part[0], spec._arg[0], t1);
     }
     }
     val2 = fetch_specified_part(spec._part[1], spec._arg[1], t2);
     val2 = fetch_specified_part(spec._part[1], spec._arg[1], t2);
     acc.multiply(spec._cache, *val2);
     acc.multiply(spec._cache, *val2);
     return &acc;
     return &acc;
-  case ShaderExpansion::SMF_compose_cache_second:
+  case Shader::SMF_compose_cache_second:
     if (altered) {
     if (altered) {
       spec._cache = *fetch_specified_part(spec._part[1], spec._arg[1], t2);
       spec._cache = *fetch_specified_part(spec._part[1], spec._arg[1], t2);
     }
     }
     val1 = fetch_specified_part(spec._part[0], spec._arg[0], t1);
     val1 = fetch_specified_part(spec._part[0], spec._arg[0], t1);
     acc.multiply(*val1, spec._cache);
     acc.multiply(*val1, spec._cache);
     return &acc;
     return &acc;
-  case ShaderExpansion::SMF_first:
+  case Shader::SMF_first:
     return fetch_specified_part(spec._part[0], spec._arg[0], t1);
     return fetch_specified_part(spec._part[0], spec._arg[0], t1);
   default:
   default:
     // should never get here
     // should never get here
@@ -860,24 +860,24 @@ fetch_specified_value(ShaderExpansion::ShaderMatSpec &spec, bool altered) {
 //  Description: See fetch_specified_value
 //  Description: See fetch_specified_value
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 const LMatrix4f *GraphicsStateGuardian::
 const LMatrix4f *GraphicsStateGuardian::
-fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, LMatrix4f &t) {
+fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4f &t) {
   switch(part) {
   switch(part) {
-  case ShaderExpansion::SMO_identity: {
+  case Shader::SMO_identity: {
     return &LMatrix4f::ident_mat();
     return &LMatrix4f::ident_mat();
   }
   }
-  case ShaderExpansion::SMO_window_size: {
+  case Shader::SMO_window_size: {
     t = LMatrix4f::translate_mat(_current_display_region->get_pixel_width(),
     t = LMatrix4f::translate_mat(_current_display_region->get_pixel_width(),
                                  _current_display_region->get_pixel_height(),
                                  _current_display_region->get_pixel_height(),
                                  0.0);
                                  0.0);
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_pixel_size: {
+  case Shader::SMO_pixel_size: {
     t = LMatrix4f::translate_mat(_current_display_region->get_pixel_width(),
     t = LMatrix4f::translate_mat(_current_display_region->get_pixel_width(),
                                  _current_display_region->get_pixel_height(),
                                  _current_display_region->get_pixel_height(),
                                  0.0);
                                  0.0);
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_card_center: {
+  case Shader::SMO_card_center: {
     int px = _current_display_region->get_pixel_width();
     int px = _current_display_region->get_pixel_width();
     int py = _current_display_region->get_pixel_height();
     int py = _current_display_region->get_pixel_height();
     t = LMatrix4f::translate_mat((px*0.5) / Texture::up_to_power_2(px),
     t = LMatrix4f::translate_mat((px*0.5) / Texture::up_to_power_2(px),
@@ -885,12 +885,12 @@ fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, L
                                  0.0);
                                  0.0);
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_mat_constant_x: {
+  case Shader::SMO_mat_constant_x: {
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     return &(np.node()->get_transform()->get_mat());
     return &(np.node()->get_transform()->get_mat());
   }
   }
-  case ShaderExpansion::SMO_vec_constant_x: {
+  case Shader::SMO_vec_constant_x: {
     const LVector4f &input = _target._shader->get_shader_input_vector(name);
     const LVector4f &input = _target._shader->get_shader_input_vector(name);
     const float *data = input.get_data();
     const float *data = input.get_data();
     t = LMatrix4f(data[0],data[1],data[2],data[3],
     t = LMatrix4f(data[0],data[1],data[2],data[3],
@@ -899,28 +899,28 @@ fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, L
                   data[0],data[1],data[2],data[3]);
                   data[0],data[1],data[2],data[3]);
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_world_to_view: {
+  case Shader::SMO_world_to_view: {
     return &(get_scene()->get_world_transform()->get_mat());
     return &(get_scene()->get_world_transform()->get_mat());
     break;
     break;
   }
   }
-  case ShaderExpansion::SMO_view_to_world: {
+  case Shader::SMO_view_to_world: {
     return &(get_scene()->get_camera_transform()->get_mat());
     return &(get_scene()->get_camera_transform()->get_mat());
   }
   }
-  case ShaderExpansion::SMO_model_to_view: {
+  case Shader::SMO_model_to_view: {
     return &(get_external_transform()->get_mat());
     return &(get_external_transform()->get_mat());
   }
   }
-  case ShaderExpansion::SMO_view_to_model: {
+  case Shader::SMO_view_to_model: {
     // DANGER: SLOW AND NOT CACHEABLE!
     // DANGER: SLOW AND NOT CACHEABLE!
     t.invert_from(get_external_transform()->get_mat());
     t.invert_from(get_external_transform()->get_mat());
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_apiview_to_view: {
+  case Shader::SMO_apiview_to_view: {
     return &(_inv_cs_transform->get_mat());
     return &(_inv_cs_transform->get_mat());
   }
   }
-  case ShaderExpansion::SMO_view_to_apiview: {
+  case Shader::SMO_view_to_apiview: {
     return &(_cs_transform->get_mat());
     return &(_cs_transform->get_mat());
   }
   }
-  case ShaderExpansion::SMO_clip_to_view: {
+  case Shader::SMO_clip_to_view: {
     if (_current_lens->get_coordinate_system() == _coordinate_system) {
     if (_current_lens->get_coordinate_system() == _coordinate_system) {
       return &(_current_lens->get_projection_mat_inv(_current_stereo_channel));
       return &(_current_lens->get_projection_mat_inv(_current_stereo_channel));
     } else {
     } else {
@@ -929,7 +929,7 @@ fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, L
       return &t;
       return &t;
     }
     }
   }
   }
-  case ShaderExpansion::SMO_view_to_clip: {
+  case Shader::SMO_view_to_clip: {
     if (_current_lens->get_coordinate_system() == _coordinate_system) {
     if (_current_lens->get_coordinate_system() == _coordinate_system) {
       return &(_current_lens->get_projection_mat(_current_stereo_channel));
       return &(_current_lens->get_projection_mat(_current_stereo_channel));
     } else {
     } else {
@@ -938,29 +938,29 @@ fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, L
       return &t;
       return &t;
     }
     }
   }
   }
-  case ShaderExpansion::SMO_apiclip_to_view: {
+  case Shader::SMO_apiclip_to_view: {
     t = _projection_mat_inv->get_mat() * _inv_cs_transform->get_mat();
     t = _projection_mat_inv->get_mat() * _inv_cs_transform->get_mat();
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_view_to_apiclip: {
+  case Shader::SMO_view_to_apiclip: {
     t = _cs_transform->get_mat() * _projection_mat->get_mat();
     t = _cs_transform->get_mat() * _projection_mat->get_mat();
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_view_x_to_view: {
+  case Shader::SMO_view_x_to_view: {
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     t = np.get_net_transform()->get_mat() *
     t = np.get_net_transform()->get_mat() *
       get_scene()->get_world_transform()->get_mat();
       get_scene()->get_world_transform()->get_mat();
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_view_to_view_x: {
+  case Shader::SMO_view_to_view_x: {
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     t = get_scene()->get_camera_transform()->get_mat() *
     t = get_scene()->get_camera_transform()->get_mat() *
       invert(np.get_net_transform()->get_mat());
       invert(np.get_net_transform()->get_mat());
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_apiview_x_to_view: {
+  case Shader::SMO_apiview_x_to_view: {
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     t = LMatrix4f::convert_mat(_internal_coordinate_system, _coordinate_system) *
     t = LMatrix4f::convert_mat(_internal_coordinate_system, _coordinate_system) *
@@ -968,7 +968,7 @@ fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, L
       get_scene()->get_world_transform()->get_mat();
       get_scene()->get_world_transform()->get_mat();
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_view_to_apiview_x: {
+  case Shader::SMO_view_to_apiview_x: {
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     t = (get_scene()->get_camera_transform()->get_mat() *
     t = (get_scene()->get_camera_transform()->get_mat() *
@@ -976,7 +976,7 @@ fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, L
          LMatrix4f::convert_mat(_coordinate_system, _internal_coordinate_system));
          LMatrix4f::convert_mat(_coordinate_system, _internal_coordinate_system));
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_clip_x_to_view: {
+  case Shader::SMO_clip_x_to_view: {
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     Lens *lens = DCAST(LensNode, np.node())->get_lens();
     Lens *lens = DCAST(LensNode, np.node())->get_lens();
@@ -986,7 +986,7 @@ fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, L
       get_scene()->get_world_transform()->get_mat();
       get_scene()->get_world_transform()->get_mat();
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_view_to_clip_x: {
+  case Shader::SMO_view_to_clip_x: {
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     const NodePath &np = _target._shader->get_shader_input_nodepath(name);
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     nassertr(!np.is_empty(), &LMatrix4f::ident_mat());
     Lens *lens = DCAST(LensNode, np.node())->get_lens();
     Lens *lens = DCAST(LensNode, np.node())->get_lens();
@@ -996,11 +996,11 @@ fetch_specified_part(ShaderExpansion::ShaderMatInput part, InternalName *name, L
       lens->get_projection_mat(_current_stereo_channel);
       lens->get_projection_mat(_current_stereo_channel);
     return &t;
     return &t;
   }
   }
-  case ShaderExpansion::SMO_apiclip_x_to_view: {
+  case Shader::SMO_apiclip_x_to_view: {
     // NOT IMPLEMENTED
     // NOT IMPLEMENTED
     return &LMatrix4f::ident_mat();
     return &LMatrix4f::ident_mat();
   }
   }
-  case ShaderExpansion::SMO_view_to_apiclip_x: {
+  case Shader::SMO_view_to_apiclip_x: {
     // NOT IMPLEMENTED
     // NOT IMPLEMENTED
     return &LMatrix4f::ident_mat();
     return &LMatrix4f::ident_mat();
   }
   }

+ 4 - 4
panda/src/display/graphicsStateGuardian.h

@@ -166,7 +166,7 @@ public:
   virtual GeomContext *prepare_geom(Geom *geom);
   virtual GeomContext *prepare_geom(Geom *geom);
   virtual void release_geom(GeomContext *gc);
   virtual void release_geom(GeomContext *gc);
 
 
-  virtual ShaderContext *prepare_shader(ShaderExpansion *shader);
+  virtual ShaderContext *prepare_shader(Shader *shader);
   virtual void release_shader(ShaderContext *sc);
   virtual void release_shader(ShaderContext *sc);
 
 
   virtual VertexBufferContext *prepare_vertex_buffer(GeomVertexArrayData *data);
   virtual VertexBufferContext *prepare_vertex_buffer(GeomVertexArrayData *data);
@@ -195,8 +195,8 @@ public:
 
 
   void clear(DrawableRegion *clearable);
   void clear(DrawableRegion *clearable);
 
 
-  const LMatrix4f *fetch_specified_value(ShaderExpansion::ShaderMatSpec &spec, bool altered);
-  const LMatrix4f *fetch_specified_part(ShaderExpansion::ShaderMatInput input, InternalName *name, LMatrix4f &t);
+  const LMatrix4f *fetch_specified_value(Shader::ShaderMatSpec &spec, bool altered);
+  const LMatrix4f *fetch_specified_part(Shader::ShaderMatInput input, InternalName *name, LMatrix4f &t);
 
 
   virtual void prepare_display_region(DisplayRegionPipelineReader *dr,
   virtual void prepare_display_region(DisplayRegionPipelineReader *dr,
                                       Lens::StereoChannel stereo_channel);
                                       Lens::StereoChannel stereo_channel);
@@ -418,7 +418,7 @@ protected:
 
 
   static PT(TextureStage) _alpha_scale_texture_stage;
   static PT(TextureStage) _alpha_scale_texture_stage;
 
 
-  ShaderExpansion::ShaderCaps _shader_caps;
+  Shader::ShaderCaps _shader_caps;
 
 
   float _gamma;
   float _gamma;
   
   

+ 17 - 21
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -351,7 +351,7 @@ release_texture(TextureContext *tc) {
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 ShaderContext *DXGraphicsStateGuardian9::
 ShaderContext *DXGraphicsStateGuardian9::
-prepare_shader(ShaderExpansion *se) {
+prepare_shader(Shader *se) {
 #ifdef HAVE_CG
 #ifdef HAVE_CG
   CLP(ShaderContext) *result = new CLP(ShaderContext)(se, this);
   CLP(ShaderContext) *result = new CLP(ShaderContext)(se, this);
   return result;
   return result;
@@ -1272,7 +1272,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
         update_shader_vertex_arrays(_vertex_array_shader_context,this);
         update_shader_vertex_arrays(_vertex_array_shader_context,this);
     }
     }
   }
   }
-  _vertex_array_shader_expansion = _current_shader_expansion;
+  _vertex_array_shader = _current_shader;
   _vertex_array_shader_context = _current_shader_context;
   _vertex_array_shader_context = _current_shader_context;
 
 
   const GeomVertexFormat *format = _data_reader->get_format ( );
   const GeomVertexFormat *format = _data_reader->get_format ( );
@@ -3016,11 +3016,11 @@ reset() {
   // must check (_screen->_d3dcaps.PrimitiveMiscCaps & D3DPMISCCAPS_BLENDOP) (yes on GF2/Radeon8500, no on TNT)
   // must check (_screen->_d3dcaps.PrimitiveMiscCaps & D3DPMISCCAPS_BLENDOP) (yes on GF2/Radeon8500, no on TNT)
   set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD);
   set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD);
 
 
-  _current_shader_expansion = (ShaderExpansion *)NULL;
+  _current_shader = (Shader *)NULL;
   _current_shader_context = (CLP(ShaderContext) *)NULL;
   _current_shader_context = (CLP(ShaderContext) *)NULL;
-  _vertex_array_shader_expansion = (ShaderExpansion *)NULL;
+  _vertex_array_shader = (Shader *)NULL;
   _vertex_array_shader_context = (CLP(ShaderContext) *)NULL;
   _vertex_array_shader_context = (CLP(ShaderContext) *)NULL;
-  _texture_binding_shader_expansion = (ShaderExpansion *)NULL;
+  _texture_binding_shader = (Shader *)NULL;
   _texture_binding_shader_context = (CLP(ShaderContext) *)NULL;
   _texture_binding_shader_context = (CLP(ShaderContext) *)NULL;
 
 
   PRINT_REFCNT(dxgsg9, _d3d_device);
   PRINT_REFCNT(dxgsg9, _d3d_device);
@@ -3157,25 +3157,21 @@ do_issue_shader() {
   DBG_SH3  dxgsg9_cat.debug ( ) << "SHADER: do_issue_shader\n"; DBG_E
   DBG_SH3  dxgsg9_cat.debug ( ) << "SHADER: do_issue_shader\n"; DBG_E
 
 
   CLP(ShaderContext) *context = 0;
   CLP(ShaderContext) *context = 0;
-  ShaderExpansion *expansion = _target_rs->get_shader_expansion();
-  if (expansion == 0) {
-    if (_target._shader->get_shader() != 0) {
-      expansion = _target._shader->get_shader()->macroexpand(_target_rs, _shader_caps);
-      // I am casting away the const-ness of this pointer, because
-      // the 'shader-expansion' field is just a cache.
-      ((RenderState *)((const RenderState*)_target_rs))->
-        set_shader_expansion(expansion);
-    }
+  const ShaderAttrib *attr = _target_rs->get_generated_shader();
+  if (attr == 0) {
+    attr = _target._shader;
+    // if (attr is auto) then generate a shader.
+    // store that shader using set_generated_shader.
   }
   }
-
-  if (expansion) {
-    context = (CLP(ShaderContext) *)(expansion->prepare_now(get_prepared_objects(), this));
+  Shader *shader = (Shader *)(attr->get_shader());
+  if (shader) {
+    context = (CLP(ShaderContext) *)(shader->prepare_now(get_prepared_objects(), this));
   }
   }
 
 
   if (context == 0 || (context && context -> valid (this) == false)) {
   if (context == 0 || (context && context -> valid (this) == false)) {
     if (_current_shader_context != 0) {
     if (_current_shader_context != 0) {
       _current_shader_context->unbind(this);
       _current_shader_context->unbind(this);
-      _current_shader_expansion = 0;
+      _current_shader = 0;
       _current_shader_context = 0;
       _current_shader_context = 0;
       disable_standard_texture_bindings();
       disable_standard_texture_bindings();
     }
     }
@@ -3188,12 +3184,12 @@ do_issue_shader() {
     if (_current_shader_context != 0) {
     if (_current_shader_context != 0) {
       _current_shader_context->unbind(this);
       _current_shader_context->unbind(this);
       _current_shader_context = 0;
       _current_shader_context = 0;
-      _current_shader_expansion = 0;
+      _current_shader = 0;
       disable_standard_texture_bindings();
       disable_standard_texture_bindings();
     }
     }
     if (context != 0) {
     if (context != 0) {
       context->bind(this);
       context->bind(this);
-      _current_shader_expansion = expansion;
+      _current_shader = shader;
       _current_shader_context = context;
       _current_shader_context = context;
     }
     }
   } else {
   } else {
@@ -3822,7 +3818,7 @@ do_issue_texture() {
         update_shader_texture_bindings(_texture_binding_shader_context,this);
         update_shader_texture_bindings(_texture_binding_shader_context,this);
     }
     }
   }
   }
-  _texture_binding_shader_expansion = _current_shader_expansion;
+  _texture_binding_shader = _current_shader;
   _texture_binding_shader_context = _current_shader_context;
   _texture_binding_shader_context = _current_shader_context;
 }
 }
 
 

+ 4 - 4
panda/src/dxgsg9/dxGraphicsStateGuardian9.h

@@ -89,7 +89,7 @@ public:
   void apply_texture(int i, TextureContext *tc);
   void apply_texture(int i, TextureContext *tc);
   virtual void release_texture(TextureContext *tc);
   virtual void release_texture(TextureContext *tc);
 
 
-  ShaderContext *prepare_shader(ShaderExpansion *se);
+  ShaderContext *prepare_shader(Shader *se);
   void release_shader(ShaderContext *sc);
   void release_shader(ShaderContext *sc);
 
 
   virtual VertexBufferContext *prepare_vertex_buffer(GeomVertexArrayData *data);
   virtual VertexBufferContext *prepare_vertex_buffer(GeomVertexArrayData *data);
@@ -302,11 +302,11 @@ protected:
   CullFaceAttrib::Mode _cull_face_mode;
   CullFaceAttrib::Mode _cull_face_mode;
   RenderModeAttrib::Mode _current_fill_mode;  //point/wireframe/solid
   RenderModeAttrib::Mode _current_fill_mode;  //point/wireframe/solid
 
 
-  PT(ShaderExpansion)  _current_shader_expansion;
+  PT(Shader)  _current_shader;
   CLP(ShaderContext)  *_current_shader_context;
   CLP(ShaderContext)  *_current_shader_context;
-  PT(ShaderExpansion)  _vertex_array_shader_expansion;
+  PT(Shader)  _vertex_array_shader;
   CLP(ShaderContext)  *_vertex_array_shader_context;
   CLP(ShaderContext)  *_vertex_array_shader_context;
-  PT(ShaderExpansion)  _texture_binding_shader_expansion;
+  PT(Shader)  _texture_binding_shader;
   CLP(ShaderContext)  *_texture_binding_shader_context;
   CLP(ShaderContext)  *_texture_binding_shader_context;
 
 
   const DXVertexBufferContext9 *_active_vbuffer;
   const DXVertexBufferContext9 *_active_vbuffer;

+ 39 - 39
panda/src/dxgsg9/dxShaderContext9.cxx

@@ -39,16 +39,16 @@ TypeHandle CLP(ShaderContext)::_type_handle;
 //  Description: xyz
 //  Description: xyz
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 CLP(ShaderContext)::
 CLP(ShaderContext)::
-CLP(ShaderContext)(ShaderExpansion *s, GSG *gsg) : ShaderContext(s) {
+CLP(ShaderContext)(Shader *s, GSG *gsg) : ShaderContext(s) {
 
 
   _vertex_size = 0;
   _vertex_size = 0;
   _vertex_element_array = 0;
   _vertex_element_array = 0;
-  _name = s->get_name ( );
+  _name = s->get_filename ( );
 
 
 #ifdef HAVE_CG
 #ifdef HAVE_CG
   if (s->get_header() == "//Cg") {
   if (s->get_header() == "//Cg") {
     
     
-    // Ask the shader expansion to compile itself for us and 
+    // Ask the shader to compile itself for us and 
     // to give us the resulting Cg program objects.
     // to give us the resulting Cg program objects.
 
 
     if (!s->cg_compile_for(gsg->_shader_caps,
     if (!s->cg_compile_for(gsg->_shader_caps,
@@ -277,7 +277,7 @@ unbind(GSG *gsg) {
 //     Function: DXShaderContext9::issue_parameters
 //     Function: DXShaderContext9::issue_parameters
 //       Access: Public
 //       Access: Public
 //  Description: This function gets called whenever the RenderState
 //  Description: This function gets called whenever the RenderState
-//               or TransformState has changed, but the ShaderExpansion
+//               or TransformState has changed, but the Shader
 //               itself has not changed.  It loads new values into the
 //               itself has not changed.  It loads new values into the
 //               shader's parameters.
 //               shader's parameters.
 //
 //
@@ -301,13 +301,13 @@ issue_parameters(GSG *gsg, bool altered)
 {
 {
 #ifdef HAVE_CG
 #ifdef HAVE_CG
   if (_cg_context) {
   if (_cg_context) {
-    for (int i=0; i<(int)_expansion->_mat_spec.size(); i++) {
-      if (altered || _expansion->_mat_spec[i]._trans_dependent) {
-        CGparameter p = _cg_parameter_map[_expansion->_mat_spec[i]._id._seqno];
+    for (int i=0; i<(int)_shader->_mat_spec.size(); i++) {
+      if (altered || _shader->_mat_spec[i]._trans_dependent) {
+        CGparameter p = _cg_parameter_map[_shader->_mat_spec[i]._id._seqno];
         if (p == NULL) {
         if (p == NULL) {
           continue;
           continue;
         }        
         }        
-        const LMatrix4f *val = gsg->fetch_specified_value(_expansion->_mat_spec[i], altered);
+        const LMatrix4f *val = gsg->fetch_specified_value(_shader->_mat_spec[i], altered);
         if (val) {
         if (val) {
           HRESULT hr;
           HRESULT hr;
           float v [4];
           float v [4];
@@ -322,13 +322,13 @@ issue_parameters(GSG *gsg, bool altered)
           #if DEBUG_SHADER
           #if DEBUG_SHADER
           // DEBUG
           // DEBUG
           global_data = (float *) data;
           global_data = (float *) data;
-          global_shader_mat_spec = &_expansion->_mat_spec[i];
+          global_shader_mat_spec = &_shader->_mat_spec[i];
           global_internal_name_0 = global_shader_mat_spec -> _arg [0];
           global_internal_name_0 = global_shader_mat_spec -> _arg [0];
           global_internal_name_1 = global_shader_mat_spec -> _arg [1];
           global_internal_name_1 = global_shader_mat_spec -> _arg [1];
           #endif
           #endif
 
 
-          switch (_expansion->_mat_spec[i]._piece) {
-          case ShaderExpansion::SMP_whole:
+          switch (_shader->_mat_spec[i]._piece) {
+          case Shader::SMP_whole:
             // TRANSPOSE REQUIRED
             // TRANSPOSE REQUIRED
             temp_matrix.transpose_from (*val);
             temp_matrix.transpose_from (*val);
             data = temp_matrix.get_data();
             data = temp_matrix.get_data();
@@ -336,7 +336,7 @@ issue_parameters(GSG *gsg, bool altered)
             hr = cgD3D9SetUniform (p, data);
             hr = cgD3D9SetUniform (p, data);
 
 
             DBG_SH2
             DBG_SH2
-              dxgsg9_cat.debug ( ) << "ShaderExpansion::SMP_whole MATRIX \n" <<
+              dxgsg9_cat.debug ( ) << "Shader::SMP_whole MATRIX \n" <<
                 data[ 0] << " " << data[ 1] << " " << data[ 2] << " " << data[ 3] << "\n" <<
                 data[ 0] << " " << data[ 1] << " " << data[ 2] << " " << data[ 3] << "\n" <<
                 data[ 4] << " " << data[ 5] << " " << data[ 6] << " " << data[ 7] << "\n" <<
                 data[ 4] << " " << data[ 5] << " " << data[ 6] << " " << data[ 7] << "\n" <<
                 data[ 8] << " " << data[ 9] << " " << data[10] << " " << data[11] << "\n" <<
                 data[ 8] << " " << data[ 9] << " " << data[10] << " " << data[11] << "\n" <<
@@ -345,44 +345,44 @@ issue_parameters(GSG *gsg, bool altered)
 
 
             break;
             break;
 
 
-          case ShaderExpansion::SMP_transpose:
+          case Shader::SMP_transpose:
             // NO TRANSPOSE REQUIRED
             // NO TRANSPOSE REQUIRED
             hr = cgD3D9SetUniform (p, data);
             hr = cgD3D9SetUniform (p, data);
             break;
             break;
 
 
-          case ShaderExpansion::SMP_row0:
+          case Shader::SMP_row0:
             hr = cgD3D9SetUniform (p, data + 0);
             hr = cgD3D9SetUniform (p, data + 0);
             break;
             break;
-          case ShaderExpansion::SMP_row1:
+          case Shader::SMP_row1:
             hr = cgD3D9SetUniform (p, data + 4);
             hr = cgD3D9SetUniform (p, data + 4);
             break;
             break;
-          case ShaderExpansion::SMP_row2:
+          case Shader::SMP_row2:
             hr = cgD3D9SetUniform (p, data + 8);
             hr = cgD3D9SetUniform (p, data + 8);
             break;
             break;
-          case ShaderExpansion::SMP_row3:
+          case Shader::SMP_row3:
             hr = cgD3D9SetUniform (p, data + 12);
             hr = cgD3D9SetUniform (p, data + 12);
             break;
             break;
 
 
-          case ShaderExpansion::SMP_col0:
+          case Shader::SMP_col0:
             v[0] = data[0]; v[1] = data[4]; v[2] = data[8]; v[3] = data[12];
             v[0] = data[0]; v[1] = data[4]; v[2] = data[8]; v[3] = data[12];
             hr = cgD3D9SetUniform (p, v);
             hr = cgD3D9SetUniform (p, v);
             break;
             break;
-          case ShaderExpansion::SMP_col1:
+          case Shader::SMP_col1:
             v[0] = data[1]; v[1] = data[5]; v[2] = data[9]; v[3] = data[13];
             v[0] = data[1]; v[1] = data[5]; v[2] = data[9]; v[3] = data[13];
             hr = cgD3D9SetUniform (p, v);
             hr = cgD3D9SetUniform (p, v);
             break;
             break;
-          case ShaderExpansion::SMP_col2:
+          case Shader::SMP_col2:
             v[0] = data[2]; v[1] = data[6]; v[2] = data[10]; v[3] = data[14];
             v[0] = data[2]; v[1] = data[6]; v[2] = data[10]; v[3] = data[14];
             hr = cgD3D9SetUniform (p, v);
             hr = cgD3D9SetUniform (p, v);
             break;
             break;
-          case ShaderExpansion::SMP_col3:
+          case Shader::SMP_col3:
             v[0] = data[3]; v[1] = data[7]; v[2] = data[11]; v[3] = data[15];
             v[0] = data[3]; v[1] = data[7]; v[2] = data[11]; v[3] = data[15];
             hr = cgD3D9SetUniform (p, v);
             hr = cgD3D9SetUniform (p, v);
             break;
             break;
 
 
           default:
           default:
             dxgsg9_cat.error()
             dxgsg9_cat.error()
-              << "issue_parameters ( ) SMP parameter type not implemented " << _expansion->_mat_spec[i]._piece << "\n";
+              << "issue_parameters ( ) SMP parameter type not implemented " << _shader->_mat_spec[i]._piece << "\n";
             break;
             break;
           }
           }
 
 
@@ -390,14 +390,14 @@ issue_parameters(GSG *gsg, bool altered)
 
 
             string name = "unnamed";
             string name = "unnamed";
 
 
-            if (_expansion->_mat_spec[i]._arg [0]) {
-              name = _expansion->_mat_spec[i]._arg [0] -> get_basename ( );
+            if (_shader->_mat_spec[i]._arg [0]) {
+              name = _shader->_mat_spec[i]._arg [0] -> get_basename ( );
             }
             }
 
 
             dxgsg9_cat.error()
             dxgsg9_cat.error()
               << "NAME  " << name << "\n"
               << "NAME  " << name << "\n"
               << "MAT TYPE  "
               << "MAT TYPE  "
-              << _expansion->_mat_spec[i]._piece
+              << _shader->_mat_spec[i]._piece
               << " cgD3D9SetUniform failed "
               << " cgD3D9SetUniform failed "
               << D3DERRORSTRING(hr);
               << D3DERRORSTRING(hr);
 
 
@@ -465,7 +465,7 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg)
         const GeomVertexArrayDataHandle *array_reader;
         const GeomVertexArrayDataHandle *array_reader;
         Geom::NumericType numeric_type;
         Geom::NumericType numeric_type;
         int start, stride, num_values;
         int start, stride, num_values;
-        int nvarying = _expansion->_var_spec.size();
+        int nvarying = _shader->_var_spec.size();
 
 
         int stream_index;
         int stream_index;
         VertexElementArray *vertex_element_array;
         VertexElementArray *vertex_element_array;
@@ -481,12 +481,12 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg)
         #endif
         #endif
 
 
         for (int i=0; i<nvarying; i++) {
         for (int i=0; i<nvarying; i++) {
-          CGparameter p = _cg_parameter_map[_expansion->_var_spec[i]._id._seqno];
+          CGparameter p = _cg_parameter_map[_shader->_var_spec[i]._id._seqno];
           if (p == NULL) {
           if (p == NULL) {
             continue;
             continue;
           }        
           }        
-          InternalName *name = _expansion->_var_spec[i]._name;
-          int texslot = _expansion->_var_spec[i]._append_uv;
+          InternalName *name = _shader->_var_spec[i]._name;
+          int texslot = _shader->_var_spec[i]._append_uv;
           if (texslot >= 0) {
           if (texslot >= 0) {
             const Geom::ActiveTextureStages &active_stages =
             const Geom::ActiveTextureStages &active_stages =
               gsg->_state._texture->get_on_stages();
               gsg->_state._texture->get_on_stages();
@@ -688,8 +688,8 @@ disable_shader_texture_bindings(GSG *gsg)
 {
 {
 #ifdef HAVE_CG
 #ifdef HAVE_CG
   if (_cg_context) {
   if (_cg_context) {
-    for (int i=0; i<(int)_expansion->_tex_spec.size(); i++) {
-      CGparameter p = _cg_parameter_map[_expansion->_tex_spec[i]._id._seqno];
+    for (int i=0; i<(int)_shader->_tex_spec.size(); i++) {
+      CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._seqno];
       if (p == NULL) {
       if (p == NULL) {
         continue;
         continue;
       }        
       }        
@@ -728,31 +728,31 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg)
 
 
 #ifdef HAVE_CG
 #ifdef HAVE_CG
   if (_cg_context) {
   if (_cg_context) {
-    for (int i=0; i<(int)_expansion->_tex_spec.size(); i++) {
-      CGparameter p = _cg_parameter_map[_expansion->_tex_spec[i]._id._seqno];
+    for (int i=0; i<(int)_shader->_tex_spec.size(); i++) {
+      CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._seqno];
       if (p == NULL) {
       if (p == NULL) {
         continue;
         continue;
       }        
       }        
       Texture *tex = 0;
       Texture *tex = 0;
-      InternalName *id = _expansion->_tex_spec[i]._name;
+      InternalName *id = _shader->_tex_spec[i]._name;
       if (id != 0) {
       if (id != 0) {
         const ShaderInput *input = gsg->_target._shader->get_shader_input(id);
         const ShaderInput *input = gsg->_target._shader->get_shader_input(id);
         tex = input->get_texture();
         tex = input->get_texture();
       } else {
       } else {
-        if (_expansion->_tex_spec[i]._stage >= gsg->_target._texture->get_num_on_stages()) {
+        if (_shader->_tex_spec[i]._stage >= gsg->_target._texture->get_num_on_stages()) {
           continue;
           continue;
         }
         }
-        TextureStage *stage = gsg->_target._texture->get_on_stage(_expansion->_tex_spec[i]._stage);
+        TextureStage *stage = gsg->_target._texture->get_on_stage(_shader->_tex_spec[i]._stage);
         tex = gsg->_target._texture->get_on_texture(stage);
         tex = gsg->_target._texture->get_on_texture(stage);
       }
       }
-      if (_expansion->_tex_spec[i]._suffix != 0) {
+      if (_shader->_tex_spec[i]._suffix != 0) {
         // The suffix feature is inefficient. It is a temporary hack.
         // The suffix feature is inefficient. It is a temporary hack.
         if (tex == 0) {
         if (tex == 0) {
           continue;
           continue;
         }
         }
-        tex = tex->load_related(_expansion->_tex_spec[i]._suffix);
+        tex = tex->load_related(_shader->_tex_spec[i]._suffix);
       }
       }
-      if ((tex == 0) || (tex->get_texture_type() != _expansion->_tex_spec[i]._desired_type)) {
+      if ((tex == 0) || (tex->get_texture_type() != _shader->_tex_spec[i]._desired_type)) {
         continue;
         continue;
       }
       }
       TextureContext *tc = tex->prepare_now(gsg->_prepared_objects, gsg);
       TextureContext *tc = tex->prepare_now(gsg->_prepared_objects, gsg);

+ 2 - 2
panda/src/dxgsg9/dxShaderContext9.h

@@ -23,7 +23,7 @@
 #include "pandabase.h"
 #include "pandabase.h"
 #include "string_utils.h"
 #include "string_utils.h"
 #include "internalName.h"
 #include "internalName.h"
-#include "shaderExpansion.h"
+#include "shader.h"
 #include "shaderContext.h"
 #include "shaderContext.h"
 
 
 
 
@@ -71,7 +71,7 @@ class EXPCL_PANDADX CLP(ShaderContext): public ShaderContext {
 public:
 public:
   typedef CLP(GraphicsStateGuardian) GSG;
   typedef CLP(GraphicsStateGuardian) GSG;
   
   
-  CLP(ShaderContext)(ShaderExpansion *s, GSG *gsg);
+  CLP(ShaderContext)(Shader *s, GSG *gsg);
   ~CLP(ShaderContext)();
   ~CLP(ShaderContext)();
 
 
   INLINE bool valid(GSG *gsg);
   INLINE bool valid(GSG *gsg);

+ 9 - 9
panda/src/dxgsg9/dxTextureContext9.cxx

@@ -145,14 +145,14 @@ create_texture(DXScreenData &scrn) {
   }
   }
 
 
   // check for texture compression
   // check for texture compression
-  Texture::CompressionMode compression_mode = Texture::CompressionMode::CM_off;
+  Texture::CompressionMode compression_mode = Texture::CM_off;
   bool texture_stored_compressed = false;
   bool texture_stored_compressed = false;
   bool texture_wants_compressed = false;
   bool texture_wants_compressed = false;
 
 
   compression_mode = get_texture()->get_ram_image_compression();
   compression_mode = get_texture()->get_ram_image_compression();
   // assert my assumption that CM_dxt1..CM_dxt5 enum values are ascending without gaps
   // assert my assumption that CM_dxt1..CM_dxt5 enum values are ascending without gaps
-  nassertr(((Texture::CompressionMode::CM_dxt1+1)==Texture::CompressionMode::CM_dxt2)&&((Texture::CompressionMode::CM_dxt2+1)==Texture::CompressionMode::CM_dxt3)&&((Texture::CompressionMode::CM_dxt3+1)==Texture::CompressionMode::CM_dxt4)&&((Texture::CompressionMode::CM_dxt4+1)==Texture::CompressionMode::CM_dxt5),false);
-  if ((compression_mode >= Texture::CompressionMode::CM_dxt1) && (compression_mode <= Texture::CompressionMode::CM_dxt5)) {
+  nassertr(((Texture::CM_dxt1+1)==Texture::CM_dxt2)&&((Texture::CM_dxt2+1)==Texture::CM_dxt3)&&((Texture::CM_dxt3+1)==Texture::CM_dxt4)&&((Texture::CM_dxt4+1)==Texture::CM_dxt5),false);
+  if ((compression_mode >= Texture::CM_dxt1) && (compression_mode <= Texture::CM_dxt5)) {
     texture_stored_compressed = true;
     texture_stored_compressed = true;
   }
   }
   
   
@@ -160,11 +160,11 @@ create_texture(DXScreenData &scrn) {
     texture_wants_compressed = true;  
     texture_wants_compressed = true;  
   }
   }
   else {
   else {
-    if (get_texture()->get_compression() == Texture::CompressionMode::CM_off) {
+    if (get_texture()->get_compression() == Texture::CM_off) {
       // no compression
       // no compression
     }
     }
     else {    
     else {    
-      if (get_texture()->get_compression() == Texture::CompressionMode::CM_default) {
+      if (get_texture()->get_compression() == Texture::CM_default) {
         // default = use "compressed-textures" config setting
         // default = use "compressed-textures" config setting
         if (compressed_textures) {
         if (compressed_textures) {
           texture_wants_compressed = true;
           texture_wants_compressed = true;
@@ -374,16 +374,16 @@ create_texture(DXScreenData &scrn) {
           // if the texture is already compressed, we need to choose the corresponding format, 
           // if the texture is already compressed, we need to choose the corresponding format, 
           // otherwise we might end up cross-compressing from e.g. DXT5 to DXT3
           // otherwise we might end up cross-compressing from e.g. DXT5 to DXT3
           switch (compression_mode){
           switch (compression_mode){
-          case Texture::CompressionMode::CM_dxt2:
+          case Texture::CM_dxt2:
             CHECK_FOR_FMT(DXT2, Conv32toDXT2);
             CHECK_FOR_FMT(DXT2, Conv32toDXT2);
             break;
             break;
-          case Texture::CompressionMode::CM_dxt3:
+          case Texture::CM_dxt3:
             CHECK_FOR_FMT(DXT3, Conv32toDXT3);
             CHECK_FOR_FMT(DXT3, Conv32toDXT3);
             break;
             break;
-          case Texture::CompressionMode::CM_dxt4:
+          case Texture::CM_dxt4:
             CHECK_FOR_FMT(DXT4, Conv32toDXT4);
             CHECK_FOR_FMT(DXT4, Conv32toDXT4);
             break;
             break;
-          case Texture::CompressionMode::CM_dxt5:
+          case Texture::CM_dxt5:
             CHECK_FOR_FMT(DXT5, Conv32toDXT5);
             CHECK_FOR_FMT(DXT5, Conv32toDXT5);
             break;
             break;
           }
           }

+ 17 - 20
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -706,7 +706,7 @@ reset() {
     // Bug workaround for radeons.
     // Bug workaround for radeons.
     if (_shader_caps._active_fprofile == CG_PROFILE_ARBFP1) {
     if (_shader_caps._active_fprofile == CG_PROFILE_ARBFP1) {
       if (has_extension("GL_ATI_draw_buffers")) {
       if (has_extension("GL_ATI_draw_buffers")) {
-        _shader_caps._bug_list.insert(ShaderExpansion::SBUG_ati_draw_buffers);
+        _shader_caps._bug_list.insert(Shader::SBUG_ati_draw_buffers);
       }
       }
     }    
     }    
   }
   }
@@ -1060,11 +1060,11 @@ reset() {
   GLP(Disable)(GL_DITHER);
   GLP(Disable)(GL_DITHER);
   _dithering_enabled = false;
   _dithering_enabled = false;
 
 
-  _current_shader_expansion = (ShaderExpansion *)NULL;
+  _current_shader = (Shader *)NULL;
   _current_shader_context = (CLP(ShaderContext) *)NULL;
   _current_shader_context = (CLP(ShaderContext) *)NULL;
-  _vertex_array_shader_expansion = (ShaderExpansion *)NULL;
+  _vertex_array_shader = (Shader *)NULL;
   _vertex_array_shader_context = (CLP(ShaderContext) *)NULL;
   _vertex_array_shader_context = (CLP(ShaderContext) *)NULL;
-  _texture_binding_shader_expansion = (ShaderExpansion *)NULL;
+  _texture_binding_shader = (Shader *)NULL;
   _texture_binding_shader_context = (CLP(ShaderContext) *)NULL;
   _texture_binding_shader_context = (CLP(ShaderContext) *)NULL;
 
 
   // Count the max number of lights
   // Count the max number of lights
@@ -1748,7 +1748,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
       }
       }
     }
     }
   }
   }
-  _vertex_array_shader_expansion = _current_shader_expansion;
+  _vertex_array_shader = _current_shader;
   _vertex_array_shader_context = _current_shader_context;
   _vertex_array_shader_context = _current_shader_context;
 
 
   report_my_gl_errors();
   report_my_gl_errors();
@@ -2723,7 +2723,7 @@ release_geom(GeomContext *gc) {
 //  Description: yadda.
 //  Description: yadda.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 ShaderContext *CLP(GraphicsStateGuardian)::
 ShaderContext *CLP(GraphicsStateGuardian)::
-prepare_shader(ShaderExpansion *se) {
+prepare_shader(Shader *se) {
   CLP(ShaderContext) *result = new CLP(ShaderContext)(se, this);
   CLP(ShaderContext) *result = new CLP(ShaderContext)(se, this);
   if (result->valid()) return result;
   if (result->valid()) return result;
   delete result;
   delete result;
@@ -3529,24 +3529,21 @@ do_issue_shade_model() {
 void CLP(GraphicsStateGuardian)::
 void CLP(GraphicsStateGuardian)::
 do_issue_shader() {
 do_issue_shader() {
   CLP(ShaderContext) *context = 0;
   CLP(ShaderContext) *context = 0;
-  ShaderExpansion *expansion = _target_rs->get_shader_expansion();
-  if (expansion == 0) {
-    if (_target._shader->get_shader() != 0) {
-      expansion = _target._shader->get_shader()->macroexpand(_target_rs, _shader_caps);
-      // I am casting away the const-ness of this pointer, because
-      // the 'shader-expansion' field is just a cache.
-      ((RenderState *)((const RenderState*)_target_rs))->
-        set_shader_expansion(expansion);
-    }
+  const ShaderAttrib *attr = _target_rs->get_generated_shader();
+  if (attr == 0) {
+    attr = _target._shader;
+    // if (attr is auto) then generate a shader.
+    // store that shader using set_generated_shader.
   }
   }
-  if (expansion) {
-    context = (CLP(ShaderContext) *)(expansion->prepare_now(get_prepared_objects(), this));
+  Shader *shader = (Shader *)(attr->get_shader());
+  if (shader) {
+    context = (CLP(ShaderContext) *)(shader->prepare_now(get_prepared_objects(), this));
   }
   }
   
   
   if (context == 0 || (context -> valid ( ) == false)) {
   if (context == 0 || (context -> valid ( ) == false)) {
     if (_current_shader_context != 0) {
     if (_current_shader_context != 0) {
       _current_shader_context->unbind();
       _current_shader_context->unbind();
-      _current_shader_expansion = 0;
+      _current_shader = 0;
       _current_shader_context = 0;
       _current_shader_context = 0;
     }
     }
   } else {
   } else {
@@ -3557,7 +3554,7 @@ do_issue_shader() {
         _current_shader_context->unbind();
         _current_shader_context->unbind();
       }
       }
       context->bind(this);
       context->bind(this);
-      _current_shader_expansion = expansion;
+      _current_shader = shader;
       _current_shader_context = context;
       _current_shader_context = context;
     } else {
     } else {
       // Use the same shader as before, but with new input arguments.
       // Use the same shader as before, but with new input arguments.
@@ -6086,7 +6083,7 @@ do_issue_texture() {
         update_shader_texture_bindings(_texture_binding_shader_context,this);
         update_shader_texture_bindings(_texture_binding_shader_context,this);
     }
     }
   }
   }
-  _texture_binding_shader_expansion = _current_shader_expansion;
+  _texture_binding_shader = _current_shader;
   _texture_binding_shader_context = _current_shader_context;
   _texture_binding_shader_context = _current_shader_context;
 }
 }
 
 

+ 4 - 4
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -133,7 +133,7 @@ public:
   virtual GeomContext *prepare_geom(Geom *geom);
   virtual GeomContext *prepare_geom(Geom *geom);
   virtual void release_geom(GeomContext *gc);
   virtual void release_geom(GeomContext *gc);
 
 
-  virtual ShaderContext *prepare_shader(ShaderExpansion *shader);
+  virtual ShaderContext *prepare_shader(Shader *shader);
   virtual void release_shader(ShaderContext *sc);
   virtual void release_shader(ShaderContext *sc);
 
 
   void record_deleted_display_list(GLuint index);
   void record_deleted_display_list(GLuint index);
@@ -359,11 +359,11 @@ protected:
   bool _point_perspective;
   bool _point_perspective;
   bool _vertex_blending_enabled;
   bool _vertex_blending_enabled;
 
 
-  PT(ShaderExpansion)  _current_shader_expansion;
+  PT(Shader)  _current_shader;
   CLP(ShaderContext)  *_current_shader_context;
   CLP(ShaderContext)  *_current_shader_context;
-  PT(ShaderExpansion)  _vertex_array_shader_expansion;
+  PT(Shader)  _vertex_array_shader;
   CLP(ShaderContext)  *_vertex_array_shader_context;
   CLP(ShaderContext)  *_vertex_array_shader_context;
-  PT(ShaderExpansion)  _texture_binding_shader_expansion;
+  PT(Shader)  _texture_binding_shader;
   CLP(ShaderContext)  *_texture_binding_shader_context;
   CLP(ShaderContext)  *_texture_binding_shader_context;
 
 
 #ifdef SUPPORT_IMMEDIATE_MODE
 #ifdef SUPPORT_IMMEDIATE_MODE

+ 37 - 37
panda/src/glstuff/glShaderContext_src.cxx

@@ -31,11 +31,11 @@ TypeHandle CLP(ShaderContext)::_type_handle;
 //  Description: xyz
 //  Description: xyz
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 CLP(ShaderContext)::
 CLP(ShaderContext)::
-CLP(ShaderContext)(ShaderExpansion *s, GSG *gsg) : ShaderContext(s) {
+CLP(ShaderContext)(Shader *s, GSG *gsg) : ShaderContext(s) {
 #ifdef HAVE_CG
 #ifdef HAVE_CG
   if (s->get_header() == "//Cg") {
   if (s->get_header() == "//Cg") {
     
     
-    // Ask the shader expansion to compile itself for us and 
+    // Ask the shader to compile itself for us and 
     // to give us the resulting Cg program objects.
     // to give us the resulting Cg program objects.
 
 
     if (!s->cg_compile_for(gsg->_shader_caps,
     if (!s->cg_compile_for(gsg->_shader_caps,
@@ -52,7 +52,7 @@ CLP(ShaderContext)(ShaderExpansion *s, GSG *gsg) : ShaderContext(s) {
     CGerror verror = cgGetError();
     CGerror verror = cgGetError();
     if (verror != CG_NO_ERROR) {
     if (verror != CG_NO_ERROR) {
       const char *str = (const char *)GLP(GetString)(GL_PROGRAM_ERROR_STRING_ARB);
       const char *str = (const char *)GLP(GetString)(GL_PROGRAM_ERROR_STRING_ARB);
-      GLCAT.error() << "Could not load Cg vertex program:" << s->get_name() << " (" << 
+      GLCAT.error() << "Could not load Cg vertex program:" << s->get_filename() << " (" << 
         cgGetProfileString(cgGetProgramProfile(_cg_vprogram)) << " " << str << ")\n";
         cgGetProfileString(cgGetProgramProfile(_cg_vprogram)) << " " << str << ")\n";
       release_resources();
       release_resources();
     }
     }
@@ -60,7 +60,7 @@ CLP(ShaderContext)(ShaderExpansion *s, GSG *gsg) : ShaderContext(s) {
     CGerror ferror = cgGetError();
     CGerror ferror = cgGetError();
     if (ferror != CG_NO_ERROR) {
     if (ferror != CG_NO_ERROR) {
       const char *str = (const char *)GLP(GetString)(GL_PROGRAM_ERROR_STRING_ARB);
       const char *str = (const char *)GLP(GetString)(GL_PROGRAM_ERROR_STRING_ARB);
-      GLCAT.error() << "Could not load Cg fragment program:" << s->get_name() << " (" << 
+      GLCAT.error() << "Could not load Cg fragment program:" << s->get_filename() << " (" << 
         cgGetProfileString(cgGetProgramProfile(_cg_fprogram)) << " " << str << ")\n";
         cgGetProfileString(cgGetProgramProfile(_cg_fprogram)) << " " << str << ")\n";
       release_resources();
       release_resources();
     }
     }
@@ -142,7 +142,7 @@ unbind() {
 //     Function: GLShaderContext::issue_parameters
 //     Function: GLShaderContext::issue_parameters
 //       Access: Public
 //       Access: Public
 //  Description: This function gets called whenever the RenderState
 //  Description: This function gets called whenever the RenderState
-//               or TransformState has changed, but the ShaderExpansion
+//               or TransformState has changed, but the Shader
 //               itself has not changed.  It loads new values into the
 //               itself has not changed.  It loads new values into the
 //               shader's parameters.
 //               shader's parameters.
 //
 //
@@ -160,23 +160,23 @@ issue_parameters(GSG *gsg, bool altered) {
     return;
     return;
   }
   }
 
 
-  for (int i=0; i<(int)_expansion->_mat_spec.size(); i++) {
-    if (altered || _expansion->_mat_spec[i]._trans_dependent) {
-      CGparameter p = _cg_parameter_map[_expansion->_mat_spec[i]._id._seqno];
-      const LMatrix4f *val = gsg->fetch_specified_value(_expansion->_mat_spec[i], altered);
+  for (int i=0; i<(int)_shader->_mat_spec.size(); i++) {
+    if (altered || _shader->_mat_spec[i]._trans_dependent) {
+      CGparameter p = _cg_parameter_map[_shader->_mat_spec[i]._id._seqno];
+      const LMatrix4f *val = gsg->fetch_specified_value(_shader->_mat_spec[i], altered);
       if (val) {
       if (val) {
         const float *data = val->get_data();
         const float *data = val->get_data();
-        switch (_expansion->_mat_spec[i]._piece) {
-        case ShaderExpansion::SMP_whole: cgGLSetMatrixParameterfc(p, data); break;
-        case ShaderExpansion::SMP_transpose: cgGLSetMatrixParameterfr(p, data); break;
-        case ShaderExpansion::SMP_row0: cgGLSetParameter4fv(p, data+ 0); break;
-        case ShaderExpansion::SMP_row1: cgGLSetParameter4fv(p, data+ 4); break;
-        case ShaderExpansion::SMP_row2: cgGLSetParameter4fv(p, data+ 8); break;
-        case ShaderExpansion::SMP_row3: cgGLSetParameter4fv(p, data+12); break;
-        case ShaderExpansion::SMP_col0: cgGLSetParameter4f(p, data[0], data[4], data[ 8], data[12]); break;
-        case ShaderExpansion::SMP_col1: cgGLSetParameter4f(p, data[1], data[5], data[ 9], data[13]); break;
-        case ShaderExpansion::SMP_col2: cgGLSetParameter4f(p, data[2], data[6], data[10], data[14]); break;
-        case ShaderExpansion::SMP_col3: cgGLSetParameter4f(p, data[3], data[7], data[11], data[15]); break;
+        switch (_shader->_mat_spec[i]._piece) {
+        case Shader::SMP_whole: cgGLSetMatrixParameterfc(p, data); break;
+        case Shader::SMP_transpose: cgGLSetMatrixParameterfr(p, data); break;
+        case Shader::SMP_row0: cgGLSetParameter4fv(p, data+ 0); break;
+        case Shader::SMP_row1: cgGLSetParameter4fv(p, data+ 4); break;
+        case Shader::SMP_row2: cgGLSetParameter4fv(p, data+ 8); break;
+        case Shader::SMP_row3: cgGLSetParameter4fv(p, data+12); break;
+        case Shader::SMP_col0: cgGLSetParameter4f(p, data[0], data[4], data[ 8], data[12]); break;
+        case Shader::SMP_col1: cgGLSetParameter4f(p, data[1], data[5], data[ 9], data[13]); break;
+        case Shader::SMP_col2: cgGLSetParameter4f(p, data[2], data[6], data[10], data[14]); break;
+        case Shader::SMP_col3: cgGLSetParameter4f(p, data[3], data[7], data[11], data[15]); break;
         }
         }
       }
       }
     }
     }
@@ -197,8 +197,8 @@ disable_shader_vertex_arrays(GSG *gsg) {
     return;
     return;
   }
   }
 
 
-  for (int i=0; i<(int)_expansion->_var_spec.size(); i++) {
-    CGparameter p = _cg_parameter_map[_expansion->_var_spec[i]._id._seqno];
+  for (int i=0; i<(int)_shader->_var_spec.size(); i++) {
+    CGparameter p = _cg_parameter_map[_shader->_var_spec[i]._id._seqno];
     if (p == 0) continue;
     if (p == 0) continue;
     cgGLDisableClientState(p);
     cgGLDisableClientState(p);
   }
   }
@@ -236,12 +236,12 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg,
     const GeomVertexArrayDataHandle *array_reader;
     const GeomVertexArrayDataHandle *array_reader;
     Geom::NumericType numeric_type;
     Geom::NumericType numeric_type;
     int start, stride, num_values;
     int start, stride, num_values;
-    int nvarying = _expansion->_var_spec.size();
+    int nvarying = _shader->_var_spec.size();
     for (int i=0; i<nvarying; i++) {
     for (int i=0; i<nvarying; i++) {
-      CGparameter p = _cg_parameter_map[_expansion->_var_spec[i]._id._seqno];
+      CGparameter p = _cg_parameter_map[_shader->_var_spec[i]._id._seqno];
       if (p == 0) continue;
       if (p == 0) continue;
-      InternalName *name = _expansion->_var_spec[i]._name;
-      int texslot = _expansion->_var_spec[i]._append_uv;
+      InternalName *name = _shader->_var_spec[i]._name;
+      int texslot = _shader->_var_spec[i]._append_uv;
       if (texslot >= 0) {
       if (texslot >= 0) {
         const Geom::ActiveTextureStages &active_stages =
         const Geom::ActiveTextureStages &active_stages =
           gsg->_state._texture->get_on_stages();
           gsg->_state._texture->get_on_stages();
@@ -288,8 +288,8 @@ disable_shader_texture_bindings(GSG *gsg) {
     return;
     return;
   }
   }
 
 
-  for (int i=0; i<(int)_expansion->_tex_spec.size(); i++) {
-    CGparameter p = _cg_parameter_map[_expansion->_tex_spec[i]._id._seqno];
+  for (int i=0; i<(int)_shader->_tex_spec.size(); i++) {
+    CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._seqno];
     if (p == 0) continue;
     if (p == 0) continue;
     int texunit = cgGetParameterResourceIndex(p);
     int texunit = cgGetParameterResourceIndex(p);
     gsg->_glActiveTexture(GL_TEXTURE0 + texunit);
     gsg->_glActiveTexture(GL_TEXTURE0 + texunit);
@@ -327,29 +327,29 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg) {
     return;
     return;
   }
   }
 
 
-  for (int i=0; i<(int)_expansion->_tex_spec.size(); i++) {
-    CGparameter p = _cg_parameter_map[_expansion->_tex_spec[i]._id._seqno];
+  for (int i=0; i<(int)_shader->_tex_spec.size(); i++) {
+    CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._seqno];
     if (p == 0) continue;
     if (p == 0) continue;
     Texture *tex = 0;
     Texture *tex = 0;
-    InternalName *id = _expansion->_tex_spec[i]._name;
+    InternalName *id = _shader->_tex_spec[i]._name;
     if (id != 0) {
     if (id != 0) {
       const ShaderInput *input = gsg->_target._shader->get_shader_input(id);
       const ShaderInput *input = gsg->_target._shader->get_shader_input(id);
       tex = input->get_texture();
       tex = input->get_texture();
     } else {
     } else {
-      if (_expansion->_tex_spec[i]._stage >= gsg->_target._texture->get_num_on_stages()) {
+      if (_shader->_tex_spec[i]._stage >= gsg->_target._texture->get_num_on_stages()) {
         continue;
         continue;
       }
       }
-      TextureStage *stage = gsg->_target._texture->get_on_stage(_expansion->_tex_spec[i]._stage);
+      TextureStage *stage = gsg->_target._texture->get_on_stage(_shader->_tex_spec[i]._stage);
       tex = gsg->_target._texture->get_on_texture(stage);
       tex = gsg->_target._texture->get_on_texture(stage);
     }
     }
-    if (_expansion->_tex_spec[i]._suffix != 0) {
+    if (_shader->_tex_spec[i]._suffix != 0) {
       // The suffix feature is inefficient. It is a temporary hack.
       // The suffix feature is inefficient. It is a temporary hack.
       if (tex == 0) {
       if (tex == 0) {
         continue;
         continue;
       }
       }
-      tex = tex->load_related(_expansion->_tex_spec[i]._suffix);
+      tex = tex->load_related(_shader->_tex_spec[i]._suffix);
     }
     }
-    if ((tex == 0) || (tex->get_texture_type() != _expansion->_tex_spec[i]._desired_type)) {
+    if ((tex == 0) || (tex->get_texture_type() != _shader->_tex_spec[i]._desired_type)) {
       continue;
       continue;
     }
     }
     TextureContext *tc = tex->prepare_now(gsg->_prepared_objects, gsg);
     TextureContext *tc = tex->prepare_now(gsg->_prepared_objects, gsg);
@@ -383,7 +383,7 @@ void CLP(ShaderContext)::
 cg_report_errors() {
 cg_report_errors() {
   CGerror err = cgGetError();
   CGerror err = cgGetError();
   if (err != CG_NO_ERROR) {
   if (err != CG_NO_ERROR) {
-    GLCAT.error() << _expansion->get_name() << " " << cgGetErrorString(err) << "\n";
+    GLCAT.error() << _shader->get_filename() << " " << cgGetErrorString(err) << "\n";
   }
   }
 }
 }
 #endif
 #endif

+ 2 - 2
panda/src/glstuff/glShaderContext_src.h

@@ -19,7 +19,7 @@
 #include "pandabase.h"
 #include "pandabase.h"
 #include "string_utils.h"
 #include "string_utils.h"
 #include "internalName.h"
 #include "internalName.h"
-#include "shaderExpansion.h"
+#include "shader.h"
 #include "shaderContext.h"
 #include "shaderContext.h"
 #include "deletedChain.h"
 #include "deletedChain.h"
 
 
@@ -34,7 +34,7 @@ class EXPCL_GL CLP(ShaderContext): public ShaderContext {
 public:
 public:
   typedef CLP(GraphicsStateGuardian) GSG;
   typedef CLP(GraphicsStateGuardian) GSG;
 
 
-  CLP(ShaderContext)(ShaderExpansion *s, GSG *gsg);
+  CLP(ShaderContext)(Shader *s, GSG *gsg);
   ~CLP(ShaderContext)();
   ~CLP(ShaderContext)();
   ALLOC_DELETED_CHAIN(CLP(ShaderContext));
   ALLOC_DELETED_CHAIN(CLP(ShaderContext));
 
 

+ 3 - 2
panda/src/gobj/config_gobj.cxx

@@ -44,7 +44,7 @@
 #include "texturePoolFilter.h"
 #include "texturePoolFilter.h"
 #include "textureStage.h"
 #include "textureStage.h"
 #include "textureContext.h"
 #include "textureContext.h"
-#include "shaderExpansion.h"
+#include "shader.h"
 #include "shaderContext.h"
 #include "shaderContext.h"
 #include "transformBlend.h"
 #include "transformBlend.h"
 #include "transformBlendTable.h"
 #include "transformBlendTable.h"
@@ -356,7 +356,7 @@ ConfigureFn(config_gobj) {
   PerspectiveLens::init_type();
   PerspectiveLens::init_type();
   QueryContext::init_type();
   QueryContext::init_type();
   ShaderContext::init_type();
   ShaderContext::init_type();
-  ShaderExpansion::init_type();
+  Shader::init_type();
   SliderTable::init_type();
   SliderTable::init_type();
   Texture::init_type();
   Texture::init_type();
   TextureContext::init_type();
   TextureContext::init_type();
@@ -392,6 +392,7 @@ ConfigureFn(config_gobj) {
   MatrixLens::register_with_read_factory();
   MatrixLens::register_with_read_factory();
   OrthographicLens::register_with_read_factory();
   OrthographicLens::register_with_read_factory();
   PerspectiveLens::register_with_read_factory();
   PerspectiveLens::register_with_read_factory();
+  Shader::register_with_read_factory();
   SliderTable::register_with_read_factory();
   SliderTable::register_with_read_factory();
   Texture::register_with_read_factory();
   Texture::register_with_read_factory();
   TextureStage::register_with_read_factory();
   TextureStage::register_with_read_factory();

+ 1 - 1
panda/src/gobj/gobj_composite2.cxx

@@ -8,7 +8,7 @@
 #include "queryContext.cxx"
 #include "queryContext.cxx"
 #include "savedContext.cxx"
 #include "savedContext.cxx"
 #include "shaderContext.cxx"
 #include "shaderContext.cxx"
-#include "shaderExpansion.cxx"
+#include "shader.cxx"
 #include "simpleAllocator.cxx"
 #include "simpleAllocator.cxx"
 #include "simpleLru.cxx"
 #include "simpleLru.cxx"
 #include "sliderTable.cxx"
 #include "sliderTable.cxx"

+ 12 - 12
panda/src/gobj/preparedGraphicsObjects.cxx

@@ -24,7 +24,7 @@
 #include "geom.h"
 #include "geom.h"
 #include "geomVertexArrayData.h"
 #include "geomVertexArrayData.h"
 #include "geomPrimitive.h"
 #include "geomPrimitive.h"
-#include "shaderExpansion.h"
+#include "shader.h"
 #include "reMutexHolder.h"
 #include "reMutexHolder.h"
 #include "geomContext.h"
 #include "geomContext.h"
 #include "shaderContext.h"
 #include "shaderContext.h"
@@ -487,7 +487,7 @@ prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg) {
 //               do this (presumably at the next frame).
 //               do this (presumably at the next frame).
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void PreparedGraphicsObjects::
 void PreparedGraphicsObjects::
-enqueue_shader(ShaderExpansion *se) {
+enqueue_shader(Shader *se) {
   ReMutexHolder holder(_lock);
   ReMutexHolder holder(_lock);
 
 
   _enqueued_shaders.insert(se);
   _enqueued_shaders.insert(se);
@@ -500,10 +500,10 @@ enqueue_shader(ShaderExpansion *se) {
 //               GSG, false otherwise.
 //               GSG, false otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool PreparedGraphicsObjects::
 bool PreparedGraphicsObjects::
-is_shader_queued(const ShaderExpansion *shader) const {
+is_shader_queued(const Shader *shader) const {
   ReMutexHolder holder(_lock);
   ReMutexHolder holder(_lock);
 
 
-  EnqueuedShaders::const_iterator qi = _enqueued_shaders.find((ShaderExpansion *)shader);
+  EnqueuedShaders::const_iterator qi = _enqueued_shaders.find((Shader *)shader);
   return (qi != _enqueued_shaders.end());
   return (qi != _enqueued_shaders.end());
 }
 }
 
 
@@ -522,7 +522,7 @@ is_shader_queued(const ShaderExpansion *shader) const {
 //               queued.
 //               queued.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool PreparedGraphicsObjects::
 bool PreparedGraphicsObjects::
-dequeue_shader(ShaderExpansion *se) {
+dequeue_shader(Shader *se) {
   ReMutexHolder holder(_lock);
   ReMutexHolder holder(_lock);
 
 
   EnqueuedShaders::iterator qi = _enqueued_shaders.find(se);
   EnqueuedShaders::iterator qi = _enqueued_shaders.find(se);
@@ -540,7 +540,7 @@ dequeue_shader(ShaderExpansion *se) {
 //               this GSG, false otherwise.
 //               this GSG, false otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool PreparedGraphicsObjects::
 bool PreparedGraphicsObjects::
-is_shader_prepared(const ShaderExpansion *shader) const {
+is_shader_prepared(const Shader *shader) const {
   return shader->is_prepared((PreparedGraphicsObjects *)this);
   return shader->is_prepared((PreparedGraphicsObjects *)this);
 }
 }
 
 
@@ -561,12 +561,12 @@ void PreparedGraphicsObjects::
 release_shader(ShaderContext *sc) {
 release_shader(ShaderContext *sc) {
   ReMutexHolder holder(_lock);
   ReMutexHolder holder(_lock);
 
 
-  sc->_expansion->clear_prepared(this);
+  sc->_shader->clear_prepared(this);
 
 
   // We have to set the Shader pointer to NULL at this point, since
   // We have to set the Shader pointer to NULL at this point, since
   // the Shader itself might destruct at any time after it has been
   // the Shader itself might destruct at any time after it has been
   // released.
   // released.
-  sc->_expansion = (ShaderExpansion *)NULL;
+  sc->_shader = (Shader *)NULL;
 
 
   bool removed = (_prepared_shaders.erase(sc) != 0);
   bool removed = (_prepared_shaders.erase(sc) != 0);
   nassertv(removed);
   nassertv(removed);
@@ -593,8 +593,8 @@ release_all_shaders() {
        sci != _prepared_shaders.end();
        sci != _prepared_shaders.end();
        ++sci) {
        ++sci) {
     ShaderContext *sc = (*sci);
     ShaderContext *sc = (*sci);
-    sc->_expansion->clear_prepared(this);
-    sc->_expansion = (ShaderExpansion *)NULL;
+    sc->_shader->clear_prepared(this);
+    sc->_shader = (Shader *)NULL;
 
 
     _released_shaders.insert(sc);
     _released_shaders.insert(sc);
   }
   }
@@ -650,7 +650,7 @@ get_num_prepared_shaders() const {
 //               ShaderContext will be deleted.
 //               ShaderContext will be deleted.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 ShaderContext *PreparedGraphicsObjects::
 ShaderContext *PreparedGraphicsObjects::
-prepare_shader_now(ShaderExpansion *se, GraphicsStateGuardianBase *gsg) {
+prepare_shader_now(Shader *se, GraphicsStateGuardianBase *gsg) {
   ReMutexHolder holder(_lock);
   ReMutexHolder holder(_lock);
 
 
   // Ask the GSG to create a brand new ShaderContext.  There might
   // Ask the GSG to create a brand new ShaderContext.  There might
@@ -1226,7 +1226,7 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) {
   for (qsi = _enqueued_shaders.begin();
   for (qsi = _enqueued_shaders.begin();
        qsi != _enqueued_shaders.end();
        qsi != _enqueued_shaders.end();
        ++qsi) {
        ++qsi) {
-    ShaderExpansion *shader = (*qsi);
+    Shader *shader = (*qsi);
     shader->prepare_now(this, gsg);
     shader->prepare_now(this, gsg);
   }
   }
 
 

+ 7 - 7
panda/src/gobj/preparedGraphicsObjects.h

@@ -25,7 +25,7 @@
 #include "geom.h"
 #include "geom.h"
 #include "geomVertexArrayData.h"
 #include "geomVertexArrayData.h"
 #include "geomPrimitive.h"
 #include "geomPrimitive.h"
-#include "shaderExpansion.h"
+#include "shader.h"
 #include "pointerTo.h"
 #include "pointerTo.h"
 #include "pStatCollector.h"
 #include "pStatCollector.h"
 #include "pset.h"
 #include "pset.h"
@@ -92,16 +92,16 @@ PUBLISHED:
 
 
   GeomContext *prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg);
   GeomContext *prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg);
 
 
-  void enqueue_shader(ShaderExpansion *shader);
-  bool is_shader_queued(const ShaderExpansion *shader) const;
-  bool dequeue_shader(ShaderExpansion *shader);
-  bool is_shader_prepared(const ShaderExpansion *shader) const;
+  void enqueue_shader(Shader *shader);
+  bool is_shader_queued(const Shader *shader) const;
+  bool dequeue_shader(Shader *shader);
+  bool is_shader_prepared(const Shader *shader) const;
   void release_shader(ShaderContext *sc);
   void release_shader(ShaderContext *sc);
   int release_all_shaders();
   int release_all_shaders();
   int get_num_queued_shaders() const;
   int get_num_queued_shaders() const;
   int get_num_prepared_shaders() const;
   int get_num_prepared_shaders() const;
 
 
-  ShaderContext *prepare_shader_now(ShaderExpansion *shader, GraphicsStateGuardianBase *gsg);
+  ShaderContext *prepare_shader_now(Shader *shader, GraphicsStateGuardianBase *gsg);
 
 
   void enqueue_vertex_buffer(GeomVertexArrayData *data);
   void enqueue_vertex_buffer(GeomVertexArrayData *data);
   bool is_vertex_buffer_queued(const GeomVertexArrayData *data) const;
   bool is_vertex_buffer_queued(const GeomVertexArrayData *data) const;
@@ -143,7 +143,7 @@ private:
   typedef phash_set<GeomContext *, pointer_hash> Geoms;
   typedef phash_set<GeomContext *, pointer_hash> Geoms;
   typedef phash_set< PT(Geom) > EnqueuedGeoms;
   typedef phash_set< PT(Geom) > EnqueuedGeoms;
   typedef phash_set<ShaderContext *, pointer_hash> Shaders;
   typedef phash_set<ShaderContext *, pointer_hash> Shaders;
-  typedef phash_set< PT(ShaderExpansion) > EnqueuedShaders;
+  typedef phash_set< PT(Shader) > EnqueuedShaders;
   typedef phash_set<BufferContext *, pointer_hash> Buffers;
   typedef phash_set<BufferContext *, pointer_hash> Buffers;
   typedef phash_set< PT(GeomVertexArrayData) > EnqueuedVertexBuffers;
   typedef phash_set< PT(GeomVertexArrayData) > EnqueuedVertexBuffers;
   typedef phash_set< PT(GeomPrimitive) > EnqueuedIndexBuffers;
   typedef phash_set< PT(GeomPrimitive) > EnqueuedIndexBuffers;

+ 18 - 35
panda/src/gobj/shaderExpansion.I → panda/src/gobj/shader.I

@@ -1,4 +1,4 @@
-// Filename: shaderExpansion.I
+// Filename: shader.I
 // Heavily Modified:  jyelon (Sep05)
 // Heavily Modified:  jyelon (Sep05)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -17,80 +17,63 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::get_name
+//  Function: Shader::get_filename
 //  Access: Public
 //  Access: Public
-//  Description: Return the ShaderExpansion's text.
+//  Description: Return the Shader's filename.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE const string &ShaderExpansion::
-get_name() const {
-  return _name;
+INLINE const Filename &Shader::
+get_filename() const {
+  return _filename;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::get_text
+//  Function: Shader::get_text
 //  Access: Public
 //  Access: Public
-//  Description: Return the ShaderExpansion's text.
+//  Description: Return the Shader's text.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE const string &ShaderExpansion::
+INLINE const string &Shader::
 get_text() const {
 get_text() const {
   return _text;
   return _text;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::get_header
+//  Function: Shader::get_header
 //  Access: Public
 //  Access: Public
-//  Description: Return the ShaderExpansion's header line.
+//  Description: Return the Shader's header line.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE const string &ShaderExpansion::
+INLINE const string &Shader::
 get_header() const {
 get_header() const {
   return _header;
   return _header;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::get_error_flag
+//  Function: Shader::get_error_flag
 //  Access: Public
 //  Access: Public
 //  Description: Returns true if the shader contains a compile-time
 //  Description: Returns true if the shader contains a compile-time
 //               error.  This doesn't tell you whether or not the
 //               error.  This doesn't tell you whether or not the
 //               shader is supported on the current video card.
 //               shader is supported on the current video card.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE bool ShaderExpansion::
+INLINE bool Shader::
 get_error_flag() const {
 get_error_flag() const {
   return _error_flag;
   return _error_flag;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::ShaderCapabilities Constructor
+//  Function: Shader::ShaderCapabilities Constructor
 //  Access: Public
 //  Access: Public
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE ShaderExpansion::ShaderCaps::
+INLINE Shader::ShaderCaps::
 ShaderCaps() {
 ShaderCaps() {
   clear();
   clear();
 }
 }
 
 
-
-////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::ShaderCapabilities::clear()
-//  Access: Public
-//  Description: 
-////////////////////////////////////////////////////////////////////
-INLINE void ShaderExpansion::ShaderCaps::
-clear() {
-#ifdef HAVE_CG
-  _active_vprofile = 0;
-  _active_fprofile = 0;
-  _ultimate_vprofile = 0;
-  _ultimate_fprofile = 0;
-#endif
-}
-
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::ShaderCapabilities::operator ==
+//  Function: Shader::ShaderCapabilities::operator ==
 //  Access: Public
 //  Access: Public
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE bool ShaderExpansion::ShaderCaps::
+INLINE bool Shader::ShaderCaps::
 operator == (const ShaderCaps &other) const {
 operator == (const ShaderCaps &other) const {
 #ifdef HAVE_CG
 #ifdef HAVE_CG
   if ((_active_vprofile != other._active_vprofile) ||
   if ((_active_vprofile != other._active_vprofile) ||

+ 177 - 109
panda/src/gobj/shaderExpansion.cxx → panda/src/gobj/shader.cxx

@@ -1,4 +1,4 @@
-// Filename: shaderExpansion.cxx
+// Filename: shader.cxx
 // Created by: jyelon (01Sep05)
 // Created by: jyelon (01Sep05)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -17,23 +17,26 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #include "pandabase.h"
 #include "pandabase.h"
-#include "shaderExpansion.h"
+#include "shader.h"
 #include "preparedGraphicsObjects.h"
 #include "preparedGraphicsObjects.h"
+#include "virtualFileSystem.h"
 
 
 #ifdef HAVE_CG
 #ifdef HAVE_CG
 #include "Cg/cg.h"
 #include "Cg/cg.h"
 #endif
 #endif
 
 
-TypeHandle ShaderExpansion::_type_handle;
-ShaderExpansion::ExpansionCache ShaderExpansion::_expansion_cache;
+TypeHandle Shader::_type_handle;
+Shader::LoadTable Shader::_load_table;
+Shader::MakeTable Shader::_make_table;
+Shader::ShaderCaps Shader::_default_caps;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_report_error
+//     Function: Shader::cp_report_error
 //       Access: Public
 //       Access: Public
 //  Description: Generate an error message including a description
 //  Description: Generate an error message including a description
 //               of the specified parameter.
 //               of the specified parameter.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 cp_report_error(ShaderArgInfo &p, const string &msg)
 cp_report_error(ShaderArgInfo &p, const string &msg)
 {
 {
   string vstr;
   string vstr;
@@ -59,19 +62,19 @@ cp_report_error(ShaderArgInfo &p, const string &msg)
   case SAT_unknown: tstr = "unknown "; break;
   case SAT_unknown: tstr = "unknown "; break;
   }
   }
 
 
-  string fn = get_name();
+  Filename fn = get_filename();
   p._cat->error() << fn << ": " << msg << " (" <<
   p._cat->error() << fn << ": " << msg << " (" <<
     vstr << dstr << tstr << p._id._name << ")\n";
     vstr << dstr << tstr << p._id._name << ")\n";
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_errchk_parameter_words
+//     Function: Shader::cp_errchk_parameter_words
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: Make sure the provided parameter contains
 //  Description: Make sure the provided parameter contains
 //               the specified number of words.  If not, print
 //               the specified number of words.  If not, print
 //               error message and return false.
 //               error message and return false.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cp_errchk_parameter_words(ShaderArgInfo &p, int len)
 cp_errchk_parameter_words(ShaderArgInfo &p, int len)
 {
 {
   vector_string words;
   vector_string words;
@@ -84,13 +87,13 @@ cp_errchk_parameter_words(ShaderArgInfo &p, int len)
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_errchk_parameter_in
+//     Function: Shader::cp_errchk_parameter_in
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: Make sure the provided parameter has the
 //  Description: Make sure the provided parameter has the
 //               'in' direction.  If not, print
 //               'in' direction.  If not, print
 //               error message and return false.
 //               error message and return false.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cp_errchk_parameter_in(ShaderArgInfo &p)
 cp_errchk_parameter_in(ShaderArgInfo &p)
 {
 {
   if (p._direction != SAD_in) {
   if (p._direction != SAD_in) {
@@ -101,13 +104,13 @@ cp_errchk_parameter_in(ShaderArgInfo &p)
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_errchk_parameter_varying
+//     Function: Shader::cp_errchk_parameter_varying
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: Make sure the provided parameter has the
 //  Description: Make sure the provided parameter has the
 //               correct variance.  If not, print
 //               correct variance.  If not, print
 //               error message and return false.
 //               error message and return false.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cp_errchk_parameter_varying(ShaderArgInfo &p)
 cp_errchk_parameter_varying(ShaderArgInfo &p)
 {
 {
   if (!p._varying) {
   if (!p._varying) {
@@ -118,13 +121,13 @@ cp_errchk_parameter_varying(ShaderArgInfo &p)
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_errchk_parameter_uniform
+//     Function: Shader::cp_errchk_parameter_uniform
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: Make sure the provided parameter has the
 //  Description: Make sure the provided parameter has the
 //               correct variance.  If not, print
 //               correct variance.  If not, print
 //               error message and return false.
 //               error message and return false.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cp_errchk_parameter_uniform(ShaderArgInfo &p)
 cp_errchk_parameter_uniform(ShaderArgInfo &p)
 {
 {
   if (p._varying) {
   if (p._varying) {
@@ -135,13 +138,13 @@ cp_errchk_parameter_uniform(ShaderArgInfo &p)
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_errchk_parameter_float
+//     Function: Shader::cp_errchk_parameter_float
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: Make sure the provided parameter has
 //  Description: Make sure the provided parameter has
 //               a floating point type.  If not, print
 //               a floating point type.  If not, print
 //               error message and return false.
 //               error message and return false.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cp_errchk_parameter_float(ShaderArgInfo &p, int lo, int hi)
 cp_errchk_parameter_float(ShaderArgInfo &p, int lo, int hi)
 {
 {
   int nfloat;
   int nfloat;
@@ -162,13 +165,13 @@ cp_errchk_parameter_float(ShaderArgInfo &p, int lo, int hi)
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_errchk_parameter_sampler
+//     Function: Shader::cp_errchk_parameter_sampler
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: Make sure the provided parameter has
 //  Description: Make sure the provided parameter has
 //               a texture type.  If not, print
 //               a texture type.  If not, print
 //               error message and return false.
 //               error message and return false.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cp_errchk_parameter_sampler(ShaderArgInfo &p)
 cp_errchk_parameter_sampler(ShaderArgInfo &p)
 {
 {
   if ((p._type!=SAT_sampler1d)&&
   if ((p._type!=SAT_sampler1d)&&
@@ -182,11 +185,11 @@ cp_errchk_parameter_sampler(ShaderArgInfo &p)
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_parse_trans_clause
+//     Function: Shader::cp_parse_trans_clause
 //       Access: Public
 //       Access: Public
 //  Description: Parses a single clause of a "trans" parameter.
 //  Description: Parses a single clause of a "trans" parameter.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cp_parse_trans_clause(ShaderArgInfo &p, ShaderMatSpec &spec, 
 cp_parse_trans_clause(ShaderArgInfo &p, ShaderMatSpec &spec, 
                       int part, const vector_string &pieces,
                       int part, const vector_string &pieces,
                       int &next, ShaderMatInput ofop, ShaderMatInput op) {
                       int &next, ShaderMatInput ofop, ShaderMatInput op) {
@@ -208,7 +211,7 @@ cp_parse_trans_clause(ShaderArgInfo &p, ShaderMatSpec &spec,
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cp_optimize_mat_spec
+//     Function: Shader::cp_optimize_mat_spec
 //       Access: Public
 //       Access: Public
 //  Description: Analyzes a ShaderMatSpec and decides what it should
 //  Description: Analyzes a ShaderMatSpec and decides what it should
 //               use its cache for.  It can cache the results of any
 //               use its cache for.  It can cache the results of any
@@ -216,7 +219,7 @@ cp_parse_trans_clause(ShaderArgInfo &p, ShaderMatSpec &spec,
 //               routine needs to be smart enough to know which
 //               routine needs to be smart enough to know which
 //               data items can be correctly cached, and which cannot.
 //               data items can be correctly cached, and which cannot.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 cp_optimize_mat_spec(ShaderMatSpec &spec) {
 cp_optimize_mat_spec(ShaderMatSpec &spec) {
 
 
   // If we're composing with identity, simplify.
   // If we're composing with identity, simplify.
@@ -263,7 +266,7 @@ cp_optimize_mat_spec(ShaderMatSpec &spec) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::compile_parameter
+//     Function: Shader::compile_parameter
 //       Access: Public
 //       Access: Public
 //  Description: Analyzes a parameter and decides how to
 //  Description: Analyzes a parameter and decides how to
 //               bind the parameter to some part of panda's
 //               bind the parameter to some part of panda's
@@ -273,7 +276,7 @@ cp_optimize_mat_spec(ShaderMatSpec &spec) {
 //               If there is an error, this routine will append
 //               If there is an error, this routine will append
 //               an error message onto the error messages.
 //               an error message onto the error messages.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 compile_parameter(const ShaderArgId  &arg_id,
 compile_parameter(const ShaderArgId  &arg_id,
                   ShaderArgType       arg_type,
                   ShaderArgType       arg_type,
                   ShaderArgDir        arg_direction,
                   ShaderArgDir        arg_direction,
@@ -702,11 +705,11 @@ compile_parameter(const ShaderArgId  &arg_id,
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::clear_parameters
+//     Function: Shader::clear_parameters
 //       Access: Private
 //       Access: Private
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 clear_parameters() {
 clear_parameters() {
   _mat_spec.clear();
   _mat_spec.clear();
   _var_spec.clear();
   _var_spec.clear();
@@ -715,47 +718,47 @@ clear_parameters() {
 
 
 #ifdef HAVE_CG
 #ifdef HAVE_CG
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cg_parameter_type
+//     Function: Shader::cg_parameter_type
 //       Access: Private
 //       Access: Private
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-ShaderExpansion::ShaderArgType ShaderExpansion::
+Shader::ShaderArgType Shader::
 cg_parameter_type(CGparameter p) {
 cg_parameter_type(CGparameter p) {
   switch (cgGetParameterType(p)) {
   switch (cgGetParameterType(p)) {
-  case CG_FLOAT1:      return ShaderExpansion::SAT_float1;
-  case CG_FLOAT2:      return ShaderExpansion::SAT_float2;
-  case CG_FLOAT3:      return ShaderExpansion::SAT_float3;
-  case CG_FLOAT4:      return ShaderExpansion::SAT_float4;
-  case CG_FLOAT4x4:    return ShaderExpansion::SAT_float4x4;
-  case CG_SAMPLER1D:   return ShaderExpansion::SAT_sampler1d;
-  case CG_SAMPLER2D:   return ShaderExpansion::SAT_sampler2d;
-  case CG_SAMPLER3D:   return ShaderExpansion::SAT_sampler3d;
-  case CG_SAMPLERCUBE: return ShaderExpansion::SAT_samplercube;
-  default:           return ShaderExpansion::SAT_unknown;
+  case CG_FLOAT1:      return Shader::SAT_float1;
+  case CG_FLOAT2:      return Shader::SAT_float2;
+  case CG_FLOAT3:      return Shader::SAT_float3;
+  case CG_FLOAT4:      return Shader::SAT_float4;
+  case CG_FLOAT4x4:    return Shader::SAT_float4x4;
+  case CG_SAMPLER1D:   return Shader::SAT_sampler1d;
+  case CG_SAMPLER2D:   return Shader::SAT_sampler2d;
+  case CG_SAMPLER3D:   return Shader::SAT_sampler3d;
+  case CG_SAMPLERCUBE: return Shader::SAT_samplercube;
+  default:           return Shader::SAT_unknown;
   }
   }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cg_parameter_dir
+//     Function: Shader::cg_parameter_dir
 //       Access: Private
 //       Access: Private
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-ShaderExpansion::ShaderArgDir ShaderExpansion::
+Shader::ShaderArgDir Shader::
 cg_parameter_dir(CGparameter p) {
 cg_parameter_dir(CGparameter p) {
   switch (cgGetParameterDirection(p)) {
   switch (cgGetParameterDirection(p)) {
-  case CG_IN:    return ShaderExpansion::SAD_in;
-  case CG_OUT:   return ShaderExpansion::SAD_out;
-  case CG_INOUT: return ShaderExpansion::SAD_inout;
-  default:       return ShaderExpansion::SAD_unknown;
+  case CG_IN:    return Shader::SAD_in;
+  case CG_OUT:   return Shader::SAD_out;
+  case CG_INOUT: return Shader::SAD_inout;
+  default:       return Shader::SAD_unknown;
   }
   }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cg_release_resources
+//     Function: Shader::cg_release_resources
 //       Access: Private
 //       Access: Private
 //  Description: xyz
 //  Description: xyz
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 cg_release_resources() {
 cg_release_resources() {
   if (_cg_vprogram != 0) {
   if (_cg_vprogram != 0) {
     cgDestroyProgram(_cg_vprogram);
     cgDestroyProgram(_cg_vprogram);
@@ -772,11 +775,11 @@ cg_release_resources() {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cg_compile_entry_point
+//     Function: Shader::cg_compile_entry_point
 //       Access: Private
 //       Access: Private
 //  Description: xyz
 //  Description: xyz
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-CGprogram ShaderExpansion::
+CGprogram Shader::
 cg_compile_entry_point(char *entry, const ShaderCaps &caps, bool fshader)
 cg_compile_entry_point(char *entry, const ShaderCaps &caps, bool fshader)
 {
 {
   CGprogram prog;
   CGprogram prog;
@@ -818,11 +821,11 @@ cg_compile_entry_point(char *entry, const ShaderCaps &caps, bool fshader)
     for (int i=0; i<(int)errlines.size(); i++) {
     for (int i=0; i<(int)errlines.size(); i++) {
       string line = trim(errlines[i]);
       string line = trim(errlines[i]);
       if (line != "") {
       if (line != "") {
-        gobj_cat.error() << _name << " " << errlines[i] << "\n";
+        gobj_cat.error() << get_filename() << ": " << errlines[i] << "\n";
       }
       }
     }
     }
   } else {
   } else {
-    gobj_cat.error() << _name << ": " << cgGetErrorString(err) << "\n";
+    gobj_cat.error() << get_filename() << ": " << cgGetErrorString(err) << "\n";
   }
   }
   if (prog != 0) {
   if (prog != 0) {
     cgDestroyProgram(prog);
     cgDestroyProgram(prog);
@@ -832,13 +835,13 @@ cg_compile_entry_point(char *entry, const ShaderCaps &caps, bool fshader)
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cg_compile_shader
+//     Function: Shader::cg_compile_shader
 //       Access: Private
 //       Access: Private
 //  Description: Compiles a Cg shader for a given set of capabilities.
 //  Description: Compiles a Cg shader for a given set of capabilities.
 //               If successful, the shader is stored in the instance
 //               If successful, the shader is stored in the instance
 //               variables _cg_context, _cg_vprogram, _cg_fprogram.
 //               variables _cg_context, _cg_vprogram, _cg_fprogram.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cg_compile_shader(const ShaderCaps &caps) {
 cg_compile_shader(const ShaderCaps &caps) {
 
 
   // If we already tried compiling for this set of caps, there's no point
   // If we already tried compiling for this set of caps, there's no point
@@ -872,11 +875,11 @@ cg_compile_shader(const ShaderCaps &caps) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cg_analyze_entry_point
+//     Function: Shader::cg_analyze_entry_point
 //       Access: Private
 //       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cg_analyze_entry_point(CGprogram prog, bool fshader) {
 cg_analyze_entry_point(CGprogram prog, bool fshader) {
   CGparameter parameter;
   CGparameter parameter;
   bool success = true;
   bool success = true;
@@ -901,7 +904,7 @@ cg_analyze_entry_point(CGprogram prog, bool fshader) {
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::cg_analyze_shader
+//     Function: Shader::cg_analyze_shader
 //       Access: Private
 //       Access: Private
 //  Description: This subroutine analyzes the parameters of a Cg 
 //  Description: This subroutine analyzes the parameters of a Cg 
 //               shader. The output is stored in instance variables:
 //               shader. The output is stored in instance variables:
@@ -932,7 +935,7 @@ cg_analyze_entry_point(CGprogram prog, bool fshader) {
 //               profile.
 //               profile.
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cg_analyze_shader(const ShaderCaps &caps) {
 cg_analyze_shader(const ShaderCaps &caps) {
 
 
   if (!cg_compile_shader(caps)) {
   if (!cg_compile_shader(caps)) {
@@ -1059,14 +1062,14 @@ cg_analyze_shader(const ShaderCaps &caps) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::cg_compile_for
+//  Function: Shader::cg_compile_for
 //  Access: Public
 //  Access: Public
 //  Description: This routine is used by the ShaderContext constructor
 //  Description: This routine is used by the ShaderContext constructor
 //               to compile the shader.  The CGprogram
 //               to compile the shader.  The CGprogram
 //               objects are turned over to the ShaderContext, we no
 //               objects are turned over to the ShaderContext, we no
 //               longer own them.
 //               longer own them.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 cg_compile_for(const ShaderCaps &caps,
 cg_compile_for(const ShaderCaps &caps,
                CGcontext &ctx,
                CGcontext &ctx,
                CGprogram &vprogram,
                CGprogram &vprogram,
@@ -1079,10 +1082,11 @@ cg_compile_for(const ShaderCaps &caps,
   vprogram = 0;
   vprogram = 0;
   fprogram = 0;
   fprogram = 0;
   map.clear();
   map.clear();
-
+  
   // Make sure the shader is compiled for the target caps.
   // Make sure the shader is compiled for the target caps.
   // Most of the time, it will already be - this is usually a no-op.
   // Most of the time, it will already be - this is usually a no-op.
   
   
+  _default_caps = caps;
   if (!cg_compile_shader(caps)) {
   if (!cg_compile_shader(caps)) {
     return false;
     return false;
   }
   }
@@ -1093,7 +1097,7 @@ cg_compile_for(const ShaderCaps &caps,
   
   
   if ((cgGetProgramProfile(_cg_vprogram) != caps._active_vprofile)||
   if ((cgGetProgramProfile(_cg_vprogram) != caps._active_vprofile)||
       (cgGetProgramProfile(_cg_fprogram) != caps._active_fprofile)) {
       (cgGetProgramProfile(_cg_fprogram) != caps._active_fprofile)) {
-    gobj_cat.error() << "Cg program too complex for driver:" << get_name() << "\n";
+    gobj_cat.error() << "Cg program too complex for driver:" << get_filename() << "\n";
     return false;
     return false;
   }
   }
   
   
@@ -1143,14 +1147,13 @@ cg_compile_for(const ShaderCaps &caps,
 #endif  // HAVE_CG
 #endif  // HAVE_CG
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//  Function: ShaderExpansion::Constructor
+//  Function: Shader::Constructor
 //  Access: Private
 //  Access: Private
-//  Description: Construct a ShaderExpansion.
+//  Description: Construct a Shader.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-ShaderExpansion::
-ShaderExpansion(const string &name, const string &text,
-                const ShaderCaps &caps) :
-  _name(name),
+Shader::
+Shader(const Filename &filename, const string &text) :
+  _filename(filename),
   _text(text),
   _text(text),
   _header(""),
   _header(""),
   _error_flag(true),
   _error_flag(true),
@@ -1164,8 +1167,14 @@ ShaderExpansion(const string &name, const string &text,
   _cg_context = 0;
   _cg_context = 0;
   _cg_vprogram = 0;
   _cg_vprogram = 0;
   _cg_fprogram = 0;
   _cg_fprogram = 0;
+  if (_default_caps._ultimate_vprofile == 0) {
+    _default_caps._active_vprofile = CG_PROFILE_UNKNOWN;
+    _default_caps._active_fprofile = CG_PROFILE_UNKNOWN;
+    _default_caps._ultimate_vprofile = CG_PROFILE_VS_3_0;
+    _default_caps._ultimate_fprofile = CG_PROFILE_PS_3_0;
+  }
   if (_header == "//Cg") {
   if (_header == "//Cg") {
-    if (cg_analyze_shader(caps)) {
+    if (cg_analyze_shader(_default_caps)) {
       _error_flag = false;
       _error_flag = false;
     }
     }
   } else {
   } else {
@@ -1178,53 +1187,87 @@ ShaderExpansion(const string &name, const string &text,
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::Destructor
+//     Function: Shader::Destructor
 //       Access: Public
 //       Access: Public
 //  Description: Delete the compiled code, if it exists.
 //  Description: Delete the compiled code, if it exists.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-ShaderExpansion::
-~ShaderExpansion() {
+Shader::
+~Shader() {
   release_all();
   release_all();
-  _expansion_cache.erase(ExpansionKey(_name,_text));
+  if (_loaded) {
+    _load_table.erase(_filename);
+  } else {
+    _make_table.erase(_text);
+  }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::make
-//       Access: Public, Static
-//  Description: Create a shader expansion (or reuse one from cache)
-////////////////////////////////////////////////////////////////////
-PT(ShaderExpansion) ShaderExpansion::
-make(const string &name, const string &text,
-     const ShaderCaps &caps) {
-  ExpansionKey key(name, text);
-  ExpansionCache::const_iterator i = _expansion_cache.find(key);
-  if (i != _expansion_cache.end()) {
+//     Function: Shader::load
+//       Access: Published, Static
+//  Description:
+////////////////////////////////////////////////////////////////////
+PT(Shader) Shader::
+load(const string &file) {
+  return load(Filename(file));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: Shader::load
+//       Access: Published, Static
+//  Description:
+////////////////////////////////////////////////////////////////////
+PT(Shader) Shader::
+load(const Filename &file) {
+  LoadTable::const_iterator i = _load_table.find(file);
+  if (i != _load_table.end()) {
+    return i->second;
+  }
+  string body;
+  VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
+  if (!vfs->read_file(file, body, true)) {
+    gobj_cat.error() << "Could not read shader file: " << file << "\n";
+    return NULL;
+  }
+  PT(Shader) result = new Shader(file, body);
+  _load_table[file] = result;
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: Shader::make
+//       Access: Published, Static
+//  Description:
+////////////////////////////////////////////////////////////////////
+PT(Shader) Shader::
+make(const string &body) {
+  MakeTable::const_iterator i = _make_table.find(body);
+  if (i != _make_table.end()) {
     return i->second;
     return i->second;
   }
   }
-  ShaderExpansion *result = new ShaderExpansion(name, text, caps);
-  _expansion_cache.insert(ExpansionCache::value_type(key,result));
+  PT(Shader) result = new Shader("created-shader", body);
+  _make_table[body] = result;
   return result;
   return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::parse_init
+//     Function: Shader::parse_init
 //       Access: Public
 //       Access: Public
 //  Description: Set a 'parse pointer' to the beginning of the shader.
 //  Description: Set a 'parse pointer' to the beginning of the shader.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 parse_init() {
 parse_init() {
   _parse = 0;
   _parse = 0;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::parse_line
+//     Function: Shader::parse_line
 //       Access: Public
 //       Access: Public
 //  Description: Parse a line of text. If 'lt' is true, trim blanks
 //  Description: Parse a line of text. If 'lt' is true, trim blanks
 //               from the left end of the line. If 'rt' is true, trim
 //               from the left end of the line. If 'rt' is true, trim
 //               blanks from the right end (the newline is always
 //               blanks from the right end (the newline is always
 //               trimmed).
 //               trimmed).
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 parse_line(string &result, bool lt, bool rt) {
 parse_line(string &result, bool lt, bool rt) {
   int len = _text.size();
   int len = _text.size();
   int head = _parse;
   int head = _parse;
@@ -1245,14 +1288,14 @@ parse_line(string &result, bool lt, bool rt) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::parse_upto
+//     Function: Shader::parse_upto
 //       Access: Public
 //       Access: Public
 //  Description: Parse lines until you read a line that matches the
 //  Description: Parse lines until you read a line that matches the
 //               specified pattern.  Returns all the preceding lines,
 //               specified pattern.  Returns all the preceding lines,
 //               and if the include flag is set, returns the final
 //               and if the include flag is set, returns the final
 //               line as well.
 //               line as well.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 parse_upto(string &result, string pattern, bool include) {
 parse_upto(string &result, string pattern, bool include) {
   GlobPattern endpat(pattern);
   GlobPattern endpat(pattern);
   int start = _parse;
   int start = _parse;
@@ -1271,22 +1314,22 @@ parse_upto(string &result, string pattern, bool include) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::parse_rest
+//     Function: Shader::parse_rest
 //       Access: Public
 //       Access: Public
 //  Description: Returns the rest of the text from the current
 //  Description: Returns the rest of the text from the current
 //               parse location.
 //               parse location.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 parse_rest(string &result) {
 parse_rest(string &result) {
   result = _text.substr(_parse, _text.size() - _parse);
   result = _text.substr(_parse, _text.size() - _parse);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::parse_lineno
+//     Function: Shader::parse_lineno
 //       Access: Public
 //       Access: Public
 //  Description: Returns the line number of the current parse pointer.
 //  Description: Returns the line number of the current parse pointer.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-int ShaderExpansion::
+int Shader::
 parse_lineno() {
 parse_lineno() {
   int result = 1;
   int result = 1;
   for (int i=0; i<_parse; i++) {
   for (int i=0; i<_parse; i++) {
@@ -1296,18 +1339,18 @@ parse_lineno() {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::parse_eof
+//     Function: Shader::parse_eof
 //       Access: Public
 //       Access: Public
 //  Description: Returns true if the parse pointer is at the end of
 //  Description: Returns true if the parse pointer is at the end of
 //               the shader.
 //               the shader.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 parse_eof() {
 parse_eof() {
   return (int)_text.size() == _parse;
   return (int)_text.size() == _parse;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::prepare
+//     Function: Shader::prepare
 //       Access: Published
 //       Access: Published
 //  Description: Indicates that the shader should be enqueued to be
 //  Description: Indicates that the shader should be enqueued to be
 //               prepared in the indicated prepared_objects at the
 //               prepared in the indicated prepared_objects at the
@@ -1318,19 +1361,19 @@ parse_eof() {
 //               Use this function instead of prepare_now() to preload
 //               Use this function instead of prepare_now() to preload
 //               textures from a user interface standpoint.
 //               textures from a user interface standpoint.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 prepare(PreparedGraphicsObjects *prepared_objects) {
 prepare(PreparedGraphicsObjects *prepared_objects) {
   prepared_objects->enqueue_shader(this);
   prepared_objects->enqueue_shader(this);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::is_prepared
+//     Function: Shader::is_prepared
 //       Access: Published
 //       Access: Published
 //  Description: Returns true if the shader has already been prepared
 //  Description: Returns true if the shader has already been prepared
 //               or enqueued for preparation on the indicated GSG,
 //               or enqueued for preparation on the indicated GSG,
 //               false otherwise.
 //               false otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 is_prepared(PreparedGraphicsObjects *prepared_objects) const {
 is_prepared(PreparedGraphicsObjects *prepared_objects) const {
   Contexts::const_iterator ci;
   Contexts::const_iterator ci;
   ci = _contexts.find(prepared_objects);
   ci = _contexts.find(prepared_objects);
@@ -1341,13 +1384,13 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::release
+//     Function: Shader::release
 //       Access: Published
 //       Access: Published
 //  Description: Frees the texture context only on the indicated object,
 //  Description: Frees the texture context only on the indicated object,
 //               if it exists there.  Returns true if it was released,
 //               if it exists there.  Returns true if it was released,
 //               false if it had not been prepared.
 //               false if it had not been prepared.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-bool ShaderExpansion::
+bool Shader::
 release(PreparedGraphicsObjects *prepared_objects) {
 release(PreparedGraphicsObjects *prepared_objects) {
   Contexts::iterator ci;
   Contexts::iterator ci;
   ci = _contexts.find(prepared_objects);
   ci = _contexts.find(prepared_objects);
@@ -1366,7 +1409,7 @@ release(PreparedGraphicsObjects *prepared_objects) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::prepare_now
+//     Function: Shader::prepare_now
 //       Access: Published
 //       Access: Published
 //  Description: Creates a context for the texture on the particular
 //  Description: Creates a context for the texture on the particular
 //               GSG, if it does not already exist.  Returns the new
 //               GSG, if it does not already exist.  Returns the new
@@ -1381,7 +1424,7 @@ release(PreparedGraphicsObjects *prepared_objects) {
 //               explicitly prepared by the user before it may be
 //               explicitly prepared by the user before it may be
 //               rendered.
 //               rendered.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-ShaderContext *ShaderExpansion::
+ShaderContext *Shader::
 prepare_now(PreparedGraphicsObjects *prepared_objects, 
 prepare_now(PreparedGraphicsObjects *prepared_objects, 
             GraphicsStateGuardianBase *gsg) {
             GraphicsStateGuardianBase *gsg) {
   Contexts::const_iterator ci;
   Contexts::const_iterator ci;
@@ -1397,15 +1440,15 @@ prepare_now(PreparedGraphicsObjects *prepared_objects,
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::clear_prepared
+//     Function: Shader::clear_prepared
 //       Access: Private
 //       Access: Private
 //  Description: Removes the indicated PreparedGraphicsObjects table
 //  Description: Removes the indicated PreparedGraphicsObjects table
-//               from the ShaderExpansion's table, without actually releasing
+//               from the Shader's table, without actually releasing
 //               the texture.  This is intended to be called only from
 //               the texture.  This is intended to be called only from
 //               PreparedGraphicsObjects::release_texture(); it should
 //               PreparedGraphicsObjects::release_texture(); it should
 //               never be called by user code.
 //               never be called by user code.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ShaderExpansion::
+void Shader::
 clear_prepared(PreparedGraphicsObjects *prepared_objects) {
 clear_prepared(PreparedGraphicsObjects *prepared_objects) {
   Contexts::iterator ci;
   Contexts::iterator ci;
   ci = _contexts.find(prepared_objects);
   ci = _contexts.find(prepared_objects);
@@ -1419,13 +1462,13 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderExpansion::release_all
+//     Function: Shader::release_all
 //       Access: Published
 //       Access: Published
 //  Description: Frees the context allocated on all objects for which
 //  Description: Frees the context allocated on all objects for which
 //               the texture has been declared.  Returns the number of
 //               the texture has been declared.  Returns the number of
 //               contexts which have been freed.
 //               contexts which have been freed.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-int ShaderExpansion::
+int Shader::
 release_all() {
 release_all() {
   // We have to traverse a copy of the _contexts list, because the
   // We have to traverse a copy of the _contexts list, because the
   // PreparedGraphicsObjects object will call clear_prepared() in response
   // PreparedGraphicsObjects object will call clear_prepared() in response
@@ -1450,3 +1493,28 @@ release_all() {
   return num_freed;
   return num_freed;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: Shader::ShaderCapabilities::clear()
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE void Shader::ShaderCaps::
+clear() {
+#ifdef HAVE_CG
+  _active_vprofile = 0;
+  _active_fprofile = 0;
+  _ultimate_vprofile = 0;
+  _ultimate_fprofile = 0;
+#endif
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: Shader::register_with_read_factory
+//       Access: Public, Static
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void Shader::
+register_with_read_factory() {
+  // IMPLEMENT ME
+}
+

+ 29 - 28
panda/src/gobj/shaderExpansion.h → panda/src/gobj/shader.h

@@ -1,4 +1,4 @@
-// Filename: shaderExpansion.h
+// Filename: shader.h
 // Created by:  jyelon (01Sep05)
 // Created by:  jyelon (01Sep05)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,8 +16,8 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifndef SHADEREXPANSION_H
-#define SHADEREXPANSION_H
+#ifndef SHADER_H
+#define SHADER_H
 
 
 #include "pandabase.h"
 #include "pandabase.h"
 #include "typedReferenceCount.h"
 #include "typedReferenceCount.h"
@@ -34,23 +34,21 @@ typedef struct _CGparameter *CGparameter;
 #endif
 #endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//       Class : ShaderExpansion
-//      Summary: A shader can contain context-sensitive macros.
-//               A ShaderExpansion is the output you get when you
-//               run the macro preprocessor on a shader.
-//               The ShaderExpansion contains the shader's 
-//               macroexpanded text, an analysis of the shader's
-//               parameters, and a map of ShaderContext
-//               objects.
+//       Class : Shader
+//      Summary: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-class EXPCL_PANDA_GOBJ ShaderExpansion: public TypedReferenceCount {
+class EXPCL_PANDA_GOBJ Shader: public TypedReferenceCount {
 
 
 PUBLISHED:
 PUBLISHED:
   
   
-  INLINE const string &get_name() const;
-  INLINE const string &get_text() const;
-  INLINE const string &get_header() const;
+  static PT(Shader) load(const Filename &file);
+  static PT(Shader) load(const string &file);
+  static PT(Shader) make(const string &body);
+
+  INLINE const Filename &get_filename() const;
+  INLINE const string   &get_text() const;
+  INLINE const string   &get_header() const;
   INLINE bool get_error_flag() const;
   INLINE bool get_error_flag() const;
 
 
   void prepare(PreparedGraphicsObjects *prepared_objects);
   void prepare(PreparedGraphicsObjects *prepared_objects);
@@ -191,7 +189,7 @@ public:
     int _ultimate_fprofile;
     int _ultimate_fprofile;
     pset <ShaderBug> _bug_list;
     pset <ShaderBug> _bug_list;
 #endif
 #endif
-    INLINE void clear();
+    void clear();
     INLINE bool operator == (const ShaderCaps &other) const;
     INLINE bool operator == (const ShaderCaps &other) const;
     INLINE ShaderCaps();
     INLINE ShaderCaps();
   };
   };
@@ -262,15 +260,20 @@ public:
   pvector <ShaderVarSpec> _var_spec;
   pvector <ShaderVarSpec> _var_spec;
   
   
  protected:
  protected:
-  string         _name;
+  Filename       _filename;
   string         _text;
   string         _text;
   string         _header;
   string         _header;
   bool           _error_flag;
   bool           _error_flag;
   int            _parse;
   int            _parse;
+  bool           _loaded;
   
   
-  typedef pair < string, string > ExpansionKey;
-  typedef pmap < ExpansionKey, ShaderExpansion * > ExpansionCache;
-  static ExpansionCache _expansion_cache;
+  static ShaderCaps _default_caps;
+
+  typedef phash_map < Filename , Shader * > LoadTable;
+  typedef phash_map < string   , Shader * > MakeTable;
+
+  static LoadTable _load_table;
+  static MakeTable _make_table;
 
 
   friend class ShaderContext;
   friend class ShaderContext;
   friend class PreparedGraphicsObjects;
   friend class PreparedGraphicsObjects;
@@ -278,17 +281,15 @@ public:
   typedef pmap <PreparedGraphicsObjects *, ShaderContext *> Contexts;
   typedef pmap <PreparedGraphicsObjects *, ShaderContext *> Contexts;
   Contexts _contexts;
   Contexts _contexts;
 
 
-  
  private:  
  private:  
-  ShaderExpansion(const string &name, const string &text,
-                  const ShaderCaps &caps);
+  Shader(const Filename &name, const string &text);
   void clear_prepared(PreparedGraphicsObjects *prepared_objects);
   void clear_prepared(PreparedGraphicsObjects *prepared_objects);
 
 
  public:
  public:
-  static PT(ShaderExpansion) make(const string &name, const string &body,
-                                  const ShaderCaps &caps);
+  static void register_with_read_factory();
+  static PT(Shader) make(const string &name, const string &body);
   
   
-  ~ShaderExpansion();
+  ~Shader();
   
   
  public:
  public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
@@ -296,7 +297,7 @@ public:
   }
   }
   static void init_type() {
   static void init_type() {
     TypedReferenceCount::init_type();
     TypedReferenceCount::init_type();
-    register_type(_type_handle, "ShaderExpansion",
+    register_type(_type_handle, "Shader",
                   TypedReferenceCount::get_class_type());
                   TypedReferenceCount::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {
@@ -308,6 +309,6 @@ public:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 };
 };
 
 
-#include "shaderExpansion.I"
+#include "shader.I"
 
 
 #endif
 #endif

+ 5 - 5
panda/src/gobj/shaderContext.I

@@ -22,8 +22,8 @@
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE ShaderContext::
 INLINE ShaderContext::
-ShaderContext(ShaderExpansion *se) :
-  _expansion(se)
+ShaderContext(Shader *se) :
+  _shader(se)
 {
 {
 }
 }
 
 
@@ -32,7 +32,7 @@ ShaderContext(ShaderExpansion *se) :
 //       Access: Published
 //       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE ShaderExpansion *ShaderContext::
-get_expansion() const {
-  return _expansion;
+INLINE Shader *ShaderContext::
+get_shader() const {
+  return _shader;
 }
 }

+ 4 - 4
panda/src/gobj/shaderContext.h

@@ -22,7 +22,7 @@
 #include "pandabase.h"
 #include "pandabase.h"
 #include "internalName.h"
 #include "internalName.h"
 #include "savedContext.h"
 #include "savedContext.h"
-#include "shaderExpansion.h"
+#include "shader.h"
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : ShaderContext
 //       Class : ShaderContext
@@ -38,13 +38,13 @@
 
 
 class EXPCL_PANDA_GOBJ ShaderContext: public SavedContext {
 class EXPCL_PANDA_GOBJ ShaderContext: public SavedContext {
 public:
 public:
-  INLINE ShaderContext(ShaderExpansion *se);
+  INLINE ShaderContext(Shader *se);
 
 
 PUBLISHED:
 PUBLISHED:
-  INLINE ShaderExpansion *get_expansion() const;
+  INLINE Shader *get_shader() const;
 
 
 public:  
 public:  
-  ShaderExpansion *_expansion;
+  Shader *_shader;
 
 
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {

+ 2 - 2
panda/src/gsgbase/graphicsStateGuardianBase.h

@@ -58,7 +58,7 @@ class GraphicsOutput;
 class Texture;
 class Texture;
 class TextureContext;
 class TextureContext;
 class ShaderContext;
 class ShaderContext;
-class ShaderExpansion;
+class Shader;
 class RenderState;
 class RenderState;
 class TransformState;
 class TransformState;
 class Material;
 class Material;
@@ -138,7 +138,7 @@ public:
   virtual GeomContext *prepare_geom(Geom *geom)=0;
   virtual GeomContext *prepare_geom(Geom *geom)=0;
   virtual void release_geom(GeomContext *gc)=0;
   virtual void release_geom(GeomContext *gc)=0;
 
 
-  virtual ShaderContext *prepare_shader(ShaderExpansion *shader)=0;
+  virtual ShaderContext *prepare_shader(Shader *shader)=0;
   virtual void release_shader(ShaderContext *sc)=0;
   virtual void release_shader(ShaderContext *sc)=0;
   
   
   virtual VertexBufferContext *prepare_vertex_buffer(GeomVertexArrayData *data)=0;
   virtual VertexBufferContext *prepare_vertex_buffer(GeomVertexArrayData *data)=0;

+ 1 - 0
panda/src/pgraph/cullableObject.h

@@ -32,6 +32,7 @@
 #include "cullTraverserData.h"
 #include "cullTraverserData.h"
 #include "pStatCollector.h"
 #include "pStatCollector.h"
 #include "deletedChain.h"
 #include "deletedChain.h"
+#include "graphicsStateGuardianBase.h"
 
 
 class CullTraverser;
 class CullTraverser;
 
 

+ 0 - 1
panda/src/pgraph/pgraph_composite4.cxx

@@ -9,7 +9,6 @@
 #include "selectiveChildNode.cxx"
 #include "selectiveChildNode.cxx"
 #include "sequenceNode.cxx"
 #include "sequenceNode.cxx"
 #include "shadeModelAttrib.cxx"
 #include "shadeModelAttrib.cxx"
-#include "shader.cxx"
 #include "shaderInput.cxx"
 #include "shaderInput.cxx"
 #include "shaderAttrib.cxx"
 #include "shaderAttrib.cxx"
 #include "shaderPool.cxx"
 #include "shaderPool.cxx"

+ 7 - 7
panda/src/pgraph/renderState.I

@@ -602,23 +602,23 @@ compare_to(const Attribute &other) const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: RenderState::get_shader_expansion
+//     Function: RenderState::get_generated_shader
 //       Access: Public
 //       Access: Public
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE ShaderExpansion *RenderState::
-get_shader_expansion() const {
-  return _shader_expansion;
+INLINE ShaderAttrib *RenderState::
+get_generated_shader() const {
+  return (ShaderAttrib*)(RenderAttrib*)_generated_shader;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: RenderState::set_shader_expansion
+//     Function: RenderState::set_generated_shader
 //       Access: Public
 //       Access: Public
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void RenderState::
 INLINE void RenderState::
-set_shader_expansion(ShaderExpansion *exp) {
-  _shader_expansion = exp;
+set_generated_shader(ShaderAttrib *attr) {
+  _generated_shader = (RenderAttrib*)attr;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 7 - 7
panda/src/pgraph/renderState.h

@@ -31,7 +31,6 @@
 #include "texMatrixAttrib.h"
 #include "texMatrixAttrib.h"
 #include "geomMunger.h"
 #include "geomMunger.h"
 #include "weakPointerTo.h"
 #include "weakPointerTo.h"
-#include "shaderExpansion.h"
 #include "reMutex.h"
 #include "reMutex.h"
 #include "pmutex.h"
 #include "pmutex.h"
 #include "deletedChain.h"
 #include "deletedChain.h"
@@ -159,8 +158,8 @@ public:
   void store_into_slots(AttribSlots *slots) const;
   void store_into_slots(AttribSlots *slots) const;
   
   
   static void bin_removed(int bin_index);
   static void bin_removed(int bin_index);
-  INLINE ShaderExpansion *get_shader_expansion() const;
-  INLINE void set_shader_expansion(ShaderExpansion *exp);
+  INLINE ShaderAttrib *get_generated_shader() const;
+  INLINE void set_generated_shader(ShaderAttrib *attr);
 
 
   INLINE static void flush_level();
   INLINE static void flush_level();
 
 
@@ -300,10 +299,11 @@ private:
   int _bin_index;
   int _bin_index;
   int _draw_order;
   int _draw_order;
 
 
-  // If this renderstate contains a Shader, then the macroexpansion
-  // of the shader needs to be cached (to avoid having to regenerate
-  // it each time this RenderState is applied).
-  PT(ShaderExpansion) _shader_expansion;
+  // If this state contains an "auto" ShaderAttrib, then an explicit
+  // ShaderAttrib will be synthesized by the runtime and stored here.
+  // I can't declare this as a ShaderAttrib because that would create
+  // a circular include-file dependency problem.  Aaargh.
+  PT(RenderAttrib) _generated_shader;
   
   
   // We also cache the pointer to some critical attribs stored in the
   // We also cache the pointer to some critical attribs stored in the
   // state, if they exist.
   // state, if they exist.

+ 0 - 79
panda/src/pgraph/shader.I

@@ -1,79 +0,0 @@
-// Filename: shader.I
-// Created by: jyelon (01Sep05)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://etc.cmu.edu/panda3d/docs/license/ .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::get_file
-//       Access: Published
-//  Description: Returns null string if shader was not loaded from
-//               a source file.
-////////////////////////////////////////////////////////////////////
-INLINE const Filename &Shader::
-get_file() const {
-  return _file;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::get_body
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE const string &Shader::
-get_body() const {
-  return _body;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::get_name
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE const string &Shader::
-get_name() const {
-  return _name;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::get_loaded
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE bool Shader::
-get_loaded() const {
-  return _loaded;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::get_load_error
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE bool Shader::
-get_load_error() const {
-  return _load_error;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::get_preprocessor
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE int Shader::
-get_preprocessor() const {
-  return _preprocessor;
-}
-

+ 0 - 169
panda/src/pgraph/shader.cxx

@@ -1,169 +0,0 @@
-// Filename: shader.cxx
-// Created by: jyelon (01Sep05)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://etc.cmu.edu/panda3d/docs/license/ .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-#include "shader.h"
-#include "virtualFileSystem.h"
-
-TypeHandle Shader::_type_handle;
-Shader::LoadTable Shader::_load_table;
-Shader::MakeTable Shader::_make_table;
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::Constructor
-//       Access: Private
-//  Description:
-////////////////////////////////////////////////////////////////////
-Shader::
-Shader() {
-  this -> _load_error = false;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::Destructor
-//       Access: Private
-//  Description:
-////////////////////////////////////////////////////////////////////
-Shader::
-~Shader() {
-  if (_loaded) {
-    LoadTableKey key(_file, _preprocessor);
-    _load_table.erase(key);
-  } else {
-    MakeTableKey key(_body, _preprocessor);
-    _make_table.erase(key);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::load
-//       Access: Published, Static
-//  Description:
-////////////////////////////////////////////////////////////////////
-CPT(Shader) Shader::
-load(const string &file, int preprocessor) {
-  return load(Filename(file), preprocessor);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::load
-//       Access: Published, Static
-//  Description:
-////////////////////////////////////////////////////////////////////
-CPT(Shader) Shader::
-load(const Filename &file, int preprocessor) {
-  LoadTableKey key(file, preprocessor);
-  LoadTable::const_iterator i = _load_table.find(key);
-  if (i != _load_table.end()) {
-    return i->second;
-  }
-  Shader *result = new Shader;
-  result->_name = file;
-  result->_file = file;
-  result->_loaded = true;
-  result->_preprocessor = preprocessor;
-  result->_fixed_expansion = 0;
-  VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
-  if (!vfs->read_file(file, result->_body, true)) {
-    cerr << "Could not read shader file: " << file << "\n";
-    result->_body = "";
-    result->_load_error = true;
-  }
-  _load_table[key] = result;
-  return result;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::make
-//       Access: Published, Static
-//  Description:
-////////////////////////////////////////////////////////////////////
-CPT(Shader) Shader::
-make(const string &body, int preprocessor) {
-  MakeTableKey key(body, preprocessor);
-  MakeTable::const_iterator i = _make_table.find(key);
-  if (i != _make_table.end()) {
-    return i->second;
-  }
-  Shader *result = new Shader;
-  result->_name = "generated shader";
-  result->_file = "";
-  result->_loaded = false;
-  result->_preprocessor = preprocessor;
-  result->_fixed_expansion = 0;
-  result->_body = body;
-  _make_table[key] = result;
-  return result;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::macroexpand
-//       Access: Public
-//  Description: The eventual plan is that shaders will be run through
-//               a macro preprocessor in order to generate the actual
-//               shader text in Cg, GLSL, HLSL, or whatever.  The
-//               macro preprocessor will be able to query the RenderState
-//               and generate different shader code for different states.
-//
-//               The macroexpansion of the shader is stored in an object
-//               of class ShaderExpansion.  This is somewhat expensive
-//               to generate, so the ShaderExpansion is cached inside the
-//               the RenderState itself.  The ShaderExpansion contains
-//               a map of ShaderContexts, each containing a compiled
-//               copy of the shader's macroexpansion.
-//
-//               Any given shader might not contain any ifdefs that
-//               depend on the RenderState.  If macroexpand determines
-//               that a given shader is not state-sensitive, it can cache
-//               the macroexpansion in the field "_fixed_expansion."
-//
-//               The preprocessing is usually done by a built-in macro
-//               preprocessing function.  However, the user can write
-//               his own preprocessor if he wishes to do so.  A user-
-//               supplied preprocessor can generate arbitrary code ---
-//               in fact, it doesn't need to look at the input string
-//               if it does not wish to do so.
-//
-//               Currently, macroexpand is just a stub that returns an
-//               expansion which is exactly equal to the input string.
-//
-//               The "caps" parameter should describe the capabilities
-//               of the gsg on which this is intended to run.
-////////////////////////////////////////////////////////////////////
-PT(ShaderExpansion) Shader::
-macroexpand(const RenderState *context,
-            const ShaderExpansion::ShaderCaps &caps) const {
-  if (_fixed_expansion) {
-    return _fixed_expansion;
-  }
-  // I am casting away the 'const' so as to be able
-  // to write to this field.  This field is just a cache.
-  ((Shader*)this)->_fixed_expansion = ShaderExpansion::make(_name,_body,caps);
-  return _fixed_expansion;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Shader::register_with_read_factory
-//       Access: Public, Static
-//  Description:
-////////////////////////////////////////////////////////////////////
-void Shader::
-register_with_read_factory() {
-  // IMPLEMENT ME
-}
-
-

+ 0 - 97
panda/src/pgraph/shader.h

@@ -1,97 +0,0 @@
-// Filename: shader.h
-// Created by: jyelon (01Sep05)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://etc.cmu.edu/panda3d/docs/license/ .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-#ifndef SHADER_H
-#define SHADER_H
-
-#include "pandabase.h"
-#include "typedWritableReferenceCount.h"
-#include "shaderExpansion.h"
-#include "pointerTo.h"
-#include "dcast.h"
-
-class RenderState;
-
-////////////////////////////////////////////////////////////////////
-//       Class : Shader
-// Description :
-////////////////////////////////////////////////////////////////////
-
-class EXPCL_PANDA_PGRAPH Shader: public TypedWritableReferenceCount {
-PUBLISHED:
-  static CPT(Shader) load(const Filename &file, int preprocessor=0);
-  static CPT(Shader) load(const string &file,   int preprocessor=0);
-  static CPT(Shader) make(const string &body,   int preprocessor=0);
-
-  INLINE const string   &get_name() const;
-  INLINE const Filename &get_file() const;
-  INLINE const string   &get_body() const;
-  INLINE int             get_preprocessor() const;
-  INLINE bool            get_loaded() const;
-  INLINE bool            get_load_error() const;
-
-  PT(ShaderExpansion) macroexpand(const RenderState *context,
-                                  const ShaderExpansion::ShaderCaps &caps) const;
-
-public:
-  Shader();
-  ~Shader();
-
-private:
-  string   _name;
-  Filename _file;
-  string   _body;
-  bool     _loaded;
-  bool     _load_error;
-  int      _preprocessor;
-
-  PT(ShaderExpansion) _fixed_expansion;
-
-  typedef pair < Filename, int > LoadTableKey;
-  typedef pair < string,   int > MakeTableKey;
-
-  typedef pmap < LoadTableKey , Shader * > LoadTable;
-  typedef pmap < MakeTableKey , Shader * > MakeTable;
-
-  static LoadTable _load_table;
-  static MakeTable _make_table;
-
-public:
-  static void register_with_read_factory();
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    TypedWritableReferenceCount::init_type();
-    register_type(_type_handle, "Shader",
-                  TypedWritableReferenceCount::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-};
-
-#include "shader.I"
-
-#endif  // SHADER_H

+ 1 - 10
panda/src/pgraph/shaderPool.cxx

@@ -100,16 +100,7 @@ ns_load_shader(const string &str) {
 // ***** face_index ???
 // ***** face_index ???
 
 
   if (shader == (CPT(Shader)) NULL) {
   if (shader == (CPT(Shader)) NULL) {
-    int preprocessor;
-
-    preprocessor = 0;
-    shader = Shader::load (filename, preprocessor);
-    if (shader) {
-      if (shader -> get_load_error ( )) {
-//        delete shader;
-        shader = (CPT(Shader)) NULL;
-      }
-    }
+    shader = Shader::load (filename);
   }
   }
 
 
   if (shader == (CPT(Shader)) NULL) {
   if (shader == (CPT(Shader)) NULL) {