Ejemplo n.º 1
0
  virtual int Execute(cmdline::parser &parser, const CaptureOptions &opts)
  {
    if(parser.rest().empty())
    {
      std::cerr << "Error: capture command requires an executable to launch." << std::endl
                << std::endl
                << parser.usage();
      return 0;
    }

    std::string executable = parser.rest()[0];
    std::string workingDir = parser.get<string>("working-dir");
    std::string cmdLine;
    std::string logFile = parser.get<string>("capture-file");

    for(size_t i = 1; i < parser.rest().size(); i++)
    {
      if(!cmdLine.empty())
        cmdLine += ' ';

      cmdLine += EscapeArgument(parser.rest()[i]);
    }

    std::cout << "Launching '" << executable << "'";

    if(!cmdLine.empty())
      std::cout << " with params: " << cmdLine;

    std::cout << std::endl;

    uint32_t ident = RENDERDOC_ExecuteAndInject(
        executable.c_str(), workingDir.empty() ? "" : workingDir.c_str(),
        cmdLine.empty() ? "" : cmdLine.c_str(), NULL, logFile.empty() ? "" : logFile.c_str(), &opts,
        parser.exist("wait-for-exit"));

    if(ident == 0)
    {
      std::cerr << "Failed to create & inject." << std::endl;
      return 2;
    }

    if(parser.exist("wait-for-exit"))
    {
      std::cerr << "'" << executable << "' finished executing." << std::endl;
      ident = 0;
    }
    else
    {
      std::cerr << "Launched as ID " << ident << std::endl;
    }

    return ident;
  }
Ejemplo n.º 2
0
  virtual int Execute(cmdline::parser &parser, const CaptureOptions &)
  {
    CaptureOptions cmdopts;
    readCapOpts(parser.get<string>("capopts").c_str(), &cmdopts);

    std::vector<std::string> rest = parser.rest();

    if(rest.size() % 3 != 0)
    {
      std::cerr << "Invalid generated cap32for64 command rest.size() == " << rest.size() << std::endl;
      return 0;
    }

    int numEnvs = int(rest.size() / 3);

    void *env = RENDERDOC_MakeEnvironmentModificationList(numEnvs);

    for(int i = 0; i < numEnvs; i++)
    {
      string typeString = rest[i * 3 + 0];

      EnvironmentModificationType type = eEnvMod_Set;
      EnvironmentSeparator sep = eEnvSep_None;

      if(typeString == "+env-replace")
      {
        type = eEnvMod_Set;
        sep = eEnvSep_None;
      }
      else if(typeString == "+env-append-platform")
      {
        type = eEnvMod_Append;
        sep = eEnvSep_Platform;
      }
      else if(typeString == "+env-append-semicolon")
      {
        type = eEnvMod_Append;
        sep = eEnvSep_SemiColon;
      }
      else if(typeString == "+env-append-colon")
      {
        type = eEnvMod_Append;
        sep = eEnvSep_Colon;
      }
      else if(typeString == "+env-append")
      {
        type = eEnvMod_Append;
        sep = eEnvSep_None;
      }
      else if(typeString == "+env-prepend-platform")
      {
        type = eEnvMod_Prepend;
        sep = eEnvSep_Platform;
      }
      else if(typeString == "+env-prepend-semicolon")
      {
        type = eEnvMod_Prepend;
        sep = eEnvSep_SemiColon;
      }
      else if(typeString == "+env-prepend-colon")
      {
        type = eEnvMod_Prepend;
        sep = eEnvSep_Colon;
      }
      else if(typeString == "+env-prepend")
      {
        type = eEnvMod_Prepend;
        sep = eEnvSep_None;
      }
      else
      {
        std::cerr << "Invalid generated cap32for64 env '" << rest[i * 3 + 0] << std::endl;
        RENDERDOC_FreeEnvironmentModificationList(env);
        return 0;
      }

      RENDERDOC_SetEnvironmentModification(env, i, rest[i * 3 + 1].c_str(), rest[i * 3 + 2].c_str(),
                                           type, sep);
    }

    int ret = RENDERDOC_InjectIntoProcess(parser.get<uint32_t>("pid"), env,
                                          parser.get<string>("log").c_str(), &cmdopts, false);

    RENDERDOC_FreeEnvironmentModificationList(env);

    return ret;
  }
