Merge remote-tracking branch 'origin/5.4' into dev

Change-Id: I05fcd8dc66d9ad0dc76bb7f5bae05c9876bfba14
This commit is contained in:
Frederik Gladhorn 2014-10-09 17:56:51 +02:00
commit 881ceeff42
560 changed files with 20670 additions and 18940 deletions

45
configure vendored
View File

@ -627,6 +627,7 @@ CFG_PPS=auto
CFG_QNX_IMF=auto CFG_QNX_IMF=auto
CFG_LGMON=auto CFG_LGMON=auto
CFG_SYSTEM_PROXIES=no CFG_SYSTEM_PROXIES=no
CFG_ANDROID_STYLE_ASSETS=yes
# Target architecture # Target architecture
CFG_ARCH= CFG_ARCH=
@ -699,8 +700,8 @@ RPATH_FLAGS=
W_FLAGS= W_FLAGS=
QCONFIG_FLAGS= QCONFIG_FLAGS=
XPLATFORM= # This seems to be the QMAKESPEC, like "linux-g++" XPLATFORM= # This seems to be the QMAKESPEC, like "linux-g++"
XPLATFORM_MAC=no XPLATFORM_MAC=no # Whether target platform is OS X or iOS
XPLATFORM_IOS=no XPLATFORM_IOS=no # Whether target platform is iOS
XPLATFORM_ANDROID=no XPLATFORM_ANDROID=no
XPLATFORM_MINGW=no # Whether target platform is MinGW (win32-g++*) XPLATFORM_MINGW=no # Whether target platform is MinGW (win32-g++*)
XPLATFORM_QNX=no XPLATFORM_QNX=no
@ -2169,6 +2170,13 @@ while [ "$#" -gt 0 ]; do
android-toolchain-version) android-toolchain-version)
CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION="$VAL" CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION="$VAL"
;; ;;
android-style-assets)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_ANDROID_STYLE_ASSETS="$VAL"
else
UNKNOWN_OPT=yes
fi
;;
l*) # -lfoo l*) # -lfoo
if [ "$VAL" = "yes" ]; then if [ "$VAL" = "yes" ]; then
L_FLAGS="$L_FLAGS -l\"${VAR#l}\"" L_FLAGS="$L_FLAGS -l\"${VAR#l}\""
@ -2592,6 +2600,14 @@ Android options:
-android-toolchain-version ..... Sets the android toolchain version -android-toolchain-version ..... Sets the android toolchain version
(default $CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION) (default $CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION)
-no-android-style-assets ....... Do not compile in the code which automatically extracts
style assets from the run-time device. Setting this will
make the Android style behave incorrectly, but will enable
compatibility with the LGPL2.1 license.
* -android-style-assets .......... Compile the code which automatically extracts style assets
from the run-time device. This option will make the
Android platform plugin incompatible with the LGPL2.1.
EOF EOF
exit 0 exit 0
@ -2853,15 +2869,20 @@ fi
if [ "$Edition" = "OpenSource" ]; then if [ "$Edition" = "OpenSource" ]; then
while true; do while true; do
echo "You are licensed to use this software under the terms of" if [ "$CFG_ANDROID_STYLE_ASSETS" = "no" ] || [ "$XPLATFORM_ANDROID" = "no" ]; then
echo "the Lesser GNU General Public License (LGPL) versions 2.1." echo "You are licensed to use this software under the terms of"
if [ -f "$relpath/LICENSE.LGPLv3" ]; then echo "the Lesser GNU General Public License (LGPL) versions 2.1."
echo "You are also licensed to use this software under the terms of" echo "You are also licensed to use this software under the terms of"
echo "the GNU Lesser General Public License (LGPL) versions 3." echo "the GNU Lesser General Public License (LGPL) versions 3."
affix="either" affix="either"
showLGPL2="yes"
else else
echo "You are licensed to use this software under the terms of"
echo "the GNU Lesser General Public License (LGPL) versions 3."
showLGPL2="no"
affix="the" affix="the"
fi fi
echo echo
if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
echo "You have already accepted the terms of the $EditionString license." echo "You have already accepted the terms of the $EditionString license."
@ -2870,7 +2891,9 @@ if [ "$Edition" = "OpenSource" ]; then
if [ -f "$relpath/LICENSE.LGPLv3" ]; then if [ -f "$relpath/LICENSE.LGPLv3" ]; then
echo "Type '3' to view the GNU Lesser General Public License version 3." echo "Type '3' to view the GNU Lesser General Public License version 3."
fi fi
echo "Type 'L' to view the Lesser GNU General Public License version 2.1." if [ "$showLGPL2" = "yes" ]; then
echo "Type 'L' to view the Lesser GNU General Public License version 2.1."
fi
echo "Type 'yes' to accept this license offer." echo "Type 'yes' to accept this license offer."
echo "Type 'no' to decline this license offer." echo "Type 'no' to decline this license offer."
echo echo
@ -2886,7 +2909,7 @@ if [ "$Edition" = "OpenSource" ]; then
exit 1 exit 1
elif [ "$acceptance" = "3" ]; then elif [ "$acceptance" = "3" ]; then
more "$relpath/LICENSE.LGPLv3" more "$relpath/LICENSE.LGPLv3"
elif [ "$acceptance" = "L" ]; then elif [ "$acceptance" = "L" ] && [ "$showLGPL2" = "yes" ]; then
more "$relpath/LICENSE.LGPLv21" more "$relpath/LICENSE.LGPLv21"
fi fi
done done
@ -3147,9 +3170,12 @@ if [ "$CFG_FORCEDEBUGINFO" = "yes" ]; then
QMAKE_CONFIG="$QMAKE_CONFIG force_debug_info" QMAKE_CONFIG="$QMAKE_CONFIG force_debug_info"
fi fi
if [ "$XPLATFORM_MAC" = "yes" ]; then
[ "$CFG_PKGCONFIG" = "auto" ] && CFG_PKGCONFIG="no"
fi
if [ "$XPLATFORM_IOS" = "yes" ]; then if [ "$XPLATFORM_IOS" = "yes" ]; then
CFG_RPATH="no" CFG_RPATH="no"
CFG_PKGCONFIG="no"
CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS examples" CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS examples"
CFG_SHARED="no" # iOS builds should be static to be able to submit to the App Store CFG_SHARED="no" # iOS builds should be static to be able to submit to the App Store
CFG_SKIP_MODULES="$CFG_SKIP_MODULES qtconnectivity qtdoc qtmacextras qtserialport qtwebkit qtwebkit-examples" CFG_SKIP_MODULES="$CFG_SKIP_MODULES qtconnectivity qtdoc qtmacextras qtserialport qtwebkit qtwebkit-examples"
@ -3195,6 +3221,9 @@ if [ "$XPLATFORM_ANDROID" = "yes" ] ; then
esac esac
QMAKE_CONF_COMPILER=$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/$ANDROID_NDK_TOOLS_PREFIX-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/$CFG_DEFAULT_ANDROID_NDK_HOST/bin/$ANDROID_NDK_TOOLS_PREFIX-g++ QMAKE_CONF_COMPILER=$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/$ANDROID_NDK_TOOLS_PREFIX-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/$CFG_DEFAULT_ANDROID_NDK_HOST/bin/$ANDROID_NDK_TOOLS_PREFIX-g++
TEST_COMPILER="$QMAKE_CONF_COMPILER --sysroot=$CFG_DEFAULT_ANDROID_NDK_ROOT/platforms/$CFG_DEFAULT_ANDROID_PLATFORM/$ANDROID_PLATFORM_ARCH/" TEST_COMPILER="$QMAKE_CONF_COMPILER --sysroot=$CFG_DEFAULT_ANDROID_NDK_ROOT/platforms/$CFG_DEFAULT_ANDROID_PLATFORM/$ANDROID_PLATFORM_ARCH/"
if [ "$CFG_ANDROID_STYLE_ASSETS" = "yes" ]; then
QMAKE_CONFIG="$QMAKE_CONFIG android-style-assets"
fi
fi fi
if [ "$XPLATFORM_SYMBIAN_SBSV2" = "no" ]; then if [ "$XPLATFORM_SYMBIAN_SBSV2" = "no" ]; then

7
dist/changes-5.4.0 vendored
View File

@ -24,3 +24,10 @@ QtCore
- Added QEnableSharedFromThis, a class that allows obtaining a - Added QEnableSharedFromThis, a class that allows obtaining a
QSharedPointer for an object already managed by a shared pointer. QSharedPointer for an object already managed by a shared pointer.
QtSql
-----
- qsql ibase: fix memory corruption due to LONG being 4 bytes in firebird.
- QSqlDriver::dbmsType(): New method reports DBMS type. Especially useful when using ODBC.

View File

