From ef8f66c9a1acd6df65e5d6700305e4e391b8cb26 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Jul 2014 23:13:16 +0200 Subject: [PATCH] - removed the code for hardware alpha testing again because it didn't work anymore with how things are set up now. - we need to check all GL versions when trying to get a context because some drivers only give us the version we request, leaving out newer features that are not exposed via extension. - added some status info about uniform blocks. --- src/gl/renderer/gl_renderstate.cpp | 24 +------------------ src/gl/system/gl_interface.cpp | 4 ++++ src/gl/system/gl_interface.h | 1 + src/gl/textures/gl_hwtexture.cpp | 2 ++ src/win32/win32gliface.cpp | 31 +++++++------------------ wadsrc/static/shaders/glsl/main.fp | 4 +--- wadsrc/static/shaders/glsl/shaderdefs.i | 2 -- 7 files changed, 17 insertions(+), 51 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index bee49cd969..24492c4955 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -138,29 +138,7 @@ bool FRenderState::ApplyShader() activeShader->muClipHeightTop.Set(mClipHeightTop); activeShader->muClipHeightBottom.Set(mClipHeightBottom); activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); - -#ifndef CORE_PROFILE - if (!(gl.flags & RFL_COREPROFILE)) - { - if (mAlphaThreshold != stAlphaThreshold) - { - stAlphaThreshold = mAlphaThreshold; - if (mAlphaThreshold < 0.f) - { - glDisable(GL_ALPHA_TEST); - } - else - { - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, mAlphaThreshold * mColor.vec[3]); - } - } - } - else -#endif - { - activeShader->muAlphaThreshold.Set(mAlphaThreshold); - } + activeShader->muAlphaThreshold.Set(mAlphaThreshold); if (mGlowEnabled) { diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index ca40bc60e0..404c068d70 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -175,6 +175,9 @@ void gl_PrintStartupLog() gl.maxuniforms = v; glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); Printf ("Max. vertex uniforms: %d\n", v); + glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); + Printf ("Max. uniform block size: %d\n", v); + gl.maxuniformblock = v; glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); @@ -182,5 +185,6 @@ void gl_PrintStartupLog() glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); Printf("Max. vertex shader storage blocks: %d\n", v); + } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index d33ce77fc2..a881339292 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -29,6 +29,7 @@ struct RenderContext { unsigned int flags; unsigned int maxuniforms; + unsigned int maxuniformblock; float version; float glslversion; int max_texturesize; diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 516b5aaf55..98229a1cab 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -192,6 +192,8 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i if (alphatexture) { // thanks to deprecation and delayed introduction of a suitable replacement feature this has become a bit messy... + // Of all the targeted hardware, the Intel GMA 2000 and 3000 are the only ones not supporting texture swizzle, and they + // are also the only ones not supoorting GL 3.3. On those we are forced to use a full RGBA texture here. if (gl.version >= 3.3f) { texformat = GL_R8; diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 3b630177ad..a0e55d6733 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -745,37 +745,22 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) #else bool core = true; #endif - if (core) - { - // let's try to get the best version possible. - static int versions[] = { 44, 43, 42, 41, 40, 33, 32, -1 }; + // let's try to get the best version possible. Some drivers only give us the version we request + // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement. + static int versions[] = { 44, 43, 42, 41, 40, 33, 32, 30, -1 }; - for (int i = 0; versions[i] > 0; i++) - { - int ctxAttribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, - WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, - WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; - - m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); - if (m_hRC != NULL) break; - } - } - else + for (int i = 0; versions[i] > 0; i++) { int ctxAttribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 0, + WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, + WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, core? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0 }; m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); - + if (m_hRC != NULL) break; } } if (m_hRC == 0) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index a4e4d782b3..482afc0cab 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -222,12 +222,10 @@ void main() { vec4 frag = ProcessTexel(); -#ifdef CORE_PROFILE - // alpha testing - only for the core profile, in compatibility mode we use the alpha test. +#ifndef NO_ALPHATEST if (frag.a <= uAlphaThreshold) discard; #endif - switch (uFixedColormap) { case 0: diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 242b7244b7..d310126ab2 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -8,9 +8,7 @@ uniform vec4 uCameraPos; uniform int uTextureMode; uniform float uClipHeightTop, uClipHeightBottom; -#ifdef CORE_PROFILE uniform float uAlphaThreshold; -#endif // colors