-
Notifications
You must be signed in to change notification settings - Fork 502
Bugfix: RGB/Hue Curve Performance with MSL #2342
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: main
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 |
|---|---|---|
|
|
@@ -1215,48 +1215,20 @@ ocioOCIOMain( | |
| , bool ocio_grading_rgbcurve_localBypass | ||
| ) | ||
| { | ||
| for(int i = 0; i < ocio_grading_rgbcurve_knotsOffsets_count; ++i) | ||
| { | ||
| this->ocio_grading_rgbcurve_knotsOffsets[i] = ocio_grading_rgbcurve_knotsOffsets[i]; | ||
| } | ||
| for(int i = ocio_grading_rgbcurve_knotsOffsets_count; i < 8; ++i) | ||
| { | ||
| this->ocio_grading_rgbcurve_knotsOffsets[i] = 0; | ||
| } | ||
| for(int i = 0; i < ocio_grading_rgbcurve_knots_count; ++i) | ||
| { | ||
| this->ocio_grading_rgbcurve_knots[i] = ocio_grading_rgbcurve_knots[i]; | ||
| } | ||
| for(int i = ocio_grading_rgbcurve_knots_count; i < 120; ++i) | ||
| { | ||
| this->ocio_grading_rgbcurve_knots[i] = 0; | ||
| } | ||
| for(int i = 0; i < ocio_grading_rgbcurve_coefsOffsets_count; ++i) | ||
| { | ||
| this->ocio_grading_rgbcurve_coefsOffsets[i] = ocio_grading_rgbcurve_coefsOffsets[i]; | ||
| } | ||
| for(int i = ocio_grading_rgbcurve_coefsOffsets_count; i < 8; ++i) | ||
| { | ||
| this->ocio_grading_rgbcurve_coefsOffsets[i] = 0; | ||
| } | ||
| for(int i = 0; i < ocio_grading_rgbcurve_coefs_count; ++i) | ||
| { | ||
| this->ocio_grading_rgbcurve_coefs[i] = ocio_grading_rgbcurve_coefs[i]; | ||
| } | ||
| for(int i = ocio_grading_rgbcurve_coefs_count; i < 360; ++i) | ||
| { | ||
| this->ocio_grading_rgbcurve_coefs[i] = 0; | ||
| } | ||
| this->ocio_grading_rgbcurve_knotsOffsets = ocio_grading_rgbcurve_knotsOffsets; | ||
| this->ocio_grading_rgbcurve_knots = ocio_grading_rgbcurve_knots; | ||
| this->ocio_grading_rgbcurve_coefsOffsets = ocio_grading_rgbcurve_coefsOffsets; | ||
| this->ocio_grading_rgbcurve_coefs = ocio_grading_rgbcurve_coefs; | ||
| this->ocio_grading_rgbcurve_localBypass = ocio_grading_rgbcurve_localBypass; | ||
| } | ||
|
|
||
|
|
||
| // Declaration of all variables | ||
|
|
||
| int ocio_grading_rgbcurve_knotsOffsets[8]; | ||
| float ocio_grading_rgbcurve_knots[120]; | ||
| int ocio_grading_rgbcurve_coefsOffsets[8]; | ||
| float ocio_grading_rgbcurve_coefs[360]; | ||
| constant int* ocio_grading_rgbcurve_knotsOffsets; | ||
| constant float* ocio_grading_rgbcurve_knots; | ||
| constant int* ocio_grading_rgbcurve_coefsOffsets; | ||
| constant float* ocio_grading_rgbcurve_coefs; | ||
| bool ocio_grading_rgbcurve_localBypass; | ||
|
|
||
|
|
||
|
|
@@ -1361,8 +1333,21 @@ float4 OCIOMain( | |
| ).OCIOMain(inPixel); | ||
| } | ||
| )" }; | ||
|
|
||
| OCIO_CHECK_EQUAL(expected, text); | ||
|
|
||
| // The struct is instantiated once per invocation, which for a compute shader | ||
| // dispatched one thread per pixel means once per pixel. Owning the array | ||
| // uniforms rather than pointing at them therefore copies the whole declared | ||
| // capacity into per-thread memory for every pixel, which dominated the cost | ||
| // of any curve op. These checks state that invariant on its own so a future | ||
| // update of the expected text above cannot quietly restore the copy. | ||
| OCIO_CHECK_ASSERT(text.find("constant float* ocio_grading_rgbcurve_knots;") | ||
| != std::string::npos); | ||
| OCIO_CHECK_ASSERT(text.find("this->ocio_grading_rgbcurve_knots = " | ||
| "ocio_grading_rgbcurve_knots;") != std::string::npos); | ||
| OCIO_CHECK_ASSERT(text.find("this->ocio_grading_rgbcurve_knots[i]") | ||
| == std::string::npos); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this is a nit pick but it seems like kind of an odd test. The first two asserts are redundant after the comparison of the shader program above. And for the third, if we don't want people to change the code back in the future, perhaps just a comment where the original code is should suffice? If someone did try to return to the original approach, it would have to be written exactly the same in order to fail this test (e.g., maybe someone uses j rather than i for their loop)? |
||
| } | ||
|
|
||
| OCIO_ADD_TEST(GpuShader, VulkanSupport) | ||
|
|
||
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.
Is it true that "the struct is typically instantiated once per pixel"? Isn't it more typical that a group of pixels is processed in a batch, to amortize cost like this?
I'm all in favor of the change to improve performance for the single-pixel case, but I suspect it's not the "typical" situation.