summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPasi Keränen <pasi.keranen@qt.io>2019-04-26 11:39:47 +0300
committerPasi Keränen <pasi.keranen@qt.io>2019-05-03 14:12:35 +0000
commit7e724a2645f3b9448a41c11d9f1c3dcce32bfba6 (patch)
tree71c321faf3b72fd97b4e8554638570443be19404
parent73ebd0f9cf6376a762c96d37ab6046fefd8d4789 (diff)
Convert CRenderString to be QString based
Replaces QString as the implementation class of CRenderString instead of std::basic_string Task-number: QT3DS-3370 Change-Id: Ie1b9068bfdbf0ce05659f1ae83fe9243acdf7eee Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Runtime/Source/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp5
-rw-r--r--src/Runtime/Source/foundation/StringTable.cpp50
-rw-r--r--src/Runtime/Source/foundation/StringTable.h9
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp13
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp55
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.h2
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderShaderCache.cpp29
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGenerator.cpp2
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp41
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h8
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderString.h598
-rw-r--r--src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp45
-rw-r--r--src/Runtime/Source/runtimerender/rendererimpl/Qt3DSVertexPipelineImpl.h28
13 files changed, 761 insertions, 124 deletions
diff --git a/src/Runtime/Source/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp b/src/Runtime/Source/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp
index 8b54e5d5..40b3ab02 100644
--- a/src/Runtime/Source/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp
+++ b/src/Runtime/Source/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp
@@ -1241,9 +1241,10 @@ struct SDynamicObjectTranslatorContext : public STranslatorContext
const char *inExtension, Q3DStudio::EAttributeType inType,
CRenderString &ioStringBuilder, QT3DSU32 inOffset, QT3DSU32 dataOffset)
{
- ioStringBuilder.assign(thePropDef.m_Name.c_str());
+ ioStringBuilder.fromUtf8(thePropDef.m_Name.c_str());
ioStringBuilder.append(inExtension);
- Q3DStudio::INT32 theHash = Q3DStudio::CHash::HashAttribute(ioStringBuilder.c_str());
+ Q3DStudio::INT32 theHash = Q3DStudio::CHash::HashAttribute(
+ ioStringBuilder.toUtf8().constData());
m_PropertyHashes.insert(
eastl::make_pair(theHash, SEffectPropertyEntry(inType, inOffset, dataOffset)));
}
diff --git a/src/Runtime/Source/foundation/StringTable.cpp b/src/Runtime/Source/foundation/StringTable.cpp
index 9e78cfd3..47130dca 100644
--- a/src/Runtime/Source/foundation/StringTable.cpp
+++ b/src/Runtime/Source/foundation/StringTable.cpp
@@ -54,7 +54,7 @@ struct SCharAndHash
{
}
SCharAndHash()
- : m_Data(NULL)
+ : m_Data(nullptr)
, m_Hash(0)
{
}
@@ -90,7 +90,7 @@ void CRegisteredString::Remap(const SStrRemapMap &inMap)
else {
QT3DS_ASSERT(false);
// Ensure a failure here doesn't *guarantee* a crash somewhere else.
- m_String = NULL;
+ m_String = nullptr;
}
} else {
// Indicates an invalid string.
@@ -123,7 +123,7 @@ typedef eastl::basic_string<TWCharEASTLConverter::TCharType, ForwardingAllocator
inline bool isTrivialWide(const wchar_t *str)
{
- return str == NULL || *str == 0;
+ return str == nullptr || *str == 0;
}
QT3DSU8 *AlignPointer(QT3DSU8 *inStart, QT3DSU8 *inPtr)
@@ -165,13 +165,13 @@ struct SStringFileData
: m_StartOffset(0)
, m_StrLen(0)
, m_Handle(0)
- , m_Str(NULL)
+ , m_Str(nullptr)
{
}
void Deallocate(NVAllocatorCallback &inAlloc)
{
inAlloc.deallocate(m_Str);
- m_Str = NULL;
+ m_Str = nullptr;
}
const char8_t *GetNarrow() { return m_Str; }
operator CRegisteredString() const
@@ -192,7 +192,7 @@ struct SCharAndHandle
const char8_t *m_Data;
QT3DSU32 m_Handle;
SCharAndHandle()
- : m_Data(NULL)
+ : m_Data(nullptr)
, m_Handle(0)
{
}
@@ -445,7 +445,7 @@ protected:
if (iter != m_HandleDataBlockOffset.end() && iter->first == handle
&& m_DataBlock[iter->second].m_Handle == handle)
return m_DataBlock[iter->second].m_Str;
- return NULL;
+ return nullptr;
}
void WriteStringBlockData(const SStringFileData *begin, const SStringFileData *end,
@@ -550,17 +550,45 @@ public:
, m_ConvertBuffer(ForwardingAllocator(alloc, "StringTable::m_ConvertBuffer"))
, m_WideConvertBuffer(ForwardingAllocator(alloc, "StringTable::m_WideConvertBuffer"))
, m_MultithreadMutexBacker(alloc)
- , m_MultithreadMutex(NULL)
+ , m_MultithreadMutex(nullptr)
{
}
- virtual ~StringTable() {}
+ virtual ~StringTable() override {}
QT3DS_IMPLEMENT_REF_COUNT_ADDREF_RELEASE_OVERRIDE(m_FileData.m_Allocator.m_Allocator)
- void EnableMultithreadedAccess() override { m_MultithreadMutex = &m_MultithreadMutexBacker; }
+ void EnableMultithreadedAccess() override
+ {
+ m_MultithreadMutex = &m_MultithreadMutexBacker;
+ }
+
+ void DisableMultithreadedAccess() override
+ {
+ m_MultithreadMutex = nullptr;
+ }
+
+ CRegisteredString RegisterStr(const QString &str) override
+ {
+ STRING_TABLE_MULTITHREADED_METHOD;
+ if (str.isEmpty())
+ return CRegisteredString();
+ return RegisterStr(str.toUtf8());
+ }
- void DisableMultithreadedAccess() override { m_MultithreadMutex = NULL; }
+ CRegisteredString RegisterStr(const QByteArray &str) override
+ {
+ STRING_TABLE_MULTITHREADED_METHOD;
+ if (str.isEmpty())
+ return CRegisteredString();
+ return RegisterStr(str.constData());
+ }
+
+ CRegisteredString RegisterStr(const eastl::string &string) override
+ {
+ STRING_TABLE_MULTITHREADED_METHOD;
+ return RegisterStr(string.c_str());
+ }
CRegisteredString RegisterStr(Qt3DSBCharPtr str) override
{
diff --git a/src/Runtime/Source/foundation/StringTable.h b/src/Runtime/Source/foundation/StringTable.h
index 79529467..c7c62199 100644
--- a/src/Runtime/Source/foundation/StringTable.h
+++ b/src/Runtime/Source/foundation/StringTable.h
@@ -37,8 +37,13 @@
#define WIDE_IS_DIFFERENT_TYPE_THAN_CHAR16_T
#endif
#endif
+
+#include <QtCore/qstring.h>
+#include <QtCore/qbytearray.h>
+
#include "foundation/Qt3DSRefCounted.h"
#include "foundation/Qt3DSAllocator.h"
+#include "EASTL/string.h"
#include "EASTL/functional.h"
#include "EABase/eabase.h" //char16_t definition
#include "foundation/Qt3DSDataRef.h"
@@ -221,6 +226,10 @@ namespace foundation {
virtual void EnableMultithreadedAccess() = 0;
virtual void DisableMultithreadedAccess() = 0;
+ virtual CRegisteredString RegisterStr(const QByteArray &str) = 0;
+ virtual CRegisteredString RegisterStr(const QString &str) = 0;
+ virtual CRegisteredString RegisterStr(const eastl::string &string) = 0;
+
virtual CRegisteredString RegisterStr(Qt3DSBCharPtr str) = 0;
// utf-16->utf-8
virtual CRegisteredString RegisterStr(const char16_t *str) = 0;
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp b/src/Runtime/Source/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp
index 065a8383..9a993705 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderCustomMaterialShaderGenerator.cpp
@@ -388,7 +388,7 @@ struct SShaderGenerator : public ICustomMaterialShaderGenerator
{
// convert to NVRenderTextureTypeValue
NVRenderTextureTypeValue::Enum texType = (NVRenderTextureTypeValue::Enum)imageIdx;
- m_ImageStem = NVRenderTextureTypeValue::toString(texType);
+ m_ImageStem.assign(NVRenderTextureTypeValue::toString(texType));
m_ImageStem.append("_");
m_ImageSampler = m_ImageStem;
m_ImageSampler.append("sampler");
@@ -494,11 +494,10 @@ struct SShaderGenerator : public ICustomMaterialShaderGenerator
qt3ds::render::IDynamicObjectSystem &theDynamicSystem(
m_RenderContext.GetDynamicObjectSystem());
CRenderString theShaderBuffer;
- const char8_t *vertSource = theDynamicSystem.GetShaderSource(
+ theDynamicSystem.GetShaderSource(
m_RenderContext.GetStringTable().RegisterStr(inShaderPathName), theShaderBuffer);
- QT3DS_ASSERT(vertSource);
- eastl::string srcString(vertSource);
+ eastl::string srcString(theShaderBuffer.c_str());
// Check if the vertex shader portion already contains a main function
// The same string contains both the vertex and the fragment shader
@@ -1029,10 +1028,10 @@ struct SShaderGenerator : public ICustomMaterialShaderGenerator
qt3ds::render::IDynamicObjectSystem &theDynamicSystem(
m_RenderContext.GetDynamicObjectSystem());
CRenderString theShaderBuffer;
- const char8_t *fragSource = theDynamicSystem.GetShaderSource(
+ theDynamicSystem.GetShaderSource(
m_RenderContext.GetStringTable().RegisterStr(inShaderPathName), theShaderBuffer);
- QT3DS_ASSERT(fragSource);
+ QT3DS_ASSERT(theShaderBuffer.size() > 0);
// light maps
bool hasLightmaps = false;
@@ -1062,7 +1061,7 @@ struct SShaderGenerator : public ICustomMaterialShaderGenerator
IDefaultMaterialVertexPipeline &vertexShader(VertexGenerator());
IShaderStageGenerator &fragmentShader(FragmentGenerator());
- eastl::string srcString(fragSource);
+ eastl::string srcString(theShaderBuffer.c_str());
if (m_RenderContext.GetRenderContext().GetRenderContextType()
== NVRenderContextValues::GLES2) {
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp b/src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
index 00de6c3d..4970f3e3 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.cpp
@@ -942,11 +942,12 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
const char8_t *inPathToEffect)
{
// Now do search and replace for the headers
- for (CRenderString::size_type thePos = theReadBuffer.find(m_IncludeSearch);
+ for (CRenderString::size_type thePos = theReadBuffer.indexOf(m_IncludeSearch);
thePos != CRenderString::npos;
- thePos = theReadBuffer.find(m_IncludeSearch, thePos + 1)) {
+ thePos = theReadBuffer.indexOf(m_IncludeSearch, thePos + 1)) {
CRenderString::size_type theEndQuote =
- theReadBuffer.find('\"', thePos + m_IncludeSearch.size() + 1);
+ theReadBuffer.indexOf(QLatin1Char('\"'), thePos + m_IncludeSearch.size() + 1);
+
// Indicates an unterminated include file.
if (theEndQuote == CRenderString::npos) {
qCCritical(INVALID_OPERATION, "Unterminated include in file: %s", inPathToEffect);
@@ -960,21 +961,20 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
m_IncludePath.append(theIncludeBegin, theIncludeEnd);
// If we haven't included the file yet this round
CRenderString theIncludeBuffer;
- const char8_t *theHeader = DoLoadShader(m_IncludePath.c_str(), theIncludeBuffer);
- QT3DSU32 theLen = (QT3DSU32)strlen(theHeader);
+ DoLoadShader(m_IncludePath.c_str(), theIncludeBuffer);
theReadBuffer =
theReadBuffer.replace(theReadBuffer.begin() + thePos,
- theReadBuffer.begin() + theEndQuote + 1, theHeader, theLen);
+ theReadBuffer.begin() + theEndQuote + 1,
+ theIncludeBuffer);
}
}
- const char8_t *DoLoadShader(const char8_t *inPathToEffect, CRenderString &outShaderData)
+ void DoLoadShader(const char8_t *inPathToEffect, CRenderString &outShaderData)
{
eastl::pair<TPathDataMap::iterator, bool> theInsert =
m_ExpandedFiles.insert(eastl::make_pair(
m_CoreContext.GetStringTable().RegisterStr(inPathToEffect), (char8_t *)""));
- CRenderString &theReadBuffer(outShaderData);
if (theInsert.second) {
const QString defaultDir = m_Context->GetDynamicObjectSystem()
@@ -996,13 +996,13 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
QTextStream stream(&fullPath);
stream << defaultDir << QLatin1Char('/') << inPathToEffect;
theStream = m_CoreContext.GetInputStreamFactory()
- .GetStreamForFile(fullPath.toLatin1().data());
+ .GetStreamForFile(fullPath);
if (theStream.mPtr == NULL) {
fullPath.clear();
QTextStream stream(&fullPath);
stream << defaultDir << QLatin1Char('/') << inPathToEffect;
theStream = m_CoreContext.GetInputStreamFactory()
- .GetStreamForFile(fullPath.toLatin1().data());
+ .GetStreamForFile(fullPath);
}
}
if (theStream.mPtr != NULL) {
@@ -1011,20 +1011,21 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
do {
amountRead = theStream->Read(NVDataRef<QT3DSU8>(readBuf, 1024));
if (amountRead)
- theReadBuffer.append((const char8_t *)readBuf, amountRead);
+ outShaderData.append((const char8_t *)readBuf, amountRead);
} while (amountRead);
} else {
qCCritical(INVALID_OPERATION, "Failed to find include file %s", inPathToEffect);
QT3DS_ASSERT(false);
}
theInsert.first->second = (char8_t *)m_Allocator.allocate(
- theReadBuffer.size() + 1, "SDynamicObjectSystem::DoLoadShader", __FILE__, __LINE__);
- memCopy(theInsert.first->second, theReadBuffer.c_str(),
- QT3DSU32(theReadBuffer.size()) + 1);
- } else
- theReadBuffer.assign(theInsert.first->second);
- DoInsertShaderHeaderInformation(theReadBuffer, inPathToEffect);
- return theReadBuffer.c_str();
+ outShaderData.size() + 1, "SDynamicObjectSystem::DoLoadShader", __FILE__, __LINE__);
+ memCopy(theInsert.first->second, outShaderData.c_str(),
+ QT3DSU32(outShaderData.size()) + 1);
+ } else {
+ outShaderData.assign(theInsert.first->second);
+ }
+
+ DoInsertShaderHeaderInformation(outShaderData, inPathToEffect);
}
void Save(qt3ds::render::SWriteBuffer &ioBuffer,
@@ -1392,13 +1393,13 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
}
// This just returns the custom material shader source without compiling
- const char8_t *GetShaderSource(CRegisteredString inPath, CRenderString &inBuffer) override
+ void GetShaderSource(CRegisteredString inPath, CRenderString &outBuffer) override
{
- inBuffer.clear();
- inBuffer.append("#define FRAGMENT_SHADER\n");
+ outBuffer.clear();
+ outBuffer.append("#define FRAGMENT_SHADER\n");
- const char8_t *source = DoLoadShader(inPath, inBuffer);
- return source;
+ CRenderString source;
+ DoLoadShader(inPath, outBuffer);
}
TShaderAndFlags GetShaderProgram(CRegisteredString inPath,
@@ -1422,10 +1423,10 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
.first->second;
if (theShaderInfo.m_IsComputeShader == false) {
CRenderString theShaderBuffer;
- const char8_t *programSource = DoLoadShader(inPath, theShaderBuffer);
+ DoLoadShader(inPath, theShaderBuffer);
if (theShaderInfo.m_HasGeomShader)
theFlags.SetGeometryShaderEnabled(true);
- theProgram = CompileShader(inPath, programSource, NULL, inProgramMacro,
+ theProgram = CompileShader(inPath, theShaderBuffer.c_str(), NULL, inProgramMacro,
inFeatureSet, theFlags, inForceCompilation);
} else {
CRenderString theShaderBuffer;
@@ -1477,7 +1478,7 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
SDynamicShaderProgramFlags flags(theFlags);
if (!theProgram) {
CRenderString theShaderBuffer;
- const char8_t *geomSource = DoLoadShader(inPath, theShaderBuffer);
+ DoLoadShader(inPath, theShaderBuffer);
SShaderVertexCodeGenerator vertexShader(
m_Context->GetStringTable(), m_Allocator,
m_Context->GetRenderContext().GetRenderContextType());
@@ -1504,7 +1505,7 @@ struct SDynamicObjectSystemImpl : public IDynamicObjectSystem
programBuffer.append(fragmentSource);
programBuffer.append("\n#endif");
flags.SetGeometryShaderEnabled(true);
- theProgram = CompileShader(inPath, programBuffer.c_str(), geomSource,
+ theProgram = CompileShader(inPath, programBuffer.c_str(), theShaderBuffer.c_str(),
theProgramMacro, inFeatureSet, flags);
}
theInsertResult.first->second = TShaderAndFlags(theProgram, flags);
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.h b/src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.h
index b149efc8..b58385d4 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.h
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderDynamicObjectSystem.h
@@ -267,7 +267,7 @@ namespace render {
const dynamic::SDynamicShaderProgramFlags &inFlags,
bool inForceCompilation = false) = 0;
- virtual const char8_t *GetShaderSource(CRegisteredString inPath, CRenderString &source) = 0;
+ virtual void GetShaderSource(CRegisteredString inPath, CRenderString &outSource) = 0;
// Will return null in the case where a custom prepass shader isn't needed for this object
// If no geom shader, then no depth prepass shader.
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCache.cpp b/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCache.cpp
index 0c7c4997..a5af8bb9 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCache.cpp
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCache.cpp
@@ -56,7 +56,7 @@ const char *GeometryEnabledStr = "GeometryStageEnabled";
inline void AppendFlagValue(CRenderString &inStr, const char *flag)
{
if (inStr.length())
- inStr.append(1, ',');
+ inStr.append(QLatin1Char(','));
inStr.append(flag);
}
inline void CacheFlagsToStr(const SShaderCacheProgramFlags &inFlags, CRenderString &inString)
@@ -99,9 +99,9 @@ inline ShaderType::Enum StringToShaderType(CRenderString &inShaderType)
inline SShaderCacheProgramFlags CacheFlagsToStr(const CRenderString &inString)
{
SShaderCacheProgramFlags retval;
- if (inString.find(TessellationEnabledStr) != CRenderString::npos)
+ if (inString.indexOf(TessellationEnabledStr) != CRenderString::npos)
retval.SetTessellationEnabled(true);
- if (inString.find(GeometryEnabledStr) != CRenderString::npos)
+ if (inString.indexOf(GeometryEnabledStr) != CRenderString::npos)
retval.SetGeometryShaderEnabled(true);
return retval;
}
@@ -134,7 +134,7 @@ inline void ContextTypeToString(qt3ds::render::NVRenderContextType inType,
for (size_t idx = 0, end = g_NumStringToContextValueEntries; idx < end; ++idx) {
if (inType & g_StringToContextTypeValue[idx].second) {
if (outContextType.size())
- outContextType.append(1, '|');
+ outContextType.append('|');
outContextType.append(g_StringToContextTypeValue[idx].first);
}
}
@@ -145,19 +145,20 @@ inline qt3ds::render::NVRenderContextType StringToContextType(const CRenderStrin
qt3ds::render::NVRenderContextType retval;
char tempBuffer[128];
memZero(tempBuffer, 128);
- const eastl::string::size_type lastTempBufIdx = 127;
- eastl::string::size_type pos = 0, lastpos = 0;
+ const QString::size_type lastTempBufIdx = 127;
+ QString::size_type pos = 0, lastpos = 0;
if (inContextType.size() == 0)
return retval;
do {
- pos = int(inContextType.find('|', lastpos));
- if (pos == eastl::string::npos)
+ pos = int(inContextType.indexOf(QLatin1Char('|'), lastpos));
+ if (pos == CRenderString::npos)
pos = int(inContextType.size());
{
- eastl::string::size_type sectionLen = NVMin(pos - lastpos, lastTempBufIdx);
- qt3ds::intrinsics::memCopy(tempBuffer, inContextType.c_str() + lastpos, sectionLen);
+ QString::size_type sectionLen = NVMin(pos - lastpos, lastTempBufIdx);
+ qt3ds::intrinsics::memCopy(tempBuffer, inContextType.toUtf8().constData() + lastpos,
+ sectionLen);
tempBuffer[lastTempBufIdx] = 0;
for (size_t idx = 0, end = g_NumStringToContextValueEntries; idx < end; ++idx) {
if (strcmp(g_StringToContextTypeValue[idx].first, tempBuffer) == 0)
@@ -167,7 +168,7 @@ inline qt3ds::render::NVRenderContextType StringToContextType(const CRenderStrin
// iterate past the bar
++pos;
lastpos = pos;
- } while (pos < inContextType.size() && pos != eastl::string::npos);
+ } while (pos < inContextType.size() && pos != CRenderString::npos);
return retval;
}
@@ -492,9 +493,9 @@ struct ShaderCache : public IShaderCache
m_FragmentCode.assign(inFrag);
// Add defines and such so we can write unified shaders that work across platforms.
// vertex and fragment shaders are optional for separable shaders
- if (!separableProgram || !m_VertexCode.empty())
+ if (!separableProgram || !m_VertexCode.isEmpty())
AddShaderPreprocessor(m_VertexCode, inKey, ShaderType::Vertex, inFeatures);
- if (!separableProgram || !m_FragmentCode.empty())
+ if (!separableProgram || !m_FragmentCode.isEmpty())
AddShaderPreprocessor(m_FragmentCode, inKey, ShaderType::Fragment, inFeatures);
// optional shaders
if (inFlags.IsTessellationEnabled()) {
@@ -602,7 +603,7 @@ struct ShaderCache : public IShaderCache
return;
}
BootupDOMWriter();
- m_CacheFilePath = QDir(inDirectory).filePath(GetShaderCacheFileName()).toStdString();
+ m_CacheFilePath = QDir(inDirectory).filePath(GetShaderCacheFileName());
NVScopedRefCounted<IRefCountedInputStream> theInStream =
m_InputStreamFactory.GetStreamForFile(m_CacheFilePath.c_str());
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGenerator.cpp b/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGenerator.cpp
index 1cc9e9c7..d84c37de 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGenerator.cpp
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGenerator.cpp
@@ -301,7 +301,7 @@ const char *SShaderCodeGeneratorBase::BuildShaderSource()
AddShaderConstantBufferItemMap("uniform", m_ConstantBuffers, m_ConstantBufferParams);
AddShaderItemMap("varying", GetVaryings());
m_FinalShaderBuilder.append("\n");
- m_FinalShaderBuilder.append(m_CodeBuilder);
+ m_FinalShaderBuilder.append(m_CodeBuilder.c_str());
return m_FinalShaderBuilder.c_str();
}
SShaderCodeGeneratorBase &SShaderCodeGeneratorBase::operator<<(const char *data)
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp b/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp
index 173ba431..3aa03eae 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.cpp
@@ -94,6 +94,7 @@ struct SStageGeneratorBase : public IShaderStageGenerator
{
m_Incoming.insert(eastl::make_pair(Str(name), Str(type)));
}
+
virtual const char8_t *GetIncomingVariableName()
{
return "in";
@@ -103,6 +104,12 @@ struct SStageGeneratorBase : public IShaderStageGenerator
{
AddIncoming(name.c_str(), type);
}
+
+ void AddIncoming(const QString &name, const char8_t *type) override
+ {
+ AddIncoming(name.toUtf8().constData(), type);
+ }
+
void AddOutgoing(const char8_t *name, const char8_t *type) override
{
if (m_Outgoing == NULL) {
@@ -111,25 +118,44 @@ struct SStageGeneratorBase : public IShaderStageGenerator
}
m_Outgoing->insert(eastl::make_pair(Str(name), Str(type)));
}
+
void AddOutgoing(const TStrType &name, const char8_t *type) override
{
AddOutgoing(name.c_str(), type);
}
+ void AddOutgoing(const QString &name, const char8_t *type) override
+ {
+ AddOutgoing(name.toUtf8().constData(), type);
+ }
+
void AddUniform(const char8_t *name, const char8_t *type) override
{
m_Uniforms.insert(eastl::make_pair(Str(name), Str(type)));
}
+
void AddUniform(const TStrType &name, const char8_t *type) override
{
AddUniform(name.c_str(), type);
}
+ void AddUniform(const QString &name, const char8_t *type) override
+ {
+ AddUniform(name.toUtf8().constData(), type);
+ }
+
void AddConstantBuffer(const char *name, const char *layout) override
{
m_ConstantBuffers.insert(eastl::make_pair(Str(name), Str(layout)));
}
- void AddConstantBufferParam(const char *cbName, const char *paramName, const char *type) override
+
+ void AddConstantBuffer(const QString &name, const char *layout) override
+ {
+ AddConstantBuffer(name.toUtf8().constData(), layout);
+ }
+
+ void AddConstantBufferParam(const char *cbName, const char *paramName,
+ const char *type) override
{
TParamPair theParamPair(m_StringTable.RegisterStr(paramName),
m_StringTable.RegisterStr(type));
@@ -138,13 +164,26 @@ struct SStageGeneratorBase : public IShaderStageGenerator
m_ConstantBufferParams.push_back(theBufferParamPair);
}
+ void AddConstantBufferParam(const QString &cbName, const QString &paramName,
+ const char *type) override
+ {
+ AddConstantBufferParam(cbName.toUtf8().constData(), paramName.toUtf8().constData(), type);
+ }
+
IShaderStageGenerator &operator<<(const char *data) override
{
m_CodeBuilder.append(nonNull(data));
return *this;
}
+
IShaderStageGenerator &operator<<(const TStrType &data) override
{
+ m_CodeBuilder.append(data.c_str());
+ return *this;
+ }
+
+ IShaderStageGenerator &operator<<(const QString &data) override
+ {
m_CodeBuilder.append(data);
return *this;
}
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h b/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h
index 23892c5c..6a6e967e 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderShaderCodeGeneratorV2.h
@@ -61,12 +61,15 @@ namespace render {
public:
virtual void AddIncoming(const char8_t *name, const char8_t *type) = 0;
virtual void AddIncoming(const TStrType &name, const char8_t *type) = 0;
+ virtual void AddIncoming(const QString &name, const char8_t *type) = 0;
virtual void AddOutgoing(const char8_t *name, const char8_t *type) = 0;
virtual void AddOutgoing(const TStrType &name, const char8_t *type) = 0;
+ virtual void AddOutgoing(const QString &name, const char8_t *type) = 0;
virtual void AddUniform(const char8_t *name, const char8_t *type) = 0;
virtual void AddUniform(const TStrType &name, const char8_t *type) = 0;
+ virtual void AddUniform(const QString &name, const char8_t *type) = 0;
virtual void AddInclude(const char8_t *name) = 0;
virtual void AddInclude(const TStrType &name) = 0;
@@ -75,9 +78,14 @@ namespace render {
virtual void AddFunction(const QString &functionName) = 0;
virtual void AddConstantBuffer(const char *name, const char *layout) = 0;
+ virtual void AddConstantBuffer(const QString &name, const char *layout) = 0;
+ virtual void AddConstantBufferParam(const QString &cbName,
+ const QString &paramName,
+ const char *type) = 0;
virtual void AddConstantBufferParam(const char *cbName, const char *paramName,
const char *type) = 0;
+ virtual IShaderStageGenerator &operator<<(const QString &data) = 0;
virtual IShaderStageGenerator &operator<<(const char *data) = 0;
virtual IShaderStageGenerator &operator<<(const TStrType &data) = 0;
virtual IShaderStageGenerator &operator<<(const SEndlType & /*data*/) = 0;
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderString.h b/src/Runtime/Source/runtimerender/Qt3DSRenderString.h
index 8d831c20..9321b4b9 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderString.h
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderString.h
@@ -30,40 +30,584 @@
#pragma once
#ifndef QT3DS_RENDER_STRING_H
#define QT3DS_RENDER_STRING_H
-#include "Qt3DSRender.h"
+#include <QtCore/qstring.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qhash.h>
#include <string>
+#include "Qt3DSRender.h"
+#include "EASTL/string.h"
+
namespace qt3ds {
namespace render {
- // can't name this CString else we will conflict a
- class CRenderString : public std::basic_string<char8_t>
+
+class Qt3DSStringUtils {
+public:
+ static inline QString ConvertUTFtoQString(const char16_t *string)
{
- public:
- typedef std::basic_string<char8_t> TStrType;
+ return QString::fromUtf16(string);
+ }
- CRenderString()
- : TStrType()
- {
- }
- CRenderString(const CRenderString &inOther)
- : TStrType(inOther)
- {
- }
- CRenderString(const TStrType &inOther)
- : TStrType(inOther)
- {
- }
- CRenderString &operator=(const CRenderString &inOther)
- {
- TStrType::operator=(inOther);
- return *this;
- }
- CRenderString &operator=(const char8_t *inOther)
- {
- TStrType::operator=(inOther);
- return *this;
+ static inline QString ConvertUTFtoQString(const char32_t *string)
+ {
+ return QString::fromUcs4(string);
+ }
+
+ static inline QString ConvertUTFtoQString(const wchar_t *string)
+ {
+ return QString::fromWCharArray(string);
+ }
+
+ static inline QString &append(QString &target, QString::iterator begin,
+ QString::iterator end)
+ {
+ for (QString::iterator iter = begin;iter != end;++iter)
+ target.append(*iter);
+ return target;
+ }
+
+ static inline QString &append(QString &target, QString::const_iterator begin,
+ QString::const_iterator end)
+ {
+ for (QString::const_iterator iter = begin;iter != end;++iter)
+ target.append(*iter);
+ return target;
+ }
+
+ /**
+ * @brief replace Replaces specified portion of a string.
+ * @param source Source text that will be used. Note: This is const and will
+ * not be directly modified.
+ * @param first First character in the range that will be replaced.
+ * @param last Last character in the range that will be replaced.
+ * @param replaceText Pointer to the character string to use for replacement.
+ * @param len Length of the replacement character string.
+ * @return Returns a new QString containing the modified result.
+ */
+ static inline QString replace(const QString &source,
+ QString::const_iterator first,
+ QString::const_iterator last,
+ const char *replaceText, int len)
+ {
+ return replace(source, first, last, QString::fromUtf8(replaceText, len));
+ }
+
+ /**
+ * @brief replace Replaces specified portion of a string.
+ * @param source Source text that will be used. Note: This is const and will
+ * not be directly modified.
+ * @param first First character in the range that will be replaced.
+ * @param last Last character in the range that will be replaced.
+ * @param replaceText String to use for replacement.
+ * @return Returns a new QString containing the modified result.
+ */
+ static inline QString replace(const QString &source,
+ QString::const_iterator first,
+ QString::const_iterator last,
+ const QString &replaceText)
+ {
+ QString newStr;
+ for (QString::const_iterator iter = source.constBegin(); iter != first;
+ iter++)
+ newStr.append(*iter);
+
+ newStr.append(replaceText);
+
+ for (QString::const_iterator iter = last; iter != source.constEnd();
+ iter++)
+ newStr.append(*iter);
+ return newStr;
+ }
+
+ /**
+ * @brief replace Replaces specified portion of a string.
+ * @param source Source text that will be used. Note: This is const and
+ * will not be directly modified.
+ * @param first First character in the range that will be replaced.
+ * @param last Last character in the range that will be replaced.
+ * @param replaceText Pointer to the character string to use for replacement.
+ * @param len Length of the replacement character string.
+ * @return Returns a temporary object allocated on the stack containing
+ * the modified result.
+ */
+ static inline QString &replace(QString &target,
+ QString::iterator first,
+ QString::iterator last,
+ const char *replaceText, int len)
+ {
+ return replace(target, first, last, QString::fromUtf8(replaceText, len));
+ }
+
+ /**
+ * @brief replace Replaces specified portion of a string.
+ * @param target Target QString that will be modified.
+ * @param first First character in the range that will be replaced.
+ * @param last Last character in the range that will be replaced.
+ * @param replaceText String to use for replacement.
+ * @return Returns the string given in target, containing the modified result.
+ */
+ static inline QString &replace(QString &target,
+ QString::iterator first,
+ QString::iterator last,
+ const QString &replaceText)
+ {
+ QString newStr;
+ for (QString::iterator iter = target.begin(); iter != first; iter++)
+ newStr.append(*iter);
+
+ newStr.append(replaceText);
+
+ for (QString::iterator iter = last; iter != target.end(); iter++)
+ newStr.append(*iter);
+
+ target = newStr;
+ return target;
+ }
+};
+
+class CRenderString {
+public:
+ inline CRenderString() {}
+
+ CRenderString(QChar c) : m_string(QString(c)) {}
+
+ CRenderString(int size, QChar c) : m_string(size, c) {}
+
+ inline CRenderString(QLatin1String latin1)
+ : m_string(latin1) {}
+
+ explicit CRenderString(const QChar *unicode, int size = -1)
+ : m_string(unicode,size) {}
+
+ inline CRenderString(const QString &str) Q_DECL_NOTHROW
+ : m_string(str) {}
+
+ inline CRenderString(const CRenderString &str) Q_DECL_NOTHROW
+ : m_string(str.m_string) {}
+
+ ~CRenderString() {}
+
+ inline operator QString() const
+ {
+ return m_string;
+ }
+
+ inline void operator=(const CRenderString &text)
+ {
+ m_string = text.m_string;
+ m_isDirty = true;
+ }
+
+ inline void operator=(const QString &text)
+ {
+ m_string = text;
+ m_isDirty = true;
+ }
+
+ // QString method wrappers
+ static inline CRenderString fromUtf8(const char *str, int size = -1)
+ {
+ return CRenderString(QString::fromUtf8(str, size));
+ }
+
+ typedef int size_type;
+ typedef qptrdiff difference_type;
+ typedef const QChar & const_reference;
+ typedef QChar & reference;
+ typedef QChar *pointer;
+ typedef const QChar *const_pointer;
+ typedef QChar value_type;
+ typedef QChar *iterator;
+ typedef const QChar *const_iterator;
+ typedef iterator Iterator;
+ typedef const_iterator ConstIterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ inline iterator begin() { return m_string.begin(); }
+ inline const_iterator begin() const { return m_string.begin(); }
+ inline const_iterator cbegin() const { return m_string.cbegin(); }
+ inline const_iterator constBegin() const { return m_string.constBegin(); }
+ inline iterator end() { return m_string.end(); }
+ inline const_iterator end() const { return m_string.end(); }
+ inline const_iterator cend() const { return m_string.cend(); }
+ inline const_iterator constEnd() const { return m_string.constEnd(); }
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
+ const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
+ const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); }
+ const_reverse_iterator crend() const { return const_reverse_iterator(begin()); }
+
+ inline void push_back(QChar c)
+ {
+ m_string.push_back(c);
+ m_isDirty = true;
+ }
+
+ inline void push_back(const QString &s)
+ {
+ m_string.push_back(s);
+ m_isDirty = true;
+ }
+
+ inline void push_front(QChar c)
+ {
+ m_string.push_front(c);
+ m_isDirty = true;
+ }
+
+ inline void push_front(const QString &s)
+ {
+ m_string.push_front(s);
+ m_isDirty = true;
+ }
+
+ inline bool operator==(const QString &rhs)
+ {
+ return rhs == m_string;
+ }
+
+ inline bool operator<(const QString &rhs)
+ {
+ return m_string < rhs;
+ }
+
+ inline bool operator!=(const QString &rhs)
+ {
+ return !(*this == rhs);
+ }
+
+ inline bool operator>(const QString& rhs)
+ {
+ return (rhs < m_string);
+ }
+
+ inline bool operator<=(const QString& rhs)
+ {
+ return !operator> (rhs);
+ }
+
+ inline bool operator>=(const QString& rhs)
+ {
+ return !operator< (rhs);
+ }
+
+ inline CRenderString& operator+=(const QString &rhs)
+ {
+ m_string += rhs;
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString& operator+=(const char *s)
+ {
+ m_string += s;
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline bool isEmpty() const
+ {
+ return m_string.isEmpty();
+ }
+
+ int indexOf(const QString &str, int from = 0,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.indexOf(str, from, cs);
+ }
+
+ int indexOf(QChar ch, int from = 0,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.indexOf(ch, from, cs);
+ }
+
+ int indexOf(QLatin1String str, int from = 0,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.indexOf(str, from, cs);
+ }
+
+ int indexOf(const QStringRef &str, int from = 0,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.indexOf(str, from, cs);
+ }
+
+ int lastIndexOf(const QString &str, int from = -1,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.lastIndexOf(str, from, cs);
+ }
+
+ int lastIndexOf(QChar ch, int from = -1,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.lastIndexOf(ch, from, cs);
+ }
+
+ int lastIndexOf(QLatin1String str, int from = -1,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.lastIndexOf(str, from, cs);
+ }
+
+ int lastIndexOf(const QStringRef &str, int from = -1,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.lastIndexOf(str, from, cs);
+ }
+
+ inline void clear()
+ {
+ m_string.clear();
+ m_isDirty = true;
+ }
+
+ inline CRenderString &insert(int i, QChar c)
+ {
+ m_string.insert(i,c);
+ m_isDirty = true;
+ return *this;
+ }
+ inline CRenderString &insert(int i, const QChar *uc, int len)
+ {
+ m_string.insert(i,uc, len);
+ m_isDirty = true;
+ return *this;
+ }
+ inline CRenderString &insert(int i, const QString &s)
+ {
+ m_string.insert(i,s);
+ m_isDirty = true;
+ return *this;
+ }
+ inline CRenderString &insert(int i, const QStringRef &s)
+ {
+ m_string.insert(i,s);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &insert(int i, QLatin1String s)
+ {
+ m_string.insert(i,s);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline int size() const
+ {
+ return m_string.size();
+ }
+
+ inline int length() const {
+ return m_string.length();
+ }
+
+ inline CRenderString &append(QChar c)
+ {
+ m_string.append(c);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &append(const QChar *uc, int len)
+ {
+ m_string.append(uc, len);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &append(const QString &s)
+ {
+ m_string.append(s);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &append(const QStringRef &s)
+ {
+ m_string.append(s);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &append(QLatin1String s)
+ {
+ m_string.append(s);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline int compare(const QString &s,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ {
+ return m_string.compare(s, cs);
+ }
+
+ // Compatibility wrappers for std::basic_string and eastl::basic_string
+ // Required for now for the Qt 3D Studio's template classes.
+ static const int npos = -1;
+
+ inline char operator[](int idx) const
+ {
+ return m_string[idx].toLatin1();
+ }
+
+ inline void assign(const char *text)
+ {
+ m_string = QString::fromUtf8(text);
+ m_isDirty = true;
+ }
+
+ inline void assign(const char16_t *text)
+ {
+ m_string = QString::fromUtf16(text);
+ m_isDirty = true;
+ }
+
+ inline void assign(const char32_t *text)
+ {
+ m_string = QString::fromUcs4(text);
+ m_isDirty = true;
+ }
+
+ inline void assign(const wchar_t *text)
+ {
+ m_string = QString::fromWCharArray(text);
+ m_isDirty = true;
+ }
+
+ inline void assign(const eastl::string &text)
+ {
+ m_string = QString::fromUtf8(text.c_str());
+ m_isDirty = true;
+ }
+
+ inline void operator=(const char *text)
+ {
+ assign(text);
+ }
+
+ inline void operator=(const char16_t *text)
+ {
+ assign(text);
+ }
+
+ inline void operator=(const char32_t *text)
+ {
+ assign(text);
+ }
+
+ inline void operator=(const wchar_t *text)
+ {
+ assign(text);
+ }
+
+ inline void operator=(const eastl::string &text)
+ {
+ assign(text);
+ }
+
+ inline void operator=(const eastl::basic_string<char*> &text)
+ {
+ assign(*text.c_str());
+ }
+
+ inline CRenderString &append(QString::iterator first,
+ QString::iterator last)
+ {
+ Qt3DSStringUtils::append(m_string, first, last);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &append(QString::const_iterator first,
+ QString::const_iterator last)
+ {
+ Qt3DSStringUtils::append(m_string, first, last);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &append(const char *text, int size)
+ {
+ m_string.append(QString::fromUtf8(text, size));
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &append(const char *text)
+ {
+ m_string.append(QString::fromUtf8(text));
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &replace(QString::iterator replaceBegin,
+ QString::iterator replaceEnd,
+ const char *replaceText, int len)
+ {
+ return replace(replaceBegin, replaceEnd,
+ QString::fromUtf8(replaceText, len));
+ }
+
+ inline CRenderString &replace(QString::iterator replaceBegin,
+ QString::iterator replaceEnd,
+ const QString &replaceText)
+ {
+ m_string = Qt3DSStringUtils::replace(this->m_string,
+ replaceBegin, replaceEnd,
+ replaceText);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline CRenderString &replace(QString::const_iterator replaceBegin,
+ QString::const_iterator replaceEnd,
+ const QString &replaceText)
+ {
+ m_string = Qt3DSStringUtils::replace(this->m_string,
+ replaceBegin, replaceEnd,
+ replaceText);
+ m_isDirty = true;
+ return *this;
+ }
+
+ inline QByteArray toUtf8() const
+ {
+ updateCache();
+ return m_array;
+ }
+
+ inline const char *c_str() const
+ {
+ updateCache();
+ return m_array.constData();
+ }
+
+ inline const char *c_str()
+ {
+ updateCache();
+ return m_array.constData();
+ }
+
+private:
+ inline void updateCache() const
+ {
+ if (m_isDirty) {
+ m_array = m_string.toUtf8();
+ m_isDirty = false;
}
- };
+ }
+
+ QString m_string;
+ mutable bool m_isDirty = true;
+ mutable QByteArray m_array;
+};
+
}
}
diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp b/src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp
index 61b132ba..6ab4047f 100644
--- a/src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp
+++ b/src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp
@@ -1954,27 +1954,6 @@ ConvertTextureCoordOp(const char8_t *inWrap, NVFoundationBase &inFoundation)
}
}
-template <typename TCharStr>
-QString ConvertUTFtoQString(const TCharStr *string);
-
-template <>
-QString ConvertUTFtoQString(const char16_t *string)
-{
- return QString::fromUtf16(string);
-}
-
-template <>
-QString ConvertUTFtoQString(const char32_t *string)
-{
- return QString::fromUcs4(string);
-}
-
-template <>
-QString ConvertUTFtoQString(const wchar_t *string)
-{
- return QString::fromWCharArray(string);
-}
-
// Re-register all strings because we can't be sure that the meta data system and the effect
// system are sharing the same string table.
void qt3ds::render::IUIPLoader::CreateEffectClassFromMetaEffect(
@@ -2021,12 +2000,12 @@ void qt3ds::render::IUIPLoader::CreateEffectClassFromMetaEffect(
for (QT3DSU32 idx = 0, end = inMetaDataEffect.m_Shaders.size(); idx < end; ++idx) {
const qt3dsdm::SMetaDataShader &theShader = inMetaDataEffect.m_Shaders[idx];
theConvertStr.clear();
- theConvertStr = ConvertUTFtoQString(
- theShader.m_Code.c_str()).toStdString();
- theConvertShaderTypeStr = ConvertUTFtoQString(
- theShader.m_Type.c_str()).toStdString();
- theConvertShaderVersionStr = ConvertUTFtoQString(
- theShader.m_Version.c_str()).toStdString();
+ theConvertStr = Qt3DSStringUtils::ConvertUTFtoQString(
+ theShader.m_Code.c_str());
+ theConvertShaderTypeStr = Qt3DSStringUtils::ConvertUTFtoQString(
+ theShader.m_Type.c_str());
+ theConvertShaderVersionStr = Qt3DSStringUtils::ConvertUTFtoQString(
+ theShader.m_Version.c_str());
inEffectSystem.SetShaderData(inStrTable.RegisterStr(theShader.m_Name.c_str()),
theConvertStr.c_str(), theConvertShaderVersionStr.c_str(),
@@ -2083,12 +2062,12 @@ void qt3ds::render::IUIPLoader::CreateMaterialClassFromMetaMaterial(
if (inMetaDataMaterial.m_Shaders.size()) {
for (QT3DSU32 idx = 0, end = (QT3DSU32)inMetaDataMaterial.m_Shaders.size(); idx < end; ++idx) {
const qt3dsdm::SMetaDataShader &theShader = inMetaDataMaterial.m_Shaders[idx];
- theConvertStr = ConvertUTFtoQString(
- theShader.m_Code.c_str()).toStdString();
- theConvertShaderTypeStr = ConvertUTFtoQString(
- theShader.m_Type.c_str()).toStdString();
- theConvertShaderVersionStr = ConvertUTFtoQString(
- theShader.m_Version.c_str()).toStdString();
+ theConvertStr = Qt3DSStringUtils::ConvertUTFtoQString(
+ theShader.m_Code.c_str());
+ theConvertShaderTypeStr = Qt3DSStringUtils::ConvertUTFtoQString(
+ theShader.m_Type.c_str());
+ theConvertShaderVersionStr = Qt3DSStringUtils::ConvertUTFtoQString(
+ theShader.m_Version.c_str());
inMaterialSystem.SetMaterialClassShader(
inStrTable.RegisterStr(theShader.m_Name.c_str()), theConvertShaderTypeStr.c_str(),
theConvertShaderVersionStr.c_str(), theConvertStr.c_str(),
diff --git a/src/Runtime/Source/runtimerender/rendererimpl/Qt3DSVertexPipelineImpl.h b/src/Runtime/Source/runtimerender/rendererimpl/Qt3DSVertexPipelineImpl.h
index e2de7e0f..439f2467 100644
--- a/src/Runtime/Source/runtimerender/rendererimpl/Qt3DSVertexPipelineImpl.h
+++ b/src/Runtime/Source/runtimerender/rendererimpl/Qt3DSVertexPipelineImpl.h
@@ -339,6 +339,10 @@ namespace render {
{
AddIncoming(name.c_str(), type);
}
+ void AddIncoming(const QString &name, const char8_t *type) override
+ {
+ AddIncoming(name.toUtf8().constData(), type);
+ }
void AddOutgoing(const char8_t *name, const char8_t *type) override
{
@@ -348,6 +352,14 @@ namespace render {
{
AddOutgoing(name.c_str(), type);
}
+ void AddOutgoing(const QString &name, const char8_t *type) override
+ {
+ AddOutgoing(name.toUtf8().constData(), type);
+ }
+ void AddUniform(const QString &name, const char8_t *type) override
+ {
+ AddUniform(name.toUtf8().constData(), type);
+ }
void AddUniform(const char8_t *name, const char8_t *type) override
{
@@ -381,11 +393,22 @@ namespace render {
{
ActiveStage().AddConstantBuffer(name, layout);
}
+ void AddConstantBuffer(const QString &name, const char *layout) override
+ {
+ AddConstantBuffer(name.toUtf8().constData(), layout);
+ }
+
void AddConstantBufferParam(const char *cbName, const char *paramName,
const char *type) override
{
ActiveStage().AddConstantBufferParam(cbName, paramName, type);
}
+ void AddConstantBufferParam(const QString &cbName, const QString &paramName,
+ const char *type) override
+ {
+ AddConstantBufferParam(cbName.toUtf8().constData(),
+ paramName.toUtf8().constData(), type);
+ }
IShaderStageGenerator &operator<<(const char *data) override
{
@@ -397,6 +420,11 @@ namespace render {
ActiveStage() << data;
return *this;
}
+ IShaderStageGenerator &operator<<(const QString &data) override
+ {
+ ActiveStage() << data;
+ return *this;
+ }
IShaderStageGenerator &operator<<(const SEndlType &data) override
{
ActiveStage() << data;