1

我正在对 6x6 矩阵进行块矩阵求逆,将其拆分为 4x4、2x4、4x2 和 2x2 块,但在某处出现问题并尝试访问其中一个值会导致崩溃。我想我会尝试使用 isnan() 或 isinf() 来检测错误值,但这似乎也会导致崩溃。

// Pieces of a block matrix inversion:
mat4 invA = inverse(A);
mat2 invD = inverse(D);
mat4 schurA = A - B*invD*C;
mat2 schurD = D - C*invA*B;
mat2x4 upperR = -invA*B*schurD;
mat4x2 lowerL = -invD*C*schurA;

// Set outgoing color for the vertex to yellowish:
v_pColorMarker = vec3(0.90, 1.00, 0.60);

// Does not crash, so it seems I can do a multiply with these matrix values:
vec2 p45 = vec2(0.0);
p45 += lowerL*b0123 + schurD*b45;

float temp = schurD[0][1];

// Checking matrix entry for NaN causes crash ????!!!!
if (isnan(temp))
{
    // Set the vertex color to something I’ll be able to see and detect:
    v_pColorMarker = vec3(0.0, 1.0, 0.0);
}

有任何想法吗?我不确定如何调试它,因为崩溃发生在顶点着色器中,而且我没有检查矩阵内部值的好方法。矩阵中 [0][1] 处的值是否可能是某些描述的非数字值,它与 INF 的 NaN 不同,并且会使 isnan() 和 isinf() 都崩溃?

4

1 回答 1

0

这最终成为一个不相关的问题,其中“不稳定性”来自使用太多地址并导致 GPU/编译器回收或丢失特定地址中的值。重构代码以提高地址效率会导致不稳定性消失。

于 2014-11-03T20:42:16.293 回答