Files
renderdoc/util/test/tests/GL/GL_Callstacks.py
T
baldurk 7149302680 Rename 'draw' or 'drawcall' to action
* There's not a good accepted terminology for this kind of event, and for
  historical reasons 'drawcall' has been the accepted term, even though
  that can be quite confusing when a dispatch or a copy is a 'drawcall'.
* This is particularly highlighted by the event browser filters where
  $draw() includes draws and dispatches, but $dispatch() only includes
  dispatches, it's hard to intuitively understand why $draw() matches all
  of these calls.
* As a result we've defined the term 'action' to cover these types of
  events in the same way that we defined 'event' in the first place to
  mean a single atomic API call.
2021-07-01 15:15:05 +01:00

79 lines
2.8 KiB
Python

import renderdoc as rd
import rdtest
prevProgress = -1.0
def resolve_progress(progress: float):
global prevProgress
if progress - prevProgress > 0.01 or progress == 1.0:
prevProgress = progress
rdtest.log.print("Resolve progress: {:.2f}%".format(progress*100.0))
class GL_Callstacks(rdtest.TestCase):
demos_test_name = 'GL_Callstacks'
def get_capture_options(self):
ret = rd.CaptureOptions()
ret.captureCallstacks = True
return ret
def check_capture(self):
# Need capture access. Rather than trying to keep the original around, we just open a new one
cap = rd.OpenCaptureFile()
# Open a particular file
status = cap.OpenFile(self.capture_filename, '', None)
# Make sure the file opened successfully
if status != rd.ReplayStatus.Succeeded:
cap.Shutdown()
raise rdtest.TestFailureException("Couldn't open capture for access: {}".format(self.capture_filename, str(status)))
if not cap.HasCallstacks():
raise rdtest.TestFailureException("Capture does not report having callstacks")
if not cap.InitResolver(False, resolve_progress):
raise rdtest.TestFailureException("Failed to initialise callstack resolver")
action = self.find_action("Draw")
event: rd.APIEvent = action.events[-1]
expected_funcs = [
"GL_Callstacks::testFunction",
"GL_Callstacks::main",
]
expected_lines = [
7001,
8002
]
sdfile = self.controller.GetStructuredFile()
if event.chunkIndex < 0 or event.chunkIndex > len(sdfile.chunks):
raise rdtest.TestFailureException("Event {} has invalid chunk index {}"
.format(event.eventId, event.chunkIndex))
chunk = sdfile.chunks[event.chunkIndex]
callstack = cap.GetResolve(list(chunk.metadata.callstack))
if len(callstack) < len(expected_funcs):
raise rdtest.TestFailureException("Resolved callstack isn't long enough ({} stack frames), expected at least {}".format(len(event.callstack), len(expected_funcs)))
for i in range(len(expected_funcs)):
stack: str = callstack[i]
if expected_funcs[i] not in stack:
raise rdtest.TestFailureException("Expected '{}' in '{}'".format(expected_funcs[i], stack))
idx = callstack[i].find("line")
if idx < 0:
raise rdtest.TestFailureException("Expected a line number in '{}'".format(stack))
if int(stack[idx+5:]) != expected_lines[i]:
raise rdtest.TestFailureException("Expected line number {} in '{}'".format(expected_lines[i], stack))
rdtest.log.success("Callstacks are as expected")