-
Notifications
You must be signed in to change notification settings - Fork 5.9k
cudev: fix CUDA texture pitch alignment for createContinuous GpuMat #4068
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: 4.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -176,17 +176,28 @@ namespace cv { namespace cudev { | |||||||||||||||||||||||||||||||
| texRes.res.pitch2D.height = rows; | ||||||||||||||||||||||||||||||||
| texRes.res.pitch2D.width = cols; | ||||||||||||||||||||||||||||||||
| // temporary fix for single row/columns until TexturePtr is reworked | ||||||||||||||||||||||||||||||||
| if (rows == 1 || cols == 1) { | ||||||||||||||||||||||||||||||||
| int currentDevice = 0; | ||||||||||||||||||||||||||||||||
| CV_CUDEV_SAFE_CALL(cudaGetDevice(¤tDevice)); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| cudaDeviceProp prop; | ||||||||||||||||||||||||||||||||
| CV_CUDEV_SAFE_CALL(cudaGetDeviceProperties(&prop, currentDevice)); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+182
to
+184
|
||||||||||||||||||||||||||||||||
| cudaDeviceProp prop; | |
| CV_CUDEV_SAFE_CALL(cudaGetDeviceProperties(&prop, currentDevice)); | |
| // Cache device properties per device to avoid repeated queries. | |
| static int cachedDevice = -1; | |
| static cudaDeviceProp cachedProp; | |
| static bool propInitialized = false; | |
| if (!propInitialized || currentDevice != cachedDevice) | |
| { | |
| CV_CUDEV_SAFE_CALL(cudaGetDeviceProperties(&cachedProp, currentDevice)); | |
| cachedDevice = currentDevice; | |
| propInitialized = true; | |
| } | |
| const cudaDeviceProp& prop = cachedProp; |
Copilot
AI
Jan 23, 2026
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.
Inconsistent indentation: the closing brace and else statement use incorrect indentation. They should align with the opening brace on line 187, using 12 spaces instead of 11.
| } | |
| else { | |
| texRes.res.pitch2D.devPtr = data; | |
| texRes.res.pitch2D.pitchInBytes = step; | |
| } | |
| } | |
| else { | |
| texRes.res.pitch2D.devPtr = data; | |
| texRes.res.pitch2D.pitchInBytes = step; | |
| } |
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.
The comment "temporary fix for single row/columns until TexturePtr is reworked" is now outdated. The fix now also handles pitch alignment issues, not just single row/column cases. Consider updating the comment to reflect the expanded scope, such as: "temporary fix for single row/columns and misaligned pitch until TexturePtr is reworked".