Fix GL_Buffer_Updates to not rely on exact thumbnail

This commit is contained in:
baldurk
2024-12-10 00:06:39 +00:00
parent 8cabf9eaf0
commit 9d32418e33
+28 -13
View File
@@ -30,15 +30,6 @@ class GL_Buffer_Updates(rdtest.TestCase):
rdtest.log.success("Draws are all green")
# Now save the backbuffer to disk
ref_path = rdtest.get_tmp_path('backbuffer.png')
save_data = rd.TextureSave()
save_data.resourceId = tex
save_data.destType = rd.FileType.PNG
self.controller.SaveTexture(save_data, ref_path)
# Open the capture and grab the thumbnail, check that it is all green too (dirty way of verifying we didn't
# break in-app updates but somehow end up with the right data)
cap = rd.OpenCaptureFile()
@@ -58,9 +49,33 @@ class GL_Buffer_Updates(rdtest.TestCase):
with open(tmp_path, 'wb') as f:
f.write(thumb.data)
# The original thumbnail should also be identical, since we have the uncompressed extended thumbnail.
test_reader = rdtest.png.Reader(filename=tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference backbuffer and thumbnail image differ", tmp_path, ref_path)
test_w, test_h, test_data, test_info = test_reader.read()
rdtest.log.success("Thumbnail is identical to reference")
box_w = test_w//8
rows = test_h//box_w
offset = box_w//2
rows_data = list(test_data)
comps = 4 if test_info['alpha'] else 3
for row in range(0,rows):
y = row * box_w + offset
row_data = rows_data[y]
for col in range(0, 8):
x = col * box_w + offset
pixel = (row_data[x * comps + 0]/255, row_data[x * comps + 1]/255,
row_data[x * comps + 2]/255)
if (not rdtest.value_compare((0.2, 0.2, 0.2), pixel, 1) and
not rdtest.value_compare((0.0, 1.0, 0.0), pixel, 1)):
raise rdtest.TestFailureException(
f"Thumbnail of backbuffer at {x},{y} has bad pixel: {pixel}", tmp_path)
rdtest.log.success("Thumbnail is as expected")