From 571f7a4eb6b85f6ac24e92156df92693f27a36a6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 24 Dec 2015 10:32:19 +0200 Subject: [PATCH 1/5] - fixed: debug assertion failure in texture precaching loading of level from command line attempted to use uninitialized time value --- src/textures/texturemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 3de5016fd..0612fa792 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -1239,7 +1239,7 @@ void FTextureManager::PrecacheLevel (void) if (demoplayback) return; - precacheTime = I_MSTime(); + precacheTime = I_FPSTime(); hitlist = new BYTE[cnt]; memset (hitlist, 0, cnt); From 19ae244f66fdda01de08b0db458aa0a5a486d024 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 24 Dec 2015 10:33:30 +0200 Subject: [PATCH 2/5] - fixed: allow to use all hqNx texture upscale modes --- src/gl/textures/gl_hqresize.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index a4f192ce8..621f444bc 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -46,7 +46,11 @@ CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { +#ifdef _MSC_VER + if (self < 0 || self > 9) +#else if (self < 0 || self > 6) +#endif self = 0; GLRenderer->FlushTextures(); } From 69813993b0e023b2452da1a9097cac1a393e7c23 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 24 Dec 2015 11:13:31 +0200 Subject: [PATCH 3/5] - added missing hqNx modes to options menu --- src/gl/system/gl_menu.cpp | 14 ++++++++++++++ wadsrc/static/menudef.z | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index a9167b7a6..41304be0f 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -57,4 +57,18 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // when they are actually valid. void gl_SetupMenu() { +#ifndef _MSC_VER + FOptionValues **opt = OptionValues.CheckKey("HqResizeModes"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete HQnX resize modes for non MSVC targets + if ((*opt)->mValues[i].Value >= 7.0) + { + (*opt)->mValues.Delete(i); + } + } + } +#endif } diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 75ea1bf5f..ffe67ee51 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -103,6 +103,9 @@ OptionValue "HqResizeModes" 4, "hq2x" 5, "hq3x" 6, "hq4x" + 7, "hq2x MMX" + 8, "hq3x MMX" + 9, "hq4x MMX" } OptionValue "FogMode" From 1c5d0ccd65e8a8ae631fd3160abf808fb26635d6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 25 Dec 2015 15:41:06 +0200 Subject: [PATCH 4/5] - enabled hqNx MMX on all platforms with Intel intrinsics support --- src/CMakeLists.txt | 39 +++++++++++++++++++++++++++++---- src/gl/system/gl_menu.cpp | 2 +- src/gl/textures/gl_hqresize.cpp | 11 +++++----- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9332e4919..d4da7e7ce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -449,6 +449,22 @@ else( SSE_MATTERS ) set( BACKPATCH 0 ) endif( SSE_MATTERS ) +if( X64 ) + set( HAVE_MMX 1 ) +else( X64 ) + set( SAFE_CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ) + + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmmx") + endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + + CHECK_CXX_SOURCE_COMPILES("#include + int main(void) { __m64 v = _m_from_int(0); }" + HAVE_MMX) + + set( CMAKE_C_FLAGS ${SAFE_CMAKE_C_FLAGS} ) +endif( X64 ) + # Set up flags for GCC if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) @@ -581,10 +597,6 @@ endif( NOT DYN_FLUIDSYNTH ) # Start defining source files for ZDoom set( PLAT_WIN32_SOURCES - gl/hqnx_asm/hq2x_asm.cpp - gl/hqnx_asm/hq3x_asm.cpp - gl/hqnx_asm/hq4x_asm.cpp - gl/hqnx_asm/hqnx_asm_Image.cpp win32/eaxedit.cpp win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp @@ -668,6 +680,25 @@ else( WIN32 ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ) endif( WIN32 ) +if( HAVE_MMX ) + add_definitions( -DHAVE_MMX=1 ) + + set( SYSTEM_SOURCES ${SYSTEM_SOURCES} + gl/hqnx_asm/hq2x_asm.cpp + gl/hqnx_asm/hq3x_asm.cpp + gl/hqnx_asm/hq4x_asm.cpp + gl/hqnx_asm/hqnx_asm_Image.cpp) + + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + set_source_files_properties( + gl/hqnx_asm/hq2x_asm.cpp + gl/hqnx_asm/hq3x_asm.cpp + gl/hqnx_asm/hq4x_asm.cpp + gl/textures/gl_hqresize.cpp + PROPERTIES COMPILE_FLAGS "-mmmx" ) + endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) +endif( HAVE_MMX ) + if( NOT ASM_SOURCES ) set( ASM_SOURCES "" ) endif( NOT ASM_SOURCES ) diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 41304be0f..d4688cfd1 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -57,7 +57,7 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // when they are actually valid. void gl_SetupMenu() { -#ifndef _MSC_VER +#ifndef HAVE_MMX FOptionValues **opt = OptionValues.CheckKey("HqResizeModes"); if (opt != NULL) { diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 621f444bc..261f66e6a 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -40,13 +40,13 @@ #include "gl/textures/gl_texture.h" #include "c_cvars.h" #include "gl/hqnx/hqx.h" -#ifdef _MSC_VER +#ifdef HAVE_MMX #include "gl/hqnx_asm/hqnx_asm.h" #endif CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { -#ifdef _MSC_VER +#ifdef HAVE_MMX if (self < 0 || self > 9) #else if (self < 0 || self > 6) @@ -186,8 +186,7 @@ static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32* return newBuffer; } -// [BB] hqnx scaling is only supported with the MS compiler. -#ifdef _MSC_VER +#ifdef HAVE_MMX static unsigned char *hqNxAsmHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ), const int N, unsigned char *inputBuffer, @@ -285,7 +284,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u outWidth = inWidth; outHeight = inHeight; int type = gl_texture_hqresize; -#ifdef _MSC_VER +#ifdef HAVE_MMX // ASM-hqNx does not preserve the alpha channel so fall back to C-version for such textures if (!hasAlpha && type > 3 && type <= 6) { @@ -307,7 +306,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); case 6: return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); -#ifdef _MSC_VER +#ifdef HAVE_MMX case 7: return hqNxAsmHelper( &HQnX_asm::hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); case 8: From f8c38a0bbe9571dee33ed722d96b67ac016074c5 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 25 Dec 2015 15:42:13 +0200 Subject: [PATCH 5/5] - fixed GCC's 'unknown pragma' warnings in hqNx MMX implementation --- src/gl/hqnx_asm/hqnx_asm.h | 2 ++ src/gl/hqnx_asm/hqnx_asm_Image.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gl/hqnx_asm/hqnx_asm.h b/src/gl/hqnx_asm/hqnx_asm.h index 2580f80ef..9ced349fa 100644 --- a/src/gl/hqnx_asm/hqnx_asm.h +++ b/src/gl/hqnx_asm/hqnx_asm.h @@ -21,7 +21,9 @@ #ifndef __HQNX_H__ #define __HQNX_H__ +#ifdef _MSC_VER #pragma warning(disable:4799) +#endif // _MSC_VER #include "hqnx_asm_Image.h" diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.h b/src/gl/hqnx_asm/hqnx_asm_Image.h index 8f57d7865..e4157a7b5 100644 --- a/src/gl/hqnx_asm/hqnx_asm_Image.h +++ b/src/gl/hqnx_asm/hqnx_asm_Image.h @@ -24,7 +24,9 @@ #include #pragma once +#ifdef _MSC_VER #pragma warning(disable: 4103) +#endif // _MSC_VER #pragma pack(1) namespace HQnX_asm