From 66a258c60dd46d3693f467a2394bafb04a804006 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 26 Jan 2020 13:12:51 -0800 Subject: Renamed .h -> .hpp files in GLSLTools, GraphicsAccessories, and GraphicsTools projects --- Graphics/GraphicsTools/CMakeLists.txt | 20 +- .../GraphicsTools/interface/DurationQueryHelper.h | 103 ----------- .../interface/DurationQueryHelper.hpp | 103 +++++++++++ Graphics/GraphicsTools/interface/MapHelper.h | 202 --------------------- Graphics/GraphicsTools/interface/MapHelper.hpp | 202 +++++++++++++++++++++ .../GraphicsTools/interface/ScopedQueryHelper.h | 88 --------- .../GraphicsTools/interface/ScopedQueryHelper.hpp | 88 +++++++++ Graphics/GraphicsTools/interface/ScreenCapture.h | 99 ---------- Graphics/GraphicsTools/interface/ScreenCapture.hpp | 99 ++++++++++ .../GraphicsTools/interface/ShaderMacroHelper.h | 168 ----------------- .../GraphicsTools/interface/ShaderMacroHelper.hpp | 168 +++++++++++++++++ Graphics/GraphicsTools/interface/TextureUploader.h | 92 ---------- .../GraphicsTools/interface/TextureUploader.hpp | 92 ++++++++++ .../GraphicsTools/interface/TextureUploaderBase.h | 107 ----------- .../interface/TextureUploaderBase.hpp | 107 +++++++++++ .../GraphicsTools/interface/TextureUploaderD3D11.h | 63 ------- .../interface/TextureUploaderD3D11.hpp | 63 +++++++ .../interface/TextureUploaderD3D12_Vk.h | 63 ------- .../interface/TextureUploaderD3D12_Vk.hpp | 63 +++++++ .../GraphicsTools/interface/TextureUploaderGL.h | 63 ------- .../GraphicsTools/interface/TextureUploaderGL.hpp | 63 +++++++ Graphics/GraphicsTools/src/DurationQueryHelper.cpp | 2 +- Graphics/GraphicsTools/src/GraphicsUtilities.cpp | 2 +- Graphics/GraphicsTools/src/ScopedQueryHelper.cpp | 2 +- Graphics/GraphicsTools/src/ScreenCapture.cpp | 2 +- Graphics/GraphicsTools/src/TextureUploader.cpp | 6 +- .../GraphicsTools/src/TextureUploaderD3D11.cpp | 4 +- .../GraphicsTools/src/TextureUploaderD3D12_Vk.cpp | 4 +- Graphics/GraphicsTools/src/TextureUploaderGL.cpp | 4 +- 29 files changed, 1071 insertions(+), 1071 deletions(-) delete mode 100644 Graphics/GraphicsTools/interface/DurationQueryHelper.h create mode 100644 Graphics/GraphicsTools/interface/DurationQueryHelper.hpp delete mode 100644 Graphics/GraphicsTools/interface/MapHelper.h create mode 100644 Graphics/GraphicsTools/interface/MapHelper.hpp delete mode 100644 Graphics/GraphicsTools/interface/ScopedQueryHelper.h create mode 100644 Graphics/GraphicsTools/interface/ScopedQueryHelper.hpp delete mode 100644 Graphics/GraphicsTools/interface/ScreenCapture.h create mode 100644 Graphics/GraphicsTools/interface/ScreenCapture.hpp delete mode 100644 Graphics/GraphicsTools/interface/ShaderMacroHelper.h create mode 100644 Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp delete mode 100644 Graphics/GraphicsTools/interface/TextureUploader.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploader.hpp delete mode 100644 Graphics/GraphicsTools/interface/TextureUploaderBase.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploaderBase.hpp delete mode 100644 Graphics/GraphicsTools/interface/TextureUploaderD3D11.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploaderD3D11.hpp delete mode 100644 Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.hpp delete mode 100644 Graphics/GraphicsTools/interface/TextureUploaderGL.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploaderGL.hpp (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/CMakeLists.txt b/Graphics/GraphicsTools/CMakeLists.txt index db477aff..5858475b 100644 --- a/Graphics/GraphicsTools/CMakeLists.txt +++ b/Graphics/GraphicsTools/CMakeLists.txt @@ -4,15 +4,15 @@ project(Diligent-GraphicsTools CXX) set(INTERFACE interface/CommonlyUsedStates.h - interface/DurationQueryHelper.h + interface/DurationQueryHelper.hpp interface/GraphicsUtilities.h - interface/MapHelper.h + interface/MapHelper.hpp interface/pch.h - interface/ScopedQueryHelper.h - interface/ScreenCapture.h - interface/ShaderMacroHelper.h - interface/TextureUploader.h - interface/TextureUploaderBase.h + interface/ScopedQueryHelper.hpp + interface/ScreenCapture.hpp + interface/ShaderMacroHelper.hpp + interface/TextureUploader.hpp + interface/TextureUploaderBase.hpp ) set(SOURCE @@ -28,18 +28,18 @@ set(DEPENDENCIES) if(D3D11_SUPPORTED) list(APPEND SOURCE src/TextureUploaderD3D11.cpp) - list(APPEND INTERFACE interface/TextureUploaderD3D11.h) + list(APPEND INTERFACE interface/TextureUploaderD3D11.hpp) list(APPEND DEPENDENCIES Diligent-GraphicsEngineD3D11Interface) endif() if(D3D12_SUPPORTED OR VULKAN_SUPPORTED) list(APPEND SOURCE src/TextureUploaderD3D12_Vk.cpp) - list(APPEND INTERFACE interface/TextureUploaderD3D12_Vk.h) + list(APPEND INTERFACE interface/TextureUploaderD3D12_Vk.hpp) endif() if(GL_SUPPORTED OR GLES_SUPPORTED) list(APPEND SOURCE src/TextureUploaderGL.cpp) - list(APPEND INTERFACE interface/TextureUploaderGL.h) + list(APPEND INTERFACE interface/TextureUploaderGL.hpp) list(APPEND DEPENDENCIES Diligent-GraphicsEngineOpenGLInterface) endif() diff --git a/Graphics/GraphicsTools/interface/DurationQueryHelper.h b/Graphics/GraphicsTools/interface/DurationQueryHelper.h deleted file mode 100644 index b073a02a..00000000 --- a/Graphics/GraphicsTools/interface/DurationQueryHelper.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2019-2020 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 - -#include -#include - -#include "../../GraphicsEngine/interface/RenderDevice.h" -#include "../../GraphicsEngine/interface/DeviceContext.h" -#include "../../GraphicsEngine/interface/Query.h" -#include "../../../Common/interface/RefCntAutoPtr.h" - -namespace Diligent -{ - -/// Helper class to manage duration queries. -/// One DurationQueryHelper instance must be used once per frame. -class DurationQueryHelper -{ -public: - DurationQueryHelper(IRenderDevice* pDevice, - Uint32 NumQueriesToReserve, - Uint32 ExpectedQueryLimit = 5); - - // clang-format off - DurationQueryHelper (const DurationQueryHelper&) = delete; - DurationQueryHelper& operator=(const DurationQueryHelper&) = delete; - DurationQueryHelper (DurationQueryHelper&&) = default; - DurationQueryHelper& operator=(DurationQueryHelper&&) = delete; - // clang-format on - - - /// Begins a query. - - /// \param [in] pCtx - Context to record begin query command - /// - /// \remarks There must be exaclty one matching Begin() for every End() call, otherwise - /// the behavior is undefined. - void Begin(IDeviceContext* pCtx); - - - /// Ends a query and returns the duration, in seconds, if it is available. - - /// \param [in] pCtx - Context to record end query command. - /// \param [out] Duration - Variable where duration will be written to. - /// \return true if the data from the oldest query is available, and false otherwise. - /// - /// \remarks There must be exaclty one matching End() for every Begin() call, otherwise - /// the behavior is undefined. - bool End(IDeviceContext* pCtx, double& Duration); - -private: - RefCntAutoPtr m_pDevice; - - const Uint32 m_ExpectedQueryLimit; - - struct DurationQuery - { - DurationQuery(IRenderDevice* pDevice); - - // clang-format off - DurationQuery (const DurationQuery&) = delete; - DurationQuery& operator=(const DurationQuery&) = delete; - DurationQuery (DurationQuery&&) = default; - DurationQuery& operator=(DurationQuery&&) = default; - // clang-format on - - RefCntAutoPtr StartTimestamp; - RefCntAutoPtr EndTimestamp; - }; - void InitDurationQuery(DurationQuery& query); - - - std::deque m_PendingQueries; - std::vector m_AvailableQueries; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/DurationQueryHelper.hpp b/Graphics/GraphicsTools/interface/DurationQueryHelper.hpp new file mode 100644 index 00000000..b073a02a --- /dev/null +++ b/Graphics/GraphicsTools/interface/DurationQueryHelper.hpp @@ -0,0 +1,103 @@ +/* + * Copyright 2019-2020 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 + +#include +#include + +#include "../../GraphicsEngine/interface/RenderDevice.h" +#include "../../GraphicsEngine/interface/DeviceContext.h" +#include "../../GraphicsEngine/interface/Query.h" +#include "../../../Common/interface/RefCntAutoPtr.h" + +namespace Diligent +{ + +/// Helper class to manage duration queries. +/// One DurationQueryHelper instance must be used once per frame. +class DurationQueryHelper +{ +public: + DurationQueryHelper(IRenderDevice* pDevice, + Uint32 NumQueriesToReserve, + Uint32 ExpectedQueryLimit = 5); + + // clang-format off + DurationQueryHelper (const DurationQueryHelper&) = delete; + DurationQueryHelper& operator=(const DurationQueryHelper&) = delete; + DurationQueryHelper (DurationQueryHelper&&) = default; + DurationQueryHelper& operator=(DurationQueryHelper&&) = delete; + // clang-format on + + + /// Begins a query. + + /// \param [in] pCtx - Context to record begin query command + /// + /// \remarks There must be exaclty one matching Begin() for every End() call, otherwise + /// the behavior is undefined. + void Begin(IDeviceContext* pCtx); + + + /// Ends a query and returns the duration, in seconds, if it is available. + + /// \param [in] pCtx - Context to record end query command. + /// \param [out] Duration - Variable where duration will be written to. + /// \return true if the data from the oldest query is available, and false otherwise. + /// + /// \remarks There must be exaclty one matching End() for every Begin() call, otherwise + /// the behavior is undefined. + bool End(IDeviceContext* pCtx, double& Duration); + +private: + RefCntAutoPtr m_pDevice; + + const Uint32 m_ExpectedQueryLimit; + + struct DurationQuery + { + DurationQuery(IRenderDevice* pDevice); + + // clang-format off + DurationQuery (const DurationQuery&) = delete; + DurationQuery& operator=(const DurationQuery&) = delete; + DurationQuery (DurationQuery&&) = default; + DurationQuery& operator=(DurationQuery&&) = default; + // clang-format on + + RefCntAutoPtr StartTimestamp; + RefCntAutoPtr EndTimestamp; + }; + void InitDurationQuery(DurationQuery& query); + + + std::deque m_PendingQueries; + std::vector m_AvailableQueries; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/MapHelper.h b/Graphics/GraphicsTools/interface/MapHelper.h deleted file mode 100644 index 0206b057..00000000 --- a/Graphics/GraphicsTools/interface/MapHelper.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright 2019-2020 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 - -/// \file -/// Definition of the Diligent::MapHelper helper template class - -#include "../../../Platforms/Basic/interface/DebugUtilities.h" -#include "../../../Common/interface/RefCntAutoPtr.h" -#include "../../GraphicsEngine/interface/DeviceContext.h" -#include "../../GraphicsEngine/interface/Buffer.h" - -namespace Diligent -{ - -/// Facilitates resource mapping - -/// \tparam DataType - type of the mapped data. -/// -/// This class is designed to automate resource mapping/unmapping process. -/// The class automatically unmaps the resource when the class instance gets out of scope.\n -/// Usage example: -/// -/// { -/// MapHelper UniformData( pDeviceContext, pUniformBuff, MAP_WRITE, MAP_FLAG_DISCARD ); -/// UniformData[0] = UniformData[1] = UniformData[2] = UniformData[3] = 1; -/// } -template -class MapHelper -{ -public: - /// Initializes the class member with null values - // clang-format off - MapHelper() : - m_pBuffer {nullptr}, - m_pContext {nullptr}, - m_pMappedData {nullptr}, - m_MapType {static_cast(-1)}, - m_MapFlags {static_cast(-1) } - // clang-format on - { - } - - /// Initializes the object and maps the provided resource. - /// See Map() for details. - MapHelper(IDeviceContext* pContext, IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags) : - MapHelper() - { - Map(pContext, pBuffer, MapType, MapFlags); - } - - /// Move constructor: takes over resource ownership from Helper - // clang-format off - MapHelper(MapHelper&& Helper) : - m_pBuffer {std::move(Helper.m_pBuffer) }, - m_pMappedData {std::move(Helper.m_pMappedData)}, - m_pContext {std::move(Helper.m_pContext) }, - m_MapType {std::move(Helper.m_MapType) }, - m_MapFlags {std::move(Helper.m_MapFlags) } - // clang-format on - { - Helper.m_pBuffer = nullptr; - Helper.m_pContext = nullptr; - Helper.m_pMappedData = nullptr; - Helper.m_MapType = static_cast(-1); - Helper.m_MapFlags = static_cast(-1); - } - - /// Move-assignement operator: takes over resource ownership from Helper - MapHelper& operator=(MapHelper&& Helper) - { - m_pBuffer = std::move(Helper.m_pBuffer); - m_pMappedData = std::move(Helper.m_pMappedData); - m_pContext = std::move(Helper.m_pContext); - m_MapType = std::move(Helper.m_MapType); - m_MapFlags = std::move(Helper.m_MapFlags); - - Helper.m_pBuffer = nullptr; - Helper.m_pContext = nullptr; - Helper.m_pMappedData = nullptr; - Helper.m_MapType = static_cast(-1); - Helper.m_MapFlags = static_cast(-1); - - return *this; - } - - /// Maps the provided resource. - - /// \param pContext - Pointer to the device context to perform mapping with. - /// \param pBuffer - Pointer to the buffer interface to map. - /// \param MapType - Type of the map operation, see Diligent::MAP_TYPE for details. - /// \param MapFlags - Additional map flags, see Diligent::MAP_FLAGS. - void Map(IDeviceContext* pContext, IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags) - { - VERIFY(!m_pBuffer && !m_pMappedData && !m_pContext, "Object already mapped"); - Unmap(); -#ifdef _DEBUG - auto& BuffDesc = pBuffer->GetDesc(); - VERIFY(sizeof(DataType) <= BuffDesc.uiSizeInBytes, "Data type size exceeds buffer size"); -#endif - pContext->MapBuffer(pBuffer, MapType, MapFlags, (PVoid&)m_pMappedData); - if (m_pMappedData != nullptr) - { - m_pContext = pContext; - m_pBuffer = pBuffer; - m_MapType = MapType; - m_MapFlags = MapFlags; - } - } - - /// Unamps the resource and resets the object state to default. - void Unmap() - { - if (m_pBuffer) - { - m_pContext->UnmapBuffer(m_pBuffer, m_MapType); - m_pBuffer = nullptr; - m_MapType = static_cast(-1); - m_MapFlags = static_cast(-1); - } - m_pContext = nullptr; - m_pMappedData = nullptr; - } - - /// Converts mapped data pointer to DataType* - operator DataType*() { return m_pMappedData; } - - /// Converts mapped data pointer to const DataType* - operator const DataType*() const { return m_pMappedData; } - - /// Operator -> - DataType* operator->() { return m_pMappedData; } - - /// Operator const -> - const DataType* operator->() const { return m_pMappedData; } - - /// Unamps the resource - ~MapHelper() - { - Unmap(); - } - -private: - MapHelper(const MapHelper&); - MapHelper& operator=(const MapHelper&); - - template - struct PtrTypeSelector - {}; - - template - struct PtrTypeSelector - { - typedef RefCntAutoPtr Type; - }; - - template - struct PtrTypeSelector - { - typedef PtrType* Type; - }; - - /// Pointer / strong auto pointer to the resource - typename PtrTypeSelector::Type m_pBuffer; - - /// Pointer / strong auto pointer to the context - typename PtrTypeSelector::Type m_pContext; - - /// Pointer to the mapped data - DataType* m_pMappedData; - - MAP_TYPE m_MapType; - - Uint32 m_MapFlags; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/MapHelper.hpp b/Graphics/GraphicsTools/interface/MapHelper.hpp new file mode 100644 index 00000000..0206b057 --- /dev/null +++ b/Graphics/GraphicsTools/interface/MapHelper.hpp @@ -0,0 +1,202 @@ +/* + * Copyright 2019-2020 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 + +/// \file +/// Definition of the Diligent::MapHelper helper template class + +#include "../../../Platforms/Basic/interface/DebugUtilities.h" +#include "../../../Common/interface/RefCntAutoPtr.h" +#include "../../GraphicsEngine/interface/DeviceContext.h" +#include "../../GraphicsEngine/interface/Buffer.h" + +namespace Diligent +{ + +/// Facilitates resource mapping + +/// \tparam DataType - type of the mapped data. +/// +/// This class is designed to automate resource mapping/unmapping process. +/// The class automatically unmaps the resource when the class instance gets out of scope.\n +/// Usage example: +/// +/// { +/// MapHelper UniformData( pDeviceContext, pUniformBuff, MAP_WRITE, MAP_FLAG_DISCARD ); +/// UniformData[0] = UniformData[1] = UniformData[2] = UniformData[3] = 1; +/// } +template +class MapHelper +{ +public: + /// Initializes the class member with null values + // clang-format off + MapHelper() : + m_pBuffer {nullptr}, + m_pContext {nullptr}, + m_pMappedData {nullptr}, + m_MapType {static_cast(-1)}, + m_MapFlags {static_cast(-1) } + // clang-format on + { + } + + /// Initializes the object and maps the provided resource. + /// See Map() for details. + MapHelper(IDeviceContext* pContext, IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags) : + MapHelper() + { + Map(pContext, pBuffer, MapType, MapFlags); + } + + /// Move constructor: takes over resource ownership from Helper + // clang-format off + MapHelper(MapHelper&& Helper) : + m_pBuffer {std::move(Helper.m_pBuffer) }, + m_pMappedData {std::move(Helper.m_pMappedData)}, + m_pContext {std::move(Helper.m_pContext) }, + m_MapType {std::move(Helper.m_MapType) }, + m_MapFlags {std::move(Helper.m_MapFlags) } + // clang-format on + { + Helper.m_pBuffer = nullptr; + Helper.m_pContext = nullptr; + Helper.m_pMappedData = nullptr; + Helper.m_MapType = static_cast(-1); + Helper.m_MapFlags = static_cast(-1); + } + + /// Move-assignement operator: takes over resource ownership from Helper + MapHelper& operator=(MapHelper&& Helper) + { + m_pBuffer = std::move(Helper.m_pBuffer); + m_pMappedData = std::move(Helper.m_pMappedData); + m_pContext = std::move(Helper.m_pContext); + m_MapType = std::move(Helper.m_MapType); + m_MapFlags = std::move(Helper.m_MapFlags); + + Helper.m_pBuffer = nullptr; + Helper.m_pContext = nullptr; + Helper.m_pMappedData = nullptr; + Helper.m_MapType = static_cast(-1); + Helper.m_MapFlags = static_cast(-1); + + return *this; + } + + /// Maps the provided resource. + + /// \param pContext - Pointer to the device context to perform mapping with. + /// \param pBuffer - Pointer to the buffer interface to map. + /// \param MapType - Type of the map operation, see Diligent::MAP_TYPE for details. + /// \param MapFlags - Additional map flags, see Diligent::MAP_FLAGS. + void Map(IDeviceContext* pContext, IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags) + { + VERIFY(!m_pBuffer && !m_pMappedData && !m_pContext, "Object already mapped"); + Unmap(); +#ifdef _DEBUG + auto& BuffDesc = pBuffer->GetDesc(); + VERIFY(sizeof(DataType) <= BuffDesc.uiSizeInBytes, "Data type size exceeds buffer size"); +#endif + pContext->MapBuffer(pBuffer, MapType, MapFlags, (PVoid&)m_pMappedData); + if (m_pMappedData != nullptr) + { + m_pContext = pContext; + m_pBuffer = pBuffer; + m_MapType = MapType; + m_MapFlags = MapFlags; + } + } + + /// Unamps the resource and resets the object state to default. + void Unmap() + { + if (m_pBuffer) + { + m_pContext->UnmapBuffer(m_pBuffer, m_MapType); + m_pBuffer = nullptr; + m_MapType = static_cast(-1); + m_MapFlags = static_cast(-1); + } + m_pContext = nullptr; + m_pMappedData = nullptr; + } + + /// Converts mapped data pointer to DataType* + operator DataType*() { return m_pMappedData; } + + /// Converts mapped data pointer to const DataType* + operator const DataType*() const { return m_pMappedData; } + + /// Operator -> + DataType* operator->() { return m_pMappedData; } + + /// Operator const -> + const DataType* operator->() const { return m_pMappedData; } + + /// Unamps the resource + ~MapHelper() + { + Unmap(); + } + +private: + MapHelper(const MapHelper&); + MapHelper& operator=(const MapHelper&); + + template + struct PtrTypeSelector + {}; + + template + struct PtrTypeSelector + { + typedef RefCntAutoPtr Type; + }; + + template + struct PtrTypeSelector + { + typedef PtrType* Type; + }; + + /// Pointer / strong auto pointer to the resource + typename PtrTypeSelector::Type m_pBuffer; + + /// Pointer / strong auto pointer to the context + typename PtrTypeSelector::Type m_pContext; + + /// Pointer to the mapped data + DataType* m_pMappedData; + + MAP_TYPE m_MapType; + + Uint32 m_MapFlags; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/ScopedQueryHelper.h b/Graphics/GraphicsTools/interface/ScopedQueryHelper.h deleted file mode 100644 index 1a089e0a..00000000 --- a/Graphics/GraphicsTools/interface/ScopedQueryHelper.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2019-2020 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 - -#include -#include - -#include "../../GraphicsEngine/interface/RenderDevice.h" -#include "../../GraphicsEngine/interface/DeviceContext.h" -#include "../../GraphicsEngine/interface/Query.h" -#include "../../../Common/interface/RefCntAutoPtr.h" - -namespace Diligent -{ - -/// Helper class to manage scoped queries. -/// One scoped query instance must be used once per frame. -class ScopedQueryHelper -{ -public: - ScopedQueryHelper(IRenderDevice* pDevice, - const QueryDesc& queryDesc, - Uint32 NumQueriesToReserve, - Uint32 ExpectedQueryLimit = 5); - - // clang-format off - ScopedQueryHelper (const ScopedQueryHelper&) = delete; - ScopedQueryHelper& operator=(const ScopedQueryHelper&) = delete; - ScopedQueryHelper (ScopedQueryHelper&&) = default; - ScopedQueryHelper& operator=(ScopedQueryHelper&&) = delete; - // clang-format on - - - /// Begins a query. - - /// \param [in] pCtx - Context to record begin query command - /// - /// \remarks There must be exaclty one matching Begin() for every End() call, otherwise - /// the behavior is undefined. - void Begin(IDeviceContext* pCtx); - - - /// Ends a query and returns the query data, if it is available. - - /// \param [in] pCtx - Context to record end query command. - /// \param [out] pData - Pointer to the buffer that will receive query data. - /// \param [in] DataSize - Buffer data size. - /// \return true if the data from the oldest query is available, and false otherwise. - /// - /// \remarks There must be exaclty one matching End() for every Begin() call, otherwise - /// the behavior is undefined. - bool End(IDeviceContext* pCtx, void* pData, Uint32 DataSize); - -private: - RefCntAutoPtr m_pDevice; - const QueryDesc m_QueryDesc; - const Uint32 m_ExpectedQueryLimit; - - std::deque> m_PendingQueries; - std::vector> m_AvailableQueries; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/ScopedQueryHelper.hpp b/Graphics/GraphicsTools/interface/ScopedQueryHelper.hpp new file mode 100644 index 00000000..1a089e0a --- /dev/null +++ b/Graphics/GraphicsTools/interface/ScopedQueryHelper.hpp @@ -0,0 +1,88 @@ +/* + * Copyright 2019-2020 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 + +#include +#include + +#include "../../GraphicsEngine/interface/RenderDevice.h" +#include "../../GraphicsEngine/interface/DeviceContext.h" +#include "../../GraphicsEngine/interface/Query.h" +#include "../../../Common/interface/RefCntAutoPtr.h" + +namespace Diligent +{ + +/// Helper class to manage scoped queries. +/// One scoped query instance must be used once per frame. +class ScopedQueryHelper +{ +public: + ScopedQueryHelper(IRenderDevice* pDevice, + const QueryDesc& queryDesc, + Uint32 NumQueriesToReserve, + Uint32 ExpectedQueryLimit = 5); + + // clang-format off + ScopedQueryHelper (const ScopedQueryHelper&) = delete; + ScopedQueryHelper& operator=(const ScopedQueryHelper&) = delete; + ScopedQueryHelper (ScopedQueryHelper&&) = default; + ScopedQueryHelper& operator=(ScopedQueryHelper&&) = delete; + // clang-format on + + + /// Begins a query. + + /// \param [in] pCtx - Context to record begin query command + /// + /// \remarks There must be exaclty one matching Begin() for every End() call, otherwise + /// the behavior is undefined. + void Begin(IDeviceContext* pCtx); + + + /// Ends a query and returns the query data, if it is available. + + /// \param [in] pCtx - Context to record end query command. + /// \param [out] pData - Pointer to the buffer that will receive query data. + /// \param [in] DataSize - Buffer data size. + /// \return true if the data from the oldest query is available, and false otherwise. + /// + /// \remarks There must be exaclty one matching End() for every Begin() call, otherwise + /// the behavior is undefined. + bool End(IDeviceContext* pCtx, void* pData, Uint32 DataSize); + +private: + RefCntAutoPtr m_pDevice; + const QueryDesc m_QueryDesc; + const Uint32 m_ExpectedQueryLimit; + + std::deque> m_PendingQueries; + std::vector> m_AvailableQueries; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/ScreenCapture.h b/Graphics/GraphicsTools/interface/ScreenCapture.h deleted file mode 100644 index cb5f4bb6..00000000 --- a/Graphics/GraphicsTools/interface/ScreenCapture.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2019-2020 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 - -#include -#include -#include - -#include "../../GraphicsEngine/interface/SwapChain.h" -#include "../../GraphicsEngine/interface/RenderDevice.h" -#include "../../GraphicsEngine/interface/DeviceContext.h" -#include "../../../Common/interface/RefCntAutoPtr.h" - -namespace Diligent -{ - -class ScreenCapture -{ -public: - ScreenCapture(IRenderDevice* pDevice); - - void Capture(ISwapChain* pSwapChain, IDeviceContext* pContext, Uint32 FrameId); - - struct CaptureInfo - { - RefCntAutoPtr pTexture; - Uint32 Id = 0; - - operator bool() const - { - return pTexture != nullptr; - } - }; - - CaptureInfo GetCapture(); - bool HasCapture(); - - void RecycleStagingTexture(RefCntAutoPtr&& pTexture); - - size_t GetNumPendingCaptures() - { - std::lock_guard Lock{m_PendingTexturesMtx}; - return m_PendingTextures.size(); - } - -private: - RefCntAutoPtr m_pFence; - RefCntAutoPtr m_pDevice; - - std::mutex m_AvailableTexturesMtx; - std::vector> m_AvailableTextures; - - std::mutex m_PendingTexturesMtx; - struct PendingTextureInfo - { - PendingTextureInfo(RefCntAutoPtr&& _pTex, Uint32 _Id, Uint64 _Fence) : - // clang-format off - pTex {std::move(_pTex)}, - Id {_Id }, - Fence {_Fence } - // clang-format on - { - } - - RefCntAutoPtr pTex; - const Uint32 Id; - const Uint64 Fence; - }; - std::deque m_PendingTextures; - - Uint64 m_CurrentFenceValue = 1; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/ScreenCapture.hpp b/Graphics/GraphicsTools/interface/ScreenCapture.hpp new file mode 100644 index 00000000..cb5f4bb6 --- /dev/null +++ b/Graphics/GraphicsTools/interface/ScreenCapture.hpp @@ -0,0 +1,99 @@ +/* + * Copyright 2019-2020 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 + +#include +#include +#include + +#include "../../GraphicsEngine/interface/SwapChain.h" +#include "../../GraphicsEngine/interface/RenderDevice.h" +#include "../../GraphicsEngine/interface/DeviceContext.h" +#include "../../../Common/interface/RefCntAutoPtr.h" + +namespace Diligent +{ + +class ScreenCapture +{ +public: + ScreenCapture(IRenderDevice* pDevice); + + void Capture(ISwapChain* pSwapChain, IDeviceContext* pContext, Uint32 FrameId); + + struct CaptureInfo + { + RefCntAutoPtr pTexture; + Uint32 Id = 0; + + operator bool() const + { + return pTexture != nullptr; + } + }; + + CaptureInfo GetCapture(); + bool HasCapture(); + + void RecycleStagingTexture(RefCntAutoPtr&& pTexture); + + size_t GetNumPendingCaptures() + { + std::lock_guard Lock{m_PendingTexturesMtx}; + return m_PendingTextures.size(); + } + +private: + RefCntAutoPtr m_pFence; + RefCntAutoPtr m_pDevice; + + std::mutex m_AvailableTexturesMtx; + std::vector> m_AvailableTextures; + + std::mutex m_PendingTexturesMtx; + struct PendingTextureInfo + { + PendingTextureInfo(RefCntAutoPtr&& _pTex, Uint32 _Id, Uint64 _Fence) : + // clang-format off + pTex {std::move(_pTex)}, + Id {_Id }, + Fence {_Fence } + // clang-format on + { + } + + RefCntAutoPtr pTex; + const Uint32 Id; + const Uint64 Fence; + }; + std::deque m_PendingTextures; + + Uint64 m_CurrentFenceValue = 1; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/ShaderMacroHelper.h b/Graphics/GraphicsTools/interface/ShaderMacroHelper.h deleted file mode 100644 index f566b702..00000000 --- a/Graphics/GraphicsTools/interface/ShaderMacroHelper.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2019-2020 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. - */ - -//-------------------------------------------------------------------------------------- -// Copyright 2013 Intel Corporation -// All Rights Reserved -// -// Permission is granted to use, copy, distribute and prepare derivative works of this -// software for any purpose and without fee, provided, that the above copyright notice -// and this statement appear in all copies. Intel makes no representations about the -// suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS." -// INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY, -// INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE, -// INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not -// assume any responsibility for any errors which may appear in this software nor any -// responsibility to update it. -//-------------------------------------------------------------------------------------- -#pragma once - -#include -#include -#include -#include -#include "../../GraphicsEngine/interface/Shader.h" -#include "../../../Platforms/Basic/interface/DebugUtilities.h" - - -namespace Diligent -{ - -class ShaderMacroHelper -{ -public: - template - void AddShaderMacro(const Char* Name, DefintionType Definition) - { - std::ostringstream ss; - ss << Definition; - AddShaderMacro(Name, ss.str().c_str()); - } - - void Finalize() - { - if (!m_bIsFinalized) - { - m_Macros.emplace_back(nullptr, nullptr); - m_bIsFinalized = true; - } - } - - void Reopen() - { - if (m_bIsFinalized) - { - VERIFY_EXPR(m_Macros.size() > 0 && m_Macros.back().Name == nullptr && m_Macros.back().Definition == nullptr); - m_Macros.pop_back(); - m_bIsFinalized = false; - } - } - - void Clear() - { - m_Macros.clear(); - m_DefinitionsPool.clear(); - m_bIsFinalized = false; - } - - operator const ShaderMacro*() - { - if (m_Macros.size() > 0 && !m_bIsFinalized) - Finalize(); - return m_Macros.size() ? m_Macros.data() : nullptr; - } - - void RemoveMacro(const Char* Name) - { - size_t i = 0; - while (i < m_Macros.size() && m_Macros[i].Definition != nullptr) - { - if (strcmp(m_Macros[i].Name, Name) == 0) - { - m_Macros.erase(m_Macros.begin() + i); - break; - } - else - { - ++i; - } - } - } - - template - void UpdateMacro(const Char* Name, DefintionType Definition) - { - RemoveMacro(Name); - AddShaderMacro(Name, Definition); - } - -private: - std::vector m_Macros; - std::set m_DefinitionsPool; - bool m_bIsFinalized = false; -}; - -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); -} - -template <> -inline void ShaderMacroHelper::AddShaderMacro(const Char* Name, bool Definition) -{ - AddShaderMacro(Name, Definition ? "1" : "0"); -} - -template <> -inline void ShaderMacroHelper::AddShaderMacro(const Char* Name, float Definition) -{ - std::ostringstream ss; - - // Make sure that when floating point represents integer, it is still - // written as float: 1024.0, but not 1024. This is essnetial to - // avoid type conversion issues in GLES. - if (Definition == static_cast(static_cast(Definition))) - ss << std::fixed << std::setprecision(1); - - ss << Definition; - AddShaderMacro(Name, ss.str().c_str()); -} - -template <> -inline void ShaderMacroHelper::AddShaderMacro(const Char* Name, Uint32 Definition) -{ - // Make sure that uint constants have the 'u' suffix to avoid problems in GLES. - std::ostringstream ss; - ss << Definition << 'u'; - AddShaderMacro(Name, ss.str().c_str()); -} - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp b/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp new file mode 100644 index 00000000..f566b702 --- /dev/null +++ b/Graphics/GraphicsTools/interface/ShaderMacroHelper.hpp @@ -0,0 +1,168 @@ +/* + * Copyright 2019-2020 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. + */ + +//-------------------------------------------------------------------------------------- +// Copyright 2013 Intel Corporation +// All Rights Reserved +// +// Permission is granted to use, copy, distribute and prepare derivative works of this +// software for any purpose and without fee, provided, that the above copyright notice +// and this statement appear in all copies. Intel makes no representations about the +// suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS." +// INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY, +// INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE, +// INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not +// assume any responsibility for any errors which may appear in this software nor any +// responsibility to update it. +//-------------------------------------------------------------------------------------- +#pragma once + +#include +#include +#include +#include +#include "../../GraphicsEngine/interface/Shader.h" +#include "../../../Platforms/Basic/interface/DebugUtilities.h" + + +namespace Diligent +{ + +class ShaderMacroHelper +{ +public: + template + void AddShaderMacro(const Char* Name, DefintionType Definition) + { + std::ostringstream ss; + ss << Definition; + AddShaderMacro(Name, ss.str().c_str()); + } + + void Finalize() + { + if (!m_bIsFinalized) + { + m_Macros.emplace_back(nullptr, nullptr); + m_bIsFinalized = true; + } + } + + void Reopen() + { + if (m_bIsFinalized) + { + VERIFY_EXPR(m_Macros.size() > 0 && m_Macros.back().Name == nullptr && m_Macros.back().Definition == nullptr); + m_Macros.pop_back(); + m_bIsFinalized = false; + } + } + + void Clear() + { + m_Macros.clear(); + m_DefinitionsPool.clear(); + m_bIsFinalized = false; + } + + operator const ShaderMacro*() + { + if (m_Macros.size() > 0 && !m_bIsFinalized) + Finalize(); + return m_Macros.size() ? m_Macros.data() : nullptr; + } + + void RemoveMacro(const Char* Name) + { + size_t i = 0; + while (i < m_Macros.size() && m_Macros[i].Definition != nullptr) + { + if (strcmp(m_Macros[i].Name, Name) == 0) + { + m_Macros.erase(m_Macros.begin() + i); + break; + } + else + { + ++i; + } + } + } + + template + void UpdateMacro(const Char* Name, DefintionType Definition) + { + RemoveMacro(Name); + AddShaderMacro(Name, Definition); + } + +private: + std::vector m_Macros; + std::set m_DefinitionsPool; + bool m_bIsFinalized = false; +}; + +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); +} + +template <> +inline void ShaderMacroHelper::AddShaderMacro(const Char* Name, bool Definition) +{ + AddShaderMacro(Name, Definition ? "1" : "0"); +} + +template <> +inline void ShaderMacroHelper::AddShaderMacro(const Char* Name, float Definition) +{ + std::ostringstream ss; + + // Make sure that when floating point represents integer, it is still + // written as float: 1024.0, but not 1024. This is essnetial to + // avoid type conversion issues in GLES. + if (Definition == static_cast(static_cast(Definition))) + ss << std::fixed << std::setprecision(1); + + ss << Definition; + AddShaderMacro(Name, ss.str().c_str()); +} + +template <> +inline void ShaderMacroHelper::AddShaderMacro(const Char* Name, Uint32 Definition) +{ + // Make sure that uint constants have the 'u' suffix to avoid problems in GLES. + std::ostringstream ss; + ss << Definition << 'u'; + AddShaderMacro(Name, ss.str().c_str()); +} + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/TextureUploader.h b/Graphics/GraphicsTools/interface/TextureUploader.h deleted file mode 100644 index 021dbf67..00000000 --- a/Graphics/GraphicsTools/interface/TextureUploader.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2019-2020 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 - -#include "../../GraphicsEngine/interface/RenderDevice.h" -#include "../../GraphicsEngine/interface/DeviceContext.h" - -namespace Diligent -{ - -// clang-format off -struct UploadBufferDesc -{ - Uint32 Width = 0; - Uint32 Height = 0; - Uint32 Depth = 1; - Uint32 MipLevels = 1; - Uint32 ArraySize = 1; - TEXTURE_FORMAT Format = TEX_FORMAT_UNKNOWN; - - bool operator == (const UploadBufferDesc &rhs) const - { - return Width == rhs.Width && - Height == rhs.Height && - Depth == rhs.Depth && - Format == rhs.Format; - } -}; -// clang-format on - -class IUploadBuffer : public IObject -{ -public: - virtual void WaitForCopyScheduled() = 0; - virtual MappedTextureSubresource GetMappedData(Uint32 Mip, Uint32 Slice) = 0; - virtual const UploadBufferDesc& GetDesc() const = 0; -}; - -struct TextureUploaderDesc -{ -}; - -struct TextureUploaderStats -{ - Uint32 NumPendingOperations = 0; -}; - -class ITextureUploader : public IObject -{ -public: - virtual void RenderThreadUpdate(IDeviceContext* pContext) = 0; - - virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, - bool IsRenderThread, - IUploadBuffer** ppBuffer) = 0; - virtual void ScheduleGPUCopy(ITexture* pDstTexture, - Uint32 ArraySlice, - Uint32 MipLevel, - IUploadBuffer* pUploadBuffer) = 0; - virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) = 0; - - virtual TextureUploaderStats GetStats() = 0; -}; - -void CreateTextureUploader(IRenderDevice* pDevice, const TextureUploaderDesc& Desc, ITextureUploader** ppUploader); - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/TextureUploader.hpp b/Graphics/GraphicsTools/interface/TextureUploader.hpp new file mode 100644 index 00000000..021dbf67 --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploader.hpp @@ -0,0 +1,92 @@ +/* + * Copyright 2019-2020 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 + +#include "../../GraphicsEngine/interface/RenderDevice.h" +#include "../../GraphicsEngine/interface/DeviceContext.h" + +namespace Diligent +{ + +// clang-format off +struct UploadBufferDesc +{ + Uint32 Width = 0; + Uint32 Height = 0; + Uint32 Depth = 1; + Uint32 MipLevels = 1; + Uint32 ArraySize = 1; + TEXTURE_FORMAT Format = TEX_FORMAT_UNKNOWN; + + bool operator == (const UploadBufferDesc &rhs) const + { + return Width == rhs.Width && + Height == rhs.Height && + Depth == rhs.Depth && + Format == rhs.Format; + } +}; +// clang-format on + +class IUploadBuffer : public IObject +{ +public: + virtual void WaitForCopyScheduled() = 0; + virtual MappedTextureSubresource GetMappedData(Uint32 Mip, Uint32 Slice) = 0; + virtual const UploadBufferDesc& GetDesc() const = 0; +}; + +struct TextureUploaderDesc +{ +}; + +struct TextureUploaderStats +{ + Uint32 NumPendingOperations = 0; +}; + +class ITextureUploader : public IObject +{ +public: + virtual void RenderThreadUpdate(IDeviceContext* pContext) = 0; + + virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, + bool IsRenderThread, + IUploadBuffer** ppBuffer) = 0; + virtual void ScheduleGPUCopy(ITexture* pDstTexture, + Uint32 ArraySlice, + Uint32 MipLevel, + IUploadBuffer* pUploadBuffer) = 0; + virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) = 0; + + virtual TextureUploaderStats GetStats() = 0; +}; + +void CreateTextureUploader(IRenderDevice* pDevice, const TextureUploaderDesc& Desc, ITextureUploader** ppUploader); + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/TextureUploaderBase.h b/Graphics/GraphicsTools/interface/TextureUploaderBase.h deleted file mode 100644 index f48566f9..00000000 --- a/Graphics/GraphicsTools/interface/TextureUploaderBase.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2019-2020 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 - -#include - -#include "TextureUploader.h" -#include "../../../Common/interface/ObjectBase.h" -#include "../../../Common/interface/HashUtils.h" -#include "../../../Common/interface/RefCntAutoPtr.h" - -namespace std -{ - -template <> -struct hash -{ - size_t operator()(const Diligent::UploadBufferDesc& Desc) const - { - return Diligent::ComputeHash(Desc.Width, Desc.Height, Desc.Depth, static_cast(Desc.Format)); - } -}; - -} // namespace std - -namespace Diligent -{ -class UploadBufferBase : public ObjectBase -{ -public: - UploadBufferBase(IReferenceCounters* pRefCounters, const UploadBufferDesc& Desc) : - // clang-format off - ObjectBase{pRefCounters}, - m_Desc {Desc}, - m_MappedData (m_Desc.ArraySize * m_Desc.MipLevels) - // clang-format on - { - } - - virtual MappedTextureSubresource GetMappedData(Uint32 Mip, Uint32 Slice) override final - { - VERIFY_EXPR(Mip < m_Desc.MipLevels && Slice < m_Desc.ArraySize); - return m_MappedData[m_Desc.MipLevels * Slice + Mip]; - } - virtual const UploadBufferDesc& GetDesc() const override final { return m_Desc; } - - void SetMappedData(Uint32 Mip, Uint32 Slice, const MappedTextureSubresource& MappedData) - { - VERIFY_EXPR(Mip < m_Desc.MipLevels && Slice < m_Desc.ArraySize); - m_MappedData[m_Desc.MipLevels * Slice + Mip] = MappedData; - } - - bool IsMapped(Uint32 Mip, Uint32 Slice) const - { - VERIFY_EXPR(Mip < m_Desc.MipLevels && Slice < m_Desc.ArraySize); - return m_MappedData[m_Desc.MipLevels * Slice + Mip].pData != nullptr; - } - - void Reset() - { - for (auto& MappedData : m_MappedData) - MappedData = MappedTextureSubresource{}; - } - -protected: - const UploadBufferDesc m_Desc; - std::vector m_MappedData; -}; - -class TextureUploaderBase : public ObjectBase -{ -public: - TextureUploaderBase(IReferenceCounters* pRefCounters, IRenderDevice* pDevice, const TextureUploaderDesc Desc) : - ObjectBase{pRefCounters}, - m_pDevice{pDevice} - {} - -protected: - RefCntAutoPtr m_pDevice; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/TextureUploaderBase.hpp b/Graphics/GraphicsTools/interface/TextureUploaderBase.hpp new file mode 100644 index 00000000..7010cf12 --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploaderBase.hpp @@ -0,0 +1,107 @@ +/* + * Copyright 2019-2020 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 + +#include + +#include "TextureUploader.hpp" +#include "../../../Common/interface/ObjectBase.h" +#include "../../../Common/interface/HashUtils.h" +#include "../../../Common/interface/RefCntAutoPtr.h" + +namespace std +{ + +template <> +struct hash +{ + size_t operator()(const Diligent::UploadBufferDesc& Desc) const + { + return Diligent::ComputeHash(Desc.Width, Desc.Height, Desc.Depth, static_cast(Desc.Format)); + } +}; + +} // namespace std + +namespace Diligent +{ +class UploadBufferBase : public ObjectBase +{ +public: + UploadBufferBase(IReferenceCounters* pRefCounters, const UploadBufferDesc& Desc) : + // clang-format off + ObjectBase{pRefCounters}, + m_Desc {Desc}, + m_MappedData (m_Desc.ArraySize * m_Desc.MipLevels) + // clang-format on + { + } + + virtual MappedTextureSubresource GetMappedData(Uint32 Mip, Uint32 Slice) override final + { + VERIFY_EXPR(Mip < m_Desc.MipLevels && Slice < m_Desc.ArraySize); + return m_MappedData[m_Desc.MipLevels * Slice + Mip]; + } + virtual const UploadBufferDesc& GetDesc() const override final { return m_Desc; } + + void SetMappedData(Uint32 Mip, Uint32 Slice, const MappedTextureSubresource& MappedData) + { + VERIFY_EXPR(Mip < m_Desc.MipLevels && Slice < m_Desc.ArraySize); + m_MappedData[m_Desc.MipLevels * Slice + Mip] = MappedData; + } + + bool IsMapped(Uint32 Mip, Uint32 Slice) const + { + VERIFY_EXPR(Mip < m_Desc.MipLevels && Slice < m_Desc.ArraySize); + return m_MappedData[m_Desc.MipLevels * Slice + Mip].pData != nullptr; + } + + void Reset() + { + for (auto& MappedData : m_MappedData) + MappedData = MappedTextureSubresource{}; + } + +protected: + const UploadBufferDesc m_Desc; + std::vector m_MappedData; +}; + +class TextureUploaderBase : public ObjectBase +{ +public: + TextureUploaderBase(IReferenceCounters* pRefCounters, IRenderDevice* pDevice, const TextureUploaderDesc Desc) : + ObjectBase{pRefCounters}, + m_pDevice{pDevice} + {} + +protected: + RefCntAutoPtr m_pDevice; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/TextureUploaderD3D11.h b/Graphics/GraphicsTools/interface/TextureUploaderD3D11.h deleted file mode 100644 index 093ddb26..00000000 --- a/Graphics/GraphicsTools/interface/TextureUploaderD3D11.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2019-2020 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 - -#include "TextureUploaderBase.h" - -namespace Diligent -{ - -class TextureUploaderD3D11 : public TextureUploaderBase -{ -public: - TextureUploaderD3D11(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - const TextureUploaderDesc Desc); - ~TextureUploaderD3D11(); - - virtual void RenderThreadUpdate(IDeviceContext* pContext) override final; - - virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, - bool IsRenderThread, - IUploadBuffer** ppBuffer) override final; - - virtual void ScheduleGPUCopy(ITexture* pDstTexture, - Uint32 ArraySlice, - Uint32 MipLevel, - IUploadBuffer* pUploadBuffer) override final; - - virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) override final; - - virtual TextureUploaderStats GetStats() override final; - -private: - struct InternalData; - std::unique_ptr m_pInternalData; -}; - -} // namespace Diligent \ No newline at end of file diff --git a/Graphics/GraphicsTools/interface/TextureUploaderD3D11.hpp b/Graphics/GraphicsTools/interface/TextureUploaderD3D11.hpp new file mode 100644 index 00000000..fab896bd --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploaderD3D11.hpp @@ -0,0 +1,63 @@ +/* + * Copyright 2019-2020 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 + +#include "TextureUploaderBase.hpp" + +namespace Diligent +{ + +class TextureUploaderD3D11 : public TextureUploaderBase +{ +public: + TextureUploaderD3D11(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const TextureUploaderDesc Desc); + ~TextureUploaderD3D11(); + + virtual void RenderThreadUpdate(IDeviceContext* pContext) override final; + + virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, + bool IsRenderThread, + IUploadBuffer** ppBuffer) override final; + + virtual void ScheduleGPUCopy(ITexture* pDstTexture, + Uint32 ArraySlice, + Uint32 MipLevel, + IUploadBuffer* pUploadBuffer) override final; + + virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) override final; + + virtual TextureUploaderStats GetStats() override final; + +private: + struct InternalData; + std::unique_ptr m_pInternalData; +}; + +} // namespace Diligent \ No newline at end of file diff --git a/Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.h b/Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.h deleted file mode 100644 index 555a1d4a..00000000 --- a/Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2019-2020 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 - -#include "TextureUploaderBase.h" - -namespace Diligent -{ - -class TextureUploaderD3D12_Vk : public TextureUploaderBase -{ -public: - TextureUploaderD3D12_Vk(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - const TextureUploaderDesc Desc); - ~TextureUploaderD3D12_Vk(); - - virtual void RenderThreadUpdate(IDeviceContext* pContext) override final; - - virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, - bool IsRenderThread, - IUploadBuffer** ppBuffer) override final; - - virtual void ScheduleGPUCopy(ITexture* pDstTexture, - Uint32 ArraySlice, - Uint32 MipLevel, - IUploadBuffer* pUploadBuffer) override final; - - virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) override final; - - virtual TextureUploaderStats GetStats() override final; - -private: - struct InternalData; - std::unique_ptr m_pInternalData; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.hpp b/Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.hpp new file mode 100644 index 00000000..4fac42f3 --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.hpp @@ -0,0 +1,63 @@ +/* + * Copyright 2019-2020 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 + +#include "TextureUploaderBase.hpp" + +namespace Diligent +{ + +class TextureUploaderD3D12_Vk : public TextureUploaderBase +{ +public: + TextureUploaderD3D12_Vk(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const TextureUploaderDesc Desc); + ~TextureUploaderD3D12_Vk(); + + virtual void RenderThreadUpdate(IDeviceContext* pContext) override final; + + virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, + bool IsRenderThread, + IUploadBuffer** ppBuffer) override final; + + virtual void ScheduleGPUCopy(ITexture* pDstTexture, + Uint32 ArraySlice, + Uint32 MipLevel, + IUploadBuffer* pUploadBuffer) override final; + + virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) override final; + + virtual TextureUploaderStats GetStats() override final; + +private: + struct InternalData; + std::unique_ptr m_pInternalData; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/TextureUploaderGL.h b/Graphics/GraphicsTools/interface/TextureUploaderGL.h deleted file mode 100644 index 7ea1f1b2..00000000 --- a/Graphics/GraphicsTools/interface/TextureUploaderGL.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2019-2020 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 - -#include "TextureUploaderBase.h" - -namespace Diligent -{ - -class TextureUploaderGL : public TextureUploaderBase -{ -public: - TextureUploaderGL(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - const TextureUploaderDesc Desc); - ~TextureUploaderGL(); - - virtual void RenderThreadUpdate(IDeviceContext* pContext) override final; - - virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, - bool IsRenderThread, - IUploadBuffer** ppBuffer) override final; - - virtual void ScheduleGPUCopy(ITexture* pDstTexture, - Uint32 ArraySlice, - Uint32 MipLevel, - IUploadBuffer* pUploadBuffer) override final; - - virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) override final; - - virtual TextureUploaderStats GetStats() override final; - -private: - struct InternalData; - std::unique_ptr m_pInternalData; -}; - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/TextureUploaderGL.hpp b/Graphics/GraphicsTools/interface/TextureUploaderGL.hpp new file mode 100644 index 00000000..20be3213 --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploaderGL.hpp @@ -0,0 +1,63 @@ +/* + * Copyright 2019-2020 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 + +#include "TextureUploaderBase.hpp" + +namespace Diligent +{ + +class TextureUploaderGL : public TextureUploaderBase +{ +public: + TextureUploaderGL(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const TextureUploaderDesc Desc); + ~TextureUploaderGL(); + + virtual void RenderThreadUpdate(IDeviceContext* pContext) override final; + + virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, + bool IsRenderThread, + IUploadBuffer** ppBuffer) override final; + + virtual void ScheduleGPUCopy(ITexture* pDstTexture, + Uint32 ArraySlice, + Uint32 MipLevel, + IUploadBuffer* pUploadBuffer) override final; + + virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) override final; + + virtual TextureUploaderStats GetStats() override final; + +private: + struct InternalData; + std::unique_ptr m_pInternalData; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/src/DurationQueryHelper.cpp b/Graphics/GraphicsTools/src/DurationQueryHelper.cpp index 6f69bd0c..7bcb1358 100644 --- a/Graphics/GraphicsTools/src/DurationQueryHelper.cpp +++ b/Graphics/GraphicsTools/src/DurationQueryHelper.cpp @@ -26,7 +26,7 @@ */ #include "pch.h" -#include "DurationQueryHelper.h" +#include "DurationQueryHelper.hpp" namespace Diligent { diff --git a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp index 54032073..b2bf2c39 100644 --- a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp +++ b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp @@ -31,7 +31,7 @@ #include "GraphicsUtilities.h" #include "DebugUtilities.h" -#include "GraphicsAccessories.h" +#include "GraphicsAccessories.hpp" #include "ColorConversion.h" #define PI_F 3.1415926f diff --git a/Graphics/GraphicsTools/src/ScopedQueryHelper.cpp b/Graphics/GraphicsTools/src/ScopedQueryHelper.cpp index 236a6551..faf5dde1 100644 --- a/Graphics/GraphicsTools/src/ScopedQueryHelper.cpp +++ b/Graphics/GraphicsTools/src/ScopedQueryHelper.cpp @@ -26,7 +26,7 @@ */ #include "pch.h" -#include "ScopedQueryHelper.h" +#include "ScopedQueryHelper.hpp" namespace Diligent { diff --git a/Graphics/GraphicsTools/src/ScreenCapture.cpp b/Graphics/GraphicsTools/src/ScreenCapture.cpp index 40f6ce05..c75da007 100644 --- a/Graphics/GraphicsTools/src/ScreenCapture.cpp +++ b/Graphics/GraphicsTools/src/ScreenCapture.cpp @@ -26,7 +26,7 @@ */ #include "pch.h" -#include "ScreenCapture.h" +#include "ScreenCapture.hpp" namespace Diligent { diff --git a/Graphics/GraphicsTools/src/TextureUploader.cpp b/Graphics/GraphicsTools/src/TextureUploader.cpp index 0a2127bb..b7dc26b0 100644 --- a/Graphics/GraphicsTools/src/TextureUploader.cpp +++ b/Graphics/GraphicsTools/src/TextureUploader.cpp @@ -26,9 +26,9 @@ */ #include "pch.h" -#include "TextureUploaderD3D11.h" -#include "TextureUploaderD3D12_Vk.h" -#include "TextureUploaderGL.h" +#include "TextureUploaderD3D11.hpp" +#include "TextureUploaderD3D12_Vk.hpp" +#include "TextureUploaderGL.hpp" namespace Diligent { diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp index 8dc1be69..66fd91bc 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp @@ -34,13 +34,13 @@ #include #include -#include "TextureUploaderD3D11.h" +#include "TextureUploaderD3D11.hpp" #include "RenderDeviceD3D11.h" #include "DeviceContextD3D11.h" #include "TextureD3D11.h" #include "DXGITypeConversions.h" #include "ThreadSignal.h" -#include "GraphicsAccessories.h" +#include "GraphicsAccessories.hpp" namespace Diligent { diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp index 8bd279cf..9ff0063e 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp @@ -30,9 +30,9 @@ #include #include -#include "TextureUploaderD3D12_Vk.h" +#include "TextureUploaderD3D12_Vk.hpp" #include "ThreadSignal.h" -#include "GraphicsAccessories.h" +#include "GraphicsAccessories.hpp" namespace Diligent { diff --git a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp index 8d3a734e..8b1f2411 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp @@ -32,9 +32,9 @@ #include #include -#include "TextureUploaderGL.h" +#include "TextureUploaderGL.hpp" #include "ThreadSignal.h" -#include "GraphicsAccessories.h" +#include "GraphicsAccessories.hpp" #include "Align.h" namespace Diligent -- cgit v1.2.3