-
Notifications
You must be signed in to change notification settings - Fork 632
GLSL: Implement SPV_NV_cooperative_matrix2, SPV_NV_tensor_addressing. #2529
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
base: main
Are you sure you want to change the base?
Conversation
|
Is there something I need to review here? It's marked as draft and assuming it's WIP until undrafted. |
|
Callback functions are complicated. Should I split them off to a separate PR? Do you agree with the overall approach on how to handle them? I basically stopped at WIP because I wanted to know how you would handle the "all parameters must be |
cf931c6 to
96ecacb
Compare
HansKristian-Work
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call callback functions require const in for all parameters which is a unusual requirement. I'm not sure yet how to best implement this (flag on the parameters, flag on the functions)
What do you mean here? Do you literally have to annotate the parameters as void my_lambda(const int a), or do you mean just not using in/out/inout?
spirv_common.hpp
Outdated
| #include "spirv_cross_containers.hpp" | ||
| #include "spirv_cross_error_handling.hpp" | ||
| #include <functional> | ||
| #include <array> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't really used in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
spirv_common.hpp
Outdated
| AccelerationStructure, | ||
| RayQuery, | ||
| CoopVecNV, | ||
| TensorLayoutNv, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NV for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
spirv_common.hpp
Outdated
| // read and write counts as access to the function arguments | ||
| // is not local to the function in question. | ||
| bool alias_global_variable; | ||
| spv::StorageClass storage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird indent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
spirv_parser.cpp
Outdated
| } | ||
| if (length - 3 > type.ext.tensorViewNv.dim_ids.size() || dims.scalar() > type.ext.tensorViewNv.dim_ids.size()) | ||
| { | ||
| SPIRV_CROSS_THROW("Can't have more than 5 dimensions for tensor view!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec limitation or SPIRV-Cross limitation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spec limitation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rephrased the message to make clear that this is a spec limitation
spirv_common.hpp
Outdated
| uint32_t dim_id; | ||
| uint32_t has_dimensions_id; | ||
| // From spec on Dims: "The value must be greater than zero and less than or equal to 5." | ||
| std::array<int32_t, 5> dim_ids; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-POT inside union will lead to subtle UB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with plain array and top-level constant for array length
spirv_glsl.cpp
Outdated
|
|
||
| auto called_func = maybe_get_called_function(instruction); | ||
| if(called_func) { | ||
| for(auto& par: called_func->arguments) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reference and pointer ties right.
yes, they need to be explicitly annotated with |
|
Sorry for not getting back to this sooner. For the "const in" part, I suppose a simple bool in SPIRFunction is sufficient? A simple "used as lambda function" is probably fine. |
ca6c40f to
4c84008
Compare
I moved the info for the special usage from the SPIRParameter to SPIRFunction in the last commit. |
9b1efe3 to
2df866a
Compare
9509800 to
52d8cc7
Compare
This adds support for more operations SPV_NV_cooperative_matrix2 and SPV_NV_tensor_addressing
Marking as draft because:
intspec constant (instead of uint) for createTensorLayoutNV leads to null pointer dereference glslang#4011 makes a workaround in this PR necessary.createTensorLayoutNVexpects auintargument while all names constants for the arguments areint. When casting a spec constant tointand passing it tocreateTensorLayoutNVone would trigger Using aintspec constant (instead of uint) for createTensorLayoutNV leads to null pointer dereference glslang#4011OpFunctionCallwas assumed to be the only op code being able to call functionshandler.begin_function_scope/handler.end_function_scopewould need to be refactored to not assumeOpFunctionCall(currently just skipped since implementers currently still assumeOpFunctionCallespecially the operand index where they would find the called function)const infor all parameters which is a unusual requirement. I'm not sure yet how to best implement this (flag on the parameters, flag on the functions)