hlslpp icon indicating copy to clipboard operation
hlslpp copied to clipboard

Double precision matrix support

Open CUSkidmore opened this issue 4 years ago • 4 comments

Would you consider adding support for double precision matrix such as double4x4?

CUSkidmore avatar Feb 07 '21 14:02 CUSkidmore

Hi @CUSkidmore it is always my plan to expand hlsl++ beyond its capabilities and make it as useful as possible. It isn't a priority right now as it's a big chunk of work, and there are several considerations such as SSE/AVX implementation. I'll leave it here in case there is more demand or even if you want to tackle it. As a matter of curiosity, what application would you use them for?

redorav avatar Feb 07 '21 17:02 redorav

Hi @CUSkidmore it is always my plan to expand hlsl++ beyond its capabilities and make it as useful as possible. It isn't a priority right now as it's a big chunk of work, and there are several considerations such as SSE/AVX implementation. I'll leave it here in case there is more demand or even if you want to tackle it. As a matter of curiosity, what application would you use them for?

I can only talk for myself, but I'm doing CAD rendering with HLSL.

If I want to use the same functions to work with view matrices and similar in shaders and on CPU, then it would be important.

I myself don't really care about SSE vs AVX implementation, you could give me a simple transpose and FMA matrix-vector done in terms of double8 and leave optimization as a TODO.

I guess we as the users of something whose goal is to be compatible with HLSL syntax are not looking for ultimate performance but maintainability offerred by code-sharing between C++ and HLSL

Hi @devshgraphicsprogramming,

I can only talk for myself, but I'm doing CAD rendering with HLSL.

I can see there can be a use case for this, so thanks for commenting.

I myself don't really care about SSE vs AVX implementation, I guess we as the users of something whose goal is to be compatible with HLSL syntax are not looking for ultimate performance but maintainability offerred by code-sharing between C++ and HLSL

This library's main target is SIMD-style computation, such as SSE and AVX, which I think is clear from the repository decription. Scalar implementations are there for compatibility. Were I to implement this I would go the fully featured route, not a halfway solution. I understand that as a user you may not need it but I personally use this library in my own projects and have to maintain it.

you could give me a simple transpose and FMA matrix-vector.

I should be able to implement the beginnings of a double matrix with this in mind and prioritize your needs, which as you said are multiplying by vectors and transposing. That might not be a lot of work considering that double vectors already exist in the codebase. Also bear in mind I do this outside work, if you need this urgently you could consider submitting a patch or something that would speed it up.

redorav avatar Mar 22 '23 17:03 redorav

which as you said are multiplying by vectors and transposing

I was refering to "turn row major into columns and do matrix-vector mult as FMA" as a particular strategy.

My main use case is just matrix<4,4,double> and double<4> usage (adding, multiplying with each other and themselves) followed by a bit of double<3>.

Also bear in mind I do this outside work, if you need this urgently you could consider submitting a patch or something that would speed it up.

We will try and use it in our engine https://github.com/devshgraphicsprogramming/Nabla and if we feel like we can get 90% of the functionality then we'll submit patches for the remaining 10%.

We've already done this to SPIRV-Cross, shaderc/glslang, and DXC.