Ejemplo n.º 3
0
  virtual int Execute(cmdline::parser &parser, const CaptureOptions &)
  {
    if(parser.rest().empty())
    {
      std::cerr << "Error: capture command requires a filename to load." << std::endl
                << std::endl
                << parser.usage();
      return 0;
    }

    string filename = parser.rest()[0];

    if(parser.exist("remote-host"))
    {
      std::cout << "Replaying '" << filename << "' on " << parser.get<string>("remote-host") << ":"
                << parser.get<uint32_t>("remote-port") << "." << std::endl;

      RemoteServer *remote = NULL;
      ReplayCreateStatus status = RENDERDOC_CreateRemoteServerConnection(
          parser.get<string>("remote-host").c_str(), parser.get<uint32_t>("remote-port"), &remote);

      if(remote == NULL || status != eReplayCreate_Success)
      {
        std::cerr << "Error: Couldn't connect to " << parser.get<string>("remote-host") << ":"
                  << parser.get<uint32_t>("remote-port") << "." << std::endl;
        std::cerr << "       Have you run renderdoccmd remoteserver on '"
                  << parser.get<string>("remote-host") << "'?" << std::endl;
        return 1;
      }

      std::cerr << "Copying capture file to remote server" << std::endl;

      float progress = 0.0f;
      rdctype::str remotePath = remote->CopyCaptureToRemote(filename.c_str(), &progress);

      ReplayRenderer *renderer = NULL;
      status = remote->OpenCapture(~0U, remotePath.elems, &progress, &renderer);

      if(status == eReplayCreate_Success)
      {
        DisplayRendererPreview(renderer, parser.get<uint32_t>("width"),
                               parser.get<uint32_t>("height"));

        remote->CloseCapture(renderer);
      }
      else
      {
        std::cerr << "Couldn't load and replay '" << filename << "'." << std::endl;
      }

      remote->ShutdownConnection();
    }
    else
    {
      std::cout << "Replaying '" << filename << "' locally.." << std::endl;

      float progress = 0.0f;
      ReplayRenderer *renderer = NULL;
      ReplayCreateStatus status =
          RENDERDOC_CreateReplayRenderer(filename.c_str(), &progress, &renderer);

      if(status == eReplayCreate_Success)
      {
        DisplayRendererPreview(renderer, parser.get<uint32_t>("width"),
                               parser.get<uint32_t>("height"));

        renderer->Shutdown();
      }
      else
      {
        std::cerr << "Couldn't load and replay '" << filename << "'." << std::endl;
      }
    }
    return 0;
  }
Ejemplo n.º 4
0
  virtual int Execute(cmdline::parser &parser, const CaptureOptions &)
  {
    if(parser.rest().empty())
    {
      std::cerr << "Error: thumb command requires a capture filename." << std::endl
                << std::endl
                << parser.usage();
      return 0;
    }

    string filename = parser.rest()[0];

    string outfile = parser.get<string>("out");

    string format = parser.get<string>("format");

    FileType type = eFileType_JPG;

    if(format == "png")
    {
      type = eFileType_PNG;
    }
    else if(format == "tga")
    {
      type = eFileType_TGA;
    }
    else if(format == "bmp")
    {
      type = eFileType_BMP;
    }
    else
    {
      const char *dot = strrchr(outfile.c_str(), '.');

      if(dot != NULL && strstr(dot, "png"))
        type = eFileType_PNG;
      else if(dot != NULL && strstr(dot, "tga"))
        type = eFileType_TGA;
      else if(dot != NULL && strstr(dot, "bmp"))
        type = eFileType_BMP;
      else
        std::cerr << "Couldn't guess format from '" << outfile << "', defaulting to jpg."
                  << std::endl;
    }

    rdctype::array<byte> buf;
    bool32 ret =
        RENDERDOC_GetThumbnail(filename.c_str(), type, parser.get<uint32_t>("max-size"), &buf);

    if(!ret)
    {
      std::cerr << "Couldn't fetch the thumbnail in '" << filename << "'" << std::endl;
    }
    else
    {
      FILE *f = fopen(outfile.c_str(), "wb");

      if(!f)
      {
        std::cerr << "Couldn't open destination file '" << outfile << "'" << std::endl;
      }
      else
      {
        fwrite(buf.elems, 1, buf.count, f);
        fclose(f);

        std::cout << "Wrote thumbnail from '" << filename << "' to '" << outfile << "'." << std::endl;
      }
    }

    return 0;
  }