Skip to content
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

Options::packMatricesInRowMajor is inverted #41

Closed
tklajnscek opened this issue Mar 19, 2019 · 1 comment · Fixed by #50
Closed

Options::packMatricesInRowMajor is inverted #41

tklajnscek opened this issue Mar 19, 2019 · 1 comment · Fixed by #50

Comments

@tklajnscek
Copy link

Describe the bug
Options::packMatricesInRowMajor is inverted. Setting it to true, passes in '-Zpc' which makes the compiler generate column major matrices.

To Reproduce
Inspect the source code:

        // HLSL matrices are translated into SPIR-V OpTypeMatrixs in a transposed manner,
        // See also https://antiagainst.github.io/post/hlsl-for-vulkan-matrices/
        if (options.packMatricesInRowMajor)
        {
            dxcArgStrings.push_back(L"-Zpc");
        }
        else
        {
            dxcArgStrings.push_back(L"-Zpr");
        }

Expected behavior
The values need to be inverted. Reading the comment it seems that this might've been intentionally inverted to fix SPIRV codegen, but my DX12/Vulkan/GLES engine works correctly for all three APIs when I pass in -Zpr and my matrices are row major in memory.

@gongminmin
Copy link
Contributor

How do you use your matrix in shader? If you are writing mul(vector, matrix), a row major matrix on CPU need to be transposed and copy to cbuffer. If it's mul(matrix, vector), you don't need the transpose matries on CPU, but the shader is in lower efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants