Permalink
Browse files

Merge branch 'master' of github.com:Unvanquished/Unvanquished into co…

…nnectionless_packet
  • Loading branch information...
mbasaglia committed Mar 25, 2016
2 parents d691f77 + bfe5530 commit ed0d05bfd4aee78bbe4f8bcad9ac72a00554a984
Showing with 12,799 additions and 12,626 deletions.
  1. +44 −43 daemon/src/engine/renderer/gl_shader.cpp
  2. +17 −4 daemon/src/engine/renderer/gl_shader.h
  3. +11,393 −11,342 daemon/src/engine/renderer/shaders.cpp
  4. +25 −11 daemon/src/engine/renderer/tr_backend.cpp
  5. +10 −45 daemon/src/engine/renderer/tr_fbo.cpp
  6. +27 −112 daemon/src/engine/renderer/tr_image.cpp
  7. +15 −24 daemon/src/engine/renderer/tr_init.cpp
  8. +3 −0 daemon/src/engine/renderer/tr_light.cpp
  9. +7 −9 daemon/src/engine/renderer/tr_local.h
  10. +20 −4 daemon/src/engine/renderer/tr_shade.cpp
  11. +4 −4 daemon/src/engine/renderer/tr_types.h
  12. +17 −12 daemon/src/engine/renderer/tr_vbo.cpp
  13. +128 −155 daemon/src/engine/sys/sdl_glimp.cpp
  14. +1 −1 main/configs/buildables/eggpod.attr.cfg
  15. +2 −2 main/configs/buildables/eggpod.model.cfg
  16. +11 −5 main/glsl/blurX_fp.glsl
  17. +11 −5 main/glsl/blurY_fp.glsl
  18. +8 −5 main/glsl/cameraEffects_fp.glsl
  19. +8 −5 main/glsl/contrast_fp.glsl
  20. +9 −3 main/glsl/debugShadowMap_fp.glsl
  21. +8 −3 main/glsl/depthToColor_fp.glsl
  22. +3 −3 main/glsl/depthToColor_vp.glsl
  23. +9 −3 main/glsl/depthtile1_fp.glsl
  24. +10 −6 main/glsl/depthtile2_fp.glsl
  25. +7 −1 main/glsl/dispersion_C_fp.glsl
  26. +7 −4 main/glsl/fogGlobal_fp.glsl
  27. +8 −2 main/glsl/fogQuake3_fp.glsl
  28. +73 −68 main/glsl/forwardLighting_fp.glsl
  29. +580 −580 main/glsl/fxaa3_11_fp.glsl
  30. +7 −1 main/glsl/fxaa_fp.glsl
  31. +8 −2 main/glsl/generic_fp.glsl
  32. +7 −4 main/glsl/heatHaze_fp.glsl
  33. +8 −3 main/glsl/lightMapping_fp.glsl
  34. +13 −10 main/glsl/lightVolume_omni_fp.glsl
  35. +21 −10 main/glsl/lighttile_fp.glsl
  36. +10 −4 main/glsl/liquid_fp.glsl
  37. +7 −4 main/glsl/motionblur_fp.glsl
  38. +7 −4 main/glsl/portal_fp.glsl
  39. +10 −4 main/glsl/reflection_CB_fp.glsl
  40. +7 −1 main/glsl/refraction_C_fp.glsl
  41. +47 −15 main/glsl/reliefMapping_fp.glsl
  42. +7 −4 main/glsl/screen_fp.glsl
  43. +12 −6 main/glsl/shadowFill_fp.glsl
  44. +7 −1 main/glsl/skybox_fp.glsl
  45. +8 −2 main/glsl/ssao_fp.glsl
  46. +10 −7 main/glsl/vertexLighting_DBS_entity_fp.glsl
  47. +35 −14 main/glsl/vertexLighting_DBS_world_fp.glsl
  48. +12 −17 main/glsl/vertexLighting_DBS_world_vp.glsl
  49. +6 −4 main/glsl/volumetricFog_fp.glsl
  50. +2 −1 main/models/weapons/lcannon/weapon.cfg
  51. +2 −0 main/scripts/blaster.particle
  52. +5 −36 main/scripts/eggpod.shader
  53. +2 −0 main/scripts/firebomb.particle
  54. +2 −0 main/scripts/grenade.particle
  55. +4 −0 main/scripts/lcannon.particle
  56. +14 −0 main/scripts/lcannon.shader
  57. +2 −0 main/scripts/pulserifle.trail
  58. +4 −0 src/cgame/cg_local.h
  59. +37 −0 src/cgame/cg_trails.cpp
  60. +11 −11 src/sgame/sg_admin.cpp
