Skip to content

Fix compilation error when using Algorithm::setPushConstants(const std::vector<T> &)#466

Merged
axsaucedo merged 4 commits into
KomputeProject:masterfrom
mitjap:fix-push-constants-const
Jul 16, 2026
Merged

Fix compilation error when using Algorithm::setPushConstants(const std::vector<T> &)#466
axsaucedo merged 4 commits into
KomputeProject:masterfrom
mitjap:fix-push-constants-const

Conversation

@mitjap

@mitjap mitjap commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This function is templated and is never instantiated in kompute project so the compilation error was not detected.

When calling Algorithm::setPushConstants(const std::vector<T> &), this function then calls Algorithm::setPushConstants(void* data, uint32_t size, uint32_t memorySize) which accepts non-const pointer.

This PR adds a test that instantiates this function and validates the results and also fixes the incorrect function signature.

[ 67%] Building CXX object test/CMakeFiles/kompute_tests.dir/TestPushConstant.cpp.o
In file included from <redacted>/kompute/src/include/kompute/Kompute.hpp:3,
                 from <redacted>/kompute/test/TestPushConstant.cpp:5:
<redacted>/kompute/src/include/kompute/Algorithm.hpp: In instantiation of ‘void kp::Algorithm::setPushConstants(const std::vector<T>&) [with T = float]’:
<redacted>/kompute/test/TestPushConstant.cpp:93:35:   required from here
<redacted>/kompute/src/include/kompute/Algorithm.hpp:217:31: error: no matching function for call to ‘kp::Algorithm::setPushConstants(const float*, uint32_t&, uint32_t&)’
  217 |         this->setPushConstants(pushConstants.data(), size, memorySize);
      |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>/kompute/src/include/kompute/Algorithm.hpp:229:10: note: candidate: ‘void kp::Algorithm::setPushConstants(void*, uint32_t, uint32_t)’ (near match)
  229 |     void setPushConstants(void* data, uint32_t size, uint32_t memorySize)
      |          ^~~~~~~~~~~~~~~~
<redacted>/kompute/src/include/kompute/Algorithm.hpp:229:10: note:   conversion of argument 1 would be ill-formed:
<redacted>/kompute/src/include/kompute/Algorithm.hpp:217:50: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
  217 |         this->setPushConstants(pushConstants.data(), size, memorySize);
      |                                ~~~~~~~~~~~~~~~~~~^~
      |                                                  |
      |                                                  const void*
<redacted>/kompute/src/include/kompute/Algorithm.hpp:212:10: note: candidate: ‘template<class T> void kp::Algorithm::setPushConstants(const std::vector<T>&)’
  212 |     void setPushConstants(const std::vector<T>& pushConstants)
      |          ^~~~~~~~~~~~~~~~
<redacted>/kompute/src/include/kompute/Algorithm.hpp:212:10: note:   template argument deduction/substitution failed:
<redacted>/kompute/src/include/kompute/Algorithm.hpp:217:31: note:   mismatched types ‘const std::vector<T>’ and ‘const float*’
  217 |         this->setPushConstants(pushConstants.data(), size, memorySize);
      |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [test/CMakeFiles/kompute_tests.dir/build.make:191: test/CMakeFiles/kompute_tests.dir/TestPushConstant.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:674: test/CMakeFiles/kompute_tests.dir/all] Error 2
gmake: *** [Makefile:166: all] Error 2

mitjap added 2 commits July 16, 2026 17:32
Signed-off-by: Mitja Puzigaća <mitjap@gmail.com>
Signed-off-by: Mitja Puzigaća <mitjap@gmail.com>
@mitjap
mitjap force-pushed the fix-push-constants-const branch from 7bbead5 to 090cc26 Compare July 16, 2026 15:34
axsaucedo and others added 2 commits July 16, 2026 18:22
@mitjap
mitjap force-pushed the fix-push-constants-const branch from 6295bd6 to 1163efe Compare July 16, 2026 16:46
@axsaucedo
axsaucedo merged commit 004618b into KomputeProject:master Jul 16, 2026
9 checks passed
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