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

UniformMatrix4f does not seem to work #98

Open
harry-cpp opened this issue Apr 17, 2018 · 7 comments
Open

UniformMatrix4f does not seem to work #98

harry-cpp opened this issue Apr 17, 2018 · 7 comments

Comments

@harry-cpp
Copy link

Unless I am doing something wrong, UniformMatrix4f does not work with System.Numerics.Matrix4x4:

// works 
fixed (Matrix4x4* native = &_mvp)
    Gl.UniformMatrix4(_matrixid, 1, false, (float*)native);

// does not work :(
// Gl.UniformMatrix4f<Matrix4x4>(_matrixid, 1, false, ref _mvp);
@luca-piccioni
Copy link
Owner

Numerics structure have special JIT management, and the generic functions on some platforms uses the "obscure" __makeref keyword, which assumes that the value is allocate on stack.

On what platform are you running?

Maybe in Debug configuration is it working?

The Numerics structures is have a column-major order? Maybe it is sufficient to transpose the matrix.

The Numerics structure maybe does have the proper StructLayout?

@harry-cpp
Copy link
Author

harry-cpp commented Apr 20, 2018

On what platform are you running?

Linux, mono, net471

Maybe in Debug configuration is it working?

Does not work in it.

The Numerics structures is have a column-major order? Maybe it is sufficient to transpose the matrix.
The Numerics structure maybe does have the proper StructLayout?

Wouldn't my fixed code fail than?

@luca-piccioni
Copy link
Owner

Correct. Tonight I'll check with some unit tests...

@harry-cpp
Copy link
Author

@luca-piccioni Any update on this?

@luca-piccioni
Copy link
Owner

I've checked the unit tests for glUniform1-4v, and they are currently calling generic Uniform calls (but not the generic GetUniform calls), and they run successfully on my machine.

I thought to be confident that the UniformMatrix generic calls are fine too since the underlying implementation is essentially the same. I suspect that the issue is strictly related to the Numerics structure.

If you convert the Numerics.Matrix4 structure to the managed Matrix4x4f structure (or any equivalent), is it working? When I'll have some free time I'll write specific test for UniformMatrix calls.

@harry-cpp
Copy link
Author

If you convert the Numerics.Matrix4 structure to the managed Matrix4x4f structure (or any equivalent), is it working?

It was not working, I checked before submitting this issue.

@harry-cpp
Copy link
Author

Fun note, I found out that the code runs fine on Windows, but not on Linux.

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

No branches or pull requests

2 participants