Merge pull request #206 from olvaffe/linux-fixes

misc Linux fixes
This commit is contained in:
Baldur Karlsson
2016-03-08 07:48:40 +01:00
3 changed files with 19 additions and 6 deletions
+4 -1
View File
@@ -773,9 +773,12 @@ void RenderDoc::SetCaptureOptions(const CaptureOptions &opts)
void RenderDoc::SetLogFile(const char *logFile)
{
if (logFile == NULL || logFile[0] == '\0')
return;
m_LogFile = logFile;
if(m_LogFile.substr(m_LogFile.length()-4) == ".rdc")
if(m_LogFile.length() > 4 && m_LogFile.substr(m_LogFile.length()-4) == ".rdc")
m_LogFile = m_LogFile.substr(0, m_LogFile.length()-4);
FileIO::CreateParentDirectory(m_LogFile);
+7 -1
View File
@@ -50,6 +50,7 @@ typedef void (*PFNGLXSWAPBUFFERSPROC)(Display *dpy, GLXDrawable drawable);
typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display *dpy, GLXFBConfig config);
typedef int (*PFNGLXGETCONFIGPROC)(Display *dpy, XVisualInfo *vis, int attrib, int * value);
typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display *dpy, int *errorBase, int *eventBase);
typedef Bool (*PFNGLXISDIRECTPROC)(Display *dpy, GLXContext ctx);
void *libGLdlsymHandle = RTLD_NEXT; // default to RTLD_NEXT, but overwritten if app calls dlopen() on real libGL
@@ -336,9 +337,14 @@ class OpenGLHook : LibraryHook
GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
0, 0,
};
bool is_direct = false;
PFNGLXISDIRECTPROC glXIsDirectProc = (PFNGLXISDIRECTPROC)dlsym(RTLD_NEXT, "glXIsDirect");
PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfigProc = (PFNGLXCHOOSEFBCONFIGPROC)dlsym(RTLD_NEXT, "glXChooseFBConfig");
if (glXIsDirectProc)
is_direct = glXIsDirectProc(share.dpy, share.ctx);
if(glXChooseFBConfigProc)
{
// don't need to care about the fb config as we won't be using the default framebuffer (backbuffer)
@@ -349,7 +355,7 @@ class OpenGLHook : LibraryHook
if(fbcfg)
{
ret.dpy = share.dpy;
ret.ctx = glXCreateContextAttribsARB_real(share.dpy, fbcfg[0], share.ctx, false, attribs);
ret.ctx = glXCreateContextAttribsARB_real(share.dpy, fbcfg[0], share.ctx, is_direct, attribs);
}
}
}
+8 -4
View File
@@ -83,8 +83,8 @@ static pid_t RunProcess(const char *app, const char *workingDir, const char *cmd
{
if(!app) return (pid_t)0;
int argc = 0;
char *emptyargv[] = { NULL };
// it is safe to use app directly as execve never modifies argv
char *emptyargv[] = { (char *) app, NULL };
char **argv = emptyargv;
const char *c = cmdLine;
@@ -92,7 +92,7 @@ static pid_t RunProcess(const char *app, const char *workingDir, const char *cmd
// parse command line into argv[], similar to how bash would
if(cmdLine)
{
argc = 1;
int argc = 1;
// get a rough upper bound on the number of arguments
while(*c)
@@ -212,6 +212,7 @@ static pid_t RunProcess(const char *app, const char *workingDir, const char *cmd
}
execve(app, argv, envp);
RDCERR("Failed to execute %s: %s", app, strerror(errno));
exit(0);
}
@@ -261,6 +262,9 @@ uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workin
map<string, string> env = EnvStringToEnvMap((const char **)environ);
vector<EnvironmentModification> &modifications = GetEnvModifications();
if (logfile == NULL)
logfile = "";
string libpath;
{
FileIO::GetExecutableFilename(libpath);
@@ -287,7 +291,7 @@ uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workin
{
EnvironmentModification &m = modifications[i];
string value = env[m.name];
string &value = env[m.name];
switch(m.type)
{