diff options
author | Antti Määttä <antti.maatta@qt.io> | 2019-06-04 11:59:24 +0300 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2019-06-04 13:32:18 +0300 |
commit | 7a269685bdd72f075deb9a4262cbfb8fda0ce631 (patch) | |
tree | c10a3e6e9d7dc054a65845f27e0ed797ff5e5d8b | |
parent | 403b3a82be8edb928d227b240436d272d863b0d7 (diff) |
Properly detect and generate ibl image mipmaps
Also fix some warnings.
Task-number: QT3DS-1470
Change-Id: I02891d1b7e690df56d91b1c87a043f0915cae734
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
9 files changed, 111 insertions, 158 deletions
diff --git a/src/Runtime/ogl-runtime/src/engine/Qt3DSRenderRuntimeBinding.cpp b/src/Runtime/ogl-runtime/src/engine/Qt3DSRenderRuntimeBinding.cpp index cd99a95b..4507c742 100644 --- a/src/Runtime/ogl-runtime/src/engine/Qt3DSRenderRuntimeBinding.cpp +++ b/src/Runtime/ogl-runtime/src/engine/Qt3DSRenderRuntimeBinding.cpp @@ -184,7 +184,7 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene m_PathSubPathType = inContext.GetStringTable().RegisterStr("PathAnchorPoint"); } - virtual ~Qt3DSRenderScene() + virtual ~Qt3DSRenderScene() override { if (m_OffscreenRenderer) m_Context->GetOffscreenRenderManager().ReleaseOffscreenRenderer(m_OffscreenRendererId); @@ -210,7 +210,7 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene { Q3DStudio::TElementList &theDirtyList = m_RuntimePresentation->GetFrameData().GetDirtyList(); - for (QT3DSU32 idx = 0, end = theDirtyList.GetCount(); idx < end; ++idx) { + for (int idx = 0, end = theDirtyList.GetCount(); idx < end; ++idx) { Q3DStudio::TElement &theElement = *theDirtyList[idx]; Qt3DSTranslator *theTranslator = reinterpret_cast<Qt3DSTranslator *>(theElement.GetAssociation()); @@ -250,7 +250,7 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene if (m_Presentation && m_Presentation->m_Scene) { NVRenderRect theViewportSize(m_LastRenderViewport); return m_Presentation->m_Scene->PrepareForRender( - QT3DSVec2((QT3DSF32)theViewportSize.m_Width, (QT3DSF32)theViewportSize.m_Height), + QT3DSVec2(QT3DSF32(theViewportSize.m_Width), QT3DSF32(theViewportSize.m_Height)), *m_Context); } return false; @@ -261,8 +261,8 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene if (m_Presentation && m_Presentation->m_Scene) { NVRenderRect theViewportSize(m_LastRenderViewport); m_Presentation->m_Scene->Render( - QT3DSVec2((QT3DSF32)theViewportSize.m_Width, (QT3DSF32)theViewportSize.m_Height), *m_Context, - SScene::DoNotClear); + QT3DSVec2(QT3DSF32(theViewportSize.m_Width), QT3DSF32(theViewportSize.m_Height)), + *m_Context, SScene::DoNotClear); } } @@ -342,12 +342,12 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene thePlane = qt3ds::render::SBasisPlanes::XZ; break; } - if (theBounds.isEmpty() == false) + if (theBounds.isEmpty() == false) { return m_Context->GetRenderer().FacePosition( theNode, theBounds, theNode.m_GlobalTransform, m_Context->GetMousePickViewport(), - mousePos, - NVDataRef<SGraphObject *>(theMapperObjects.data(), (QT3DSU32)theMapperObjects.size()), - thePlane); + mousePos, NVDataRef<SGraphObject *>(theMapperObjects.data(), + QT3DSU32(theMapperObjects.size())), thePlane); + } return Empty(); } @@ -588,24 +588,6 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene } } - static inline int wrapMod(int a, int base) { return (a >= 0) ? a % base : (a % base) + base; } - static inline float fMin(float a, float b) { return (a < b) ? a : b; } - static inline int iMax(int a, int b) { return (a > b) ? a : b; } - - static inline void getWrappedCoords(int &sX, int &sY, int width, int height) - { - if (sY < 0) { - sX -= width >> 1; - sY = -sY; - } - if (sY >= height) { - sX += width >> 1; - sY = height - sY; - } - sX = wrapMod(sX, width); - sY = wrapMod(sY, height); - } - static void GenerateBsdfMipmaps(SImage *theImage, const unsigned char *inBuffer, Q3DStudio::INT32 inBufferLength, Q3DStudio::INT32 inWidth, Q3DStudio::INT32 inHeight, @@ -623,7 +605,7 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene } if (theBSDFMipMap) - theBSDFMipMap->Build((void *)inBuffer, inBufferLength, inFormat); + theBSDFMipMap->Build((void *)(inBuffer), inBufferLength, inFormat); } // This could cause some significant drama. @@ -704,8 +686,8 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene STextDimensions theDimensions = m_Context->GetTextRenderer()->MeasureText(*theText, 1.0f, inTextStr); - retval = Q3DStudio::STextSizes((Q3DStudio::INT32)theDimensions.m_TextWidth, - (Q3DStudio::INT32)theDimensions.m_TextHeight); + retval = Q3DStudio::STextSizes(Q3DStudio::INT32(theDimensions.m_TextWidth), + Q3DStudio::INT32(theDimensions.m_TextHeight)); } } else { qCCritical(INVALID_OPERATION, "MeasureText called on object that is not text"); @@ -732,7 +714,7 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene // If there aren't any rotations, then account for the difference in width/height of the // presentation and the window QT3DSVec2 theCoords = m_Context->GetMousePickMouseCoords( - QT3DSVec2((QT3DSF32)inWindowCoords.m_X, (QT3DSF32)inWindowCoords.m_Y)); + QT3DSVec2(QT3DSF32(inWindowCoords.m_X), QT3DSF32(inWindowCoords.m_Y))); theCoords.x -= m_LastRenderViewport.m_X; // Note that the mouse Y is reversed. Thus a positive offset of the viewport will reduce // the mouse value. @@ -745,16 +727,6 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene return m_Context->GetStringTable().RegisterStr(inStr); } - Q3DStudio::INT32 LoadImageBatch(qt3ds::foundation::CRegisteredString *inFullPaths, - Q3DStudio::INT32 inNumPaths, - qt3ds::foundation::CRegisteredString inDefaultImage, - qt3ds::render::IImageLoadListener *inLoadCallback) override - { - return static_cast<Q3DStudio::INT32>(m_Context->GetImageBatchLoader().LoadImageBatch( - toConstDataRef(inFullPaths, (QT3DSU32)inNumPaths), inDefaultImage, inLoadCallback, - m_Context->GetRenderContext().GetRenderContextType(), m_Presentation->m_preferKTX)); - } - void RegisterOffscreenRenderer(const char *inKey) override { m_OffscreenRenderer = QT3DS_NEW(m_Context->GetAllocator(), Qt3DSRenderSceneSubPresRenderer)( @@ -782,8 +754,9 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene forAllObjects<SImage>(m_GraphObjectList, GraphObjectTypes::Image, [&mgr](SImage *image){ if (image->m_ImagePath.IsValid() && qt3ds::runtime::isImagePath( image->m_ImagePath.c_str())) { + const bool ibl = image->m_MappingMode == ImageMappingModes::LightProbe; image->m_LoadedTextureData = mgr.CreateReloadableImage(image->m_ImagePath, - false, false); + false, ibl); image->m_LoadedTextureData->m_callbacks.push_back(image); } }); @@ -838,8 +811,8 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, Q3DStudio::INT32 m_ViewHeight; Q3DStudio::SPickFrame m_PickFrame; NVDataRef<QT3DSU8> m_StrTableData; - // The boolean is to mark transparent images - nvvector<eastl::pair<CRegisteredString, bool>> m_SourcePaths; + // The boolean is to mark transparent images and ibl images + nvvector<eastl::pair<CRegisteredString, eastl::pair<bool, bool>>> m_SourcePaths; eastl::hash_set<CRegisteredString> m_SourcePathSet; Qt3DSRenderScene *m_LastRenderedScene; @@ -866,7 +839,7 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, { memZero(&m_PickFrame, sizeof(m_PickFrame)); } - virtual ~Qt3DSRenderSceneManager() + virtual ~Qt3DSRenderSceneManager() override { for (QT3DSU32 idx = 0, end = m_Scenes.size(); idx < end; ++idx) m_Scenes[idx].second->Release(); @@ -882,13 +855,6 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, return *theTagPtr; } - static bool IsMesh(const char *ending) - { - if (!ending) - return false; - return stricmp(ending, "mesh") == 0; - } - void FinalizeScene(Q3DStudio::IPresentation &inPresentation, Qt3DSRenderScene &inScene) { inPresentation.SetScene(&inScene); @@ -1005,6 +971,7 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, IBufferManager &theManager(m_Context->m_Context->GetBufferManager()); // List of image paths to be loaded in parallel at the end. eastl::vector<CRegisteredString> theSourcePathList; + eastl::vector<CRegisteredString> iblList; for (QT3DSU32 idx = 0, end = theSourcePathData.size(); idx < end; ++idx) { const eastl::string &theValue = theSourcePathData[idx]; CRegisteredString theSourcePath = @@ -1017,11 +984,18 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, if (!theManager.isReloadableResourcesEnabled() || !slideSourcePaths.contains(QString::fromLatin1(theValue.c_str()))) { theManager.SetImageTransparencyToFalseIfNotSet(theObjectPath); + bool ibl = inParser->isIblImage(theObjectPath.c_str()); + bool transparent = theManager.GetImageHasTransparency(theObjectPath); if (m_SourcePathSet.insert(theSourcePath).second) { + m_SourcePaths.push_back(eastl::make_pair(theSourcePath, - theManager.GetImageHasTransparency(theObjectPath))); + eastl::make_pair(transparent, ibl))); } - theSourcePathList.push_back(theObjectPath); + if (ibl) + iblList.push_back(theObjectPath); + else + theSourcePathList.push_back(theObjectPath); + } } else if (theValue.find(".mesh") != eastl::string::npos) { theManager.LoadMesh(theObjectPath); @@ -1034,9 +1008,16 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, toConstDataRef(theSourcePathList.data(), theSourcePathList.size()), CRegisteredString(), nullptr, m_Context->m_Context->GetRenderContext() .GetRenderContextType(), - theScene->m_Presentation->m_preferKTX); + theScene->m_Presentation->m_preferKTX, false); + QT3DSU64 iblImageBatchId = m_Context->m_Context->GetImageBatchLoader().LoadImageBatch( + toConstDataRef(iblList.data(), iblList.size()), + CRegisteredString(), nullptr, m_Context->m_Context->GetRenderContext() + .GetRenderContextType(), + theScene->m_Presentation->m_preferKTX, true); m_Context->m_Context->GetImageBatchLoader().BlockUntilLoaded( static_cast<TImageBatchId>(imageBatchId)); + m_Context->m_Context->GetImageBatchLoader().BlockUntilLoaded( + static_cast<TImageBatchId>(iblImageBatchId)); theIScene = QT3DS_NEW(m_Context->GetAllocator(), Qt3DSRenderScene)(*m_Context, *m_Context->m_Context, *theScene); @@ -1093,7 +1074,7 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, QT3DSU32 theFileSig = theReader.LoadRef<QT3DSU32>(); QT3DSU32 theBinaryVersion = theReader.LoadRef<QT3DSU32>(); - QT3DSU32 theDataSectionSize = (QT3DSU32)(theReader.m_EndPtr - theReader.m_CurrentPtr); + QT3DSU32 theDataSectionSize = QT3DSU32(theReader.m_EndPtr - theReader.m_CurrentPtr); if (theFileSig != GetFileTag() || theBinaryVersion != SGraphObject::GetSceneGraphBinaryVersion()) { @@ -1104,7 +1085,7 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, SSceneLoadData *theScene; { Mutex::ScopedLock __locker(m_LoadingScenesMutex); - theLoadingSceneIndex = (QT3DSU32)m_LoadingScenes.size() + 1; + theLoadingSceneIndex = QT3DSU32(m_LoadingScenes.size()) + 1; m_LoadingScenes.push_back( QT3DS_NEW(m_Context->GetAllocator(), SSceneLoadData)(m_Context->GetAllocator())); theScene = m_LoadingScenes.back(); @@ -1150,7 +1131,7 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, SSceneLoadData *theScene; { Mutex::ScopedLock __locker(m_LoadingScenesMutex); - QT3DSU32 numLoadingScenes = (QT3DSU32)m_LoadingScenes.size(); + QT3DSU32 numLoadingScenes = QT3DSU32(m_LoadingScenes.size()); if (inSceneHandle && inSceneHandle <= numLoadingScenes) { theSceneIndex = inSceneHandle - 1; theScene = m_LoadingScenes[theSceneIndex]; @@ -1180,16 +1161,22 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, // this means graphics have been initialized eastl::string theSourcePathStr; IBufferManager &theManager(m_Context->m_Context->GetBufferManager()); - nvvector<CRegisteredString> theSourcePathList(m_Context->GetAllocator(), - "TempSourcePathList"); + nvvector<CRegisteredString> imagePathList(m_Context->GetAllocator(), + "imagePathList"); + nvvector<CRegisteredString> iblImagePathList(m_Context->GetAllocator(), + "iblImagePathList"); for (QT3DSU32 idx = 0, end = m_SourcePaths.size(); idx < end; ++idx) { theSourcePathStr.assign(m_SourcePaths[idx].first); - bool hasTransparency = m_SourcePaths[idx].second; + bool hasTransparency = m_SourcePaths[idx].second.first; + bool isIbl = m_SourcePaths[idx].second.second; if (theSourcePathStr.size() > 4) { CRegisteredString theObjectPath = m_SourcePaths[idx].first; if (qt3ds::runtime::isImagePath(theSourcePathStr.c_str())) { theManager.SetImageHasTransparency(theObjectPath, hasTransparency); - theSourcePathList.push_back(theObjectPath); + if (isIbl) + iblImagePathList.push_back(theObjectPath); + else + imagePathList.push_back(theObjectPath); } else { if (theSourcePathStr.find(".mesh") != eastl::string::npos) theManager.LoadMesh(theObjectPath); @@ -1198,7 +1185,7 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, } bool pktx = false; - for (int i = 0; i < m_Scenes.size(); ++i) { + for (unsigned int i = 0; i < m_Scenes.size(); ++i) { if (m_Scenes[i].second->m_Presentation->m_preferKTX) { pktx = true; break; @@ -1210,9 +1197,13 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, "Initial Batch Image Load"); m_Context->m_Context->GetImageBatchLoader().LoadImageBatch( - toConstDataRef(theSourcePathList.data(), theSourcePathList.size()), + toConstDataRef(imagePathList.data(), imagePathList.size()), CRegisteredString(), nullptr, m_Context->m_Context->GetRenderContext() - .GetRenderContextType(), pktx); + .GetRenderContextType(), pktx, false); + m_Context->m_Context->GetImageBatchLoader().LoadImageBatch( + toConstDataRef(iblImagePathList.data(), iblImagePathList.size()), + CRegisteredString(), nullptr, m_Context->m_Context->GetRenderContext() + .GetRenderContextType(), pktx, true); } { @@ -1228,7 +1219,7 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, FinalizeScene(*theScene.m_RuntimePresentation, *theIScene); theIScene->PostLoadStep(); } else { - qCWarning(WARNING, "Failed to finalize scene %d", (int)idx + 1); + qCWarning(WARNING, "Failed to finalize scene %d", int(idx + 1)); } } } @@ -1397,14 +1388,15 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, theWriteBuffer, theStrTable.GetRemapMap(), theProjectDir.c_str()); QT3DSU32 theBinaryPathOffset = theWriteBuffer.size() - theOffsetStart; - theWriteBuffer.write((QT3DSU32)m_SourcePaths.size()); - for (nvvector<pair<CRegisteredString, bool>>::iterator iter = m_SourcePaths.begin(), - end = m_SourcePaths.end(); + theWriteBuffer.write(QT3DSU32(m_SourcePaths.size())); + for (nvvector<pair<CRegisteredString, eastl::pair<bool, bool>>>::iterator iter + = m_SourcePaths.begin(), end = m_SourcePaths.end(); iter != end; ++iter) { CRegisteredString theStr(iter->first); theStr.Remap(theStrTable.GetRemapMap()); - theWriteBuffer.write((size_t)theStr.c_str()); - QT3DSU32 theSourcePathFlags = iter->second ? 1 : 0; + theWriteBuffer.write(size_t(theStr.c_str())); + QT3DSU32 theSourcePathFlags = iter->second.first ? 1 : 0; + theSourcePathFlags |= iter->second.second ? 2 : 0; theWriteBuffer.write(theSourcePathFlags); } @@ -1544,7 +1536,7 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, { bool theResult = false; long theSceneCount = m_Scenes.size(); - for (long theSceneIndex = 0; theSceneIndex < theSceneCount; ++theSceneIndex) { + for (size_t theSceneIndex = 0; theSceneIndex < theSceneCount; ++theSceneIndex) { Qt3DSRenderScene *theScene = m_Scenes[theSceneIndex].second; theResult |= theScene->Update(); } @@ -1577,8 +1569,8 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, m_Context->m_Context->SetRenderRotation(RenderRotationValues::NoRotation); m_Context->m_Context->SetPresentationDimensions(QSize( - (QT3DSU32)theFirstScene->m_Presentation->m_PresentationDimensions.x, - (QT3DSU32)theFirstScene->m_Presentation->m_PresentationDimensions.y)); + int(theFirstScene->m_Presentation->m_PresentationDimensions.x), + int(theFirstScene->m_Presentation->m_PresentationDimensions.y))); } m_Context->m_Context->BeginFrame(firstFrame); @@ -1622,8 +1614,8 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager, theFirstScene = m_Scenes[idx].second; if (theFirstScene) { m_Context->m_Context->SetPresentationDimensions(QSize( - (QT3DSU32)theFirstScene->m_Presentation->m_PresentationDimensions.x, - (QT3DSU32)theFirstScene->m_Presentation->m_PresentationDimensions.y)); + int(theFirstScene->m_Presentation->m_PresentationDimensions.x), + int(theFirstScene->m_Presentation->m_PresentationDimensions.y))); render::NVRenderRectF theDisplayViewport = m_Context->m_Context->GetDisplayViewport(); return Q3DStudio::STextSizes( @@ -1853,59 +1845,6 @@ struct SRenderFactory : public IQt3DSRenderFactoryCore, public IQt3DSRenderFacto } }; -Q3DStudio::SScriptEngineGotoSlideArgs ToEngine(const qt3ds::state::SGotoSlideData &inData) -{ - using namespace qt3ds::state; - Q3DStudio::SScriptEngineGotoSlideArgs retval; - if (inData.m_Mode.hasValue()) { - switch (*inData.m_Mode) { - case SlidePlaybackModes::StopAtEnd: - retval.m_Mode = Q3DStudio::TimePolicyModes::StopAtEnd; - break; - case SlidePlaybackModes::Looping: - retval.m_Mode = Q3DStudio::TimePolicyModes::Looping; - break; - case SlidePlaybackModes::Ping: - retval.m_Mode = Q3DStudio::TimePolicyModes::Ping; - break; - case SlidePlaybackModes::PingPong: - retval.m_Mode = Q3DStudio::TimePolicyModes::PingPong; - break; - default: - QT3DS_ASSERT(false); - break; - } - } - if (inData.m_PlaythroughTo.hasValue()) - retval.m_PlaythroughTo = inData.m_PlaythroughTo->c_str(); - if (inData.m_Paused.hasValue()) - retval.m_Paused = inData.m_Paused; - retval.m_Rate = inData.m_Rate; - retval.m_Reverse = inData.m_Reverse; - if (inData.m_StartTime.hasValue()) - retval.m_StartTime = *inData.m_StartTime; - return retval; -} - -class CStateScriptEngineCallFunctionArgRetriever - : public Q3DStudio::CScriptEngineCallFunctionArgRetriever -{ -public: - CStateScriptEngineCallFunctionArgRetriever(const char *inArguments, - qt3ds::state::IScriptContext &inScriptContext) - : CScriptEngineCallFunctionArgRetriever(inArguments) - , m_ScriptContext(inScriptContext) - { - } - int RetrieveArgument(script_State *inState) override - { - (void *)inState; - return m_ScriptContext.ExecuteStr(m_ArgumentString, true) ? 1 : -1; - } - -private: - qt3ds::state::IScriptContext &m_ScriptContext; -}; } IQt3DSRenderFactoryCore &IQt3DSRenderFactoryCore::CreateRenderFactoryCore( @@ -1913,7 +1852,7 @@ IQt3DSRenderFactoryCore &IQt3DSRenderFactoryCore::CreateRenderFactoryCore( Q3DStudio::IWindowSystem &inWindowSystem, Q3DStudio::ITimeProvider &inTimeProvider) { - SBindingCore *theCore = (SBindingCore *)malloc(sizeof(SBindingCore)); + SBindingCore *theCore = reinterpret_cast<SBindingCore *>(malloc(sizeof(SBindingCore))); new (theCore) SBindingCore(inApplicationDirectory, inWindowSystem, inTimeProvider); return *QT3DS_NEW(theCore->GetAllocator(), SRenderFactory)(*theCore); } diff --git a/src/Runtime/ogl-runtime/src/runtime/Qt3DSApplication.cpp b/src/Runtime/ogl-runtime/src/runtime/Qt3DSApplication.cpp index df2f00fa..8be219c1 100644 --- a/src/Runtime/ogl-runtime/src/runtime/Qt3DSApplication.cpp +++ b/src/Runtime/ogl-runtime/src/runtime/Qt3DSApplication.cpp @@ -337,7 +337,7 @@ struct STextureUploadRenderTask : public IRenderTask, public IImageLoadListener for (auto &s : qAsConst(m_uploadSet)) sourcePaths.push_back(m_bufferManager.GetStringTable().RegisterStr(s)); QT3DSU32 id = m_batchLoader.LoadImageBatch(sourcePaths, CRegisteredString(), - this, m_type, m_preferKtx); + this, m_type, m_preferKtx, false); if (id) m_batches[id] = m_uploadSet; } @@ -347,7 +347,7 @@ struct STextureUploadRenderTask : public IRenderTask, public IImageLoadListener for (auto &s : qAsConst(m_uploadWaitSet)) sourcePaths.push_back(m_bufferManager.GetStringTable().RegisterStr(s)); QT3DSU32 id = m_batchLoader.LoadImageBatch(sourcePaths, CRegisteredString(), - this, m_type, m_preferKtx); + this, m_type, m_preferKtx, false); if (id) { m_batchLoader.BlockUntilLoaded(id); m_bufferManager.loadSet(m_uploadWaitSet); diff --git a/src/Runtime/ogl-runtime/src/runtime/Qt3DSIScene.h b/src/Runtime/ogl-runtime/src/runtime/Qt3DSIScene.h index 7494ab0f..421fe9c4 100644 --- a/src/Runtime/ogl-runtime/src/runtime/Qt3DSIScene.h +++ b/src/Runtime/ogl-runtime/src/runtime/Qt3DSIScene.h @@ -146,11 +146,6 @@ public: // Base Interface virtual qt3ds::foundation::CRegisteredString RegisterStr(const char *inStr) = 0; - virtual Q3DStudio::INT32 - LoadImageBatch(qt3ds::foundation::CRegisteredString *inFullPaths, INT32 inNumPaths, - qt3ds::foundation::CRegisteredString inDefaultImage, - qt3ds::render::IImageLoadListener *inLoadCallback = nullptr) = 0; - virtual SMousePosition WindowToPresentation(const SMousePosition &inWindowPos) = 0; virtual void RegisterOffscreenRenderer(const char *inKey) = 0; diff --git a/src/Runtime/ogl-runtime/src/runtimerender/graphobjects/Qt3DSRenderImage.cpp b/src/Runtime/ogl-runtime/src/runtimerender/graphobjects/Qt3DSRenderImage.cpp index 1cbd6015..57e86ad6 100644 --- a/src/Runtime/ogl-runtime/src/runtimerender/graphobjects/Qt3DSRenderImage.cpp +++ b/src/Runtime/ogl-runtime/src/runtimerender/graphobjects/Qt3DSRenderImage.cpp @@ -99,6 +99,7 @@ bool SImage::ClearDirty(IBufferManager &inBufferManager, IOffscreenRenderManager || m_LoadedTextureData->m_path != QString::fromUtf8(m_ImagePath.c_str())) { if (m_LoadedTextureData) m_LoadedTextureData->m_callbacks.removeOne(this); + forIbl = forIbl || m_MappingMode == ImageMappingModes::LightProbe; m_LoadedTextureData = inBufferManager.CreateReloadableImage(m_ImagePath, false, forIbl); m_LoadedTextureData->m_callbacks.push_back(this); diff --git a/src/Runtime/ogl-runtime/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp b/src/Runtime/ogl-runtime/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp index e2cfbed1..72495cd9 100644 --- a/src/Runtime/ogl-runtime/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp +++ b/src/Runtime/ogl-runtime/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp @@ -109,6 +109,7 @@ struct SImageLoaderBatch QT3DSU32 m_NumImages; NVRenderContextType m_contextType; bool m_preferKTX; + bool m_ibl; // Called from main thread static SImageLoaderBatch *CreateLoaderBatch(SBatchLoader &inLoader, TImageBatchId inBatchId, @@ -116,13 +117,13 @@ struct SImageLoaderBatch CRegisteredString inImageTillLoaded, IImageLoadListener *inListener, NVRenderContextType contextType, - bool preferKTX); + bool preferKTX, bool ibl); // Called from main thread SImageLoaderBatch(SBatchLoader &inLoader, IImageLoadListener *inLoadListener, const TLoadingImageList &inImageList, TImageBatchId inBatchId, QT3DSU32 inImageCount, NVRenderContextType contextType, - bool preferKTX); + bool preferKTX, bool ibl); // Called from main thread ~SImageLoaderBatch(); @@ -262,7 +263,7 @@ struct SBatchLoader : public IImageBatchLoader CRegisteredString inImageTillLoaded, IImageLoadListener *inListener, NVRenderContextType contextType, - bool preferKTX) override + bool preferKTX, bool iblImages) override { if (inSourcePaths.size() == 0) return 0; @@ -277,7 +278,8 @@ struct SBatchLoader : public IImageBatchLoader } SImageLoaderBatch *theBatch(SImageLoaderBatch::CreateLoaderBatch( - *this, theBatchId, inSourcePaths, inImageTillLoaded, inListener, contextType, preferKTX)); + *this, theBatchId, inSourcePaths, inImageTillLoaded, inListener, contextType, + preferKTX, iblImages)); if (theBatch) { m_Batches.insert(eastl::make_pair(theBatchId, theBatch)); return theBatchId; @@ -406,14 +408,8 @@ void SLoadingImage::TaskCancelled(void *inImg) bool SBatchLoadedImage::Finalize(IBufferManager &inMgr) { if (m_Texture) { - // PKC : We'll look at the path location to see if the image is in the standard - // location for IBL light probes or a standard hdr format and decide to generate BSDF - // miplevels (if the image doesn't have - // mipmaps of its own that is). eastl::string thepath(m_SourcePath); - bool isIBL = (thepath.find(".hdr") != eastl::string::npos) - || (thepath.find("\\IBL\\") != eastl::string::npos) - || (thepath.find("/IBL/") != eastl::string::npos); + bool isIBL = this->m_Batch->m_ibl; inMgr.LoadRenderImage(m_SourcePath, *m_Texture, false, isIBL); inMgr.UnaliasImagePath(m_SourcePath); } @@ -435,7 +431,7 @@ SImageLoaderBatch::CreateLoaderBatch(SBatchLoader &inLoader, TImageBatchId inBat CRegisteredString inImageTillLoaded, IImageLoadListener *inListener, NVRenderContextType contextType, - bool preferKTX) + bool preferKTX, bool iblImages) { TLoadingImageList theImages; QT3DSU32 theLoadingImageCount = 0; @@ -473,7 +469,7 @@ SImageLoaderBatch::CreateLoaderBatch(SBatchLoader &inLoader, TImageBatchId inBat (SImageLoaderBatch *)inLoader.m_BatchPool.allocate(__FILE__, __LINE__); new (theBatch) SImageLoaderBatch(inLoader, inListener, theImages, inBatchId, theLoadingImageCount, - contextType, preferKTX); + contextType, preferKTX, iblImages); return theBatch; } return NULL; @@ -482,7 +478,7 @@ SImageLoaderBatch::CreateLoaderBatch(SBatchLoader &inLoader, TImageBatchId inBat SImageLoaderBatch::SImageLoaderBatch(SBatchLoader &inLoader, IImageLoadListener *inLoadListener, const TLoadingImageList &inImageList, TImageBatchId inBatchId, QT3DSU32 inImageCount, NVRenderContextType contextType, - bool preferKTX) + bool preferKTX, bool ibl) : m_Loader(inLoader) , m_LoadListener(inLoadListener) , m_LoadEvent(inLoader.m_Foundation.getAllocator()) @@ -494,6 +490,7 @@ SImageLoaderBatch::SImageLoaderBatch(SBatchLoader &inLoader, IImageLoadListener , m_NumImages(inImageCount) , m_contextType(contextType) , m_preferKTX(preferKTX) + , m_ibl(ibl) { for (TLoadingImageList::iterator iter = m_Images.begin(), end = m_Images.end(); iter != end; ++iter) { diff --git a/src/Runtime/ogl-runtime/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.h b/src/Runtime/ogl-runtime/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.h index bc1773ce..28059403 100644 --- a/src/Runtime/ogl-runtime/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.h +++ b/src/Runtime/ogl-runtime/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.h @@ -73,7 +73,7 @@ namespace render { CRegisteredString inImageTillLoaded, IImageLoadListener *inListener, NVRenderContextType type, - bool preferKTX) = 0; + bool preferKTX, bool iblImages) = 0; // Blocks if any of the images in the batch are in flight virtual void CancelImageBatchLoading(TImageBatchId inBatchId) = 0; // Blocks if the image is currently in-flight diff --git a/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParser.h b/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParser.h index c3b4611b..2b75f258 100644 --- a/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParser.h +++ b/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParser.h @@ -142,6 +142,7 @@ public: // Parse UIP file // so that it can do things like register images as opaque/transparent as well as preload // mesh files (and possibly font files). virtual NVConstDataRef<eastl::string> GetSourcePaths() const = 0; + virtual bool isIblImage(const eastl::string &sourcepath) const = 0; virtual QVector<QString> GetSlideSourcePaths() const = 0; diff --git a/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParserImpl.cpp b/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParserImpl.cpp index 9f7641b0..79876ba5 100644 --- a/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParserImpl.cpp +++ b/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParserImpl.cpp @@ -839,7 +839,7 @@ void CUIPParserImpl::AddStringAttribute(IPresentation &inPresentation, eastl::make_pair(SPropertyDesc(inAttStrName, ATTRIBUTETYPE_STRING), theValue)); if (CHash::HashAttribute(inAttStrName.c_str()) == Q3DStudio::ATTRIBUTE_SOURCEPATH && inValue && *inValue) - AddSourcePath(inValue); + AddSourcePath(inValue, false); } void CUIPParserImpl::AddElementRefAttribute(TPropertyDescAndValueList &outDescList, @@ -1076,8 +1076,15 @@ BOOL CUIPParserImpl::LoadSceneGraph(IPresentation &inPresentation, IDOMReader &i m_ParseElementManager.GetOrCreateElementData(theId, theType, theClass); const char8_t *theSourcePath; - if (inReader.UnregisteredAtt("sourcepath", theSourcePath)) - AddSourcePath(theSourcePath); + if (inReader.UnregisteredAtt("sourcepath", theSourcePath)) { + const char8_t *mapping; + bool ibl = false; + if (inReader.UnregisteredAtt("mappingmode", mapping)) { + if (QString::fromUtf8(mapping) == QLatin1String("Light Probe")) + ibl = true; + } + AddSourcePath(theSourcePath, ibl); + } TAttrMap &theList = theElementData.m_PropertyMap; @@ -2130,7 +2137,13 @@ BOOL CUIPParserImpl::LoadSlideElementAttrs(IPresentation &inPresentation, bool, bool isSet = AreEqual(inReader.GetNarrowElementName(), "Set"); const char8_t *sourcepath; if (inReader.UnregisteredAtt("sourcepath", sourcepath)) { - AddSourcePath(sourcepath); + const char8_t *mapping; + bool ibl = false; + if (inReader.UnregisteredAtt("mappingmode", mapping)) { + if (QString::fromUtf8(mapping) == QLatin1String("Light Probe")) + ibl = true; + } + AddSourcePath(sourcepath, ibl); theBuilder.AddSourcePath(sourcepath); m_slideSourcePaths.push_back(QString::fromLatin1(sourcepath)); } diff --git a/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParserImpl.h b/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParserImpl.h index 585dd857..bca984b4 100644 --- a/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParserImpl.h +++ b/src/Runtime/ogl-runtime/src/uipparser/Qt3DSUIPParserImpl.h @@ -428,7 +428,7 @@ protected: TStringSet m_SourcePathSet; TStringVector m_SourcePathList; - + TStringSet m_iblSources; QVector<QString> m_slideSourcePaths; struct SElementRefCache @@ -541,6 +541,11 @@ public: // Parse UIP file return m_slideSourcePaths; } + bool isIblImage(const eastl::string &sourcepath) const override + { + return m_iblSources.find(sourcepath) != m_iblSources.end(); + } + protected: // Operation BOOL LoadProjectSettings(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader); BOOL LoadClasses(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader); @@ -652,12 +657,14 @@ protected: void AddElementRefAttribute(TPropertyDescAndValueList &outDescList, CRegisteredString inAttStrName, SElement *inElement); - void AddSourcePath(const char *inValue) + void AddSourcePath(const char *inValue, bool ibl) { if (m_SourcePathSet.find(inValue) == m_SourcePathSet.end()) { m_SourcePathSet.insert(inValue); m_SourcePathList.push_back(eastl::string(inValue)); } + if (ibl && m_iblSources.find(inValue) == m_iblSources.end()) + m_iblSources.insert(inValue); } public: // |