Skip to content

Commit

Permalink
Fix GL_Buffer_Updates to not rely on exact thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurk committed Dec 10, 2024
1 parent 8cabf9e commit 9d32418
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions util/test/tests/GL/GL_Buffer_Updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ def check_capture(self):

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()
Expand All @@ -58,9 +49,33 @@ def check_capture(self):
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)

test_w, test_h, test_data, test_info = test_reader.read()

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.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference backbuffer and thumbnail image differ", tmp_path, ref_path)
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 identical to reference")
rdtest.log.success("Thumbnail is as expected")

0 comments on commit 9d32418

Please sign in to comment.