Skip to content

Commit

Permalink
Adding SSE4.1 optimized CRC32 and Adler32 - 15% faster for 24bpp with…
Browse files Browse the repository at this point in the history
… MSVC 2022

Switching back to unlicense
Exposing some utility API's
Adding "SSE" option to CMakeLists.txt file
  • Loading branch information
richgel999 committed Dec 30, 2021
1 parent 6326cc8 commit f95df78
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 1,390 deletions.
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ project(fpng_test)

cmake_minimum_required(VERSION 3.0)
option(BUILD_X64 "build 64-bit" TRUE)
option(SSE "SSE 4.1 support" FALSE)

message("Initial BUILD_X64=${BUILD_X64}")
message("Initial SSE=${SSE}")

if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release )
Expand All @@ -17,6 +19,12 @@ else()
message("Building 32-bit")
endif()

if (SSE)
message("SSE enabled")
else()
message("SSE disabled")
endif()

if (NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
Expand All @@ -43,14 +51,21 @@ if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COMPILE_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${GCC_COMPILE_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${GCC_COMPILE_FLAGS} -D_DEBUG")

if (SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFPNG_NO_SSE=0 -msse4.1 -mpclmul")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFPNG_NO_SSE=0 -msse4.1 -mpclmul")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFPNG_NO_SSE=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFPNG_NO_SSE=1")
endif()
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()

set(FPNG_SRC_LIST ${COMMON_SRC_LIST}
src/fpng.cpp
src/Crc32.cpp
src/fpng_test.cpp
src/lodepng.cpp
)
Expand Down
4 changes: 1 addition & 3 deletions fpng.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src/Crc32.cpp" />
<ClCompile Include="src/fpng.cpp" />
<ClCompile Include="src/fpng_test.cpp" />
<ClCompile Include="src/lodepng.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src/Crc32.h" />
<ClInclude Include="src/fpng.h" />
<ClInclude Include="src/lodepng.h" />
<ClInclude Include="src/qoi.h" />
Expand All @@ -159,4 +157,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
8 changes: 1 addition & 7 deletions fpng.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
<ClCompile Include="src/fpng.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src/Crc32.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src/fpng_test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -29,9 +26,6 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src/Crc32.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src/fpng.h">
<Filter>Source Files</Filter>
</ClInclude>
Expand All @@ -48,4 +42,4 @@
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
Loading

0 comments on commit f95df78

Please sign in to comment.