1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
import rdtest
import renderdoc as rd
class VK_Line_Raster(rdtest.TestCase):
demos_test_name = 'VK_Line_Raster'
# Line segments are relative to 100x75 framebuffers. We sample in each corner (adjusted to be sure even with
# slightly varying rasterization we should sample in the line endpoint) and in the middle
points = [
[ 6, 69 ],
[ 50, 36 ],
[ 93, 5 ],
]
view = [ 100, 75 ]
def sample(self, row, col):
ret = []
for p in self.points:
x = self.view[0] * col + p[0]
y = self.view[1] * row + p[1]
picked: rd.PixelValue = self.controller.PickPixel(self.tex, x, y, rd.Subresource(0, 0, 0), rd.CompType.Typeless)
ret.append(rdtest.value_compare(picked.floatValue, [0.0, 1.0, 1.0, 1.0]))
return ret
def check_capture(self):
action = self.find_action("vkCmdEndRenderPass")
self.check(action is not None)
action = action.previous
self.controller.SetFrameEvent(action.eventId, False)
pipe: rd.PipeState = self.controller.GetPipelineState()
self.tex = pipe.GetOutputTargets()[0].resourceId
texdetails = self.get_texture(self.tex)
# Top left we expect a regular line segment.
s = self.sample(0, 0)
# All points should be the line color
if not rdtest.value_compare(s, [True, True, True]):
raise rdtest.TestFailureException("Normal line picked values {} doesn't match expectation".format(s))
# Next row is unstippled. The lines should either be all present, or not present
names = ["Rectangle", "Bresenham", "Rectangle Round"]
for col in [0, 1, 2]:
s = self.sample(1, col)
n = "Unstippled {}".format(names[col])
if s[0]:
if not rdtest.value_compare(s, [True, True, True]):
raise rdtest.TestFailureException("{} picked values {} doesn't match expectation".format(n, s))
rdtest.log.success("{} line looks as expected".format(n))
else:
if not rdtest.value_compare(s, [False, False, False]):
raise rdtest.TestFailureException("{} picked values {} doesn't match expectation".format(n, s))
rdtest.log.success("{} line not supported".format(n))
# Final row is stippled. The lines should be present on each end, and not present in the middle
# (or not present at all)
for col in [0, 1, 2]:
s = self.sample(2, col)
n = "Stippled {}".format(names[col])
if s[0]:
if not rdtest.value_compare(s, [True, False, True]):
raise rdtest.TestFailureException("{} picked values {} doesn't match expectation".format(n, s))
rdtest.log.success("{} line looks as expected".format(n))
else:
if not rdtest.value_compare(s, [False, False, False]):
raise rdtest.TestFailureException("{} picked values {} doesn't match expectation".format(n, s))
rdtest.log.success("{} line not supported".format(n))
rdtest.log.success("All lines look as expected")
|