@@ -255,18 +255,21 @@ void GLShaderManager::UpdateShaderProgramUniformLocations( GLShader *shader, sha
// create buffer for uniform firewall
shaderProgram->uniformFirewall = ( byte * ) ri.Z_Malloc( uniformSize );
// create buffer for storing uniform block indexes
shaderProgram->uniformBlockIndexes = ( GLuint * ) ri.Z_Malloc( sizeof( GLuint ) * numUniformBlocks );
// update uniforms
for (GLUniform *uniform : shader->_uniforms)
{
uniform->UpdateShaderProgramUniformLocation( shaderProgram );
}
// update uniform blocks
for (GLUniformBlock *uniformBlock : shader->_uniformBlocks)
{
uniformBlock->UpdateShaderProgramUniformBlockIndex( shaderProgram );
if( glConfig2.uniformBufferObjectAvailable ) {
// create buffer for storing uniform block indexes
shaderProgram->uniformBlockIndexes = ( GLuint * ) ri.Z_Malloc( sizeof( GLuint ) * numUniformBlocks );
// update uniform blocks
for (GLUniformBlock *uniformBlock : shader->_uniformBlocks)
{
uniformBlock->UpdateShaderProgramUniformBlockIndex( shaderProgram );
}
}
}
@@ -377,11 +380,11 @@ static std::string BuildDeformSteps( deformStage_t *deforms, int numDeforms )
return steps;
}
std::string GLShaderManager::BuildDeformShaderText( const std::string& steps ) const
std::string GLShaderManager::BuildDeformShaderText( const std::string& steps )
{
std::string shaderText;
shaderText = Str::Format( "#version %d\n", glConfig2.shadingLanguageVersion );
shaderText = GetVersionDeclaration();
shaderText += steps + "\n";
// We added a lot of stuff but if we do something bad
@@ -454,6 +457,12 @@ std::string GLShaderManager::BuildGPUShaderText( Str::StringRef mainShaderNa
if ( glConfig2.textureRGAvailable )
AddDefine( env, "TEXTURE_RG", 1 );
if ( glConfig2.uniformBufferObjectAvailable )
AddDefine( env, "UNIFORM_BUFFER_OBJECT", 1 );
if ( glConfig2.textureIntegerAvailable )
AddDefine( env, "TEXTURE_INTEGER", 1 );
AddDefine( env, "r_AmbientScale", r_ambientScale->value );
AddDefine( env, "r_SpecularScale", r_specularScale->value );
AddDefine( env, "r_NormalScale", r_normalScale->value );
@@ -469,16 +478,6 @@ std::string GLShaderManager::BuildGPUShaderText( Str::StringRef mainShaderNa
AddDefine( env, "r_FBufScale", fbufWidthScale, fbufHeightScale );
float npotWidthScale = 1;
float npotHeightScale = 1;
if ( !glConfig2.textureNPOTAvailable )
{
npotWidthScale = ( float ) glConfig.vidWidth / ( float ) NearestPowerOfTwo( glConfig.vidWidth );
npotHeightScale = ( float ) glConfig.vidHeight / ( float ) NearestPowerOfTwo( glConfig.vidHeight );
}
AddDefine( env, "r_NPOTScale", npotWidthScale, npotHeightScale );
AddDefine( env, "r_tileStep", glState.tileStep[ 0 ], glState.tileStep[ 1 ] );
if ( glConfig.driverType == glDriverType_t::GLDRV_MESA )
@@ -645,7 +644,6 @@ bool GLShaderManager::buildPermutation( GLShader *shader, int macroIndex, int de
shader->SetShaderProgramUniforms( shaderProgram );
GL_BindProgram( nullptr );
ValidateProgram( shaderProgram->program );
GL_CheckErrors();
endTime = ri.Milliseconds();
@@ -713,7 +711,7 @@ void GLShaderManager::InitShader( GLShader *shader )
bool GLShaderManager::LoadShaderBinary( GLShader *shader, size_t programNum )
{
#ifdef GLEW_ARB_get_program_binary
#ifdef GL_ARB_get_program_binary
GLint success;
const byte *binaryptr;
GLShaderHeader shaderHeader;
@@ -787,7 +785,7 @@ bool GLShaderManager::LoadShaderBinary( GLShader *shader, size_t programNum )
}
void GLShaderManager::SaveShaderBinary( GLShader *shader, size_t programNum )
{
#ifdef GLEW_ARB_get_program_binary
#ifdef GL_ARB_get_program_binary
GLint binaryLength;
GLuint binarySize = 0;
byte *binary;
@@ -842,7 +840,7 @@ void GLShaderManager::SaveShaderBinary( GLShader *shader, size_t programNum )
}
void GLShaderManager::CompileGPUShaders( GLShader *shader, shaderProgram_t *program,
const std::string &compileMacros ) const
const std::string &compileMacros )
{
// header of the glsl shader
std::string vertexHeader;
@@ -851,10 +849,10 @@ void GLShaderManager::CompileGPUShaders( GLShader *shader, shaderProgram_t *prog
if ( glConfig2.shadingLanguageVersion != 120 )
{
// HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones
// HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.50 ones
vertexHeader += "#version 130\n";
fragmentHeader += "#version 130\n";
vertexHeader = GetVersionDeclaration();
fragmentHeader = GetVersionDeclaration();
vertexHeader += "#define attribute in\n";
vertexHeader += "#define varying out\n";
@@ -864,10 +862,12 @@ void GLShaderManager::CompileGPUShaders( GLShader *shader, shaderProgram_t *prog
vertexHeader += "#define textureCube texture\n";
vertexHeader += "#define texture2D texture\n";
vertexHeader += "#define texture2DProj textureProj\n";
vertexHeader += "#define texture3D texture\n";
fragmentHeader += "#define textureCube texture\n";
fragmentHeader += "#define texture2D texture\n";
fragmentHeader += "#define texture2DProj textureProj\n";
fragmentHeader += "#define texture3D texture\n";
}
else
{
@@ -914,7 +914,7 @@ void GLShaderManager::CompileGPUShaders( GLShader *shader, shaderProgram_t *prog
}
void GLShaderManager::CompileAndLinkGPUShaderProgram( GLShader *shader, shaderProgram_t *program,
Str::StringRef compileMacros, int deformIndex ) const
Str::StringRef compileMacros, int deformIndex )
{
GLShaderManager::CompileGPUShaders( shader, program, compileMacros );
@@ -1013,7 +1013,7 @@ void GLShaderManager::LinkProgram( GLuint program ) const
{
GLint linked;
#ifdef GLEW_ARB_get_program_binary
#ifdef GL_ARB_get_program_binary
// Apparently, this is necessary to get the binary program via glGetProgramBinary
if( glConfig2.getProgramBinaryAvailable )
{
@@ -1031,21 +1031,6 @@ void GLShaderManager::LinkProgram( GLuint program ) const
}
}
void GLShaderManager::ValidateProgram( GLuint program ) const
{
GLint validated;
glValidateProgram( program );
glGetProgramiv( program, GL_VALIDATE_STATUS, &validated );
if ( !validated )
{
PrintInfoLog( program );
ThrowShaderError( "Shaders failed to validate!" );
}
}
void GLShaderManager::BindAttribLocations( GLuint program ) const
{
for ( uint32_t i = 0; i < ATTR_INDEX_MAX; i++ )
@@ -1322,6 +1307,9 @@ void GLShader_generic::SetShaderProgramUniforms( shaderProgram_t *shaderProgram
{
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ColorMap" ), 0 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_DepthMap" ), 1 );
if( !glConfig2.uniformBufferObjectAvailable ) {
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
}
}
GLShader_lightMapping::GLShader_lightMapping( GLShaderManager *manager ) :
@@ -1372,6 +1360,9 @@ void GLShader_lightMapping::SetShaderProgramUniforms( shaderProgram_t *shaderPro
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_DeluxeMap" ), 4 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_GlowMap" ), 5 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightTiles" ), 8 );
if( !glConfig2.uniformBufferObjectAvailable ) {
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
}
}
GLShader_vertexLighting_DBS_entity::GLShader_vertexLighting_DBS_entity( GLShaderManager *manager ) :
@@ -1430,6 +1421,9 @@ void GLShader_vertexLighting_DBS_entity::SetShaderProgramUniforms( shaderProgram
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightGrid1" ), 6 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightGrid2" ), 7 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightTiles" ), 8 );
if( !glConfig2.uniformBufferObjectAvailable ) {
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
}
}
GLShader_vertexLighting_DBS_world::GLShader_vertexLighting_DBS_world( GLShaderManager *manager ) :
@@ -1485,6 +1479,9 @@ void GLShader_vertexLighting_DBS_world::SetShaderProgramUniforms( shaderProgram_
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightGrid1" ), 6 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightGrid2" ), 7 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightTiles" ), 8 );
if( !glConfig2.uniformBufferObjectAvailable ) {
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
}
}
GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderManager *manager ):
@@ -2054,6 +2051,10 @@ GLShader_lighttile::GLShader_lighttile( GLShaderManager *manager ) :
void GLShader_lighttile::SetShaderProgramUniforms( shaderProgram_t *shaderProgram )
{
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_DepthMap" ), 0 );
if( !glConfig2.uniformBufferObjectAvailable ) {
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 1 );
}
}
GLShader_fxaa::GLShader_fxaa( GLShaderManager *manager ) :
@@ -243,6 +243,7 @@ class GLShader
class GLShaderManager
{
std::string _versionDeclaration;
std::queue< GLShader* > _shaderBuildQueue;
std::vector< GLShader* > _shaders;
std::unordered_map< std::string, int > _deformShaderLookup;
@@ -254,6 +255,19 @@ class GLShaderManager
}
~GLShaderManager();
std::string GetVersionDeclaration() {
if( _versionDeclaration.size() == 0 ) {
const char *profile = "";
if( glConfig2.shadingLanguageVersion >= 150 ) {
profile = glConfig2.glCoreProfile ? "core" : "compatibility";
}
_versionDeclaration = Str::Format( "#version %d %s\n", glConfig2.shadingLanguageVersion, profile );
}
return _versionDeclaration;
}
template< class T >
void load( T *& shader )
{
@@ -278,17 +292,16 @@ class GLShaderManager
GLuint CompileShader( Str::StringRef programName, Str::StringRef shaderText,
int shaderTextSize, GLenum shaderType ) const;
void CompileGPUShaders( GLShader *shader, shaderProgram_t *program,
const std::string &compileMacros ) const;
const std::string &compileMacros );
void CompileAndLinkGPUShaderProgram( GLShader *shader, shaderProgram_t *program,
Str::StringRef compileMacros, int deformIndex ) const;
std::string BuildDeformShaderText( const std::string& steps ) const;
Str::StringRef compileMacros, int deformIndex );
std::string BuildDeformShaderText( const std::string& steps );
std::string BuildGPUShaderText( Str::StringRef mainShader, Str::StringRef libShaders, GLenum shaderType ) const;
void LinkProgram( GLuint program ) const;
void BindAttribLocations( GLuint program ) const;
void PrintShaderSource( Str::StringRef programName, GLuint object ) const;
void PrintInfoLog( GLuint object ) const;
void InitShader( GLShader *shader );
void ValidateProgram( GLuint program ) const;
void UpdateShaderProgramUniformLocations( GLShader *shader, shaderProgram_t *shaderProgram ) const;
};
Oops, something went wrong.

0 comments on commit ed0d05b

Please sign in to comment.