]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
More debug code for shaders, this time it preprocesses the shader before saving it...
authortomaz <tomaz@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 17 Sep 2010 22:47:20 +0000 (22:47 +0000)
committertomaz <tomaz@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 17 Sep 2010 22:47:20 +0000 (22:47 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10472 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index 9f8ab2401d274003ed2d2d5a1a0f999274bc1c60..2ae699b36267a43b629cfdf707c8e541f619113c 100644 (file)
@@ -4500,7 +4500,7 @@ 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;
+       qboolean debugshader = 1;//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)
@@ -4536,10 +4536,12 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c
                };
                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 *qD3DXPreprocessShader)(LPCSTR pSrcData, UINT SrcDataSize, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPD3DXBUFFER* ppShaderText, LPD3DXBUFFER* ppErrorMsgs);
                HRESULT (WINAPI *qD3DXCompileShader)(LPCSTR pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs, LPD3DXCONSTANTTABLE* ppConstantTable);
                dllfunction_t d3dx9_dllfuncs[] =
                {
                        {"D3DXCompileShaderFromFileA",  (void **) &qD3DXCompileShaderFromFileA},
+                       {"D3DXPreprocessShader",                (void **) &qD3DXPreprocessShader},
                        {"D3DXCompileShader",                   (void **) &qD3DXCompileShader},
                        {NULL, NULL}
                };
@@ -4554,6 +4556,8 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c
                        {
                                if (debugshader)
                                {
+//                                     vsresult = qD3DXPreprocessShader(vertstring, strlen(vertstring), NULL, NULL, &vsbuffer, &vslog);
+//                                     FS_WriteFile(va("%s_vs.fx", cachename), vsbuffer->GetBufferPointer(), vsbuffer->GetBufferSize());
                                        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);
                                }
@@ -4577,6 +4581,8 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c
                        {
                                if (debugshader)
                                {
+//                                     psresult = qD3DXPreprocessShader(fragstring, strlen(fragstring), NULL, NULL, &psbuffer, &pslog);
+//                                     FS_WriteFile(va("%s_ps.fx", cachename), psbuffer->GetBufferPointer(), psbuffer->GetBufferSize());
                                        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);
                                }