DXGL r471 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r470‎ | r471 | r472 >
Date:01:09, 28 July 2014
Author:admin
Status:new
Tags:
Comment:
Add generated shaders to trace log, as well as any error messages.
Modified paths:
  • /ddraw/ShaderGen2D.cpp (modified) (history)
  • /ddraw/ShaderGen3D.cpp (modified) (history)
  • /ddraw/trace.c (modified) (history)
  • /ddraw/trace.h (modified) (history)

Diff [purge]

Index: ddraw/ShaderGen2D.cpp
@@ -837,6 +837,9 @@
838838 OutputDebugStringA("2D blitter vertex shader:\n");
839839 OutputDebugStringA(vsrc->ptr);
840840 OutputDebugStringA("\nCompiling 2D blitter vertex shader:\n");
 841+ TRACE_STRING("2D blitter vertex shader:\n");
 842+ TRACE_STRING(vsrc->ptr);
 843+ TRACE_STRING("\nCompiling 2D blitter vertex shader:\n");
841844 #endif
842845 gen->genshaders2D[index].shader.vs = gen->ext->glCreateShader(GL_VERTEX_SHADER);
843846 GLint srclen = strlen(vsrc->ptr);
@@ -854,6 +857,8 @@
855858 gen->ext->glGetShaderInfoLog(gen->genshaders2D[index].shader.vs, loglen, &result, infolog);
856859 OutputDebugStringA("Compilation failed. Error messages:\n");
857860 OutputDebugStringA(infolog);
 861+ TRACE_STRING("Compilation failed. Error messages:\n");
 862+ TRACE_STRING(infolog);
858863 free(infolog);
859864 }
860865 #endif
@@ -926,6 +931,9 @@
927932 OutputDebugStringA("2D blitter fragment shader:\n");
928933 OutputDebugStringA(fsrc->ptr);
929934 OutputDebugStringA("\nCompiling 2D blitter fragment shader:\n");
 935+ TRACE_STRING("2D blitter fragment shader:\n");
 936+ TRACE_STRING(fsrc->ptr);
 937+ TRACE_STRING("\nCompiling 2D blitter fragment shader:\n");
930938 #endif
931939 gen->genshaders2D[index].shader.fs = gen->ext->glCreateShader(GL_FRAGMENT_SHADER);
932940 srclen = strlen(fsrc->ptr);
@@ -940,6 +948,8 @@
941949 gen->ext->glGetShaderInfoLog(gen->genshaders2D[index].shader.fs, loglen, &result, infolog);
942950 OutputDebugStringA("Compilation failed. Error messages:\n");
943951 OutputDebugStringA(infolog);
 952+ TRACE_STRING("Compilation failed. Error messages:\n");
 953+ TRACE_STRING(infolog);
944954 free(infolog);
945955 }
946956 #endif
@@ -956,6 +966,8 @@
957967 gen->ext->glGetProgramInfoLog(gen->genshaders2D[index].shader.prog, loglen, &result, infolog);
958968 OutputDebugStringA("Program link failed. Error messages:\n");
959969 OutputDebugStringA(infolog);
 970+ TRACE_STRING("Program link failed. Error messages:\n");
 971+ TRACE_STRING(infolog);
960972 free(infolog);
961973 }
962974 #endif
Index: ddraw/ShaderGen3D.cpp
@@ -695,6 +695,9 @@
696696 OutputDebugStringA("Vertex shader:\n");
697697 OutputDebugStringA(vsrc->ptr);
698698 OutputDebugStringA("\nCompiling vertex shader:\n");
 699+ TRACE_STRING("Vertex shader:\n");
 700+ TRACE_STRING(vsrc->ptr);
 701+ TRACE_STRING("\nCompiling vertex shader:\n");
699702 #endif
700703 genshaders[index].shader.vs = ext->glCreateShader(GL_VERTEX_SHADER);
701704 const char *src = vsrc->ptr;
@@ -713,6 +716,8 @@
714717 ext->glGetShaderInfoLog(genshaders[index].shader.vs,loglen,&result,infolog);
715718 OutputDebugStringA("Compilation failed. Error messages:\n");
716719 OutputDebugStringA(infolog);
 720+ TRACE_STRING("Compilation failed. Error messages:\n");
 721+ TRACE_STRING(infolog);
