qmake: better way to detect sse2 sse4.1 for qt4/5

This commit is contained in:
wang-bin
2014-05-03 22:05:56 +08:00
parent 97548cc6c4
commit d0491663f8
8 changed files with 108 additions and 68 deletions
+2 -2
View File
@@ -32,11 +32,11 @@ OTHER_FILES += \
EssentialDepends = avutil avcodec avformat swscale
OptionalDepends = \
sse2 \
sse4_1 \
swresample \
avresample \
gl
## sse2 sse4_1 may be defined in Qt5 qmodule.pri. Qt4 only defines sse and sse2
lessThan(QT_MAJOR_VERSION, 5): OptionalDepends *= sse4_1
# no-xxx can set in $$PWD/user.conf
!no-openal: OptionalDepends *= openal
!no-portaudio: OptionalDepends *= portaudio
+29
View File
@@ -142,6 +142,35 @@ defineTest(empty_file) {
##TODO: add defineReplace(getValue): parameter is varname
lessThan(QT_MAJOR_VERSION, 5): {
win32-icc {
QMAKE_CFLAGS_SSE2 = -arch:SSE2
QMAKE_CFLAGS_SSE4_1 = -arch:SSE4.1
} else:*-icc { #mac, linux
QMAKE_CFLAGS_SSE2 = -xSSE2
QMAKE_CFLAGS_SSE4_1 = -xSSE4.1
} else:*msvc* {
QMAKE_CFLAGS_SSE2 = -arch:SSE2
QMAKE_CFLAGS_SSE4_1 = -arch:SSE2
} else {
QMAKE_CFLAGS_SSE2 = -msse2
QMAKE_CFLAGS_SSE4_1 = -msse4.1
}
sse4_1|config_sse4_1 {
HEADERS += $$SSE4_1_HEADERS
sse4_1_compiler.commands = $$QMAKE_CXX -c $(CXXFLAGS)
!contains(QT_CPU_FEATURES, sse4_1):sse4_1_compiler.commands += $$QMAKE_CFLAGS_SSE4_1
sse4_1_compiler.commands += $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
sse4_1_compiler.dependency_type = TYPE_C
sse4_1_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
sse4_1_compiler.input = SSE4_1_SOURCES
sse4_1_compiler.variable_out = OBJECTS
sse4_1_compiler.name = compiling[sse4_1] ${QMAKE_FILE_IN}
silent:sse4_1_compiler.commands = @echo compiling[sse4_1] ${QMAKE_FILE_IN} && $$sse4_1_compiler.commands
QMAKE_EXTRA_COMPILERS += sse4_1_compiler
}
defineTest(log){
system(echo $$system_quote($$1))
}
-52
View File
@@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <emmintrin.h>
#if defined(__GNUC__) && __GNUC__ < 4 && __GNUC_MINOR__ < 3
#error GCC < 3.2 is known to create internal compiler errors with our MMX code
#endif
int main(int, char**)
{
__m128i a = _mm_setzero_si128();
_mm_maskmoveu_si128(a, _mm_setzero_si128(), 0);
return 0;
}
-7
View File
@@ -1,7 +0,0 @@
SOURCES = sse2.cpp
CONFIG -= qt dylib release debug_and_release
CONFIG += debug console
#qt5 only has gcc, qcc, vc, linux icc. clang?
win32-icc: QMAKE_CFLAGS_SSE2 *= -arch:SSE2
isEmpty(QMAKE_CFLAGS_SSE2):error("This compiler does not support SSE2")
else:QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_SSE2
+30 -3
View File
@@ -1,7 +1,34 @@
SOURCES = sse4_1.cpp
#SSE4_1_SOURCES = sse4_1.cpp
CONFIG -= qt dylib release debug_and_release
CONFIG += debug console
#qt5 only has gcc, qcc, vc, linux icc. clang?
win32-icc: QMAKE_CFLAGS_SSE4_1 *= -arch:SSE4.1
CONFIG += debug console sse4_1
# for Qt4. we can only detect sse2 in Qt4
#qt5 only has gcc, qcc, vc, linux icc.
win32-icc {
QMAKE_CFLAGS_SSE4_1 = -arch:SSE4.1
} else:*-icc { #mac, linux
QMAKE_CFLAGS_SSE4_1 = -xSSE4.1
} else:*msvc* {
QMAKE_CFLAGS_SSE4_1 = -arch:SSE2
} else {
QMAKE_CFLAGS_SSE4_1 = -msse4.1
}
sse4_1 {
HEADERS += $$SSE4_1_HEADERS
sse4_1_compiler.commands = $$QMAKE_CXX -c $(CXXFLAGS)
!contains(QT_CPU_FEATURES, sse4_1):sse4_1_compiler.commands += $$QMAKE_CFLAGS_SSE4_1
sse4_1_compiler.commands += $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
sse4_1_compiler.dependency_type = TYPE_C
sse4_1_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
sse4_1_compiler.input = SSE4_1_SOURCES
sse4_1_compiler.variable_out = OBJECTS
sse4_1_compiler.name = compiling[sse4_1] ${QMAKE_FILE_IN}
silent:sse4_1_compiler.commands = @echo compiling[sse4_1] ${QMAKE_FILE_IN} && $$sse4_1_compiler.commands
QMAKE_EXTRA_COMPILERS += sse4_1_compiler
}
isEmpty(QMAKE_CFLAGS_SSE4_1):error("This compiler does not support SSE4.1")
else:QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_SSE4_1
+5 -2
View File
@@ -32,11 +32,13 @@ win32 {
OTHER_FILES += $$RC_FILE
TRANSLATIONS = $${PROJECTROOT}/i18n/QtAV_zh_CN.ts
config_sse4_1|contains(TARGET_ARCH_SUB, sse4.1) {
## sse2 sse4_1 may be defined in Qt5 qmodule.pri. Qt4 only defines sse and sse2
sse4_1|config_sse4_1|contains(TARGET_ARCH_SUB, sse4.1) {
DEFINES += QTAV_HAVE_SSE4_1=1
## TODO: use SSE4_1_SOURCES
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_SSE4_1 #gcc -msse4.1
}
config_sse2|contains(TARGET_ARCH_SUB, sse2) {
sse2|config_sse2|contains(TARGET_ARCH_SUB, sse2) {
DEFINES += QTAV_HAVE_SSE2=1
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_SSE2 #gcc -msse2
}
@@ -172,6 +174,7 @@ config_libcedarv {
SOURCES += VideoDecoderCedarv.cpp
LIBS += -lvecore -lcedarv
}
SOURCES += \
QtAV_Compat.cpp \
QtAV_Global.cpp \
+21 -1
View File
@@ -1,3 +1,24 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <wbsecg1@gmail.com>
* This file is part of QtAV
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/
#include "GPUMemCopy.h"
#include <stdlib.h>
@@ -13,7 +34,6 @@
#include <smmintrin.h> //stream load
#endif
/* Branch prediction */
#ifdef __GNUC__
# define likely(p) __builtin_expect(!!(p), 1)
+21 -1
View File
@@ -1,3 +1,24 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <wbsecg1@gmail.com>
* This file is part of QtAV
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/
#ifndef GPUMemCopy_H
#define GPUMemCopy_H
@@ -9,7 +30,6 @@ class GPUMemCopy
{
public:
static bool isAvailable();
GPUMemCopy();
~GPUMemCopy();