diff --git a/README.md b/README.md index 09c8e589e..ddb07c1e2 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ with those projects are best fixed upstream and then merged into *DeepMind Lab*. * *ioquake3* is taken from [github.com/ioquake/ioq3](https://github.com/ioquake/ioq3), - revision 1c1e1f61f180596c925a4ac0eddba4806d1369cd. The code contains extensive + revision 0672905ef1b8f6ca219341e7252044dd727753dd. The code contains extensive modifications and additions. We aim to merge upstream changes occasionally. We are very grateful to the maintainers of these repositories for all their hard diff --git a/engine/code/renderercommon/qgl.h b/engine/code/renderercommon/qgl.h index 6d8629f6a..8b7367afa 100644 --- a/engine/code/renderercommon/qgl.h +++ b/engine/code/renderercommon/qgl.h @@ -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) \ diff --git a/engine/code/renderergl2/tr_animation.c b/engine/code/renderergl2/tr_animation.c index 4f333cb9b..9acd6fc79 100644 --- a/engine/code/renderergl2/tr_animation.c +++ b/engine/code/renderergl2/tr_animation.c @@ -414,8 +414,8 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) R_VaoPackNormal(tess.normal[baseVertex + j], tempNormal); - tess.texCoords[baseVertex + j][0][0] = v->texCoords[0]; - tess.texCoords[baseVertex + j][0][1] = v->texCoords[1]; + tess.texCoords[baseVertex + j][0] = v->texCoords[0]; + tess.texCoords[baseVertex + j][1] = v->texCoords[1]; v = (mdrVertex_t *)&v->weights[v->numWeights]; } diff --git a/engine/code/renderergl2/tr_backend.c b/engine/code/renderergl2/tr_backend.c index 004c1258a..bc0d5e740 100644 --- a/engine/code/renderergl2/tr_backend.c +++ b/engine/code/renderergl2/tr_backend.c @@ -895,29 +895,29 @@ const void *RB_StretchPic ( const void *data ) { tess.xyz[ numVerts ][1] = cmd->y; tess.xyz[ numVerts ][2] = 0; - tess.texCoords[ numVerts ][0][0] = cmd->s1; - tess.texCoords[ numVerts ][0][1] = cmd->t1; + tess.texCoords[ numVerts ][0] = cmd->s1; + tess.texCoords[ numVerts ][1] = cmd->t1; tess.xyz[ numVerts + 1 ][0] = cmd->x + cmd->w; tess.xyz[ numVerts + 1 ][1] = cmd->y; tess.xyz[ numVerts + 1 ][2] = 0; - tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + tess.texCoords[ numVerts + 1 ][0] = cmd->s2; + tess.texCoords[ numVerts + 1 ][1] = cmd->t1; tess.xyz[ numVerts + 2 ][0] = cmd->x + cmd->w; tess.xyz[ numVerts + 2 ][1] = cmd->y + cmd->h; tess.xyz[ numVerts + 2 ][2] = 0; - tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + tess.texCoords[ numVerts + 2 ][0] = cmd->s2; + tess.texCoords[ numVerts + 2 ][1] = cmd->t2; tess.xyz[ numVerts + 3 ][0] = cmd->x; tess.xyz[ numVerts + 3 ][1] = cmd->y + cmd->h; tess.xyz[ numVerts + 3 ][2] = 0; - tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; - tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; + tess.texCoords[ numVerts + 3 ][0] = cmd->s1; + tess.texCoords[ numVerts + 3 ][1] = cmd->t2; return (const void *)(cmd + 1); } @@ -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); } } } diff --git a/engine/code/renderergl2/tr_dsa.c b/engine/code/renderergl2/tr_dsa.c index f738a5d58..8fde8419e 100644 --- a/engine/code/renderergl2/tr_dsa.c +++ b/engine/code/renderergl2/tr_dsa.c @@ -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, diff --git a/engine/code/renderergl2/tr_dsa.h b/engine/code/renderergl2/tr_dsa.h index 44f32303b..84e35f56d 100644 --- a/engine/code/renderergl2/tr_dsa.h +++ b/engine/code/renderergl2/tr_dsa.h @@ -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, diff --git a/engine/code/renderergl2/tr_extensions.c b/engine/code/renderergl2/tr_extensions.c index 609303fa2..10ae3b851 100644 --- a/engine/code/renderergl2/tr_extensions.c +++ b/engine/code/renderergl2/tr_extensions.c @@ -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; @@ -159,8 +164,8 @@ void GLimp_InitExtraExtensions() { glRefConfig.framebufferObject = !!r_ext_framebuffer_object->integer; - glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); + qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); + qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); QGL_EXT_framebuffer_object_PROCS; diff --git a/engine/code/renderergl2/tr_fbo.c b/engine/code/renderergl2/tr_fbo.c index 41cfdd720..6b7ab01a2 100644 --- a/engine/code/renderergl2/tr_fbo.c +++ b/engine/code/renderergl2/tr_fbo.c @@ -230,6 +230,12 @@ FBO_Bind */ void FBO_Bind(FBO_t * fbo) { + if (!glRefConfig.framebufferObject) + { + ri.Printf(PRINT_WARNING, "FBO_Bind() called without framebuffers enabled!\n"); + return; + } + if (glState.currentFBO == fbo) return; @@ -265,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) diff --git a/engine/code/renderergl2/tr_flares.c b/engine/code/renderergl2/tr_flares.c index 7dd5ab8d0..54853cada 100644 --- a/engine/code/renderergl2/tr_flares.c +++ b/engine/code/renderergl2/tr_flares.c @@ -404,8 +404,8 @@ void RB_RenderFlare( flare_t *f ) { // FIXME: use quadstamp? tess.xyz[tess.numVertexes][0] = f->windowX - size; tess.xyz[tess.numVertexes][1] = f->windowY - size; - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 0; + tess.texCoords[tess.numVertexes][0] = 0; + tess.texCoords[tess.numVertexes][1] = 0; tess.color[tess.numVertexes][0] = iColor[0]; tess.color[tess.numVertexes][1] = iColor[1]; tess.color[tess.numVertexes][2] = iColor[2]; @@ -414,8 +414,8 @@ void RB_RenderFlare( flare_t *f ) { tess.xyz[tess.numVertexes][0] = f->windowX - size; tess.xyz[tess.numVertexes][1] = f->windowY + size; - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 1; + tess.texCoords[tess.numVertexes][0] = 0; + tess.texCoords[tess.numVertexes][1] = 1; tess.color[tess.numVertexes][0] = iColor[0]; tess.color[tess.numVertexes][1] = iColor[1]; tess.color[tess.numVertexes][2] = iColor[2]; @@ -424,8 +424,8 @@ void RB_RenderFlare( flare_t *f ) { tess.xyz[tess.numVertexes][0] = f->windowX + size; tess.xyz[tess.numVertexes][1] = f->windowY + size; - tess.texCoords[tess.numVertexes][0][0] = 1; - tess.texCoords[tess.numVertexes][0][1] = 1; + tess.texCoords[tess.numVertexes][0] = 1; + tess.texCoords[tess.numVertexes][1] = 1; tess.color[tess.numVertexes][0] = iColor[0]; tess.color[tess.numVertexes][1] = iColor[1]; tess.color[tess.numVertexes][2] = iColor[2]; @@ -434,8 +434,8 @@ void RB_RenderFlare( flare_t *f ) { tess.xyz[tess.numVertexes][0] = f->windowX + size; tess.xyz[tess.numVertexes][1] = f->windowY - size; - tess.texCoords[tess.numVertexes][0][0] = 1; - tess.texCoords[tess.numVertexes][0][1] = 0; + tess.texCoords[tess.numVertexes][0] = 1; + tess.texCoords[tess.numVertexes][1] = 0; tess.color[tess.numVertexes][0] = iColor[0]; tess.color[tess.numVertexes][1] = iColor[1]; tess.color[tess.numVertexes][2] = iColor[2]; diff --git a/engine/code/renderergl2/tr_image.c b/engine/code/renderergl2/tr_image.c index fea6d4e62..135616a00 100644 --- a/engine/code/renderergl2/tr_image.c +++ b/engine/code/renderergl2/tr_image.c @@ -2766,7 +2766,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; diff --git a/engine/code/renderergl2/tr_init.c b/engine/code/renderergl2/tr_init.c index c6610a9f3..7e41302c0 100644 --- a/engine/code/renderergl2/tr_init.c +++ b/engine/code/renderergl2/tr_init.c @@ -951,7 +951,9 @@ void GL_SetDefaultState( void ) qglColor4f (1,1,1,1); GL_BindNullTextures(); - GL_BindNullFramebuffers(); + + if (glRefConfig.framebufferObject) + GL_BindNullFramebuffers(); qglEnable(GL_TEXTURE_2D); GL_TextureMode( r_textureMode->string ); diff --git a/engine/code/renderergl2/tr_local.h b/engine/code/renderergl2/tr_local.h index 696081c7a..e6781b732 100644 --- a/engine/code/renderergl2/tr_local.h +++ b/engine/code/renderergl2/tr_local.h @@ -1373,6 +1373,8 @@ typedef struct { int openglMajorVersion; int openglMinorVersion; + qboolean intelGraphics; + qboolean drawRangeElements; qboolean multiDrawArrays; qboolean occlusionQuery; @@ -1983,7 +1985,8 @@ typedef struct shaderCommands_s vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); int16_t normal[SHADER_MAX_VERTEXES][4] QALIGN(16); int16_t tangent[SHADER_MAX_VERTEXES][4] QALIGN(16); - vec2_t texCoords[SHADER_MAX_VERTEXES][2] QALIGN(16); + vec2_t texCoords[SHADER_MAX_VERTEXES] QALIGN(16); + vec2_t lightCoords[SHADER_MAX_VERTEXES] QALIGN(16); uint16_t color[SHADER_MAX_VERTEXES][4] QALIGN(16); int16_t lightdir[SHADER_MAX_VERTEXES][4] QALIGN(16); //int vertexDlightBits[SHADER_MAX_VERTEXES] QALIGN(16); diff --git a/engine/code/renderergl2/tr_main.c b/engine/code/renderergl2/tr_main.c index 014457afa..cc33c7199 100644 --- a/engine/code/renderergl2/tr_main.c +++ b/engine/code/renderergl2/tr_main.c @@ -1333,8 +1333,8 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { return qfalse; // bad portal, no portalentity } - if (newParms.isMirror) - newParms.flags |= VPF_NOVIEWMODEL; + // Never draw viewmodels in portal or mirror views. + newParms.flags |= VPF_NOVIEWMODEL; R_MirrorPoint (oldParms.or.origin, &surface, &camera, newParms.or.origin ); diff --git a/engine/code/renderergl2/tr_model_iqm.c b/engine/code/renderergl2/tr_model_iqm.c index 79ee6674d..ce6d3610f 100644 --- a/engine/code/renderergl2/tr_model_iqm.c +++ b/engine/code/renderergl2/tr_model_iqm.c @@ -1026,7 +1026,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { vec4_t *outXYZ; int16_t *outNormal; int16_t *outTangent; - vec2_t (*outTexCoord)[2]; + vec2_t *outTexCoord; uint16_t *outColor; int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0; @@ -1096,10 +1096,8 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { nrmMat[ 7] = vtxMat[ 2]*vtxMat[ 4] - vtxMat[ 0]*vtxMat[ 6]; nrmMat[ 8] = vtxMat[ 0]*vtxMat[ 5] - vtxMat[ 1]*vtxMat[ 4]; - (*outTexCoord)[0][0] = data->texcoords[2*vtx + 0]; - (*outTexCoord)[0][1] = data->texcoords[2*vtx + 1]; - (*outTexCoord)[1][0] = (*outTexCoord)[0][0]; - (*outTexCoord)[1][1] = (*outTexCoord)[0][1]; + (*outTexCoord)[0] = data->texcoords[2*vtx + 0]; + (*outTexCoord)[1] = data->texcoords[2*vtx + 1]; (*outXYZ)[0] = vtxMat[ 0] * data->positions[3*vtx+0] + diff --git a/engine/code/renderergl2/tr_shade_calc.c b/engine/code/renderergl2/tr_shade_calc.c index e0f18e7f4..cb7bcf74d 100644 --- a/engine/code/renderergl2/tr_shade_calc.c +++ b/engine/code/renderergl2/tr_shade_calc.c @@ -208,7 +208,7 @@ void RB_CalcBulgeVertexes( deformStage_t *ds ) { now = backEnd.refdef.time * ds->bulgeSpeed * 0.001f; - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 4, normal += 4 ) { + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 2, normal += 4 ) { int off; float scale; vec3_t fNormal; diff --git a/engine/code/renderergl2/tr_sky.c b/engine/code/renderergl2/tr_sky.c index 3b4e860de..1ff0c0e86 100644 --- a/engine/code/renderergl2/tr_sky.c +++ b/engine/code/renderergl2/tr_sky.c @@ -386,8 +386,8 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max tess.xyz[tess.numVertexes][2] = s_skyPoints[t][s][2]; tess.xyz[tess.numVertexes][3] = 1.0; - tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0]; - tess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1]; + tess.texCoords[tess.numVertexes][0] = s_skyTexCoords[t][s][0]; + tess.texCoords[tess.numVertexes][1] = s_skyTexCoords[t][s][1]; tess.numVertexes++; @@ -563,8 +563,8 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) { VectorAdd( s_skyPoints[t][s], backEnd.viewParms.or.origin, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0]; - tess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1]; + tess.texCoords[tess.numVertexes][0] = s_skyTexCoords[t][s][0]; + tess.texCoords[tess.numVertexes][1] = s_skyTexCoords[t][s][1]; tess.numVertexes++; diff --git a/engine/code/renderergl2/tr_surface.c b/engine/code/renderergl2/tr_surface.c index 1ade59cd3..f624a1393 100644 --- a/engine/code/renderergl2/tr_surface.c +++ b/engine/code/renderergl2/tr_surface.c @@ -135,17 +135,17 @@ void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4], VectorCopy4(iNormal, tess.normal[ndx + 3]); // standard square texture coordinates - VectorSet2(tess.texCoords[ndx ][0], s1, t1); - VectorSet2(tess.texCoords[ndx ][1], s1, t1); + VectorSet2(tess.texCoords[ndx], s1, t1); + VectorSet2(tess.lightCoords[ndx], s1, t1); - VectorSet2(tess.texCoords[ndx+1][0], s2, t1); - VectorSet2(tess.texCoords[ndx+1][1], s2, t1); + VectorSet2(tess.texCoords[ndx+1], s2, t1); + VectorSet2(tess.lightCoords[ndx+1], s2, t1); - VectorSet2(tess.texCoords[ndx+2][0], s2, t2); - VectorSet2(tess.texCoords[ndx+2][1], s2, t2); + VectorSet2(tess.texCoords[ndx+2], s2, t2); + VectorSet2(tess.lightCoords[ndx+2], s2, t2); - VectorSet2(tess.texCoords[ndx+3][0], s1, t2); - VectorSet2(tess.texCoords[ndx+3][1], s1, t2); + VectorSet2(tess.texCoords[ndx+3], s1, t2); + VectorSet2(tess.lightCoords[ndx+3], s1, t2); // constant color all the way around // should this be identity and let the shader specify from entity? @@ -187,19 +187,19 @@ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) tess.firstIndex = 0; VectorCopy4(quadVerts[0], tess.xyz[tess.numVertexes]); - VectorCopy2(texCoords[0], tess.texCoords[tess.numVertexes][0]); + VectorCopy2(texCoords[0], tess.texCoords[tess.numVertexes]); tess.numVertexes++; VectorCopy4(quadVerts[1], tess.xyz[tess.numVertexes]); - VectorCopy2(texCoords[1], tess.texCoords[tess.numVertexes][0]); + VectorCopy2(texCoords[1], tess.texCoords[tess.numVertexes]); tess.numVertexes++; VectorCopy4(quadVerts[2], tess.xyz[tess.numVertexes]); - VectorCopy2(texCoords[2], tess.texCoords[tess.numVertexes][0]); + VectorCopy2(texCoords[2], tess.texCoords[tess.numVertexes]); tess.numVertexes++; VectorCopy4(quadVerts[3], tess.xyz[tess.numVertexes]); - VectorCopy2(texCoords[3], tess.texCoords[tess.numVertexes][0]); + VectorCopy2(texCoords[3], tess.texCoords[tess.numVertexes]); tess.numVertexes++; tess.indexes[tess.numIndexes++] = 0; @@ -298,8 +298,8 @@ static void RB_SurfacePolychain( srfPoly_t *p ) { numv = tess.numVertexes; for ( i = 0; i < p->numVerts; i++ ) { VectorCopy( p->verts[i].xyz, tess.xyz[numv] ); - tess.texCoords[numv][0][0] = p->verts[i].st[0]; - tess.texCoords[numv][0][1] = p->verts[i].st[1]; + tess.texCoords[numv][0] = p->verts[i].st[0]; + tess.texCoords[numv][1] = p->verts[i].st[1]; tess.color[numv][0] = (int)p->verts[i].modulate[0] * 257; tess.color[numv][1] = (int)p->verts[i].modulate[1] * 257; tess.color[numv][2] = (int)p->verts[i].modulate[2] * 257; @@ -369,16 +369,16 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) { dv = verts; - texCoords = tess.texCoords[ tess.numVertexes ][0]; - for ( i = 0 ; i < numVerts ; i++, dv++, texCoords+=4 ) + texCoords = tess.texCoords[tess.numVertexes]; + for ( i = 0 ; i < numVerts ; i++, dv++, texCoords+=2 ) VectorCopy2(dv->st, texCoords); } if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) { dv = verts; - lightCoords = tess.texCoords[ tess.numVertexes ][1]; - for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=4 ) + lightCoords = tess.lightCoords[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=2 ) VectorCopy2(dv->lightmap, lightCoords); } @@ -641,16 +641,16 @@ static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, f // FIXME: use quad stamp? VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 0; + tess.texCoords[tess.numVertexes][0] = 0; + tess.texCoords[tess.numVertexes][1] = 0; tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25f * 257.0f; tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25f * 257.0f; tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25f * 257.0f; tess.numVertexes++; VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 1; + tess.texCoords[tess.numVertexes][0] = 0; + tess.texCoords[tess.numVertexes][1] = 1; tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257; tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257; tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257; @@ -658,16 +658,16 @@ static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, f VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = t; - tess.texCoords[tess.numVertexes][0][1] = 0; + tess.texCoords[tess.numVertexes][0] = t; + tess.texCoords[tess.numVertexes][1] = 0; tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257; tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257; tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257; tess.numVertexes++; VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = t; - tess.texCoords[tess.numVertexes][0][1] = 1; + tess.texCoords[tess.numVertexes][0] = t; + tess.texCoords[tess.numVertexes][1] = 1; tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257; tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257; tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257; @@ -725,8 +725,8 @@ static void DoRailDiscs( int numSegs, const vec3_t start, const vec3_t dir, cons for ( j = 0; j < 4; j++ ) { VectorCopy( pos[j], tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = ( j < 2 ); - tess.texCoords[tess.numVertexes][0][1] = ( j && j != 3 ); + tess.texCoords[tess.numVertexes][0] = (j < 2); + tess.texCoords[tess.numVertexes][1] = (j && j != 3); tess.color[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 257; tess.color[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 257; tess.color[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 257; @@ -944,8 +944,8 @@ static void RB_SurfaceMesh(mdvSurface_t *surface) { numVerts = surface->numVerts; for ( j = 0; j < numVerts; j++ ) { - tess.texCoords[Doug + j][0][0] = texCoords[j].st[0]; - tess.texCoords[Doug + j][0][1] = texCoords[j].st[1]; + tess.texCoords[Doug + j][0] = texCoords[j].st[0]; + tess.texCoords[Doug + j][1] = texCoords[j].st[1]; // FIXME: fill in lightmapST for completeness? } @@ -1102,8 +1102,8 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) { xyz = tess.xyz[numVertexes]; normal = tess.normal[numVertexes]; tangent = tess.tangent[numVertexes]; - texCoords = tess.texCoords[numVertexes][0]; - lightCoords = tess.texCoords[numVertexes][1]; + texCoords = tess.texCoords[numVertexes]; + lightCoords = tess.lightCoords[numVertexes]; color = tess.color[numVertexes]; lightdir = tess.lightdir[numVertexes]; //vDlightBits = &tess.vertexDlightBits[numVertexes]; @@ -1134,13 +1134,13 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) { if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) { VectorCopy2(dv->st, texCoords); - texCoords += 4; + texCoords += 2; } if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) { VectorCopy2(dv->lightmap, lightCoords); - lightCoords += 4; + lightCoords += 2; } if ( tess.shader->vertexAttribs & ATTR_COLOR ) diff --git a/engine/code/renderergl2/tr_vbo.c b/engine/code/renderergl2/tr_vbo.c index 08dbed604..0ac63a409 100644 --- a/engine/code/renderergl2/tr_vbo.c +++ b/engine/code/renderergl2/tr_vbo.c @@ -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 @@ -428,7 +428,8 @@ void R_InitVaos(void) vertexesSize += sizeof(tess.normal[0]); vertexesSize += sizeof(tess.tangent[0]); vertexesSize += sizeof(tess.color[0]); - vertexesSize += sizeof(tess.texCoords[0][0]) * 2; + vertexesSize += sizeof(tess.texCoords[0]); + vertexesSize += sizeof(tess.lightCoords[0]); vertexesSize += sizeof(tess.lightdir[0]); vertexesSize *= SHADER_MAX_VERTEXES; @@ -470,29 +471,27 @@ void R_InitVaos(void) tess.vao->attribs[ATTR_INDEX_COLOR ].normalized = GL_TRUE; tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].normalized = GL_TRUE; - tess.vao->attribs[ATTR_INDEX_POSITION ].offset = offset; offset += sizeof(tess.xyz[0]) * SHADER_MAX_VERTEXES; - tess.vao->attribs[ATTR_INDEX_NORMAL ].offset = offset; offset += sizeof(tess.normal[0]) * SHADER_MAX_VERTEXES; - tess.vao->attribs[ATTR_INDEX_TANGENT ].offset = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; - // these next two are actually interleaved - tess.vao->attribs[ATTR_INDEX_TEXCOORD ].offset = offset; - tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].offset = offset + sizeof(tess.texCoords[0][0]); - offset += sizeof(tess.texCoords[0][0]) * 2 * SHADER_MAX_VERTEXES; - - tess.vao->attribs[ATTR_INDEX_COLOR ].offset = offset; offset += sizeof(tess.color[0]) * SHADER_MAX_VERTEXES; + tess.vao->attribs[ATTR_INDEX_POSITION ].offset = offset; offset += sizeof(tess.xyz[0]) * SHADER_MAX_VERTEXES; + tess.vao->attribs[ATTR_INDEX_NORMAL ].offset = offset; offset += sizeof(tess.normal[0]) * SHADER_MAX_VERTEXES; + tess.vao->attribs[ATTR_INDEX_TANGENT ].offset = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; + tess.vao->attribs[ATTR_INDEX_TEXCOORD ].offset = offset; offset += sizeof(tess.texCoords[0]) * SHADER_MAX_VERTEXES; + tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].offset = offset; offset += sizeof(tess.lightCoords[0]) * SHADER_MAX_VERTEXES; + tess.vao->attribs[ATTR_INDEX_COLOR ].offset = offset; offset += sizeof(tess.color[0]) * SHADER_MAX_VERTEXES; tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].offset = offset; tess.vao->attribs[ATTR_INDEX_POSITION ].stride = sizeof(tess.xyz[0]); tess.vao->attribs[ATTR_INDEX_NORMAL ].stride = sizeof(tess.normal[0]); tess.vao->attribs[ATTR_INDEX_TANGENT ].stride = sizeof(tess.tangent[0]); + tess.vao->attribs[ATTR_INDEX_TEXCOORD ].stride = sizeof(tess.texCoords[0]); + tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].stride = sizeof(tess.lightCoords[0]); tess.vao->attribs[ATTR_INDEX_COLOR ].stride = sizeof(tess.color[0]); - tess.vao->attribs[ATTR_INDEX_TEXCOORD ].stride = sizeof(tess.texCoords[0][0]) * 2; - tess.vao->attribs[ATTR_INDEX_LIGHTCOORD ].stride = sizeof(tess.texCoords[0][0]) * 2; tess.vao->attribs[ATTR_INDEX_LIGHTDIRECTION].stride = sizeof(tess.lightdir[0]); tess.attribPointers[ATTR_INDEX_POSITION] = tess.xyz; - tess.attribPointers[ATTR_INDEX_TEXCOORD] = tess.texCoords; tess.attribPointers[ATTR_INDEX_NORMAL] = tess.normal; tess.attribPointers[ATTR_INDEX_TANGENT] = tess.tangent; + tess.attribPointers[ATTR_INDEX_TEXCOORD] = tess.texCoords; + tess.attribPointers[ATTR_INDEX_LIGHTCOORD] = tess.lightCoords; tess.attribPointers[ATTR_INDEX_COLOR] = tess.color; tess.attribPointers[ATTR_INDEX_LIGHTDIRECTION] = tess.lightdir; @@ -613,14 +612,6 @@ void RB_UpdateTessVao(unsigned int attribBits) attribUpload = attribBits; - if((attribUpload & ATTR_TEXCOORD) || (attribUpload & ATTR_LIGHTCOORD)) - { - // these are interleaved, so we update both if either need it - // this translates to updating ATTR_TEXCOORD twice as large as it needs - attribUpload &= ~ATTR_LIGHTCOORD; - attribUpload |= ATTR_TEXCOORD; - } - for (attribIndex = 0; attribIndex < ATTR_INDEX_COUNT; attribIndex++) { uint32_t attribBit = 1 << attribIndex; diff --git a/engine/code/server/sv_client.c b/engine/code/server/sv_client.c index d45c49d79..ad759eff2 100644 --- a/engine/code/server/sv_client.c +++ b/engine/code/server/sv_client.c @@ -488,7 +488,7 @@ void SV_DirectConnect( netadr_t from ) { // check for privateClient password password = Info_ValueForKey( userinfo, "password" ); - if ( !strcmp( password, sv_privatePassword->string ) ) { + if ( *password && !strcmp( password, sv_privatePassword->string ) ) { startIndex = 0; } else { // skip past the reserved slots