-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with matrix layout #3752
Comments
Correction! struct Push
{
float3x4* ptr;
};
[[vk::push_constant]] Push push;
[shader("compute")]
[numthreads(1, 1, 1)]
void main(uint3 dtid : SV_DispatchThreadID)
{
// This matrix is in memry column major. Slang respects this here and load it properly!
float3x4 correctly_read_matrix = *push.ptr;
printf("(%f,%f,%f,%f)\n(%f,%f,%f,%f)\n",
correctly_read_matrix[0][0], correctly_read_matrix[0][1], correctly_read_matrix[0][2], correctly_read_matrix[0][3],
correctly_read_matrix[1][0], correctly_read_matrix[1][1], correctly_read_matrix[1][2], correctly_read_matrix[1][3]
);
printf("(%f,%f,%f,%f)\n\n",
correctly_read_matrix[2][0], correctly_read_matrix[2][1], correctly_read_matrix[2][2], correctly_read_matrix[2][3]
);
// With this syntax however, Slang ignores the column major setting and loads it as it it was row major!
float3x4 broken_matrix = push.ptr[0];
printf("(%f,%f,%f,%f)\n(%f,%f,%f,%f)\n",
broken_matrix[0][0], broken_matrix[0][1], broken_matrix[0][2], broken_matrix[0][3],
broken_matrix[1][0], broken_matrix[1][1], broken_matrix[1][2], broken_matrix[1][3]
);
printf("(%f,%f,%f,%f)\n\n",
broken_matrix[2][0], broken_matrix[2][1], broken_matrix[2][2], broken_matrix[2][3]
);
} I wrote the following matrix to a buffer: buffer_host_ptr = f32mat3x4{
// rc = row column
{11, 21, 31}, // col 1
{12, 22, 32}, // col 2
{13, 23, 33}, // col 3
{14, 24, 34}, // col 4
}; I get the following output from the minimal repro:
|
I looked into it and verified that sessionDesc.defaultMatrixLayout is indeed ineffective and fixed that. I think the buffer pointer thing is a different issue. |
Btw, thank you for all the quick fixes. This is very appreciated. I had much worse experience with other shading languages fixing issues. |
OK, the PR should fix this issue. |
And thank you for your patience with the compiler so far. The buffer pointer thing and the API around setting compiler options are relatively new and there are still bugs, but we are committed to address any issues quickly. |
Setting
slang::SessionDesc::defaultMatrixLayoutMode
toSLANG_MATRIX_LAYOUT_COLUMN_MAJOR
, seems to have no effect when compiling with the following settings:Also, i found that specific typedef qualifier syntax causes an internal compiler error:
I would like this syntax (
typedef qualifier type alias
) to work.The text was updated successfully, but these errors were encountered: