Rewrote OpenCL-OpenGL-interop device discovery routine without extensions and with Apple support#26281
Merged
asmorkalov merged 7 commits intoopencv:4.xfrom Oct 18, 2024
Merged
Conversation
6 tasks
Contributor
Author
|
Build error seems to be an unrelated timeout. checking. |
Contributor
Author
|
Build error is an unrelated case of: #24731 |
Contributor
Author
|
Will have access to a Mac this evening to do final testing on that plarform. |
Contributor
Author
|
Works on linux/nvidia, linux/intel and mac - currently can't test on windows. I think this is ready. |
asmorkalov
reviewed
Oct 14, 2024
| { | ||
| AutoBuffer<char> extensionStr; | ||
| try { | ||
| devices = new cl_device_id[devCnt]; |
Contributor
There was a problem hiding this comment.
Let's use std::vector<> or cv::AutoBuffer for locals to prevent leaks.
| char* extensions = nullptr; | ||
|
|
||
| try { | ||
| extensions = new char[extensionSize]; |
Contributor
There was a problem hiding this comment.
The same on memory management.
asmorkalov
reviewed
Oct 15, 2024
Comment on lines
+1697
to
+1724
| std::string devString; | ||
|
|
||
| if(extensions != nullptr) { | ||
| devString = extensions; | ||
| delete[] extensions; | ||
| } | ||
| else { | ||
| CV_Error(cv::Error::OpenCLInitError, "OpenCL: Unexpected error during device extensions gathering"); | ||
| } | ||
|
|
||
| size_t oldPos = 0; | ||
| size_t spacePos = devString.find(' ', oldPos); // extensions string is space delimited | ||
| while (spacePos != devString.npos) { | ||
| if (strcmp(GL_SHARING_EXTENSION, | ||
| devString.substr(oldPos, spacePos - oldPos).c_str()) | ||
| == 0) { | ||
| // Device supports context sharing with OpenGL | ||
| devUsed = i; | ||
| sharingSupported = true; | ||
| break; | ||
| } | ||
| do { | ||
| oldPos = spacePos + 1; | ||
| spacePos = devString.find(' ', oldPos); | ||
| } while (spacePos == oldPos); | ||
| } | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Let's extract extension search as dedicated static function. It should make the code more readable.
4 tasks
Contributor
|
Works with Ubuntu 18.04 and NVIDIA GF1080. |
asmorkalov
approved these changes
Oct 18, 2024
Merged
Contributor
Author
|
I'd still perform the proposals from review. should i? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIPIssue: #26273
Supersedes: #26274
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.