Detect certain software rasterizing OpenGL ICDs and add some speedups for them
also restore the GLHW_ detection stuff that was removed
This commit is contained in:
@@ -225,13 +225,219 @@ void GL_TexEnv( int env )
|
||||
}
|
||||
|
||||
extern cvar_t *r_mockvr;
|
||||
|
||||
// for software icds - do a few things differently for the SPEED
|
||||
static void GL_StateSW( unsigned long stateBits )
|
||||
{
|
||||
unsigned long diff = stateBits ^ glState.glStateBits;
|
||||
|
||||
|
||||
if ( !diff )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//GL_TexEnv( GL_REPLACE );
|
||||
|
||||
qglShadeModel( GL_SMOOTH );
|
||||
qglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // nice first (for maps...)
|
||||
|
||||
//
|
||||
// check depthFunc bits
|
||||
//
|
||||
if ( diff & GLS_DEPTHFUNC_EQUAL )
|
||||
{
|
||||
if ( stateBits & GLS_DEPTHFUNC_EQUAL )
|
||||
{
|
||||
qglDepthFunc( GL_EQUAL );
|
||||
}
|
||||
else
|
||||
{
|
||||
qglDepthFunc( GL_LEQUAL );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check blend bits
|
||||
//
|
||||
if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
|
||||
{
|
||||
GLenum srcFactor, dstFactor;
|
||||
|
||||
if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )
|
||||
{
|
||||
switch ( stateBits & GLS_SRCBLEND_BITS )
|
||||
{
|
||||
case GLS_SRCBLEND_ZERO:
|
||||
srcFactor = GL_ZERO;
|
||||
break;
|
||||
case GLS_SRCBLEND_ONE:
|
||||
srcFactor = GL_ONE;
|
||||
break;
|
||||
case GLS_SRCBLEND_DST_COLOR:
|
||||
srcFactor = GL_DST_COLOR;
|
||||
break;
|
||||
case GLS_SRCBLEND_ONE_MINUS_DST_COLOR:
|
||||
srcFactor = GL_ONE_MINUS_DST_COLOR;
|
||||
break;
|
||||
case GLS_SRCBLEND_SRC_ALPHA:
|
||||
srcFactor = GL_SRC_ALPHA;
|
||||
break;
|
||||
case GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA:
|
||||
srcFactor = GL_ONE_MINUS_SRC_ALPHA;
|
||||
break;
|
||||
case GLS_SRCBLEND_DST_ALPHA:
|
||||
srcFactor = GL_DST_ALPHA;
|
||||
break;
|
||||
case GLS_SRCBLEND_ONE_MINUS_DST_ALPHA:
|
||||
srcFactor = GL_ONE_MINUS_DST_ALPHA;
|
||||
break;
|
||||
case GLS_SRCBLEND_ALPHA_SATURATE:
|
||||
srcFactor = GL_SRC_ALPHA_SATURATE;
|
||||
break;
|
||||
default:
|
||||
srcFactor = GL_ONE; // to get warning to shut up
|
||||
ri.Error( ERR_DROP, "GL_State: invalid src blend state bits\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( stateBits & GLS_DSTBLEND_BITS )
|
||||
{
|
||||
case GLS_DSTBLEND_ZERO:
|
||||
dstFactor = GL_ZERO;
|
||||
break;
|
||||
case GLS_DSTBLEND_ONE:
|
||||
dstFactor = GL_ONE;
|
||||
break;
|
||||
case GLS_DSTBLEND_SRC_COLOR:
|
||||
dstFactor = GL_SRC_COLOR;
|
||||
break;
|
||||
case GLS_DSTBLEND_ONE_MINUS_SRC_COLOR:
|
||||
dstFactor = GL_ONE_MINUS_SRC_COLOR;
|
||||
break;
|
||||
case GLS_DSTBLEND_SRC_ALPHA:
|
||||
dstFactor = GL_SRC_ALPHA;
|
||||
break;
|
||||
case GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA:
|
||||
dstFactor = GL_ONE_MINUS_SRC_ALPHA;
|
||||
break;
|
||||
case GLS_DSTBLEND_DST_ALPHA:
|
||||
dstFactor = GL_DST_ALPHA;
|
||||
break;
|
||||
case GLS_DSTBLEND_ONE_MINUS_DST_ALPHA:
|
||||
dstFactor = GL_ONE_MINUS_DST_ALPHA;
|
||||
break;
|
||||
default:
|
||||
dstFactor = GL_ONE; // to get warning to shut up
|
||||
ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits\n" );
|
||||
break;
|
||||
}
|
||||
qglEnable( GL_BLEND );
|
||||
qglBlendFunc( srcFactor, dstFactor );
|
||||
qglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); // it's an effect...
|
||||
qglShadeModel( GL_FLAT );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
qglDisable( GL_BLEND );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check depthmask
|
||||
//
|
||||
if ( diff & GLS_DEPTHMASK_TRUE )
|
||||
{
|
||||
if ( stateBits & GLS_DEPTHMASK_TRUE )
|
||||
{
|
||||
qglDepthMask( GL_TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
qglDepthMask( GL_FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fill/line mode
|
||||
//
|
||||
if ( diff & GLS_POLYMODE_LINE )
|
||||
{
|
||||
if ( stateBits & GLS_POLYMODE_LINE )
|
||||
{
|
||||
qglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
||||
qglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); // it's an effect...
|
||||
}
|
||||
else
|
||||
{
|
||||
qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// depthtest
|
||||
//
|
||||
if ( diff & GLS_DEPTHTEST_DISABLE )
|
||||
{
|
||||
if ( stateBits & GLS_DEPTHTEST_DISABLE )
|
||||
{
|
||||
qglDisable( GL_DEPTH_TEST );
|
||||
}
|
||||
else
|
||||
{
|
||||
qglEnable( GL_DEPTH_TEST );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// alpha test
|
||||
//
|
||||
if ( diff & GLS_ATEST_BITS )
|
||||
{
|
||||
switch ( stateBits & GLS_ATEST_BITS )
|
||||
{
|
||||
case 0:
|
||||
qglDisable( GL_ALPHA_TEST );
|
||||
break;
|
||||
case GLS_ATEST_GT_0:
|
||||
qglEnable( GL_ALPHA_TEST );
|
||||
qglAlphaFunc( GL_GREATER, 0.0f );
|
||||
qglShadeModel( GL_FLAT );
|
||||
|
||||
break;
|
||||
case GLS_ATEST_LT_80:
|
||||
qglEnable( GL_ALPHA_TEST );
|
||||
qglAlphaFunc( GL_LESS, 0.5f );
|
||||
qglShadeModel( GL_FLAT );
|
||||
|
||||
break;
|
||||
case GLS_ATEST_GE_80:
|
||||
qglEnable( GL_ALPHA_TEST );
|
||||
qglAlphaFunc( GL_GEQUAL, 0.5f );
|
||||
qglShadeModel( GL_FLAT );
|
||||
|
||||
break;
|
||||
default:
|
||||
assert( 0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
glState.glStateBits = stateBits;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
** GL_StatePVR
|
||||
**
|
||||
** A bit slimmed down
|
||||
**
|
||||
*/
|
||||
void GL_StatePCX( unsigned long stateBits )
|
||||
static void GL_StatePCX( unsigned long stateBits )
|
||||
{
|
||||
unsigned long diff = stateBits ^ glState.glStateBits;
|
||||
|
||||
@@ -326,6 +532,10 @@ void GL_State( unsigned long stateBits )
|
||||
if (r_mockvr->integer){
|
||||
GL_StatePCX (stateBits);
|
||||
return;}
|
||||
if (softwaremode){
|
||||
GL_StateSW (stateBits);
|
||||
return;}
|
||||
|
||||
if ( !diff )
|
||||
{
|
||||
return;
|
||||
@@ -918,8 +1128,13 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
|
||||
tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;
|
||||
tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;
|
||||
qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
|
||||
if (softwaremode) { // leilei - software speedup
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
}else{
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
}
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
} else {
|
||||
@@ -960,8 +1175,13 @@ void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int
|
||||
tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;
|
||||
tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;
|
||||
qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
|
||||
if (softwaremode) { // leilei - software speedup
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
}else{
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
}
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
} else {
|
||||
|
@@ -107,6 +107,19 @@ GLvoid (APIENTRYP qglGetVertexAttribPointervARB) (GLuint index, GLenum pname, GL
|
||||
GLvoid (APIENTRYP qglColorTableEXT)( GLint, GLint, GLint, GLint, GLint, const GLvoid *);
|
||||
GLvoid (APIENTRYP qglColorTableSGI)( GLint, GLint, GLint, GLint, GLint, const GLvoid *);
|
||||
|
||||
/*
|
||||
typedef enum {
|
||||
GLHW_GENERIC, // where everthing works the way it should
|
||||
GLHW_3DFX_2D3D, // Voodoo Banshee or Voodoo3, relevant since if this is
|
||||
// the hardware type then there can NOT exist a secondary
|
||||
// display adapter
|
||||
GLHW_RIVA128, // where you can't interpolate alpha
|
||||
GLHW_RAGEPRO, // where you can't modulate alpha on alpha textures
|
||||
GLHW_PERMEDIA2 // where you don't have src*dst
|
||||
} glHardwareType2_t;
|
||||
*/
|
||||
|
||||
int softwaremode; // leilei - detect for software mode
|
||||
|
||||
/** From renderer_opengl2 (v28) */
|
||||
static qboolean GLimp_HaveExtension(const char *ext)
|
||||
@@ -260,4 +273,73 @@ void GLimp_InitExtraExtensions()
|
||||
ri.Cvar_Set( "r_ext_vertex_shader", "0");
|
||||
}
|
||||
|
||||
|
||||
// Vendor-specific graphics fixes because we need it for these cards
|
||||
char buf[1024];
|
||||
|
||||
// get our config strings
|
||||
Q_strncpyz( glConfig.vendor_string, (char *) qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) );
|
||||
Q_strncpyz( glConfig.renderer_string, (char *) qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) );
|
||||
if (*glConfig.renderer_string && glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] == '\n')
|
||||
glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] = 0;
|
||||
Q_strncpyz( glConfig.version_string, (char *) qglGetString (GL_VERSION), sizeof( glConfig.version_string ) );
|
||||
Q_strncpyz( glConfig.extensions_string, (char *) qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) );
|
||||
|
||||
|
||||
|
||||
Q_strncpyz( buf, glConfig.renderer_string, sizeof(buf) );
|
||||
Q_strlwr( buf );
|
||||
|
||||
|
||||
//
|
||||
// this is where hardware specific workarounds that should be
|
||||
// detected/initialized every startup should go.
|
||||
//
|
||||
if ( strstr( buf, "banshee" ) || strstr( buf, "voodoo3" ) )
|
||||
{
|
||||
glConfig.hardwareType = GLHW_3DFX_2D3D;
|
||||
}
|
||||
// VOODOO GRAPHICS w/ 2MB
|
||||
else if ( strstr( buf, "voodoo graphics/1 tmu/2 mb" ) )
|
||||
{
|
||||
}
|
||||
else if ( strstr( buf, "glzicd" ) )
|
||||
{
|
||||
}
|
||||
else if ( strstr( buf, "rage pro" ) || strstr( buf, "Rage Pro" ) || strstr( buf, "ragepro" ) )
|
||||
{
|
||||
glConfig.hardwareType = GLHW_RAGEPRO;
|
||||
}
|
||||
else if ( strstr( buf, "rage 128" ) )
|
||||
{
|
||||
}
|
||||
else if ( strstr( buf, "permedia2" ) )
|
||||
{
|
||||
glConfig.hardwareType = GLHW_PERMEDIA2;
|
||||
}
|
||||
else if ( strstr( buf, "sis" ) ) // unfortunately onboard SiS is a bit craptastic so give it permedia fallback as well
|
||||
{
|
||||
glConfig.hardwareType = GLHW_PERMEDIA2;
|
||||
}
|
||||
else if ( strstr( buf, "powervr" ) )
|
||||
{
|
||||
// glConfig.hardwareType = GLHW_PCX2;
|
||||
}
|
||||
else if ( strstr( buf, "generic" ) || strstr( buf, "brian" ) || strstr( buf, "paul" ) || strstr( buf, "GDI" ) ) // software mode opengl needs speedup tricks
|
||||
{
|
||||
//glConfig.hardwareType = GLHW_SOFTWARE;
|
||||
// ri.Cvar_Set( "r_texturemode", "GL_NEAREST" );
|
||||
// ri.Cvar_Set( "r_picmip", "2" );
|
||||
// ri.Cvar_Set( "r_detailtextures", "0" );
|
||||
// ri.Cvar_Set( "r_primitives", "2" );
|
||||
// ri.Cvar_Get( "r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
softwaremode = 1;
|
||||
}
|
||||
else if ( strstr( buf, "riva 128" ) )
|
||||
{
|
||||
glConfig.hardwareType = GLHW_RIVA128;
|
||||
}
|
||||
else if ( strstr( buf, "riva tnt " ) )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -1395,6 +1395,10 @@ done:
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_ALPHA);
|
||||
}
|
||||
if (softwaremode) { // leilei - software speedup
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
}
|
||||
GL_CheckErrors();
|
||||
|
||||
if ( scaledBuffer != 0 )
|
||||
@@ -1700,10 +1704,10 @@ done:
|
||||
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
}
|
||||
|
||||
// if (glConfig.hardwareType == GLHW_SOFTWARE ) { // leilei - software speedup
|
||||
// qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
// qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
// }
|
||||
if (softwaremode) { // leilei - software speedup
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
}
|
||||
|
||||
GL_CheckErrors();
|
||||
|
||||
|
@@ -2041,5 +2041,5 @@ void R_PostprocessingInit(void);
|
||||
void R_BrightScreen( void );
|
||||
void R_AltBrightnessInit( void );
|
||||
void R_FilmScreen( void ); // leilei - film effect
|
||||
|
||||
extern int softwaremode;
|
||||
#endif //TR_LOCAL_H
|
||||
|
Reference in New Issue
Block a user