예제 #1
0
    def run(self):
        with InputFile(self.args.file) as input:
            with OutputFile(self.args.newfile) as output:
                output.jsonHeader = input.jsonHeader
                for call in input.Calls():
                    if self.store_call(call):
                        output.WriteCall(call)

                    if call.name == 'eglSwapBuffers':
                        self.current_frame += 1
예제 #2
0
def inject(oldfile, newfile):
    if not os.path.exists(oldfile):
        print("File does not exists: {}".format(oldfile))
        return

    injector = Injector()
    with InputFile(oldfile) as input:
        with OutputFile(newfile) as output:
            injector.run(input, output)

    return injector.num_calls_injected
예제 #3
0
def remap(oldfile, newfile):
    remapper = Remapper()

    if not os.path.exists(oldfile):
        print("File does not exists: {}".format(oldfile))
        return

    with InputFile(oldfile) as input:
        with OutputFile(newfile) as output:
            remapper.run(input, output)

    return remapper.num_calls_remapped
예제 #4
0
def main():
    trace_filepath = sys.argv[1]
    if not os.path.exists(trace_filepath):
        print("File does not exists: {0}".format(trace_filepath))
        sys.exit(1)

    with InputFile(trace_filepath) as input:
        with OutputFile('output.pat') as output:
            output.jsonHeader = input.jsonHeader

            for call in input.Calls():
                OutputCall(output, call)
예제 #5
0
    def saveAs(self):
        from patrace import InputFile, OutputFile
        filename = str(
            QFileDialog.getSaveFileName(parent=self,
                                        caption="Save As Trace",
                                        directory='',
                                        filter='*.pat'))
        if filename:

            if not filename.endswith('.pat'):
                filename += '.pat'

            input_trace = InputFile()
            input_trace.Open(self.trace_path)

            output_trace = OutputFile()
            output_trace.Open(filename)
            output_trace.jsonHeader = json.dumps(
                json.loads(self.headerEditor.json_string))

            for call in input_trace.Calls():
                output_trace.WriteCall(call)

            input_trace.Close()
            output_trace.Close()
예제 #6
0
def main():
    parser = argparse.ArgumentParser(
        description='Upgrade .pat trace file to use the newest binary format')
    parser.add_argument('file', help='Path to the .pat trace file')
    parser.add_argument('--newfile',
                        default='trace_out.pat',
                        help="Specifies the path to the output trace file")

    args = parser.parse_args()
    upgrader = Upgrader(args)

    with InputFile(args.file) as input:
        with OutputFile(args.newfile) as output:
            upgrader.run(input, output)

    print("Number of calls in trace {num}".format(num=upgrader.num_calls))
예제 #7
0
def main():
    parser = argparse.ArgumentParser(description='Change the resolution for all threads in trace')
    parser.add_argument('file', help='Path to the .pat trace file')
    parser.add_argument('width', type=int, help='Resolution width in pixels')
    parser.add_argument('height', type=int, help='Resolution height in pixels')
    parser.add_argument('--newfile', default='trace_out.pat', help="Specifies the path to the output trace file")
    args = parser.parse_args()

    with InputFile(args.file) as input:
        with OutputFile(args.newfile) as output:
            # Modify header, if we are remaping the default tid
            header = json.loads(input.jsonHeader)
            for thread in header['threads']:
                thread['winH'] = args.height
                thread['winW'] = args.width
            output.jsonHeader = json.dumps(header)

            for call in input.Calls():
                output.WriteCall(call)
예제 #8
0
def main():
    parser = argparse.ArgumentParser(
        description='Remap thread ids in a .pat trace')
    parser.add_argument('file', help='Path to the .pat trace file')
    parser.add_argument('--newfile',
                        default='trace_out.pat',
                        help="Specifies the path to the output trace file")
    parser.add_argument('--samples',
                        type=int,
                        default=0,
                        help="Only functions with this name will be remapped",
                        choices=[0, 2, 4, 8, 16])

    args = parser.parse_args()

    with InputFile(args.file) as input:
        with OutputFile(args.newfile) as output:
            modified_fbos = change_msaa_samples(input, output, args.samples)
            print 'Modified FBOs: ' + str(modified_fbos)
