[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PATCH: enable MMX for X86_64, VideoCapture



Thanks. The attached batch file creates the missing 64-bit libmsvcr90.a library from the msvcr90 DLL and compiles scale_mmx.c using mingw. The two library files can then be used during the msvc build process (see setup.py diff). This method leaves the scale_mmx source code in the trunk untouched. All tests pass except freetype_font_test.

Btw, svn rev 2657 does not compile with msvc any longer due to C99 usage (bool) in _camera.c.

Christoph

On 09/25/2009 10:43, Lenard Lindstrom wrote:
Hi,

This could be an SVN branch for now (*). I will get on to it. I should
be possible to use the same template for building the 32 bit msvcr90
import library for MinGW to build on for 64 bit mscvr90. If not then the
best long term solution here would be to have an masm version of
scale_mmx64.c. The smoothscale code has been around for awhile and
without any bug reports filed. So the code should be stable.

Lenard Linstrom

(*) For other maintainers, this would also be a test case for getting
SVN merges working properly by adding the proper tags to trunk.

Christoph Gohlke wrote:
Hello,

the attached patch and source files contain a workaround for building
pygame with MMX scaling support for 64-bit Windows using Visual Studio
and mingw-64-bit.

When compiling scale_mmx.c without -D_NO_MMX_FOR_X86_64 using the
64-bit Visual Studio compiler the file scale_mmx64_msvc.c is included,
which has all asm code replaced by function calls. The asm containing
functions are implemented in scale_mmx64_gcc.c, which can be compiled
independently with mingw-64-bit:

x86_64-w64-mingw32-gcc.exe -c src/scale_mmx64_gcc.c
-fno-leading-underscore -o obj/win64/scale_mmx64_gcc.obj

The resulting scale_mmx64_gcc.obj is then linked during the MSVC build
process.

The patch should not interfere with other compilers (not verified). It
is just a workaround until mingw-64-bit has support for using the
msvc9 runtime. It is probably not a good idea to apply the patch to
the main trunk since it duplicates code.

The resulting 1.9.2pre binaries pass all tests, except
freetype_font_test.

The patch also tries to import vidcap from the VideoCapture package.

Christoph





setlocal
set MINGW32=C:\mingw
set MINGW64=C:\mingw-x64
mkdir obj\win64
cd obj\win64
copy /Y %WINDIR%\winsxs\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_08e3747fa83e48bc\MSVCR90.DLL msvcr90.dll
%MINGW32%\bin\gendef.exe msvcr90.dll
%MINGW64%\bin\x86_64-w64-mingw32-dlltool.exe -D msvcr90.dll -l libmsvcr90.a -d msvcr90.def
cd ..\..\
%MINGW64%\bin\x86_64-w64-mingw32-gcc.exe -c src/scale_mmx.c -fno-leading-underscore -o obj/win64/scale_mmx.obj
pause
Index: setup.py
===================================================================
--- setup.py	(revision 2657)
+++ setup.py	(working copy)
@@ -360,15 +360,18 @@
     def replace_scale_mmx():
         for e in extensions:
             if e.name == 'transform':
-                e.extra_objects.append(
-                    os.path.join('obj', 'win32', 'scale_mmx.obj'))
+                if '64 bit' in sys.version:
+                    e.extra_objects.extend((
+                        os.path.join('obj', 'win64', 'scale_mmx.obj'),
+                        os.path.join('obj', 'win64', 'libmsvcr90.a')))
+                else:
+                    e.extra_objects.append(
+                        os.path.join('obj', 'win32', 'scale_mmx.obj'))
                 for i in range(len(e.sources)):
                     if e.sources[i].endswith('scale_mmx.c'):
                         del e.sources[i]
                         return
-    # linking to 64-bit mingw generated scale_mmx.obj fails
-    if not '64 bit' in sys.version:
-        replace_scale_mmx()
+    replace_scale_mmx()
 
 
 #clean up the list of extensions