@ -25,7 +25,7 @@
** **
****************************************************************************/ ****************************************************************************/
/*! /*!
\externalpage http://qt-project.org/ \externalpage http://qt.io/
\title Qt Homepage \title Qt Homepage
*/ */
/*! /*!
@ -33,11 +33,11 @@
\title Qt Bug Tracker \title Qt Bug Tracker
*/ */
/*! /*!
\externalpage http://qt-project.org/downloads \externalpage http://qt.io/download
\title Downloads \title Downloads
*/ */
/*! /*!
\externalpage http://qt.digia.com/licensing/ \externalpage http://qt.io/licensing/
\title Qt Licensing Overview \title Qt Licensing Overview
*/ */
/*! /*!

View File

@ -34,7 +34,7 @@
\image openglwindow-example.png Screenshot of the OpenGLWindow example \image openglwindow-example.png Screenshot of the OpenGLWindow example
\section1 OpenGLWindow super class \section1 OpenGLWindow Super Class
Our OpenGLWindow class acts as an API which is then subclassed to do the Our OpenGLWindow class acts as an API which is then subclassed to do the
actual rendering. It has functions to make a request for render() to be actual rendering. It has functions to make a request for render() to be
@ -118,7 +118,7 @@
\snippet openglwindow/openglwindow.cpp 5 \snippet openglwindow/openglwindow.cpp 5
\section1 Example OpenGL rendering sub class \section1 Example OpenGL Rendering Sub Class
Here we sub class OpenGLWindow to show how to do OpenGL to render a Here we sub class OpenGLWindow to show how to do OpenGL to render a
rotating triangle. By indirectly sub classing QOpenGLFunctions we gain rotating triangle. By indirectly sub classing QOpenGLFunctions we gain

View File

@ -43,7 +43,7 @@
In this example, we'll demonstrate how to save and load a simple game to In this example, we'll demonstrate how to save and load a simple game to
and from JSON and binary formats. and from JSON and binary formats.
\section1 The Character class \section1 The Character Class
The Character class represents a non-player character (NPC) in our game, and The Character class represents a non-player character (NPC) in our game, and
stores the player's name, level, and class type. stores the player's name, level, and class type.

View File

@ -90,7 +90,7 @@
\snippet cube/mainwidget.cpp 2 \snippet cube/mainwidget.cpp 2
\section1 Loading textures from Qt Resource files \section1 Loading Textures from Qt Resource Files
\c QGLWidget interface implements methods for loading textures from QImage to GL \c QGLWidget interface implements methods for loading textures from QImage to GL
texture memory. We still need to use OpenGL provided functions for specifying texture memory. We still need to use OpenGL provided functions for specifying
@ -133,14 +133,14 @@
\snippet cube/geometryengine.cpp 2 \snippet cube/geometryengine.cpp 2
\section1 Perspective projection \section1 Perspective Projection
Using \c QMatrix4x4 helper methods it's really easy to calculate perpective Using \c QMatrix4x4 helper methods it's really easy to calculate perpective
projection matrix. This matrix is used to project vertices to screen space. projection matrix. This matrix is used to project vertices to screen space.
\snippet cube/mainwidget.cpp 5 \snippet cube/mainwidget.cpp 5
\section1 Orientation of the 3D object \section1 Orientation of the 3D Object
Quaternions are handy way to represent orientation of the 3D object. Quaternions Quaternions are handy way to represent orientation of the 3D object. Quaternions
involve quite complex mathematics but fortunately all the necessary mathematics involve quite complex mathematics but fortunately all the necessary mathematics

View File

@ -394,6 +394,11 @@ void GLWidget::paintGL()
} }
m_fAngle += 1.0f; m_fAngle += 1.0f;
++m_frames; ++m_frames;
// When requested, follow the ideal way to animate: Rely on
// blocking swap and just schedule updates continuously.
if (!m_mainWindow->timerEnabled())
update();
} }
void GLWidget::createBubbles(int number) void GLWidget::createBubbles(int number)

View File

@ -54,6 +54,7 @@ MainWindow::MainWindow()
: m_nextX(1), m_nextY(1) : m_nextX(1), m_nextY(1)
{ {
GLWidget *glwidget = new GLWidget(this, true, qRgb(20, 20, 50)); GLWidget *glwidget = new GLWidget(this, true, qRgb(20, 20, 50));
m_glWidgets << glwidget;
QLabel *label = new QLabel(this); QLabel *label = new QLabel(this);
m_timer = new QTimer(this); m_timer = new QTimer(this);
QSlider *slider = new QSlider(this); QSlider *slider = new QSlider(this);
@ -67,12 +68,19 @@ MainWindow::MainWindow()
"Note that on most systems the swap will block to wait for vsync\n" "Note that on most systems the swap will block to wait for vsync\n"
"and therefore an interval < 16 ms will likely lead to a 60 FPS update rate."); "and therefore an interval < 16 ms will likely lead to a 60 FPS update rate.");
QGroupBox *updateGroupBox = new QGroupBox(this); QGroupBox *updateGroupBox = new QGroupBox(this);
QCheckBox *timerBased = new QCheckBox("Use timer", this);
timerBased->setChecked(true);
timerBased->setToolTip("Toggles using a timer to trigger update().\n"
"When not set, each paintGL() schedules the next update immediately,\n"
"expecting the blocking swap to throttle the thread.\n"
"This shows how unnecessary the timer is in most cases.");
QCheckBox *transparent = new QCheckBox("Transparent background", this); QCheckBox *transparent = new QCheckBox("Transparent background", this);
transparent->setToolTip("Toggles Qt::WA_AlwaysStackOnTop and transparent clear color for glClear().\n" transparent->setToolTip("Toggles Qt::WA_AlwaysStackOnTop and transparent clear color for glClear().\n"
"Note how the button on top stacks incorrectly when enabling this."); "Note how the button on top stacks incorrectly when enabling this.");
QHBoxLayout *updateLayout = new QHBoxLayout; QHBoxLayout *updateLayout = new QHBoxLayout;
updateLayout->addWidget(updateLabel); updateLayout->addWidget(updateLabel);
updateLayout->addWidget(updateInterval); updateLayout->addWidget(updateInterval);
updateLayout->addWidget(timerBased);
updateLayout->addWidget(transparent); updateLayout->addWidget(transparent);
updateGroupBox->setLayout(updateLayout); updateGroupBox->setLayout(updateLayout);
@ -123,6 +131,8 @@ MainWindow::MainWindow()
connect(transparent, &QCheckBox::toggled, glwidget, &GLWidget::setTransparent); connect(transparent, &QCheckBox::toggled, glwidget, &GLWidget::setTransparent);
connect(updateInterval, SIGNAL(valueChanged(int)), this, SLOT(updateIntervalChanged(int))); connect(updateInterval, SIGNAL(valueChanged(int)), this, SLOT(updateIntervalChanged(int)));
connect(timerBased, &QCheckBox::toggled, this, &MainWindow::timerUsageChanged);
connect(timerBased, &QCheckBox::toggled, updateInterval, &QWidget::setEnabled);
m_timer->start(); m_timer->start();
} }
@ -130,7 +140,8 @@ MainWindow::MainWindow()
void MainWindow::updateIntervalChanged(int value) void MainWindow::updateIntervalChanged(int value)
{ {
m_timer->setInterval(value); m_timer->setInterval(value);
m_timer->start(); if (m_timer->isActive())
m_timer->start();
} }
void MainWindow::addNew() void MainWindow::addNew()
@ -138,6 +149,7 @@ void MainWindow::addNew()
if (m_nextY == 4) if (m_nextY == 4)
return; return;
GLWidget *w = new GLWidget(this, false, qRgb(qrand() % 256, qrand() % 256, qrand() % 256)); GLWidget *w = new GLWidget(this, false, qRgb(qrand() % 256, qrand() % 256, qrand() % 256));
m_glWidgets << w;
connect(m_timer, SIGNAL(timeout()), w, SLOT(update())); connect(m_timer, SIGNAL(timeout()), w, SLOT(update()));
m_layout->addWidget(w, m_nextY, m_nextX, 1, 1); m_layout->addWidget(w, m_nextY, m_nextX, 1, 1);
if (m_nextX == 3) { if (m_nextX == 3) {
@ -147,3 +159,14 @@ void MainWindow::addNew()
++m_nextX; ++m_nextX;
} }
} }
void MainWindow::timerUsageChanged(bool enabled)
{
if (enabled) {
m_timer->start();
} else {
m_timer->stop();
foreach (QOpenGLWidget *w, m_glWidgets)
w->update();
}
}

View File

@ -45,6 +45,8 @@
#include <QTimer> #include <QTimer>
#include <QGridLayout> #include <QGridLayout>
QT_FORWARD_DECLARE_CLASS(QOpenGLWidget)
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -52,15 +54,18 @@ class MainWindow : public QMainWindow
public: public:
MainWindow(); MainWindow();
void addNew(); void addNew();
bool timerEnabled() const { return m_timer->isActive(); }
private slots: private slots:
void updateIntervalChanged(int value); void updateIntervalChanged(int value);
void timerUsageChanged(bool enabled);
private: private:
QTimer *m_timer; QTimer *m_timer;
QGridLayout *m_layout; QGridLayout *m_layout;
int m_nextX; int m_nextX;
int m_nextY; int m_nextY;
QVector<QOpenGLWidget *> m_glWidgets;
}; };
#endif #endif

View File

@ -192,7 +192,7 @@
the platform. By convention the target should have the same name the platform. By convention the target should have the same name
as the plugin (set with Q_EXPORT_PLUGIN2) as the plugin (set with Q_EXPORT_PLUGIN2)
\section1 Further reading and examples \section1 Further Reading and Examples
The \l {qtplugin-defining-plugins}{Defining Plugins} page presents an overview of the macros needed to The \l {qtplugin-defining-plugins}{Defining Plugins} page presents an overview of the macros needed to
create plugins. create plugins.

View File

@ -123,7 +123,7 @@
styles folder under stylewindow because this is a path in which Qt styles folder under stylewindow because this is a path in which Qt
will search for style plugins. will search for style plugins.
\section1 Related articles and examples \section1 Related Articles and Examples
In addition to the plugin \l{How to Create Qt Plugins}{overview In addition to the plugin \l{How to Create Qt Plugins}{overview
document}, we have other examples and articles that concern document}, we have other examples and articles that concern

View File

@ -61,7 +61,7 @@
First we will review the \c SortingBox class, then we will take a First we will review the \c SortingBox class, then we will take a
look at the \c ShapeItem class. look at the \c ShapeItem class.
\section1 SortingBox Class Definition \section1 SortingBox Class Definition
\snippet widgets/tooltips/sortingbox.h 0 \snippet widgets/tooltips/sortingbox.h 0

View File

@ -1,6 +1,6 @@
TEMPLATE = app TEMPLATE = app
TARGET = buttontester TARGET = mousebuttons
TEMPLATE = app TEMPLATE = app
SOURCES += \ SOURCES += \

28
header.LGPL3 Normal file
View File

@ -0,0 +1,28 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the FOO module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** 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 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

View File

@ -133,11 +133,16 @@ contains(CONFIG, plugin) {
CMAKE_PLUGIN_NAME = $$PLUGIN_CLASS_NAME CMAKE_PLUGIN_NAME = $$PLUGIN_CLASS_NAME
win32 { win32 {
isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dll isEmpty(CMAKE_STATIC_TYPE) {
else: CMAKE_PlUGIN_EXT = .lib CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}$${CMAKE_PlUGIN_EXT} } else:mingw {
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d$${CMAKE_PlUGIN_EXT} CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
} else { # MSVC static
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
}
} else { } else {
mac { mac {
isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib

View File

@ -30,7 +30,7 @@ CONFIG += plugin no_plugin_name_prefix
javac.input = JAVASOURCES javac.input = JAVASOURCES
javac.output = $$CLASS_DIR javac.output = $$CLASS_DIR
javac.CONFIG += combine javac.CONFIG += combine
javac.commands = javac -source 6 -target 6 -Xlint:unchecked -bootclasspath $$ANDROID_JAR_FILE -cp $$shell_quote($$system_path($$join(JAVACLASSPATH, $$DIRLIST_SEP))) -d $$shell_quote($$CLASS_DIR) ${QMAKE_FILE_IN} javac.commands = javac -source 6 -target 6 -Xlint:unchecked -bootclasspath $$ANDROID_JAR_FILE -cp $$shell_quote($$system_path($$join(JAVACLASSPATH, $$DIRLIST_SEPARATOR))) -d $$shell_quote($$CLASS_DIR) ${QMAKE_FILE_IN}
# Force rebuild every time, because we don't know the paths of the destination files # Force rebuild every time, because we don't know the paths of the destination files
# as they depend on the code. # as they depend on the code.
javac.depends = FORCE javac.depends = FORCE

View File

@ -89,12 +89,12 @@ contains(qt_module_deps, qml): \
} }
# run qmlimportscanner # run qmlimportscanner
qtPrepareTool(QMLIMPORTSCANNER, qmlimportscanner, _SYS) qtPrepareTool(QMLIMPORTSCANNER, qmlimportscanner, , system)
for (QMLPATH, QMLPATHS): \ for (QMLPATH, QMLPATHS): \
IMPORTPATHS += -importPath $$QMLPATH IMPORTPATHS += -importPath $$QMLPATH
#message(run $$QMLIMPORTSCANNER_SYS $$_PRO_FILE_PWD_ $$IMPORTPATHS) #message(run $$QMLIMPORTSCANNER $$_PRO_FILE_PWD_ $$IMPORTPATHS)
JSON = $$system($$QMLIMPORTSCANNER_SYS $$_PRO_FILE_PWD_ $$IMPORTPATHS) JSON = $$system($$QMLIMPORTSCANNER $$_PRO_FILE_PWD_ $$IMPORTPATHS)
parseJson(JSON, IMPORTS)| error("Failed to parse qmlimportscanner output.") parseJson(JSON, IMPORTS)| error("Failed to parse qmlimportscanner output.")

View File

@ -187,7 +187,7 @@ defineTest(qtAddRpathLink) {
export(QMAKE_RPATHLINKDIR) export(QMAKE_RPATHLINKDIR)
} }
# variable, default, [suffix for variable for system() use] # variable, default, [suffix for variable for system() use], [prepare primary variable for system() use]
defineTest(qtPrepareTool) { defineTest(qtPrepareTool) {
cmd = $$eval(QT_TOOL.$${2}.binary) cmd = $$eval(QT_TOOL.$${2}.binary)
isEmpty(cmd) { isEmpty(cmd) {
@ -204,16 +204,18 @@ defineTest(qtPrepareTool) {
} }
} }
QT_TOOL_ENV += $$eval(QT_TOOL.$${2}.envvars) QT_TOOL_ENV += $$eval(QT_TOOL.$${2}.envvars)
!isEmpty(3) { !isEmpty(3)|!isEmpty(4) {
$$1$$3 = $$1$$3 =
for (arg, cmd): \ for (arg, cmd): \
$$1$$3 += $$system_quote($$arg) $$1$$3 += $$system_quote($$arg)
qtAddTargetEnv($$1$$3, QT_TOOL.$${2}.depends, system) qtAddTargetEnv($$1$$3, QT_TOOL.$${2}.depends, system)
} }
$$1 = isEmpty(4) {
for (arg, cmd): \ $$1 =
$$1 += $$shell_quote($$arg) for (arg, cmd): \
qtAddTargetEnv($$1, QT_TOOL.$${2}.depends, ) $$1 += $$shell_quote($$arg)
qtAddTargetEnv($$1, QT_TOOL.$${2}.depends, )
}
} }
# target variable, list of env var names, [non-empty: prepare for system(), not make] # target variable, list of env var names, [non-empty: prepare for system(), not make]

View File

@ -101,8 +101,10 @@ mac:CONFIG(shared, static|shared):contains(QT_CONFIG, qt_framework) {
FRAMEWORK_HEADERS.version = Versions FRAMEWORK_HEADERS.version = Versions
FRAMEWORK_HEADERS.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES FRAMEWORK_HEADERS.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES
FRAMEWORK_HEADERS.path = Headers FRAMEWORK_HEADERS.path = Headers
FRAMEWORK_PRIVATE_HEADERS.version = Versions
FRAMEWORK_PRIVATE_HEADERS.files = $$SYNCQT.PRIVATE_HEADER_FILES FRAMEWORK_PRIVATE_HEADERS.files = $$SYNCQT.PRIVATE_HEADER_FILES
FRAMEWORK_PRIVATE_HEADERS.path = Headers/$$VERSION/$$MODULE_INCNAME/private FRAMEWORK_PRIVATE_HEADERS.path = Headers/$$VERSION/$$MODULE_INCNAME/private
FRAMEWORK_QPA_HEADERS.version = Versions
FRAMEWORK_QPA_HEADERS.files = $$SYNCQT.QPA_HEADER_FILES FRAMEWORK_QPA_HEADERS.files = $$SYNCQT.QPA_HEADER_FILES
FRAMEWORK_QPA_HEADERS.path = Headers/$$VERSION/$$MODULE_INCNAME/qpa FRAMEWORK_QPA_HEADERS.path = Headers/$$VERSION/$$MODULE_INCNAME/qpa
QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS FRAMEWORK_PRIVATE_HEADERS FRAMEWORK_QPA_HEADERS QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS FRAMEWORK_PRIVATE_HEADERS FRAMEWORK_QPA_HEADERS

View File

@ -12,7 +12,7 @@
load(qt_build_paths) load(qt_build_paths)
!build_pass:git_build { !build_pass:git_build {
qtPrepareTool(QMAKE_SYNCQT, syncqt) qtPrepareTool(QMAKE_SYNCQT, syncqt, , system)
minimal_syncqt { minimal_syncqt {
QMAKE_SYNCQT += -minimal $$QMAKE_SYNCQT_OPTIONS QMAKE_SYNCQT += -minimal $$QMAKE_SYNCQT_OPTIONS
} else { } else {

View File

@ -25,10 +25,13 @@ CONFIG(static, static|shared) {
!macx-xcode: \ !macx-xcode: \
addExclusiveBuilds(shared, static) addExclusiveBuilds(shared, static)
CONFIG(debug, debug|release): \ CONFIG(debug, debug|release) {
CONFIG -= release CONFIG -= release
else: \ !force_debug_plist:debug_and_release: \
CONFIG += no_plist
} else {
CONFIG -= debug CONFIG -= debug
}
!macx-xcode { !macx-xcode {
addExclusiveBuilds(debug, release) addExclusiveBuilds(debug, release)

View File

@ -1,6 +1,6 @@
CONFIG -= windows CONFIG -= windows
QMAKE_LFLAGS += $$replace(QMAKE_LFLAGS_CONSOLE, @QMAKE_SUBSYSTEM_SUFFIX@, $$QMAKE_SUBSYSTEM_SUFFIX)
contains(TEMPLATE, ".*app") { contains(TEMPLATE, ".*app") {
QMAKE_LFLAGS += \ wince: QMAKE_LFLAGS += /ENTRY:mainACRTStartup
$$replace(QMAKE_LFLAGS_CONSOLE, @QMAKE_SUBSYSTEM_SUFFIX@, $$QMAKE_SUBSYSTEM_SUFFIX) \ QMAKE_LFLAGS += $$QMAKE_LFLAGS_EXE
$$QMAKE_LFLAGS_EXE
} }

View File

@ -1,8 +1,7 @@
CONFIG -= console CONFIG -= console
contains(TEMPLATE, ".*app"){ QMAKE_LFLAGS += $$replace(QMAKE_LFLAGS_WINDOWS, @QMAKE_SUBSYSTEM_SUFFIX@, $$QMAKE_SUBSYSTEM_SUFFIX)
QMAKE_LFLAGS += \ contains(TEMPLATE, ".*app") {
$$replace(QMAKE_LFLAGS_WINDOWS, @QMAKE_SUBSYSTEM_SUFFIX@, $$QMAKE_SUBSYSTEM_SUFFIX) \ QMAKE_LFLAGS += $$QMAKE_LFLAGS_EXE
$$QMAKE_LFLAGS_EXE
mingw:DEFINES += QT_NEEDS_QMAIN mingw:DEFINES += QT_NEEDS_QMAIN
qt:for(entryLib, $$list($$unique(QMAKE_LIBS_QT_ENTRY))) { qt:for(entryLib, $$list($$unique(QMAKE_LIBS_QT_ENTRY))) {

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -24,6 +24,13 @@
<string>1.0</string> <string>1.0</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NOTE</key> <key>NOTE</key>
<string>This file was generated by Qt/QMake.</string> <string>This file was generated by Qt/QMake.</string>
</dict> </dict>

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -6,6 +6,8 @@
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string> <string>@SHORT_VERSION@</string>
<key>CFBundleVersion</key>
<string>@FULL_VERSION@</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string> <string>Created by Qt/QMake</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -12,7 +12,7 @@ CE_ARCH = ARMV4I
DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _ARMV4I_ armv4i _ARM_ ARM _M_ARM ARM _WIN32 __arm__ DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _ARMV4I_ armv4i _ARM_ ARM _M_ARM ARM _WIN32 __arm__
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /ENTRY:mainACRTStartup QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB
QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB
QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /DLL /SAFESEH:NO QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /DLL /SAFESEH:NO
QMAKE_LIBFLAGS_RELEASE = /LTCG QMAKE_LIBFLAGS_RELEASE = /LTCG

View File

@ -12,7 +12,7 @@ CE_ARCH = x86
DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _X86_ _M_IX86 DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _X86_ _M_IX86
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /ENTRY:mainACRTStartup QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86
QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86
QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /DLL /SAFESEH:NO QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /DLL /SAFESEH:NO
QMAKE_LIBFLAGS_RELEASE = /LTCG QMAKE_LIBFLAGS_RELEASE = /LTCG

View File

@ -10,7 +10,7 @@ CE_ARCH = armv4i
DEFINES += QT_NO_CLIPBOARD QT_NO_ACCESSIBILITY QT_NO_NATIVE_GESTURES QT_NOSTANDARDSHELL_UI_MODEL _CRT_SECURE_NO_DEPRECATE _WIN32_WCE=0x700 $$CE_ARCH _AMRV7_ armv7 _ARM_ DEFINES += QT_NO_CLIPBOARD QT_NO_ACCESSIBILITY QT_NO_NATIVE_GESTURES QT_NOSTANDARDSHELL_UI_MODEL _CRT_SECURE_NO_DEPRECATE _WIN32_WCE=0x700 $$CE_ARCH _AMRV7_ armv7 _ARM_
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:THUMB /ENTRY:mainACRTStartup QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:THUMB
QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:THUMB QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:THUMB
QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:THUMB /DLL /SAFESEH:NO QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:THUMB /DLL /SAFESEH:NO
QMAKE_LIBFLAGS_RELEASE = /LTCG QMAKE_LIBFLAGS_RELEASE = /LTCG

View File

@ -9,7 +9,7 @@ CE_ARCH = _TGTCPU
DEFINES += QT_NO_NATIVE_GESTURES QT_NOSTANDARDSHELL_UI_MODEL _CRT_SECURE_NO_DEPRECATE _WIN32_WCE=0x700 $$CE_ARCH _X86_ _M_IX86 DEFINES += QT_NO_NATIVE_GESTURES QT_NOSTANDARDSHELL_UI_MODEL _CRT_SECURE_NO_DEPRECATE _WIN32_WCE=0x700 $$CE_ARCH _X86_ _M_IX86
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:X86 /ENTRY:mainACRTStartup QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:X86
QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:X86 QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:X86
QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:X86 /DLL /SAFESEH:NO QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,7.00 /MACHINE:X86 /DLL /SAFESEH:NO
QMAKE_LIBFLAGS_RELEASE = /LTCG QMAKE_LIBFLAGS_RELEASE = /LTCG

View File

@ -4328,7 +4328,7 @@
This tutorial teaches you the basics of qmake. The other topics in this This tutorial teaches you the basics of qmake. The other topics in this
manual contain more detailed information about using qmake. manual contain more detailed information about using qmake.
\section1 Starting off Simple \section1 Starting Off Simple
Let's assume that you have just finished a basic implementation of Let's assume that you have just finished a basic implementation of
your application, and you have created the following files: your application, and you have created the following files:

View File

@ -306,8 +306,6 @@ UnixMakefileGenerator::init()
} }
if(!bundle.isEmpty()) { if(!bundle.isEmpty()) {
project->values("QMAKE_BUNDLE") = ProStringList(bundle); project->values("QMAKE_BUNDLE") = ProStringList(bundle);
project->values("ALL_DEPS") += project->first("QMAKE_PKGINFO");
project->values("ALL_DEPS") += project->first("QMAKE_BUNDLE_RESOURCE_FILE");
} else { } else {
project->values("QMAKE_BUNDLE").clear(); project->values("QMAKE_BUNDLE").clear();
project->values("QMAKE_BUNDLE_LOCATION").clear(); project->values("QMAKE_BUNDLE_LOCATION").clear();

View File

@ -430,6 +430,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
} }
} }
} }
QString allDeps;
if (!project->values("QMAKE_APP_FLAG").isEmpty() || project->first("TEMPLATE") == "aux") { if (!project->values("QMAKE_APP_FLAG").isEmpty() || project->first("TEMPLATE") == "aux") {
QString destdir = project->first("DESTDIR").toQString(); QString destdir = project->first("DESTDIR").toQString();
if(!project->isEmpty("QMAKE_BUNDLE")) { if(!project->isEmpty("QMAKE_BUNDLE")) {
@ -490,8 +491,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
deps.prepend(incr_target_dir + " "); deps.prepend(incr_target_dir + " ");
incr_deps = "$(OBJECTS)"; incr_deps = "$(OBJECTS)";
} }
t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << "$(TARGET)"
<< endl << endl;
//real target //real target
t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps << " " << target_deps t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps << " " << target_deps
@ -505,9 +504,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << "\n\t" << var("QMAKE_POST_LINK"); t << "\n\t" << var("QMAKE_POST_LINK");
t << endl << endl; t << endl << endl;
} else { } else {
t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << "$(TARGET)"
<< endl << endl;
t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) " t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(OBJECTS) "
<< target_deps << " " << var("POST_TARGETDEPS") << "\n\t"; << target_deps << " " << var("POST_TARGETDEPS") << "\n\t";
if (project->first("TEMPLATE") != "aux") { if (project->first("TEMPLATE") != "aux") {
@ -521,6 +517,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
} }
t << endl << endl; t << endl << endl;
} }
allDeps = " $(TARGET)";
} else if(!project->isActiveConfig("staticlib")) { } else if(!project->isActiveConfig("staticlib")) {
QString destdir = unescapeFilePath(project->first("DESTDIR").toQString()), incr_deps; QString destdir = unescapeFilePath(project->first("DESTDIR").toQString()), incr_deps;
if(!project->isEmpty("QMAKE_BUNDLE")) { if(!project->isEmpty("QMAKE_BUNDLE")) {
@ -580,19 +577,15 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
incr_deps = "$(OBJECTS)"; incr_deps = "$(OBJECTS)";
} }
t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ")
<< " " << destdir << "$(TARGET)\n\n";
//real target //real target
t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") << " " t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") << " "
<< incr_deps << " $(SUBLIBS) " << target_deps << " " << var("POST_TARGETDEPS"); << incr_deps << " $(SUBLIBS) " << target_deps << " " << var("POST_TARGETDEPS");
} else { } else {
t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << " " <<
destdir << "$(TARGET)\n\n";
t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS")
<< " $(OBJECTS) $(SUBLIBS) $(OBJCOMP) " << target_deps << " $(OBJECTS) $(SUBLIBS) $(OBJCOMP) " << target_deps
<< " " << var("POST_TARGETDEPS"); << " " << var("POST_TARGETDEPS");
} }
allDeps = ' ' + destdir + "$(TARGET)";
if(!destdir.isEmpty()) if(!destdir.isEmpty())
t << "\n\t" << mkdir_p_asstring(destdir, false); t << "\n\t" << mkdir_p_asstring(destdir, false);
if(!project->isEmpty("QMAKE_PRE_LINK")) if(!project->isEmpty("QMAKE_PRE_LINK"))
@ -695,9 +688,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
} }
} else { } else {
QString destdir = project->first("DESTDIR").toQString(); QString destdir = project->first("DESTDIR").toQString();
t << "all: " << escapeDependencyPath(deps) << " " << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")),""," "," ") << destdir << "$(TARGET) " allDeps = ' ' + destdir + "$(TARGET)"
<< varGlue("QMAKE_AR_SUBLIBS", destdir, " " + destdir, "") << "\n\n" + varGlue("QMAKE_AR_SUBLIBS", ' ' + destdir, ' ' + destdir, "");
<< "staticlib: " << destdir << "$(TARGET)\n\n"; t << "staticlib: " << destdir << "$(TARGET)\n\n";
if(project->isEmpty("QMAKE_AR_SUBLIBS")) { if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS") t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS")
<< " $(OBJECTS) $(OBJCOMP) " << var("POST_TARGETDEPS") << "\n\t"; << " $(OBJECTS) $(OBJCOMP) " << var("POST_TARGETDEPS") << "\n\t";
@ -763,85 +756,111 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< "@$(QMAKE) -prl " << buildArgs() << " " << project->projectFile() << endl; << "@$(QMAKE) -prl " << buildArgs() << " " << project->projectFile() << endl;
} }
if(!project->first("QMAKE_PKGINFO").isEmpty()) { if (!project->isEmpty("QMAKE_BUNDLE")) {
ProString pkginfo = escapeFilePath(project->first("QMAKE_PKGINFO")); QHash<QString, QString> symlinks;
QString destdir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/Contents"; ProStringList &alldeps = project->values("ALL_DEPS");
t << pkginfo << ": \n\t"; QString bundle_dir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/";
if(!destdir.isEmpty()) if (!project->first("QMAKE_PKGINFO").isEmpty()) {
t << mkdir_p_asstring(destdir) << "\n\t"; ProString pkginfo = escapeFilePath(project->first("QMAKE_PKGINFO"));
t << "@$(DEL_FILE) " << pkginfo << "\n\t" bundledFiles << pkginfo;
<< "@echo \"APPL" alldeps << pkginfo;
<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ? QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) QString destdir = bundle_dir + "Contents";
<< "\" >" << pkginfo << endl; t << pkginfo << ": \n\t";
} if (!destdir.isEmpty())
if(!project->first("QMAKE_BUNDLE_RESOURCE_FILE").isEmpty()) { t << mkdir_p_asstring(destdir) << "\n\t";
ProString resources = escapeFilePath(project->first("QMAKE_BUNDLE_RESOURCE_FILE")); t << "@$(DEL_FILE) " << pkginfo << "\n\t"
bundledFiles << resources; << "@echo \"APPL"
QString destdir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/Contents/Resources"; << (project->isEmpty("QMAKE_PKGINFO_TYPEINFO")
t << resources << ": \n\t"; ? QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4))
t << mkdir_p_asstring(destdir) << "\n\t"; << "\" >" << pkginfo << endl;
t << "@touch " << resources << "\n\t\n";
}
if(!project->isEmpty("QMAKE_BUNDLE")) {
//copy the plist
QString info_plist = escapeFilePath(fileFixify(project->first("QMAKE_INFO_PLIST").toQString())),
info_plist_out = escapeFilePath(project->first("QMAKE_INFO_PLIST_OUT").toQString());
if (info_plist.isEmpty())
info_plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE");
bundledFiles << info_plist_out;
QString destdir = info_plist_out.section(Option::dir_sep, 0, -2);
t << info_plist_out << ": \n\t";
if(!destdir.isEmpty())
t << mkdir_p_asstring(destdir, false) << "\n\t";
ProStringList commonSedArgs;
if (!project->values("VERSION").isEmpty())
commonSedArgs << "-e \"s,@SHORT_VERSION@," << project->first("VER_MAJ") << "." << project->first("VER_MIN") << ",g\" ";
commonSedArgs << "-e \"s,@TYPEINFO@,"<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" ";
if(project->first("TEMPLATE") == "app") {
QString icon = fileFixify(var("ICON"));
QString bundlePrefix = project->first("QMAKE_TARGET_BUNDLE_PREFIX").toQString();
if (bundlePrefix.isEmpty())
bundlePrefix = "com.yourcompany";
if (bundlePrefix.endsWith("."))
bundlePrefix.chop(1);
QString bundleIdentifier = bundlePrefix + "." + var("QMAKE_BUNDLE");
if (bundleIdentifier.endsWith(".app"))
bundleIdentifier.chop(4);
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
foreach (const ProString &arg, commonSedArgs)
t << arg;
t << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" "
<< "-e \"s,@BUNDLEIDENTIFIER@," << bundleIdentifier << ",g\" "
<< "-e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" "
<< "-e \"s,@TYPEINFO@,"<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
<< "" << info_plist << " >" << info_plist_out << endl;
//copy the icon
if(!project->isEmpty("ICON")) {
QString dir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/Contents/Resources/";
const QString icon_path = escapeFilePath(dir + icon.section(Option::dir_sep, -1));
bundledFiles << icon_path;
t << icon_path << ": " << icon << "\n\t"
<< mkdir_p_asstring(dir) << "\n\t"
<< "@$(DEL_FILE) " << icon_path << "\n\t"
<< "@$(COPY_FILE) " << escapeFilePath(icon) << " " << icon_path << endl;
}
} else {
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
foreach (const ProString &arg, commonSedArgs)
t << arg;
t << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
<< "-e \"s,@TYPEINFO@,"
<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
<< "" << info_plist << " >" << info_plist_out << endl;
} }
if (!project->first("QMAKE_BUNDLE_RESOURCE_FILE").isEmpty()) {
ProString resources = escapeFilePath(project->first("QMAKE_BUNDLE_RESOURCE_FILE"));
bundledFiles << resources;
alldeps << resources;
QString destdir = bundle_dir + "Contents/Resources";
t << resources << ": \n\t";
t << mkdir_p_asstring(destdir) << "\n\t";
t << "@touch " << resources << "\n\t\n";
}
//copy the plist
while (!project->isActiveConfig("no_plist")) { // 'while' just to be able to 'break'
QString info_plist = escapeFilePath(fileFixify(project->first("QMAKE_INFO_PLIST").toQString()));
if (info_plist.isEmpty())
info_plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE");
if (!exists(Option::fixPathToLocalOS(info_plist))) {
warn_msg(WarnLogic, "Could not resolve Info.plist: '%s'. Check if QMAKE_INFO_PLIST points to a valid file.",
info_plist.toLatin1().constData());
break;
}
bool isApp = (project->first("TEMPLATE") == "app");
QString info_plist_out = escapeFilePath(
bundle_dir + (isApp ? "Contents/Info.plist"
: "Versions/" + project->first("QMAKE_FRAMEWORK_VERSION")
+ "/Resources/Info.plist"));
bundledFiles << info_plist_out;
alldeps << info_plist_out;
QString destdir = info_plist_out.section(Option::dir_sep, 0, -2);
t << info_plist_out << ": \n\t";
if (!destdir.isEmpty())
t << mkdir_p_asstring(destdir, false) << "\n\t";
ProStringList commonSedArgs;
if (!project->values("VERSION").isEmpty()) {
commonSedArgs << "-e \"s,@SHORT_VERSION@," << project->first("VER_MAJ") << "."
<< project->first("VER_MIN") << ",g\" ";
commonSedArgs << "-e \"s,@FULL_VERSION@," << project->first("VER_MAJ") << "."
<< project->first("VER_MIN") << "."
<< project->first("VER_PAT") << ",g\" ";
}
commonSedArgs << "-e \"s,@TYPEINFO@,"<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" ";
if (isApp) {
QString icon = fileFixify(var("ICON"));
QString bundlePrefix = project->first("QMAKE_TARGET_BUNDLE_PREFIX").toQString();
if (bundlePrefix.isEmpty())
bundlePrefix = "com.yourcompany";
if (bundlePrefix.endsWith("."))
bundlePrefix.chop(1);
QString bundleIdentifier = bundlePrefix + "." + var("QMAKE_BUNDLE");
if (bundleIdentifier.endsWith(".app"))
bundleIdentifier.chop(4);
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
foreach (const ProString &arg, commonSedArgs)
t << arg;
t << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" "
<< "-e \"s,@BUNDLEIDENTIFIER@," << bundleIdentifier << ",g\" "
<< "-e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" "
<< "-e \"s,@TYPEINFO@,"<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
<< "" << info_plist << " >" << info_plist_out << endl;
//copy the icon
if (!project->isEmpty("ICON")) {
QString dir = bundle_dir + "Contents/Resources/";
const QString icon_path = escapeFilePath(dir + icon.section(Option::dir_sep, -1));
bundledFiles << icon_path;
alldeps << icon_path;
t << icon_path << ": " << icon << "\n\t"
<< mkdir_p_asstring(dir) << "\n\t"
<< "@$(DEL_FILE) " << icon_path << "\n\t"
<< "@$(COPY_FILE) " << escapeFilePath(icon) << " " << icon_path << endl;
}
} else {
symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources";
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
foreach (const ProString &arg, commonSedArgs)
t << arg;
t << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
<< "-e \"s,@TYPEINFO@,"
<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
<< "" << info_plist << " >" << info_plist_out << endl;
}
break;
} // project->isActiveConfig("no_plist")
//copy other data //copy other data
if(!project->isEmpty("QMAKE_BUNDLE_DATA")) { if(!project->isEmpty("QMAKE_BUNDLE_DATA")) {
QString bundle_dir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/";
const ProStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA"); const ProStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA");
for(int i = 0; i < bundle_data.count(); i++) { for(int i = 0; i < bundle_data.count(); i++) {
const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files")); const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files"));
@ -851,11 +870,12 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
if (!project->isEmpty(vkey)) { if (!project->isEmpty(vkey)) {
QString version = project->first(vkey) + "/" + QString version = project->first(vkey) + "/" +
project->first("QMAKE_FRAMEWORK_VERSION") + "/"; project->first("QMAKE_FRAMEWORK_VERSION") + "/";
QString link = Option::fixPathToLocalOS(path + project->first(pkey)); ProString name = project->first(pkey);
bundledFiles << link; int pos = name.indexOf('/');
t << link << ": \n\t" if (pos > 0)
<< mkdir_p_asstring(path) << "\n\t" name = name.mid(0, pos);
<< "@$(SYMLINK) " << version << project->first(pkey) << " " << path << endl; symlinks[Option::fixPathToLocalOS(path + name)] =
project->first(vkey) + "/Current/" + name;
path += version; path += version;
} }
path += project->first(pkey).toQString(); path += project->first(pkey).toQString();
@ -868,6 +888,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
src = escapeFilePath(src); src = escapeFilePath(src);
const QString dst = escapeFilePath(path + Option::dir_sep + fileInfo(fn).fileName()); const QString dst = escapeFilePath(path + Option::dir_sep + fileInfo(fn).fileName());
bundledFiles << dst; bundledFiles << dst;
alldeps << dst;
t << dst << ": " << src << "\n\t" t << dst << ": " << src << "\n\t"
<< mkdir_p_asstring(path) << "\n\t"; << mkdir_p_asstring(path) << "\n\t";
QFileInfo fi(fileInfo(fn)); QFileInfo fi(fileInfo(fn));
@ -880,8 +901,21 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
} }
} }
} }
QHash<QString, QString>::ConstIterator symIt = symlinks.constBegin(),
symEnd = symlinks.constEnd();
for (; symIt != symEnd; ++symIt) {
bundledFiles << symIt.key();
alldeps << symIt.key();
t << symIt.key() << ":\n\t"
<< mkdir_p_asstring(bundle_dir) << "\n\t"
<< "@$(SYMLINK) " << symIt.value() << " " << bundle_dir << endl;
}
} }
t << endl << "all: " << escapeDependencyPath(deps)
<< valGlue(escapeDependencyPaths(project->values("ALL_DEPS")), " \\\n\t\t", " \\\n\t\t", "")
<< allDeps << endl << endl;
t << "dist: distdir FORCE\n\t"; t << "dist: distdir FORCE\n\t";
t << "(cd `dirname $(DISTDIR)` && $(TAR) $(DISTNAME).tar $(DISTNAME) && $(COMPRESS) $(DISTNAME).tar)" t << "(cd `dirname $(DISTDIR)` && $(TAR) $(DISTNAME).tar $(DISTNAME) && $(COMPRESS) $(DISTNAME).tar)"
" && $(MOVE) `dirname $(DISTDIR)`" << Option::dir_sep << "$(DISTNAME).tar.gz ." " && $(MOVE) `dirname $(DISTDIR)`" << Option::dir_sep << "$(DISTNAME).tar.gz ."
@ -1315,44 +1349,6 @@ void UnixMakefileGenerator::init2()
project->values("QMAKE_CFLAGS") += MD_flag; project->values("QMAKE_CFLAGS") += MD_flag;
project->values("QMAKE_CXXFLAGS") += MD_flag; project->values("QMAKE_CXXFLAGS") += MD_flag;
} }
if(!project->isEmpty("QMAKE_BUNDLE")) {
QString plist = fileFixify(project->first("QMAKE_INFO_PLIST").toQString(), qmake_getpwd());
if(plist.isEmpty())
plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE");
if(exists(Option::fixPathToLocalOS(plist))) {
project->values("QMAKE_INFO_PLIST_OUT").append(project->first("DESTDIR") +
project->first("QMAKE_BUNDLE") +
"/Contents/Info.plist");
project->values("ALL_DEPS") += project->first("QMAKE_INFO_PLIST_OUT");
if(!project->isEmpty("ICON") && project->first("TEMPLATE") == "app")
project->values("ALL_DEPS") += project->first("DESTDIR") +
project->first("QMAKE_BUNDLE") +
"/Contents/Resources/" + project->first("ICON").toQString().section('/', -1);
if(!project->isEmpty("QMAKE_BUNDLE_DATA")) {
QString bundle_dir = project->first("DESTDIR") + project->first("QMAKE_BUNDLE") + "/";
ProStringList &alldeps = project->values("ALL_DEPS");
const ProStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA");
for(int i = 0; i < bundle_data.count(); i++) {
const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files"));
QString path = bundle_dir;
const ProKey vkey(bundle_data[i] + ".version");
const ProKey pkey(bundle_data[i] + ".path");
if (!project->isEmpty(vkey)) {
alldeps += Option::fixPathToLocalOS(path + Option::dir_sep + project->first(pkey));
path += project->first(vkey) + "/" +
project->first("QMAKE_FRAMEWORK_VERSION") + "/";
}
path += project->first(pkey);
path = Option::fixPathToLocalOS(path);
for(int file = 0; file < files.count(); file++)
alldeps += path + Option::dir_sep + fileInfo(files[file].toQString()).fileName();
}
}
} else {
warn_msg(WarnLogic, "Could not resolve Info.plist: '%s'. Check if QMAKE_INFO_PLIST points to a valid file.", plist.toLatin1().constData());
}
}
} }
QString QString

View File

@ -97,7 +97,7 @@ bool CeSdkHandler::parse()
return false; return false;
} }
return m_list.size() > 0 ? true : false; return m_list.size() > 0;
} }
QString CeSdkHandler::fixPaths(QString path) const QString CeSdkHandler::fixPaths(QString path) const

View File

@ -341,7 +341,8 @@ static QStringList unquote(const QStringList &values)
} }
// Tree file generation --------------------------------------------- // Tree file generation ---------------------------------------------
void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter) { void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName,
VCProject &tool, const QString &filter, const QString &filterId) {
if (children.size()) { if (children.size()) {
// Filter // Filter
@ -362,38 +363,39 @@ void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString
if ((*it)->children.size()) if ((*it)->children.size())
{ {
if ( !tempFilterName.isEmpty() ) if ( !tempFilterName.isEmpty() )
(*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName); (*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName, filterId);
else else
(*it)->generateXML(xml, xmlFilter, it.key(), tool, filter); (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter, filterId);
} }
// Second round, do leafs // Second round, do leafs
for (it = children.constBegin(); it != end; ++it) for (it = children.constBegin(); it != end; ++it)
if (!(*it)->children.size()) if (!(*it)->children.size())
{ {
if ( !tempFilterName.isEmpty() ) if ( !tempFilterName.isEmpty() )
(*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName); (*it)->generateXML(xml, xmlFilter, it.key(), tool, tempFilterName, filterId);
else else
(*it)->generateXML(xml, xmlFilter, it.key(), tool, filter); (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter, filterId);
} }
} else { } else {
// Leaf // Leaf
xml << tag(_ItemGroup); xml << tag(_ItemGroup);
xmlFilter << tag(_ItemGroup); xmlFilter << tag(_ItemGroup);
VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, info, filter); VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, info, filter, filterId);
xmlFilter << closetag(); xmlFilter << closetag();
xml << closetag(); xml << closetag();
} }
} }
// Flat file generation --------------------------------------------- // Flat file generation ---------------------------------------------
void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/, VCProject &tool, const QString &filter) { void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/,
VCProject &tool, const QString &filter, const QString &filterId) {
if (children.size()) { if (children.size()) {
ChildrenMapFlat::ConstIterator it = children.constBegin(); ChildrenMapFlat::ConstIterator it = children.constBegin();
ChildrenMapFlat::ConstIterator end = children.constEnd(); ChildrenMapFlat::ConstIterator end = children.constEnd();
xml << tag(_ItemGroup); xml << tag(_ItemGroup);
xmlFilter << tag(_ItemGroup); xmlFilter << tag(_ItemGroup);
for (; it != end; ++it) { for (; it != end; ++it) {
VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, (*it), filter); VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, (*it), filter, filterId);
} }
xml << closetag(); xml << closetag();
xmlFilter << closetag(); xmlFilter << closetag();
@ -1836,22 +1838,47 @@ void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutpu
if (!root->hasElements()) if (!root->hasElements())
return; return;
root->generateXML(xml, xmlFilter, "", project, filtername); // output root tree root->generateXML(xml, xmlFilter, "", project, filtername, filtername); // output root tree
} }
// Output all configurations (by filtername) for a file (by info) // Output all configurations (by filtername) for a file (by info)
// A filters config output is in VCFilter.outputFileConfig() // A filters config output is in VCFilter.outputFileConfig()
void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCFilterFile &info, const QString &filtername) void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter,
const VCFilterFile &info, const QString &filtername,
const QString &filterId)
{ {
// We need to check if the file has any custom build step. // We need to check if the file has any custom build step.
// If there is one then it has to be included with "CustomBuild Include" // If there is one then it has to be included with "CustomBuild Include"
bool fileAdded = false; bool hasCustomBuildStep = false;
QVarLengthArray<OutputFilterData> data(project.SingleProjects.count());
for (int i = 0; i < project.SingleProjects.count(); ++i) { for (int i = 0; i < project.SingleProjects.count(); ++i) {
const VCFilter &filter = project.SingleProjects.at(i).filterByName(filtername); data[i].filter = project.SingleProjects.at(i).filterByName(filterId);
if (filter.Config) // only if the filter is not empty if (!data[i].filter.Config) // only if the filter is not empty
if (outputFileConfig(filter, xml, xmlFilter, info.file, fileAdded)) // only add it once. continue;
fileAdded = true; VCFilter &filter = data[i].filter;
// Clearing each filter tool
filter.useCustomBuildTool = false;
filter.useCompilerTool = false;
filter.CustomBuildTool = VCCustomBuildTool();
filter.CustomBuildTool.config = filter.Config;
filter.CompilerTool = VCCLCompilerTool();
filter.CompilerTool.config = filter.Config;
VCFilterFile fileInFilter = filter.findFile(info.file, &data[i].inBuild);
data[i].inBuild &= !fileInFilter.excludeFromBuild;
if (data[i].inBuild && filter.addExtraCompiler(fileInFilter))
hasCustomBuildStep = true;
}
bool fileAdded = false;
for (int i = 0; i < project.SingleProjects.count(); ++i) {
const VCFilter &filter = project.SingleProjects.at(i).filterByName(filterId);
if (!filter.Config) // only if the filter is not empty
continue;
if (outputFileConfig(&data[i], xml, xmlFilter, info.file, fileAdded,
hasCustomBuildStep))
fileAdded = true;
} }
if ( !fileAdded ) if ( !fileAdded )
@ -1861,42 +1888,25 @@ void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, Xml
xmlFilter << closetag(); xmlFilter << closetag();
} }
bool VCXProjectWriter::outputFileConfig(VCFilter filter, XmlOutput &xml, XmlOutput &xmlFilter, bool VCXProjectWriter::outputFileConfig(OutputFilterData *d, XmlOutput &xml, XmlOutput &xmlFilter,
const QString &filename, bool fileAdded) const QString &filename, bool fileAdded,
bool hasCustomBuildStep)
{ {
// Clearing each filter tool VCFilter &filter = d->filter;
filter.useCustomBuildTool = false; if (d->inBuild) {
filter.useCompilerTool = false;
filter.CustomBuildTool = VCCustomBuildTool();
filter.CustomBuildTool.config = filter.Config;
filter.CompilerTool = VCCLCompilerTool();
filter.CompilerTool.config = filter.Config;
bool inBuild = false;
VCFilterFile info;
for (int i = 0; i < filter.Files.count(); ++i) {
if (filter.Files.at(i).file == filename) {
info = filter.Files.at(i);
inBuild = true;
}
}
inBuild &= !info.excludeFromBuild;
if (inBuild) {
filter.addExtraCompiler(info);
if (filter.Project->usePCH) if (filter.Project->usePCH)
filter.modifyPCHstage(info.file); filter.modifyPCHstage(filename);
} else { } else {
// Excluded files uses an empty compiler stage // Excluded files uses an empty compiler stage
if(info.excludeFromBuild) if (d->info.excludeFromBuild)
filter.useCompilerTool = true; filter.useCompilerTool = true;
} }
// Actual XML output ---------------------------------- // Actual XML output ----------------------------------
if (filter.useCustomBuildTool || filter.useCompilerTool if (hasCustomBuildStep || filter.useCompilerTool
|| !inBuild || filter.Name.startsWith("Deployment Files")) { || !d->inBuild || filter.Name.startsWith("Deployment Files")) {
if (filter.useCustomBuildTool) if (hasCustomBuildStep)
{ {
if (!fileAdded) { if (!fileAdded) {
fileAdded = true; fileAdded = true;
@ -1925,13 +1935,13 @@ bool VCXProjectWriter::outputFileConfig(VCFilter filter, XmlOutput &xml, XmlOutp
} }
const QString condition = generateCondition(*filter.Config); const QString condition = generateCondition(*filter.Config);
if(!inBuild) { if (!d->inBuild) {
xml << tag("ExcludedFromBuild") xml << tag("ExcludedFromBuild")
<< attrTag("Condition", condition) << attrTag("Condition", condition)
<< valueTag("true"); << valueTag("true");
} }
if (filter.Name.startsWith("Deployment Files") && inBuild) { if (filter.Name.startsWith("Deployment Files") && d->inBuild) {
xml << tag("DeploymentContent") xml << tag("DeploymentContent")
<< attrTag("Condition", condition) << attrTag("Condition", condition)
<< valueTag("true"); << valueTag("true");

View File

@ -56,7 +56,8 @@ public:
} }
virtual void addElement(const QString &filepath, const VCFilterFile &allInfo) = 0; virtual void addElement(const QString &filepath, const VCFilterFile &allInfo) = 0;
virtual void removeElements()= 0; virtual void removeElements()= 0;
virtual void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter) = 0; virtual void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName,
VCProject &tool, const QString &filter, const QString &filterId) = 0;
virtual bool hasElements() = 0; virtual bool hasElements() = 0;
}; };
@ -106,7 +107,8 @@ public:
children.clear(); children.clear();
} }
void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter); void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool,
const QString &filter, const QString &filterId);
bool hasElements() { bool hasElements() {
return children.size() != 0; return children.size() != 0;
} }
@ -146,7 +148,8 @@ public:
children.clear(); children.clear();
} }
void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &proj, const QString &filter); void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &proj,
const QString &filter, const QString &filterId);
bool hasElements() { bool hasElements() {
return children.size() != 0; return children.size() != 0;
} }
@ -171,10 +174,17 @@ public:
void write(XmlOutput &, VCFilter &); void write(XmlOutput &, VCFilter &);
private: private:
struct OutputFilterData
{
VCFilter filter;
VCFilterFile info;
bool inBuild;
};
static void addFilters(VCProject &project, XmlOutput &xmlFilter, const QString &filterName); static void addFilters(VCProject &project, XmlOutput &xmlFilter, const QString &filterName);
static void outputFilter(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername); static void outputFilter(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername);
static void outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCFilterFile &info, const QString &filtername); static void outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCFilterFile &info, const QString &filtername, const QString &filterId);
static bool outputFileConfig(VCFilter filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, bool fileAdded); static bool outputFileConfig(OutputFilterData *d, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, bool fileAdded, bool hasCustomBuildStep);
static void outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &fileName, const QString &filterName); static void outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &fileName, const QString &filterName);
static QString generateCondition(const VCConfiguration &config); static QString generateCondition(const VCConfiguration &config);

View File

@ -2241,6 +2241,19 @@ void VCFilter::modifyPCHstage(QString str)
CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)"); CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)");
} }
VCFilterFile VCFilter::findFile(const QString &filePath, bool *found) const
{
for (int i = 0; i < Files.count(); ++i) {
const VCFilterFile &f = Files.at(i);
if (f.file == filePath) {
*found = true;
return f;
}
}
*found = false;
return VCFilterFile();
}
bool VCFilter::addExtraCompiler(const VCFilterFile &info) bool VCFilter::addExtraCompiler(const VCFilterFile &info)
{ {
const QStringList &extraCompilers = Project->extraCompilerSources.value(info.file); const QStringList &extraCompilers = Project->extraCompilerSources.value(info.file);
@ -2508,14 +2521,14 @@ void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)
// XML output functionality // XML output functionality
VCProject tempProj; VCProject tempProj;
tempProj.SingleProjects += tool; tempProj.SingleProjects += tool;
outputFilter(tempProj, xml, "Sources"); outputFilter(tempProj, xml, "Source Files");
outputFilter(tempProj, xml, "Headers"); outputFilter(tempProj, xml, "Header Files");
outputFilter(tempProj, xml, "GeneratedFiles"); outputFilter(tempProj, xml, "Generated Files");
outputFilter(tempProj, xml, "LexYaccFiles"); outputFilter(tempProj, xml, "LexYacc Files");
outputFilter(tempProj, xml, "TranslationFiles"); outputFilter(tempProj, xml, "Translation Files");
outputFilter(tempProj, xml, "FormFiles"); outputFilter(tempProj, xml, "Form Files");
outputFilter(tempProj, xml, "ResourceFiles"); outputFilter(tempProj, xml, "Resource Files");
outputFilter(tempProj, xml, "DeploymentFiles"); outputFilter(tempProj, xml, "Deployment Files");
QSet<QString> extraCompilersInProject; QSet<QString> extraCompilersInProject;
for (int i = 0; i < tool.ExtraCompilersFiles.count(); ++i) { for (int i = 0; i < tool.ExtraCompilersFiles.count(); ++i) {
@ -2529,7 +2542,7 @@ void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)
for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) {
outputFilter(tempProj, xml, tempProj.ExtraCompilers.at(x)); outputFilter(tempProj, xml, tempProj.ExtraCompilers.at(x));
} }
outputFilter(tempProj, xml, "RootFiles"); outputFilter(tempProj, xml, "Root Files");
xml << closetag(q_Files) xml << closetag(q_Files)
<< tag(_Globals) << tag(_Globals)
<< data(); // No "/>" end tag << data(); // No "/>" end tag
@ -2561,18 +2574,18 @@ void VCProjectWriter::write(XmlOutput &xml, VCProject &tool)
write(xml, tool.SingleProjects.at(i).Configuration); write(xml, tool.SingleProjects.at(i).Configuration);
xml << closetag(_Configurations) xml << closetag(_Configurations)
<< tag(q_Files); << tag(q_Files);
outputFilter(tool, xml, "Sources"); outputFilter(tool, xml, "Source Files");
outputFilter(tool, xml, "Headers"); outputFilter(tool, xml, "Header Files");
outputFilter(tool, xml, "GeneratedFiles"); outputFilter(tool, xml, "Generated Files");
outputFilter(tool, xml, "LexYaccFiles"); outputFilter(tool, xml, "LexYacc Files");
outputFilter(tool, xml, "TranslationFiles"); outputFilter(tool, xml, "Translation Files");
outputFilter(tool, xml, "FormFiles"); outputFilter(tool, xml, "Form Files");
outputFilter(tool, xml, "ResourceFiles"); outputFilter(tool, xml, "Resource Files");
outputFilter(tool, xml, "DeploymentFiles"); outputFilter(tool, xml, "Deployment Files");
for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { for (int x = 0; x < tool.ExtraCompilers.count(); ++x) {
outputFilter(tool, xml, tool.ExtraCompilers.at(x)); outputFilter(tool, xml, tool.ExtraCompilers.at(x));
} }
outputFilter(tool, xml, "RootFiles"); outputFilter(tool, xml, "Root Files");
xml << closetag(q_Files) xml << closetag(q_Files)
<< tag(_Globals) << tag(_Globals)
<< data(); // No "/>" end tag << data(); // No "/>" end tag
@ -2974,14 +2987,8 @@ void VCProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, const Q
filter.CompilerTool.WarningLevel = warningLevelUnknown; filter.CompilerTool.WarningLevel = warningLevelUnknown;
filter.CompilerTool.config = filter.Config; filter.CompilerTool.config = filter.Config;
bool inBuild = false; bool inBuild;
VCFilterFile info; VCFilterFile info = filter.findFile(filename, &inBuild);
for (int i = 0; i < filter.Files.count(); ++i) {
if (filter.Files.at(i).file == filename) {
info = filter.Files.at(i);
inBuild = true;
}
}
inBuild &= !info.excludeFromBuild; inBuild &= !info.excludeFromBuild;
if (inBuild) { if (inBuild) {

View File

@ -72,12 +72,6 @@ enum DotNET {
forcing the tool to utilize default values. forcing the tool to utilize default values.
False/True values will be in the output... False/True values will be in the output...
*/ */
enum customBuildCheck {
none,
mocSrc,
mocHdr,
lexyacc
};
enum triState { enum triState {
unset = -1, unset = -1,
_False = 0, _False = 0,
@ -958,6 +952,7 @@ public:
void addFiles(const ProStringList& fileList); void addFiles(const ProStringList& fileList);
bool addExtraCompiler(const VCFilterFile &info); bool addExtraCompiler(const VCFilterFile &info);
void modifyPCHstage(QString str); void modifyPCHstage(QString str);
VCFilterFile findFile(const QString &filePath, bool *found) const;
// Variables // Variables
QString Name; QString Name;
@ -968,8 +963,6 @@ public:
VCConfiguration* Config; VCConfiguration* Config;
QList<VCFilterFile> Files; QList<VCFilterFile> Files;
customBuildCheck CustomBuild;
bool useCustomBuildTool; bool useCustomBuildTool;
VCCustomBuildTool CustomBuildTool; VCCustomBuildTool CustomBuildTool;

View File

@ -1346,7 +1346,6 @@ void VcprojGenerator::initDeploymentTool()
if (conf.WinRT) { if (conf.WinRT) {
vcProject.DeploymentFiles.Project = this; vcProject.DeploymentFiles.Project = this;
vcProject.DeploymentFiles.Config = &(vcProject.Configuration); vcProject.DeploymentFiles.Config = &(vcProject.Configuration);
vcProject.DeploymentFiles.CustomBuild = none;
} }
} }
} }
@ -1385,7 +1384,6 @@ void VcprojGenerator::initRootFiles()
vcProject.RootFiles.Project = this; vcProject.RootFiles.Project = this;
vcProject.RootFiles.Config = &(vcProject.Configuration); vcProject.RootFiles.Config = &(vcProject.Configuration);
vcProject.RootFiles.CustomBuild = none;
} }
void VcprojGenerator::initSourceFiles() void VcprojGenerator::initSourceFiles()
@ -1398,7 +1396,6 @@ void VcprojGenerator::initSourceFiles()
vcProject.SourceFiles.Project = this; vcProject.SourceFiles.Project = this;
vcProject.SourceFiles.Config = &(vcProject.Configuration); vcProject.SourceFiles.Config = &(vcProject.Configuration);
vcProject.SourceFiles.CustomBuild = none;
} }
void VcprojGenerator::initHeaderFiles() void VcprojGenerator::initHeaderFiles()
@ -1450,7 +1447,6 @@ void VcprojGenerator::initLexYaccFiles()
vcProject.LexYaccFiles.Project = this; vcProject.LexYaccFiles.Project = this;
vcProject.LexYaccFiles.Config = &(vcProject.Configuration); vcProject.LexYaccFiles.Config = &(vcProject.Configuration);
vcProject.LexYaccFiles.CustomBuild = lexyacc;
} }
void VcprojGenerator::initTranslationFiles() void VcprojGenerator::initTranslationFiles()
@ -1464,7 +1460,6 @@ void VcprojGenerator::initTranslationFiles()
vcProject.TranslationFiles.Project = this; vcProject.TranslationFiles.Project = this;
vcProject.TranslationFiles.Config = &(vcProject.Configuration); vcProject.TranslationFiles.Config = &(vcProject.Configuration);
vcProject.TranslationFiles.CustomBuild = none;
} }
void VcprojGenerator::initFormFiles() void VcprojGenerator::initFormFiles()
@ -1476,7 +1471,6 @@ void VcprojGenerator::initFormFiles()
vcProject.FormFiles.addFiles(project->values("FORMS")); vcProject.FormFiles.addFiles(project->values("FORMS"));
vcProject.FormFiles.Project = this; vcProject.FormFiles.Project = this;
vcProject.FormFiles.Config = &(vcProject.Configuration); vcProject.FormFiles.Config = &(vcProject.Configuration);
vcProject.FormFiles.CustomBuild = none;
} }
void VcprojGenerator::initResourceFiles() void VcprojGenerator::initResourceFiles()
@ -1526,7 +1520,6 @@ void VcprojGenerator::initResourceFiles()
vcProject.ResourceFiles.Project = this; vcProject.ResourceFiles.Project = this;
vcProject.ResourceFiles.Config = &(vcProject.Configuration); vcProject.ResourceFiles.Config = &(vcProject.Configuration);
vcProject.ResourceFiles.CustomBuild = none;
} }
void VcprojGenerator::initExtraCompilerOutputs() void VcprojGenerator::initExtraCompilerOutputs()
@ -1603,7 +1596,6 @@ void VcprojGenerator::initExtraCompilerOutputs()
} }
extraCompile.Project = this; extraCompile.Project = this;
extraCompile.Config = &(vcProject.Configuration); extraCompile.Config = &(vcProject.Configuration);
extraCompile.CustomBuild = none;
vcProject.ExtraCompilersFiles.append(extraCompile); vcProject.ExtraCompilersFiles.append(extraCompile);
} }

