Browse Source

shaderpipeline: Use valid MatrixStride decoration for UBO matrix

rdb 1 year ago
parent
commit
290f06282b
1 changed files with 2 additions and 1 deletions
  1. 2 1
      panda/src/shaderpipeline/spirVTransformPass.cxx

+ 2 - 1
panda/src/shaderpipeline/spirVTransformPass.cxx

@@ -1001,8 +1001,9 @@ r_annotate_struct_layout(uint32_t type_id) {
 
 
     if (const ShaderType::Matrix *matrix_type = base_type->as_matrix()) {
     if (const ShaderType::Matrix *matrix_type = base_type->as_matrix()) {
       // Matrix types need to be explicitly laid out.
       // Matrix types need to be explicitly laid out.
+      uint32_t stride = (matrix_type->get_scalar_type() == ShaderType::ST_double) ? 32u : 16u;
       add_annotation(spv::OpMemberDecorate,
       add_annotation(spv::OpMemberDecorate,
-        {type_id, i, spv::DecorationMatrixStride, matrix_type->get_num_columns() * 4});
+        {type_id, i, spv::DecorationMatrixStride, stride});
       add_annotation(spv::OpMemberDecorate,
       add_annotation(spv::OpMemberDecorate,
         {type_id, i, spv::DecorationColMajor});
         {type_id, i, spv::DecorationColMajor});
     } else {
     } else {