]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix reflection of vector and matrix types from SPIR-V
authorMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 16:56:07 +0000 (18:56 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 16:56:07 +0000 (18:56 +0200)
source/core/module.cpp

index 2326a5e7fd3dcf73c8a9f4e73ba191cd2a0acda3..4afbc53403d4f283cd57277a5436a64775b1bc3e 100644 (file)
@@ -308,7 +308,7 @@ void SpirVModule::Reflection::reflect_code(const vector<uint32_t> &code)
                case OP_TYPE_INT: reflect_int_type(op); break;
                case OP_TYPE_FLOAT: reflect_float_type(op); break;
                case OP_TYPE_VECTOR: reflect_vector_type(op); break;
-               case OP_TYPE_MATRIX: reflect_vector_type(op); break;
+               case OP_TYPE_MATRIX: reflect_matrix_type(op); break;
                case OP_TYPE_IMAGE: reflect_image_type(op); break;
                case OP_TYPE_SAMPLED_IMAGE: reflect_sampled_image_type(op); break;
                case OP_TYPE_ARRAY: reflect_array_type(op); break;
@@ -391,7 +391,7 @@ void SpirVModule::Reflection::reflect_vector_type(CodeIterator op)
        TypeInfo &type = types[*(op+1)];
        DataType component = types[*(op+2)].type;
        unsigned count = *(op+3);
-       type.type = static_cast<DataType>((count<<12) | (component&0xF00) | ((component&0xFF)*count));
+       type.type = static_cast<DataType>(((count-1)<<12) | (component&0xF00) | ((component&0xFF)*count));
 }
 
 void SpirVModule::Reflection::reflect_matrix_type(CodeIterator op)
@@ -399,7 +399,7 @@ void SpirVModule::Reflection::reflect_matrix_type(CodeIterator op)
        TypeInfo &type = types[*(op+1)];
        DataType column = types[*(op+2)].type;
        unsigned count = *(op+3);
-       type.type = static_cast<DataType>((count<<16) | (column&0xF00) | ((column&0xFF)*count));
+       type.type = static_cast<DataType>(((count-1)<<14) | (column&0x3F00) | ((column&0xFF)*count));
 }
 
 void SpirVModule::Reflection::reflect_image_type(CodeIterator op)