Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound: added optimized x86_64 mixing for mingw and unix builds #234

Merged
merged 2 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,11 @@ ifndef MINGW
endif
endif

ifeq ($(ARCH),x86_64)
Q3OBJ += \
$(B)/client/snd_mix_x86_64.o
endif

ifeq ($(HAVE_VM_COMPILED),true)
ifeq ($(ARCH),x86)
Q3OBJ += $(B)/client/vm_x86.o
Expand Down
126 changes: 126 additions & 0 deletions code/asm/snd_mix_x86_64.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#if defined(__APPLE__)
#undef ELF
#endif

#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif

#ifdef ELF
#define C(label) label
#else
#define C(label) _##label
#endif

.intel_syntax noprefix

.text

.globl C(S_WriteLinearBlastStereo16_SSE_x64)
C(S_WriteLinearBlastStereo16_SSE_x64):
push rbx
#ifdef _WIN32
// RCX RDX R8 R9
push rsi
push rdi
mov rsi, rcx
mov rdi, rdx
mov ebx, r8d
#else
// RDI RSI RDX RCX R8 R9
xchg rsi, rdi
mov ebx, edx
#endif
test ebx,ebx
jz LExit
mov ecx,esi
and ecx,63
jz LMain
and ecx,3
jnz LTail
shr ecx,2
not ecx
add ecx,17
LClamp1:
mov eax,[rsi]
sar eax,8
cmp eax,32767
jg LClampHigh1
cmp eax,-32768
jnl LClampDone1
mov eax,-32768
jmp LClampDone1
LClampHigh1:
mov eax,32767
LClampDone1:
mov [rdi],ax
add rsi,4
add rdi,2
dec ebx
jz LExit
dec ecx
jnz LClamp1
LMain:
mov ecx,ebx
shr ecx,4
jz LTail
and ebx,15
LAgain:
movq mm0, qword ptr [rsi+ 0]
movq mm1, qword ptr [rsi+ 8]
movq mm2, qword ptr [rsi+16]
movq mm3, qword ptr [rsi+24]
movq mm4, qword ptr [rsi+32]
movq mm5, qword ptr [rsi+40]
movq mm6, qword ptr [rsi+48]
movq mm7, qword ptr [rsi+56]
psrad mm0,8
psrad mm1,8
psrad mm2,8
psrad mm3,8
psrad mm4,8
psrad mm5,8
psrad mm6,8
psrad mm7,8
packssdw mm0, mm1
packssdw mm2, mm3
packssdw mm4, mm5
packssdw mm6, mm7
movntq qword ptr [rdi+ 0], mm0
movntq qword ptr [rdi+ 8], mm2
movntq qword ptr [rdi+16], mm4
movntq qword ptr [rdi+24], mm6
add rsi, 64
add rdi, 32
dec ecx
jnz LAgain
LTail:
test ebx, ebx
jz LEnd
LClamp2:
mov eax,[rsi]
sar eax,8
cmp eax,32767
jg LClampHigh2
cmp eax,-32768
jnl LClampDone2
mov eax,-32768
jmp LClampDone2
LClampHigh2:
mov eax,32767
LClampDone2:
mov [rdi],ax
add rsi,4
add rdi,2
dec ebx
jnz LClamp2
LEnd:
sfence
emms
LExit:
#ifdef _WIN32
pop rdi
pop rsi
#endif
pop rbx
ret
5 changes: 4 additions & 1 deletion code/client/cl_scrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,11 @@ static void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
// unless they are displaying game renderings
if ( uiFullscreen || cls.state < CA_LOADING ) {
if ( cls.glconfig.vidWidth * 480 > cls.glconfig.vidHeight * 640 ) {
// draw vertical bars on sides for legacy mods
const int w = (cls.glconfig.vidWidth - ((cls.glconfig.vidHeight * 640) / 480)) /2;
re.SetColor( g_color_table[ ColorIndex( COLOR_BLACK ) ] );
re.DrawStretchPic( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, 0, 0, 0, cls.whiteShader );
re.DrawStretchPic( 0, 0, w, cls.glconfig.vidHeight, 0, 0, 0, 0, cls.whiteShader );
re.DrawStretchPic( cls.glconfig.vidWidth - w, 0, w, cls.glconfig.vidHeight, 0, 0, 0, 0, cls.whiteShader );
re.SetColor( NULL );
}
}
Expand Down
4 changes: 2 additions & 2 deletions code/client/snd_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ __asm {

#endif // id386

#if idx64 && defined (_MSC_VER) && defined(USE_WIN32_ASM)
#if idx64 && (!defined (_MSC_VER) || defined(USE_WIN32_ASM))
void S_WriteLinearBlastStereo16_SSE_x64( int*, short*, int );
#endif

Expand Down Expand Up @@ -299,7 +299,7 @@ void S_TransferStereo16( unsigned long *pbuf, int endtime )
S_WriteLinearBlastStereo16_MMX();
else
#endif
#if idx64 && defined (_MSC_VER) && defined (USE_WIN32_ASM)
#if idx64 && (!defined (_MSC_VER) || defined (USE_WIN32_ASM))
S_WriteLinearBlastStereo16_SSE_x64( snd_p, snd_out, snd_linear_count );
#else
S_WriteLinearBlastStereo16();
Expand Down
6 changes: 6 additions & 0 deletions code/win32/msvc2017/botlib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,23 @@
<WarningLevel>Level4</WarningLevel>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;BOTLIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;BOTLIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand All @@ -132,6 +135,7 @@
<WarningLevel>Level3</WarningLevel>
<FloatingPointExceptions>true</FloatingPointExceptions>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -143,6 +147,7 @@
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<FloatingPointExceptions>true</FloatingPointExceptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
Expand All @@ -154,6 +159,7 @@
<BrowseInformation>true</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<FloatingPointExceptions>true</FloatingPointExceptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions code/win32/msvc2017/libjpeg.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<WarningLevel>Level3</WarningLevel>
<FloatingPointExceptions>true</FloatingPointExceptions>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -119,6 +120,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<FloatingPointExceptions>true</FloatingPointExceptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
Expand All @@ -129,6 +131,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<FloatingPointExceptions>true</FloatingPointExceptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -137,13 +140,15 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
Expand All @@ -152,6 +157,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<CompileAs>CompileAsC</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions code/win32/msvc2017/libogg.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand All @@ -128,6 +129,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<FloatingPointExceptions>true</FloatingPointExceptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -137,13 +139,15 @@
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FloatingPointExceptions>true</FloatingPointExceptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand All @@ -155,6 +159,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand All @@ -169,6 +174,7 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<FloatingPointExceptions>true</FloatingPointExceptions>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions code/win32/msvc2017/libvorbis.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level1</WarningLevel>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand All @@ -129,6 +130,7 @@
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<FloatingPointExceptions>true</FloatingPointExceptions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -139,6 +141,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FloatingPointExceptions>true</FloatingPointExceptions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -148,6 +151,7 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level1</WarningLevel>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand All @@ -162,13 +166,15 @@
<FloatingPointExceptions>true</FloatingPointExceptions>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level1</WarningLevel>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand Down
Loading