diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2016-08-20 06:35:47 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2016-08-20 06:35:47 +0000 |
| commit | 2b64f003622ee7871fd7aec041622427dd2fc88f (patch) | |
| tree | 893dab48c6d0e7121e047d8d3bb6d5bf172ce2d5 /Graphics/GraphicsTools | |
| parent | Release v1.0.0 (diff) | |
| download | DiligentCore-2b64f003622ee7871fd7aec041622427dd2fc88f.tar.gz DiligentCore-2b64f003622ee7871fd7aec041622427dd2fc88f.zip | |
Updated to Diligent Engine 2.0
Diffstat (limited to 'Graphics/GraphicsTools')
28 files changed, 756 insertions, 363 deletions
diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj b/Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj index 85152c29..ae79dc6f 100644 --- a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj +++ b/Graphics/GraphicsTools/build/UWP/GraphicsTools.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|ARM"> <Configuration>Debug</Configuration> @@ -27,88 +27,89 @@ </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> - <ProjectGuid>{dac331f3-c5a2-4568-8714-9213c3487a49}</ProjectGuid> + <ProjectGuid>{7a1a6e2c-3952-4a57-ad30-abd92aa39c69}</ProjectGuid> + <Keyword>StaticLibrary</Keyword> <RootNamespace>GraphicsTools</RootNamespace> <DefaultLanguage>en-US</DefaultLanguage> - <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion> + <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> <AppContainerApplication>true</AppContainerApplication> <ApplicationType>Windows Store</ApplicationType> - <ApplicationTypeRevision>8.1</ApplicationTypeRevision> - <ConvergedProjectType>CodeSharingStaticLibrary</ConvergedProjectType> + <WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion> + <WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion> + <ApplicationTypeRevision>10.0</ApplicationTypeRevision> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <Import Project="..\GraphicsTools.Shared\GraphicsTools.Shared.vcxitems" Label="Shared" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + <Import Project="..\Windows.Shared\GraphicsTools.Shared.vcxitems" Label="Shared" /> + </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore32Dbg.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> + <Import Project="..\..\..\..\Shared\build\UWP\UWP_Win32Dbg.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore32Rel.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> + <Import Project="..\..\..\..\Shared\build\UWP\UWP_Win32Rel.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStoreArmDbg.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> + <Import Project="..\..\..\..\Shared\build\UWP\UWP_ArmDbg.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStoreArmRel.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> + <Import Project="..\..\..\..\Shared\build\UWP\UWP_ArmRel.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore64Dbg.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> + <Import Project="..\..\..\..\Shared\build\UWP\UWP_X64Dbg.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore64Rel.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> + <Import Project="..\..\..\..\Shared\build\UWP\UWP_X64Rel.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> + <PropertyGroup /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <GenerateManifest>false</GenerateManifest> </PropertyGroup> @@ -129,7 +130,6 @@ </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> <CompileAsWinRT>false</CompileAsWinRT> <SDLCheck>true</SDLCheck> </ClCompile> @@ -141,7 +141,6 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> <CompileAsWinRT>false</CompileAsWinRT> <SDLCheck>true</SDLCheck> </ClCompile> @@ -153,7 +152,6 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'"> <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> <CompileAsWinRT>false</CompileAsWinRT> <SDLCheck>true</SDLCheck> </ClCompile> @@ -165,7 +163,6 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'"> <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> <CompileAsWinRT>false</CompileAsWinRT> <SDLCheck>true</SDLCheck> </ClCompile> @@ -177,7 +174,6 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> <CompileAsWinRT>false</CompileAsWinRT> <SDLCheck>true</SDLCheck> </ClCompile> @@ -189,7 +185,6 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> <CompileAsWinRT>false</CompileAsWinRT> <SDLCheck>true</SDLCheck> </ClCompile> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
\ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings b/Graphics/GraphicsTools/build/Win32/GraphicsTools-Debug.vgdbsettings index 3f5b24b1..3f5b24b1 100644 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings +++ b/Graphics/GraphicsTools/build/Win32/GraphicsTools-Debug.vgdbsettings diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings b/Graphics/GraphicsTools/build/Win32/GraphicsTools-Release.vgdbsettings index 669691f2..669691f2 100644 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings +++ b/Graphics/GraphicsTools/build/Win32/GraphicsTools-Release.vgdbsettings diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj b/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj index c90a589b..a1020462 100644 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj +++ b/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj @@ -68,31 +68,27 @@ </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> - <Import Project="..\WindowsStore\GraphicsTools.Shared\GraphicsTools.Shared.vcxitems" Label="Shared" Condition="Exists('..\WindowsStore\GraphicsTools.Shared\GraphicsTools.Shared.vcxitems')" /> + <Import Project="..\Windows.Shared\GraphicsTools.Shared.vcxitems" Label="Shared" Condition="Exists('..\Windows.Shared\GraphicsTools.Shared.vcxitems')" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="..\..\..\..\Shared\build\Windows\Win32d.props" /> - <Import Project="EngineRoot.props" /> - <Import Project="GraphicsTools.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="..\..\..\..\Shared\build\Windows\Win64d.props" /> - <Import Project="EngineRoot.props" /> - <Import Project="GraphicsTools.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="..\..\..\..\Shared\build\Windows\Win32r.props" /> - <Import Project="EngineRoot.props" /> - <Import Project="GraphicsTools.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="..\..\..\..\Shared\build\Windows\Win64r.props" /> - <Import Project="EngineRoot.props" /> - <Import Project="GraphicsTools.props" /> + <Import Project="..\Windows.Shared\GraphicsTools.props" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <Import Project="..\..\..\..\Shared\build\Windows\Android32d.props" /> @@ -104,7 +100,6 @@ <PropertyGroup /> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> - <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> @@ -115,7 +110,6 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> - <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> @@ -126,7 +120,6 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> - <WarningLevel>Level3</WarningLevel> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> @@ -141,7 +134,6 @@ </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> - <WarningLevel>Level3</WarningLevel> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters b/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj.filters index 89d44e9e..89d44e9e 100644 --- a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters +++ b/Graphics/GraphicsTools/build/Win32/GraphicsTools.vcxproj.filters diff --git a/Graphics/GraphicsTools/build/Windows/jni/Android.mk b/Graphics/GraphicsTools/build/Win32/jni/Android.mk index 2b02dd54..2b02dd54 100644 --- a/Graphics/GraphicsTools/build/Windows/jni/Android.mk +++ b/Graphics/GraphicsTools/build/Win32/jni/Android.mk diff --git a/Graphics/GraphicsTools/build/Windows/jni/Application.mk b/Graphics/GraphicsTools/build/Win32/jni/Application.mk index 063ff721..063ff721 100644 --- a/Graphics/GraphicsTools/build/Windows/jni/Application.mk +++ b/Graphics/GraphicsTools/build/Win32/jni/Application.mk 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup Label="Globals"> + <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> + <HasSharedItems>true</HasSharedItems> + <ItemsProjectGuid>{3bb4f2ac-1d2f-4af6-b9cc-bdc17bb8bc39}</ItemsProjectGuid> + <ItemsRootNamespace>GraphicsTools</ItemsRootNamespace> + <ItemsProjectName>GraphicsTools.Shared</ItemsProjectName> + <CodeSharingProject>248F659F-DAC5-46E8-AC09-60EC9FC95053</CodeSharingProject> + </PropertyGroup> + <ItemDefinitionGroup> + <ClCompile> + <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ProjectCapability Include="SourceItemsFromImports" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\BasicShaderSourceStreamFactory.h" /> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\FreeBlockListManager.h" /> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\FreeBlockListManagerGPU.h" /> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\GraphicsUtilities.h" /> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\pch.h" /> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\RingBuffer.h" /> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\ShaderMacroHelper.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\BasicShaderSourceStreamFactory.cpp" /> + <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\GraphicsUtilities.cpp" /> + <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\pch.cpp"> + <PrecompiledHeader>Create</PrecompiledHeader> + </ClCompile> + </ItemGroup> + <ItemGroup> + <Text Include="$(MSBuildThisFileDirectory)..\..\CMakeLists.txt"> + <DeploymentContent>false</DeploymentContent> + </Text> + </ItemGroup> +</Project>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="include"> + <UniqueIdentifier>{610cb4a4-ad9a-42e0-936c-239055f0caa6}</UniqueIdentifier> + </Filter> + <Filter Include="src"> + <UniqueIdentifier>{2fa69c92-b6b7-4e73-9ccd-49a715515cc8}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\pch.h"> + <Filter>include</Filter> + </ClInclude> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\BasicShaderSourceStreamFactory.h"> + <Filter>include</Filter> + </ClInclude> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\GraphicsUtilities.h"> + <Filter>include</Filter> + </ClInclude> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\ShaderMacroHelper.h"> + <Filter>include</Filter> + </ClInclude> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\RingBuffer.h"> + <Filter>include</Filter> + </ClInclude> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\FreeBlockListManager.h"> + <Filter>include</Filter> + </ClInclude> + <ClInclude Include="$(MSBuildThisFileDirectory)..\..\include\FreeBlockListManagerGPU.h"> + <Filter>include</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\pch.cpp"> + <Filter>src</Filter> + </ClCompile> + <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\BasicShaderSourceStreamFactory.cpp"> + <Filter>src</Filter> + </ClCompile> + <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\GraphicsUtilities.cpp"> + <Filter>src</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <Text Include="$(MSBuildThisFileDirectory)..\..\CMakeLists.txt" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/EngineRoot.props b/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.props index 6e4b958b..4da87146 100644 --- a/Graphics/GraphicsTools/build/Windows/EngineRoot.props +++ b/Graphics/GraphicsTools/build/Windows.Shared/GraphicsTools.props @@ -5,7 +5,9 @@ <EngineRoot>..\..\..\..</EngineRoot> <GraphicsRoot>..\..\..</GraphicsRoot> </PropertyGroup> - <PropertyGroup /> + <PropertyGroup> + <IncludePath>$(GraphicsRoot)\GraphicsTools\include;$(GraphicsRoot)\GraphicsEngine\interface;$(GraphicsRoot)\TextureLoader\interface;$(EngineRoot)\Common\include;$(EngineRoot)\Common\interface;$(EngineRoot)\Platforms\interface;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath> + </PropertyGroup> <ItemDefinitionGroup /> <ItemGroup> <BuildMacro Include="EngineRoot"> 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 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ImportGroup Label="PropertySheets" /> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup> - <IncludePath>$(GraphicsRoot)\GraphicsTools\include;$(GraphicsRoot)\GraphicsEngine\interface;$(GraphicsRoot)\TextureLoader\interface;$(EngineRoot)\Common\include;$(EngineRoot)\Common\interface;$(EngineRoot)\Platforms\interface;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath> - </PropertyGroup> - <ItemDefinitionGroup /> - <ItemGroup /> -</Project>
\ 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 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ImportGroup Label="PropertySheets" /> - <PropertyGroup Label="UserMacros"> - <EngineRoot>..\..\..\..\..</EngineRoot> - <GraphicsRoot>..\..\..\..</GraphicsRoot> - </PropertyGroup> - <PropertyGroup /> - <ItemDefinitionGroup /> - <ItemGroup> - <BuildMacro Include="EngineRoot"> - <Value>$(EngineRoot)</Value> - </BuildMacro> - <BuildMacro Include="GraphicsRoot"> - <Value>$(GraphicsRoot)</Value> - </BuildMacro> - </ItemGroup> -</Project>
\ 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 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup Label="Globals"> - <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> - <HasSharedItems>true</HasSharedItems> - <ItemsProjectGuid>{3bb4f2ac-1d2f-4af6-b9cc-bdc17bb8bc39}</ItemsProjectGuid> - <ItemsRootNamespace>GraphicsTools</ItemsRootNamespace> - <ItemsProjectName>GraphicsTools.Shared</ItemsProjectName> - <CodeSharingProject>248F659F-DAC5-46E8-AC09-60EC9FC95053</CodeSharingProject> - </PropertyGroup> - <ItemDefinitionGroup> - <ClCompile> - <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories> - </ClCompile> - </ItemDefinitionGroup> - <ItemGroup> - <ProjectCapability Include="SourceItemsFromImports" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\BasicShaderSourceStreamFactory.h" /> - <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\GraphicsUtilities.h" /> - <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\pch.h" /> - <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\ShaderMacroHelper.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\BasicShaderSourceStreamFactory.cpp" /> - <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\GraphicsUtilities.cpp" /> - <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\pch.cpp"> - <PrecompiledHeader>Create</PrecompiledHeader> - </ClCompile> - </ItemGroup> -</Project>
\ 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 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="include"> - <UniqueIdentifier>{610cb4a4-ad9a-42e0-936c-239055f0caa6}</UniqueIdentifier> - </Filter> - <Filter Include="src"> - <UniqueIdentifier>{2fa69c92-b6b7-4e73-9ccd-49a715515cc8}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\pch.h"> - <Filter>include</Filter> - </ClInclude> - <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\BasicShaderSourceStreamFactory.h"> - <Filter>include</Filter> - </ClInclude> - <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\GraphicsUtilities.h"> - <Filter>include</Filter> - </ClInclude> - <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\ShaderMacroHelper.h"> - <Filter>include</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\pch.cpp"> - <Filter>src</Filter> - </ClCompile> - <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\BasicShaderSourceStreamFactory.cpp"> - <Filter>src</Filter> - </ClCompile> - <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\GraphicsUtilities.cpp"> - <Filter>src</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ 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 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - </ItemGroup> -</Project> 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 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|ARM"> - <Configuration>Debug</Configuration> - <Platform>ARM</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|ARM"> - <Configuration>Release</Configuration> - <Platform>ARM</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{2f340c0e-43b2-471f-b4f3-7cdce69f6e1f}</ProjectGuid> - <RootNamespace>GraphicsTools</RootNamespace> - <DefaultLanguage>en-US</DefaultLanguage> - <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion> - <AppContainerApplication>true</AppContainerApplication> - <ApplicationType>Windows Phone</ApplicationType> - <ApplicationTypeRevision>8.1</ApplicationTypeRevision> - <ConvergedProjectType>CodeSharingStaticLibrary</ConvergedProjectType> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120_wp81</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120_wp81</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120_wp81</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120_wp81</PlatformToolset> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <Import Project="..\GraphicsTools.Shared\GraphicsTools.Shared.vcxitems" Label="Shared" /> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore32Dbg.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore32Rel.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStoreArmDbg.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStoreArmRel.props" /> - <Import Project="..\EngineRoot.props" /> - <Import Project="..\..\Windows\GraphicsTools.props" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <GenerateManifest>false</GenerateManifest> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <GenerateManifest>false</GenerateManifest> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> - <GenerateManifest>false</GenerateManifest> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> - <GenerateManifest>false</GenerateManifest> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <CompileAsWinRT>false</CompileAsWinRT> - <SDLCheck>true</SDLCheck> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <GenerateWindowsMetadata>false</GenerateWindowsMetadata> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <CompileAsWinRT>false</CompileAsWinRT> - <SDLCheck>true</SDLCheck> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <GenerateWindowsMetadata>false</GenerateWindowsMetadata> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <CompileAsWinRT>false</CompileAsWinRT> - <SDLCheck>true</SDLCheck> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <GenerateWindowsMetadata>false</GenerateWindowsMetadata> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <CompileAsWinRT>false</CompileAsWinRT> - <SDLCheck>true</SDLCheck> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <GenerateWindowsMetadata>false</GenerateWindowsMetadata> - </Link> - </ItemDefinitionGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ 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 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - </ItemGroup> -</Project> 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 <map> +#include "MemoryAllocator.h" +#include "FixedBlockMemoryAllocator.h" +#include "STDAllocator.h" +#include "DebugUtilities.h" + +namespace Diligent +{ + class FreeBlockListManager + { + public: + typedef size_t OffsetType; + typedef std::pair<Uint64,OffsetType> FrameNumOffsetPair; + + struct FreeBlockInfo; + typedef std::map<OffsetType, + FreeBlockInfo, + std::less<OffsetType>, // Standard ordering + STDAllocatorRawMem<std::pair<OffsetType, FreeBlockInfo>> // Raw memory allocator + > TFreeBlocksByOffsetMap; + typedef std::multimap<OffsetType, + TFreeBlocksByOffsetMap::iterator, + std::less<OffsetType>, // Standard ordering + STDAllocatorRawMem<std::pair<OffsetType, TFreeBlocksByOffsetMap::iterator>> // 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<OffsetType>(-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<OffsetType, FreeBlockInfo>") ), + m_FreeBlocksBySize( STD_ALLOCATOR_RAW_MEM(TFreeBlocksBySizeMap::value_type, Allocator, "multimap<OffsetType, TFreeBlocksByOffsetMap::iterator>") ) + { + 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 <deque> +#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<FreedAllocationInfo> > 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<VT_FLOAT16>{ typedef Uint16 CType; }; template<>struct VALUE_TYPE2CType<VT_FLOAT32>{ typedef Float32 CType; }; +static const Uint32 ValueTypeToSizeMap[] = +{ + 0, + sizeof(VALUE_TYPE2CType<VT_INT8> :: CType), + sizeof(VALUE_TYPE2CType<VT_INT16> :: CType), + sizeof(VALUE_TYPE2CType<VT_INT32> :: CType), + sizeof(VALUE_TYPE2CType<VT_UINT8> :: CType), + sizeof(VALUE_TYPE2CType<VT_UINT16> :: CType), + sizeof(VALUE_TYPE2CType<VT_UINT32> :: CType), + sizeof(VALUE_TYPE2CType<VT_FLOAT16> :: CType), + sizeof(VALUE_TYPE2CType<VT_FLOAT32> :: 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 <deque> +#include "MemoryAllocator.h" +#include "STDAllocator.h" +#include "DebugUtilities.h" + +namespace Diligent +{ + class RingBuffer + { + public: + typedef size_t OffsetType; + typedef std::pair<Uint64,OffsetType> FrameNumOffsetPair; + + static const OffsetType InvalidOffset = static_cast<OffsetType>(-1); + + RingBuffer(OffsetType MaxSize, IMemoryAllocator &Allocator) : + m_CompletedFrameTails(0, FrameNumOffsetPair(), STD_ALLOCATOR_RAW_MEM(FrameNumOffsetPair, Allocator, "Allocator for vector<FrameNumOffsetPair>" )), + 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<FrameNumOffsetPair> > 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<ValType>::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<TEXTURE_FORMAT>(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. |
