Re: [PATCH 10/11] drm/vkms: add script to create optimized LUTs for color curves

[email protected] Tue, 04 Aug 2026 20:47:36 +0000
Newsgroups org.freedesktop.lists.dri-devel
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Unconditional GUI plot generation and matplotlib import block script execution and break in headless environments.
--

--- Patch [10]: [PATCH 10/11] drm/vkms: add script to create optimized LUTs for color curves ---
commit eeb1a305fab717b385cfb6fdf6633f43f03c3b5f
Author: Leandro Ribeiro <[email protected]>

drm/vkms: add script to create optimized LUTs for color curves

This commit adds a Python script to generate u16 LUTs for VKMS color transfer
functions. The script compares different LUT generation strategies and outputs
the generated LUTs as C arrays formatted for vkms_luts.c.

> diff --git a/drivers/gpu/drm/vkms/scripts/color-curve-lut.py b/drivers/gpu/drm/vkms/scripts/color-curve-lut.py
> new file mode 100644
> index 0000000000000..f80e67120f5b3
> --- /dev/null
> +++ b/drivers/gpu/drm/vkms/scripts/color-curve-lut.py
> @@ -0,0 +1,561 @@
[ ... ]
> +import sys
> +import os
> +import time
> +import bisect
> +import math
> +import numpy as np
> +import matplotlib.pyplot as plt

[Severity: Medium]
Will this unconditional import of matplotlib crash the script in headless
environments or CI pipelines that lack a configured display backend?

[ ... ]
> +def main(args):
[ ... ]
> +    # Save the greedy subdivision LUT as C arrays for VKMS
> +    greedy_lut = luts[2]
> +    emit_c_arrays(greedy_lut, func_str)
> +
> +    # Plot the LUTs... kind of useless when we have a big LUT, but still good to
> +    # visualize with fewer taps.
> +    fig, axes = plt.subplots(1, len(luts), figsize=(15, 6))
> +    for i, lut in enumerate(luts):
> +        ax = axes[i]
> +        ax.set_title(f"{lut.name} - {func_str}, LUT size: {lut.lut_size}")
> +        ax.set_xlabel('X')
> +        ax.set_ylabel('Y')
> +        ax.grid(True, linestyle='--')
> +        ax.plot(lut.x, lut.y, 'o', color="blue")
> +        ax.set_aspect('equal')
> +    plt.tight_layout()
> +    plt.show()

[Severity: Medium]
Does this plt.show() call block execution indefinitely until the GUI window is
manually closed? 

If this script is run as part of an automated workflow, this could cause the
process to hang. Could the plotting functionality be made optional and put
behind a command-line flag?

> +
> +
> +if __name__ == "__main__":
> +    main(sys.argv)

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=10