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, 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, 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, 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, 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, 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) \ 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) else if (tr.renderFbo == NULL && tr.renderDepthImage)
{ {
// If we're rendering directly to the screen, copy the depth to a texture // 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) if (tr.hdrDepthFbo)
@ -1475,14 +1477,14 @@ const void *RB_CapShadowMap(const void *data)
{ {
if (tr.shadowCubemaps[cmd->map]) 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 else
{ {
if (tr.pshadowMaps[cmd->map]) 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); qglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
} }
GLvoid APIENTRY GLDSA_CopyTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLvoid APIENTRY GLDSA_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height, GLint border) GLint x, GLint y, GLsizei width, GLsizei height)
{ {
GL_BindMultiTexture(glDsaState.texunit, target, texture); 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, 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); 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, 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); GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
GLvoid APIENTRY GLDSA_CopyTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLvoid APIENTRY GLDSA_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GLint x, GLint y, GLsizei width, GLsizei height);
GLvoid APIENTRY GLDSA_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLvoid APIENTRY GLDSA_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
GLvoid APIENTRY GLDSA_CompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, 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.Error(ERR_FATAL, "OpenGL 2.0 required!");
ri.Printf(PRINT_ALL, "...using OpenGL %s\n", glConfig.version_string); 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 // set DSA fallbacks
#define GLE(ret, name, ...) qgl##name = GLDSA_##name; #define GLE(ret, name, ...) qgl##name = GLDSA_##name;
QGL_EXT_direct_state_access_PROCS; QGL_EXT_direct_state_access_PROCS;

View File

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

View File

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

View File

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

View File

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