Browse Source

shader: Fix memory corruption with matrix array shader inputs

Fixes #1788
rdb 2 days ago
parent
commit
f123cb142d
1 changed files with 1 additions and 1 deletions
  1. 1 1
      panda/src/gobj/shader.cxx

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

@@ -742,7 +742,7 @@ cp_add_mat_spec(ShaderMatSpec &spec) {
     spec._cache_offset[p] = offset + begin[p] * size;
   }
   if (spec._func == SMF_shader_input_ptr) {
-    _mat_scratch_size = std::max(_mat_scratch_size, spec._array_count);
+    _mat_scratch_size = std::max(_mat_scratch_size, spec._array_count * ((spec._num_components + 3) / 4));
 
     // We specify SSD_frame because a PTA may be modified by the app from
     // frame to frame, and we have no way to know.  So, we must respecify a