From 0fa8afbd58e315c1a2e66212a8d0ca4a0086e462 Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 1 Feb 2021 20:51:39 -0800 Subject: Reworked ShaderResourceLayoutTest.Textures and ShaderResourceLayoutTest.ImmutableSamplers to be more robust --- Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp b/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp index 8688ce46..207d9020 100644 --- a/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp +++ b/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp @@ -95,7 +95,7 @@ public: void Clear() { m_Macros.clear(); - m_DefinitionsPool.clear(); + m_StringPool.clear(); m_bIsFinalized = false; } @@ -132,7 +132,7 @@ public: private: std::vector m_Macros; - std::set m_DefinitionsPool; + std::set m_StringPool; bool m_bIsFinalized = false; }; @@ -140,14 +140,15 @@ template <> inline void ShaderMacroHelper::AddShaderMacro(const Char* Name, const Char* Definition) { Reopen(); - auto* PooledDefinition = m_DefinitionsPool.insert(Definition).first->c_str(); - m_Macros.emplace_back(Name, PooledDefinition); + const auto* PooledDefinition = m_StringPool.insert(Definition).first->c_str(); + const auto* PooledName = m_StringPool.insert(Name).first->c_str(); + m_Macros.emplace_back(PooledName, PooledDefinition); } template <> inline void ShaderMacroHelper::AddShaderMacro(const Char* Name, bool Definition) { - AddShaderMacro(Name, Definition ? "1" : "0"); + AddShaderMacro(Name, Definition ? "1" : "0"); } template <> -- cgit v1.2.3 From c0246cc70ac5c46671b08439fa2d16a007a7ffe9 Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 1 Feb 2021 23:09:07 -0800 Subject: Reworked ShaderResourceLayoutTest.FormattedBuffers and ShaderResourceLayoutTest.StructuredBuffers to make them more robust --- Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp b/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp index 207d9020..ed1a48ff 100644 --- a/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp +++ b/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp @@ -73,6 +73,15 @@ public: AddShaderMacro(Name, ss.str().c_str()); } + ShaderMacroHelper() = default; + + // NB: string pointers in m_Macros may become invalid after the + // copy or move due to short string optimization in std::string + ShaderMacroHelper(const ShaderMacroHelper&) = delete; + ShaderMacroHelper(ShaderMacroHelper&&) = delete; + ShaderMacroHelper& operator=(const ShaderMacroHelper&) = delete; + ShaderMacroHelper& operator=(ShaderMacroHelper&&) = delete; + void Finalize() { if (!m_bIsFinalized) -- cgit v1.2.3 From f355307ba47674a450b0a7f696031f58661cee47 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 5 Feb 2021 19:30:40 -0800 Subject: GraphicsTools: removed pch.h (fixed https://github.com/DiligentGraphics/DiligentCore/issues/187) --- Graphics/GraphicsTools/CMakeLists.txt | 2 -- Graphics/GraphicsTools/interface/pch.h | 28 ---------------------- Graphics/GraphicsTools/src/DurationQueryHelper.cpp | 1 - Graphics/GraphicsTools/src/GraphicsUtilities.cpp | 1 - Graphics/GraphicsTools/src/ScopedQueryHelper.cpp | 1 - Graphics/GraphicsTools/src/ScreenCapture.cpp | 1 - Graphics/GraphicsTools/src/TextureUploader.cpp | 1 - .../GraphicsTools/src/TextureUploaderD3D11.cpp | 2 -- Graphics/GraphicsTools/src/TextureUploaderGL.cpp | 1 - Graphics/GraphicsTools/src/pch.cpp | 28 ---------------------- 10 files changed, 66 deletions(-) delete mode 100644 Graphics/GraphicsTools/interface/pch.h delete mode 100644 Graphics/GraphicsTools/src/pch.cpp (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/CMakeLists.txt b/Graphics/GraphicsTools/CMakeLists.txt index aeb4131f..09728c33 100644 --- a/Graphics/GraphicsTools/CMakeLists.txt +++ b/Graphics/GraphicsTools/CMakeLists.txt @@ -10,7 +10,6 @@ set(INTERFACE interface/DurationQueryHelper.hpp interface/GraphicsUtilities.h interface/MapHelper.hpp - interface/pch.h interface/ScopedQueryHelper.hpp interface/ScreenCapture.hpp interface/ShaderMacroHelper.hpp @@ -27,7 +26,6 @@ set(SOURCE src/GraphicsUtilities.cpp src/ScopedQueryHelper.cpp src/ScreenCapture.cpp - src/pch.cpp src/TextureUploader.cpp ) diff --git a/Graphics/GraphicsTools/interface/pch.h b/Graphics/GraphicsTools/interface/pch.h deleted file mode 100644 index d3fa402f..00000000 --- a/Graphics/GraphicsTools/interface/pch.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2019-2021 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once diff --git a/Graphics/GraphicsTools/src/DurationQueryHelper.cpp b/Graphics/GraphicsTools/src/DurationQueryHelper.cpp index ed6d0b64..1af4bb18 100644 --- a/Graphics/GraphicsTools/src/DurationQueryHelper.cpp +++ b/Graphics/GraphicsTools/src/DurationQueryHelper.cpp @@ -25,7 +25,6 @@ * of the possibility of such damages. */ -#include "pch.h" #include "DurationQueryHelper.hpp" namespace Diligent diff --git a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp index c6f798d2..2226d790 100644 --- a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp +++ b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp @@ -25,7 +25,6 @@ * of the possibility of such damages. */ -#include "pch.h" #include #include diff --git a/Graphics/GraphicsTools/src/ScopedQueryHelper.cpp b/Graphics/GraphicsTools/src/ScopedQueryHelper.cpp index 9b7e6a6e..f03f4d32 100644 --- a/Graphics/GraphicsTools/src/ScopedQueryHelper.cpp +++ b/Graphics/GraphicsTools/src/ScopedQueryHelper.cpp @@ -25,7 +25,6 @@ * of the possibility of such damages. */ -#include "pch.h" #include "ScopedQueryHelper.hpp" namespace Diligent diff --git a/Graphics/GraphicsTools/src/ScreenCapture.cpp b/Graphics/GraphicsTools/src/ScreenCapture.cpp index e1b18c88..5d37560e 100644 --- a/Graphics/GraphicsTools/src/ScreenCapture.cpp +++ b/Graphics/GraphicsTools/src/ScreenCapture.cpp @@ -25,7 +25,6 @@ * of the possibility of such damages. */ -#include "pch.h" #include "ScreenCapture.hpp" namespace Diligent diff --git a/Graphics/GraphicsTools/src/TextureUploader.cpp b/Graphics/GraphicsTools/src/TextureUploader.cpp index 622945ca..0d27f62a 100644 --- a/Graphics/GraphicsTools/src/TextureUploader.cpp +++ b/Graphics/GraphicsTools/src/TextureUploader.cpp @@ -25,7 +25,6 @@ * of the possibility of such damages. */ -#include "pch.h" #if D3D11_SUPPORTED # include "TextureUploaderD3D11.hpp" #endif diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp index 76eec864..91c47512 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp @@ -25,8 +25,6 @@ * of the possibility of such damages. */ -#include "pch.h" - #include #include #include diff --git a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp index 34c4789f..0fabd561 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp @@ -25,7 +25,6 @@ * of the possibility of such damages. */ -#include "pch.h" #include #include #include diff --git a/Graphics/GraphicsTools/src/pch.cpp b/Graphics/GraphicsTools/src/pch.cpp deleted file mode 100644 index 8f74c6f2..00000000 --- a/Graphics/GraphicsTools/src/pch.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2019-2021 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "pch.h" -- cgit v1.2.3