X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=gl_rmain.c;h=52e68fac0e005d4e141aaba5753fc74d4e565fca;hb=796d03386decaf9af1f674aaf25616686524cc4d;hp=9abaabf6f6c3427c9c7ae2c2407588c2ffdc0bdd;hpb=60e2412bbf8edeea07d1d5ea3d03e075c7044b48;p=xonotic%2Fdarkplaces.git diff --git a/gl_rmain.c b/gl_rmain.c index 9abaabf6..52e68fac 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -497,8 +497,8 @@ static void R_BuildFogTexture(void) } else { - r_texture_fogattenuation = R_LoadTexture2D(r_main_texturepool, "fogattenuation", FOGWIDTH, 1, &data1[0][0], TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_CLAMP | TEXF_PERSISTENT | TEXF_ALLOWUPDATES, -1, NULL); - //r_texture_fogintensity = R_LoadTexture2D(r_main_texturepool, "fogintensity", FOGWIDTH, 1, &data2[0][0], TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_CLAMP | TEXF_ALLOWUPDATES, NULL); + r_texture_fogattenuation = R_LoadTexture2D(r_main_texturepool, "fogattenuation", FOGWIDTH, 1, &data1[0][0], TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_CLAMP | TEXF_PERSISTENT, -1, NULL); + //r_texture_fogintensity = R_LoadTexture2D(r_main_texturepool, "fogintensity", FOGWIDTH, 1, &data2[0][0], TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_CLAMP, NULL); } } @@ -2071,8 +2071,8 @@ const char *builtincgshaderstring = "#ifdef USESATURATION\n" " //apply saturation BEFORE gamma ramps, so v_glslgamma value does not matter\n" " float y = dot(gl_FragColor.rgb, float3(0.299, 0.587, 0.114));\n" -" //gl_FragColor = float3(y) + (gl_FragColor.rgb - float3(y)) * Saturation;\n" -" gl_FragColor.rgb = lerp(float3(y), gl_FragColor.rgb, Saturation);\n" +" //gl_FragColor = float3(y,y,y) + (gl_FragColor.rgb - float3(y)) * Saturation;\n" +" gl_FragColor.rgb = lerp(float3(y,y,y), gl_FragColor.rgb, Saturation);\n" "#endif\n" "\n" "#ifdef USEGAMMARAMPS\n" @@ -2307,7 +2307,7 @@ const char *builtincgshaderstring = " //float4 ScreenTexCoord = (ModelViewProjectionPosition.xyxy + normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xyxy * DistortScaleRefractReflect * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;\n" " float4 SafeScreenTexCoord = ModelViewProjectionPosition.xyxy * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;\n" " //SafeScreenTexCoord = gl_FragCoord.xyxy * float4(1.0 / 1920.0, 1.0 / 1200.0, 1.0 / 1920.0, 1.0 / 1200.0);\n" -" float4 ScreenTexCoord = SafeScreenTexCoord + float2(normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5))).xyxy * DistortScaleRefractReflect;\n" +" float4 ScreenTexCoord = SafeScreenTexCoord + float2(normalize(tex2D(Texture_Normal, TexCoord).rgb - float3(0.5,0.5,0.5)).xy).xyxy * DistortScaleRefractReflect;\n" " // FIXME temporary hack to detect the case that the reflection\n" " // gets blackened at edges due to leaving the area that contains actual\n" " // content.\n" @@ -4700,10 +4700,8 @@ static char *R_HLSL_GetText(const char *filename, qboolean printfromdisknotice) } #include -#include -#ifdef _MSC_VER -#pragma comment(lib, "d3dx9.lib") -#endif +//#include +//#include static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, const char *vertstring, const char *fragstring) { @@ -4729,42 +4727,79 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c psbin = (DWORD *)FS_LoadFile(va("%s.psbin", cachename), r_main_mempool, true, &psbinsize); if ((!vsbin && vertstring) || (!psbin && fragstring)) { - vsbin = (DWORD *)Mem_Realloc(tempmempool, vsbin, 0); - psbin = (DWORD *)Mem_Realloc(tempmempool, psbin, 0); - if (vertstring && vertstring[0]) - { - vsresult = D3DXCompileShader(vertstring, strlen(vertstring), NULL, NULL, "main", vsversion, 0, &vsbuffer, &vslog, &vsconstanttable); - if (vsbuffer) + const char* dllnames_d3dx9 [] = + { + "d3dx9_43.dll", + "d3dx9_42.dll", + "d3dx9_41.dll", + "d3dx9_40.dll", + "d3dx9_39.dll", + "d3dx9_38.dll", + "d3dx9_37.dll", + "d3dx9_36.dll", + "d3dx9_35.dll", + "d3dx9_34.dll", + "d3dx9_33.dll", + "d3dx9_32.dll", + "d3dx9_31.dll", + "d3dx9_30.dll", + "d3dx9_29.dll", + "d3dx9_28.dll", + "d3dx9_27.dll", + "d3dx9_26.dll", + "d3dx9_25.dll", + "d3dx9_24.dll", + NULL + }; + dllhandle_t d3dx9_dll = NULL; + 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[] = + { + {"D3DXCompileShader", (void **) &qD3DXCompileShader}, + {NULL, NULL} + }; + if (Sys_LoadLibrary(dllnames_d3dx9, &d3dx9_dll, d3dx9_dllfuncs)) + { + vsbin = (DWORD *)Mem_Realloc(tempmempool, vsbin, 0); + psbin = (DWORD *)Mem_Realloc(tempmempool, psbin, 0); + if (vertstring && vertstring[0]) { - vsbinsize = vsbuffer->GetBufferSize(); - vsbin = (DWORD *)Mem_Alloc(tempmempool, vsbinsize); - memcpy(vsbin, vsbuffer->GetBufferPointer(), vsbinsize); - vsbuffer->Release(); - } - if (vslog) - { - strlcpy(temp, (const char *)vslog->GetBufferPointer(), min(sizeof(temp), vslog->GetBufferSize())); - Con_Printf("HLSL vertex shader compile output for %s follows:\n%s\n", cachename, temp); - vslog->Release(); - } - } - if (fragstring && fragstring[0]) - { - psresult = D3DXCompileShader(fragstring, strlen(fragstring), NULL, NULL, "main", psversion, 0, &psbuffer, &pslog, &psconstanttable); - if (psbuffer) - { - psbinsize = psbuffer->GetBufferSize(); - psbin = (DWORD *)Mem_Alloc(tempmempool, psbinsize); - memcpy(psbin, psbuffer->GetBufferPointer(), psbinsize); - psbuffer->Release(); + vsresult = qD3DXCompileShader(vertstring, strlen(vertstring), NULL, NULL, "main", vsversion, 0, &vsbuffer, &vslog, &vsconstanttable); + if (vsbuffer) + { + vsbinsize = vsbuffer->GetBufferSize(); + vsbin = (DWORD *)Mem_Alloc(tempmempool, vsbinsize); + memcpy(vsbin, vsbuffer->GetBufferPointer(), vsbinsize); + vsbuffer->Release(); + } + if (vslog) + { + strlcpy(temp, (const char *)vslog->GetBufferPointer(), min(sizeof(temp), vslog->GetBufferSize())); + Con_Printf("HLSL vertex shader compile output for %s follows:\n%s\n", cachename, temp); + vslog->Release(); + } } - if (pslog) + if (fragstring && fragstring[0]) { - strlcpy(temp, (const char *)pslog->GetBufferPointer(), min(sizeof(temp), pslog->GetBufferSize())); - Con_Printf("HLSL pixel shader compile output for %s follows:\n%s\n", cachename, temp); - pslog->Release(); + psresult = qD3DXCompileShader(fragstring, strlen(fragstring), NULL, NULL, "main", psversion, 0, &psbuffer, &pslog, &psconstanttable); + if (psbuffer) + { + psbinsize = psbuffer->GetBufferSize(); + psbin = (DWORD *)Mem_Alloc(tempmempool, psbinsize); + memcpy(psbin, psbuffer->GetBufferPointer(), psbinsize); + psbuffer->Release(); + } + if (pslog) + { + strlcpy(temp, (const char *)pslog->GetBufferPointer(), min(sizeof(temp), pslog->GetBufferSize())); + Con_Printf("HLSL pixel shader compile output for %s follows:\n%s\n", cachename, temp); + pslog->Release(); + } } + Sys_UnloadLibrary(&d3dx9_dll); } + else + Con_Printf("Unable to compile shader - D3DXCompileShader function not found\n"); } if (vsbin) { @@ -5869,7 +5904,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, R_Mesh_TexCoordPointer(0, 2, GL_FLOAT, sizeof(float[2]), rsurface.batchtexcoordtexture2f, rsurface.batchtexcoordtexture2f_vertexbuffer, rsurface.batchtexcoordtexture2f_bufferoffset); R_Mesh_TexCoordPointer(1, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchsvector3f, rsurface.batchsvector3f_vertexbuffer, rsurface.batchsvector3f_bufferoffset); R_Mesh_TexCoordPointer(2, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchtvector3f, rsurface.batchtvector3f_vertexbuffer, rsurface.batchtvector3f_bufferoffset); - R_Mesh_TexCoordPointer(3, 4, GL_FLOAT, sizeof(float[3]), rsurface.batchnormal3f, rsurface.batchnormal3f_vertexbuffer, rsurface.batchnormal3f_bufferoffset); + R_Mesh_TexCoordPointer(3, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchnormal3f, rsurface.batchnormal3f_vertexbuffer, rsurface.batchnormal3f_bufferoffset); R_Mesh_TexCoordPointer(4, 2, GL_FLOAT, sizeof(float[2]), rsurface.batchtexcoordlightmap2f, rsurface.batchtexcoordlightmap2f_vertexbuffer, rsurface.batchtexcoordlightmap2f_bufferoffset); } else @@ -6023,7 +6058,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, R_Mesh_TexCoordPointer(0, 2, GL_FLOAT, sizeof(float[2]), rsurface.batchtexcoordtexture2f, rsurface.batchtexcoordtexture2f_vertexbuffer, rsurface.batchtexcoordtexture2f_bufferoffset); R_Mesh_TexCoordPointer(1, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchsvector3f, rsurface.batchsvector3f_vertexbuffer, rsurface.batchsvector3f_bufferoffset); R_Mesh_TexCoordPointer(2, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchtvector3f, rsurface.batchtvector3f_vertexbuffer, rsurface.batchtvector3f_bufferoffset); - R_Mesh_TexCoordPointer(3, 4, GL_FLOAT, sizeof(float[3]), rsurface.batchnormal3f, rsurface.batchnormal3f_vertexbuffer, rsurface.batchnormal3f_bufferoffset); + R_Mesh_TexCoordPointer(3, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchnormal3f, rsurface.batchnormal3f_vertexbuffer, rsurface.batchnormal3f_bufferoffset); R_Mesh_TexCoordPointer(4, 2, GL_FLOAT, sizeof(float[2]), rsurface.batchtexcoordlightmap2f, rsurface.batchtexcoordlightmap2f_vertexbuffer, rsurface.batchtexcoordlightmap2f_bufferoffset); } else @@ -6968,7 +7003,7 @@ skinframe_t *R_SkinFrame_LoadMissing(void) //static char *suffix[6] = {"ft", "bk", "rt", "lf", "up", "dn"}; typedef struct suffixinfo_s { - char *suffix; + const char *suffix; qboolean flipx, flipy, flipdiagonal; } suffixinfo_t; @@ -9439,7 +9474,7 @@ void R_UpdateVariables(void) } else { - r_texture_gammaramps = R_LoadTexture2D(r_main_texturepool, "gammaramps", RAMPWIDTH, 1, &rampbgr[0][0], TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_CLAMP | TEXF_PERSISTENT | TEXF_ALLOWUPDATES, -1, NULL); + r_texture_gammaramps = R_LoadTexture2D(r_main_texturepool, "gammaramps", RAMPWIDTH, 1, &rampbgr[0][0], TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_CLAMP | TEXF_PERSISTENT, -1, NULL); } } } @@ -11368,7 +11403,7 @@ void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const // when the model data has no vertex buffer (dynamic mesh), we need to // eliminate gaps - if (!rsurface.modelvertexmeshbuffer || (!gl_vbo.integer && !vid.forcevbo)) + if (!rsurface.modelvertexmeshbuffer) batchneed |= BATCHNEED_NOGAPS; // if needsupdate, we have to do a dynamic vertex batch for sure