def get_remote_controller(host: str, rdc_path: str): status, remote = rd.CreateRemoteServerConnection(host) if status != rd.ReplayStatus.Succeeded: raise RuntimeError(f"Couldn't connect to remote server, got error {str(status)}") remote_rdc_path = remote.CopyCaptureToRemote(rdc_path, lambda progress: print_progress_bar(int(progress * 100), 100, "Transferring capture:")) finish_progress_bar() status, controller = remote.OpenCapture(rd.RemoteServer.NoPreference, remote_rdc_path, rd.ReplayOptions(), None) if status != rd.ReplayStatus.Succeeded: raise RuntimeError(f"Couldn't open {remote_rdc_path} on remote, got error {str(status)}") return controller
def check_capture(self, capture_filename: str, controller: rd.ReplayController): self.controller = controller self.opengl_mode = (self.controller.GetAPIProperties().pipelineType == rd.GraphicsAPI.OpenGL) failed = False try: # First check with the local controller self.check_capture_with_controller('') except rdtest.TestFailureException as ex: rdtest.log.error(str(ex)) failed = True # Now shut it down self.controller.Shutdown() self.controller = None # Launch a remote server rdtest.launch_remote_server() # Wait for it to start time.sleep(0.5) ret: Tuple[rd.ReplayStatus, rd.RemoteServer] = rd.CreateRemoteServerConnection( 'localhost') status, remote = ret proxies = remote.LocalProxies() try: # Try D3D11 and GL as proxies, D3D12/Vulkan technically don't have proxying implemented even though they # will be listed in proxies for api in ['D3D11', 'OpenGL']: if api not in proxies: continue try: ret: Tuple[rd.ReplayStatus, rd.ReplayController] = remote.OpenCapture( proxies.index(api), capture_filename, rd.ReplayOptions(), None) status, self.controller = ret # Now check with the proxy self.check_capture_with_controller(api) except ValueError: continue except rdtest.TestFailureException as ex: rdtest.log.error(str(ex)) failed = True finally: self.controller.Shutdown() self.controller = None finally: remote.ShutdownServerAndConnection() # Now iterate over all the temp images saved out, load them as captures, and check the texture. dir_path = rdtest.get_tmp_path('') was_opengl = self.opengl_mode # We iterate in filename order, so that dds files get opened before png files. for file in os.scandir(dir_path): if '.dds' not in file.name and '.png' not in file.name: continue cap = rd.OpenCaptureFile() status = cap.OpenFile(file.path, 'rdc', None) if status != rd.ReplayStatus.Succeeded: rdtest.log.error("Couldn't open {}".format(file.name)) failed = True continue ret: Tuple[rd.ReplayStatus, rd.ReplayController] = cap.OpenCapture( rd.ReplayOptions(), None) status, self.controller = ret # Some packed formats can't be opened, allow that if status == rd.ReplayStatus.ImageUnsupported and 'dds' in file.name: rdtest.log.print("Couldn't open {} - unsupported".format( file.name)) continue if status != rd.ReplayStatus.Succeeded: rdtest.log.error("Couldn't open {}".format(file.name)) failed = True continue self.filename = file.name.replace('.dds', '').replace('.png', '') [a, b] = file.name.replace('.dds', ' (DDS)').replace('.png', ' (PNG)').split('@') self.controller.SetFrameEvent( self.controller.GetDrawcalls()[0].eventId, True) try: self.opengl_mode = False fmt: rd.ResourceFormat = self.controller.GetTextures( )[0].format is_compressed = (rd.ResourceFormatType.BC1 <= fmt.type <= rd.ResourceFormatType.BC7 or fmt.type == rd.ResourceFormatType.EAC or fmt.type == rd.ResourceFormatType.ETC2 or fmt.type == rd.ResourceFormatType.ASTC or fmt.type == rd.ResourceFormatType.PVRTC) # OpenGL saves all non-compressed images to disk with a flip, since that's the expected order for # most formats. The effect of this is that we should apply the opengl_mode workaround for all files # *except* compressed textures if was_opengl and not is_compressed: self.opengl_mode = True self.check_test( a, b, Texture_Zoo.TEST_DDS if '.dds' in file.name else Texture_Zoo.TEST_PNG) rdtest.log.success("{} loaded with the correct data".format( file.name)) except rdtest.TestFailureException as ex: rdtest.log.error(str(ex)) failed = True self.controller.Shutdown() self.controller = None if failed: raise rdtest.TestFailureException( "Some tests were not as expected")
# If so, trying to execute a program for capture is an error if not protocol.SupportsMultiplePrograms(URL): # check to see if anything is running. Just use the URL ident = rd.EnumerateRemoteTargets(URL, 0) if ident != 0: raise RuntimeError(f"{name} already has a program running on {ident}") else: # If you're not using a protocol then the URL can simply be a hostname. # The remote server must be running already - how that is done is up # to you. Everything else will work the same over a normal TCP connection protocol = None URL = hostname # Let's try to connect status,remote = rd.CreateRemoteServerConnection(URL) if status == rd.ReplayStatus.NetworkIOFailed and protocol is not None: # If there's just no I/O, most likely the server is not running. If we have # a protocol, we can try to start the remote server print("Couldn't connect to remote server, trying to start it") status = protocol.StartRemoteServer(URL) if status != rd.ReplayStatus.Succeeded: raise RuntimeError(f"Couldn't launch remote server, got error {str(status)}") # Try to connect again! status,remote = rd.CreateRemoteServerConnection(URL) if status != rd.ReplayStatus.Succeeded:
if not protocol.SupportsMultiplePrograms(URL): # check to see if anything is running. Just use the URL ident = rd.EnumerateRemoteTargets(URL, 0) if ident != 0: raise RuntimeError( f"{name} already has a program running on {ident}") else: # If you're not using a protocol then the URL can simply be a hostname. # The remote server must be running already - how that is done is up # to you. Everything else will work the same over a normal TCP connection protocol = None URL = hostname # Let's try to connect result, remote = rd.CreateRemoteServerConnection(URL) if result == rd.ResultCode.NetworkIOFailed and protocol is not None: # If there's just no I/O, most likely the server is not running. If we have # a protocol, we can try to start the remote server print("Couldn't connect to remote server, trying to start it") result = protocol.StartRemoteServer(URL) if result != rd.ResultCode.Succeeded: raise RuntimeError( f"Couldn't launch remote server, got error {str(result)}") # Try to connect again! result, remote = rd.CreateRemoteServerConnection(URL)