From 4dbb1c8679d6b6dd7bfbd2a2c0cd60194911f0e7 Mon Sep 17 00:00:00 2001 From: assiduous Date: Wed, 25 Dec 2019 21:42:30 -0800 Subject: moved public public headers of GraphicsTools project to interface folder to make them available in installation --- Graphics/GraphicsTools/CMakeLists.txt | 29 ++- .../GraphicsTools/include/CommonlyUsedStates.h | 223 --------------------- Graphics/GraphicsTools/include/GraphicsUtilities.h | 53 ----- Graphics/GraphicsTools/include/ScreenCapture.h | 95 --------- Graphics/GraphicsTools/include/ShaderMacroHelper.h | 164 --------------- Graphics/GraphicsTools/include/TextureUploader.h | 88 -------- .../GraphicsTools/include/TextureUploaderBase.h | 103 ---------- .../GraphicsTools/include/TextureUploaderD3D11.h | 59 ------ .../include/TextureUploaderD3D12_Vk.h | 59 ------ Graphics/GraphicsTools/include/TextureUploaderGL.h | 59 ------ Graphics/GraphicsTools/include/pch.h | 24 --- .../GraphicsTools/interface/CommonlyUsedStates.h | 223 +++++++++++++++++++++ .../GraphicsTools/interface/GraphicsUtilities.h | 53 +++++ Graphics/GraphicsTools/interface/ScreenCapture.h | 95 +++++++++ .../GraphicsTools/interface/ShaderMacroHelper.h | 164 +++++++++++++++ Graphics/GraphicsTools/interface/TextureUploader.h | 88 ++++++++ .../GraphicsTools/interface/TextureUploaderBase.h | 103 ++++++++++ .../GraphicsTools/interface/TextureUploaderD3D11.h | 59 ++++++ .../interface/TextureUploaderD3D12_Vk.h | 59 ++++++ .../GraphicsTools/interface/TextureUploaderGL.h | 59 ++++++ Graphics/GraphicsTools/interface/pch.h | 24 +++ 21 files changed, 941 insertions(+), 942 deletions(-) delete mode 100644 Graphics/GraphicsTools/include/CommonlyUsedStates.h delete mode 100644 Graphics/GraphicsTools/include/GraphicsUtilities.h delete mode 100644 Graphics/GraphicsTools/include/ScreenCapture.h delete mode 100644 Graphics/GraphicsTools/include/ShaderMacroHelper.h delete mode 100644 Graphics/GraphicsTools/include/TextureUploader.h delete mode 100644 Graphics/GraphicsTools/include/TextureUploaderBase.h delete mode 100644 Graphics/GraphicsTools/include/TextureUploaderD3D11.h delete mode 100644 Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h delete mode 100644 Graphics/GraphicsTools/include/TextureUploaderGL.h delete mode 100644 Graphics/GraphicsTools/include/pch.h create mode 100644 Graphics/GraphicsTools/interface/CommonlyUsedStates.h create mode 100644 Graphics/GraphicsTools/interface/GraphicsUtilities.h create mode 100644 Graphics/GraphicsTools/interface/ScreenCapture.h create mode 100644 Graphics/GraphicsTools/interface/ShaderMacroHelper.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploader.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploaderBase.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploaderD3D11.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.h create mode 100644 Graphics/GraphicsTools/interface/TextureUploaderGL.h create mode 100644 Graphics/GraphicsTools/interface/pch.h (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/CMakeLists.txt b/Graphics/GraphicsTools/CMakeLists.txt index eebc2aa5..eb120586 100644 --- a/Graphics/GraphicsTools/CMakeLists.txt +++ b/Graphics/GraphicsTools/CMakeLists.txt @@ -2,14 +2,14 @@ cmake_minimum_required (VERSION 3.6) project(Diligent-GraphicsTools CXX) -set(INCLUDE - include/CommonlyUsedStates.h - include/GraphicsUtilities.h - include/pch.h - include/ScreenCapture.h - include/ShaderMacroHelper.h - include/TextureUploader.h - include/TextureUploaderBase.h +set(INTERFACE + interface/CommonlyUsedStates.h + interface/GraphicsUtilities.h + interface/pch.h + interface/ScreenCapture.h + interface/ShaderMacroHelper.h + interface/TextureUploader.h + interface/TextureUploaderBase.h ) set(SOURCE @@ -23,26 +23,26 @@ set(DEPENDENCIES) if(D3D11_SUPPORTED) list(APPEND SOURCE src/TextureUploaderD3D11.cpp) - list(APPEND INCLUDE include/TextureUploaderD3D11.h) + list(APPEND INTERFACE interface/TextureUploaderD3D11.h) list(APPEND DEPENDENCIES Diligent-GraphicsEngineD3D11Interface) endif() if(D3D12_SUPPORTED OR VULKAN_SUPPORTED) list(APPEND SOURCE src/TextureUploaderD3D12_Vk.cpp) - list(APPEND INCLUDE include/TextureUploaderD3D12_Vk.h) + list(APPEND INTERFACE interface/TextureUploaderD3D12_Vk.h) endif() if(GL_SUPPORTED OR GLES_SUPPORTED) list(APPEND SOURCE src/TextureUploaderGL.cpp) - list(APPEND INCLUDE include/TextureUploaderGL.h) + list(APPEND INTERFACE interface/TextureUploaderGL.h) list(APPEND DEPENDENCIES Diligent-GraphicsEngineOpenGLInterface) endif() -add_library(Diligent-GraphicsTools STATIC ${SOURCE} ${INCLUDE}) +add_library(Diligent-GraphicsTools STATIC ${SOURCE} ${INTERFACE}) target_include_directories(Diligent-GraphicsTools PUBLIC - include + interface PRIVATE ../GraphicsEngineD3DBase/include ) @@ -68,7 +68,6 @@ endif() set_common_target_properties(Diligent-GraphicsTools) source_group("src" FILES ${SOURCE}) -source_group("include" FILES ${INCLUDE}) source_group("interface" FILES ${INTERFACE}) set_target_properties(Diligent-GraphicsTools PROPERTIES @@ -77,4 +76,4 @@ set_target_properties(Diligent-GraphicsTools PROPERTIES if(DILIGENT_INSTALL_CORE) install_core_lib(Diligent-GraphicsTools) -endif() \ No newline at end of file +endif() diff --git a/Graphics/GraphicsTools/include/CommonlyUsedStates.h b/Graphics/GraphicsTools/include/CommonlyUsedStates.h deleted file mode 100644 index f52bd34d..00000000 --- a/Graphics/GraphicsTools/include/CommonlyUsedStates.h +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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 -/// Defines graphics engine utilities - -#include "../../GraphicsEngine/interface/GraphicsTypes.h" -#include "../../GraphicsEngine/interface/DepthStencilState.h" -#include "../../GraphicsEngine/interface/BlendState.h" -#include "../../GraphicsEngine/interface/RasterizerState.h" -#include "../../GraphicsEngine/interface/Sampler.h" - -namespace Diligent -{ - -// clang-format off - -// Common depth-stencil states -static const DepthStencilStateDesc DSS_Default{}; - -static const DepthStencilStateDesc DSS_DisableDepth -{ - False, // DepthEnable - False // DepthWriteEnable -}; - - -// Common rasterizer states -static const RasterizerStateDesc RS_Default{}; - -static const RasterizerStateDesc RS_SolidFillNoCull -{ - FILL_MODE_SOLID, - CULL_MODE_NONE -}; - -static const RasterizerStateDesc RS_WireFillNoCull -{ - FILL_MODE_WIREFRAME, - CULL_MODE_NONE -}; - - -// Blend states -static const BlendStateDesc BS_Default{}; - -static const BlendStateDesc BS_AlphaBlend = -{ - False, // AlphaToCoverageEnable - False, // IndependentBlendEnable - RenderTargetBlendDesc // Render Target 0 - { - True, // BlendEnable - False, // LogicOperationEnable - BLEND_FACTOR_SRC_ALPHA, // SrcBlend - BLEND_FACTOR_INV_SRC_ALPHA, // DestBlend - BLEND_OPERATION_ADD, // BlendOp - BLEND_FACTOR_SRC_ALPHA, // SrcBlendAlpha - BLEND_FACTOR_INV_SRC_ALPHA, // DestBlendAlpha - BLEND_OPERATION_ADD // BlendOpAlpha - } -}; - - -// Common sampler states -static const SamplerDesc Sam_LinearClamp -{ - FILTER_TYPE_LINEAR, - FILTER_TYPE_LINEAR, - FILTER_TYPE_LINEAR, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP -}; - -static const SamplerDesc Sam_PointClamp -{ - FILTER_TYPE_POINT, - FILTER_TYPE_POINT, - FILTER_TYPE_POINT, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP -}; - -static const SamplerDesc Sam_LinearMirror -{ - FILTER_TYPE_LINEAR, - FILTER_TYPE_LINEAR, - FILTER_TYPE_LINEAR, - TEXTURE_ADDRESS_MIRROR, - TEXTURE_ADDRESS_MIRROR, - TEXTURE_ADDRESS_MIRROR -}; - -static const SamplerDesc Sam_PointWrap -{ - FILTER_TYPE_POINT, - FILTER_TYPE_POINT, - FILTER_TYPE_POINT, - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_WRAP -}; - -static const SamplerDesc Sam_LinearWrap -{ - FILTER_TYPE_LINEAR, - FILTER_TYPE_LINEAR, - FILTER_TYPE_LINEAR, - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_WRAP -}; - -static const SamplerDesc Sam_ComparsionLinearClamp -{ - FILTER_TYPE_COMPARISON_LINEAR, - FILTER_TYPE_COMPARISON_LINEAR, - FILTER_TYPE_COMPARISON_LINEAR, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - SamplerDesc{}.MipLODBias, - SamplerDesc{}.MaxAnisotropy, - COMPARISON_FUNC_LESS -}; - -static const SamplerDesc Sam_Aniso2xClamp -{ - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - 0.f, // MipLODBias - 2 // MaxAnisotropy -}; - -static const SamplerDesc Sam_Aniso4xClamp -{ - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - 0.f, // MipLODBias - 4 // MaxAnisotropy -}; - -static const SamplerDesc Sam_Aniso8xClamp -{ - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - 0.f, // MipLODBias - 8 // MaxAnisotropy -}; - -static const SamplerDesc Sam_Aniso16xClamp -{ - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_CLAMP, - 0.f, // MipLODBias - 16 // MaxAnisotropy -}; - -static const SamplerDesc Sam_Aniso4xWrap -{ - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_WRAP, - 0.f, // MipLODBias - 4 // MaxAnisotropy -}; - -static const SamplerDesc Sam_Aniso8xWrap -{ - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - FILTER_TYPE_ANISOTROPIC, - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_WRAP, - 0.f, // MipLODBias - 8 // MaxAnisotropy -}; - -} diff --git a/Graphics/GraphicsTools/include/GraphicsUtilities.h b/Graphics/GraphicsTools/include/GraphicsUtilities.h deleted file mode 100644 index 8638d211..00000000 --- a/Graphics/GraphicsTools/include/GraphicsUtilities.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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 -/// Defines graphics engine utilities - -#include "../../GraphicsEngine/interface/Texture.h" -#include "../../GraphicsEngine/interface/Buffer.h" -#include "../../GraphicsEngine/interface/RenderDevice.h" - -namespace Diligent -{ - -void CreateUniformBuffer(IRenderDevice* pDevice, - Uint32 Size, - const Char* Name, - IBuffer** ppBuffer, - USAGE Usage = USAGE_DYNAMIC, - BIND_FLAGS BindFlags = BIND_UNIFORM_BUFFER, - CPU_ACCESS_FLAGS CPUAccessFlags = CPU_ACCESS_WRITE, - void* pInitialData = nullptr); - -void GenerateCheckerBoardPattern(Uint32 Width, - Uint32 Height, - TEXTURE_FORMAT Fmt, - Uint32 HorzCells, - Uint32 VertCells, - Uint8* pData, - Uint32 StrideInBytes); - -} // namespace Diligent diff --git a/Graphics/GraphicsTools/include/ScreenCapture.h b/Graphics/GraphicsTools/include/ScreenCapture.h deleted file mode 100644 index 019bfa2a..00000000 --- a/Graphics/GraphicsTools/include/ScreenCapture.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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/include/ShaderMacroHelper.h b/Graphics/GraphicsTools/include/ShaderMacroHelper.h deleted file mode 100644 index 44ea1290..00000000 --- a/Graphics/GraphicsTools/include/ShaderMacroHelper.h +++ /dev/null @@ -1,164 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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/include/TextureUploader.h b/Graphics/GraphicsTools/include/TextureUploader.h deleted file mode 100644 index a67c7b9b..00000000 --- a/Graphics/GraphicsTools/include/TextureUploader.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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/include/TextureUploaderBase.h b/Graphics/GraphicsTools/include/TextureUploaderBase.h deleted file mode 100644 index 6026d60b..00000000 --- a/Graphics/GraphicsTools/include/TextureUploaderBase.h +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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/include/TextureUploaderD3D11.h b/Graphics/GraphicsTools/include/TextureUploaderD3D11.h deleted file mode 100644 index 9de6d84e..00000000 --- a/Graphics/GraphicsTools/include/TextureUploaderD3D11.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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/include/TextureUploaderD3D12_Vk.h b/Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h deleted file mode 100644 index b3ca4bef..00000000 --- a/Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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/include/TextureUploaderGL.h b/Graphics/GraphicsTools/include/TextureUploaderGL.h deleted file mode 100644 index 8d4fb3b2..00000000 --- a/Graphics/GraphicsTools/include/TextureUploaderGL.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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/include/pch.h b/Graphics/GraphicsTools/include/pch.h deleted file mode 100644 index e8997cc7..00000000 --- a/Graphics/GraphicsTools/include/pch.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * 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/interface/CommonlyUsedStates.h b/Graphics/GraphicsTools/interface/CommonlyUsedStates.h new file mode 100644 index 00000000..f52bd34d --- /dev/null +++ b/Graphics/GraphicsTools/interface/CommonlyUsedStates.h @@ -0,0 +1,223 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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 +/// Defines graphics engine utilities + +#include "../../GraphicsEngine/interface/GraphicsTypes.h" +#include "../../GraphicsEngine/interface/DepthStencilState.h" +#include "../../GraphicsEngine/interface/BlendState.h" +#include "../../GraphicsEngine/interface/RasterizerState.h" +#include "../../GraphicsEngine/interface/Sampler.h" + +namespace Diligent +{ + +// clang-format off + +// Common depth-stencil states +static const DepthStencilStateDesc DSS_Default{}; + +static const DepthStencilStateDesc DSS_DisableDepth +{ + False, // DepthEnable + False // DepthWriteEnable +}; + + +// Common rasterizer states +static const RasterizerStateDesc RS_Default{}; + +static const RasterizerStateDesc RS_SolidFillNoCull +{ + FILL_MODE_SOLID, + CULL_MODE_NONE +}; + +static const RasterizerStateDesc RS_WireFillNoCull +{ + FILL_MODE_WIREFRAME, + CULL_MODE_NONE +}; + + +// Blend states +static const BlendStateDesc BS_Default{}; + +static const BlendStateDesc BS_AlphaBlend = +{ + False, // AlphaToCoverageEnable + False, // IndependentBlendEnable + RenderTargetBlendDesc // Render Target 0 + { + True, // BlendEnable + False, // LogicOperationEnable + BLEND_FACTOR_SRC_ALPHA, // SrcBlend + BLEND_FACTOR_INV_SRC_ALPHA, // DestBlend + BLEND_OPERATION_ADD, // BlendOp + BLEND_FACTOR_SRC_ALPHA, // SrcBlendAlpha + BLEND_FACTOR_INV_SRC_ALPHA, // DestBlendAlpha + BLEND_OPERATION_ADD // BlendOpAlpha + } +}; + + +// Common sampler states +static const SamplerDesc Sam_LinearClamp +{ + FILTER_TYPE_LINEAR, + FILTER_TYPE_LINEAR, + FILTER_TYPE_LINEAR, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP +}; + +static const SamplerDesc Sam_PointClamp +{ + FILTER_TYPE_POINT, + FILTER_TYPE_POINT, + FILTER_TYPE_POINT, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP +}; + +static const SamplerDesc Sam_LinearMirror +{ + FILTER_TYPE_LINEAR, + FILTER_TYPE_LINEAR, + FILTER_TYPE_LINEAR, + TEXTURE_ADDRESS_MIRROR, + TEXTURE_ADDRESS_MIRROR, + TEXTURE_ADDRESS_MIRROR +}; + +static const SamplerDesc Sam_PointWrap +{ + FILTER_TYPE_POINT, + FILTER_TYPE_POINT, + FILTER_TYPE_POINT, + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_WRAP +}; + +static const SamplerDesc Sam_LinearWrap +{ + FILTER_TYPE_LINEAR, + FILTER_TYPE_LINEAR, + FILTER_TYPE_LINEAR, + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_WRAP +}; + +static const SamplerDesc Sam_ComparsionLinearClamp +{ + FILTER_TYPE_COMPARISON_LINEAR, + FILTER_TYPE_COMPARISON_LINEAR, + FILTER_TYPE_COMPARISON_LINEAR, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + SamplerDesc{}.MipLODBias, + SamplerDesc{}.MaxAnisotropy, + COMPARISON_FUNC_LESS +}; + +static const SamplerDesc Sam_Aniso2xClamp +{ + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + 0.f, // MipLODBias + 2 // MaxAnisotropy +}; + +static const SamplerDesc Sam_Aniso4xClamp +{ + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + 0.f, // MipLODBias + 4 // MaxAnisotropy +}; + +static const SamplerDesc Sam_Aniso8xClamp +{ + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + 0.f, // MipLODBias + 8 // MaxAnisotropy +}; + +static const SamplerDesc Sam_Aniso16xClamp +{ + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_CLAMP, + 0.f, // MipLODBias + 16 // MaxAnisotropy +}; + +static const SamplerDesc Sam_Aniso4xWrap +{ + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_WRAP, + 0.f, // MipLODBias + 4 // MaxAnisotropy +}; + +static const SamplerDesc Sam_Aniso8xWrap +{ + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + FILTER_TYPE_ANISOTROPIC, + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_WRAP, + 0.f, // MipLODBias + 8 // MaxAnisotropy +}; + +} diff --git a/Graphics/GraphicsTools/interface/GraphicsUtilities.h b/Graphics/GraphicsTools/interface/GraphicsUtilities.h new file mode 100644 index 00000000..8638d211 --- /dev/null +++ b/Graphics/GraphicsTools/interface/GraphicsUtilities.h @@ -0,0 +1,53 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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 +/// Defines graphics engine utilities + +#include "../../GraphicsEngine/interface/Texture.h" +#include "../../GraphicsEngine/interface/Buffer.h" +#include "../../GraphicsEngine/interface/RenderDevice.h" + +namespace Diligent +{ + +void CreateUniformBuffer(IRenderDevice* pDevice, + Uint32 Size, + const Char* Name, + IBuffer** ppBuffer, + USAGE Usage = USAGE_DYNAMIC, + BIND_FLAGS BindFlags = BIND_UNIFORM_BUFFER, + CPU_ACCESS_FLAGS CPUAccessFlags = CPU_ACCESS_WRITE, + void* pInitialData = nullptr); + +void GenerateCheckerBoardPattern(Uint32 Width, + Uint32 Height, + TEXTURE_FORMAT Fmt, + Uint32 HorzCells, + Uint32 VertCells, + Uint8* pData, + Uint32 StrideInBytes); + +} // namespace Diligent diff --git a/Graphics/GraphicsTools/interface/ScreenCapture.h b/Graphics/GraphicsTools/interface/ScreenCapture.h new file mode 100644 index 00000000..019bfa2a --- /dev/null +++ b/Graphics/GraphicsTools/interface/ScreenCapture.h @@ -0,0 +1,95 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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 new file mode 100644 index 00000000..44ea1290 --- /dev/null +++ b/Graphics/GraphicsTools/interface/ShaderMacroHelper.h @@ -0,0 +1,164 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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 new file mode 100644 index 00000000..a67c7b9b --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploader.h @@ -0,0 +1,88 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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 new file mode 100644 index 00000000..6026d60b --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploaderBase.h @@ -0,0 +1,103 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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/TextureUploaderD3D11.h b/Graphics/GraphicsTools/interface/TextureUploaderD3D11.h new file mode 100644 index 00000000..9de6d84e --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploaderD3D11.h @@ -0,0 +1,59 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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/TextureUploaderD3D12_Vk.h b/Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.h new file mode 100644 index 00000000..b3ca4bef --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploaderD3D12_Vk.h @@ -0,0 +1,59 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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/TextureUploaderGL.h b/Graphics/GraphicsTools/interface/TextureUploaderGL.h new file mode 100644 index 00000000..8d4fb3b2 --- /dev/null +++ b/Graphics/GraphicsTools/interface/TextureUploaderGL.h @@ -0,0 +1,59 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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/pch.h b/Graphics/GraphicsTools/interface/pch.h new file mode 100644 index 00000000..e8997cc7 --- /dev/null +++ b/Graphics/GraphicsTools/interface/pch.h @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * 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 -- cgit v1.2.3