Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,14 @@ static void AddConst( std::string& str, const std::string& name, float v1, float

static std::string GenVersionDeclaration( const std::vector<addedExtension_t> &addedExtensions ) {
// Declare version.
std::string str = Str::Format( "#version %d %s\n\n",
std::string str = Str::Format( "#version %d %s\n",
glConfig.shadingLanguageVersion,
glConfig.shadingLanguageVersion >= 150 ? ( glConfig.glCoreProfile ? "core" : "compatibility" ) : "" );

str += "#line 1000000000\n";

str += "\n";

// Add supported GLSL extensions.
for ( const auto& addedExtension : addedExtensions ) {
addExtension( str, addedExtension.available, addedExtension.minGlslVersion, addedExtension.name );
Expand Down Expand Up @@ -838,7 +842,10 @@ std::string GLShaderManager::GetDeformShaderName( const int index ) {
std::string GLShaderManager::BuildDeformShaderText( const std::string& steps ) {
std::string shaderText;

shaderText = steps + "\n";
shaderText = "\n" + steps + "\n";

shaderText += "#line 2000000000\n";

shaderText += GetShaderText( "deformVertexes_vp.glsl" );

return shaderText;
Expand Down Expand Up @@ -1194,6 +1201,13 @@ std::string GLShaderManager::ProcessInserts( const std::string& shaderText ) con

while ( std::getline( shaderTextStream, line, '\n' ) ) {
++lineCount;

/* The deform vertex header is prepended to the mainText and is part
of the shaderText, so we should reset line numbering after it. */
if ( line == "#line 0" ) {
lineCount = 0;
}

const std::string::size_type position = line.find( "#insert" );
if ( position == std::string::npos || line.find_first_not_of( " \t" ) != position ) {
out += line + "\n";
Expand Down Expand Up @@ -1324,7 +1338,9 @@ void GLShaderManager::InitShader( GLShader* shader ) {
if ( shaderType.enabled ) {
Com_sprintf( filename, sizeof( filename ), "%s%s.glsl", shaderType.path.c_str(), shaderType.postfix );

shaderType.mainText = GetShaderText( filename );
/* The deform vertex header is prepended to the mainText,
so we should reset line numbering after it. */
shaderType.mainText = "#line 0\n" + GetShaderText( filename );
}
}

Expand Down Expand Up @@ -3066,4 +3082,4 @@ GlobalUBOProxy::GlobalUBOProxy() :
u_Tonemap( this ),
u_TonemapParms( this ),
u_Exposure( this ) {
}
}
Loading