@@ -490,10 +490,14 @@ static void AddConst( std::string& str, const std::string& name, float v1, float
490490
491491static std::string GenVersionDeclaration ( const std::vector<addedExtension_t> &addedExtensions ) {
492492 // Declare version.
493- std::string str = Str::Format ( " #version %d %s\n\n " ,
493+ std::string str = Str::Format ( " #version %d %s\n " ,
494494 glConfig.shadingLanguageVersion ,
495495 glConfig.shadingLanguageVersion >= 150 ? ( glConfig.glCoreProfile ? " core" : " compatibility" ) : " " );
496496
497+ str += " #line 1000000000\n " ;
498+
499+ str += " \n " ;
500+
497501 // Add supported GLSL extensions.
498502 for ( const auto & addedExtension : addedExtensions ) {
499503 addExtension ( str, addedExtension.available , addedExtension.minGlslVersion , addedExtension.name );
@@ -840,7 +844,10 @@ std::string GLShaderManager::GetDeformShaderName( const int index ) {
840844std::string GLShaderManager::BuildDeformShaderText ( const std::string& steps ) {
841845 std::string shaderText;
842846
843- shaderText = steps + " \n " ;
847+ shaderText = " \n " + steps + " \n " ;
848+
849+ shaderText += " #line 2000000000\n " ;
850+
844851 shaderText += GetShaderText ( " deformVertexes_vp.glsl" );
845852
846853 return shaderText;
@@ -1196,6 +1203,13 @@ std::string GLShaderManager::ProcessInserts( const std::string& shaderText ) con
11961203
11971204 while ( std::getline ( shaderTextStream, line, ' \n ' ) ) {
11981205 ++lineCount;
1206+
1207+ /* The deform vertex header is prepended to the mainText and is part
1208+ of the shaderText, so we should reset line numbering after it. */
1209+ if ( line == " #line 0" ) {
1210+ lineCount = 0 ;
1211+ }
1212+
11991213 const std::string::size_type position = line.find ( " #insert" );
12001214 if ( position == std::string::npos || line.find_first_not_of ( " \t " ) != position ) {
12011215 out += line + " \n " ;
@@ -1326,7 +1340,9 @@ void GLShaderManager::InitShader( GLShader* shader ) {
13261340 if ( shaderType.enabled ) {
13271341 Com_sprintf ( filename, sizeof ( filename ), " %s%s.glsl" , shaderType.path .c_str (), shaderType.postfix );
13281342
1329- shaderType.mainText = GetShaderText ( filename );
1343+ /* The deform vertex header is prepended to the mainText,
1344+ so we should reset line numbering after it. */
1345+ shaderType.mainText = " #line 0\n " + GetShaderText ( filename );
13301346 }
13311347 }
13321348
@@ -3068,4 +3084,4 @@ GlobalUBOProxy::GlobalUBOProxy() :
30683084 u_Tonemap( this ),
30693085 u_TonemapParms( this ),
30703086 u_Exposure( this ) {
3071- }
3087+ }
0 commit comments