def vid(self, draw: rd.DrawcallDescription, val: int): # For D3D, Vertex ID is either 0-based for non indexed calls, or the raw index. That means no baseVertex applied if rd.IsD3D(self.props.pipelineType): if draw.flags & rd.DrawFlags.Indexed: return float(val - draw.baseVertex) return float(val) # For GL and vulkan it includes all offsets - so for non-indexed that includes vertexOffset, and for indexed # that includes baseVertex if draw.flags & rd.DrawFlags.Indexed: return float(val) return float(val + draw.vertexOffset)
def check_capture(self, capture_filename: str, controller: rd.ReplayController): self.controller = controller self.pipeType = self.controller.GetAPIProperties().pipelineType self.opengl_mode = (self.controller.GetAPIProperties().pipelineType == rd.GraphicsAPI.OpenGL) self.d3d_mode = rd.IsD3D( self.controller.GetAPIProperties().pipelineType) 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.ResultCode, rd.RemoteServer] = rd.CreateRemoteServerConnection( 'localhost') result, remote = ret if result != rd.ResultCode.Succeeded: time.sleep(2) ret: Tuple[rd.ResultCode, rd.RemoteServer] = rd.CreateRemoteServerConnection( 'localhost') result, remote = ret if result != rd.ResultCode.Succeeded: raise rdtest.TestFailureException( "Couldn't connect to remote server: {}".format(str(result))) 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.ResultCode, rd.ReplayController] = remote.OpenCapture( proxies.index(api), capture_filename, rd.ReplayOptions(), None) result, 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: remote.CloseCapture(self.controller) 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() result = cap.OpenFile(file.path, 'rdc', None) if result != rd.ResultCode.Succeeded: rdtest.log.error("Couldn't open {}".format(file.name)) failed = True continue ret: Tuple[rd.ResultCode, rd.ReplayController] = cap.OpenCapture( rd.ReplayOptions(), None) result, self.controller = ret if result != rd.ResultCode.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.GetRootActions()[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.out: rd.ReplayOutput = self.controller.CreateOutput( rd.CreateHeadlessWindowingData(100, 100), rd.ReplayOutputType.Texture) self.check_test( a, b, Texture_Zoo.TEST_DDS if '.dds' in file.name else Texture_Zoo.TEST_PNG) self.out.Shutdown() self.out = None 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")