]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
UNMERGE
authorhavoc havoc@d7cf8633-e32d-0410-b094-e92efae38249 <>
Fri, 17 Sep 2010 09:16:30 +0000 (09:16 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 24 Sep 2010 20:00:09 +0000 (22:00 +0200)
enable Tomaz's PIX-friendly shader debugging code if gl_paranoid is 1
made CHECKGLERROR not crash if qglGetError is NULL (as in D3D9 renderer for example)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10468 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::unmerge=5f5982cec6cf87e5a9d729ba73ec387b03d1f58a

gl_rmain.c
glquake.h

index ff26de8f3a5964bb229871f99f23f96af7b0c9ab..885453db2243262f6f5af269a82ac024635b604e 100644 (file)
@@ -4474,15 +4474,11 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c
        int psresult = 0;
        char temp[MAX_INPUTLINE];
        const char *vsversion = "vs_3_0", *psversion = "ps_3_0";
-       qboolean debugshader = gl_paranoid.integer != 0;
        if (p->permutation & SHADERPERMUTATION_OFFSETMAPPING) {vsversion = "vs_3_0";psversion = "ps_3_0";}
        if (p->permutation & SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING) {vsversion = "vs_3_0";psversion = "ps_3_0";}
-       if (!debugshader)
-       {
-               vsbin = (DWORD *)FS_LoadFile(va("%s.vsbin", cachename), r_main_mempool, true, &vsbinsize);
-               psbin = (DWORD *)FS_LoadFile(va("%s.psbin", cachename), r_main_mempool, true, &psbinsize);
-       }
-       if (debugshader || (!vsbin && vertstring) || (!psbin && fragstring))
+       vsbin = (DWORD *)FS_LoadFile(va("%s.vsbin", cachename), r_main_mempool, true, &vsbinsize);
+       psbin = (DWORD *)FS_LoadFile(va("%s.psbin", cachename), r_main_mempool, true, &psbinsize);
+       if ((!vsbin && vertstring) || (!psbin && fragstring))
        {
                const char* dllnames_d3dx9 [] =
                {
@@ -4509,30 +4505,25 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c
                        NULL
                };
                dllhandle_t d3dx9_dll = NULL;
-               HRESULT (WINAPI *qD3DXCompileShaderFromFileA)(LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable);
                HRESULT (WINAPI *qD3DXCompileShader)(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable);
+//             HRESULT (WINAPI *qD3DXCompileShaderFromFileA)(LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable);
                dllfunction_t d3dx9_dllfuncs[] =
                {
-                       {"D3DXCompileShaderFromFileA",  (void **) &qD3DXCompileShaderFromFileA},
                        {"D3DXCompileShader",                   (void **) &qD3DXCompileShader},
+//                     {"D3DXCompileShaderFromFileA",  (void **) &qD3DXCompileShaderFromFileA},
                        {NULL, NULL}
                };
                if (Sys_LoadLibrary(dllnames_d3dx9, &d3dx9_dll, d3dx9_dllfuncs))
                {
                        DWORD shaderflags = 0;
-                       if (debugshader)
-                               shaderflags = D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION;
+//                     shaderflags = D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION;
                        vsbin = (DWORD *)Mem_Realloc(tempmempool, vsbin, 0);
                        psbin = (DWORD *)Mem_Realloc(tempmempool, psbin, 0);
                        if (vertstring && vertstring[0])
                        {
-                               if (debugshader)
-                               {
-                                       FS_WriteFile(va("%s_vs.fx", cachename), vertstring, strlen(vertstring));
-                                       vsresult = qD3DXCompileShaderFromFileA(va("%s/%s_vs.fx", fs_gamedir, cachename), NULL, NULL, "main", vsversion, shaderflags, &vsbuffer, &vslog, &vsconstanttable);
-                               }
-                               else
-                                       vsresult = qD3DXCompileShader(vertstring, strlen(vertstring), NULL, NULL, "main", vsversion, shaderflags, &vsbuffer, &vslog, &vsconstanttable);
+//                             FS_WriteFile(va("%s_vs.fx", cachename), vertstring, strlen(vertstring));
+//                             vsresult = qD3DXCompileShaderFromFileA(va("%s/%s_vs.fx", fs_gamedir, cachename), NULL, NULL, "main", vsversion, shaderflags, &vsbuffer, &vslog, &vsconstanttable);
+                               vsresult = qD3DXCompileShader(vertstring, strlen(vertstring), NULL, NULL, "main", vsversion, shaderflags, &vsbuffer, &vslog, &vsconstanttable);
                                if (vsbuffer)
                                {
                                        vsbinsize = vsbuffer->GetBufferSize();
@@ -4549,13 +4540,9 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c
                        }
                        if (fragstring && fragstring[0])
                        {
-                               if (debugshader)
-                               {
-                                       FS_WriteFile(va("%s_ps.fx", cachename), fragstring, strlen(fragstring));
-                                       psresult = qD3DXCompileShaderFromFileA(va("%s/%s_ps.fx", fs_gamedir, cachename), NULL, NULL, "main", psversion, shaderflags, &psbuffer, &pslog, &psconstanttable);
-                               }
-                               else
-                                       psresult = qD3DXCompileShader(fragstring, strlen(fragstring), NULL, NULL, "main", psversion, shaderflags, &psbuffer, &pslog, &psconstanttable);
+//                             FS_WriteFile(va("%s_ps.fx", cachename), fragstring, strlen(fragstring));
+//                             psresult = qD3DXCompileShaderFromFileA(va("%s/%s_ps.fx", fs_gamedir, cachename), NULL, NULL, "main", psversion, shaderflags, &psbuffer, &pslog, &psconstanttable);
+                               psresult = qD3DXCompileShader(fragstring, strlen(fragstring), NULL, NULL, "main", psversion, shaderflags, &psbuffer, &pslog, &psconstanttable);
                                if (psbuffer)
                                {
                                        psbinsize = psbuffer->GetBufferSize();
index bb9220f4cdf9d337adf4936926d6a5816ca083e6..460650239da5f5ad20efaf988b8b07230c6af76b 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -953,7 +953,7 @@ extern void (GLAPIENTRY *qglGetQueryObjectuivARB)(GLuint qid, GLenum pname, GLui
 #define DEBUGGL
 
 #ifdef DEBUGGL
-#define CHECKGLERROR {if (gl_paranoid.integer){if (gl_printcheckerror.integer) Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);errornumber = qglGetError ? qglGetError() : 0;if (errornumber) GL_PrintError(errornumber, __FILE__, __LINE__);}}
+#define CHECKGLERROR {if (gl_paranoid.integer){if (gl_printcheckerror.integer) Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);errornumber = qglGetError();if (errornumber) GL_PrintError(errornumber, __FILE__, __LINE__);}}
 extern int errornumber;
 void GL_PrintError(int errornumber, const char *filename, int linenumber);
 #else