mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-27 16:15:49 +00:00
Greatly speed up 'attach to running instance' dialog in the 99% case
* 99% of the time, you'll only have localhost and the application will be running on the first ident checked which will return a valid socket almost immediately. * Instead of continuing to search through each valid port before returning valid data, we change the enumerate function to just find the next valid port and return - so we can update the UI as soon as we have the first result.
This commit is contained in:
@@ -420,32 +420,33 @@ extern "C" RENDERDOC_API void *RENDERDOC_CC RENDERDOC_AllocArrayMem(uint64_t sz)
|
||||
}
|
||||
|
||||
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_EnumerateRemoteConnections(const char *host,
|
||||
uint32_t *idents)
|
||||
uint32_t nextIdent)
|
||||
{
|
||||
if(idents == NULL)
|
||||
return RenderDoc_LastCaptureNetworkPort - RenderDoc_FirstCaptureNetworkPort + 1;
|
||||
|
||||
string s = "localhost";
|
||||
if(host != NULL && host[0] != '\0')
|
||||
s = host;
|
||||
|
||||
uint32_t numIdents = 0;
|
||||
// initial case is we're called with 0, start with the first port.
|
||||
// otherwise we're called with the last successful ident, so increment
|
||||
// before continuing to enumerate.
|
||||
if(nextIdent == 0)
|
||||
nextIdent = RenderDoc_FirstCaptureNetworkPort;
|
||||
else
|
||||
nextIdent++;
|
||||
|
||||
for(uint16_t ident = RenderDoc_FirstCaptureNetworkPort; ident <= RenderDoc_LastCaptureNetworkPort;
|
||||
ident++)
|
||||
for(; nextIdent <= RenderDoc_LastCaptureNetworkPort; nextIdent++)
|
||||
{
|
||||
Network::Socket *sock = Network::CreateClientSocket(s.c_str(), ident, 250);
|
||||
Network::Socket *sock = Network::CreateClientSocket(s.c_str(), (uint16_t)nextIdent, 250);
|
||||
|
||||
if(sock)
|
||||
{
|
||||
*idents = (uint32_t)ident;
|
||||
idents++;
|
||||
numIdents++;
|
||||
SAFE_DELETE(sock);
|
||||
return nextIdent;
|
||||
}
|
||||
}
|
||||
|
||||
return numIdents;
|
||||
// tried all idents remaining and found nothing
|
||||
return ~0U;
|
||||
}
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SpawnReplayHost(volatile bool32 *killReplay)
|
||||
|
||||
Reference in New Issue
Block a user