717722 free(infolog);
718723 }
719724 #endif
@@ -1204,6 +1209,9 @@
12051210 OutputDebugStringA("Fragment shader:\n");
12061211 OutputDebugStringA(fsrc->ptr);
12071212 OutputDebugStringA("\nCompiling fragment shader:\n");
 1213+ TRACE_STRING("Fragment shader:\n");
 1214+ TRACE_STRING(fsrc->ptr);
 1215+ TRACE_STRING("\nCompiling fragment shader:\n");
12081216 #endif
12091217 genshaders[index].shader.fs = ext->glCreateShader(GL_FRAGMENT_SHADER);
12101218 src = fsrc->ptr;
@@ -1219,6 +1227,8 @@
12201228 ext->glGetShaderInfoLog(genshaders[index].shader.fs,loglen,&result,infolog);
12211229 OutputDebugStringA("Compilation failed. Error messages:\n");
12221230 OutputDebugStringA(infolog);
 1231+ TRACE_STRING("Compilation failed. Error messages:\n");
 1232+ TRACE_STRING(infolog);
12231233 free(infolog);
12241234 }
12251235 OutputDebugStringA("\nLinking program:\n");
@@ -1236,6 +1246,8 @@
12371247 ext->glGetProgramInfoLog(genshaders[index].shader.prog,loglen,&result,infolog);
12381248 OutputDebugStringA("Program link failed. Error messages:\n");
12391249 OutputDebugStringA(infolog);
 1250+ TRACE_STRING("Program link failed. Error messages:\n");
 1251+ TRACE_STRING(infolog);
12401252 free(infolog);
12411253 }
12421254 #endif
Index: ddraw/trace.c
@@ -1135,6 +1135,25 @@
11361136 LeaveCriticalSection(&trace_cs);
11371137 }
11381138
 1139+void trace_string(const char *str)
 1140+{
 1141+ DWORD byteswritten;
 1142+ unsigned int i;
 1143+ if (trace_fail) return;
 1144+ if (!trace_ready) init_trace();
 1145+ EnterCriticalSection(&trace_cs);
 1146+ if (trace_end)
 1147+ {
 1148+ end_trace();
 1149+ LeaveCriticalSection(&trace_cs);
 1150+ return;
 1151+ }
 1152+ for (i = 0; i < trace_depth - 1; i++)
 1153+ WriteFile(outfile, " ", 4, &byteswritten, NULL);
 1154+ WriteFile(outfile, str, strlen(str), &byteswritten, NULL);
 1155+ LeaveCriticalSection(&trace_cs);
 1156+}
 1157+
11391158 void trace_sysinfo()
11401159 {
11411160 DWORD byteswritten;
Index: ddraw/trace.h
@@ -29,11 +29,13 @@
3030 #define TRACE_ENTER(paramcount,...) trace_enter(__FUNCTION__,paramcount,__VA_ARGS__)
3131 #define TRACE_EXIT(argtype,arg) trace_exit(__FUNCTION__,argtype,(void*)arg)
3232 #define TRACE_VAR(var,argtype,arg) trace_var(__FUNCTION__,var,argtype,(void*)arg)
 33+#define TRACE_STRING(str) trace_string(str)
3334 #define TRACE_SYSINFO() trace_sysinfo() // Must be in thread used by OpenGL.
3435 void trace_enter(const char *function, int paramcount, ...);
3536 void trace_exit(const char *function, int argtype, void *arg);
3637 void *trace_ret(const char *function, int argtype, void *arg);
3738 void trace_var(const char *function, const char *var, int argtype, void *arg);
 39+void trace_string(const char *str);
3840 void trace_sysinfo();
3941 #define TRACE_RET(type, argtype, arg) return (type)trace_ret(__FUNCTION__,argtype,(void*)arg);
4042 #else
@@ -41,6 +43,7 @@
4244 #define TRACE_EXIT(a,b)
4345 #define TRACE_VAR(a,b,c)
4446 #define TRACE_RET(type, argtype, arg) return arg;
 47+#define TRACE_STRING(str)
4548 #define TRACE_SYSINFO()
4649 #endif
4750