diff --git a/changelog.txt b/changelog.txt index 07165d3..d506078 100644 --- a/changelog.txt +++ b/changelog.txt @@ -91,6 +91,8 @@ chg: with r_backend GL3, depth fade with MSAA now requires GLSL 4.00 at a minimu chg: with r_backend GL3, alpha to coverage now requires GLSL 4.00 at a minimum +fix: the reported MSAA sample counts for the GL2 and GL3 back-ends could be wrong + fix: registration of a read-only CVar would keep the existing value fix: the Direct3D projection transform didn't perfectly match the OpenGL version diff --git a/code/renderer/tr_backend_d3d11.cpp b/code/renderer/tr_backend_d3d11.cpp index 7fbfd4a..9bf087a 100644 --- a/code/renderer/tr_backend_d3d11.cpp +++ b/code/renderer/tr_backend_d3d11.cpp @@ -1833,6 +1833,7 @@ static qbool GAL_Init() glInfo.depthFadeSupport = r_depthFade->integer == 1; glInfo.mipGenSupport = mipGenOK; glInfo.alphaToCoverageSupport = alphaToCoverageOK; + glInfo.msaaSampleCount = sampleDesc.Count; if(fullInit) { @@ -1881,8 +1882,6 @@ static qbool GAL_Init() d3d.splitBufferOffsets = r_d3d11_syncOffsets->integer == D3D11SO_SPLITOFFSETS; } - ri.Printf(PRINT_ALL, "MSAA: %d samples requested, %d selected\n", r_msaa->integer, sampleDesc.Count); - return qtrue; } diff --git a/code/renderer/tr_backend_gl2.cpp b/code/renderer/tr_backend_gl2.cpp index 574f35b..aa7e424 100644 --- a/code/renderer/tr_backend_gl2.cpp +++ b/code/renderer/tr_backend_gl2.cpp @@ -501,6 +501,11 @@ static void GL2_CreateColorRenderBufferStorageMS( int* samples ) if ( errorCode != GL_NO_ERROR ) ri.Error( ERR_FATAL, "Failed to create multi-sampled render buffer storage (error 0x%X)\n", (unsigned int)errorCode ); + GLint realSampleCount = 0; + glGetRenderbufferParameteriv( GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &realSampleCount ); + if ( glGetError() == GL_NO_ERROR && realSampleCount > 0 ) + sampleCount = realSampleCount; + *samples = sampleCount; } @@ -599,8 +604,7 @@ static qbool GL2_FBO_Init() GL2_FBO_CreateSS( frameBuffersPostProcess[1], qtrue ); } - if ( result ) - ri.Printf( PRINT_ALL, "MSAA: %d samples requested, %d selected\n", r_msaa->integer, finalSampleCount ); + glInfo.msaaSampleCount = finalSampleCount; return result; } diff --git a/code/renderer/tr_backend_gl3.cpp b/code/renderer/tr_backend_gl3.cpp index f013cb4..141635f 100644 --- a/code/renderer/tr_backend_gl3.cpp +++ b/code/renderer/tr_backend_gl3.cpp @@ -958,6 +958,13 @@ static void CreateColorTextureStorageMS(int* samples) ri.Error(ERR_FATAL, "Failed to create multi-sampled texture storage (error 0x%X)\n", (unsigned int)errorCode); } + GLint realSampleCount = 0; + glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0, GL_TEXTURE_SAMPLES, &realSampleCount); + if(glGetError() == GL_NO_ERROR && realSampleCount > 0) + { + sampleCount = realSampleCount; + } + *samples = sampleCount; } @@ -1058,7 +1065,7 @@ static void FBO_Init() FBO_CreateSS(&gl.fbSS[1], qtrue, qtrue, "post-process #2"); } - ri.Printf(PRINT_ALL, "MSAA: %d samples requested, %d selected\n", r_msaa->integer, finalSampleCount); + glInfo.msaaSampleCount = finalSampleCount; } static void FBO_Bind(const FrameBuffer* fb) diff --git a/code/renderer/tr_init.cpp b/code/renderer/tr_init.cpp index 3c5786b..742baa3 100644 --- a/code/renderer/tr_init.cpp +++ b/code/renderer/tr_init.cpp @@ -325,8 +325,9 @@ void GfxInfo_f( void ) ri.Printf( PRINT_ALL, "Renderer: %s\n", glConfig.renderer_string ); if ( glConfig.version_string[0] != '\0' ) ri.Printf( PRINT_ALL, "OpenGL version: %s\n", glConfig.version_string ); + ri.Printf( PRINT_ALL, "MSAA : %dx\n", glInfo.msaaSampleCount ); + ri.Printf( PRINT_ALL, "MSAA alpha to coverage: %s\n", glInfo.alphaToCoverageSupport ? "ON" : "OFF" ); ri.Printf( PRINT_ALL, "Depth fade : %s\n", glInfo.depthFadeSupport ? "ON" : "OFF" ); - ri.Printf( PRINT_ALL, "Alpha to coverage : %s\n", glInfo.alphaToCoverageSupport ? "ON" : "OFF" ); ri.Printf( PRINT_ALL, "GPU mip-map generation: %s\n", glInfo.mipGenSupport ? "ON" : "OFF" ); gal.PrintInfo(); } diff --git a/code/renderer/tr_local.h b/code/renderer/tr_local.h index f5f0959..da1059c 100644 --- a/code/renderer/tr_local.h +++ b/code/renderer/tr_local.h @@ -1676,6 +1676,7 @@ struct glinfo_t { qbool depthFadeSupport; qbool mipGenSupport; qbool alphaToCoverageSupport; + int msaaSampleCount; // active number of samples, can differ from r_msaa->integer }; extern glinfo_t glInfo;