예제 #9
0
def main():
    trace_filepath = sys.argv[1]
    if not os.path.exists(trace_filepath):
        print("File does not exists: {0}".format(trace_filepath))
        sys.exit(1)

    with InputFile(trace_filepath) as input:
        header = json.loads(input.jsonHeader)
        if 'defaultTid' in header:
            thread_id = header['defaultTid']

        with OutputFile('output.pat') as output:
            output.jsonHeader = input.jsonHeader

            for call in input.Calls():
                if call.thread_id == thread_id:
                    OutputCall(output, call, thread_id)
                else:
                    output.WriteCall(call)
예제 #10
0
def main():
    parser = argparse.ArgumentParser(
        description='Remap thread ids in a .pat trace')
    parser.add_argument('file', help='Path to the .pat trace file')
    parser.add_argument(
        'oldtid',
        type=int,
        help=
        'The thread id to remap. If set to -1, all thread ids will be remapped.'
    )
    parser.add_argument('newtid', type=int, help='The new thread id')
    parser.add_argument('--newfile',
                        default='trace_out.pat',
                        help="Specifies the path to the output trace file")
    parser.add_argument('--include',
                        default='',
                        help="Only functions with this name will be remapped")
    parser.add_argument('--begin',
                        type=int,
                        default=0,
                        help="Skip this many calls before remapping starts")
    parser.add_argument('--count',
                        type=int,
                        default=-1,
                        help="Remap this many calls. -1 means remap all.")
    parser.add_argument(
        '--calls',
        metavar='N',
        type=int,
        nargs='+',
        help=
        "List of call numbers to remap. If used, all other options are ignored."
    )

    args = parser.parse_args()
    remapper = Remapper(args)

    with InputFile(args.file) as input:
        with OutputFile(args.newfile) as output:
            remapper.run(input, output)

    print("Number of calls remapped {num}".format(
        num=remapper.num_calls_remapped))
예제 #11
0
def main():
    parser = argparse.ArgumentParser(
        description='trim a tracefile',
        epilog='Remember that you wont be able to playback the trace if the '
        'range doesn\'t include resources (texture,shader,vbo) needed '
        'for selected range.')
    parser.add_argument('-f',
                        '--frame_range',
                        type=int,
                        nargs=2,
                        required=True,
                        help='Specify the frame range to record drawcalls')
    parser.add_argument('input_trace', help='Specify the PAT trace to parse')
    parser.add_argument('output_trace', help='Specify name of trace to create')
    args = parser.parse_args()

    if not args.output_trace.endswith('.pat'):
        args.output_trace += '.pat'

    JSON_HEADER_FRAME_COUNT_KEY = 'frameCnt'
    JSON_HEADER_CALL_COUNT_KEY = 'callCnt'

    with InputFile(args.input_trace) as input:
        with OutputFile(args.output_trace) as output:

            jsonHeader = json.loads(input.jsonHeader)

            call_count = 0
            for index in range(args.frame_range[0], args.frame_range[1] + 1):
                for call in input.FrameCalls(index):
                    output.WriteCall(call)
                    call_count += 1

            if JSON_HEADER_FRAME_COUNT_KEY in jsonHeader:
                jsonHeader[JSON_HEADER_FRAME_COUNT_KEY] = args.frame_range[
                    1] - args.frame_range[0] + 1
            if JSON_HEADER_CALL_COUNT_KEY in jsonHeader:
                jsonHeader[JSON_HEADER_CALL_COUNT_KEY] = call_count
            output.jsonHeader = json.dumps(jsonHeader, indent=4)