Переглянути джерело

shader: Some fixes for parameter binding

rdb 5 роки тому
батько
коміт
dce865b5e5
1 змінених файлів з 10 додано та 0 видалено
  1. 10 0
      panda/src/gobj/shader.cxx

+ 10 - 0
panda/src/gobj/shader.cxx

@@ -394,6 +394,9 @@ cp_dependency(ShaderMatInput inp) {
  */
  */
 void Shader::
 void Shader::
 cp_add_mat_spec(ShaderMatSpec &spec) {
 cp_add_mat_spec(ShaderMatSpec &spec) {
+  // We currently expect each ShaderMatSpec to map to one location.
+  nassertv(spec._id._type->get_num_parameter_locations() == 1);
+
   // If we're composing with identity, simplify.
   // If we're composing with identity, simplify.
 
 
   if (spec._func == SMF_first) {
   if (spec._func == SMF_first) {
@@ -1453,6 +1456,7 @@ bind_parameter(const Parameter &param) {
       }
       }
       Shader::ShaderMatSpec bind;
       Shader::ShaderMatSpec bind;
       bind._id = param;
       bind._id = param;
+      bind._id._type = element_type;
       bind._piece = Shader::SMP_row3;
       bind._piece = Shader::SMP_row3;
       bind._func = Shader::SMF_first;
       bind._func = Shader::SMF_first;
       bind._part[0] = Shader::SMO_apiview_clipplane_i;
       bind._part[0] = Shader::SMO_apiview_clipplane_i;
@@ -1568,6 +1572,8 @@ bind_parameter(const Parameter &param) {
 
 
         ShaderMatSpec bind;
         ShaderMatSpec bind;
         bind._id = param;
         bind._id = param;
+        bind._id._name = fqname;
+        bind._id._type = member.type;
         bind._func = SMF_first;
         bind._func = SMF_first;
         bind._part[0] = SMO_light_ambient;
         bind._part[0] = SMO_light_ambient;
         bind._arg[0] = nullptr;
         bind._arg[0] = nullptr;
@@ -1610,6 +1616,7 @@ bind_parameter(const Parameter &param) {
           ShaderTexSpec bind;
           ShaderTexSpec bind;
           bind._id = param;
           bind._id = param;
           bind._id._name = fqname;
           bind._id._name = fqname;
+          bind._id._type = member.type;
           bind._id._location = location++;
           bind._id._location = location++;
           bind._part = STO_light_i_shadow_map;
           bind._part = STO_light_i_shadow_map;
           bind._desired_type = Texture::TT_2d_texture;
           bind._desired_type = Texture::TT_2d_texture;
@@ -1621,6 +1628,7 @@ bind_parameter(const Parameter &param) {
           ShaderMatSpec bind;
           ShaderMatSpec bind;
           bind._id = param;
           bind._id = param;
           bind._id._name = fqname;
           bind._id._name = fqname;
+          bind._id._type = member.type;
           bind._id._location = location++;
           bind._id._location = location++;
           bind._func = SMF_first;
           bind._func = SMF_first;
           bind._part[0] = SMO_light_source_i_attrib;
           bind._part[0] = SMO_light_source_i_attrib;
@@ -2407,6 +2415,8 @@ bind_parameter(const Parameter &param) {
         // We can't know yet, so we always have to handle it specially.
         // We can't know yet, so we always have to handle it specially.
         ShaderMatSpec bind;
         ShaderMatSpec bind;
         bind._id = param;
         bind._id = param;
+        bind._id._name = fqname;
+        bind._id._type = member.type;
         bind._id._location = location;
         bind._id._location = location;
         if (member.name == "shadowMatrix" && dim[1] == 4 && dim[2] == 4) {
         if (member.name == "shadowMatrix" && dim[1] == 4 && dim[2] == 4) {
           // Special exception for shadowMatrix, which is deprecated because it
           // Special exception for shadowMatrix, which is deprecated because it