From 32aeb963784a484e01c87eababab2203f8217b0a Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 1 Sep 2016 13:02:46 +0200 Subject: [PATCH 1/3] Graphics: Clear instances in Clear method Former-commit-id: 8f116c954577de1e231efe5d0c6c34458e7c195c [formerly 0b07a41900b0cad6305956370a045dd1539e5634] [formerly 4eb1b81cf3b3e2badcf61032988f61ffe511a001 [formerly f016c785f246cead41c81130d04ffb2dfe61e42d]] Former-commit-id: 4f7fd53326b8b60c91d4e4edf53451561c7da7ad [formerly c80c94219ed09321ff35472cc9209e383f14cb59] Former-commit-id: 8e2ec06ccf7bee67a47ad73dce1132c33cc91a5e --- src/Nazara/Graphics/DeferredGeometryPass.cpp | 7 --- src/Nazara/Graphics/DeferredRenderQueue.cpp | 30 ++++++++++ src/Nazara/Graphics/ForwardRenderQueue.cpp | 56 +++++++++++++++++++ .../Graphics/ForwardRenderTechnique.cpp | 13 +---- 4 files changed, 88 insertions(+), 18 deletions(-) diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 1c4f8b8bb..dbdb95f5a 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -187,18 +187,11 @@ namespace Nz drawFunc(meshData.primitiveMode, 0, indexCount); } } - - instances.clear(); } } } - - // And we set it back data to zero - matEntry.enabled = false; } } - - pipelineEntry.maxInstanceCount = 0; } } } diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 7d214b217..41fb9d20b 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -278,6 +278,36 @@ namespace Nz Layer& layer = it->second; if (layer.clearCount++ >= 100) it = layers.erase(it); + else + { + for (auto& pipelinePair : layer.opaqueModels) + { + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.maxInstanceCount > 0) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + MeshInstanceContainer& meshInstances = matEntry.meshMap; + + for (auto& meshIt : meshInstances) + { + auto& meshEntry = meshIt.second; + + meshEntry.instances.clear(); + } + matEntry.enabled = false; + } + } + pipelineEntry.maxInstanceCount = 0; + } + } + } } } diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 882a6f61e..2de6b66e4 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -527,6 +527,62 @@ namespace Nz layers.erase(it++); else { + for (auto& pipelinePair : layer.basicSprites) + { + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.enabled) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + auto& overlayMap = matEntry.overlayMap; + for (auto& overlayIt : overlayMap) + { + const Texture* overlay = overlayIt.first; + auto& spriteChainVector = overlayIt.second.spriteChains; + + spriteChainVector.clear(); + } + + matEntry.enabled = false; + } + } + pipelineEntry.enabled = false; + } + } + + for (auto& pipelinePair : layer.opaqueModels) + { + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.maxInstanceCount > 0) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + MeshInstanceContainer& meshInstances = matEntry.meshMap; + + for (auto& meshIt : meshInstances) + { + auto& meshEntry = meshIt.second; + + meshEntry.instances.clear(); + } + matEntry.enabled = false; + } + } + pipelineEntry.maxInstanceCount = 0; + } + } + layer.otherDrawables.clear(); layer.transparentModels.clear(); layer.transparentModelData.clear(); diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 91507ee68..959ef2f03 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -386,17 +386,12 @@ namespace Nz vertexMapper.Unmap(); Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); - } while (spriteChain < spriteChainCount); - - spriteChainVector.clear(); + } + while (spriteChain < spriteChainCount); } } - - // We set it back to zero - matEntry.enabled = false; } } - pipelineEntry.enabled = false; } } } @@ -781,12 +776,8 @@ namespace Nz instances.clear(); } } - - matEntry.enabled = false; } } - - pipelineEntry.maxInstanceCount = 0; } } } From 88615eae8579becd37c501340053571b19bb92a7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 3 Sep 2016 21:13:00 +0200 Subject: [PATCH 2/3] Graphics/DeferredRenderQueue: Fix crash on layer removal Former-commit-id: 42859917e1603acb297e0dec88d91ea673698bc7 [formerly 416ca6e56e3d19c57bbd22df7c0ee760bdc85449] [formerly b405620cd6b4ebe4413d13abd1082d68eb9d7203 [formerly 38b249271c7366e767111de1bb98bb63e0b86e93]] Former-commit-id: fb61d2d9bb16752c0e2ea9fbba3d8e61a138039d [formerly 5ef5905f3c64859d87425b76342acd6cc562ce5d] Former-commit-id: 36ab2a4d8a66737af06634dc2f79da1f9d6b5662 --- src/Nazara/Graphics/DeferredRenderQueue.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 41fb9d20b..b240edcd7 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -273,7 +273,7 @@ namespace Nz layers.clear(); else { - for (auto it = layers.begin(); it != layers.end(); ++it) + for (auto it = layers.begin(); it != layers.end();) { Layer& layer = it->second; if (layer.clearCount++ >= 100) @@ -307,6 +307,8 @@ namespace Nz pipelineEntry.maxInstanceCount = 0; } } + + ++it; } } } From bff78868ba7c5e345a13faa8c8b5dbddcb8018c6 Mon Sep 17 00:00:00 2001 From: Ardakaniz Date: Sun, 4 Sep 2016 14:50:38 +0200 Subject: [PATCH 3/3] Utility/EventHandler: Fix OnMouseButtonReleased event Former-commit-id: 813e5fed6c8b929ef54db8c1caac2ebc22584404 [formerly c972de08f65603b9d5d29a6926b206cecc274683] [formerly ae54b811c39ad784a31b2ad7b24b9f6dc1a9f364 [formerly f8c20591aea42393489846f97f2e690366605077]] Former-commit-id: 43bb11a52d9ab0cb187998f1b77aa9d6e4c4953f [formerly b83192de7f3d383904655d88552ca510d5e9090d] Former-commit-id: caa0cb2030e4d178b3f5c9a7ebdc33a804ea655a --- include/Nazara/Utility/EventHandler.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl index c066b6810..719ffddcb 100644 --- a/include/Nazara/Utility/EventHandler.inl +++ b/include/Nazara/Utility/EventHandler.inl @@ -43,7 +43,7 @@ namespace Nz break; case WindowEventType_MouseButtonReleased: - OnMouseButtonPressed(this, event.mouseButton); + OnMouseButtonReleased(this, event.mouseButton); break; case WindowEventType_MouseEntered: