Просмотр исходного кода

shader: Fix memory corruption with matrix array shader inputs

Fixes #1788
rdb 1 неделя назад
Родитель
Сommit
f123cb142d
1 измененных файлов с 1 добавлено и 1 удалено
  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;
     spec._cache_offset[p] = offset + begin[p] * size;
   }
   }
   if (spec._func == SMF_shader_input_ptr) {
   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
     // 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
     // frame to frame, and we have no way to know.  So, we must respecify a