DXGL r361 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r360‎ | r361 | r362 >
Date:22:15, 24 March 2013
Author:admin
Status:new
Tags:
Comment:
Add Windows version and OpenGL information to trace log.
Fix GetPalette regression in glDirectDrawSurface.cpp
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/trace.cpp (modified) (history)
  • /ddraw/trace.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -940,7 +940,6 @@
941941 {
942942 palette->AddRef();
943943 *lplpDDPalette = palette;
944 - TRACE_EXIT(23,DD_OK);
945944 err = DD_OK;
946945 }
947946 else
@@ -1007,7 +1006,7 @@
10081007 break;
10091008 case 1:
10101009 FIXME("glDirectDrawSurface7::Lock: surface type 1 not supported yet");
1011 - TRACE_EXIT(23,DDERR_GENERIC);
 1010+ TRACE_EXIT(23,DDERR_UNSUPPORTED);
10121011 ERR(DDERR_UNSUPPORTED);
10131012 break;
10141013 case 2:
Index: ddraw/glRenderer.cpp
@@ -816,6 +816,7 @@
817817 glBindBuffer(GL_PIXEL_PACK_BUFFER,PBO);
818818 glBufferData(GL_PIXEL_PACK_BUFFER,width*height*4,NULL,GL_STREAM_READ);
819819 glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
 820+ TRACE_SYSINFO();
820821 return TRUE;
821822 }
822823
Index: ddraw/trace.cpp
@@ -1070,7 +1070,7 @@
10711071 if(trace_fail) return;
10721072 if(!trace_ready) init_trace();
10731073 EnterCriticalSection(&trace_cs);
1074 - trace_depth--;
 1074+ if(trace_depth) trace_depth--;
10751075 DWORD byteswritten;
10761076 for(unsigned int i = 0; i < trace_depth; i++)
10771077 WriteFile(outfile," ",4,&byteswritten,NULL);
@@ -1096,4 +1096,76 @@
10971097 WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
10981098 LeaveCriticalSection(&trace_cs);
10991099 }
 1100+
 1101+void trace_sysinfo()
 1102+{
 1103+ if(trace_fail) return;
 1104+ if(!trace_ready) init_trace();
 1105+ EnterCriticalSection(&trace_cs);
 1106+ DWORD byteswritten;
 1107+ OSVERSIONINFOA osver;
 1108+ DWORD buildver;
 1109+ char osstring[256];
 1110+ osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
 1111+ GetVersionExA(&osver);
 1112+ if(osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) buildver = LOWORD(osver.dwBuildNumber);
 1113+ else buildver = osver.dwBuildNumber;
 1114+ if((osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) || (osver.dwPlatformId == VER_PLATFORM_WIN32s))
 1115+ sprintf(osstring,"Windows %u.%u.%u",osver.dwMajorVersion,osver.dwMinorVersion,buildver);
 1116+ else sprintf(osstring,"Windows NT %u.%u.%u",osver.dwMajorVersion,osver.dwMinorVersion,buildver);
 1117+ if(osver.szCSDVersion[0])
 1118+ {
 1119+ strcat(osstring,", ");
 1120+ strcat(osstring,osver.szCSDVersion);
 1121+ }
 1122+ if(((osver.dwMajorVersion == 5) && (osver.dwMinorVersion >= 1)) || (osver.dwMajorVersion >= 6))
 1123+ {
 1124+ strcat(osstring,", ");
 1125+ HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
 1126+ BOOL (WINAPI *iswow64)(HANDLE,PBOOL) = NULL;
 1127+ if(hKernel32) iswow64 = (BOOL(WINAPI*)(HANDLE,PBOOL))GetProcAddress(hKernel32,"IsWow64Process");
 1128+ BOOL is64 = FALSE;
 1129+ if(iswow64) iswow64(GetCurrentProcess(),&is64);
 1130+ if(hKernel32) FreeLibrary(hKernel32);
 1131+ if(is64) strcat(osstring,"64-bit");
 1132+ else strcat(osstring,"32-bit");
 1133+ }
 1134+ strcat(osstring,"\r\n");
 1135+ for(unsigned int i = 0; i < trace_depth-1; i++)
 1136+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1137+ WriteFile(outfile,"Windows version: ",18,&byteswritten,NULL);
 1138+ WriteFile(outfile,osstring,strlen(osstring),&byteswritten,NULL);
 1139+ for(unsigned int i = 0; i < trace_depth-1; i++)
 1140+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1141+ WriteFile(outfile,"GL_VENDOR: ",12,&byteswritten,NULL);
 1142+ const GLubyte *glstring;
 1143+ glstring = glGetString(GL_VENDOR);
 1144+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1145+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1146+ for(unsigned int i = 0; i < trace_depth-1; i++)
 1147+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1148+ WriteFile(outfile,"GL_RENDERER: ",14,&byteswritten,NULL);
 1149+ glstring = glGetString(GL_RENDERER);
 1150+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1151+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1152+ for(unsigned int i = 0; i < trace_depth-1; i++)
 1153+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1154+ WriteFile(outfile,"GL_VERSION: ",13,&byteswritten,NULL);
 1155+ glstring = glGetString(GL_VERSION);
 1156+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1157+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1158+ for(unsigned int i = 0; i < trace_depth-1; i++)
 1159+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1160+ WriteFile(outfile,"GL_SHADING_LANGUAGE_VERSION: ",30,&byteswritten,NULL);
 1161+ glstring = glGetString(GL_SHADING_LANGUAGE_VERSION);
 1162+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1163+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1164+ for(unsigned int i = 0; i < trace_depth-1; i++)
 1165+ WriteFile(outfile," ",4,&byteswritten,NULL);
 1166+ WriteFile(outfile,"GL_EXTENSIONS: ",16,&byteswritten,NULL);
 1167+ glstring = glGetString(GL_EXTENSIONS);
 1168+ if(glstring) WriteFile(outfile,glstring,strlen((const char*)glstring),&byteswritten,NULL);
 1169+ WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
 1170+ LeaveCriticalSection(&trace_cs);
 1171+}
11001172 #endif
\ No newline at end of file
Index: ddraw/trace.h
@@ -22,11 +22,13 @@
2323
2424 #ifdef _TRACE
2525 #define TRACE_ENTER(paramcount,...) trace_enter(__FUNCTION__,paramcount,__VA_ARGS__)
26 -#define TRACE_EXIT(argtype,arg) trace_exit(__FUNCTION__,argtype,(void*)arg);
27 -#define TRACE_VAR(var,argtype,arg) trace_var(__FUNCTION__,var,argtype,(void*)arg);
 26+#define TRACE_EXIT(argtype,arg) trace_exit(__FUNCTION__,argtype,(void*)arg)
 27+#define TRACE_VAR(var,argtype,arg) trace_var(__FUNCTION__,var,argtype,(void*)arg)
 28+#define TRACE_SYSINFO() trace_sysinfo() // Must be in thread used by OpenGL.
2829 void trace_enter(const char *function, int paramcount, ...);
2930 void trace_exit(const char *function, int argtype, void *arg);
3031 void trace_var(const char *function, const char *var, int argtype, void *arg);
 32+void trace_sysinfo();
3133 #define TRACE_RET(argtype, arg) \
3234 {\
3335 trace_exit(__FUNCTION__,argtype,(void*)arg);\
@@ -37,6 +39,7 @@
3840 #define TRACE_EXIT(a,b)
3941 #define TRACE_VAR(a,b,c)
4042 #define TRACE_RET(argtype, arg) return arg;
 43+#define TRACE_SYSINFO()
4144 #endif
4245
4346 #endif //_TRACE_H
\ No newline at end of file