mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 10:38:53 +00:00
More render backend refactoring. Fixed image stuff
This commit is contained in:
parent
a54612c0be
commit
a6169afac6
8 changed files with 408 additions and 401 deletions
|
@ -658,107 +658,7 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Bind
|
||||
|
||||
Automatically enables 2D mapping or cube mapping if needed
|
||||
==============
|
||||
*/
|
||||
void idImage::Bind()
|
||||
{
|
||||
RENDERLOG_PRINTF( "idImage::Bind( %s )\n", GetName() );
|
||||
|
||||
// load the image if necessary (FIXME: not SMP safe!)
|
||||
if( !IsLoaded() )
|
||||
{
|
||||
// load the image on demand here, which isn't our normal game operating mode
|
||||
ActuallyLoadImage( true );
|
||||
}
|
||||
|
||||
const int texUnit = tr.backend.currenttmu;
|
||||
|
||||
// RB: added support for more types
|
||||
tmu_t* tmu = &backEnd.glState.tmu[texUnit];
|
||||
// bind the texture
|
||||
if( opts.textureType == TT_2D )
|
||||
{
|
||||
if( tmu->current2DMap != texnum )
|
||||
{
|
||||
tmu->current2DMap = texnum;
|
||||
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
if( glConfig.directStateAccess )
|
||||
{
|
||||
glBindMultiTextureEXT( GL_TEXTURE0 + texUnit, GL_TEXTURE_2D, texnum );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glActiveTexture( GL_TEXTURE0 + texUnit );
|
||||
glBindTexture( GL_TEXTURE_2D, texnum );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( opts.textureType == TT_CUBIC )
|
||||
{
|
||||
if( tmu->currentCubeMap != texnum )
|
||||
{
|
||||
tmu->currentCubeMap = texnum;
|
||||
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
if( glConfig.directStateAccess )
|
||||
{
|
||||
glBindMultiTextureEXT( GL_TEXTURE0 + texUnit, GL_TEXTURE_CUBE_MAP, texnum );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glActiveTexture( GL_TEXTURE0 + texUnit );
|
||||
glBindTexture( GL_TEXTURE_CUBE_MAP, texnum );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( opts.textureType == TT_2D_ARRAY )
|
||||
{
|
||||
if( tmu->current2DArray != texnum )
|
||||
{
|
||||
tmu->current2DArray = texnum;
|
||||
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
if( glConfig.directStateAccess )
|
||||
{
|
||||
glBindMultiTextureEXT( GL_TEXTURE0 + texUnit, GL_TEXTURE_2D_ARRAY, texnum );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glActiveTexture( GL_TEXTURE0 + texUnit );
|
||||
glBindTexture( GL_TEXTURE_2D_ARRAY, texnum );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( opts.textureType == TT_2D_MULTISAMPLE )
|
||||
{
|
||||
if( tmu->current2DMap != texnum )
|
||||
{
|
||||
tmu->current2DMap = texnum;
|
||||
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
if( glConfig.directStateAccess )
|
||||
{
|
||||
glBindMultiTextureEXT( GL_TEXTURE0 + texUnit, GL_TEXTURE_2D_MULTISAMPLE, texnum );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glActiveTexture( GL_TEXTURE0 + texUnit );
|
||||
glBindTexture( GL_TEXTURE_2D_MULTISAMPLE, texnum );
|
||||
}
|
||||
}
|
||||
}
|
||||
// RB end
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -774,106 +674,7 @@ int MakePowerOfTwo( int num )
|
|||
return pot;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CopyFramebuffer
|
||||
====================
|
||||
*/
|
||||
void idImage::CopyFramebuffer( int x, int y, int imageWidth, int imageHeight )
|
||||
{
|
||||
int target = GL_TEXTURE_2D;
|
||||
switch( opts.textureType )
|
||||
{
|
||||
case TT_2D:
|
||||
target = GL_TEXTURE_2D;
|
||||
break;
|
||||
case TT_CUBIC:
|
||||
target = GL_TEXTURE_CUBE_MAP;
|
||||
break;
|
||||
case TT_2D_ARRAY:
|
||||
target = GL_TEXTURE_2D_ARRAY;
|
||||
break;
|
||||
case TT_2D_MULTISAMPLE:
|
||||
target = GL_TEXTURE_2D_MULTISAMPLE;
|
||||
break;
|
||||
default:
|
||||
//idLib::FatalError( "%s: bad texture type %d", GetName(), opts.textureType );
|
||||
return;
|
||||
}
|
||||
|
||||
glBindTexture( target, texnum );
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
if( Framebuffer::IsDefaultFramebufferActive() )
|
||||
{
|
||||
glReadBuffer( GL_BACK );
|
||||
}
|
||||
#endif
|
||||
|
||||
opts.width = imageWidth;
|
||||
opts.height = imageHeight;
|
||||
|
||||
#if defined(USE_GLES2)
|
||||
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, x, y, imageWidth, imageHeight, 0 );
|
||||
#else
|
||||
if( r_useHDR.GetBool() && globalFramebuffers.hdrFBO->IsBound() )
|
||||
{
|
||||
|
||||
//if( backEnd.glState.currentFramebuffer != NULL && backEnd.glState.currentFramebuffer->IsMultiSampled() )
|
||||
|
||||
#if defined(USE_HDR_MSAA)
|
||||
if( globalFramebuffers.hdrFBO->IsMultiSampled() )
|
||||
{
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, globalFramebuffers.hdrFBO->GetFramebuffer() );
|
||||
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, globalFramebuffers.hdrNonMSAAFBO->GetFramebuffer() );
|
||||
glBlitFramebuffer( 0, 0, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight,
|
||||
0, 0, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight,
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_LINEAR );
|
||||
|
||||
globalFramebuffers.hdrNonMSAAFBO->Bind();
|
||||
|
||||
glCopyTexImage2D( target, 0, GL_RGBA16F, x, y, imageWidth, imageHeight, 0 );
|
||||
|
||||
globalFramebuffers.hdrFBO->Bind();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glCopyTexImage2D( target, 0, GL_RGBA16F, x, y, imageWidth, imageHeight, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glCopyTexImage2D( target, 0, GL_RGBA8, x, y, imageWidth, imageHeight, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// these shouldn't be necessary if the image was initialized properly
|
||||
glTexParameterf( target, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
glTexParameterf( target, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
|
||||
glTexParameterf( target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
glTexParameterf( target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
|
||||
backEnd.pc.c_copyFrameBuffer++;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CopyDepthbuffer
|
||||
====================
|
||||
*/
|
||||
void idImage::CopyDepthbuffer( int x, int y, int imageWidth, int imageHeight )
|
||||
{
|
||||
glBindTexture( ( opts.textureType == TT_CUBIC ) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, texnum );
|
||||
|
||||
opts.width = imageWidth;
|
||||
opts.height = imageHeight;
|
||||
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, x, y, imageWidth, imageHeight, 0 );
|
||||
|
||||
backEnd.pc.c_copyFrameBuffer++;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
|
|
|
@ -72,6 +72,209 @@ idImage::~idImage()
|
|||
PurgeImage();
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Bind
|
||||
|
||||
Automatically enables 2D mapping or cube mapping if needed
|
||||
==============
|
||||
*/
|
||||
void idImage::Bind()
|
||||
{
|
||||
RENDERLOG_PRINTF( "idImage::Bind( %s )\n", GetName() );
|
||||
|
||||
// load the image if necessary (FIXME: not SMP safe!)
|
||||
if( !IsLoaded() )
|
||||
{
|
||||
// load the image on demand here, which isn't our normal game operating mode
|
||||
ActuallyLoadImage( true );
|
||||
}
|
||||
|
||||
const int texUnit = tr.backend.GetCurrentTextureUnit();
|
||||
|
||||
// RB: added support for more types
|
||||
tmu_t* tmu = &glcontext.tmu[texUnit];
|
||||
// bind the texture
|
||||
if( opts.textureType == TT_2D )
|
||||
{
|
||||
if( tmu->current2DMap != texnum )
|
||||
{
|
||||
tmu->current2DMap = texnum;
|
||||
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
if( glConfig.directStateAccess )
|
||||
{
|
||||
glBindMultiTextureEXT( GL_TEXTURE0 + texUnit, GL_TEXTURE_2D, texnum );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glActiveTexture( GL_TEXTURE0 + texUnit );
|
||||
glBindTexture( GL_TEXTURE_2D, texnum );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( opts.textureType == TT_CUBIC )
|
||||
{
|
||||
if( tmu->currentCubeMap != texnum )
|
||||
{
|
||||
tmu->currentCubeMap = texnum;
|
||||
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
if( glConfig.directStateAccess )
|
||||
{
|
||||
glBindMultiTextureEXT( GL_TEXTURE0 + texUnit, GL_TEXTURE_CUBE_MAP, texnum );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glActiveTexture( GL_TEXTURE0 + texUnit );
|
||||
glBindTexture( GL_TEXTURE_CUBE_MAP, texnum );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( opts.textureType == TT_2D_ARRAY )
|
||||
{
|
||||
if( tmu->current2DArray != texnum )
|
||||
{
|
||||
tmu->current2DArray = texnum;
|
||||
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
if( glConfig.directStateAccess )
|
||||
{
|
||||
glBindMultiTextureEXT( GL_TEXTURE0 + texUnit, GL_TEXTURE_2D_ARRAY, texnum );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glActiveTexture( GL_TEXTURE0 + texUnit );
|
||||
glBindTexture( GL_TEXTURE_2D_ARRAY, texnum );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( opts.textureType == TT_2D_MULTISAMPLE )
|
||||
{
|
||||
if( tmu->current2DMap != texnum )
|
||||
{
|
||||
tmu->current2DMap = texnum;
|
||||
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
if( glConfig.directStateAccess )
|
||||
{
|
||||
glBindMultiTextureEXT( GL_TEXTURE0 + texUnit, GL_TEXTURE_2D_MULTISAMPLE, texnum );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glActiveTexture( GL_TEXTURE0 + texUnit );
|
||||
glBindTexture( GL_TEXTURE_2D_MULTISAMPLE, texnum );
|
||||
}
|
||||
}
|
||||
}
|
||||
// RB end
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CopyFramebuffer
|
||||
====================
|
||||
*/
|
||||
void idImage::CopyFramebuffer( int x, int y, int imageWidth, int imageHeight )
|
||||
{
|
||||
int target = GL_TEXTURE_2D;
|
||||
switch( opts.textureType )
|
||||
{
|
||||
case TT_2D:
|
||||
target = GL_TEXTURE_2D;
|
||||
break;
|
||||
case TT_CUBIC:
|
||||
target = GL_TEXTURE_CUBE_MAP;
|
||||
break;
|
||||
case TT_2D_ARRAY:
|
||||
target = GL_TEXTURE_2D_ARRAY;
|
||||
break;
|
||||
case TT_2D_MULTISAMPLE:
|
||||
target = GL_TEXTURE_2D_MULTISAMPLE;
|
||||
break;
|
||||
default:
|
||||
//idLib::FatalError( "%s: bad texture type %d", GetName(), opts.textureType );
|
||||
return;
|
||||
}
|
||||
|
||||
glBindTexture( target, texnum );
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
if( Framebuffer::IsDefaultFramebufferActive() )
|
||||
{
|
||||
glReadBuffer( GL_BACK );
|
||||
}
|
||||
#endif
|
||||
|
||||
opts.width = imageWidth;
|
||||
opts.height = imageHeight;
|
||||
|
||||
#if defined(USE_GLES2)
|
||||
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, x, y, imageWidth, imageHeight, 0 );
|
||||
#else
|
||||
if( r_useHDR.GetBool() && globalFramebuffers.hdrFBO->IsBound() )
|
||||
{
|
||||
|
||||
//if( backEnd.glState.currentFramebuffer != NULL && backEnd.glState.currentFramebuffer->IsMultiSampled() )
|
||||
|
||||
#if defined(USE_HDR_MSAA)
|
||||
if( globalFramebuffers.hdrFBO->IsMultiSampled() )
|
||||
{
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, globalFramebuffers.hdrFBO->GetFramebuffer() );
|
||||
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, globalFramebuffers.hdrNonMSAAFBO->GetFramebuffer() );
|
||||
glBlitFramebuffer( 0, 0, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight,
|
||||
0, 0, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight,
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_LINEAR );
|
||||
|
||||
globalFramebuffers.hdrNonMSAAFBO->Bind();
|
||||
|
||||
glCopyTexImage2D( target, 0, GL_RGBA16F, x, y, imageWidth, imageHeight, 0 );
|
||||
|
||||
globalFramebuffers.hdrFBO->Bind();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glCopyTexImage2D( target, 0, GL_RGBA16F, x, y, imageWidth, imageHeight, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glCopyTexImage2D( target, 0, GL_RGBA8, x, y, imageWidth, imageHeight, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// these shouldn't be necessary if the image was initialized properly
|
||||
glTexParameterf( target, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
glTexParameterf( target, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
|
||||
glTexParameterf( target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
glTexParameterf( target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
|
||||
tr.backend.pc.c_copyFrameBuffer++;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
CopyDepthbuffer
|
||||
====================
|
||||
*/
|
||||
void idImage::CopyDepthbuffer( int x, int y, int imageWidth, int imageHeight )
|
||||
{
|
||||
glBindTexture( ( opts.textureType == TT_CUBIC ) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, texnum );
|
||||
|
||||
opts.width = imageWidth;
|
||||
opts.height = imageHeight;
|
||||
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, x, y, imageWidth, imageHeight, 0 );
|
||||
|
||||
tr.backend.pc.c_copyFrameBuffer++;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idImage::SubImageUpload
|
||||
|
|
|
@ -53,7 +53,69 @@ static GLsync renderSync[2];
|
|||
void GLimp_SwapBuffers();
|
||||
void RB_SetMVP( const idRenderMatrix& mvp );
|
||||
|
||||
glContext_t glcontext;
|
||||
|
||||
/*
|
||||
==================
|
||||
GL_CheckErrors
|
||||
==================
|
||||
*/
|
||||
// RB: added filename, line parms
|
||||
bool GL_CheckErrors_( const char* filename, int line )
|
||||
{
|
||||
int err;
|
||||
char s[64];
|
||||
int i;
|
||||
|
||||
if( r_ignoreGLErrors.GetBool() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for up to 10 errors pending
|
||||
bool error = false;
|
||||
for( i = 0 ; i < 10 ; i++ )
|
||||
{
|
||||
err = glGetError();
|
||||
if( err == GL_NO_ERROR )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
error = true;
|
||||
switch( err )
|
||||
{
|
||||
case GL_INVALID_ENUM:
|
||||
strcpy( s, "GL_INVALID_ENUM" );
|
||||
break;
|
||||
case GL_INVALID_VALUE:
|
||||
strcpy( s, "GL_INVALID_VALUE" );
|
||||
break;
|
||||
case GL_INVALID_OPERATION:
|
||||
strcpy( s, "GL_INVALID_OPERATION" );
|
||||
break;
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
case GL_STACK_OVERFLOW:
|
||||
strcpy( s, "GL_STACK_OVERFLOW" );
|
||||
break;
|
||||
case GL_STACK_UNDERFLOW:
|
||||
strcpy( s, "GL_STACK_UNDERFLOW" );
|
||||
break;
|
||||
#endif
|
||||
case GL_OUT_OF_MEMORY:
|
||||
strcpy( s, "GL_OUT_OF_MEMORY" );
|
||||
break;
|
||||
default:
|
||||
idStr::snPrintf( s, sizeof( s ), "%i", err );
|
||||
break;
|
||||
}
|
||||
|
||||
common->Printf( "caught OpenGL error: %s in file %s line %i\n", s, filename, line );
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
// RB end
|
||||
|
||||
/*
|
||||
=============
|
||||
|
@ -888,6 +950,117 @@ uint64 idRenderBackend::GL_GetCurrentStateMinusStencil() const
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
idRenderBackend::CheckCVars
|
||||
|
||||
See if some cvars that we watch have changed
|
||||
=============
|
||||
*/
|
||||
void idRenderBackend::CheckCVars()
|
||||
{
|
||||
// gamma stuff
|
||||
if( r_gamma.IsModified() || r_brightness.IsModified() )
|
||||
{
|
||||
r_gamma.ClearModified();
|
||||
r_brightness.ClearModified();
|
||||
R_SetColorMappings();
|
||||
}
|
||||
|
||||
// filtering
|
||||
if( r_maxAnisotropicFiltering.IsModified() || r_useTrilinearFiltering.IsModified() || r_lodBias.IsModified() )
|
||||
{
|
||||
idLib::Printf( "Updating texture filter parameters.\n" );
|
||||
r_maxAnisotropicFiltering.ClearModified();
|
||||
r_useTrilinearFiltering.ClearModified();
|
||||
r_lodBias.ClearModified();
|
||||
|
||||
for( int i = 0 ; i < globalImages->images.Num() ; i++ )
|
||||
{
|
||||
if( globalImages->images[i] )
|
||||
{
|
||||
globalImages->images[i]->Bind();
|
||||
globalImages->images[i]->SetTexParameters();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern idCVar r_useSeamlessCubeMap;
|
||||
if( r_useSeamlessCubeMap.IsModified() )
|
||||
{
|
||||
r_useSeamlessCubeMap.ClearModified();
|
||||
if( glConfig.seamlessCubeMapAvailable )
|
||||
{
|
||||
if( r_useSeamlessCubeMap.GetBool() )
|
||||
{
|
||||
glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS );
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable( GL_TEXTURE_CUBE_MAP_SEAMLESS );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern idCVar r_useSRGB;
|
||||
if( r_useSRGB.IsModified() )
|
||||
{
|
||||
r_useSRGB.ClearModified();
|
||||
if( glConfig.sRGBFramebufferAvailable )
|
||||
{
|
||||
if( r_useSRGB.GetBool() && r_useSRGB.GetInteger() != 3 )
|
||||
{
|
||||
glEnable( GL_FRAMEBUFFER_SRGB );
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable( GL_FRAMEBUFFER_SRGB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( r_antiAliasing.IsModified() )
|
||||
{
|
||||
switch( r_antiAliasing.GetInteger() )
|
||||
{
|
||||
case ANTI_ALIASING_MSAA_2X:
|
||||
case ANTI_ALIASING_MSAA_4X:
|
||||
case ANTI_ALIASING_MSAA_8X:
|
||||
if( r_antiAliasing.GetInteger() > 0 )
|
||||
{
|
||||
glEnable( GL_MULTISAMPLE );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
glDisable( GL_MULTISAMPLE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( r_useHDR.IsModified() || r_useHalfLambertLighting.IsModified() )
|
||||
{
|
||||
r_useHDR.ClearModified();
|
||||
r_useHalfLambertLighting.ClearModified();
|
||||
renderProgManager.KillAllShaders();
|
||||
renderProgManager.LoadAllShaders();
|
||||
}
|
||||
|
||||
// RB: turn off shadow mapping for OpenGL drivers that are too slow
|
||||
switch( glConfig.driverType )
|
||||
{
|
||||
case GLDRV_OPENGL_ES2:
|
||||
case GLDRV_OPENGL_ES3:
|
||||
//case GLDRV_OPENGL_MESA:
|
||||
r_useShadowMapping.SetInteger( 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// RB end
|
||||
}
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
|
||||
|
@ -1180,7 +1353,7 @@ void idRenderBackend::StereoRenderExecuteBackEndCommands( const emptyCommand_t*
|
|||
SetBuffer( cmds );
|
||||
break;
|
||||
case RC_COPY_RENDER:
|
||||
RB_CopyRender( cmds );
|
||||
CopyRender( cmds );
|
||||
break;
|
||||
case RC_POST_PROCESS:
|
||||
{
|
||||
|
@ -1189,7 +1362,7 @@ void idRenderBackend::StereoRenderExecuteBackEndCommands( const emptyCommand_t*
|
|||
{
|
||||
break;
|
||||
}
|
||||
RB_PostProcess( cmds );
|
||||
PostProcess( cmds );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1455,7 +1628,7 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
|
|||
break;
|
||||
case RC_DRAW_VIEW_3D:
|
||||
case RC_DRAW_VIEW_GUI:
|
||||
RB_DrawView( cmds, 0 );
|
||||
DrawView( cmds, 0 );
|
||||
if( ( ( const drawSurfsCommand_t* )cmds )->viewDef->viewEntitys )
|
||||
{
|
||||
c_draw3d++;
|
||||
|
@ -1470,11 +1643,11 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
|
|||
c_setBuffers++;
|
||||
break;
|
||||
case RC_COPY_RENDER:
|
||||
RB_CopyRender( cmds );
|
||||
CopyRender( cmds );
|
||||
c_copyRenders++;
|
||||
break;
|
||||
case RC_POST_PROCESS:
|
||||
RB_PostProcess( cmds );
|
||||
PostProcess( cmds );
|
||||
break;
|
||||
default:
|
||||
common->Error( "RB_ExecuteBackEndCommands: bad commandId" );
|
||||
|
|
|
@ -1832,8 +1832,7 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
inter.bumpImage = surfaceStage->texture.image;
|
||||
inter.diffuseImage = NULL;
|
||||
inter.specularImage = NULL;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, NULL,
|
||||
inter.bumpMatrix, NULL );
|
||||
SetupInteractionStage( surfaceStage, surfaceRegs, NULL, inter.bumpMatrix, NULL );
|
||||
break;
|
||||
}
|
||||
case SL_DIFFUSE:
|
||||
|
@ -1850,8 +1849,8 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
}
|
||||
inter.diffuseImage = surfaceStage->texture.image;
|
||||
inter.vertexColor = surfaceStage->vertexColor;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, diffuseColor.ToFloatPtr(),
|
||||
inter.diffuseMatrix, inter.diffuseColor.ToFloatPtr() );
|
||||
SetupInteractionStage( surfaceStage, surfaceRegs, diffuseColor.ToFloatPtr(),
|
||||
inter.diffuseMatrix, inter.diffuseColor.ToFloatPtr() );
|
||||
break;
|
||||
}
|
||||
case SL_SPECULAR:
|
||||
|
@ -1868,8 +1867,8 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
}
|
||||
inter.specularImage = surfaceStage->texture.image;
|
||||
inter.vertexColor = surfaceStage->vertexColor;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, specularColor.ToFloatPtr(),
|
||||
inter.specularMatrix, inter.specularColor.ToFloatPtr() );
|
||||
SetupInteractionStage( surfaceStage, surfaceRegs, specularColor.ToFloatPtr(),
|
||||
inter.specularMatrix, inter.specularColor.ToFloatPtr() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2221,8 +2220,8 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
|
|||
inter.bumpImage = surfaceStage->texture.image;
|
||||
inter.diffuseImage = NULL;
|
||||
inter.specularImage = NULL;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, NULL,
|
||||
inter.bumpMatrix, NULL );
|
||||
SetupInteractionStage( surfaceStage, surfaceRegs, NULL,
|
||||
inter.bumpMatrix, NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2242,8 +2241,8 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
|
|||
|
||||
inter.diffuseImage = surfaceStage->texture.image;
|
||||
inter.vertexColor = surfaceStage->vertexColor;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, diffuseColor.ToFloatPtr(),
|
||||
inter.diffuseMatrix, inter.diffuseColor.ToFloatPtr() );
|
||||
SetupInteractionStage( surfaceStage, surfaceRegs, diffuseColor.ToFloatPtr(),
|
||||
inter.diffuseMatrix, inter.diffuseColor.ToFloatPtr() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2261,8 +2260,8 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
|
|||
}
|
||||
inter.specularImage = surfaceStage->texture.image;
|
||||
inter.vertexColor = surfaceStage->vertexColor;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, specularColor.ToFloatPtr(),
|
||||
inter.specularMatrix, inter.specularColor.ToFloatPtr() );
|
||||
SetupInteractionStage( surfaceStage, surfaceRegs, specularColor.ToFloatPtr(),
|
||||
inter.specularMatrix, inter.specularColor.ToFloatPtr() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5552,7 +5551,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
//-------------------------------------------------
|
||||
// render debug tools
|
||||
//-------------------------------------------------
|
||||
RB_RenderDebugTools( drawSurfs, numDrawSurfs );
|
||||
DBG_RenderDebugTools( drawSurfs, numDrawSurfs );
|
||||
|
||||
// RB: convert back from HDR to LDR range
|
||||
if( useHDR )
|
||||
|
|
|
@ -127,7 +127,6 @@ void RB_SetVertexColorParms( stageVertexColor_t svc );
|
|||
void RB_GetShaderTextureMatrix( const float* shaderRegisters, const textureStage_t* texture, float matrix[16] );
|
||||
void RB_LoadShaderTextureMatrix( const float* shaderRegisters, const textureStage_t* texture );
|
||||
void RB_BakeTextureMatrixIntoTexgen( idPlane lightProject[3], const float* textureMatrix );
|
||||
void RB_SetupInteractionStage( const shaderStage_t* surfaceStage, const float* surfaceRegs, const float lightColor[4], idVec4 matrix[2], float color[4] );
|
||||
|
||||
//bool ChangeDisplaySettingsIfNeeded( gfxImpParms_t parms );
|
||||
//bool CreateGameWindow( gfxImpParms_t parms );
|
||||
|
@ -250,6 +249,7 @@ public:
|
|||
void BlockingSwapBuffers();
|
||||
|
||||
void Print();
|
||||
void CheckCVars();
|
||||
|
||||
private:
|
||||
void DrawFlickerBox();
|
||||
|
@ -258,7 +258,6 @@ private:
|
|||
void DrawStencilShadowPass( const drawSurf_t* drawSurf, const bool renderZPass );
|
||||
|
||||
void SetColorMappings();
|
||||
void CheckCVars();
|
||||
void ResizeImages();
|
||||
|
||||
void DrawViewInternal( const viewDef_t* viewDef, const int stereoEye );
|
||||
|
@ -324,11 +323,11 @@ private:
|
|||
void GL_Cull( cullType_t cullType ); // TODO remove
|
||||
|
||||
void GL_SelectTexture( int unit );
|
||||
void GL_BindTexture( idImage* image );
|
||||
|
||||
void GL_CopyFrameBuffer( idImage* image, int x, int y, int imageWidth, int imageHeight );
|
||||
void GL_CopyDepthBuffer( idImage* image, int x, int y, int imageWidth, int imageHeight );
|
||||
|
||||
// void GL_BindTexture( idImage* image );
|
||||
|
||||
// void GL_CopyFrameBuffer( idImage* image, int x, int y, int imageWidth, int imageHeight );
|
||||
// void GL_CopyDepthBuffer( idImage* image, int x, int y, int imageWidth, int imageHeight );
|
||||
|
||||
// RB: HDR parm
|
||||
void GL_Clear( bool color, bool depth, bool stencil, byte stencilValue, float r, float g, float b, float a, bool clearHDR = true );
|
||||
|
||||
|
@ -469,6 +468,12 @@ private:
|
|||
float polyOfsScale;
|
||||
float polyOfsBias;
|
||||
|
||||
public:
|
||||
int GetCurrentTextureUnit() const
|
||||
{
|
||||
return currenttmu;
|
||||
}
|
||||
|
||||
#if 0
|
||||
unsigned short gammaTable[ 256 ]; // brightness / gamma modify this
|
||||
|
||||
|
|
|
@ -1428,10 +1428,6 @@ TR_BACKEND_DRAW
|
|||
*/
|
||||
|
||||
void RB_SetMVP( const idRenderMatrix& mvp );
|
||||
void RB_DrawViewInternal( const viewDef_t* viewDef, const int stereoEye );
|
||||
void RB_DrawView( const void* data, const int stereoEye );
|
||||
void RB_CopyRender( const void* data );
|
||||
void RB_PostProcess( const void* data );
|
||||
|
||||
/*
|
||||
=============================================================
|
||||
|
@ -1450,7 +1446,6 @@ void RB_AddDebugPolygon( const idVec4& color, const idWinding& winding, const in
|
|||
void RB_ClearDebugPolygons( int time );
|
||||
void RB_DrawBounds( const idBounds& bounds );
|
||||
|
||||
void RB_RenderDebugTools( drawSurf_t** drawSurfs, int numDrawSurfs );
|
||||
void RB_ShutdownDebugTools();
|
||||
void RB_SetVertexColorParms( stageVertexColor_t svc );
|
||||
|
||||
|
|
|
@ -228,115 +228,7 @@ void R_AddDrawPostProcess( viewDef_t* parms )
|
|||
//=================================================================================
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
R_CheckCvars
|
||||
|
||||
See if some cvars that we watch have changed
|
||||
=============
|
||||
*/
|
||||
static void R_CheckCvars()
|
||||
{
|
||||
// gamma stuff
|
||||
if( r_gamma.IsModified() || r_brightness.IsModified() )
|
||||
{
|
||||
r_gamma.ClearModified();
|
||||
r_brightness.ClearModified();
|
||||
R_SetColorMappings();
|
||||
}
|
||||
|
||||
// filtering
|
||||
if( r_maxAnisotropicFiltering.IsModified() || r_useTrilinearFiltering.IsModified() || r_lodBias.IsModified() )
|
||||
{
|
||||
idLib::Printf( "Updating texture filter parameters.\n" );
|
||||
r_maxAnisotropicFiltering.ClearModified();
|
||||
r_useTrilinearFiltering.ClearModified();
|
||||
r_lodBias.ClearModified();
|
||||
for( int i = 0 ; i < globalImages->images.Num() ; i++ )
|
||||
{
|
||||
if( globalImages->images[i] )
|
||||
{
|
||||
globalImages->images[i]->Bind();
|
||||
globalImages->images[i]->SetTexParameters();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern idCVar r_useSeamlessCubeMap;
|
||||
if( r_useSeamlessCubeMap.IsModified() )
|
||||
{
|
||||
r_useSeamlessCubeMap.ClearModified();
|
||||
if( glConfig.seamlessCubeMapAvailable )
|
||||
{
|
||||
if( r_useSeamlessCubeMap.GetBool() )
|
||||
{
|
||||
glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS );
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable( GL_TEXTURE_CUBE_MAP_SEAMLESS );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern idCVar r_useSRGB;
|
||||
if( r_useSRGB.IsModified() )
|
||||
{
|
||||
r_useSRGB.ClearModified();
|
||||
if( glConfig.sRGBFramebufferAvailable )
|
||||
{
|
||||
if( r_useSRGB.GetBool() && r_useSRGB.GetInteger() != 3 )
|
||||
{
|
||||
glEnable( GL_FRAMEBUFFER_SRGB );
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable( GL_FRAMEBUFFER_SRGB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( r_antiAliasing.IsModified() )
|
||||
{
|
||||
switch( r_antiAliasing.GetInteger() )
|
||||
{
|
||||
case ANTI_ALIASING_MSAA_2X:
|
||||
case ANTI_ALIASING_MSAA_4X:
|
||||
case ANTI_ALIASING_MSAA_8X:
|
||||
if( r_antiAliasing.GetInteger() > 0 )
|
||||
{
|
||||
glEnable( GL_MULTISAMPLE );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
glDisable( GL_MULTISAMPLE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( r_useHDR.IsModified() || r_useHalfLambertLighting.IsModified() )
|
||||
{
|
||||
r_useHDR.ClearModified();
|
||||
r_useHalfLambertLighting.ClearModified();
|
||||
renderProgManager.KillAllShaders();
|
||||
renderProgManager.LoadAllShaders();
|
||||
}
|
||||
|
||||
// RB: turn off shadow mapping for OpenGL drivers that are too slow
|
||||
switch( glConfig.driverType )
|
||||
{
|
||||
case GLDRV_OPENGL_ES2:
|
||||
case GLDRV_OPENGL_ES3:
|
||||
//case GLDRV_OPENGL_MESA:
|
||||
r_useShadowMapping.SetInteger( 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// RB end
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
|
@ -754,8 +646,7 @@ void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
|
|||
{
|
||||
// wait for our fence to hit, which means the swap has actually happened
|
||||
// We must do this before clearing any resources the GPU may be using
|
||||
void GL_BlockingSwapBuffers();
|
||||
GL_BlockingSwapBuffers();
|
||||
backend.BlockingSwapBuffers();
|
||||
}
|
||||
|
||||
// read back the start and end timer queries from the previous frame
|
||||
|
@ -795,7 +686,7 @@ void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
|
|||
PrintPerformanceCounters();
|
||||
|
||||
// check for dynamic changes that require some initialization
|
||||
R_CheckCvars();
|
||||
backend.CheckCVars();
|
||||
|
||||
// RB: resize HDR buffers
|
||||
Framebuffer::CheckFramebuffers();
|
||||
|
|
|
@ -952,67 +952,7 @@ void R_InitOpenGL()
|
|||
// RB end
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
GL_CheckErrors
|
||||
==================
|
||||
*/
|
||||
// RB: added filename, line parms
|
||||
bool GL_CheckErrors_( const char* filename, int line )
|
||||
{
|
||||
int err;
|
||||
char s[64];
|
||||
int i;
|
||||
|
||||
if( r_ignoreGLErrors.GetBool() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for up to 10 errors pending
|
||||
bool error = false;
|
||||
for( i = 0 ; i < 10 ; i++ )
|
||||
{
|
||||
err = glGetError();
|
||||
if( err == GL_NO_ERROR )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
error = true;
|
||||
switch( err )
|
||||
{
|
||||
case GL_INVALID_ENUM:
|
||||
strcpy( s, "GL_INVALID_ENUM" );
|
||||
break;
|
||||
case GL_INVALID_VALUE:
|
||||
strcpy( s, "GL_INVALID_VALUE" );
|
||||
break;
|
||||
case GL_INVALID_OPERATION:
|
||||
strcpy( s, "GL_INVALID_OPERATION" );
|
||||
break;
|
||||
#if !defined(USE_GLES2) && !defined(USE_GLES3)
|
||||
case GL_STACK_OVERFLOW:
|
||||
strcpy( s, "GL_STACK_OVERFLOW" );
|
||||
break;
|
||||
case GL_STACK_UNDERFLOW:
|
||||
strcpy( s, "GL_STACK_UNDERFLOW" );
|
||||
break;
|
||||
#endif
|
||||
case GL_OUT_OF_MEMORY:
|
||||
strcpy( s, "GL_OUT_OF_MEMORY" );
|
||||
break;
|
||||
default:
|
||||
idStr::snPrintf( s, sizeof( s ), "%i", err );
|
||||
break;
|
||||
}
|
||||
|
||||
common->Printf( "caught OpenGL error: %s in file %s line %i\n", s, filename, line );
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
// RB end
|
||||
|
||||
|
||||
/*
|
||||
=====================
|
||||
|
|
Loading…
Reference in a new issue