From 5c28bd0a31a74114d593aba85af210009fc19598 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 6 May 2019 15:57:02 +0100 Subject: [PATCH] Add a parameter to allow saving RGB PNGs --- util/test/rdtest/util.py | 6 +++--- util/test/tests/Vulkan/VK_Sample_Locations.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/util/test/rdtest/util.py b/util/test/rdtest/util.py index 94aaeef4d..6eeb92276 100644 --- a/util/test/rdtest/util.py +++ b/util/test/rdtest/util.py @@ -105,13 +105,13 @@ def sanitise_filename(name: str): return re.sub('^/', '', name) -def png_save(out_path: str, rows: List[bytes], dimensions: Tuple[int, int]): +def png_save(out_path: str, rows: List[bytes], dimensions: Tuple[int, int], has_alpha: bool): try: f = open(out_path, 'wb') except Exception as ex: raise FileNotFoundError("Can't open {} for write".format(sanitise_filename(out_path))) - writer = png.Writer(dimensions[0], dimensions[1], alpha=True, greyscale=False, compression=7) + writer = png.Writer(dimensions[0], dimensions[1], alpha=has_alpha, greyscale=False, compression=7) writer.write(f, rows) f.close() @@ -165,7 +165,7 @@ def png_compare(test_img: str, ref_img: str, tolerance: int = 2): if os.path.exists(diff_file): os.remove(diff_file) - png_save(diff_file, diff_data, (test_w, test_h)) + png_save(diff_file, diff_data, (test_w, test_h), True) return False diff --git a/util/test/tests/Vulkan/VK_Sample_Locations.py b/util/test/tests/Vulkan/VK_Sample_Locations.py index 4af050260..2e140f96d 100644 --- a/util/test/tests/Vulkan/VK_Sample_Locations.py +++ b/util/test/tests/Vulkan/VK_Sample_Locations.py @@ -126,8 +126,8 @@ class VK_Sample_Locations(rdtest.TestCase): degenerate.append(combined_data[row][0:len]) rotated.append(combined_data[row][len:]) - rdtest.png_save(degenerate_path, degenerate, halfdim) - rdtest.png_save(rotated_path, rotated, halfdim) + rdtest.png_save(degenerate_path, degenerate, halfdim, True) + rdtest.png_save(rotated_path, rotated, halfdim, True) # first two degenerate images should be identical, as should the last two, and they should be different. if not rdtest.png_compare(degenerate_paths[0], degenerate_paths[1], 0):