From 7781a276417d2b6c5dea68e820cec8907311ded7 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: 66b0db92e353312b6cf3d68526417b5fb77c0bef [formerly 897579017072102b658dc637b91bc52d80a061cd] [formerly 7685fb2c3c18c030ce5a3ac6a29129bd39de88c8 [formerly 7ba2bc156951247f5f7ba7ebfb3d65bced1731e7]] Former-commit-id: a1eb128bba2d28589a7988f6f98a860839c07cfe [formerly 1fed3d7b8cbc84c528ce27db61123ce8fc562e97] Former-commit-id: cc56728a6e0a6b84c4969850287109c8e92281cd --- 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 a311ff4cf1ab6aaafba82f13f04e59ddbc9da055 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: 87fdfb051158d241754eb6f1f811d12e88811a47 [formerly c5ae03d7168851330dd2c087c515c7d30ad863c7] [formerly 0f5debff94e6a37dde830975fd219daf82382d9d [formerly 42297b9b5af5b42e4c12146d930b6641425de8f4]] Former-commit-id: b93ecd34f72724806ea06c6d335a41c7dd1afacb [formerly ad14d199f3ee381221df118b4af2cd647ab8fc24] Former-commit-id: 805f20df11668bf73d35065e23c4912800850427 --- 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 c28ea576f05f25c28d8994556e612ce8dcb07517 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: 90e7b45bfa2ff0efaad03de9f8149b27d1de2059 [formerly 39c8a91094eee32da25ec9f46534552271befd30] [formerly 73bdf966290144c9d18ceb228c88d60d143f0b2f [formerly 7e2aefa781168e192b4ae15f6f8f34ba3ab484fa]] Former-commit-id: 67231fa9b439ea294b3f1e4f7cfe5888663978e3 [formerly 975ca5d0d4ff41d858643b824036fa6818551698] Former-commit-id: ef88d5479c2f2637b213caff7923e444cc4b143d --- 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: