OpenGL2: Detect Intel graphics and avoid/use certain operations there.

Also use qglCopyTextureSubImage2DEXT instead of qglCopyTextureImage2DEXT.
This commit is contained in:
SmileTheory 2016-12-07 22:30:55 -08:00
parent 730207817e
commit 0672905ef1
9 changed files with 22 additions and 13 deletions

View file

@ -622,7 +622,7 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
GLE(GLvoid, TextureParameteriEXT, GLuint texture, GLenum target, GLenum pname, GLint param) \
GLE(GLvoid, TextureImage2DEXT, GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) \
GLE(GLvoid, TextureSubImage2DEXT, GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) \
GLE(GLvoid, CopyTextureImage2DEXT, GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) \
GLE(GLvoid, CopyTextureSubImage2DEXT, GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) \
GLE(GLvoid, CompressedTextureImage2DEXT, GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) \
GLE(GLvoid, CompressedTextureSubImage2DEXT, GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) \
GLE(GLvoid, GenerateTextureMipmapEXT, GLuint texture, GLenum target) \

View file

@ -971,7 +971,9 @@ const void *RB_DrawSurfs( const void *data ) {
else if (tr.renderFbo == NULL && tr.renderDepthImage)
{
// If we're rendering directly to the screen, copy the depth to a texture
qglCopyTextureImage2DEXT(tr.renderDepthImage->texnum, GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 0, 0, glConfig.vidWidth, glConfig.vidHeight, 0);
// This is incredibly slow on Intel Graphics, so just skip it on there
if (!glRefConfig.intelGraphics)
qglCopyTextureSubImage2DEXT(tr.renderDepthImage->texnum, GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight);
}
if (tr.hdrDepthFbo)
@ -1475,14 +1477,14 @@ const void *RB_CapShadowMap(const void *data)
{
if (tr.shadowCubemaps[cmd->map])
{
qglCopyTextureImage2DEXT(tr.shadowCubemaps[cmd->map]->texnum, GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0);
qglCopyTextureSubImage2DEXT(tr.shadowCubemaps[cmd->map]->texnum, GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE);
}
}
else
{
if (tr.pshadowMaps[cmd->map])
{
qglCopyTextureImage2DEXT(tr.pshadowMaps[cmd->map]->texnum, GL_TEXTURE_2D, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - (backEnd.refdef.y + PSHADOW_MAP_SIZE), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0);
qglCopyTextureSubImage2DEXT(tr.pshadowMaps[cmd->map]->texnum, GL_TEXTURE_2D, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - (backEnd.refdef.y + PSHADOW_MAP_SIZE), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE);
}
}
}

View file

@ -113,11 +113,11 @@ GLvoid APIENTRY GLDSA_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint
qglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
GLvoid APIENTRY GLDSA_CopyTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat,
GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
GLvoid APIENTRY GLDSA_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height)
{
GL_BindMultiTexture(glDsaState.texunit, target, texture);
qglCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
qglCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
GLvoid APIENTRY GLDSA_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat,

View file

@ -33,8 +33,8 @@ GLvoid APIENTRY GLDSA_TextureImage2DEXT(GLuint texture, GLenum target, GLint lev
GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
GLvoid APIENTRY GLDSA_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
GLvoid APIENTRY GLDSA_CopyTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat,
GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GLvoid APIENTRY GLDSA_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height);
GLvoid APIENTRY GLDSA_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
GLvoid APIENTRY GLDSA_CompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,

View file

@ -63,6 +63,11 @@ void GLimp_InitExtraExtensions()
ri.Error(ERR_FATAL, "OpenGL 2.0 required!");
ri.Printf(PRINT_ALL, "...using OpenGL %s\n", glConfig.version_string);
// Check if we need Intel graphics specific fixes.
glRefConfig.intelGraphics = qfalse;
if (strstr((char *)qglGetString(GL_RENDERER), "Intel"))
glRefConfig.intelGraphics = qtrue;
// set DSA fallbacks
#define GLE(ret, name, ...) qgl##name = GLDSA_##name;
QGL_EXT_direct_state_access_PROCS;

View file

@ -271,7 +271,7 @@ void FBO_Init(void)
R_IssuePendingRenderCommands();
hdrFormat = GL_RGBA8;
if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat)
if (r_hdr->integer && glRefConfig.textureFloat)
hdrFormat = GL_RGBA16F_ARB;
if (glRefConfig.framebufferMultisample)

View file

@ -2761,7 +2761,7 @@ void R_CreateBuiltinImages( void ) {
height = glConfig.vidHeight;
hdrFormat = GL_RGBA8;
if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat)
if (r_hdr->integer && glRefConfig.textureFloat)
hdrFormat = GL_RGBA16F_ARB;
rgbFormat = GL_RGBA8;

View file

@ -1373,6 +1373,8 @@ typedef struct {
int openglMajorVersion;
int openglMinorVersion;
qboolean intelGraphics;
qboolean drawRangeElements;
qboolean multiDrawArrays;
qboolean occlusionQuery;

View file

@ -360,8 +360,8 @@ void R_BindVao(vao_t * vao)
{
qglBindVertexArray(vao->vao);
// why you no save GL_ELEMENT_ARRAY_BUFFER binding, Intel?
if (1)
// Intel Graphics doesn't save GL_ELEMENT_ARRAY_BUFFER binding with VAO binding.
if (glRefConfig.intelGraphics || vao == tess.vao)
qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vao->indexesIBO);
// tess VAO always has buffers bound