View File

@ -20,6 +20,7 @@ Intel Corporation
Mozilla Corporation Mozilla Corporation
Turbulenz Turbulenz
Klarälvdalens Datakonsult AB Klarälvdalens Datakonsult AB
Microsoft Open Technologies, Inc.
Jacek Caban Jacek Caban
Mark Callow Mark Callow

View File

@ -59,6 +59,7 @@ Intel Corporation
Jin Yang Jin Yang
Andy Chen Andy Chen
Josh Triplett Josh Triplett
Sudarsana Nagineni
Klarälvdalens Datakonsult AB Klarälvdalens Datakonsult AB
Milian Wolff Milian Wolff
@ -78,3 +79,6 @@ Ulrik Persson (ddefrostt)
Mark Banner (standard8mbp) Mark Banner (standard8mbp)
David Kilzer David Kilzer
Microsoft Open Technologies, Inc.
Cooper Partin
Austin Kinross

View File

@ -23,9 +23,10 @@
#define COMPILER_EXPORT #define COMPILER_EXPORT
#endif #endif
#include "KHR/khrplatform.h"
#include <stddef.h> #include <stddef.h>
#include "KHR/khrplatform.h"
// //
// This is the platform independent interface between an OGL driver // This is the platform independent interface between an OGL driver
// and the shading language compiler. // and the shading language compiler.
@ -37,13 +38,17 @@ namespace sh
typedef unsigned int GLenum; typedef unsigned int GLenum;
} }
// Must be included after GLenum proxy typedef
// Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
#include "ShaderVars.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// Version number for shader translation API. // Version number for shader translation API.
// It is incremented every time the API changes. // It is incremented every time the API changes.
#define ANGLE_SH_VERSION 128 #define ANGLE_SH_VERSION 130
typedef enum { typedef enum {
SH_GLES2_SPEC = 0x8B40, SH_GLES2_SPEC = 0x8B40,
@ -100,14 +105,9 @@ typedef enum {
SH_NAME_MAX_LENGTH = 0x6001, SH_NAME_MAX_LENGTH = 0x6001,
SH_HASHED_NAME_MAX_LENGTH = 0x6002, SH_HASHED_NAME_MAX_LENGTH = 0x6002,
SH_HASHED_NAMES_COUNT = 0x6003, SH_HASHED_NAMES_COUNT = 0x6003,
SH_ACTIVE_UNIFORMS_ARRAY = 0x6004, SH_SHADER_VERSION = 0x6004,
SH_SHADER_VERSION = 0x6005, SH_RESOURCES_STRING_LENGTH = 0x6005,
SH_ACTIVE_INTERFACE_BLOCKS_ARRAY = 0x6006, SH_OUTPUT_TYPE = 0x6006
SH_ACTIVE_OUTPUT_VARIABLES_ARRAY = 0x6007,
SH_ACTIVE_ATTRIBUTES_ARRAY = 0x6008,
SH_ACTIVE_VARYINGS_ARRAY = 0x6009,
SH_RESOURCES_STRING_LENGTH = 0x600A,
SH_OUTPUT_TYPE = 0x600B
} ShShaderInfo; } ShShaderInfo;
// Compile options. // Compile options.
@ -189,6 +189,11 @@ typedef enum {
// This flag scalarizes vec/ivec/bvec/mat constructor args. // This flag scalarizes vec/ivec/bvec/mat constructor args.
// It is intended as a workaround for Linux/Mac driver bugs. // It is intended as a workaround for Linux/Mac driver bugs.
SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS = 0x40000, SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS = 0x40000,
// This flag overwrites a struct name with a unique prefix.
// It is intended as a workaround for drivers that do not handle
// struct scopes correctly, including all Mac drivers and Linux AMD.
SH_REGENERATE_STRUCT_NAMES = 0x80000,
} ShCompileOptions; } ShCompileOptions;
// Defines alternate strategies for implementing array index clamping. // Defines alternate strategies for implementing array index clamping.
@ -453,17 +458,17 @@ COMPILER_EXPORT void ShGetNameHashingEntry(const ShHandle handle,
char* name, char* name,
char* hashedName); char* hashedName);
// Returns a parameter from a compiled shader. // Shader variable inspection.
// Returns a pointer to a list of variables of the designated type.
// (See ShaderVars.h for type definitions, included above)
// Returns NULL on failure.
// Parameters: // Parameters:
// handle: Specifies the compiler // handle: Specifies the compiler
// pname: Specifies the parameter to query. COMPILER_EXPORT const std::vector<sh::Uniform> *ShGetUniforms(const ShHandle handle);
// The following parameters are defined: COMPILER_EXPORT const std::vector<sh::Varying> *ShGetVaryings(const ShHandle handle);
// SH_ACTIVE_UNIFORMS_ARRAY: an STL vector of active uniforms. Valid only for COMPILER_EXPORT const std::vector<sh::Attribute> *ShGetAttributes(const ShHandle handle);
// HLSL output. COMPILER_EXPORT const std::vector<sh::Attribute> *ShGetOutputVariables(const ShHandle handle);
// params: Requested parameter COMPILER_EXPORT const std::vector<sh::InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle);
COMPILER_EXPORT void ShGetInfoPointer(const ShHandle handle,
ShShaderInfo pname,
void** params);
typedef struct typedef struct
{ {

View File

@ -0,0 +1,123 @@
//
// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ShaderVars.h:
// Types to represent GL variables (varyings, uniforms, etc)
//
#ifndef _COMPILER_INTERFACE_VARIABLES_
#define _COMPILER_INTERFACE_VARIABLES_
#include <string>
#include <vector>
#include <algorithm>
// Assume ShaderLang.h is included before ShaderVars.h, for sh::GLenum
// Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
namespace sh
{
// Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec
enum InterpolationType
{
INTERPOLATION_SMOOTH,
INTERPOLATION_CENTROID,
INTERPOLATION_FLAT
};
// Uniform block layout qualifier, see section 4.3.8.3 of the ESSL 3.00.4 spec
enum BlockLayoutType
{
BLOCKLAYOUT_STANDARD,
BLOCKLAYOUT_PACKED,
BLOCKLAYOUT_SHARED
};
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc
// Note: we must override the copy constructor and assignment operator so we can
// work around excessive GCC binary bloating:
// See https://code.google.com/p/angleproject/issues/detail?id=697
struct COMPILER_EXPORT ShaderVariable
{
ShaderVariable();
ShaderVariable(GLenum typeIn, unsigned int arraySizeIn);
~ShaderVariable();
ShaderVariable(const ShaderVariable &other);
ShaderVariable &operator=(const ShaderVariable &other);
bool isArray() const { return arraySize > 0; }
unsigned int elementCount() const { return std::max(1u, arraySize); }
bool isStruct() const { return !fields.empty(); }
GLenum type;
GLenum precision;
std::string name;
std::string mappedName;
unsigned int arraySize;
bool staticUse;
std::vector<ShaderVariable> fields;
std::string structName;
};
struct COMPILER_EXPORT Uniform : public ShaderVariable
{
Uniform();
~Uniform();
Uniform(const Uniform &other);
Uniform &operator=(const Uniform &other);
};
struct COMPILER_EXPORT Attribute : public ShaderVariable
{
Attribute();
~Attribute();
Attribute(const Attribute &other);
Attribute &operator=(const Attribute &other);
int location;
};
struct COMPILER_EXPORT InterfaceBlockField : public ShaderVariable
{
InterfaceBlockField();
~InterfaceBlockField();
InterfaceBlockField(const InterfaceBlockField &other);
InterfaceBlockField &operator=(const InterfaceBlockField &other);
bool isRowMajorLayout;
};
struct COMPILER_EXPORT Varying : public ShaderVariable
{
Varying();
~Varying();
Varying(const Varying &other);
Varying &operator=(const Varying &other);
InterpolationType interpolation;
bool isInvariant;
};
struct COMPILER_EXPORT InterfaceBlock
{
InterfaceBlock();
~InterfaceBlock();
InterfaceBlock(const InterfaceBlock &other);
InterfaceBlock &operator=(const InterfaceBlock &other);
std::string name;
std::string mappedName;
std::string instanceName;
unsigned int arraySize;
BlockLayoutType layout;
bool isRowMajorLayout;
bool staticUse;
std::vector<InterfaceBlockField> fields;
};
}
#endif // _COMPILER_INTERFACE_VARIABLES_

View File

@ -10,9 +10,6 @@
#ifndef ANGLE_GL_H_ #ifndef ANGLE_GL_H_
#define ANGLE_GL_H_ #define ANGLE_GL_H_
#define GL_GLEXT_PROTOTYPES
#define GL_APICALL
#include "GLES2/gl2.h" #include "GLES2/gl2.h"
#include "GLES2/gl2ext.h" #include "GLES2/gl2ext.h"
#include "GLES3/gl3.h" #include "GLES3/gl3.h"

View File

@ -7,6 +7,6 @@
// This is a default commit hash header, when git is not available. // This is a default commit hash header, when git is not available.
// //
#define ANGLE_COMMIT_HASH "07d49ef5350a" #define ANGLE_COMMIT_HASH "abce76206141"
#define ANGLE_COMMIT_HASH_SIZE 12 #define ANGLE_COMMIT_HASH_SIZE 12
#define ANGLE_COMMIT_DATE "2014-07-25 16:01:42 +0000" #define ANGLE_COMMIT_DATE "2014-09-23 19:37:05 +0000"

View File

@ -12,11 +12,11 @@
#ifndef COMMON_REFCOUNTOBJECT_H_ #ifndef COMMON_REFCOUNTOBJECT_H_
#define COMMON_REFCOUNTOBJECT_H_ #define COMMON_REFCOUNTOBJECT_H_
#include <cstddef> #include "common/debug.h"
#include "angle_gl.h" #include "angle_gl.h"
#include "common/debug.h" #include <cstddef>
class RefCountObject class RefCountObject
{ {

View File

@ -0,0 +1,37 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "common/angleutils.h"
#include <vector>
std::string FormatString(const char *fmt, va_list vararg)
{
static std::vector<char> buffer(512);
// Attempt to just print to the current buffer
int len = vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
if (len < 0 || static_cast<size_t>(len) >= buffer.size())
{
// Buffer was not large enough, calculate the required size and resize the buffer
len = vsnprintf(NULL, 0, fmt, vararg);
buffer.resize(len + 1);
// Print again
vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
}
return std::string(buffer.data(), len);
}
std::string FormatString(const char *fmt, ...)
{
va_list vararg;
va_start(vararg, fmt);
std::string result = FormatString(fmt, vararg);
va_end(vararg);
return result;
}

View File

@ -16,6 +16,7 @@
#include <string> #include <string>
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <cstdarg>
// A macro to disallow the copy constructor and operator= functions // A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class // This must be used in the private: declarations for a class
@ -23,8 +24,8 @@
TypeName(const TypeName&); \ TypeName(const TypeName&); \
void operator=(const TypeName&) void operator=(const TypeName&)
template <typename T, unsigned int N> template <typename T, size_t N>
inline unsigned int ArraySize(T(&)[N]) inline size_t ArraySize(T(&)[N])
{ {
return N; return N;
} }
@ -131,6 +132,9 @@ inline std::string Str(int i)
return strstr.str(); return strstr.str();
} }
std::string FormatString(const char *fmt, va_list vararg);
std::string FormatString(const char *fmt, ...);
#if defined(_MSC_VER) && _MSC_VER < 1900 #if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif

View File

@ -8,7 +8,6 @@
// //
#include "common/blocklayout.h" #include "common/blocklayout.h"
#include "common/shadervars.h"
#include "common/mathutil.h" #include "common/mathutil.h"
#include "common/utilities.h" #include "common/utilities.h"
@ -20,46 +19,7 @@ BlockLayoutEncoder::BlockLayoutEncoder()
{ {
} }
void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields) BlockMemberInfo BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix)
{
for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
{
const InterfaceBlockField &variable = fields[fieldIndex];
if (variable.fields.size() > 0)
{
const unsigned int elementCount = std::max(1u, variable.arraySize);
for (unsigned int elementIndex = 0; elementIndex < elementCount; elementIndex++)
{
enterAggregateType();
encodeInterfaceBlockFields(variable.fields);
exitAggregateType();
}
}
else
{
encodeInterfaceBlockField(variable);
}
}
}
BlockMemberInfo BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &field)
{
int arrayStride;
int matrixStride;
ASSERT(field.fields.empty());
getBlockLayoutInfo(field.type, field.arraySize, field.isRowMajorMatrix, &arrayStride, &matrixStride);
const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix);
advanceOffset(field.type, field.arraySize, field.isRowMajorMatrix, arrayStride, matrixStride);
return memberInfo;
}
void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix)
{ {
int arrayStride; int arrayStride;
int matrixStride; int matrixStride;
@ -69,6 +29,8 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is
const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix); const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix);
advanceOffset(type, arraySize, isRowMajorMatrix, arrayStride, matrixStride); advanceOffset(type, arraySize, isRowMajorMatrix, arrayStride, matrixStride);
return memberInfo;
} }
void BlockLayoutEncoder::nextRegister() void BlockLayoutEncoder::nextRegister()

