From 2b64f003622ee7871fd7aec041622427dd2fc88f Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 19 Aug 2016 23:35:47 -0700 Subject: Updated to Diligent Engine 2.0 --- .../GraphicsTools/build/UWP/GraphicsTools.vcxproj | 200 +++++++++++++++ .../build/UWP/GraphicsTools.vcxproj.filters | 2 + .../build/Win32/GraphicsTools-Debug.vgdbsettings | 76 ++++++ .../build/Win32/GraphicsTools-Release.vgdbsettings | 76 ++++++ .../build/Win32/GraphicsTools.vcxproj | 173 +++++++++++++ .../build/Win32/GraphicsTools.vcxproj.filters | 32 +++ Graphics/GraphicsTools/build/Win32/jni/Android.mk | 25 ++ .../GraphicsTools/build/Win32/jni/Application.mk | 7 + .../Windows.Shared/GraphicsTools.Shared.vcxitems | 40 +++ .../GraphicsTools.Shared.vcxitems.filters | 48 ++++ .../build/Windows.Shared/GraphicsTools.props | 20 ++ .../GraphicsTools/build/Windows/EngineRoot.props | 18 -- .../build/Windows/GraphicsTools-Debug.vgdbsettings | 76 ------ .../Windows/GraphicsTools-Release.vgdbsettings | 76 ------ .../build/Windows/GraphicsTools.props | 10 - .../build/Windows/GraphicsTools.vcxproj | 181 -------------- .../build/Windows/GraphicsTools.vcxproj.filters | 32 --- .../GraphicsTools/build/Windows/jni/Android.mk | 25 -- .../GraphicsTools/build/Windows/jni/Application.mk | 7 - .../build/WindowsStore/EngineRoot.props | 18 -- .../GraphicsTools.Shared.vcxitems | 32 --- .../GraphicsTools.Shared.vcxitems.filters | 36 --- .../GraphicsTools.Windows.vcxproj | 205 --------------- .../GraphicsTools.Windows.vcxproj.filters | 5 - .../GraphicsTools.WindowsPhone.vcxproj | 144 ----------- .../GraphicsTools.WindowsPhone.vcxproj.filters | 5 - .../include/BasicShaderSourceStreamFactory.h | 2 +- .../GraphicsTools/include/FreeBlockListManager.h | 276 +++++++++++++++++++++ .../include/FreeBlockListManagerGPU.h | 85 +++++++ Graphics/GraphicsTools/include/GraphicsUtilities.h | 35 ++- Graphics/GraphicsTools/include/RingBuffer.h | 181 ++++++++++++++ Graphics/GraphicsTools/include/ShaderMacroHelper.h | 2 +- Graphics/GraphicsTools/include/pch.h | 2 +- .../src/BasicShaderSourceStreamFactory.cpp | 2 +- Graphics/GraphicsTools/src/GraphicsUtilities.cpp | 103 ++++---- Graphics/GraphicsTools/src/pch.cpp | 2 +- 36 files changed, 1326 insertions(+), 933 deletions(-) create mode 100644 Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj create mode 100644 Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj.filters create mode 100644 Graphics/GraphicsTools/build/Win32/GraphicsTools-Debug.vgdbsettings create mode 100644 Graphics/GraphicsTools/build/Win32/GraphicsTools-Release.vgdbsettings create mode 100644 Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj create mode 100644 Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj.filters create mode 100644 Graphics/GraphicsTools/build/Win32/jni/Android.mk create mode 100644 Graphics/GraphicsTools/build/Win32/jni/Application.mk create mode 100644 Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.Shared.vcxitems create mode 100644 Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.Shared.vcxitems.filters create mode 100644 Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.props delete mode 100644 Graphics/GraphicsTools/build/Windows/EngineRoot.props delete mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings delete mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings delete mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools.props delete mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj delete mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters delete mode 100644 Graphics/GraphicsTools/build/Windows/jni/Android.mk delete mode 100644 Graphics/GraphicsTools/build/Windows/jni/Application.mk delete mode 100644 Graphics/GraphicsTools/build/WindowsStore/EngineRoot.props delete mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems delete mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems.filters delete mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj delete mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj.filters delete mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj delete mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj.filters create mode 100644 Graphics/GraphicsTools/include/FreeBlockListManager.h create mode 100644 Graphics/GraphicsTools/include/FreeBlockListManagerGPU.h create mode 100644 Graphics/GraphicsTools/include/RingBuffer.h (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj b/Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj new file mode 100644 index 00000000..ae79dc6f --- /dev/null +++ b/Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj @@ -0,0 +1,200 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {7a1a6e2c-3952-4a57-ad30-abd92aa39c69} + StaticLibrary + GraphicsTools + en-US + 14.0 + true + Windows Store + 10.0.10586.0 + 10.0.10240.0 + 10.0 + + + + StaticLibrary + true + v140 + + + StaticLibrary + true + v140 + + + StaticLibrary + true + v140 + + + StaticLibrary + false + true + v140 + + + StaticLibrary + false + true + v140 + + + StaticLibrary + false + true + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + false + + + false + + + + false + true + + + Console + false + false + + + + + false + true + + + Console + false + false + + + + + false + true + + + Console + false + false + + + + + false + true + + + Console + false + false + + + + + false + true + + + Console + false + false + + + + + false + true + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj.filters b/Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj.filters new file mode 100644 index 00000000..c31757ec --- /dev/null +++ b/Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj.filters @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Win32/GraphicsTools-Debug.vgdbsettings b/Graphics/GraphicsTools/build/Win32/GraphicsTools-Debug.vgdbsettings new file mode 100644 index 00000000..3f5b24b1 --- /dev/null +++ b/Graphics/GraphicsTools/build/Win32/GraphicsTools-Debug.vgdbsettings @@ -0,0 +1,76 @@ + + + Debug + + + + MinGWWindowsSlash + + $(ProjectDir) + + + android-19 + true + true + bin;obj + false + false + + + + + + false + false + true + false + false + false + false + true + false + KillApp + + false + false + false + false + false + false + false + false + + false + false + main + true + + + false + false + 5039 + 5039 + 10000 + 0 + false + Ask + true + true + + + + + + + + + + + Default + + + + true + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Win32/GraphicsTools-Release.vgdbsettings b/Graphics/GraphicsTools/build/Win32/GraphicsTools-Release.vgdbsettings new file mode 100644 index 00000000..669691f2 --- /dev/null +++ b/Graphics/GraphicsTools/build/Win32/GraphicsTools-Release.vgdbsettings @@ -0,0 +1,76 @@ + + + Release + + + + MinGWWindowsSlash + + $(ProjectDir) + + + android-19 + false + true + bin;obj + false + false + + + + + + false + false + true + false + false + false + false + true + false + KillApp + + false + false + false + false + false + false + false + false + + false + false + main + true + + + false + false + 5039 + 5039 + 10000 + 0 + false + Ask + true + true + + + + + + + + + + + Default + + + + true + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj b/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj new file mode 100644 index 00000000..a1020462 --- /dev/null +++ b/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {C6014499-0CF2-43EC-A773-A4E354FB2D74} + Win32Proj + GraphicsTools + + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + false + v140 + true + Unicode + + + StaticLibrary + false + v140 + true + Unicode + + + v120 + Makefile + + + v120 + Makefile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj.filters b/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj.filters new file mode 100644 index 00000000..89d44e9e --- /dev/null +++ b/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + + + + + + jni + + + jni + + + + + android_src + + + android_src + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Win32/jni/Android.mk b/Graphics/GraphicsTools/build/Win32/jni/Android.mk new file mode 100644 index 00000000..2b02dd54 --- /dev/null +++ b/Graphics/GraphicsTools/build/Win32/jni/Android.mk @@ -0,0 +1,25 @@ +# Android NDK project makefile autogenerated by Premake + +# Preamble +DEPENDENCY_PATH := $(call my-dir) +LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) +include $(CLEAR_VARS) + + +# Project configuration +LOCAL_MODULE := GraphicsTools +LOCAL_CFLAGS := -std=c++11 +LOCAL_CPP_FEATURES := exceptions +LOCAL_STATIC_LIBRARIES += + +# Include paths +PROJECT_ROOT := $(LOCAL_PATH)/../../.. +GRAPHICS_ROOT := $(PROJECT_ROOT)/.. +SOLUTION_ROOT := $(GRAPHICS_ROOT)/.. +LOCAL_C_INCLUDES := $(PROJECT_ROOT)/include $(SOLUTION_ROOT)/Common/include $(SOLUTION_ROOT)/Common/interface $(SOLUTION_ROOT)/Platforms/interface $(GRAPHICS_ROOT)/GraphicsEngine/interface $(GRAPHICS_ROOT)/GraphicsTools/include $(GRAPHICS_ROOT)/TextureLoader/interface + +# Source files +#VisualGDBAndroid: AutoUpdateSourcesInNextLine +LOCAL_SRC_FILES := ../../../src/BasicShaderSourceStreamFactory.cpp ../../../src/GraphicsUtilities.cpp + +include $(BUILD_STATIC_LIBRARY) diff --git a/Graphics/GraphicsTools/build/Win32/jni/Application.mk b/Graphics/GraphicsTools/build/Win32/jni/Application.mk new file mode 100644 index 00000000..063ff721 --- /dev/null +++ b/Graphics/GraphicsTools/build/Win32/jni/Application.mk @@ -0,0 +1,7 @@ +# Generated by VisualGDB + +DEPENDENCY_PATH := $(call my-dir) +LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) +include $(LOCAL_PATH)/../../../../../Common/make/AppCommon.mk + +APP_MODULES := GraphicsTools \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.Shared.vcxitems b/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.Shared.vcxitems new file mode 100644 index 00000000..4ca8db57 --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.Shared.vcxitems @@ -0,0 +1,40 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {3bb4f2ac-1d2f-4af6-b9cc-bdc17bb8bc39} + GraphicsTools + GraphicsTools.Shared + 248F659F-DAC5-46E8-AC09-60EC9FC95053 + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + + + + + + + Create + + + + + false + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.Shared.vcxitems.filters b/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.Shared.vcxitems.filters new file mode 100644 index 00000000..0c8d5aa8 --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.Shared.vcxitems.filters @@ -0,0 +1,48 @@ + + + + + {610cb4a4-ad9a-42e0-936c-239055f0caa6} + + + {2fa69c92-b6b7-4e73-9ccd-49a715515cc8} + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.props b/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.props new file mode 100644 index 00000000..4da87146 --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.props @@ -0,0 +1,20 @@ + + + + + ..\..\..\.. + ..\..\.. + + + $(GraphicsRoot)\GraphicsTools\include;$(GraphicsRoot)\GraphicsEngine\interface;$(GraphicsRoot)\TextureLoader\interface;$(EngineRoot)\Common\include;$(EngineRoot)\Common\interface;$(EngineRoot)\Platforms\interface;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(IncludePath) + + + + + $(EngineRoot) + + + $(GraphicsRoot) + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/EngineRoot.props b/Graphics/GraphicsTools/build/Windows/EngineRoot.props deleted file mode 100644 index 6e4b958b..00000000 --- a/Graphics/GraphicsTools/build/Windows/EngineRoot.props +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ..\..\..\.. - ..\..\.. - - - - - - $(EngineRoot) - - - $(GraphicsRoot) - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings b/Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings deleted file mode 100644 index 3f5b24b1..00000000 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings +++ /dev/null @@ -1,76 +0,0 @@ - - - Debug - - - - MinGWWindowsSlash - - $(ProjectDir) - - - android-19 - true - true - bin;obj - false - false - - - - - - false - false - true - false - false - false - false - true - false - KillApp - - false - false - false - false - false - false - false - false - - false - false - main - true - - - false - false - 5039 - 5039 - 10000 - 0 - false - Ask - true - true - - - - - - - - - - - Default - - - - true - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings b/Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings deleted file mode 100644 index 669691f2..00000000 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings +++ /dev/null @@ -1,76 +0,0 @@ - - - Release - - - - MinGWWindowsSlash - - $(ProjectDir) - - - android-19 - false - true - bin;obj - false - false - - - - - - false - false - true - false - false - false - false - true - false - KillApp - - false - false - false - false - false - false - false - false - - false - false - main - true - - - false - false - 5039 - 5039 - 10000 - 0 - false - Ask - true - true - - - - - - - - - - - Default - - - - true - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools.props b/Graphics/GraphicsTools/build/Windows/GraphicsTools.props deleted file mode 100644 index 22851e71..00000000 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools.props +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - $(GraphicsRoot)\GraphicsTools\include;$(GraphicsRoot)\GraphicsEngine\interface;$(GraphicsRoot)\TextureLoader\interface;$(EngineRoot)\Common\include;$(EngineRoot)\Common\interface;$(EngineRoot)\Platforms\interface;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(IncludePath) - - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj b/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj deleted file mode 100644 index c90a589b..00000000 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {C6014499-0CF2-43EC-A773-A4E354FB2D74} - Win32Proj - GraphicsTools - - - - StaticLibrary - true - v140 - Unicode - - - StaticLibrary - true - v140 - Unicode - - - StaticLibrary - false - v140 - true - Unicode - - - StaticLibrary - false - v140 - true - Unicode - - - v120 - Makefile - - - v120 - Makefile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - - - - - Level3 - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - Level3 - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - - - - - - - - true - true - true - true - - - true - true - true - true - - - - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters b/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters deleted file mode 100644 index 89d44e9e..00000000 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters +++ /dev/null @@ -1,32 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - - - - - - jni - - - jni - - - - - android_src - - - android_src - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/jni/Android.mk b/Graphics/GraphicsTools/build/Windows/jni/Android.mk deleted file mode 100644 index 2b02dd54..00000000 --- a/Graphics/GraphicsTools/build/Windows/jni/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -# Android NDK project makefile autogenerated by Premake - -# Preamble -DEPENDENCY_PATH := $(call my-dir) -LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) -include $(CLEAR_VARS) - - -# Project configuration -LOCAL_MODULE := GraphicsTools -LOCAL_CFLAGS := -std=c++11 -LOCAL_CPP_FEATURES := exceptions -LOCAL_STATIC_LIBRARIES += - -# Include paths -PROJECT_ROOT := $(LOCAL_PATH)/../../.. -GRAPHICS_ROOT := $(PROJECT_ROOT)/.. -SOLUTION_ROOT := $(GRAPHICS_ROOT)/.. -LOCAL_C_INCLUDES := $(PROJECT_ROOT)/include $(SOLUTION_ROOT)/Common/include $(SOLUTION_ROOT)/Common/interface $(SOLUTION_ROOT)/Platforms/interface $(GRAPHICS_ROOT)/GraphicsEngine/interface $(GRAPHICS_ROOT)/GraphicsTools/include $(GRAPHICS_ROOT)/TextureLoader/interface - -# Source files -#VisualGDBAndroid: AutoUpdateSourcesInNextLine -LOCAL_SRC_FILES := ../../../src/BasicShaderSourceStreamFactory.cpp ../../../src/GraphicsUtilities.cpp - -include $(BUILD_STATIC_LIBRARY) diff --git a/Graphics/GraphicsTools/build/Windows/jni/Application.mk b/Graphics/GraphicsTools/build/Windows/jni/Application.mk deleted file mode 100644 index 063ff721..00000000 --- a/Graphics/GraphicsTools/build/Windows/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -# Generated by VisualGDB - -DEPENDENCY_PATH := $(call my-dir) -LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) -include $(LOCAL_PATH)/../../../../../Common/make/AppCommon.mk - -APP_MODULES := GraphicsTools \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/EngineRoot.props b/Graphics/GraphicsTools/build/WindowsStore/EngineRoot.props deleted file mode 100644 index fcb891c0..00000000 --- a/Graphics/GraphicsTools/build/WindowsStore/EngineRoot.props +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ..\..\..\..\.. - ..\..\..\.. - - - - - - $(EngineRoot) - - - $(GraphicsRoot) - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems deleted file mode 100644 index 6a1aa429..00000000 --- a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems +++ /dev/null @@ -1,32 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - {3bb4f2ac-1d2f-4af6-b9cc-bdc17bb8bc39} - GraphicsTools - GraphicsTools.Shared - 248F659F-DAC5-46E8-AC09-60EC9FC95053 - - - - %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) - - - - - - - - - - - - - - - - Create - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems.filters b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems.filters deleted file mode 100644 index ed522894..00000000 --- a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {610cb4a4-ad9a-42e0-936c-239055f0caa6} - - - {2fa69c92-b6b7-4e73-9ccd-49a715515cc8} - - - - - include - - - include - - - include - - - include - - - - - src - - - src - - - src - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj deleted file mode 100644 index 85152c29..00000000 --- a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - {dac331f3-c5a2-4568-8714-9213c3487a49} - GraphicsTools - en-US - 12.0 - true - Windows Store - 8.1 - CodeSharingStaticLibrary - - - - StaticLibrary - true - v120 - - - StaticLibrary - true - v120 - - - StaticLibrary - true - v120 - - - StaticLibrary - false - true - v120 - - - StaticLibrary - false - true - v120 - - - StaticLibrary - false - true - v120 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - - Use - false - true - - - Console - false - false - - - - - Use - false - true - - - Console - false - false - - - - - Use - false - true - - - Console - false - false - - - - - Use - false - true - - - Console - false - false - - - - - Use - false - true - - - Console - false - false - - - - - Use - false - true - - - Console - false - false - - - - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj.filters b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj.filters deleted file mode 100644 index a7761ab0..00000000 --- a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj.filters +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj deleted file mode 100644 index e99bf6b4..00000000 --- a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj +++ /dev/null @@ -1,144 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Release - ARM - - - Release - Win32 - - - - {2f340c0e-43b2-471f-b4f3-7cdce69f6e1f} - GraphicsTools - en-US - 12.0 - true - Windows Phone - 8.1 - CodeSharingStaticLibrary - - - - StaticLibrary - true - v120_wp81 - - - StaticLibrary - true - v120_wp81 - - - StaticLibrary - false - true - v120_wp81 - - - StaticLibrary - false - true - v120_wp81 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - - Use - false - true - - - Console - false - false - - - - - Use - false - true - - - Console - false - false - - - - - Use - false - true - - - Console - false - false - - - - - Use - false - true - - - Console - false - false - - - - - - \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj.filters b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj.filters deleted file mode 100644 index a7761ab0..00000000 --- a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj.filters +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h b/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h index 76adc056..86e2650b 100644 --- a/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h +++ b/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsTools/include/FreeBlockListManager.h b/Graphics/GraphicsTools/include/FreeBlockListManager.h new file mode 100644 index 00000000..7eb9d931 --- /dev/null +++ b/Graphics/GraphicsTools/include/FreeBlockListManager.h @@ -0,0 +1,276 @@ +/* Copyright 2015-2016 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 + * + * 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 "MemoryAllocator.h" +#include "FixedBlockMemoryAllocator.h" +#include "STDAllocator.h" +#include "DebugUtilities.h" + +namespace Diligent +{ + class FreeBlockListManager + { + public: + typedef size_t OffsetType; + typedef std::pair FrameNumOffsetPair; + + struct FreeBlockInfo; + typedef std::map, // Standard ordering + STDAllocatorRawMem> // Raw memory allocator + > TFreeBlocksByOffsetMap; + typedef std::multimap, // Standard ordering + STDAllocatorRawMem> // Raw memory allocator + > TFreeBlocksBySizeMap; + + struct FreeBlockInfo + { + // Block size (no reserved space) + OffsetType Size; + + // Iterator referencing this block in the multimap sorted by the block size + TFreeBlocksBySizeMap::iterator OrderBySizeIt; + + FreeBlockInfo(OffsetType _Size) : Size(_Size){} + }; + + static const OffsetType InvalidOffset = static_cast(-1); + + FreeBlockListManager(OffsetType MaxSize, IMemoryAllocator &Allocator) : + m_MaxSize(MaxSize), + m_FreeSize(MaxSize), + m_FreeBlocks( STD_ALLOCATOR_RAW_MEM(TFreeBlocksByOffsetMap::value_type, Allocator, "Allocator for std::map") ), + m_FreeBlocksBySize( STD_ALLOCATOR_RAW_MEM(TFreeBlocksBySizeMap::value_type, Allocator, "multimap") ) + { + AddNewBlock(0, m_MaxSize); + +#ifdef _DEBUG + DbgVerifyList(); +#endif + } + + ~FreeBlockListManager() + { + if( !m_FreeBlocks.empty() || !m_FreeBlocksBySize.empty() ) + { + VERIFY(m_FreeBlocks.size() == 1, "Single free block is expected"); + VERIFY(m_FreeBlocks.begin()->first == 0, "Head chunk offset is expected to be 0"); + VERIFY(m_FreeBlocks.begin()->second.Size == m_MaxSize, "Head chunk size is expected to be ", m_MaxSize); + + VERIFY(m_FreeBlocksBySize.size() == 1, "Single free block is expected"); + VERIFY(m_FreeBlocksBySize.begin()->first == m_MaxSize, "Head chunk size is expected to be ", m_MaxSize); + VERIFY(m_FreeBlocksBySize.begin()->second == m_FreeBlocks.begin(), "Incorrect first block"); + } + } + + FreeBlockListManager(FreeBlockListManager&& rhs) : + m_FreeBlocks(std::move(rhs.m_FreeBlocks)), + m_FreeBlocksBySize(std::move(rhs.m_FreeBlocksBySize)), + m_MaxSize(rhs.m_MaxSize), + m_FreeSize(rhs.m_FreeSize) + { + rhs.m_MaxSize = 0; + rhs.m_FreeSize = 0; + } + FreeBlockListManager& operator = (FreeBlockListManager&& rhs) = default; + FreeBlockListManager(const FreeBlockListManager&) = delete; + FreeBlockListManager& operator = (const FreeBlockListManager&) = delete; + + OffsetType Allocate(OffsetType Size) + { + VERIFY_EXPR(Size != 0); + if(m_FreeSize < Size) + return InvalidOffset; + + // Get the first block that is >= Size + auto SmallestBlockItIt = m_FreeBlocksBySize.lower_bound(Size); + if(SmallestBlockItIt == m_FreeBlocksBySize.end()) + return InvalidOffset; + + auto SmallestBlockIt = SmallestBlockItIt->second; + VERIFY_EXPR(Size <= SmallestBlockIt->second.Size); + + auto Offset = SmallestBlockIt->first; + auto NewOffset = Offset + Size; + auto NewSize = SmallestBlockIt->second.Size - Size; + VERIFY_EXPR(SmallestBlockItIt == SmallestBlockIt->second.OrderBySizeIt); + m_FreeBlocksBySize.erase(SmallestBlockItIt); + m_FreeBlocks.erase(SmallestBlockIt); + if (NewSize > 0) + { + AddNewBlock(NewOffset, NewSize); + } + + m_FreeSize -= Size; + +#ifdef _DEBUG + DbgVerifyList(); +#endif + return Offset; + } + + void Free(OffsetType Offset, OffsetType Size) + { + VERIFY_EXPR(Offset+Size <= m_MaxSize); + + auto NextBlockIt = m_FreeBlocks.upper_bound(Offset); // First element > +#ifdef _DEBUG + { + auto LowBnd = m_FreeBlocks.lower_bound(Offset); // First element >= + // Since zero-size allocations are not allowed, lower bound must always be equal upper bound + VERIFY_EXPR(LowBnd == NextBlockIt); + } +#endif + VERIFY_EXPR(NextBlockIt == m_FreeBlocks.end() || Offset <= NextBlockIt->first + NextBlockIt->second.Size); + auto PrevBlockIt = NextBlockIt; + if(PrevBlockIt != m_FreeBlocks.begin()) + { + --PrevBlockIt; + VERIFY_EXPR(Offset >= PrevBlockIt->first + PrevBlockIt->second.Size); + } + else + PrevBlockIt = m_FreeBlocks.end(); + + OffsetType NewSize, NewOffset; + if(PrevBlockIt != m_FreeBlocks.end() && Offset == PrevBlockIt->first + PrevBlockIt->second.Size) + { + // PrevBlock.Offset Offset + // | | + // |<-----PrevBlock.Size----->|<------Size-------->| + // + NewSize = PrevBlockIt->second.Size + Size; + NewOffset = PrevBlockIt->first; + + if (NextBlockIt != m_FreeBlocks.end() && Offset + Size == NextBlockIt->first) + { + // PrevBlock.Offset Offset NextBlock.Offset + // | | | + // |<-----PrevBlock.Size----->|<------Size-------->|<-----NextBlock.Size----->| + // + NewSize += NextBlockIt->second.Size; + m_FreeBlocksBySize.erase(PrevBlockIt->second.OrderBySizeIt); + m_FreeBlocksBySize.erase(NextBlockIt->second.OrderBySizeIt); + ++NextBlockIt; + m_FreeBlocks.erase(PrevBlockIt, NextBlockIt); + } + else + { + // PrevBlock.Offset Offset NextBlock.Offset + // | | | + // |<-----PrevBlock.Size----->|<------Size-------->| ~ ~ ~ |<-----NextBlock.Size----->| + // + m_FreeBlocksBySize.erase(PrevBlockIt->second.OrderBySizeIt); + m_FreeBlocks.erase(PrevBlockIt); + } + } + else if (NextBlockIt != m_FreeBlocks.end() && Offset + Size == NextBlockIt->first) + { + // PrevBlock.Offset Offset NextBlock.Offset + // | | | + // |<-----PrevBlock.Size----->| ~ ~ ~ |<------Size-------->|<-----NextBlock.Size----->| + // + NewSize = Size + NextBlockIt->second.Size; + NewOffset = Offset; + m_FreeBlocksBySize.erase(NextBlockIt->second.OrderBySizeIt); + m_FreeBlocks.erase(NextBlockIt); + } + else + { + // PrevBlock.Offset Offset NextBlock.Offset + // | | | + // |<-----PrevBlock.Size----->| ~ ~ ~ |<------Size-------->| ~ ~ ~ |<-----NextBlock.Size----->| + // + NewSize = Size; + NewOffset = Offset; + } + + AddNewBlock(NewOffset, NewSize); + + m_FreeSize += Size; +#ifdef _DEBUG + DbgVerifyList(); +#endif + } + + OffsetType GetMaxSize()const{return m_MaxSize;} + bool IsFull()const{ return m_FreeSize==0; }; + bool IsEmpty()const{ return m_FreeSize==m_MaxSize; }; + OffsetType GetFreeSize()const{return m_FreeSize;} + +#ifdef _DEBUG + size_t DbgGetNumFreeBlocks()const{return m_FreeBlocks.size();} +#endif + + private: + void AddNewBlock(OffsetType Offset, OffsetType Size) + { + auto NewBlockIt = m_FreeBlocks.emplace(Offset, Size); + VERIFY_EXPR(NewBlockIt.second); + auto OrderIt = m_FreeBlocksBySize.emplace(Size, NewBlockIt.first); + NewBlockIt.first->second.OrderBySizeIt = OrderIt; + } + + +#ifdef _DEBUG + void DbgVerifyList() + { + OffsetType TotalFreeSize = 0; + + auto BlockIt = m_FreeBlocks.begin(); + auto PrevBlockIt = m_FreeBlocks.end(); + VERIFY_EXPR(m_FreeBlocks.size() == m_FreeBlocksBySize.size()); + while (BlockIt != m_FreeBlocks.end()) + { + VERIFY_EXPR(BlockIt->first >= 0 && BlockIt->first + BlockIt->second.Size <= m_MaxSize); + VERIFY_EXPR(BlockIt == BlockIt->second.OrderBySizeIt->second); + VERIFY(PrevBlockIt == m_FreeBlocks.end() || BlockIt->first > PrevBlockIt->first + PrevBlockIt->second.Size, "Adjoint blocks detected" ); + TotalFreeSize += BlockIt->second.Size; + + PrevBlockIt = BlockIt; + ++BlockIt; + } + + auto OrderIt = m_FreeBlocksBySize.begin(); + while (OrderIt != m_FreeBlocksBySize.end()) + { + VERIFY_EXPR(OrderIt->first == OrderIt->second->second.Size); + ++OrderIt; + } + + VERIFY_EXPR(TotalFreeSize == m_FreeSize); + } +#endif + + TFreeBlocksByOffsetMap m_FreeBlocks; + TFreeBlocksBySizeMap m_FreeBlocksBySize; + + OffsetType m_MaxSize = 0; + OffsetType m_FreeSize = 0; + }; +} diff --git a/Graphics/GraphicsTools/include/FreeBlockListManagerGPU.h b/Graphics/GraphicsTools/include/FreeBlockListManagerGPU.h new file mode 100644 index 00000000..f2961bd3 --- /dev/null +++ b/Graphics/GraphicsTools/include/FreeBlockListManagerGPU.h @@ -0,0 +1,85 @@ +/* Copyright 2015-2016 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 + * + * 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 "FreeBlockListManager.h" +#include "STDAllocator.h" + +namespace Diligent +{ + class FreeBlockListManagerGPU : public FreeBlockListManager + { + private: + struct FreedAllocationInfo + { + OffsetType Offset; + OffsetType Size; + Uint64 FrameNumber; + FreedAllocationInfo(OffsetType _Offset, OffsetType _Size, Uint64 _FrameNumber) : + Offset(_Offset), Size(_Size), FrameNumber(_FrameNumber) + {} + }; + + public: + FreeBlockListManagerGPU(OffsetType MaxSize, IMemoryAllocator &Allocator) : + FreeBlockListManager(MaxSize, Allocator), + m_StaleAllocations(0, FreedAllocationInfo(0,0,0), STD_ALLOCATOR_RAW_MEM(FreedAllocationInfo, Allocator, "Allocator for deque< FreedAllocationInfo>" )) + {} + + ~FreeBlockListManagerGPU() + { + VERIFY(m_StaleAllocations.empty(), "Not all stale allocations released"); + } + + // = default causes compiler error when instantiating std::vector::emplace_back() in Visual Studio 2015 (Version 14.0.23107.0 D14REL) + FreeBlockListManagerGPU(FreeBlockListManagerGPU&& rhs) : + FreeBlockListManager(std::move(rhs)), + m_StaleAllocations(std::move(rhs.m_StaleAllocations)) + { + } + + FreeBlockListManagerGPU& operator = (FreeBlockListManagerGPU&& rhs) = default; + FreeBlockListManagerGPU(const FreeBlockListManagerGPU&) = delete; + FreeBlockListManagerGPU& operator = (const FreeBlockListManagerGPU&) = delete; + + void Free(OffsetType Offset, OffsetType Size, Uint64 FrameNumber) + { + m_StaleAllocations.emplace_back(Offset, Size, FrameNumber); + } + + void ReleaseCompletedFrames(Uint64 NumCompletedFrames) + { + while(!m_StaleAllocations.empty() && m_StaleAllocations.front().FrameNumber < NumCompletedFrames) + { + auto &OldestAllocation = m_StaleAllocations.front(); + FreeBlockListManager::Free(OldestAllocation.Offset, OldestAllocation.Size); + m_StaleAllocations.pop_front(); + } + } + + private: + std::deque< FreedAllocationInfo, STDAllocatorRawMem > m_StaleAllocations; + }; +} diff --git a/Graphics/GraphicsTools/include/GraphicsUtilities.h b/Graphics/GraphicsTools/include/GraphicsUtilities.h index 78002d01..6e6b34f6 100644 --- a/Graphics/GraphicsTools/include/GraphicsUtilities.h +++ b/Graphics/GraphicsTools/include/GraphicsUtilities.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ #include "Texture.h" #include "Buffer.h" #include "RenderDevice.h" +#include "DebugUtilities.h" namespace Diligent { @@ -99,8 +100,26 @@ template<>struct VALUE_TYPE2CType{ typedef Uint16 CType; }; template<>struct VALUE_TYPE2CType{ typedef Float32 CType; }; +static const Uint32 ValueTypeToSizeMap[] = +{ + 0, + sizeof(VALUE_TYPE2CType :: CType), + sizeof(VALUE_TYPE2CType :: CType), + sizeof(VALUE_TYPE2CType :: CType), + sizeof(VALUE_TYPE2CType :: CType), + sizeof(VALUE_TYPE2CType :: CType), + sizeof(VALUE_TYPE2CType :: CType), + sizeof(VALUE_TYPE2CType :: CType), + sizeof(VALUE_TYPE2CType :: CType) +}; +static_assert(VT_NUM_TYPES == VT_FLOAT32 + 1, "Not all value type sizes initialized."); + /// Returns the size of the specified value type -Uint32 GetValueSize( VALUE_TYPE Val ); +inline Uint32 GetValueSize(VALUE_TYPE Val) +{ + VERIFY_EXPR(Val < _countof(ValueTypeToSizeMap)); + return ValueTypeToSizeMap[Val]; +} /// Returns the string representing the specified value type const Char* GetValueTypeString( VALUE_TYPE Val ); @@ -134,6 +153,16 @@ const Char *GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType); /// \return Literal name of the shader type. const Char *GetShaderTypeLiteralName(SHADER_TYPE ShaderType); + +/// Returns the literal name of a shader variable type. For instance, +/// for SHADER_VARIABLE_TYPE_STATIC, if bGetFullName == true, "SHADER_VARIABLE_TYPE_STATIC" will be returned; +/// if bGetFullName == false, "static" will be returned + +/// \param [in] VarType - Variable type. +/// \param [in] bGetFullName - Whether to return string representation of the enum value +/// \return Literal name of the shader variable type. +const Char *GetShaderVariableTypeLiteralName(SHADER_VARIABLE_TYPE VarType, bool bGetFullName = false); + /// Overloaded function that returns the literal name of a texture view type. /// see GetTexViewTypeLiteralName(). inline const Char* GetViewTypeLiteralName(TEXTURE_VIEW_TYPE TexViewType) @@ -152,7 +181,7 @@ inline const Char* GetViewTypeLiteralName(BUFFER_VIEW_TYPE BuffViewType) const Char* GetUsageString(USAGE Usage); /// Returns the string containing the texture type -const Char* GetTextureTypeString( TEXTURE_TYPE TexType ); +const Char* GetResourceDimString( RESOURCE_DIMENSION TexType ); /// Returns the string containing the bind flags String GetBindFlagsString( Uint32 BindFlags ); diff --git a/Graphics/GraphicsTools/include/RingBuffer.h b/Graphics/GraphicsTools/include/RingBuffer.h new file mode 100644 index 00000000..043e884d --- /dev/null +++ b/Graphics/GraphicsTools/include/RingBuffer.h @@ -0,0 +1,181 @@ +/* Copyright 2015-2016 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 + * + * 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 "MemoryAllocator.h" +#include "STDAllocator.h" +#include "DebugUtilities.h" + +namespace Diligent +{ + class RingBuffer + { + public: + typedef size_t OffsetType; + typedef std::pair FrameNumOffsetPair; + + static const OffsetType InvalidOffset = static_cast(-1); + + RingBuffer(OffsetType MaxSize, IMemoryAllocator &Allocator) : + m_CompletedFrameTails(0, FrameNumOffsetPair(), STD_ALLOCATOR_RAW_MEM(FrameNumOffsetPair, Allocator, "Allocator for vector" )), + m_MaxSize(MaxSize) + {} + + RingBuffer(RingBuffer&& rhs) : + m_CompletedFrameTails(std::move(rhs.m_CompletedFrameTails)), + m_Head(rhs.m_Head), + m_Tail(rhs.m_Tail), + m_MaxSize(rhs.m_MaxSize), + m_UsedSize(rhs.m_UsedSize) + { + rhs.m_Head = 0; + rhs.m_Tail = 0; + rhs.m_MaxSize = 0; + rhs.m_UsedSize = 0; + } + + RingBuffer& operator = (RingBuffer&& rhs) + { + m_CompletedFrameTails = std::move(rhs.m_CompletedFrameTails); + m_Head = rhs.m_Head; + m_Tail = rhs.m_Tail; + m_MaxSize = rhs.m_MaxSize; + m_UsedSize = rhs.m_UsedSize; + + rhs.m_MaxSize = 0; + rhs.m_Head = 0; + rhs.m_Tail = 0; + rhs.m_UsedSize = 0; + + return *this; + } + + RingBuffer(const RingBuffer&) = delete; + RingBuffer& operator = (const RingBuffer&) = delete; + + OffsetType Allocate(OffsetType Size) + { + if(IsFull()) + { + return InvalidOffset; + } + + if (m_Tail >= m_Head ) + { + // Head Tail MaxSize + // | | | + // [ xxxxxxxxxxxxxxxxx ] + // + // + if (m_Tail + Size <= m_MaxSize) + { + auto Offset = m_Tail; + m_Tail += Size; + m_UsedSize += Size; + return Offset; + } + else if(Size <= m_Head) + { + // Allocate from the beginning of the buffer + m_UsedSize += (m_MaxSize - m_Tail) + Size; + m_Tail = Size; + return 0; + } + } + else if (m_Tail + Size <= m_Head ) + { + // + // Tail Head + // | | + // [xxxx xxxxxxxxxxxxxxxxxxxxxxxxxx] + // + auto Offset = m_Tail; + m_Tail += Size; + m_UsedSize += Size; + return Offset; + } + + return InvalidOffset; + } + + void FinishCurrentFrame(Uint64 FrameNum) + { + m_CompletedFrameTails.push_back(std::make_pair(FrameNum, m_Tail) ); + } + + void ReleaseCompletedFrames(Uint64 NumCompletedFrames) + { + while(!m_CompletedFrameTails.empty() && m_CompletedFrameTails.front().first < NumCompletedFrames) + { + auto &OldestFrameTail = m_CompletedFrameTails.front().second; + if( m_UsedSize > 0 ) + { + if (OldestFrameTail > m_Head) + { + // m_Head OldestFrameTail MaxSize + // | | | + // [ xxxxxxxxxxxxxxxxxxxxx ] + // + // + VERIFY_EXPR(m_UsedSize >= OldestFrameTail - m_Head); + m_UsedSize -= OldestFrameTail - m_Head; + } + else + { + // OldestFrameTail m_Head MaxSize + // | | | + // [xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx] + // + + // + // m_Head,OldestFrameTail MaxSize + // | | + // [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] + // + // + // + VERIFY_EXPR(m_UsedSize >= (m_MaxSize - m_Head) + OldestFrameTail); + m_UsedSize -= (m_MaxSize - m_Head); + m_UsedSize -= OldestFrameTail; + } + } + m_Head = OldestFrameTail; + m_CompletedFrameTails.pop_front(); + } + } + + OffsetType GetMaxSize()const{return m_MaxSize;} + bool IsFull()const{ return m_UsedSize==m_MaxSize; }; + bool IsEmpty()const{ return m_UsedSize==0; }; + OffsetType GetUsedSize()const{return m_UsedSize;} + + private: + std::deque< FrameNumOffsetPair, STDAllocatorRawMem > m_CompletedFrameTails; + OffsetType m_Head = 0; + OffsetType m_Tail = 0; + OffsetType m_MaxSize = 0; + OffsetType m_UsedSize = 0; + }; +} diff --git a/Graphics/GraphicsTools/include/ShaderMacroHelper.h b/Graphics/GraphicsTools/include/ShaderMacroHelper.h index bcfc3e52..f64c2349 100644 --- a/Graphics/GraphicsTools/include/ShaderMacroHelper.h +++ b/Graphics/GraphicsTools/include/ShaderMacroHelper.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsTools/include/pch.h b/Graphics/GraphicsTools/include/pch.h index b2893486..41fa3c3b 100644 --- a/Graphics/GraphicsTools/include/pch.h +++ b/Graphics/GraphicsTools/include/pch.h @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp b/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp index fa69c7c1..e15635e8 100644 --- a/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp +++ b/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp index 05cc0a3a..f3a7d873 100644 --- a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp +++ b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,42 +29,6 @@ namespace Diligent { -Uint32 GetValueSize( VALUE_TYPE Val ) -{ - static Uint32 Sizes[VT_NUM_TYPES] = {}; - static bool bIsInit = false; - // Note that this implementation is thread-safe - // Even if two threads try to call the function at the same time, - // the worst thing that might happen is that the array will be - // initialized multiple times. But the result will always be correct - if( !bIsInit ) - { - Sizes[VT_UNDEFINED] = 0; -#define INIT_VALUE_SIZE( ValType ) Sizes[ValType] = sizeof(VALUE_TYPE2CType::CType) - INIT_VALUE_SIZE( VT_INT8 ); - INIT_VALUE_SIZE( VT_INT16 ); - INIT_VALUE_SIZE( VT_INT32 ); - INIT_VALUE_SIZE( VT_UINT8 ); - INIT_VALUE_SIZE( VT_UINT16 ); - INIT_VALUE_SIZE( VT_UINT32 ); - INIT_VALUE_SIZE( VT_FLOAT16 ); - INIT_VALUE_SIZE( VT_FLOAT32 ); -#undef INIT_VALUE_SIZE - static_assert(VT_NUM_TYPES == VT_FLOAT32 + 1, "Not all value type sizes initialized."); - bIsInit = true; - } - - if( Val > VT_UNDEFINED && Val < VT_NUM_TYPES ) - { - return Sizes[Val]; - } - else - { - UNEXPECTED( "Incorrect value type (", Val, ")" ) - return 0; - } -} - const Char* GetValueTypeString( VALUE_TYPE Val ) { static const Char* ValueTypeStrings[VT_NUM_TYPES] = {}; @@ -233,7 +197,7 @@ const TextureFormatAttribs& GetTextureFormatAttribs( TEXTURE_FORMAT Format ) #ifdef _DEBUG for( Uint32 Fmt = TEX_FORMAT_UNKNOWN; Fmt < TEX_FORMAT_NUM_FORMATS; ++Fmt ) - VERIFY(FmtAttribs[Fmt].Format == Fmt, "Uninitialized format"); + VERIFY(FmtAttribs[Fmt].Format == static_cast(Fmt), "Uninitialized format"); #endif bIsInit = true; @@ -337,6 +301,33 @@ const Char *GetShaderTypeLiteralName( SHADER_TYPE ShaderType ) } } +const Char *GetShaderVariableTypeLiteralName(SHADER_VARIABLE_TYPE VarType, bool bGetFullName) +{ + static const Char* ShortVarTypeNameStrings[SHADER_VARIABLE_TYPE_NUM_TYPES]; + static const Char* FullVarTypeNameStrings[SHADER_VARIABLE_TYPE_NUM_TYPES]; + static bool bVarTypeStrsInit = false; + if( !bVarTypeStrsInit ) + { + ShortVarTypeNameStrings[SHADER_VARIABLE_TYPE_STATIC] = "static"; + ShortVarTypeNameStrings[SHADER_VARIABLE_TYPE_MUTABLE] = "mutable"; + ShortVarTypeNameStrings[SHADER_VARIABLE_TYPE_DYNAMIC] = "dynamic"; + FullVarTypeNameStrings[SHADER_VARIABLE_TYPE_STATIC] = "SHADER_VARIABLE_TYPE_STATIC"; + FullVarTypeNameStrings[SHADER_VARIABLE_TYPE_MUTABLE] = "SHADER_VARIABLE_TYPE_MUTABLE"; + FullVarTypeNameStrings[SHADER_VARIABLE_TYPE_DYNAMIC] = "SHADER_VARIABLE_TYPE_DYNAMIC"; + + static_assert(SHADER_VARIABLE_TYPE_NUM_TYPES == SHADER_VARIABLE_TYPE_DYNAMIC + 1, "Not all shader variable types initialized."); + + bVarTypeStrsInit = true; + } + if( VarType >= SHADER_VARIABLE_TYPE_STATIC && VarType < SHADER_VARIABLE_TYPE_NUM_TYPES ) + return (bGetFullName ? FullVarTypeNameStrings : ShortVarTypeNameStrings)[VarType]; + else + { + UNEXPECTED("Unknow shader variable type") + return "unknow"; + } +} + /// Returns the string containing the usage const Char* GetUsageString( USAGE Usage ) { @@ -361,25 +352,26 @@ const Char* GetUsageString( USAGE Usage ) } } -const Char* GetTextureTypeString( TEXTURE_TYPE TexType ) +const Char* GetResourceDimString( RESOURCE_DIMENSION TexType ) { - static const Char* TexTypeStrings[TEXTURE_TYPE_NUM_TYPES]; + static const Char* TexTypeStrings[RESOURCE_DIM_NUM_DIMENSIONS]; static bool bTexTypeStrsInit = false; if( !bTexTypeStrsInit ) { - TexTypeStrings[TEXTURE_TYPE_UNDEFINED] = "Undefined"; - TexTypeStrings[TEXTURE_TYPE_1D] = "1D"; - TexTypeStrings[TEXTURE_TYPE_1D_ARRAY] = "1D Array"; - TexTypeStrings[TEXTURE_TYPE_2D] = "2D"; - TexTypeStrings[TEXTURE_TYPE_2D_ARRAY] = "2D Array"; - TexTypeStrings[TEXTURE_TYPE_3D] = "3D"; - TexTypeStrings[TEXTURE_TYPE_2D_ARRAY] = "Cube"; - TexTypeStrings[TEXTURE_TYPE_3D] = "Cube Array"; - static_assert(TEXTURE_TYPE_NUM_TYPES == TEXTURE_TYPE_CUBE_ARRAY + 1, "Not all texture type strings initialized."); + TexTypeStrings[RESOURCE_DIM_UNDEFINED] = "Undefined"; + TexTypeStrings[RESOURCE_DIM_BUFFER] = "Buffer"; + TexTypeStrings[RESOURCE_DIM_TEX_1D] = "Tex 1D"; + TexTypeStrings[RESOURCE_DIM_TEX_1D_ARRAY] = "Tex 1D Array"; + TexTypeStrings[RESOURCE_DIM_TEX_2D] = "Tex 2D"; + TexTypeStrings[RESOURCE_DIM_TEX_2D_ARRAY] = "Tex 2D Array"; + TexTypeStrings[RESOURCE_DIM_TEX_3D] = "Tex 3D"; + TexTypeStrings[RESOURCE_DIM_TEX_2D_ARRAY] = "Tex Cube"; + TexTypeStrings[RESOURCE_DIM_TEX_3D] = "Tex Cube Array"; + static_assert(RESOURCE_DIM_NUM_DIMENSIONS == RESOURCE_DIM_TEX_CUBE_ARRAY + 1, "Not all texture type strings initialized."); bTexTypeStrsInit = true; } - if( TexType >= TEXTURE_TYPE_UNDEFINED && TexType < TEXTURE_TYPE_NUM_TYPES ) + if( TexType >= RESOURCE_DIM_UNDEFINED && TexType < RESOURCE_DIM_NUM_DIMENSIONS ) return TexTypeStrings[TexType]; else { @@ -473,22 +465,22 @@ String ToString( T Val ) String GetTextureDescString( const TextureDesc &Desc ) { String Str = "Type: "; - Str += GetTextureTypeString(Desc.Type); + Str += GetResourceDimString(Desc.Type); Str += "; size: "; Str += ToString(Desc.Width); - if( Desc.Type == TEXTURE_TYPE_2D || Desc.Type == TEXTURE_TYPE_2D_ARRAY || Desc.Type == TEXTURE_TYPE_3D) + if( Desc.Type == RESOURCE_DIM_TEX_2D || Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY || Desc.Type == RESOURCE_DIM_TEX_3D || Desc.Type == RESOURCE_DIM_TEX_CUBE || Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) { Str += "x"; Str += ToString( Desc.Height ); } - if( Desc.Type == TEXTURE_TYPE_3D ) + if( Desc.Type == RESOURCE_DIM_TEX_3D ) { Str += "x"; Str += ToString( Desc.Depth ); } - if( Desc.Type == TEXTURE_TYPE_1D_ARRAY || Desc.Type == TEXTURE_TYPE_2D_ARRAY ) + if( Desc.Type == RESOURCE_DIM_TEX_1D_ARRAY || Desc.Type == RESOURCE_DIM_TEX_2D_ARRAY || Desc.Type == RESOURCE_DIM_TEX_CUBE || Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY ) { Str += "; Num Slices: "; Str += ToString( Desc.ArraySize ); @@ -593,8 +585,9 @@ String GetBufferDescString( const BufferDesc &Desc ) Uint32 ComputeMipLevelsCount( Uint32 Width ) { Uint32 MipLevels = 0; - while( (Width >> MipLevels) > 1 ) + while( (Width >> MipLevels) > 0 ) ++MipLevels; + VERIFY( Width >= (1U << (MipLevels-1)) && Width < (1U << MipLevels), "Incorrect number of Mip levels" ) return MipLevels; } diff --git a/Graphics/GraphicsTools/src/pch.cpp b/Graphics/GraphicsTools/src/pch.cpp index 809315e1..997e0f4a 100644 --- a/Graphics/GraphicsTools/src/pch.cpp +++ b/Graphics/GraphicsTools/src/pch.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015 Egor Yusov +/* Copyright 2015-2016 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. -- cgit v1.2.3