diff --git a/renderdoc/driver/shaders/spirv/spirv_reflect.cpp b/renderdoc/driver/shaders/spirv/spirv_reflect.cpp index a826dbed7..6091944ab 100644 --- a/renderdoc/driver/shaders/spirv/spirv_reflect.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_reflect.cpp @@ -1627,6 +1627,21 @@ void Reflector::MakeConstantBlockVariables(rdcspv::StorageClass storage, const D } } +void Reflector::ApplyMatrixByteStride(const DataType &type, uint8_t matrixByteStride, + rdcarray &members) const +{ + const DataType &inner = dataTypes[type.InnerType()]; + + for(ShaderConstant &m : members) + { + if(m.type.matrixByteStride == 0) + m.type.matrixByteStride = matrixByteStride; + + if(inner.type == DataType::ArrayType) + ApplyMatrixByteStride(inner, matrixByteStride, m.type.members); + } +} + void Reflector::MakeConstantBlockVariable(ShaderConstant &outConst, SparseIdMap &pointerTypes, rdcspv::StorageClass storage, const DataType &type, @@ -1728,6 +1743,11 @@ void Reflector::MakeConstantBlockVariable(ShaderConstant &outConst, if(curType->type == DataType::ArrayType) { + // matrix byte stride is only applied on the root variable, so as we recurse down the type + // tree for multi-dimensional arrays of matrices we need to propagate down the stride + if(outConst.type.matrixByteStride != 0) + ApplyMatrixByteStride(*curType, outConst.type.matrixByteStride, outConst.type.members); + outConst.type.name = type.name; // if the inner type is an array, it will be expanded in our members list. So don't also diff --git a/renderdoc/driver/shaders/spirv/spirv_reflect.h b/renderdoc/driver/shaders/spirv/spirv_reflect.h index 981f6d078..634fccd2e 100644 --- a/renderdoc/driver/shaders/spirv/spirv_reflect.h +++ b/renderdoc/driver/shaders/spirv/spirv_reflect.h @@ -107,6 +107,8 @@ private: rdcstr StringiseConstant(rdcspv::Id id) const; void CheckDebuggable(bool &debuggable, rdcstr &debugStatus) const; + void ApplyMatrixByteStride(const DataType &type, uint8_t matrixByteStride, + rdcarray &members) const; void MakeConstantBlockVariables(rdcspv::StorageClass storage, const DataType &structType, uint32_t arraySize, uint32_t arrayByteStride, rdcarray &cblock,