diff --git a/docs/licenses/xBRZ.jpg b/docs/licenses/xBRZ.jpg new file mode 100644 index 000000000..ab8335391 Binary files /dev/null and b/docs/licenses/xBRZ.jpg differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dfac22fe0..57b65871c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -849,6 +849,7 @@ file( GLOB HEADER_FILES gl/dynlights/*.h gl/hqnx/*.h gl/hqnx_asm/*.h + gl/xbr/*.h gl/models/*.h gl/renderer/*.h gl/scene/*.h @@ -1072,6 +1073,8 @@ set( FASTMATH_SOURCES gl/hqnx/hq2x.cpp gl/hqnx/hq3x.cpp gl/hqnx/hq4x.cpp + gl/xbr/xbrz.cpp + gl/xbr/xbrz_old.cpp gl/textures/gl_hwtexture.cpp gl/textures/gl_texture.cpp gl/textures/gl_material.cpp @@ -1542,7 +1545,8 @@ source_group("OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/ source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+") source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+") source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+") -source_group("OpenGL Renderer\\HQ Resize Assembly version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+") +source_group("OpenGL Renderer\\HQ Resize MMX version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+") +source_group("OpenGL Renderer\\XBRZ" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+") source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+") source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+") source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+") diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 88a1de2b8..0efff5508 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -10,6 +10,15 @@ struct secplane_t; struct subsector_t; struct sector_t; +enum +{ + VATTR_VERTEX_BIT, + VATTR_TEXCOORD_BIT, + VATTR_COLOR_BIT, + VATTR_VERTEX2_BIT, + VATTR_NORMAL_BIT +}; + class FVertexBuffer { @@ -20,6 +29,7 @@ public: FVertexBuffer(bool wantbuffer = true); virtual ~FVertexBuffer(); virtual void BindVBO() = 0; + void EnableBufferArrays(int enable, int disable); }; struct FFlatVertex diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 31aea734c..82b63aa00 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -680,8 +680,6 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) } if (gl.legacyMode) { - int cm = gl_RenderState.GetFixedColormap(); - gl_RenderState.SetFixedColormap(cm); gl_RenderState.DrawColormapOverlay(); } diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 52ca59ec7..e205d0cf8 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -12,7 +12,8 @@ enum VATTR_VERTEX = 0, VATTR_TEXCOORD = 1, VATTR_COLOR = 2, - VATTR_VERTEX2 = 3 + VATTR_VERTEX2 = 3, + VATTR_NORMAL = 4 }; diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 0af793e58..fe523c79d 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -43,15 +43,21 @@ #ifdef HAVE_MMX #include "gl/hqnx_asm/hqnx_asm.h" #endif +#include "gl/xbr/xbrz.h" +#include "gl/xbr/xbrz_old.h" CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { -#ifdef HAVE_MMX - if (self < 0 || self > 9) -#else - if (self < 0 || self > 6) -#endif + if (self < 0 || self > 16) + { self = 0; + } + #ifndef HAVE_MMX + // This is to allow the menu option to work properly so that these filters can be skipped while cycling through them. + if (self == 7) self = 10; + if (self == 8) self = 10; + if (self == 9) self = 6; + #endif GLRenderer->FlushTextures(); } @@ -242,6 +248,42 @@ static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, i } + +static unsigned char *xbrzHelper( void (*xbrzFunction) ( size_t, const uint32_t*, uint32_t*, int, int, xbrz::ColorFormat, const xbrz::ScalerCfg&, int, int ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight, xbrz::ARGB, xbrz::ScalerCfg(), 0, std::numeric_limits::max()); + delete[] inputBuffer; + return newBuffer; +} + +static unsigned char *xbrzoldHelper( void (*xbrzFunction) ( size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz_old::ScalerCfg& cfg, int yFirst, int yLast ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight, xbrz_old::ScalerCfg(), 0, std::numeric_limits::max()); + delete[] inputBuffer; + return newBuffer; +} + + //=========================================================================== // // [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns @@ -322,6 +364,16 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u case 9: return hqNxAsmHelper( &HQnX_asm::hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); #endif + case 10: + case 11: + case 12: + return xbrzHelper(xbrz::scale, type - 8, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + + case 13: + case 14: + case 15: + return xbrzoldHelper(xbrz_old::scale, type - 11, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + } } return inputBuffer; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 2386b1076..86e2d5dc0 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -134,6 +134,12 @@ OptionValue "HqResizeModes" 7, "$OPTVAL_HQ2XMMX" 8, "$OPTVAL_HQ3XMMX" 9, "$OPTVAL_HQ4XMMX" + 10, "xBRZ 2x" + 11, "xBRZ 3x" + 12, "xBRZ 4x" + 13, "xBRZ_old 2x" + 14, "xBRZ_old 3x" + 15, "xBRZ_old 4x" } OptionValue "FogMode"