Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,166 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "shadercompilerManager.h"
#include "shadercompilerjob.h"
#include <QThreadPool>
#include "native/utilities/assetUtils.h"
ShaderCompilerManager::ShaderCompilerManager(QObject* parent)
: QObject(parent)
, m_isUnitTesting(false)
, m_numberOfJobsStarted(0)
, m_numberOfJobsEnded(0)
, m_numberOfErrors(0)
{
}
ShaderCompilerManager::~ShaderCompilerManager()
{
}
void ShaderCompilerManager::process(unsigned int connID, unsigned int type, unsigned int serial, QByteArray payload)
{
(void)type;
(void)serial;
Q_ASSERT(AssetUtilities::ComputeCRC32Lowercase("ShaderCompilerProxyRequest") == type);
decodeShaderCompilerRequest(connID, payload);
}
void ShaderCompilerManager::decodeShaderCompilerRequest(unsigned int connID, QByteArray payload)
{
if (payload.length() < sizeof(unsigned int) + sizeof(unsigned int) + 2 + sizeof(unsigned short))
{
QString error = "Payload size is too small";
AZ_Warning(AssetProcessor::ConsoleChannel, false, error.toUtf8().data());
emit sendErrorMessage(error);
return;
}
unsigned char* data_end = reinterpret_cast<unsigned char*>(payload.data() + payload.size());
unsigned int* requestId = reinterpret_cast<unsigned int*>(data_end - sizeof(unsigned int));
unsigned int* serverListSizePtr = reinterpret_cast<unsigned int*>(data_end - sizeof(unsigned int) - sizeof(unsigned int));
unsigned short* serverPortPtr = reinterpret_cast<unsigned short*>(data_end - sizeof(unsigned int) - sizeof(unsigned int) - sizeof(unsigned short));
ShaderCompilerRequestMessage msg;
QString error;
msg.requestId = *requestId;
msg.serverListSize = *serverListSizePtr;
msg.serverPort = *serverPortPtr;
if ((msg.serverListSize <= 0) || (msg.serverListSize > 100000))
{
error = "Shader Compiler Server List is wrong";
AZ_Warning(AssetProcessor::ConsoleChannel, false, error.toUtf8().data());
emit sendErrorMessage(error);
return;
}
if (msg.serverPort == 0)
{
error = "Shader Compiler port is wrong";
AZ_Warning(AssetProcessor::ConsoleChannel, false, error.toUtf8().data());
emit sendErrorMessage(error);
return;
}
char* position_of_first_null = reinterpret_cast<char*>(serverPortPtr) - 1;// -1 for null
if ((*position_of_first_null) != '\0')
{
error = "Shader Compiler payload is corrupt,position is not null";
AZ_Warning(AssetProcessor::ConsoleChannel, false, error.toUtf8().data());
emit sendErrorMessage(error);
return;
}
char* beginning_of_serverList = position_of_first_null - msg.serverListSize;
char* position_of_second_null = beginning_of_serverList - 1;//-1 for null
if ((*position_of_second_null) != '\0')
{
error = "Shader Compiler payload is corrupt,position is not null";
AZ_Warning(AssetProcessor::ConsoleChannel, false, error.toUtf8().data());
emit sendErrorMessage(error);
return;
}
unsigned int originalPayloadSize = static_cast<unsigned int>(payload.size()) - sizeof(unsigned int) - sizeof(unsigned int) - sizeof(unsigned short) - static_cast<unsigned int>(msg.serverListSize) - 2;
msg.serverList = beginning_of_serverList;
msg.originalPayload.insert(0, payload.data(), static_cast<unsigned int>(originalPayloadSize));
ShaderCompilerJob* shaderCompilerJob = new ShaderCompilerJob();
shaderCompilerJob->initialize(this, msg);
shaderCompilerJob->setIsUnitTesting(m_isUnitTesting);
m_shaderCompilerJobMap[msg.requestId] = connID;
shaderCompilerJob->setAutoDelete(true);
QThreadPool* threadPool = QThreadPool::globalInstance();
threadPool->start(shaderCompilerJob);
}
void ShaderCompilerManager::OnShaderCompilerJobComplete(QByteArray payload, unsigned int requestId)
{
auto iterator = m_shaderCompilerJobMap.find(requestId);
if (iterator != m_shaderCompilerJobMap.end())
{
sendResponse(iterator.value(), AssetUtilities::ComputeCRC32Lowercase("ShaderCompilerProxyResponse"), 0, payload);
}
else
{
QString error = "Shader Compiler cannot find the connection id";
AZ_Warning(AssetProcessor::ConsoleChannel, false, error.toUtf8().data());
emit sendErrorMessage(error);
}
}
void ShaderCompilerManager::sendResponse(unsigned int connId, unsigned int /*type*/, unsigned int /*serial*/, QByteArray payload)
{
EBUS_EVENT_ID(connId, AssetProcessor::ConnectionBus, SendRaw, AssetUtilities::ComputeCRC32Lowercase("ShaderCompilerProxyResponse"), 0, payload);
}
void ShaderCompilerManager::shaderCompilerError(QString errorMessage, QString server, QString timestamp, QString payload)
{
m_numberOfErrors++;
emit numberOfErrorsChanged();
emit sendErrorMessageFromShaderJob(errorMessage, server, timestamp, payload);
}
void ShaderCompilerManager::jobStarted()
{
m_numberOfJobsStarted++;
emit numberOfJobsStartedChanged();
}
void ShaderCompilerManager::jobEnded()
{
m_numberOfJobsEnded++;
numberOfJobsEndedChanged();
}
void ShaderCompilerManager::setIsUnitTesting(bool isUnitTesting)
{
m_isUnitTesting = isUnitTesting;
}
int ShaderCompilerManager::numberOfJobsStarted()
{
return m_numberOfJobsStarted;
}
int ShaderCompilerManager::numberOfJobsEnded()
{
return m_numberOfJobsEnded;
}
int ShaderCompilerManager::numberOfErrors()
{
return m_numberOfErrors;
}
@@ -0,0 +1,71 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef SHADERCOMPILERMANAGER_H
#define SHADERCOMPILERMANAGER_H
#if !defined(Q_MOC_RUN)
#include <QObject>
#include <QHash>
#include <QString>
#include <QByteArray>
#endif
typedef QHash<unsigned int, unsigned int> ShaderCompilerJobMap;
/**
* The Shader Compiler Manager class receive a shader compile request
* and starts a shader compiler job for it
*/
class ShaderCompilerManager
: public QObject
{
Q_OBJECT
Q_PROPERTY(int numberOfJobsStarted READ numberOfJobsStarted NOTIFY numberOfJobsStartedChanged)
Q_PROPERTY(int numberOfJobsEnded READ numberOfJobsEnded NOTIFY numberOfJobsEndedChanged)
Q_PROPERTY(int numberOfErrors READ numberOfErrors NOTIFY numberOfErrorsChanged)
public:
explicit ShaderCompilerManager(QObject* parent = 0);
virtual ~ShaderCompilerManager();
void process(unsigned int connID, unsigned int type, unsigned int serial, QByteArray payload);
void decodeShaderCompilerRequest(unsigned int connID, QByteArray payload);
void setIsUnitTesting(bool isUnitTesting);
int numberOfJobsStarted();
int numberOfJobsEnded();
int numberOfErrors();
virtual void sendResponse(unsigned int connId, unsigned int type, unsigned int serial, QByteArray payload);
signals:
void sendErrorMessage(QString errorMessage);
void sendErrorMessageFromShaderJob(QString errorMessage, QString server, QString timestamp, QString payload);
void numberOfJobsStartedChanged();
void numberOfJobsEndedChanged();
void numberOfErrorsChanged();
public slots:
void OnShaderCompilerJobComplete(QByteArray payload, unsigned int requestId);
void shaderCompilerError(QString errorMessage, QString server, QString timestamp, QString payload);
void jobStarted();
void jobEnded();
private:
ShaderCompilerJobMap m_shaderCompilerJobMap;
bool m_isUnitTesting;
int m_numberOfJobsStarted;
int m_numberOfJobsEnded;
int m_numberOfErrors;
};
#endif // SHADERCOMPILERMANAGER_H
@@ -0,0 +1,28 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef SHADERCOMPILERMESSAGES_H
#define SHADERCOMPILERMESSAGES_H
#include <QByteArray>
#include <QString>
struct ShaderCompilerRequestMessage
{
QByteArray originalPayload;
QString serverList;
unsigned short serverPort;
unsigned int serverListSize;
unsigned int requestId;
};
#endif //SHADERCOMPILERMESSAGES_H
@@ -0,0 +1,154 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "shadercompilerModel.h"
namespace
{
ShaderCompilerModel* s_singleton = nullptr;
}
ShaderCompilerModel::ShaderCompilerModel(QObject* parent)
: QAbstractItemModel(parent)
{
Q_ASSERT(s_singleton == nullptr);
s_singleton = this;
}
ShaderCompilerModel::~ShaderCompilerModel()
{
s_singleton = nullptr;
}
ShaderCompilerModel* ShaderCompilerModel::Get()
{
return s_singleton;
}
QVariant ShaderCompilerModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
{
return QVariant();
}
int row = index.row();
if (row < 0)
{
return QVariant();
}
if (row >= m_shaderErrorInfoList.count())
{
return QVariant();
}
switch (role)
{
case TimeStampRole:
return m_shaderErrorInfoList[row].m_shaderTimestamp;
case ServerRole:
return m_shaderErrorInfoList[row].m_shaderServerName;
case ErrorRole:
return m_shaderErrorInfoList[row].m_shaderError;
case OriginalRequestRole:
return m_shaderErrorInfoList[row].m_shaderOriginalPayload;
case Qt::DisplayRole:
switch (index.column())
{
case ColumnTimeStamp:
return m_shaderErrorInfoList[row].m_shaderTimestamp;
case ColumnServer:
return m_shaderErrorInfoList[row].m_shaderServerName;
case ColumnError:
return m_shaderErrorInfoList[row].m_shaderServerName;
}
}
return QVariant();
}
Qt::ItemFlags ShaderCompilerModel::flags(const QModelIndex& index) const
{
(void)index;
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
int ShaderCompilerModel::rowCount(const QModelIndex& parent) const
{
(void)parent;
return m_shaderErrorInfoList.count();
}
QModelIndex ShaderCompilerModel::parent(const QModelIndex&) const
{
return QModelIndex();
}
QModelIndex ShaderCompilerModel::index(int row, int column, const QModelIndex& parent) const
{
if (row >= rowCount(parent) || column >= columnCount(parent))
{
return QModelIndex();
}
return createIndex(row, column);
}
int ShaderCompilerModel::columnCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : Column::Max;
}
QVariant ShaderCompilerModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
switch (section)
{
case ColumnTimeStamp:
return tr("Time Stamp");
case ColumnServer:
return tr("Server");
case ColumnError:
return tr("Error");
default:
break;
}
}
return QAbstractItemModel::headerData(section, orientation, role);
}
QHash<int, QByteArray> ShaderCompilerModel::roleNames() const
{
QHash<int, QByteArray> result;
result[TimeStampRole] = "timestamp";
result[ServerRole] = "server";
result[ErrorRole] = "error";
result[OriginalRequestRole] = "originalRequest";
return result;
}
void ShaderCompilerModel::addShaderErrorInfoEntry(QString errorMessage, QString timestamp, QString payload, QString server)
{
ShaderCompilerErrorInfo shaderCompileErrorInfo(errorMessage, timestamp, payload, server);
beginInsertRows(QModelIndex(), m_shaderErrorInfoList.size(), m_shaderErrorInfoList.size());
m_shaderErrorInfoList.append(shaderCompileErrorInfo);
endInsertRows();
}
@@ -0,0 +1,97 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef SHADERCOMPILERMODEL_H
#define SHADERCOMPILERMODEL_H
#if !defined(Q_MOC_RUN)
#include <QAbstractItemModel>
#include <QList>
#include <QVariant>
#include <QHash>
#include <QByteArray>
#include <QString>
#endif
class QModelIndex;
class QObject;
struct ShaderCompilerErrorInfo
{
QString m_shaderError;
QString m_shaderTimestamp;
QString m_shaderOriginalPayload;
QString m_shaderServerName;
ShaderCompilerErrorInfo(QString shaderError, QString shaderTimestamp, QString shaderOriginalPayload, QString shaderServerName)
: m_shaderError(shaderError)
, m_shaderTimestamp(shaderTimestamp)
, m_shaderOriginalPayload(shaderOriginalPayload)
, m_shaderServerName(shaderServerName)
{
}
};
/** The Shader Compiler model is responsible for capturing error requests
*/
class ShaderCompilerModel
: public QAbstractItemModel
{
Q_OBJECT
public:
enum DataRoles
{
TimeStampRole = Qt::UserRole + 1,
ServerRole,
ErrorRole,
OriginalRequestRole,
};
enum Column
{
ColumnTimeStamp,
ColumnServer,
ColumnError,
Max
};
/// standard Qt constructor
explicit ShaderCompilerModel(QObject* parent = 0);
virtual ~ShaderCompilerModel();
// singleton pattern
static ShaderCompilerModel* Get();
/// QAbstractListModel interface
QModelIndex parent(const QModelIndex&) const override;
QModelIndex index(int row, int column, const QModelIndex& parent) const override;
int columnCount(const QModelIndex&) const override;
virtual int rowCount(const QModelIndex& parent) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
virtual QVariant data(const QModelIndex& index, int role) const override;
virtual QHash<int, QByteArray> roleNames() const override;
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
public slots:
void addShaderErrorInfoEntry(QString errorMessage, QString timestamp, QString payload, QString server);
private:
QList<ShaderCompilerErrorInfo> m_shaderErrorInfoList;
};
#endif // SHADERCOMPILERMODEL_H
@@ -0,0 +1,198 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "shadercompilerjob.h"
#include "native/assetprocessor.h"
#include <QTcpSocket>
ShaderCompilerJob::ShaderCompilerJob()
: m_isUnitTesting(false)
, m_manager(nullptr)
{
}
ShaderCompilerJob::~ShaderCompilerJob()
{
m_manager = nullptr;
}
ShaderCompilerRequestMessage ShaderCompilerJob::ShaderCompilerMessage() const
{
return m_ShaderCompilerMessage;
}
void ShaderCompilerJob::initialize(QObject* pManager, const ShaderCompilerRequestMessage& ShaderCompilerMessage)
{
m_manager = pManager;
m_ShaderCompilerMessage = ShaderCompilerMessage;
}
QString ShaderCompilerJob::getServerAddress()
{
if (isServerListEmpty())
{
return QString();
}
QString serverAddress;
if (!m_ShaderCompilerMessage.serverList.contains(","))
{
serverAddress = m_ShaderCompilerMessage.serverList;
m_ShaderCompilerMessage.serverList.clear();
return serverAddress;
}
QStringList serverList = m_ShaderCompilerMessage.serverList.split(",");
serverAddress = serverList.takeAt(0);
m_ShaderCompilerMessage.serverList = serverList.join(",");
return serverAddress;
}
bool ShaderCompilerJob::isServerListEmpty()
{
return m_ShaderCompilerMessage.serverList.isEmpty();
}
bool ShaderCompilerJob::attemptDelivery(QString serverAddress, QByteArray& payload)
{
QTcpSocket socket;
QString error;
int waitingTime = 8000; // 8 sec timeout for sending.
int jobCompileMaxTime = 1000 * 60; // 60 sec timeout for compilation
if (m_isUnitTesting)
{
waitingTime = 500;
jobCompileMaxTime = 500;
}
socket.connectToHost(serverAddress, m_ShaderCompilerMessage.serverPort, QIODevice::ReadWrite);
if (socket.waitForConnected(waitingTime))
{
qint64 bytesWritten = 0;
qint64 payloadSize = static_cast<qint64>(m_ShaderCompilerMessage.originalPayload.size());
// send payload size to server
while (bytesWritten != sizeof(qint64))
{
qint64 currentWrite = socket.write(reinterpret_cast<char*>(&payloadSize) + bytesWritten,
sizeof(qint64) - bytesWritten);
if (currentWrite == -1)
{
//It is important to note that we are only outputting the error to debugchannel only here because
//we are forwarding these error messages upstream to the manager,who will take the appropriate action
error = "Connection Lost:Unable to send data";
AZ_TracePrintf(AssetProcessor::DebugChannel, error.toUtf8().data());
QMetaObject::invokeMethod(m_manager, "shaderCompilerError", Qt::QueuedConnection, Q_ARG(QString, error), Q_ARG(QString, QDateTime::currentDateTime().toString()), Q_ARG(QString, QString(m_ShaderCompilerMessage.originalPayload)), Q_ARG(QString, serverAddress));
return false;
}
socket.flush();
bytesWritten += currentWrite;
}
bytesWritten = 0;
//send actual payload to server
while (bytesWritten != m_ShaderCompilerMessage.originalPayload.size())
{
qint64 currentWrite = socket.write(m_ShaderCompilerMessage.originalPayload.data() + bytesWritten,
m_ShaderCompilerMessage.originalPayload.size() - bytesWritten);
if (currentWrite == -1)
{
error = "Connection Lost:Unable to send data";
AZ_TracePrintf(AssetProcessor::DebugChannel, error.toUtf8().data());
QMetaObject::invokeMethod(m_manager, "shaderCompilerError", Qt::QueuedConnection, Q_ARG(QString, error), Q_ARG(QString, QDateTime::currentDateTime().toString()), Q_ARG(QString, QString(m_ShaderCompilerMessage.originalPayload)), Q_ARG(QString, serverAddress));
}
socket.flush();
bytesWritten += currentWrite;
}
}
else
{
error = "Unable to connect to IP Address " + serverAddress;
AZ_TracePrintf(AssetProcessor::DebugChannel, error.toUtf8().data());
QMetaObject::invokeMethod(m_manager, "shaderCompilerError", Qt::QueuedConnection, Q_ARG(QString, error), Q_ARG(QString, QDateTime::currentDateTime().toString()), Q_ARG(QString, QString(m_ShaderCompilerMessage.originalPayload)), Q_ARG(QString, serverAddress));
return false;
}
unsigned int expectedBytes = sizeof(unsigned int) + sizeof(qint8);
unsigned int bytesReadTotal = 0;
unsigned int messageSize = 0;
bool isMessageSizeKnown = false;
//read the entire payload
while ((bytesReadTotal < expectedBytes + messageSize))
{
if (socket.bytesAvailable() == 0)
{
if (!socket.waitForReadyRead(jobCompileMaxTime))
{
error = "Remote IP is taking too long to respond: " + serverAddress;
AZ_TracePrintf(AssetProcessor::DebugChannel, error.toUtf8().data());
QMetaObject::invokeMethod(m_manager, "shaderCompilerError", Qt::QueuedConnection, Q_ARG(QString, error), Q_ARG(QString, QDateTime::currentDateTime().toString()), Q_ARG(QString, QString(m_ShaderCompilerMessage.originalPayload)), Q_ARG(QString, serverAddress));
payload.clear();
return false;
}
}
qint64 bytesAvailable = socket.bytesAvailable();
if (bytesAvailable >= expectedBytes && !isMessageSizeKnown)
{
socket.peek(reinterpret_cast<char*>(&messageSize), sizeof(unsigned int));
payload.resize(expectedBytes + messageSize);
isMessageSizeKnown = true;
}
if (bytesAvailable > 0)
{
qint64 bytesRead = socket.read(payload.data() + bytesReadTotal, bytesAvailable);
if (bytesRead <= 0)
{
error = "Connection closed by remote IP Address " + serverAddress;
AZ_TracePrintf(AssetProcessor::DebugChannel, error.toUtf8().data());
QMetaObject::invokeMethod(m_manager, "shaderCompilerError", Qt::QueuedConnection, Q_ARG(QString, error), Q_ARG(QString, QDateTime::currentDateTime().toString()), Q_ARG(QString, QString(m_ShaderCompilerMessage.originalPayload)), Q_ARG(QString, serverAddress));
payload.clear();
return false;
}
bytesReadTotal = aznumeric_cast<uint32_t>(bytesReadTotal + bytesRead);
}
}
return true; // payload successfully send
}
void ShaderCompilerJob::run()
{
QMetaObject::invokeMethod(m_manager, "jobStarted", Qt::QueuedConnection);
QByteArray payload;
//until server list is empty, keep trying
while (!isServerListEmpty())
{
QString serverAddress = getServerAddress();
//attempt to send payload
if (attemptDelivery(serverAddress, payload))
{
break;
}
}
//we are appending request id at the end of every payload,
//therefore in the case of any errors also
//we will be sending atleast four bytes to the game
payload.append(reinterpret_cast<char*>(&m_ShaderCompilerMessage.requestId), sizeof(unsigned int));
QMetaObject::invokeMethod(m_manager, "OnShaderCompilerJobComplete", Qt::QueuedConnection, Q_ARG(QByteArray, payload), Q_ARG(unsigned int, m_ShaderCompilerMessage.requestId));
QMetaObject::invokeMethod(m_manager, "jobEnded", Qt::QueuedConnection);
}
void ShaderCompilerJob::setIsUnitTesting(bool isUnitTesting)
{
m_isUnitTesting = isUnitTesting;
}
@@ -0,0 +1,48 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifndef SHADERCOMPILERJOB_H
#define SHADERCOMPILERJOB_H
#include <QRunnable>
#include "shadercompilerMessages.h"
class QByteArray;
class QObject;
/**
* This class is responsible for connecting to the shader compiler server
* and getting back the response to the shader compiler manager
*/
class ShaderCompilerJob
: public QRunnable
{
public:
explicit ShaderCompilerJob();
virtual ~ShaderCompilerJob();
ShaderCompilerRequestMessage ShaderCompilerMessage() const;
void initialize(QObject* pManager, const ShaderCompilerRequestMessage& ShaderCompilerMessage);
QString getServerAddress();
bool isServerListEmpty();
virtual void run() override;
void setIsUnitTesting(bool isUnitTesting);
bool attemptDelivery(QString serverAddress, QByteArray& payload);
private:
ShaderCompilerRequestMessage m_ShaderCompilerMessage;
QObject* m_manager;
bool m_isUnitTesting;
};
#endif // SHADERCOMPILERJOB_H