-
Notifications
You must be signed in to change notification settings - Fork 114
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
Update Plane2D step after resetDimensions #58
Conversation
This can not be merged as is; we need to know the real buffer size in Plane2D to be able to check if |
If you change step in Plane2D, you must do it in compliance with Texture alignment rules. Since this is a card-specific value, you are not supposed to guess. So "this->step = w * this->elemSize();" is dangerous just because of that. If you dare doing this, you should round up to the next multiple of 256 (there are cards that need 32, most need 128, but a few new 256). |
The new commit adds a size_t _total_bytes to PlaneBase to hold the allocated memory. That is somewhat hackish because PlaneBase objects are instantiated on the GPU side, but this _total_bytes will only be initialized correctly on the CPU side. |
Host (CPU) Plane2D references contiguous memory and doesn't have pitch. Its step must be updated when it changes dimensions. * split resetDimensions into resetDimensionsHost and resetDimensionsDev * resetDimensionsHost: reference contiguous memory => update Plane2D's step to width * elemSize() * resetDimensionsDev: reference pitched memory => let the step untouched
4331c9a
to
89e9f8e
Compare
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.
LGTM
The problem was not about updating the step of device Plane2Ds, but host ones.
Introducing resetDimensionsDev and resetDimensionsHost to handle this. |
89e9f8e
to
4784719
Compare
This looks fine to me now. |
Plane2D's step is directly related to effective width and needs to be updated when dimension changes.
This fixes an issue when mixing images with different resolutions that can result in wrong buffer accesses, as shown here:
Re-using a previously allocated buffer (first figure) from the pool to work on another image with different width/height leads to erroneous results (second figure); updating the step fix this (third image).
Probably related to #56.