Skip to content

Conversation

@theHamsta
Copy link
Contributor

This adds support for more operations SPV_NV_cooperative_matrix2 and SPV_NV_tensor_addressing

Marking as draft because:

@theHamsta theHamsta marked this pull request as draft August 14, 2025 11:57
@HansKristian-Work
Copy link
Contributor

Is there something I need to review here? It's marked as draft and assuming it's WIP until undrafted.

@theHamsta
Copy link
Contributor Author

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 const in requirement".

@theHamsta theHamsta force-pushed the coopmat2 branch 2 times, most recently from cf931c6 to 96ecacb Compare August 18, 2025 13:02
Copy link
Contributor

@HansKristian-Work HansKristian-Work left a 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>
Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NV for consistency.

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indent.

Copy link
Contributor Author

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!");
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spec limitation

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

@theHamsta
Copy link
Contributor Author

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?

yes, they need to be explicitly annotated with const in. void my_lambda(const in int a)

@HansKristian-Work
Copy link
Contributor

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.

@theHamsta theHamsta force-pushed the coopmat2 branch 5 times, most recently from ca6c40f to 4c84008 Compare October 15, 2025 10:12
@theHamsta
Copy link
Contributor Author

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.

I moved the info for the special usage from the SPIRParameter to SPIRFunction in the last commit.

@theHamsta theHamsta marked this pull request as ready for review October 15, 2025 10:14
@theHamsta theHamsta force-pushed the coopmat2 branch 4 times, most recently from 9b1efe3 to 2df866a Compare October 15, 2025 10:23
@theHamsta theHamsta marked this pull request as draft October 15, 2025 10:30
@theHamsta theHamsta force-pushed the coopmat2 branch 2 times, most recently from 9509800 to 52d8cc7 Compare October 15, 2025 11:05
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 this pull request may close these issues.

2 participants