View File

@ -10,10 +10,11 @@
#ifndef COMMON_BLOCKLAYOUT_H_ #ifndef COMMON_BLOCKLAYOUT_H_
#define COMMON_BLOCKLAYOUT_H_ #define COMMON_BLOCKLAYOUT_H_
#include <cstddef>
#include <vector> #include <vector>
#include "angle_gl.h" #include "angle_gl.h"
#include <GLSLANG/ShaderLang.h> #include <GLSLANG/ShaderLang.h>
#include <cstddef>
namespace sh namespace sh
{ {
@ -48,9 +49,7 @@ class BlockLayoutEncoder
public: public:
BlockLayoutEncoder(); BlockLayoutEncoder();
void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields); BlockMemberInfo encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
BlockMemberInfo encodeInterfaceBlockField(const InterfaceBlockField &field);
void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; } size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; }
size_t getCurrentRegister() const { return mCurrentOffset / ComponentsPerRegister; } size_t getCurrentRegister() const { return mCurrentOffset / ComponentsPerRegister; }

View File

@ -8,6 +8,7 @@
#include "common/debug.h" #include "common/debug.h"
#include "common/platform.h" #include "common/platform.h"
#include "common/angleutils.h"
#include <stdarg.h> #include <stdarg.h>
#include <vector> #include <vector>
@ -25,22 +26,7 @@ typedef void (*PerfOutputFunction)(unsigned int, const wchar_t*);
static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg) static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
{ {
#if defined(ANGLE_ENABLE_PERF) || defined(ANGLE_ENABLE_TRACE) #if defined(ANGLE_ENABLE_PERF) || defined(ANGLE_ENABLE_TRACE)
static std::vector<char> asciiMessageBuffer(512); std::string formattedMessage = FormatString(format, vararg);
// Attempt to just print to the current buffer
int len = vsnprintf(&asciiMessageBuffer[0], asciiMessageBuffer.size(), format, vararg);
if (len < 0 || static_cast<size_t>(len) >= asciiMessageBuffer.size())
{
// Buffer was not large enough, calculate the required size and resize the buffer
len = vsnprintf(NULL, 0, format, vararg);
asciiMessageBuffer.resize(len + 1);
// Print again
vsnprintf(&asciiMessageBuffer[0], asciiMessageBuffer.size(), format, vararg);
}
// NULL terminate the buffer to be safe
asciiMessageBuffer[len] = '\0';
#endif #endif
#if defined(ANGLE_ENABLE_PERF) #if defined(ANGLE_ENABLE_PERF)
@ -48,12 +34,12 @@ static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const c
{ {
// The perf function only accepts wide strings, widen the ascii message // The perf function only accepts wide strings, widen the ascii message
static std::wstring wideMessage; static std::wstring wideMessage;
if (wideMessage.capacity() < asciiMessageBuffer.size()) if (wideMessage.capacity() < formattedMessage.length())
{ {
wideMessage.reserve(asciiMessageBuffer.size()); wideMessage.reserve(formattedMessage.size());
} }
wideMessage.assign(asciiMessageBuffer.begin(), asciiMessageBuffer.begin() + len); wideMessage.assign(formattedMessage.begin(), formattedMessage.end());
perfFunc(0, wideMessage.c_str()); perfFunc(0, wideMessage.c_str());
} }
@ -70,7 +56,7 @@ static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const c
static std::ofstream file(TRACE_OUTPUT_FILE, std::ofstream::app); static std::ofstream file(TRACE_OUTPUT_FILE, std::ofstream::app);
if (file) if (file)
{ {
file.write(&asciiMessageBuffer[0], len); file.write(formattedMessage.c_str(), formattedMessage.length());
file.flush(); file.flush();
} }

View File

@ -91,6 +91,10 @@ namespace gl
// A macro to indicate unimplemented functionality // A macro to indicate unimplemented functionality
#if defined (ANGLE_TEST_CONFIG)
#define NOASSERT_UNIMPLEMENTED 1
#endif
// Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks // Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks
// This will allow us to test with some automated test suites (eg dEQP) without crashing // This will allow us to test with some automated test suites (eg dEQP) without crashing
#ifndef NOASSERT_UNIMPLEMENTED #ifndef NOASSERT_UNIMPLEMENTED

View File

@ -1,49 +0,0 @@
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "common/event_tracer.h"
namespace gl
{
GetCategoryEnabledFlagFunc g_getCategoryEnabledFlag;
AddTraceEventFunc g_addTraceEvent;
} // namespace gl
extern "C" {
void TRACE_ENTRY SetTraceFunctionPointers(GetCategoryEnabledFlagFunc getCategoryEnabledFlag,
AddTraceEventFunc addTraceEvent)
{
gl::g_getCategoryEnabledFlag = getCategoryEnabledFlag;
gl::g_addTraceEvent = addTraceEvent;
}
} // extern "C"
namespace gl
{
const unsigned char* TraceGetTraceCategoryEnabledFlag(const char* name)
{
if (g_getCategoryEnabledFlag)
{
return g_getCategoryEnabledFlag(name);
}
static unsigned char disabled = 0;
return &disabled;
}
void TraceAddTraceEvent(char phase, const unsigned char* categoryGroupEnabled, const char* name, unsigned long long id,
int numArgs, const char** argNames, const unsigned char* argTypes,
const unsigned long long* argValues, unsigned char flags)
{
if (g_addTraceEvent)
{
g_addTraceEvent(phase, categoryGroupEnabled, name, id, numArgs, argNames, argTypes, argValues, flags);
}
}
} // namespace gl

View File

@ -1,43 +0,0 @@
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMMON_EVENT_TRACER_H_
#define COMMON_EVENT_TRACER_H_
#include "common/platform.h"
#if !defined(TRACE_ENTRY)
# ifdef ANGLE_PLATFORM_WINDOWS
# define TRACE_ENTRY __stdcall
# else
# define TRACE_ENTRY
# endif // ANGLE_PLATFORM_WINDOWS
#endif //TRACE_ENTRY
extern "C" {
typedef const unsigned char* (*GetCategoryEnabledFlagFunc)(const char* name);
typedef void (*AddTraceEventFunc)(char phase, const unsigned char* categoryGroupEnabled, const char* name,
unsigned long long id, int numArgs, const char** argNames,
const unsigned char* argTypes, const unsigned long long* argValues,
unsigned char flags);
// extern "C" so that it has a reasonable name for GetProcAddress.
void TRACE_ENTRY SetTraceFunctionPointers(GetCategoryEnabledFlagFunc get_category_enabled_flag,
AddTraceEventFunc add_trace_event_func);
}
namespace gl
{
const unsigned char* TraceGetTraceCategoryEnabledFlag(const char* name);
void TraceAddTraceEvent(char phase, const unsigned char* categoryGroupEnabled, const char* name, unsigned long long id,
int numArgs, const char** argNames, const unsigned char* argTypes,
const unsigned long long* argValues, unsigned char flags);
}
#endif // COMMON_EVENT_TRACER_H_

View File

@ -7,6 +7,7 @@
// mathutil.cpp: Math and bit manipulation functions. // mathutil.cpp: Math and bit manipulation functions.
#include "common/mathutil.h" #include "common/mathutil.h"
#include <algorithm> #include <algorithm>
#include <math.h> #include <math.h>

View File

@ -505,21 +505,33 @@ inline unsigned int averageFloat10(unsigned int a, unsigned int b)
namespace rx namespace rx
{ {
template <typename T>
struct Range struct Range
{ {
Range() {} Range() {}
Range(int lo, int hi) : start(lo), end(hi) { ASSERT(lo <= hi); } Range(T lo, T hi) : start(lo), end(hi) { ASSERT(lo <= hi); }
int start; T start;
int end; T end;
T length() const { return end - start; }
}; };
typedef Range<int> RangeI;
typedef Range<unsigned int> RangeUI;
template <typename T> template <typename T>
T roundUp(const T value, const T alignment) T roundUp(const T value, const T alignment)
{ {
return value + alignment - 1 - (value - 1) % alignment; return value + alignment - 1 - (value - 1) % alignment;
} }
inline unsigned int UnsignedCeilDivide(unsigned int value, unsigned int divisor)
{
unsigned int divided = value / divisor;
return (divided + ((value % divisor == 0) ? 0 : 1));
}
template <class T> template <class T>
inline bool IsUnsignedAdditionSafe(T lhs, T rhs) inline bool IsUnsignedAdditionSafe(T lhs, T rhs)
{ {

View File

@ -52,6 +52,9 @@
# if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_PERF) # if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_PERF)
# include <d3d9.h> # include <d3d9.h>
# if !defined(COMPILER_IMPLEMENTATION)
# include <d3dcompiler.h>
# endif
# endif # endif
# if defined(ANGLE_ENABLE_D3D11) # if defined(ANGLE_ENABLE_D3D11)
@ -61,16 +64,25 @@
# include <dxgi.h> # include <dxgi.h>
# if _MSC_VER >= 1700 # if _MSC_VER >= 1700
# include <dxgi1_2.h> # include <dxgi1_2.h>
# endif
# if !defined(COMPILER_IMPLEMENTATION)
# include <d3dcompiler.h> # include <d3dcompiler.h>
# endif # endif
# if defined(__MINGW32__)
typedef enum D3D11_MAP_FLAG
{
D3D11_MAP_FLAG_DO_NOT_WAIT = 0x100000L
} D3D11_MAP_FLAG;
typedef struct D3D11_QUERY_DATA_SO_STATISTICS
{
UINT64 NumPrimitivesWritten;
UINT64 PrimitivesStorageNeeded;
} D3D11_QUERY_DATA_SO_STATISTICS;
# endif
# endif # endif
# undef near # undef near
# undef far # undef far
# undef NEAR
# define NEAR
# undef FAR
# define FAR
#endif #endif
#endif // COMMON_PLATFORM_H_ #endif // COMMON_PLATFORM_H_

View File

@ -1,157 +0,0 @@
//
// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// shadervars.h:
// Types to represent GL variables (varyings, uniforms, etc)
//
#ifndef COMMON_SHADERVARIABLE_H_
#define COMMON_SHADERVARIABLE_H_
#include <string>
#include <vector>
#include <algorithm>
#include "GLSLANG/ShaderLang.h"
namespace sh
{
// Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec
enum InterpolationType
{
INTERPOLATION_SMOOTH,
INTERPOLATION_CENTROID,
INTERPOLATION_FLAT
};
// Uniform block layout qualifier, see section 4.3.8.3 of the ESSL 3.00.4 spec
enum BlockLayoutType
{
BLOCKLAYOUT_STANDARD,
BLOCKLAYOUT_PACKED,
BLOCKLAYOUT_SHARED
};
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc
struct ShaderVariable
{
ShaderVariable()
: type(0),
precision(0),
arraySize(0),
staticUse(false)
{}
ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
: type(typeIn),
precision(precisionIn),
name(nameIn),
arraySize(arraySizeIn),
staticUse(false)
{}
bool isArray() const { return arraySize > 0; }
unsigned int elementCount() const { return std::max(1u, arraySize); }
GLenum type;
GLenum precision;
std::string name;
std::string mappedName;
unsigned int arraySize;
bool staticUse;
};
struct Uniform : public ShaderVariable
{
Uniform()
{}
Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn)
{}
bool isStruct() const { return !fields.empty(); }
std::vector<Uniform> fields;
};
struct Attribute : public ShaderVariable
{
Attribute()
: location(-1)
{}
Attribute(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, int locationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
location(locationIn)
{}
int location;
};
struct InterfaceBlockField : public ShaderVariable
{
InterfaceBlockField()
: isRowMajorMatrix(false)
{}
InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
isRowMajorMatrix(isRowMajorMatrix)
{}
bool isStruct() const { return !fields.empty(); }
bool isRowMajorMatrix;
std::vector<InterfaceBlockField> fields;
};
struct Varying : public ShaderVariable
{
Varying()
: interpolation(INTERPOLATION_SMOOTH)
{}
Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
interpolation(interpolationIn)
{}
bool isStruct() const { return !fields.empty(); }
InterpolationType interpolation;
std::vector<Varying> fields;
std::string structName;
};
struct InterfaceBlock
{
InterfaceBlock()
: arraySize(0),
layout(BLOCKLAYOUT_PACKED),
isRowMajorLayout(false),
staticUse(false)
{}
InterfaceBlock(const char *name, unsigned int arraySize)
: name(name),
arraySize(arraySize),
layout(BLOCKLAYOUT_SHARED),
isRowMajorLayout(false),
staticUse(false)
{}
std::string name;
std::string mappedName;
unsigned int arraySize;
BlockLayoutType layout;
bool isRowMajorLayout;
bool staticUse;
std::vector<InterfaceBlockField> fields;
};
}
#endif // COMMON_SHADERVARIABLE_H_

View File

@ -69,40 +69,9 @@ enum TBasicType
EbtStruct, EbtStruct,
EbtInterfaceBlock, EbtInterfaceBlock,
EbtAddress, // should be deprecated?? EbtAddress, // should be deprecated??
EbtInvariant // used as a type when qualifying a previously declared variable as being invariant
}; };
inline const char* getBasicString(TBasicType t) const char* getBasicString(TBasicType t);
{
switch (t)
{
case EbtVoid: return "void"; break;
case EbtFloat: return "float"; break;
case EbtInt: return "int"; break;
case EbtUInt: return "uint"; break;
case EbtBool: return "bool"; break;
case EbtSampler2D: return "sampler2D"; break;
case EbtSampler3D: return "sampler3D"; break;
case EbtSamplerCube: return "samplerCube"; break;
case EbtSamplerExternalOES: return "samplerExternalOES"; break;
case EbtSampler2DRect: return "sampler2DRect"; break;
case EbtSampler2DArray: return "sampler2DArray"; break;
case EbtISampler2D: return "isampler2D"; break;
case EbtISampler3D: return "isampler3D"; break;
case EbtISamplerCube: return "isamplerCube"; break;
case EbtISampler2DArray: return "isampler2DArray"; break;
case EbtUSampler2D: return "usampler2D"; break;
case EbtUSampler3D: return "usampler3D"; break;
case EbtUSamplerCube: return "usamplerCube"; break;
case EbtUSampler2DArray: return "usampler2DArray"; break;
case EbtSampler2DShadow: return "sampler2DShadow"; break;
case EbtSamplerCubeShadow: return "samplerCubeShadow"; break;
case EbtSampler2DArrayShadow: return "sampler2DArrayShadow"; break;
case EbtStruct: return "structure"; break;
case EbtInterfaceBlock: return "interface block"; break;
default: return "unknown type";
}
}
inline bool IsSampler(TBasicType type) inline bool IsSampler(TBasicType type)
{ {

View File

@ -8,7 +8,7 @@
#define COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_ #define COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
#include "compiler/translator/InfoSink.h" #include "compiler/translator/InfoSink.h"
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
// //
// This class decides which built-in functions need to be replaced with the // This class decides which built-in functions need to be replaced with the

View File

@ -12,6 +12,7 @@
#include "compiler/translator/InitializeParseContext.h" #include "compiler/translator/InitializeParseContext.h"
#include "compiler/translator/InitializeVariables.h" #include "compiler/translator/InitializeVariables.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"
#include "compiler/translator/RegenerateStructNames.h"
#include "compiler/translator/RenameFunction.h" #include "compiler/translator/RenameFunction.h"
#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h" #include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
#include "compiler/translator/UnfoldShortCircuitAST.h" #include "compiler/translator/UnfoldShortCircuitAST.h"
@ -257,10 +258,17 @@ bool TCompiler::compile(const char* const shaderStrings[],
if (success && (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS)) if (success && (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS))
{ {
ScalarizeVecAndMatConstructorArgs scalarizer; ScalarizeVecAndMatConstructorArgs scalarizer(
shaderType, fragmentPrecisionHigh);
root->traverse(&scalarizer); root->traverse(&scalarizer);
} }
if (success && (compileOptions & SH_REGENERATE_STRUCT_NAMES))
{
RegenerateStructNames gen(symbolTable, shaderVersion);
root->traverse(&gen);
}
if (success && (compileOptions & SH_INTERMEDIATE_TREE)) if (success && (compileOptions & SH_INTERMEDIATE_TREE))
intermediate.outputTree(root); intermediate.outputTree(root);
@ -494,18 +502,18 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
void TCompiler::collectVariables(TIntermNode* root) void TCompiler::collectVariables(TIntermNode* root)
{ {
CollectVariables collect(&attributes, sh::CollectVariables collect(&attributes,
&outputVariables, &outputVariables,
&uniforms, &uniforms,
&varyings, &varyings,
&interfaceBlocks, &interfaceBlocks,
hashFunction); hashFunction);
root->traverse(&collect); root->traverse(&collect);
// For backwards compatiblity with ShGetVariableInfo, expand struct // For backwards compatiblity with ShGetVariableInfo, expand struct
// uniforms and varyings into separate variables for each field. // uniforms and varyings into separate variables for each field.
ExpandVariables(uniforms, &expandedUniforms); sh::ExpandVariables(uniforms, &expandedUniforms);
ExpandVariables(varyings, &expandedVaryings); sh::ExpandVariables(varyings, &expandedVaryings);
} }
bool TCompiler::enforcePackingRestrictions() bool TCompiler::enforcePackingRestrictions()

View File

@ -71,9 +71,9 @@ class TCompiler : public TShHandleBase
const std::vector<sh::Attribute> &getAttributes() const { return attributes; } const std::vector<sh::Attribute> &getAttributes() const { return attributes; }
const std::vector<sh::Attribute> &getOutputVariables() const { return outputVariables; } const std::vector<sh::Attribute> &getOutputVariables() const { return outputVariables; }
const std::vector<sh::Uniform> &getUniforms() const { return uniforms; } const std::vector<sh::Uniform> &getUniforms() const { return uniforms; }
const std::vector<sh::Uniform> &getExpandedUniforms() const { return expandedUniforms; } const std::vector<sh::ShaderVariable> &getExpandedUniforms() const { return expandedUniforms; }
const std::vector<sh::Varying> &getVaryings() const { return varyings; } const std::vector<sh::Varying> &getVaryings() const { return varyings; }
const std::vector<sh::Varying> &getExpandedVaryings() const { return expandedVaryings; } const std::vector<sh::ShaderVariable> &getExpandedVaryings() const { return expandedVaryings; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; } const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
ShHashFunction64 getHashFunction() const { return hashFunction; } ShHashFunction64 getHashFunction() const { return hashFunction; }
@ -83,6 +83,9 @@ class TCompiler : public TShHandleBase
ShShaderOutput getOutputType() const { return outputType; } ShShaderOutput getOutputType() const { return outputType; }
std::string getBuiltInResourcesString() const { return builtInResourcesString; } std::string getBuiltInResourcesString() const { return builtInResourcesString; }
// Get the resources set by InitBuiltInSymbolTable
const ShBuiltInResources& getResources() const;
protected: protected:
sh::GLenum getShaderType() const { return shaderType; } sh::GLenum getShaderType() const { return shaderType; }
// Initialize symbol-table with built-in symbols. // Initialize symbol-table with built-in symbols.
@ -128,8 +131,6 @@ class TCompiler : public TShHandleBase
bool limitExpressionComplexity(TIntermNode* root); bool limitExpressionComplexity(TIntermNode* root);
// Get built-in extensions with default behavior. // Get built-in extensions with default behavior.
const TExtensionBehavior& getExtensionBehavior() const; const TExtensionBehavior& getExtensionBehavior() const;
// Get the resources set by InitBuiltInSymbolTable
const ShBuiltInResources& getResources() const;
const ArrayBoundsClamper& getArrayBoundsClamper() const; const ArrayBoundsClamper& getArrayBoundsClamper() const;
ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const; ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const;
@ -138,9 +139,9 @@ class TCompiler : public TShHandleBase
std::vector<sh::Attribute> attributes; std::vector<sh::Attribute> attributes;
std::vector<sh::Attribute> outputVariables; std::vector<sh::Attribute> outputVariables;
std::vector<sh::Uniform> uniforms; std::vector<sh::Uniform> uniforms;
std::vector<sh::Uniform> expandedUniforms; std::vector<sh::ShaderVariable> expandedUniforms;
std::vector<sh::Varying> varyings; std::vector<sh::Varying> varyings;
std::vector<sh::Varying> expandedVaryings; std::vector<sh::ShaderVariable> expandedVaryings;
std::vector<sh::InterfaceBlock> interfaceBlocks; std::vector<sh::InterfaceBlock> interfaceBlocks;
private: private:

View File

@ -8,7 +8,7 @@
#define COMPILER_DETECT_RECURSION_H_ #define COMPILER_DETECT_RECURSION_H_
#include <limits.h> #include <limits.h>
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
#include "compiler/translator/VariableInfo.h" #include "compiler/translator/VariableInfo.h"
class TInfoSink; class TInfoSink;

View File

@ -11,7 +11,7 @@
#ifndef COMPILER_DETECTDISCONTINUITY_H_ #ifndef COMPILER_DETECTDISCONTINUITY_H_
#define COMPILER_DETECTDISCONTINUITY_H_ #define COMPILER_DETECTDISCONTINUITY_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
namespace sh namespace sh
{ {

View File

@ -7,7 +7,7 @@
#ifndef COMPILER_FLAGSTD140STRUCTS_H_ #ifndef COMPILER_FLAGSTD140STRUCTS_H_
#define COMPILER_FLAGSTD140STRUCTS_H_ #define COMPILER_FLAGSTD140STRUCTS_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
namespace sh namespace sh
{ {

View File

@ -9,7 +9,7 @@
#include <map> #include <map>
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
#define HASHED_NAME_PREFIX "webgl_" #define HASHED_NAME_PREFIX "webgl_"

View File

@ -12,7 +12,7 @@
#include "compiler/translator/Initialize.h" #include "compiler/translator/Initialize.h"
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
#include "angle_gl.h" #include "angle_gl.h"
void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable) void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable)

View File

@ -7,7 +7,7 @@
#ifndef COMPILER_INITIALIZE_VARIABLES_H_ #ifndef COMPILER_INITIALIZE_VARIABLES_H_
#define COMPILER_INITIALIZE_VARIABLES_H_ #define COMPILER_INITIALIZE_VARIABLES_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
class InitializeVariables : public TIntermTraverser class InitializeVariables : public TIntermTraverser
{ {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,772 @@
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
// Definition of the in-memory high-level intermediate representation
// of shaders. This is a tree that parser creates.
//
// Nodes in the tree are defined as a hierarchy of classes derived from
// TIntermNode. Each is a node in a tree. There is no preset branching factor;
// each node can have it's own type of list of children.
//
#ifndef COMPILER_TRANSLATOR_INTERMEDIATE_H_
#define COMPILER_TRANSLATOR_INTERMEDIATE_H_
#include "GLSLANG/ShaderLang.h"
#include <algorithm>
#include <queue>
#include "compiler/translator/Common.h"
#include "compiler/translator/Types.h"
#include "compiler/translator/ConstantUnion.h"
//
// Operators used by the high-level (parse tree) representation.
//
enum TOperator
{
EOpNull, // if in a node, should only mean a node is still being built
EOpSequence, // denotes a list of statements, or parameters, etc.
EOpFunctionCall,
EOpFunction, // For function definition
EOpParameters, // an aggregate listing the parameters to a function
EOpDeclaration,
EOpInvariantDeclaration, // Specialized declarations for attributing invariance
EOpPrototype,
//
// Unary operators
//
EOpNegative,
EOpLogicalNot,
EOpVectorLogicalNot,
EOpPostIncrement,
EOpPostDecrement,
EOpPreIncrement,
EOpPreDecrement,
//
// binary operations
//
EOpAdd,
EOpSub,
EOpMul,
EOpDiv,
EOpEqual,
EOpNotEqual,
EOpVectorEqual,
EOpVectorNotEqual,
EOpLessThan,
EOpGreaterThan,
EOpLessThanEqual,
EOpGreaterThanEqual,
EOpComma,
EOpVectorTimesScalar,
EOpVectorTimesMatrix,
EOpMatrixTimesVector,
EOpMatrixTimesScalar,
EOpLogicalOr,
EOpLogicalXor,
EOpLogicalAnd,
EOpIndexDirect,
EOpIndexIndirect,
EOpIndexDirectStruct,
EOpIndexDirectInterfaceBlock,
EOpVectorSwizzle,
//
// Built-in functions potentially mapped to operators
//
EOpRadians,
EOpDegrees,
EOpSin,
EOpCos,
EOpTan,
EOpAsin,
EOpAcos,
EOpAtan,
EOpPow,
EOpExp,
EOpLog,
EOpExp2,
EOpLog2,
EOpSqrt,
EOpInverseSqrt,
EOpAbs,
EOpSign,
EOpFloor,
EOpCeil,
EOpFract,
EOpMod,
EOpMin,
EOpMax,
EOpClamp,
EOpMix,
EOpStep,
EOpSmoothStep,
EOpLength,
EOpDistance,
EOpDot,
EOpCross,
EOpNormalize,
EOpFaceForward,
EOpReflect,
EOpRefract,
EOpDFdx, // Fragment only, OES_standard_derivatives extension
EOpDFdy, // Fragment only, OES_standard_derivatives extension
EOpFwidth, // Fragment only, OES_standard_derivatives extension
EOpMatrixTimesMatrix,
EOpAny,
EOpAll,
//
// Branch
//
EOpKill, // Fragment only
EOpReturn,
EOpBreak,
EOpContinue,
//
// Constructors
//
EOpConstructInt,
EOpConstructUInt,
EOpConstructBool,
EOpConstructFloat,
EOpConstructVec2,
EOpConstructVec3,
EOpConstructVec4,
EOpConstructBVec2,
EOpConstructBVec3,
EOpConstructBVec4,
EOpConstructIVec2,
EOpConstructIVec3,
EOpConstructIVec4,
EOpConstructUVec2,
EOpConstructUVec3,
EOpConstructUVec4,
EOpConstructMat2,
EOpConstructMat3,
EOpConstructMat4,
EOpConstructStruct,
//
// moves
//
EOpAssign,
EOpInitialize,
EOpAddAssign,
EOpSubAssign,
EOpMulAssign,
EOpVectorTimesMatrixAssign,
EOpVectorTimesScalarAssign,
EOpMatrixTimesScalarAssign,
EOpMatrixTimesMatrixAssign,
EOpDivAssign
};
class TIntermTraverser;
class TIntermAggregate;
class TIntermBinary;
class TIntermUnary;
class TIntermConstantUnion;
class TIntermSelection;
class TIntermTyped;
class TIntermSymbol;
class TIntermLoop;
class TInfoSink;
class TIntermRaw;
//
// Base class for the tree nodes
//
class TIntermNode
{
public:
POOL_ALLOCATOR_NEW_DELETE();
TIntermNode()
{
// TODO: Move this to TSourceLoc constructor
// after getting rid of TPublicType.
mLine.first_file = mLine.last_file = 0;
mLine.first_line = mLine.last_line = 0;
}
virtual ~TIntermNode() { }
const TSourceLoc &getLine() const { return mLine; }
void setLine(const TSourceLoc &l) { mLine = l; }
virtual void traverse(TIntermTraverser *) = 0;
virtual TIntermTyped *getAsTyped() { return 0; }
virtual TIntermConstantUnion *getAsConstantUnion() { return 0; }
virtual TIntermAggregate *getAsAggregate() { return 0; }
virtual TIntermBinary *getAsBinaryNode() { return 0; }
virtual TIntermUnary *getAsUnaryNode() { return 0; }
virtual TIntermSelection *getAsSelectionNode() { return 0; }
virtual TIntermSymbol *getAsSymbolNode() { return 0; }
virtual TIntermLoop *getAsLoopNode() { return 0; }
virtual TIntermRaw *getAsRawNode() { return 0; }
// Replace a child node. Return true if |original| is a child
// node and it is replaced; otherwise, return false.
virtual bool replaceChildNode(
TIntermNode *original, TIntermNode *replacement) = 0;
// For traversing a tree in no particular order, but using
// heap memory.
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const = 0;
protected:
TSourceLoc mLine;
};
//
// This is just to help yacc.
//
struct TIntermNodePair
{
TIntermNode *node1;
TIntermNode *node2;
};
//
// Intermediate class for nodes that have a type.
//
class TIntermTyped : public TIntermNode
{
public:
TIntermTyped(const TType &t) : mType(t) { }
virtual TIntermTyped *getAsTyped() { return this; }
virtual bool hasSideEffects() const = 0;
void setType(const TType &t) { mType = t; }
const TType &getType() const { return mType; }
TType *getTypePointer() { return &mType; }
TBasicType getBasicType() const { return mType.getBasicType(); }
TQualifier getQualifier() const { return mType.getQualifier(); }
TPrecision getPrecision() const { return mType.getPrecision(); }
int getCols() const { return mType.getCols(); }
int getRows() const { return mType.getRows(); }
int getNominalSize() const { return mType.getNominalSize(); }
int getSecondarySize() const { return mType.getSecondarySize(); }
bool isInterfaceBlock() const { return mType.isInterfaceBlock(); }
bool isMatrix() const { return mType.isMatrix(); }
bool isArray() const { return mType.isArray(); }
bool isVector() const { return mType.isVector(); }
bool isScalar() const { return mType.isScalar(); }
bool isScalarInt() const { return mType.isScalarInt(); }
const char *getBasicString() const { return mType.getBasicString(); }
const char *getQualifierString() const { return mType.getQualifierString(); }
TString getCompleteString() const { return mType.getCompleteString(); }
int getArraySize() const { return mType.getArraySize(); }
protected:
TType mType;
};
//
// Handle for, do-while, and while loops.
//
enum TLoopType
{
ELoopFor,
ELoopWhile,
ELoopDoWhile
};
class TIntermLoop : public TIntermNode
{
public:
TIntermLoop(TLoopType type,
TIntermNode *init, TIntermTyped *cond, TIntermTyped *expr,
TIntermNode *body)
: mType(type),
mInit(init),
mCond(cond),
mExpr(expr),
mBody(body),
mUnrollFlag(false) { }
virtual TIntermLoop *getAsLoopNode() { return this; }
virtual void traverse(TIntermTraverser *);
virtual bool replaceChildNode(
TIntermNode *original, TIntermNode *replacement);
TLoopType getType() const { return mType; }
TIntermNode *getInit() { return mInit; }
TIntermTyped *getCondition() { return mCond; }
TIntermTyped *getExpression() { return mExpr; }
TIntermNode *getBody() { return mBody; }
void setUnrollFlag(bool flag) { mUnrollFlag = flag; }
bool getUnrollFlag() const { return mUnrollFlag; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected:
TLoopType mType;
TIntermNode *mInit; // for-loop initialization
TIntermTyped *mCond; // loop exit condition
TIntermTyped *mExpr; // for-loop expression
TIntermNode *mBody; // loop body
bool mUnrollFlag; // Whether the loop should be unrolled or not.
};
//
// Handle break, continue, return, and kill.
//
class TIntermBranch : public TIntermNode
{
public:
TIntermBranch(TOperator op, TIntermTyped *e)
: mFlowOp(op),
mExpression(e) { }
virtual void traverse(TIntermTraverser *);
virtual bool replaceChildNode(
TIntermNode *original, TIntermNode *replacement);
TOperator getFlowOp() { return mFlowOp; }
TIntermTyped* getExpression() { return mExpression; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected:
TOperator mFlowOp;
TIntermTyped *mExpression; // non-zero except for "return exp;" statements
};
//
// Nodes that correspond to symbols or constants in the source code.
//
class TIntermSymbol : public TIntermTyped
{
public:
// if symbol is initialized as symbol(sym), the memory comes from the poolallocator of sym.
// If sym comes from per process globalpoolallocator, then it causes increased memory usage
// per compile it is essential to use "symbol = sym" to assign to symbol
TIntermSymbol(int id, const TString &symbol, const TType &type)
: TIntermTyped(type),
mId(id)
{
mSymbol = symbol;
}
virtual bool hasSideEffects() const { return false; }
int getId() const { return mId; }
const TString &getSymbol() const { return mSymbol; }
void setId(int newId) { mId = newId; }
virtual void traverse(TIntermTraverser *);
virtual TIntermSymbol *getAsSymbolNode() { return this; }
virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
protected:
int mId;
TString mSymbol;
};
// A Raw node stores raw code, that the translator will insert verbatim
// into the output stream. Useful for transformation operations that make
// complex code that might not fit naturally into the GLSL model.
class TIntermRaw : public TIntermTyped
{
public:
TIntermRaw(const TType &type, const TString &rawText)
: TIntermTyped(type),
mRawText(rawText) { }
virtual bool hasSideEffects() const { return false; }
TString getRawText() const { return mRawText; }
virtual void traverse(TIntermTraverser *);
virtual TIntermRaw *getAsRawNode() { return this; }
virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
protected:
TString mRawText;
};
class TIntermConstantUnion : public TIntermTyped
{
public:
TIntermConstantUnion(ConstantUnion *unionPointer, const TType &type)
: TIntermTyped(type),
mUnionArrayPointer(unionPointer) { }
virtual bool hasSideEffects() const { return false; }
ConstantUnion *getUnionArrayPointer() const { return mUnionArrayPointer; }
int getIConst(size_t index) const
{
return mUnionArrayPointer ? mUnionArrayPointer[index].getIConst() : 0;
}
unsigned int getUConst(size_t index) const
{
return mUnionArrayPointer ? mUnionArrayPointer[index].getUConst() : 0;
}
float getFConst(size_t index) const
{
return mUnionArrayPointer ? mUnionArrayPointer[index].getFConst() : 0.0f;
}
bool getBConst(size_t index) const
{
return mUnionArrayPointer ? mUnionArrayPointer[index].getBConst() : false;
}
virtual TIntermConstantUnion *getAsConstantUnion() { return this; }
virtual void traverse(TIntermTraverser *);
virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
TIntermTyped *fold(TOperator, TIntermTyped *, TInfoSink &);
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const {}
protected:
ConstantUnion *mUnionArrayPointer;
};
//
// Intermediate class for node types that hold operators.
//
class TIntermOperator : public TIntermTyped
{
public:
TOperator getOp() const { return mOp; }
void setOp(TOperator op) { mOp = op; }
bool isAssignment() const;
bool isConstructor() const;
virtual bool hasSideEffects() const { return isAssignment(); }
protected:
TIntermOperator(TOperator op)
: TIntermTyped(TType(EbtFloat, EbpUndefined)),
mOp(op) {}
TIntermOperator(TOperator op, const TType &type)
: TIntermTyped(type),
mOp(op) {}
TOperator mOp;
};
//
// Nodes for all the basic binary math operators.
//
class TIntermBinary : public TIntermOperator
{
public:
TIntermBinary(TOperator op)
: TIntermOperator(op),
mAddIndexClamp(false) {}
virtual TIntermBinary *getAsBinaryNode() { return this; }
virtual void traverse(TIntermTraverser *);
virtual bool replaceChildNode(
TIntermNode *original, TIntermNode *replacement);
virtual bool hasSideEffects() const
{
return isAssignment() || mLeft->hasSideEffects() || mRight->hasSideEffects();
}
void setLeft(TIntermTyped *node) { mLeft = node; }
void setRight(TIntermTyped *node) { mRight = node; }
TIntermTyped *getLeft() const { return mLeft; }
TIntermTyped *getRight() const { return mRight; }
bool promote(TInfoSink &);
void setAddIndexClamp() { mAddIndexClamp = true; }
bool getAddIndexClamp() { return mAddIndexClamp; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected:
TIntermTyped* mLeft;
TIntermTyped* mRight;
// If set to true, wrap any EOpIndexIndirect with a clamp to bounds.
bool mAddIndexClamp;
};
//
// Nodes for unary math operators.
//
class TIntermUnary : public TIntermOperator
{
public:
TIntermUnary(TOperator op, const TType &type)
: TIntermOperator(op, type),
mOperand(NULL),
mUseEmulatedFunction(false) {}
TIntermUnary(TOperator op)
: TIntermOperator(op),
mOperand(NULL),
mUseEmulatedFunction(false) {}
virtual void traverse(TIntermTraverser *);
virtual TIntermUnary *getAsUnaryNode() { return this; }
virtual bool replaceChildNode(
TIntermNode *original, TIntermNode *replacement);
virtual bool hasSideEffects() const
{
return isAssignment() || mOperand->hasSideEffects();
}
void setOperand(TIntermTyped *operand) { mOperand = operand; }
TIntermTyped *getOperand() { return mOperand; }
bool promote(TInfoSink &);
void setUseEmulatedFunction() { mUseEmulatedFunction = true; }
bool getUseEmulatedFunction() { return mUseEmulatedFunction; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected:
TIntermTyped *mOperand;
// If set to true, replace the built-in function call with an emulated one
// to work around driver bugs.
bool mUseEmulatedFunction;
};
typedef TVector<TIntermNode *> TIntermSequence;
typedef TVector<int> TQualifierList;
//
// Nodes that operate on an arbitrary sized set of children.
//
class TIntermAggregate : public TIntermOperator
{
public:
TIntermAggregate()
: TIntermOperator(EOpNull),
mUserDefined(false),
mUseEmulatedFunction(false) { }
TIntermAggregate(TOperator op)
: TIntermOperator(op),
mUseEmulatedFunction(false) { }
~TIntermAggregate() { }
virtual TIntermAggregate *getAsAggregate() { return this; }
virtual void traverse(TIntermTraverser *);
virtual bool replaceChildNode(
TIntermNode *original, TIntermNode *replacement);
// Conservatively assume function calls and other aggregate operators have side-effects
virtual bool hasSideEffects() const { return true; }
TIntermSequence *getSequence() { return &mSequence; }
void setName(const TString &name) { mName = name; }
const TString &getName() const { return mName; }
void setUserDefined() { mUserDefined = true; }
bool isUserDefined() const { return mUserDefined; }
void setOptimize(bool optimize) { mOptimize = optimize; }
bool getOptimize() const { return mOptimize; }
void setDebug(bool debug) { mDebug = debug; }
bool getDebug() const { return mDebug; }
void setUseEmulatedFunction() { mUseEmulatedFunction = true; }
bool getUseEmulatedFunction() { return mUseEmulatedFunction; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected:
TIntermAggregate(const TIntermAggregate &); // disallow copy constructor
TIntermAggregate &operator=(const TIntermAggregate &); // disallow assignment operator
TIntermSequence mSequence;
TString mName;
bool mUserDefined; // used for user defined function names
bool mOptimize;
bool mDebug;
// If set to true, replace the built-in function call with an emulated one
// to work around driver bugs.
bool mUseEmulatedFunction;
};
//
// For if tests. Simplified since there is no switch statement.
//
class TIntermSelection : public TIntermTyped
{
public:
TIntermSelection(TIntermTyped *cond, TIntermNode *trueB, TIntermNode *falseB)
: TIntermTyped(TType(EbtVoid, EbpUndefined)),
mCondition(cond),
mTrueBlock(trueB),
mFalseBlock(falseB) {}
TIntermSelection(TIntermTyped *cond, TIntermNode *trueB, TIntermNode *falseB,
const TType &type)
: TIntermTyped(type),
mCondition(cond),
mTrueBlock(trueB),
mFalseBlock(falseB) {}
virtual void traverse(TIntermTraverser *);
virtual bool replaceChildNode(
TIntermNode *original, TIntermNode *replacement);
// Conservatively assume selections have side-effects
virtual bool hasSideEffects() const { return true; }
bool usesTernaryOperator() const { return getBasicType() != EbtVoid; }
TIntermNode *getCondition() const { return mCondition; }
TIntermNode *getTrueBlock() const { return mTrueBlock; }
TIntermNode *getFalseBlock() const { return mFalseBlock; }
TIntermSelection *getAsSelectionNode() { return this; }
virtual void enqueueChildren(std::queue<TIntermNode *> *nodeQueue) const;
protected:
TIntermTyped *mCondition;
TIntermNode *mTrueBlock;
TIntermNode *mFalseBlock;
};
enum Visit
{
PreVisit,
InVisit,
PostVisit
};
//
// For traversing the tree. User should derive from this,
// put their traversal specific data in it, and then pass
// it to a Traverse method.
//
// When using this, just fill in the methods for nodes you want visited.
// Return false from a pre-visit to skip visiting that node's subtree.
//
class TIntermTraverser
{
public:
POOL_ALLOCATOR_NEW_DELETE();
// TODO(zmo): remove default values.
TIntermTraverser(bool preVisit = true, bool inVisit = false, bool postVisit = false,
bool rightToLeft = false)
: preVisit(preVisit),
inVisit(inVisit),
postVisit(postVisit),
rightToLeft(rightToLeft),
mDepth(0),
mMaxDepth(0) {}
virtual ~TIntermTraverser() {}
virtual void visitSymbol(TIntermSymbol *) {}
virtual void visitRaw(TIntermRaw *) {}
virtual void visitConstantUnion(TIntermConstantUnion *) {}
virtual bool visitBinary(Visit, TIntermBinary *) { return true; }
virtual bool visitUnary(Visit, TIntermUnary *) { return true; }
virtual bool visitSelection(Visit, TIntermSelection *) { return true; }
virtual bool visitAggregate(Visit, TIntermAggregate *) { return true; }
virtual bool visitLoop(Visit, TIntermLoop *) { return true; }
virtual bool visitBranch(Visit, TIntermBranch *) { return true; }
int getMaxDepth() const { return mMaxDepth; }
void incrementDepth(TIntermNode *current)
{
mDepth++;
mMaxDepth = std::max(mMaxDepth, mDepth);
mPath.push_back(current);
}
void decrementDepth()
{
mDepth--;
mPath.pop_back();
}
TIntermNode *getParentNode()
{
return mPath.size() == 0 ? NULL : mPath.back();
}
// Return the original name if hash function pointer is NULL;
// otherwise return the hashed name.
static TString hash(const TString& name, ShHashFunction64 hashFunction);
const bool preVisit;
const bool inVisit;
const bool postVisit;
const bool rightToLeft;
protected:
int mDepth;
int mMaxDepth;
// All the nodes from root to the current node's parent during traversing.
TVector<TIntermNode *> mPath;
};
//
// For traversing the tree, and computing max depth.
// Takes a maximum depth limit to prevent stack overflow.
//
class TMaxDepthTraverser : public TIntermTraverser
{
public:
POOL_ALLOCATOR_NEW_DELETE();
TMaxDepthTraverser(int depthLimit)
: TIntermTraverser(true, true, false, false),
mDepthLimit(depthLimit) { }
virtual bool visitBinary(Visit, TIntermBinary *) { return depthCheck(); }
virtual bool visitUnary(Visit, TIntermUnary *) { return depthCheck(); }
virtual bool visitSelection(Visit, TIntermSelection *) { return depthCheck(); }
virtual bool visitAggregate(Visit, TIntermAggregate *) { return depthCheck(); }
virtual bool visitLoop(Visit, TIntermLoop *) { return depthCheck(); }
virtual bool visitBranch(Visit, TIntermBranch *) { return depthCheck(); }
protected:
bool depthCheck() const { return mMaxDepth < mDepthLimit; }
int mDepthLimit;
};
#endif // COMPILER_TRANSLATOR_INTERMEDIATE_H_

View File

@ -4,7 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
// //
// Traverse the intermediate representation tree, and // Traverse the intermediate representation tree, and

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATOR_LOOP_INFO_H_ #ifndef COMPILER_TRANSLATOR_LOOP_INFO_H_
#define COMPILER_TRANSLATOR_LOOP_INFO_H_ #define COMPILER_TRANSLATOR_LOOP_INFO_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
class TLoopIndexInfo class TLoopIndexInfo
{ {

View File

@ -9,7 +9,7 @@
#ifndef TRANSLATOR_NODESEARCH_H_ #ifndef TRANSLATOR_NODESEARCH_H_
#define TRANSLATOR_NODESEARCH_H_ #define TRANSLATOR_NODESEARCH_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
namespace sh namespace sh
{ {

View File

@ -81,9 +81,10 @@ void TOutputGLSLBase::writeVariableType(const TType &type)
{ {
TInfoSinkBase &out = objSink(); TInfoSinkBase &out = objSink();
TQualifier qualifier = type.getQualifier(); TQualifier qualifier = type.getQualifier();
// TODO(alokp): Validate qualifier for variable declarations.
if (qualifier != EvqTemporary && qualifier != EvqGlobal) if (qualifier != EvqTemporary && qualifier != EvqGlobal)
{
out << type.getQualifierString() << " "; out << type.getQualifierString() << " ";
}
// Declare the struct if we have not done so already. // Declare the struct if we have not done so already.
if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct())) if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct()))
{ {
@ -648,6 +649,17 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
mDeclaringVariables = false; mDeclaringVariables = false;
} }
break; break;
case EOpInvariantDeclaration: {
// Invariant declaration.
ASSERT(visit == PreVisit);
const TIntermSequence *sequence = node->getSequence();
ASSERT(sequence && sequence->size() == 1);
const TIntermSymbol *symbol = sequence->front()->getAsSymbolNode();
ASSERT(symbol);
out << "invariant " << symbol->getSymbol() << ";";
visitChildren = false;
break;
}
case EOpConstructFloat: case EOpConstructFloat:
writeTriplet(visit, "float(", NULL, ")"); writeTriplet(visit, "float(", NULL, ")");
break; break;

View File

@ -9,7 +9,7 @@
#include <set> #include <set>
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
#include "compiler/translator/LoopInfo.h" #include "compiler/translator/LoopInfo.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"

View File

@ -21,6 +21,7 @@
#include "compiler/translator/util.h" #include "compiler/translator/util.h"
#include "compiler/translator/UniformHLSL.h" #include "compiler/translator/UniformHLSL.h"
#include "compiler/translator/StructureHLSL.h" #include "compiler/translator/StructureHLSL.h"
#include "compiler/translator/TranslatorHLSL.h"
#include <algorithm> #include <algorithm>
#include <cfloat> #include <cfloat>
@ -93,8 +94,10 @@ bool OutputHLSL::TextureFunction::operator<(const TextureFunction &rhs) const
return false; return false;
} }
OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType) OutputHLSL::OutputHLSL(TParseContext &context, TranslatorHLSL *parentTranslator)
: TIntermTraverser(true, true, true), mContext(context), mOutputType(outputType) : TIntermTraverser(true, true, true),
mContext(context),
mOutputType(parentTranslator->getOutputType())
{ {
mUnfoldShortCircuit = new UnfoldShortCircuit(context, this); mUnfoldShortCircuit = new UnfoldShortCircuit(context, this);
mInsideFunction = false; mInsideFunction = false;
@ -126,6 +129,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc
mUsesDiscardRewriting = false; mUsesDiscardRewriting = false;
mUsesNestedBreak = false; mUsesNestedBreak = false;
const ShBuiltInResources &resources = parentTranslator->getResources();
mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1; mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1;
mUniqueIndex = 0; mUniqueIndex = 0;
@ -138,7 +142,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc
mExcessiveLoopIndex = NULL; mExcessiveLoopIndex = NULL;
mStructureHLSL = new StructureHLSL; mStructureHLSL = new StructureHLSL;
mUniformHLSL = new UniformHLSL(mStructureHLSL, mOutputType); mUniformHLSL = new UniformHLSL(mStructureHLSL, parentTranslator);
if (mOutputType == SH_HLSL9_OUTPUT) if (mOutputType == SH_HLSL9_OUTPUT)
{ {
@ -212,31 +216,6 @@ TInfoSinkBase &OutputHLSL::getBodyStream()
return mBody; return mBody;
} }
const std::vector<sh::Uniform> &OutputHLSL::getUniforms()
{
return mUniformHLSL->getUniforms();
}
const std::vector<sh::InterfaceBlock> &OutputHLSL::getInterfaceBlocks() const
{
return mUniformHLSL->getInterfaceBlocks();
}
const std::vector<sh::Attribute> &OutputHLSL::getOutputVariables() const
{
return mActiveOutputVariables;
}
const std::vector<sh::Attribute> &OutputHLSL::getAttributes() const
{
return mActiveAttributes;
}
const std::vector<sh::Varying> &OutputHLSL::getVaryings() const
{
return mActiveVaryings;
}
const std::map<std::string, unsigned int> &OutputHLSL::getInterfaceBlockRegisterMap() const const std::map<std::string, unsigned int> &OutputHLSL::getInterfaceBlockRegisterMap() const
{ {
return mUniformHLSL->getInterfaceBlockRegisterMap(); return mUniformHLSL->getInterfaceBlockRegisterMap();
@ -324,8 +303,6 @@ void OutputHLSL::header()
// Program linking depends on this exact format // Program linking depends on this exact format
varyings += "static " + InterpolationString(type.getQualifier()) + " " + TypeString(type) + " " + varyings += "static " + InterpolationString(type.getQualifier()) + " " + TypeString(type) + " " +
Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n"; Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n";
declareVaryingToList(type, type.getQualifier(), name, mActiveVaryings);
} }
for (ReferencedSymbols::const_iterator attribute = mReferencedAttributes.begin(); attribute != mReferencedAttributes.end(); attribute++) for (ReferencedSymbols::const_iterator attribute = mReferencedAttributes.begin(); attribute != mReferencedAttributes.end(); attribute++)
@ -334,10 +311,6 @@ void OutputHLSL::header()
const TString &name = attribute->second->getSymbol(); const TString &name = attribute->second->getSymbol();
attributes += "static " + TypeString(type) + " " + Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n"; attributes += "static " + TypeString(type) + " " + Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n";
sh::Attribute attributeVar(GLVariableType(type), GLVariablePrecision(type), name.c_str(),
(unsigned int)type.getArraySize(), type.getLayoutQualifier().location);
mActiveAttributes.push_back(attributeVar);
} }
out << mStructureHLSL->structsHeader(); out << mStructureHLSL->structsHeader();
@ -370,14 +343,9 @@ void OutputHLSL::header()
{ {
const TString &variableName = outputVariableIt->first; const TString &variableName = outputVariableIt->first;
const TType &variableType = outputVariableIt->second->getType(); const TType &variableType = outputVariableIt->second->getType();
const TLayoutQualifier &layoutQualifier = variableType.getLayoutQualifier();
out << "static " + TypeString(variableType) + " out_" + variableName + ArrayString(variableType) + out << "static " + TypeString(variableType) + " out_" + variableName + ArrayString(variableType) +
" = " + initializer(variableType) + ";\n"; " = " + initializer(variableType) + ";\n";
sh::Attribute outputVar(GLVariableType(variableType), GLVariablePrecision(variableType), variableName.c_str(),
(unsigned int)variableType.getArraySize(), layoutQualifier.location);
mActiveOutputVariables.push_back(outputVar);
} }
} }
else else
@ -1951,6 +1919,9 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << ", "; out << ", ";
} }
break; break;
case EOpInvariantDeclaration:
// Do not do any translation
return false;
case EOpPrototype: case EOpPrototype:
if (visit == PreVisit) if (visit == PreVisit)
{ {
@ -2910,29 +2881,4 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con
return constUnion; return constUnion;
} }
class DeclareVaryingTraverser : public GetVariableTraverser<Varying>
{
public:
DeclareVaryingTraverser(std::vector<Varying> *output,
InterpolationType interpolation)
: GetVariableTraverser(output),
mInterpolation(interpolation)
{}
private:
void visitVariable(Varying *varying)
{
varying->interpolation = mInterpolation;
}
InterpolationType mInterpolation;
};
void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier,
const TString &name, std::vector<Varying> &fieldsOut)
{
DeclareVaryingTraverser traverser(&fieldsOut, GetInterpolationType(baseTypeQualifier));
traverser.traverse(type, name);
}
} }

View File

@ -12,9 +12,9 @@
#include <map> #include <map>
#include "angle_gl.h" #include "angle_gl.h"
#include "compiler/translator/intermediate.h"
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"
#include "common/shadervars.h"
namespace sh namespace sh
{ {
@ -27,17 +27,12 @@ typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
class OutputHLSL : public TIntermTraverser class OutputHLSL : public TIntermTraverser
{ {
public: public:
OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType); OutputHLSL(TParseContext &context, TranslatorHLSL *parentTranslator);
~OutputHLSL(); ~OutputHLSL();
void output(); void output();
TInfoSinkBase &getBodyStream(); TInfoSinkBase &getBodyStream();
const std::vector<sh::Uniform> &getUniforms();
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<sh::Attribute> &getOutputVariables() const;
const std::vector<sh::Attribute> &getAttributes() const;
const std::vector<sh::Varying> &getVaryings() const;
const std::map<std::string, unsigned int> &getInterfaceBlockRegisterMap() const; const std::map<std::string, unsigned int> &getInterfaceBlockRegisterMap() const;
const std::map<std::string, unsigned int> &getUniformRegisterMap() const; const std::map<std::string, unsigned int> &getUniformRegisterMap() const;
@ -155,13 +150,8 @@ class OutputHLSL : public TIntermTraverser
TIntermSymbol *mExcessiveLoopIndex; TIntermSymbol *mExcessiveLoopIndex;
void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<sh::Varying>& fieldsOut);
TString structInitializerString(int indent, const TStructure &structure, const TString &rhsStructName); TString structInitializerString(int indent, const TStructure &structure, const TString &rhsStructName);
std::vector<sh::Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Varying> mActiveVaryings;
std::map<TIntermTyped*, TString> mFlaggedStructMappedNames; std::map<TIntermTyped*, TString> mFlaggedStructMappedNames;
std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames; std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames;

View File

@ -1018,6 +1018,45 @@ void TParseContext::handlePragmaDirective(const TSourceLoc& loc, const char* nam
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
const TVariable *TParseContext::getNamedVariable(const TSourceLoc &location,
const TString *name,
const TSymbol *symbol)
{
const TVariable *variable = NULL;
if (!symbol)
{
error(location, "undeclared identifier", name->c_str());
recover();
}
else if (!symbol->isVariable())
{
error(location, "variable expected", name->c_str());
recover();
}
else
{
variable = static_cast<const TVariable*>(symbol);
if (symbolTable.findBuiltIn(variable->getName(), shaderVersion) &&
!variable->getExtension().empty() &&
extensionErrorCheck(location, variable->getExtension()))
{
recover();
}
}
if (!variable)
{
TType type(EbtFloat, EbpUndefined);
TVariable *fakeVariable = new TVariable(name, type);
symbolTable.declare(fakeVariable);
variable = fakeVariable;
}
return variable;
}
// //
// Look up a function name in the symbol table, and make sure it is a function. // Look up a function name in the symbol table, and make sure it is a function.
// //
@ -1050,6 +1089,8 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& line, TFunction*
// Initializers show up in several places in the grammar. Have one set of // Initializers show up in several places in the grammar. Have one set of
// code to handle them here. // code to handle them here.
// //
// Returns true on error, false if no error
//
bool TParseContext::executeInitializer(const TSourceLoc& line, const TString& identifier, TPublicType& pType, bool TParseContext::executeInitializer(const TSourceLoc& line, const TString& identifier, TPublicType& pType,
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable) TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable)
{ {
@ -1308,14 +1349,40 @@ TIntermAggregate* TParseContext::parseSingleInitDeclaration(TPublicType &publicT
} }
} }
TIntermAggregate* TParseContext::parseDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, TSymbol *identifierSymbol, const TSourceLoc& identifierLocation, const TString &identifier) TIntermAggregate* TParseContext::parseInvariantDeclaration(const TSourceLoc &invariantLoc,
const TSourceLoc &identifierLoc,
const TString *identifier,
const TSymbol *symbol)
{ {
if (publicType.type == EbtInvariant && !identifierSymbol) // invariant declaration
if (globalErrorCheck(invariantLoc, symbolTable.atGlobalLevel(), "invariant varying"))
{ {
error(identifierLocation, "undeclared identifier declared as invariant", identifier.c_str());
recover(); recover();
} }
if (!symbol)
{
error(identifierLoc, "undeclared identifier declared as invariant", identifier->c_str());
recover();
return NULL;
}
else
{
const TVariable *variable = getNamedVariable(identifierLoc, identifier, symbol);
ASSERT(variable);
const TType &type = variable->getType();
TIntermSymbol *intermSymbol = intermediate.addSymbol(variable->getUniqueId(),
*identifier, type, identifierLoc);
TIntermAggregate *aggregate = intermediate.makeAggregate(intermSymbol, identifierLoc);
aggregate->setOp(EOpInvariantDeclaration);
return aggregate;
}
}
TIntermAggregate* TParseContext::parseDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, TSymbol *identifierSymbol, const TSourceLoc& identifierLocation, const TString &identifier)
{
TIntermSymbol* symbol = intermediate.addSymbol(0, identifier, TType(publicType), identifierLocation); TIntermSymbol* symbol = intermediate.addSymbol(0, identifier, TType(publicType), identifierLocation);
TIntermAggregate* intermAggregate = intermediate.growAggregate(aggregateDeclaration, symbol, identifierLocation); TIntermAggregate* intermAggregate = intermediate.growAggregate(aggregateDeclaration, symbol, identifierLocation);
@ -1548,7 +1615,7 @@ TIntermTyped *TParseContext::addConstructor(TIntermNode *arguments, const TType
for (size_t i = 0; i < fields.size(); i++) for (size_t i = 0; i < fields.size(); i++)
{ {
if ((*args)[i]->getAsTyped()->getType() != *fields[i]->type()) if (i >= args->size() || (*args)[i]->getAsTyped()->getType() != *fields[i]->type())
{ {
error(line, "Structure constructor arguments do not match structure fields", "Error"); error(line, "Structure constructor arguments do not match structure fields", "Error");
recover(); recover();

View File

@ -9,7 +9,7 @@
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
#include "compiler/translator/Diagnostics.h" #include "compiler/translator/Diagnostics.h"
#include "compiler/translator/DirectiveHandler.h" #include "compiler/translator/DirectiveHandler.h"
#include "compiler/translator/localintermediate.h" #include "compiler/translator/Intermediate.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/preprocessor/Preprocessor.h" #include "compiler/preprocessor/Preprocessor.h"
@ -77,6 +77,9 @@ struct TParseContext {
void trace(const char* str); void trace(const char* str);
void recover(); void recover();
// This method is guaranteed to succeed, even if no variable with 'name' exists.
const TVariable *getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol);
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, const TSourceLoc& line); bool parseVectorFields(const TString&, int vecSize, TVectorFields&, const TSourceLoc& line);
bool parseMatrixFields(const TString&, int matCols, int matRows, TMatrixFields&, const TSourceLoc& line); bool parseMatrixFields(const TString&, int matCols, int matRows, TMatrixFields&, const TSourceLoc& line);
@ -126,6 +129,8 @@ struct TParseContext {
TIntermAggregate* parseSingleDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier); TIntermAggregate* parseSingleDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier);
TIntermAggregate* parseSingleArrayDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& indexLocation, TIntermTyped *indexExpression); TIntermAggregate* parseSingleArrayDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& indexLocation, TIntermTyped *indexExpression);
TIntermAggregate* parseSingleInitDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& initLocation, TIntermTyped *initializer); TIntermAggregate* parseSingleInitDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& initLocation, TIntermTyped *initializer);
TIntermAggregate* parseInvariantDeclaration(const TSourceLoc &invariantLoc, const TSourceLoc &identifierLoc, const TString *identifier, const TSymbol *symbol);
TIntermAggregate* parseDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, TSymbol *identifierSymbol, const TSourceLoc& identifierLocation, const TString &identifier); TIntermAggregate* parseDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, TSymbol *identifierSymbol, const TSourceLoc& identifierLocation, const TString &identifier);
TIntermAggregate* parseArrayDeclarator(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& arrayLocation, TIntermNode *declaratorList, TIntermTyped *indexExpression); TIntermAggregate* parseArrayDeclarator(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& arrayLocation, TIntermNode *declaratorList, TIntermTyped *indexExpression);
TIntermAggregate* parseInitDeclarator(TPublicType &publicType, TIntermAggregate *declaratorList, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& initLocation, TIntermTyped *initializer); TIntermAggregate* parseInitDeclarator(TPublicType &publicType, TIntermAggregate *declaratorList, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& initLocation, TIntermTyped *initializer);

View File

@ -4,7 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
class TAliveTraverser : public TIntermTraverser { class TAliveTraverser : public TIntermTraverser {
public: public:

View File

@ -0,0 +1,82 @@
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "compiler/translator/RegenerateStructNames.h"
#include "compiler/translator/compilerdebug.h"
void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
{
ASSERT(symbol);
TType *type = symbol->getTypePointer();
ASSERT(type);
TStructure *userType = type->getStruct();
if (!userType)
return;
if (mSymbolTable.findBuiltIn(userType->name(), mShaderVersion))
{
// Built-in struct, do not touch it.
return;
}
int uniqueId = userType->uniqueId();
ASSERT(mScopeDepth > 0);
if (mScopeDepth == 1)
{
// If a struct is defined at global scope, we don't map its name.
// This is because at global level, the struct might be used to
// declare a uniform, so the same name needs to stay the same for
// vertex/fragment shaders. However, our mapping uses internal ID,
// which will be different for the same struct in vertex/fragment
// shaders.
// This is OK because names for any structs defined in other scopes
// will begin with "_webgl", which is reserved. So there will be
// no conflicts among unmapped struct names from global scope and
// mapped struct names from other scopes.
// However, we need to keep track of these global structs, so if a
// variable is used in a local scope, we don't try to modify the
// struct name through that variable.
mDeclaredGlobalStructs.insert(uniqueId);
return;
}
if (mDeclaredGlobalStructs.count(uniqueId) > 0)
return;
// Map {name} to _webgl_struct_{uniqueId}_{name}.
const char kPrefix[] = "_webgl_struct_";
if (userType->name().find(kPrefix) == 0)
{
// The name has already been regenerated.
return;
}
std::string id = Str(uniqueId);
TString tmp = kPrefix + TString(id.c_str());
tmp += "_" + userType->name();
userType->setName(tmp);
}
bool RegenerateStructNames::visitAggregate(Visit, TIntermAggregate *aggregate)
{
ASSERT(aggregate);
switch (aggregate->getOp())
{
case EOpSequence:
++mScopeDepth;
{
TIntermSequence &sequence = *(aggregate->getSequence());
for (size_t ii = 0; ii < sequence.size(); ++ii)
{
TIntermNode *node = sequence[ii];
ASSERT(node != NULL);
node->traverse(this);
}
}
--mScopeDepth;
return false;
default:
return true;
}
}

View File

@ -0,0 +1,40 @@
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef COMPILER_TRANSLATOR_REGENERATE_STRUCT_NAMES_H_
#define COMPILER_TRANSLATOR_REGENERATE_STRUCT_NAMES_H_
#include "compiler/translator/Intermediate.h"
#include "compiler/translator/SymbolTable.h"
#include <set>
class RegenerateStructNames : public TIntermTraverser
{
public:
RegenerateStructNames(const TSymbolTable &symbolTable,
int shaderVersion)
: mSymbolTable(symbolTable),
mShaderVersion(shaderVersion),
mScopeDepth(0) {}
protected:
virtual void visitSymbol(TIntermSymbol *);
virtual bool visitAggregate(Visit, TIntermAggregate *);
private:
const TSymbolTable &mSymbolTable;
int mShaderVersion;
// Indicating the depth of the current scope.
// The global scope is 1.
int mScopeDepth;
// If a struct's declared globally, push its ID in this set.
std::set<int> mDeclaredGlobalStructs;
};
#endif // COMPILER_TRANSLATOR_REGENERATE_STRUCT_NAMES_H_

View File

@ -4,7 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
#include "compiler/translator/RemoveTree.h" #include "compiler/translator/RemoveTree.h"
// //

View File

@ -7,7 +7,7 @@
#ifndef COMPILER_RENAME_FUNCTION #ifndef COMPILER_RENAME_FUNCTION
#define COMPILER_RENAME_FUNCTION #define COMPILER_RENAME_FUNCTION
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
// //
// Renames a function, including its declaration and any calls to it. // Renames a function, including its declaration and any calls to it.

View File

@ -10,7 +10,7 @@
#ifndef COMPILER_REWRITE_ELSE_BLOCKS_H_ #ifndef COMPILER_REWRITE_ELSE_BLOCKS_H_
#define COMPILER_REWRITE_ELSE_BLOCKS_H_ #define COMPILER_REWRITE_ELSE_BLOCKS_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
namespace sh namespace sh
{ {

View File

@ -9,6 +9,7 @@
#include <algorithm> #include <algorithm>
#include "angle_gl.h"
#include "common/angleutils.h" #include "common/angleutils.h"
namespace namespace
@ -249,6 +250,16 @@ TString ScalarizeVecAndMatConstructorArgs::createTempVariable(TIntermTyped *orig
TType type = original->getType(); TType type = original->getType();
type.setQualifier(EvqTemporary); type.setQualifier(EvqTemporary);
if (mShaderType == GL_FRAGMENT_SHADER &&
type.getBasicType() == EbtFloat &&
type.getPrecision() == EbpUndefined)
{
// We use the highest available precision for the temporary variable
// to avoid computing the actual precision using the rules defined
// in GLSL ES 1.0 Section 4.5.2.
type.setPrecision(mFragmentPrecisionHigh ? EbpHigh : EbpMedium);
}
TIntermBinary *init = new TIntermBinary(EOpInitialize); TIntermBinary *init = new TIntermBinary(EOpInitialize);
TIntermSymbol *symbolNode = new TIntermSymbol(-1, tempVarName, type); TIntermSymbol *symbolNode = new TIntermSymbol(-1, tempVarName, type);
init->setLeft(symbolNode); init->setLeft(symbolNode);

View File

@ -7,13 +7,16 @@
#ifndef COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_ #ifndef COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_
#define COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_ #define COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser
{ {
public: public:
ScalarizeVecAndMatConstructorArgs() ScalarizeVecAndMatConstructorArgs(sh::GLenum shaderType,
: mTempVarCount(0) {} bool fragmentPrecisionHigh)
: mTempVarCount(0),
mShaderType(shaderType),
mFragmentPrecisionHigh(fragmentPrecisionHigh) {}
protected: protected:
virtual bool visitAggregate(Visit visit, TIntermAggregate *node); virtual bool visitAggregate(Visit visit, TIntermAggregate *node);
@ -36,6 +39,9 @@ class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser
std::vector<TIntermSequence> mSequenceStack; std::vector<TIntermSequence> mSequenceStack;
int mTempVarCount; int mTempVarCount;
sh::GLenum mShaderType;
bool mFragmentPrecisionHigh;
}; };
#endif // COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_ #endif // COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_

View File

@ -9,7 +9,7 @@
#ifndef COMPILER_SEARCHSYMBOL_H_ #ifndef COMPILER_SEARCHSYMBOL_H_
#define COMPILER_SEARCHSYMBOL_H_ #define COMPILER_SEARCHSYMBOL_H_
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
#include "compiler/translator/ParseContext.h" #include "compiler/translator/ParseContext.h"
namespace sh namespace sh

View File

@ -18,14 +18,26 @@
#include "compiler/translator/VariablePacker.h" #include "compiler/translator/VariablePacker.h"
#include "angle_gl.h" #include "angle_gl.h"
static bool isInitialized = false; namespace
{
enum ShaderVariableType
{
SHADERVAR_UNIFORM,
SHADERVAR_VARYING,
SHADERVAR_ATTRIBUTE,
SHADERVAR_OUTPUTVARIABLE,
SHADERVAR_INTERFACEBLOCK
};
bool isInitialized = false;
// //
// This is the platform independent interface between an OGL driver // This is the platform independent interface between an OGL driver
// and the shading language compiler. // and the shading language compiler.
// //
static bool checkVariableMaxLengths(const ShHandle handle, static bool CheckVariableMaxLengths(const ShHandle handle,
size_t expectedValue) size_t expectedValue)
{ {
size_t activeUniformLimit = 0; size_t activeUniformLimit = 0;
@ -39,7 +51,7 @@ static bool checkVariableMaxLengths(const ShHandle handle,
expectedValue == varyingLimit); expectedValue == varyingLimit);
} }
static bool checkMappedNameMaxLength(const ShHandle handle, size_t expectedValue) bool CheckMappedNameMaxLength(const ShHandle handle, size_t expectedValue)
{ {
size_t mappedNameMaxLength = 0; size_t mappedNameMaxLength = 0;
ShGetInfo(handle, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameMaxLength); ShGetInfo(handle, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameMaxLength);
@ -47,7 +59,7 @@ static bool checkMappedNameMaxLength(const ShHandle handle, size_t expectedValue
} }
template <typename VarT> template <typename VarT>
static const sh::ShaderVariable *ReturnVariable(const std::vector<VarT> &infoList, int index) const sh::ShaderVariable *ReturnVariable(const std::vector<VarT> &infoList, int index)
{ {
if (index < 0 || static_cast<size_t>(index) >= infoList.size()) if (index < 0 || static_cast<size_t>(index) >= infoList.size())
{ {
@ -57,7 +69,7 @@ static const sh::ShaderVariable *ReturnVariable(const std::vector<VarT> &infoLis
return &infoList[index]; return &infoList[index];
} }
static const sh::ShaderVariable *GetVariable(const TCompiler *compiler, ShShaderInfo varType, int index) const sh::ShaderVariable *GetVariable(const TCompiler *compiler, ShShaderInfo varType, int index)
{ {
switch (varType) switch (varType)
{ {
@ -73,7 +85,7 @@ static const sh::ShaderVariable *GetVariable(const TCompiler *compiler, ShShader
} }
} }
static ShPrecisionType ConvertPrecision(sh::GLenum precision) ShPrecisionType ConvertPrecision(sh::GLenum precision)
{ {
switch (precision) switch (precision)
{ {
@ -91,6 +103,55 @@ static ShPrecisionType ConvertPrecision(sh::GLenum precision)
} }
} }
template <typename VarT>
const std::vector<VarT> *GetVariableList(const TCompiler *compiler, ShaderVariableType variableType);
template <>
const std::vector<sh::Uniform> *GetVariableList(const TCompiler *compiler, ShaderVariableType)
{
return &compiler->getUniforms();
}
template <>
const std::vector<sh::Varying> *GetVariableList(const TCompiler *compiler, ShaderVariableType)
{
return &compiler->getVaryings();
}
template <>
const std::vector<sh::Attribute> *GetVariableList(const TCompiler *compiler, ShaderVariableType variableType)
{
return (variableType == SHADERVAR_ATTRIBUTE ?
&compiler->getAttributes() :
&compiler->getOutputVariables());
}
template <>
const std::vector<sh::InterfaceBlock> *GetVariableList(const TCompiler *compiler, ShaderVariableType)
{
return &compiler->getInterfaceBlocks();
}
template <typename VarT>
const std::vector<VarT> *GetShaderVariables(const ShHandle handle, ShaderVariableType variableType)
{
if (!handle)
{
return NULL;
}
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
TCompiler* compiler = base->getAsCompiler();
if (!compiler)
{
return NULL;
}
return GetVariableList<VarT>(compiler, variableType);
}
}
// //
// Driver must call this first, once, before doing any other compiler operations. // Driver must call this first, once, before doing any other compiler operations.
// Subsequent calls to this function are no-op. // Subsequent calls to this function are no-op.
@ -372,7 +433,7 @@ void ShGetVariableInfo(const ShHandle handle,
// SH_ACTIVE_UNIFORM_MAX_LENGTH, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, SH_VARYING_MAX_LENGTH // SH_ACTIVE_UNIFORM_MAX_LENGTH, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, SH_VARYING_MAX_LENGTH
// in ShGetInfo, below. // in ShGetInfo, below.
size_t variableLength = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec()); size_t variableLength = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
ASSERT(checkVariableMaxLengths(handle, variableLength)); ASSERT(CheckVariableMaxLengths(handle, variableLength));
strncpy(name, varInfo->name.c_str(), variableLength); strncpy(name, varInfo->name.c_str(), variableLength);
name[variableLength - 1] = 0; name[variableLength - 1] = 0;
if (mappedName) if (mappedName)
@ -380,7 +441,7 @@ void ShGetVariableInfo(const ShHandle handle,
// This size must match that queried by // This size must match that queried by
// SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below. // SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below.
size_t maxMappedNameLength = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec()); size_t maxMappedNameLength = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
ASSERT(checkMappedNameMaxLength(handle, maxMappedNameLength)); ASSERT(CheckMappedNameMaxLength(handle, maxMappedNameLength));
strncpy(mappedName, varInfo->mappedName.c_str(), maxMappedNameLength); strncpy(mappedName, varInfo->mappedName.c_str(), maxMappedNameLength);
mappedName[maxMappedNameLength - 1] = 0; mappedName[maxMappedNameLength - 1] = 0;
} }
@ -429,34 +490,29 @@ void ShGetNameHashingEntry(const ShHandle handle,
hashedName[len - 1] = '\0'; hashedName[len - 1] = '\0';
} }
void ShGetInfoPointer(const ShHandle handle, ShShaderInfo pname, void** params) const std::vector<sh::Uniform> *ShGetUniforms(const ShHandle handle)
{ {
if (!handle || !params) return GetShaderVariables<sh::Uniform>(handle, SHADERVAR_UNIFORM);
return; }
TShHandleBase* base = static_cast<TShHandleBase*>(handle); const std::vector<sh::Varying> *ShGetVaryings(const ShHandle handle)
TranslatorHLSL* translator = base->getAsTranslatorHLSL(); {
if (!translator) return; return GetShaderVariables<sh::Varying>(handle, SHADERVAR_VARYING);
}
switch(pname) const std::vector<sh::Attribute> *ShGetAttributes(const ShHandle handle)
{ {
case SH_ACTIVE_UNIFORMS_ARRAY: return GetShaderVariables<sh::Attribute>(handle, SHADERVAR_ATTRIBUTE);
*params = (void*)&translator->getUniforms(); }
break;
case SH_ACTIVE_INTERFACE_BLOCKS_ARRAY: const std::vector<sh::Attribute> *ShGetOutputVariables(const ShHandle handle)
*params = (void*)&translator->getInterfaceBlocks(); {
break; return GetShaderVariables<sh::Attribute>(handle, SHADERVAR_OUTPUTVARIABLE);
case SH_ACTIVE_OUTPUT_VARIABLES_ARRAY: }
*params = (void*)&translator->getOutputVariables();
break; const std::vector<sh::InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle)
case SH_ACTIVE_ATTRIBUTES_ARRAY: {
*params = (void*)&translator->getAttributes(); return GetShaderVariables<sh::InterfaceBlock>(handle, SHADERVAR_INTERFACEBLOCK);
break;
case SH_ACTIVE_VARYINGS_ARRAY:
*params = (void*)&translator->getVaryings();
break;
default: UNREACHABLE();
}
} }
int ShCheckVariablesWithinPackingLimits( int ShCheckVariablesWithinPackingLimits(
@ -468,7 +524,7 @@ int ShCheckVariablesWithinPackingLimits(
std::vector<sh::ShaderVariable> variables; std::vector<sh::ShaderVariable> variables;
for (size_t ii = 0; ii < varInfoArraySize; ++ii) for (size_t ii = 0; ii < varInfoArraySize; ++ii)
{ {
sh::ShaderVariable var(varInfoArray[ii].type, (sh::GLenum)0, "", varInfoArray[ii].size); sh::ShaderVariable var(varInfoArray[ii].type, varInfoArray[ii].size);
variables.push_back(var); variables.push_back(var);
} }
VariablePacker packer; VariablePacker packer;

View File

@ -0,0 +1,166 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ShaderVars.cpp:
// Methods for GL variable types (varyings, uniforms, etc)
//
#include <GLSLANG/ShaderLang.h>
namespace sh
{
ShaderVariable::ShaderVariable()
: type(0),
precision(0),
arraySize(0),
staticUse(false)
{}
ShaderVariable::ShaderVariable(GLenum typeIn, unsigned int arraySizeIn)
: type(typeIn),
precision(0),
arraySize(arraySizeIn),
staticUse(false)
{}
ShaderVariable::~ShaderVariable()
{}
ShaderVariable::ShaderVariable(const ShaderVariable &other)
: type(other.type),
precision(other.precision),
name(other.name),
mappedName(other.mappedName),
arraySize(other.arraySize),
staticUse(other.staticUse),
fields(other.fields),
structName(other.structName)
{}
ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other)
{
type = other.type;
precision = other.precision;
name = other.name;
mappedName = other.mappedName;
arraySize = other.arraySize;
staticUse = other.staticUse;
fields = other.fields;
structName = other.structName;
return *this;
}
Uniform::Uniform()
{}
Uniform::~Uniform()
{}
Uniform::Uniform(const Uniform &other)
: ShaderVariable(other)
{}
Uniform &Uniform::operator=(const Uniform &other)
{
ShaderVariable::operator=(other);
return *this;
}
Attribute::Attribute()
: location(-1)
{}
Attribute::~Attribute()
{}
Attribute::Attribute(const Attribute &other)
: ShaderVariable(other),
location(other.location)
{}
Attribute &Attribute::operator=(const Attribute &other)
{
ShaderVariable::operator=(other);
location = other.location;
return *this;
}
InterfaceBlockField::InterfaceBlockField()
: isRowMajorLayout(false)
{}
InterfaceBlockField::~InterfaceBlockField()
{}
InterfaceBlockField::InterfaceBlockField(const InterfaceBlockField &other)
: ShaderVariable(other),
isRowMajorLayout(other.isRowMajorLayout)
{}
InterfaceBlockField &InterfaceBlockField::operator=(const InterfaceBlockField &other)
{
ShaderVariable::operator=(other);
isRowMajorLayout = other.isRowMajorLayout;
return *this;
}
Varying::Varying()
: interpolation(INTERPOLATION_SMOOTH),
isInvariant(false)
{}
Varying::~Varying()
{}
Varying::Varying(const Varying &other)
: ShaderVariable(other),
interpolation(other.interpolation),
isInvariant(other.isInvariant)
{}
Varying &Varying::operator=(const Varying &other)
{
ShaderVariable::operator=(other);
interpolation = other.interpolation;
isInvariant = other.isInvariant;
return *this;
}
InterfaceBlock::InterfaceBlock()
: arraySize(0),
layout(BLOCKLAYOUT_PACKED),
isRowMajorLayout(false),
staticUse(false)
{}
InterfaceBlock::~InterfaceBlock()
{}
InterfaceBlock::InterfaceBlock(const InterfaceBlock &other)
: name(other.name),
mappedName(other.mappedName),
instanceName(other.instanceName),
arraySize(other.arraySize),
layout(other.layout),
isRowMajorLayout(other.isRowMajorLayout),
staticUse(other.staticUse),
fields(other.fields)
{}
InterfaceBlock &InterfaceBlock::operator=(const InterfaceBlock &other)
{
name = other.name;
mappedName = other.mappedName;
instanceName = other.instanceName;
arraySize = other.arraySize;
layout = other.layout;
isRowMajorLayout = other.isRowMajorLayout;
staticUse = other.staticUse;
fields = other.fields;
return *this;
}
}

View File

@ -17,12 +17,19 @@
namespace sh namespace sh
{ {
Std140PaddingHelper::Std140PaddingHelper(const std::map<TString, int> &structElementIndexes) Std140PaddingHelper::Std140PaddingHelper(const std::map<TString, int> &structElementIndexes,
: mPaddingCounter(0), unsigned *uniqueCounter)
: mPaddingCounter(uniqueCounter),
mElementIndex(0), mElementIndex(0),
mStructElementIndexes(structElementIndexes) mStructElementIndexes(structElementIndexes)
{} {}
TString Std140PaddingHelper::next()
{
unsigned value = (*mPaddingCounter)++;
return str(value);
}
int Std140PaddingHelper::prePadding(const TType &type) int Std140PaddingHelper::prePadding(const TType &type)
{ {
if (type.getBasicType() == EbtStruct || type.isMatrix() || type.isArray()) if (type.getBasicType() == EbtStruct || type.isMatrix() || type.isArray())
@ -68,7 +75,7 @@ TString Std140PaddingHelper::prePaddingString(const TType &type)
for (int paddingIndex = 0; paddingIndex < paddingCount; paddingIndex++) for (int paddingIndex = 0; paddingIndex < paddingCount; paddingIndex++)
{ {
padding += " float pad_" + str(mPaddingCounter++) + ";\n"; padding += " float pad_" + next() + ";\n";
} }
return padding; return padding;
@ -116,19 +123,25 @@ TString Std140PaddingHelper::postPaddingString(const TType &type, bool useHLSLRo
TString padding; TString padding;
for (int paddingOffset = numComponents; paddingOffset < 4; paddingOffset++) for (int paddingOffset = numComponents; paddingOffset < 4; paddingOffset++)
{ {
padding += " float pad_" + str(mPaddingCounter++) + ";\n"; padding += " float pad_" + next() + ";\n";
} }
return padding; return padding;
} }
StructureHLSL::StructureHLSL() StructureHLSL::StructureHLSL()
: mUniquePaddingCounter(0)
{} {}
Std140PaddingHelper StructureHLSL::getPaddingHelper()
{
return Std140PaddingHelper(mStd140StructElementIndexes, &mUniquePaddingCounter);
}
TString StructureHLSL::defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing) TString StructureHLSL::defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing)
{ {
if (useStd140Packing) if (useStd140Packing)
{ {
Std140PaddingHelper padHelper(mStd140StructElementIndexes); Std140PaddingHelper padHelper = getPaddingHelper();
return define(structure, useHLSLRowMajorPacking, useStd140Packing, &padHelper); return define(structure, useHLSLRowMajorPacking, useStd140Packing, &padHelper);
} }
else else
@ -291,9 +304,9 @@ void StructureHLSL::addConstructor(const TType &type, const TString &name, const
if (parameter.isScalar()) if (parameter.isScalar())
{ {
for (int row = 0; row < rows; row++) for (int col = 0; col < cols; col++)
{ {
for (int col = 0; col < cols; col++) for (int row = 0; row < rows; row++)
{ {
constructor += TString((row == col) ? "x0" : "0.0"); constructor += TString((row == col) ? "x0" : "0.0");
@ -306,13 +319,13 @@ void StructureHLSL::addConstructor(const TType &type, const TString &name, const
} }
else if (parameter.isMatrix()) else if (parameter.isMatrix())
{ {
for (int row = 0; row < rows; row++) for (int col = 0; col < cols; col++)
{ {
for (int col = 0; col < cols; col++) for (int row = 0; row < rows; row++)
{ {
if (row < parameter.getRows() && col < parameter.getCols()) if (row < parameter.getRows() && col < parameter.getCols())
{ {
constructor += TString("x0") + "[" + str(row) + "][" + str(col) + "]"; constructor += TString("x0") + "[" + str(col) + "][" + str(row) + "]";
} }
else else
{ {
@ -461,7 +474,7 @@ std::string StructureHLSL::structsHeader() const
void StructureHLSL::storeStd140ElementIndex(const TStructure &structure, bool useHLSLRowMajorPacking) void StructureHLSL::storeStd140ElementIndex(const TStructure &structure, bool useHLSLRowMajorPacking)
{ {
Std140PaddingHelper padHelper(mStd140StructElementIndexes); Std140PaddingHelper padHelper = getPaddingHelper();
const TFieldList &fields = structure.fields(); const TFieldList &fields = structure.fields();
for (unsigned int i = 0; i < fields.size(); i++) for (unsigned int i = 0; i < fields.size(); i++)

View File

@ -11,7 +11,7 @@
#define TRANSLATOR_STRUCTUREHLSL_H_ #define TRANSLATOR_STRUCTUREHLSL_H_
#include "compiler/translator/Common.h" #include "compiler/translator/Common.h"
#include "compiler/translator/intermediate.h" #include "compiler/translator/IntermNode.h"
#include <set> #include <set>
@ -26,7 +26,8 @@ namespace sh
class Std140PaddingHelper class Std140PaddingHelper
{ {
public: public:
explicit Std140PaddingHelper(const std::map<TString, int> &structElementIndexes); explicit Std140PaddingHelper(const std::map<TString, int> &structElementIndexes,
unsigned *uniqueCounter);
int elementIndex() const { return mElementIndex; } int elementIndex() const { return mElementIndex; }
int prePadding(const TType &type); int prePadding(const TType &type);
@ -34,7 +35,9 @@ class Std140PaddingHelper
TString postPaddingString(const TType &type, bool useHLSLRowMajorPacking); TString postPaddingString(const TType &type, bool useHLSLRowMajorPacking);
private: private:
int mPaddingCounter; TString next();
unsigned *mPaddingCounter;
int mElementIndex; int mElementIndex;
const std::map<TString, int> &mStructElementIndexes; const std::map<TString, int> &mStructElementIndexes;
}; };
@ -50,9 +53,11 @@ class StructureHLSL
TString defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing); TString defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing);
static TString defineNameless(const TStructure &structure); static TString defineNameless(const TStructure &structure);
Std140PaddingHelper getPaddingHelper() const { return Std140PaddingHelper(mStd140StructElementIndexes); } Std140PaddingHelper getPaddingHelper();
private: private:
unsigned mUniquePaddingCounter;
std::map<TString, int> mStd140StructElementIndexes; std::map<TString, int> mStd140StructElementIndexes;
typedef std::set<TString> StructNames; typedef std::set<TString> StructNames;

Some files were not shown because too many files have changed in this diff Show More