Browse Source

Renamed all projects from Camelot -> Banshee and moved them to appropriate folders

Marko Pintera 11 years ago
parent
commit
47fcfd429d
100 changed files with 14046 additions and 14046 deletions
  1. 523 523
      BansheeCore/BansheeCore.vcxproj
  2. 824 824
      BansheeCore/BansheeCore.vcxproj.filters
  3. 0 0
      BansheeCore/Include/BsCommonTypes.h
  4. 1 1
      BansheeCore/Include/BsGPUProfiler.h
  5. 0 0
      BansheeCore/Include/BsRenderStats.h
  6. 120 120
      BansheeCore/Include/CmApplication.h
  7. 42 42
      BansheeCore/Include/CmBindableGpuParamBlock.h
  8. 72 72
      BansheeCore/Include/CmBindableGpuParams.h
  9. 169 169
      BansheeCore/Include/CmBlendState.h
  10. 93 93
      BansheeCore/Include/CmBlendStateRTTI.h
  11. 452 452
      BansheeCore/Include/CmCPUProfiler.h
  12. 399 399
      BansheeCore/Include/CmCommandQueue.h
  13. 65 65
      BansheeCore/Include/CmComponent.h
  14. 34 34
      BansheeCore/Include/CmComponentRTTI.h
  15. 265 265
      BansheeCore/Include/CmCoreObject.h
  16. 38 38
      BansheeCore/Include/CmCoreObjectManager.h
  17. 203 203
      BansheeCore/Include/CmCoreThread.h
  18. 204 204
      BansheeCore/Include/CmCoreThreadAccessor.h
  19. 16 16
      BansheeCore/Include/CmDefaultRenderQueue.h
  20. 36 36
      BansheeCore/Include/CmDeferredCallManager.h
  21. 170 170
      BansheeCore/Include/CmDepthStencilState.h
  22. 51 51
      BansheeCore/Include/CmDepthStencilStateRTTI.h
  23. 25 25
      BansheeCore/Include/CmDrawOps.h
  24. 57 57
      BansheeCore/Include/CmEventQuery.h
  25. 6 6
      BansheeCore/Include/CmFolderMonitor.h
  26. 97 97
      BansheeCore/Include/CmFont.h
  27. 162 162
      BansheeCore/Include/CmFontDesc.h
  28. 76 76
      BansheeCore/Include/CmFontImportOptions.h
  29. 48 48
      BansheeCore/Include/CmFontImportOptionsRTTI.h
  30. 25 25
      BansheeCore/Include/CmFontManager.h
  31. 158 158
      BansheeCore/Include/CmFontRTTI.h
  32. 79 79
      BansheeCore/Include/CmGameObject.h
  33. 298 298
      BansheeCore/Include/CmGameObjectHandle.h
  34. 46 46
      BansheeCore/Include/CmGameObjectHandleRTTI.h
  35. 101 101
      BansheeCore/Include/CmGameObjectManager.h
  36. 54 54
      BansheeCore/Include/CmGameObjectRTTI.h
  37. 184 184
      BansheeCore/Include/CmGpuBuffer.h
  38. 97 97
      BansheeCore/Include/CmGpuBufferView.h
  39. 330 330
      BansheeCore/Include/CmGpuParam.h
  40. 65 65
      BansheeCore/Include/CmGpuParamBlock.h
  41. 100 100
      BansheeCore/Include/CmGpuParamBlockBuffer.h
  42. 57 57
      BansheeCore/Include/CmGpuParamDesc.h
  43. 233 233
      BansheeCore/Include/CmGpuParams.h
  44. 34 34
      BansheeCore/Include/CmGpuProgInclude.h
  45. 27 27
      BansheeCore/Include/CmGpuProgIncludeImporter.h
  46. 201 201
      BansheeCore/Include/CmGpuProgram.h
  47. 86 86
      BansheeCore/Include/CmGpuProgramImportOptions.h
  48. 55 55
      BansheeCore/Include/CmGpuProgramImportOptionsRTTI.h
  49. 26 26
      BansheeCore/Include/CmGpuProgramImporter.h
  50. 100 100
      BansheeCore/Include/CmGpuProgramManager.h
  51. 53 53
      BansheeCore/Include/CmGpuProgramRTTI.h
  52. 42 42
      BansheeCore/Include/CmGpuResource.h
  53. 99 99
      BansheeCore/Include/CmGpuResourceData.h
  54. 32 32
      BansheeCore/Include/CmGpuResourceDataRTTI.h
  55. 32 32
      BansheeCore/Include/CmGpuResourceRTTI.h
  56. 173 173
      BansheeCore/Include/CmHardwareBuffer.h
  57. 107 107
      BansheeCore/Include/CmHardwareBufferManager.h
  58. 24 24
      BansheeCore/Include/CmImportOptions.h
  59. 31 31
      BansheeCore/Include/CmImportOptionsRTTI.h
  60. 88 88
      BansheeCore/Include/CmImporter.h
  61. 48 48
      BansheeCore/Include/CmIndexBuffer.h
  62. 21 21
      BansheeCore/Include/CmIndexData.h
  63. 197 197
      BansheeCore/Include/CmInput.h
  64. 376 376
      BansheeCore/Include/CmInputFwd.h
  65. 516 516
      BansheeCore/Include/CmMaterial.h
  66. 25 25
      BansheeCore/Include/CmMaterialManager.h
  67. 590 590
      BansheeCore/Include/CmMaterialRTTI.h
  68. 207 207
      BansheeCore/Include/CmMesh.h
  69. 144 144
      BansheeCore/Include/CmMeshBase.h
  70. 56 56
      BansheeCore/Include/CmMeshBaseRTTI.h
  71. 329 329
      BansheeCore/Include/CmMeshData.h
  72. 74 74
      BansheeCore/Include/CmMeshDataRTTI.h
  73. 241 241
      BansheeCore/Include/CmMeshHeap.h
  74. 88 88
      BansheeCore/Include/CmMeshManager.h
  75. 64 64
      BansheeCore/Include/CmMultiRenderTexture.h
  76. 165 165
      BansheeCore/Include/CmOSInputHandler.h
  77. 75 75
      BansheeCore/Include/CmOcclusionQuery.h
  78. 96 96
      BansheeCore/Include/CmPass.h
  79. 68 68
      BansheeCore/Include/CmPassRTTI.h
  80. 92 92
      BansheeCore/Include/CmPixelBuffer.h
  81. 324 324
      BansheeCore/Include/CmPixelData.h
  82. 91 91
      BansheeCore/Include/CmPixelDataRTTI.h
  83. 194 194
      BansheeCore/Include/CmPixelUtil.h
  84. 43 43
      BansheeCore/Include/CmPixelVolume.h
  85. 189 189
      BansheeCore/Include/CmPlatform.h
  86. 358 358
      BansheeCore/Include/CmPrerequisites.h
  87. 145 145
      BansheeCore/Include/CmProfiler.h
  88. 70 70
      BansheeCore/Include/CmQueryManager.h
  89. 147 147
      BansheeCore/Include/CmRasterizerState.h
  90. 53 53
      BansheeCore/Include/CmRasterizerStateRTTI.h
  91. 94 94
      BansheeCore/Include/CmRawInputHandler.h
  92. 22 22
      BansheeCore/Include/CmRenderOperation.h
  93. 64 64
      BansheeCore/Include/CmRenderQueue.h
  94. 108 108
      BansheeCore/Include/CmRenderStateManager.h
  95. 399 399
      BansheeCore/Include/CmRenderSystem.h
  96. 654 654
      BansheeCore/Include/CmRenderSystemCapabilities.h
  97. 23 23
      BansheeCore/Include/CmRenderSystemFactory.h
  98. 40 40
      BansheeCore/Include/CmRenderSystemManager.h
  99. 170 170
      BansheeCore/Include/CmRenderTarget.h
  100. 101 101
      BansheeCore/Include/CmRenderTexture.h

+ 523 - 523
CamelotCore/CamelotCore.vcxproj → BansheeCore/BansheeCore.vcxproj

@@ -1,524 +1,524 @@
-<?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="DebugRelease|Win32">
-      <Configuration>DebugRelease</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="DebugRelease|x64">
-      <Configuration>DebugRelease</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Debug|x64">
-      <Configuration>Debug</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|x64">
-      <Configuration>Release</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{9B21D41C-516B-43BF-9B10-E99B599C7589}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>CamelotCore</RootNamespace>
-    <ProjectName>CamelotCore</ProjectName>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v120</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>NotSet</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </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" />
-  </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" />
-  </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" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </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" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
-    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
-    <OutDir>..\bin\x86\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <LinkIncremental>true</LinkIncremental>
-    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
-    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
-    <OutDir>..\bin\$(Platform)\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
-    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
-    <OutDir>..\bin\x86\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
-    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
-    <OutDir>..\bin\x86\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
-    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
-    <OutDir>..\bin\$(Platform)\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
-    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
-    <OutDir>..\bin\$(Platform)\$(Configuration)\</OutDir>
-    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>_VARIADIC_MAX=8;WIN32;_DEBUG;_CONSOLE;CM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>./Include;../CamelotUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
-    </ClCompile>
-    <Link>
-      <SubSystem>NotSet</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>CamelotUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
-      <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>_VARIADIC_MAX=8;WIN32;_DEBUG;_CONSOLE;CM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>./Include;../CamelotUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
-    </ClCompile>
-    <Link>
-      <SubSystem>NotSet</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>CamelotUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
-      <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>_VARIADIC_MAX=8;WIN32;NDEBUG;_CONSOLE;CM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>./Include;../CamelotUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
-      <DebugInformationFormat>None</DebugInformationFormat>
-      <BufferSecurityCheck>false</BufferSecurityCheck>
-    </ClCompile>
-    <Link>
-      <SubSystem>NotSet</SubSystem>
-      <GenerateDebugInformation>false</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>CamelotUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Release</AdditionalLibraryDirectories>
-      <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>_VARIADIC_MAX=8;WIN32;NDEBUG;_CONSOLE;CM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>./Include;../CamelotUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
-      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
-      <BufferSecurityCheck>false</BufferSecurityCheck>
-      <MinimalRebuild>true</MinimalRebuild>
-    </ClCompile>
-    <Link>
-      <SubSystem>NotSet</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>CamelotUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/DebugRelease</AdditionalLibraryDirectories>
-      <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>_VARIADIC_MAX=8;WIN32;NDEBUG;_CONSOLE;CM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>./Include;../CamelotUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
-      <DebugInformationFormat>None</DebugInformationFormat>
-      <BufferSecurityCheck>false</BufferSecurityCheck>
-    </ClCompile>
-    <Link>
-      <SubSystem>NotSet</SubSystem>
-      <GenerateDebugInformation>false</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>CamelotUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Release</AdditionalLibraryDirectories>
-      <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>_VARIADIC_MAX=8;WIN32;NDEBUG;_CONSOLE;CM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>./Include;../CamelotUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
-      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
-      <BufferSecurityCheck>false</BufferSecurityCheck>
-      <MinimalRebuild>true</MinimalRebuild>
-    </ClCompile>
-    <Link>
-      <SubSystem>NotSet</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>CamelotUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/DebugRelease</AdditionalLibraryDirectories>
-      <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsRenderStats.h" />
-    <ClInclude Include="Include\CmBindableGpuParamBlock.h" />
-    <ClInclude Include="Include\CmBindableGpuParams.h" />
-    <ClInclude Include="Include\CmCoreThread.h" />
-    <ClInclude Include="Include\CmCPUProfiler.h" />
-    <ClInclude Include="Include\CmDefaultRenderQueue.h" />
-    <ClInclude Include="Include\CmDeferredCallManager.h" />
-    <ClInclude Include="Include\CmDrawOps.h" />
-    <ClInclude Include="Include\CmEventQuery.h" />
-    <ClInclude Include="Include\CmFolderMonitor.h" />
-    <ClInclude Include="Include\CmGameObjectHandle.h" />
-    <ClInclude Include="Include\CmGameObject.h" />
-    <ClInclude Include="Include\CmGameObjectHandleRTTI.h" />
-    <ClInclude Include="Include\CmGameObjectManager.h" />
-    <ClInclude Include="Include\CmGameObjectRTTI.h" />
-    <ClInclude Include="Include\BsGPUProfiler.h" />
-    <ClInclude Include="Include\CmGpuResourceData.h" />
-    <ClInclude Include="Include\CmGpuParamBlockBuffer.h" />
-    <ClInclude Include="Include\CmGpuResource.h" />
-    <ClInclude Include="Include\CmGpuResourceDataRTTI.h" />
-    <ClInclude Include="Include\CmGpuResourceRTTI.h" />
-    <ClInclude Include="Include\CmGpuParam.h" />
-    <ClInclude Include="Include\CmInputFwd.h" />
-    <ClInclude Include="Include\CmMeshBase.h" />
-    <ClInclude Include="Include\CmMeshBaseRTTI.h" />
-    <ClInclude Include="Include\CmMeshHeap.h" />
-    <ClInclude Include="Include\CmOSInputHandler.h" />
-    <ClInclude Include="Include\CmPixelData.h" />
-    <ClInclude Include="Include\CmPixelDataRTTI.h" />
-    <ClInclude Include="Include\CmPixelUtil.h" />
-    <ClInclude Include="Include\CmPixelVolume.h" />
-    <ClInclude Include="Include\CmPlatform.h" />
-    <ClInclude Include="Include\CmPlatformWndProc.h" />
-    <ClInclude Include="Include\CmProfiler.h" />
-    <ClInclude Include="Include\CmQueryManager.h" />
-    <ClInclude Include="Include\CmRenderOperation.h" />
-    <ClInclude Include="Include\CmRenderQueue.h" />
-    <ClInclude Include="Include\CmResourceManifest.h" />
-    <ClInclude Include="Include\CmResourceManifestRTTI.h" />
-    <ClInclude Include="Include\CmSceneObjectRTTI.h" />
-    <ClInclude Include="Include\CmApplication.h" />
-    <ClInclude Include="Include\CmBlendStateRTTI.h" />
-    <ClInclude Include="Include\CmCommandQueue.h" />
-    <ClInclude Include="Include\BsCommonTypes.h" />
-    <ClInclude Include="Include\CmComponentRTTI.h" />
-    <ClInclude Include="Include\CmCoreObject.h" />
-    <ClInclude Include="Include\CmCoreObjectManager.h" />
-    <ClInclude Include="Include\CmCoreThreadAccessor.h" />
-    <ClInclude Include="Include\CmDepthStencilStateRTTI.h" />
-    <ClInclude Include="Include\CmDepthStencilState.h" />
-    <ClInclude Include="Include\CmFont.h" />
-    <ClInclude Include="Include\CmFontDesc.h" />
-    <ClInclude Include="Include\CmFontImportOptions.h" />
-    <ClInclude Include="Include\CmFontImportOptionsRTTI.h" />
-    <ClInclude Include="Include\CmFontManager.h" />
-    <ClInclude Include="Include\CmFontRTTI.h" />
-    <ClInclude Include="Include\CmGpuBuffer.h" />
-    <ClInclude Include="Include\CmGpuBufferView.h" />
-    <ClInclude Include="Include\CmGpuParamBlock.h" />
-    <ClInclude Include="Include\CmGpuParamDesc.h" />
-    <ClInclude Include="Include\CmGpuParams.h" />
-    <ClInclude Include="Include\CmGpuProgInclude.h" />
-    <ClInclude Include="Include\CmGpuProgram.h" />
-    <ClInclude Include="Include\CmGpuProgramImporter.h" />
-    <ClInclude Include="Include\CmGpuProgramImportOptions.h" />
-    <ClInclude Include="Include\CmGpuProgramImportOptionsRTTI.h" />
-    <ClInclude Include="Include\CmGpuProgramRTTI.h" />
-    <ClInclude Include="Include\CmHardwareBuffer.h" />
-    <ClInclude Include="Include\CmHardwareBufferManager.h" />
-    <ClInclude Include="Include\CmImportOptions.h" />
-    <ClInclude Include="Include\CmImportOptionsRTTI.h" />
-    <ClInclude Include="Include\CmIndexBuffer.h" />
-    <ClInclude Include="Include\CmMaterialManager.h" />
-    <ClInclude Include="Include\CmMeshManager.h" />
-    <ClInclude Include="Include\CmOcclusionQuery.h" />
-    <ClInclude Include="Include\CmPixelBuffer.h" />
-    <ClInclude Include="Include\CmGpuProgIncludeImporter.h" />
-    <ClInclude Include="Include\CmSubMesh.h" />
-    <ClInclude Include="Include\CmTextureView.h" />
-    <ClInclude Include="Include\CmTextData.h" />
-    <ClInclude Include="Include\CmTimerQuery.h" />
-    <ClInclude Include="Include\CmTransientMesh.h" />
-    <ClInclude Include="Include\CmUUID.h" />
-    <ClInclude Include="Include\CmVertexBuffer.h" />
-    <ClInclude Include="Include\CmGpuProgramManager.h" />
-    <ClInclude Include="Include\CmImporter.h" />
-    <ClInclude Include="Include\CmInput.h" />
-    <ClInclude Include="Include\CmRawInputHandler.h" />
-    <ClInclude Include="Include\CmMaterial.h" />
-    <ClInclude Include="Include\CmMaterialRTTI.h" />
-    <ClInclude Include="Include\CmMesh.h" />
-    <ClInclude Include="Include\CmMeshData.h" />
-    <ClInclude Include="Include\CmMeshDataRTTI.h" />
-    <ClInclude Include="Include\CmMultiRenderTexture.h" />
-    <ClInclude Include="Include\CmPass.h" />
-    <ClInclude Include="Include\CmPassRTTI.h" />
-    <ClInclude Include="Include\CmPrerequisites.h" />
-    <ClInclude Include="Include\CmRasterizerState.h" />
-    <ClInclude Include="Include\CmRasterizerStateRTTI.h" />
-    <ClInclude Include="Include\CmRenderer.h" />
-    <ClInclude Include="Include\CmRendererFactory.h" />
-    <ClInclude Include="Include\CmRendererManager.h" />
-    <ClInclude Include="Include\CmRenderStateManager.h" />
-    <ClInclude Include="Include\CmRenderSystem.h" />
-    <ClInclude Include="Include\CmRenderSystemCapabilities.h" />
-    <ClInclude Include="Include\CmRenderSystemFactory.h" />
-    <ClInclude Include="Include\CmRenderSystemManager.h" />
-    <ClInclude Include="Include\CmRenderTarget.h" />
-    <ClInclude Include="Include\CmRenderTexture.h" />
-    <ClInclude Include="Include\CmRenderWindow.h" />
-    <ClInclude Include="Include\CmRenderWindowManager.h" />
-    <ClInclude Include="Include\CmResource.h" />
-    <ClInclude Include="Include\CmResourceHandle.h" />
-    <ClInclude Include="Include\CmResourceHandleRTTI.h" />
-    <ClInclude Include="Include\CmResources.h" />
-    <ClInclude Include="Include\CmSamplerStateRTTI.h" />
-    <ClInclude Include="Include\CmSceneManager.h" />
-    <ClInclude Include="Include\CmShaderRTTI.h" />
-    <ClInclude Include="Include\CmSpecificImporter.h" />
-    <ClInclude Include="Include\CmTechniqueRTTI.h" />
-    <ClInclude Include="Include\CmTexture.h" />
-    <ClInclude Include="Include\CmTextureManager.h" />
-    <ClInclude Include="Include\CmTextureRTTI.h" />
-    <ClInclude Include="Include\CmSamplerState.h" />
-    <ClInclude Include="Include\CmIndexData.h" />
-    <ClInclude Include="Include\CmVertexDataDesc.h" />
-    <ClInclude Include="Include\CmVertexDataDescRTTI.h" />
-    <ClInclude Include="Include\CmVertexDeclaration.h" />
-    <ClInclude Include="Include\CmVertexData.h" />
-    <ClInclude Include="Include\CmVideoModeInfo.h" />
-    <ClInclude Include="Include\CmViewport.h" />
-    <ClInclude Include="Include\CmResourceRTTI.h" />
-    <ClInclude Include="Include\CmSceneObject.h" />
-    <ClInclude Include="Include\CmComponent.h" />
-    <ClInclude Include="Include\CmShader.h" />
-    <ClInclude Include="Include\CmBlendState.h" />
-    <ClInclude Include="Include\CmVertexDeclarationRTTI.h" />
-    <ClInclude Include="Include\CmTechnique.h" />
-    <ClInclude Include="Include\Win32\CmPlatformImpl.h" />
-    <ClInclude Include="Include\Win32\CmWin32Defs.h" />
-    <ClInclude Include="Include\Win32\CmWin32DropTarget.h" />
-    <ClInclude Include="Include\Win32\CmWin32FolderMonitor.h" />
-    <ClInclude Include="Source\CmMeshRTTI.h" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\CmBindableGpuParamBlock.cpp" />
-    <ClCompile Include="Source\CmBindableGpuParams.cpp" />
-    <ClCompile Include="Source\CmCoreThread.cpp" />
-    <ClCompile Include="Source\CmCPUProfiler.cpp" />
-    <ClCompile Include="Source\CmDefaultRenderQueue.cpp" />
-    <ClCompile Include="Source\CmDeferredCallManager.cpp" />
-    <ClCompile Include="Source\CmDrawOps.cpp" />
-    <ClCompile Include="Source\CmEventQuery.cpp" />
-    <ClCompile Include="Source\CmGameObjectHandle.cpp" />
-    <ClCompile Include="Source\CmGameObject.cpp" />
-    <ClCompile Include="Source\CmApplication.cpp" />
-    <ClCompile Include="Source\CmBlendState.cpp" />
-    <ClCompile Include="Source\CmCommandQueue.cpp" />
-    <ClCompile Include="Source\CmCoreObject.cpp" />
-    <ClCompile Include="Source\CmCoreObjectManager.cpp" />
-    <ClCompile Include="Source\CmCoreThreadAccessor.cpp" />
-    <ClCompile Include="Source\CmDepthStencilState.cpp" />
-    <ClCompile Include="Source\CmFont.cpp" />
-    <ClCompile Include="Source\CmFontImportOptions.cpp" />
-    <ClCompile Include="Source\CmFontManager.cpp" />
-    <ClCompile Include="Source\CmGameObjectManager.cpp" />
-    <ClCompile Include="Source\CmGpuBuffer.cpp" />
-    <ClCompile Include="Source\CmGpuBufferView.cpp" />
-    <ClCompile Include="Source\CmGpuParamBlock.cpp" />
-    <ClCompile Include="Source\CmGpuParamBlockBuffer.cpp" />
-    <ClCompile Include="Source\CmGpuParams.cpp" />
-    <ClCompile Include="Source\BsGPUProfiler.cpp" />
-    <ClCompile Include="Source\CmGpuProgInclude.cpp" />
-    <ClCompile Include="Source\CmGpuProgram.cpp" />
-    <ClCompile Include="Source\CmGpuProgramImporter.cpp" />
-    <ClCompile Include="Source\CmGpuProgramImportOptions.cpp" />
-    <ClCompile Include="Source\CmGpuResource.cpp" />
-    <ClCompile Include="Source\CmGpuResourceData.cpp" />
-    <ClCompile Include="Source\CmHardwareBufferManager.cpp" />
-    <ClCompile Include="Source\CmGpuParam.cpp" />
-    <ClCompile Include="Source\CmImportOptions.cpp" />
-    <ClCompile Include="Source\CmIndexBuffer.cpp" />
-    <ClCompile Include="Source\CmIndexData.cpp" />
-    <ClCompile Include="Source\CmMaterialManager.cpp" />
-    <ClCompile Include="Source\CmMeshBase.cpp" />
-    <ClCompile Include="Source\CmMeshHeap.cpp" />
-    <ClCompile Include="Source\CmMeshManager.cpp" />
-    <ClCompile Include="Source\CmOcclusionQuery.cpp" />
-    <ClCompile Include="Source\CmOSInputHandler.cpp" />
-    <ClCompile Include="Source\CmPixelBuffer.cpp" />
-    <ClCompile Include="Source\CmGpuProgIncludeImporter.cpp" />
-    <ClCompile Include="Source\CmPixelData.cpp" />
-    <ClCompile Include="Source\CmPixelUtil.cpp" />
-    <ClCompile Include="Source\CmPixelVolume.cpp" />
-    <ClCompile Include="Source\CmPlatform.cpp" />
-    <ClCompile Include="Source\CmProfiler.cpp" />
-    <ClCompile Include="Source\CmQueryManager.cpp" />
-    <ClCompile Include="Source\CmRenderer.cpp" />
-    <ClCompile Include="Source\CmRenderQueue.cpp" />
-    <ClCompile Include="Source\CmResourceManifest.cpp" />
-    <ClCompile Include="Source\CmTextureView.cpp" />
-    <ClCompile Include="Source\CmTextData.cpp" />
-    <ClCompile Include="Source\CmTimerQuery.cpp" />
-    <ClCompile Include="Source\CmTransientMesh.cpp" />
-    <ClCompile Include="Source\CmUUID.cpp" />
-    <ClCompile Include="Source\CmVertexBuffer.cpp" />
-    <ClCompile Include="Source\CmGpuProgramManager.cpp" />
-    <ClCompile Include="Source\CmImporter.cpp" />
-    <ClCompile Include="Source\CmInput.cpp" />
-    <ClCompile Include="Source\CmMaterial.cpp" />
-    <ClCompile Include="Source\CmMaterialRTTI.cpp" />
-    <ClCompile Include="Source\CmMesh.cpp" />
-    <ClCompile Include="Source\CmMeshData.cpp" />
-    <ClCompile Include="Source\CmMultiRenderTexture.cpp" />
-    <ClCompile Include="Source\CmPass.cpp" />
-    <ClCompile Include="Source\CmRasterizerState.cpp" />
-    <ClCompile Include="Source\CmRendererManager.cpp" />
-    <ClCompile Include="Source\CmRenderSystem.cpp" />
-    <ClCompile Include="Source\CmRenderSystemCapabilities.cpp" />
-    <ClCompile Include="Source\CmRenderSystemManager.cpp" />
-    <ClCompile Include="Source\CmRenderTarget.cpp" />
-    <ClCompile Include="Source\CmRenderTexture.cpp" />
-    <ClCompile Include="Source\CmRenderWindow.cpp" />
-    <ClCompile Include="Source\CmRenderWindowManager.cpp" />
-    <ClCompile Include="Source\CmResource.cpp" />
-    <ClCompile Include="Source\CmResourceHandle.cpp" />
-    <ClCompile Include="Source\CmResources.cpp" />
-    <ClCompile Include="Source\CmRenderStateManager.cpp" />
-    <ClCompile Include="Source\CmSceneManager.cpp" />
-    <ClCompile Include="Source\CmShader.cpp" />
-    <ClCompile Include="Source\CmSpecificImporter.cpp" />
-    <ClCompile Include="Source\CmTechnique.cpp" />
-    <ClCompile Include="Source\CmTexture.cpp" />
-    <ClCompile Include="Source\CmTextureManager.cpp" />
-    <ClCompile Include="Source\CmSamplerState.cpp" />
-    <ClCompile Include="Source\CmVertexDataDesc.cpp" />
-    <ClCompile Include="Source\CmVertexDeclaration.cpp" />
-    <ClCompile Include="Source\CmVertexData.cpp" />
-    <ClCompile Include="Source\CmVideoModeInfo.cpp" />
-    <ClCompile Include="Source\CmViewport.cpp" />
-    <ClCompile Include="Source\CmSceneObject.cpp" />
-    <ClCompile Include="Source\CmComponent.cpp" />
-    <ClCompile Include="Source\Win32\CmPlatformImpl.cpp" />
-    <ClCompile Include="Source\Win32\CmPlatformWndProc.cpp" />
-    <ClCompile Include="Source\Win32\CmWin32FolderMonitor.cpp" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
+<?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="DebugRelease|Win32">
+      <Configuration>DebugRelease</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="DebugRelease|x64">
+      <Configuration>DebugRelease</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{9B21D41C-516B-43BF-9B10-E99B599C7589}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>CamelotCore</RootNamespace>
+    <ProjectName>BansheeCore</ProjectName>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v120</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </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" />
+  </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" />
+  </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" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </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" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
+    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
+    <OutDir>..\bin\x86\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
+    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
+    <OutDir>..\bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
+    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
+    <OutDir>..\bin\x86\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
+    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
+    <OutDir>..\bin\x86\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
+    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
+    <OutDir>..\bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
+    <LinkIncremental>false</LinkIncremental>
+    <IncludePath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
+    <LibraryPath>C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
+    <OutDir>..\bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>.\Intermediate\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;BS_CORE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>./Include;../BansheeUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
+    </ClCompile>
+    <Link>
+      <SubSystem>NotSet</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>BansheeUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
+      <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;BS_CORE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>./Include;../BansheeUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
+    </ClCompile>
+    <Link>
+      <SubSystem>NotSet</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>BansheeUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
+      <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;BS_CORE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>./Include;../BansheeUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
+      <DebugInformationFormat>None</DebugInformationFormat>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+    </ClCompile>
+    <Link>
+      <SubSystem>NotSet</SubSystem>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>BansheeUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Release</AdditionalLibraryDirectories>
+      <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;BS_CORE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>./Include;../BansheeUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <MinimalRebuild>true</MinimalRebuild>
+    </ClCompile>
+    <Link>
+      <SubSystem>NotSet</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>BansheeUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/DebugRelease</AdditionalLibraryDirectories>
+      <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;BS_CORE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>./Include;../BansheeUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
+      <DebugInformationFormat>None</DebugInformationFormat>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+    </ClCompile>
+    <Link>
+      <SubSystem>NotSet</SubSystem>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>BansheeUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Release</AdditionalLibraryDirectories>
+      <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugRelease|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;BS_CORE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>./Include;../BansheeUtility/Include;../Dependencies/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <MinimalRebuild>true</MinimalRebuild>
+    </ClCompile>
+    <Link>
+      <SubSystem>NotSet</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>BansheeUtility.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/DebugRelease</AdditionalLibraryDirectories>
+      <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsRenderStats.h" />
+    <ClInclude Include="Include\CmBindableGpuParamBlock.h" />
+    <ClInclude Include="Include\CmBindableGpuParams.h" />
+    <ClInclude Include="Include\CmCoreThread.h" />
+    <ClInclude Include="Include\CmCPUProfiler.h" />
+    <ClInclude Include="Include\CmDefaultRenderQueue.h" />
+    <ClInclude Include="Include\CmDeferredCallManager.h" />
+    <ClInclude Include="Include\CmDrawOps.h" />
+    <ClInclude Include="Include\CmEventQuery.h" />
+    <ClInclude Include="Include\CmFolderMonitor.h" />
+    <ClInclude Include="Include\CmGameObjectHandle.h" />
+    <ClInclude Include="Include\CmGameObject.h" />
+    <ClInclude Include="Include\CmGameObjectHandleRTTI.h" />
+    <ClInclude Include="Include\CmGameObjectManager.h" />
+    <ClInclude Include="Include\CmGameObjectRTTI.h" />
+    <ClInclude Include="Include\BsGPUProfiler.h" />
+    <ClInclude Include="Include\CmGpuResourceData.h" />
+    <ClInclude Include="Include\CmGpuParamBlockBuffer.h" />
+    <ClInclude Include="Include\CmGpuResource.h" />
+    <ClInclude Include="Include\CmGpuResourceDataRTTI.h" />
+    <ClInclude Include="Include\CmGpuResourceRTTI.h" />
+    <ClInclude Include="Include\CmGpuParam.h" />
+    <ClInclude Include="Include\CmInputFwd.h" />
+    <ClInclude Include="Include\CmMeshBase.h" />
+    <ClInclude Include="Include\CmMeshBaseRTTI.h" />
+    <ClInclude Include="Include\CmMeshHeap.h" />
+    <ClInclude Include="Include\CmOSInputHandler.h" />
+    <ClInclude Include="Include\CmPixelData.h" />
+    <ClInclude Include="Include\CmPixelDataRTTI.h" />
+    <ClInclude Include="Include\CmPixelUtil.h" />
+    <ClInclude Include="Include\CmPixelVolume.h" />
+    <ClInclude Include="Include\CmPlatform.h" />
+    <ClInclude Include="Include\CmPlatformWndProc.h" />
+    <ClInclude Include="Include\CmProfiler.h" />
+    <ClInclude Include="Include\CmQueryManager.h" />
+    <ClInclude Include="Include\CmRenderOperation.h" />
+    <ClInclude Include="Include\CmRenderQueue.h" />
+    <ClInclude Include="Include\CmResourceManifest.h" />
+    <ClInclude Include="Include\CmResourceManifestRTTI.h" />
+    <ClInclude Include="Include\CmSceneObjectRTTI.h" />
+    <ClInclude Include="Include\CmApplication.h" />
+    <ClInclude Include="Include\CmBlendStateRTTI.h" />
+    <ClInclude Include="Include\CmCommandQueue.h" />
+    <ClInclude Include="Include\BsCommonTypes.h" />
+    <ClInclude Include="Include\CmComponentRTTI.h" />
+    <ClInclude Include="Include\CmCoreObject.h" />
+    <ClInclude Include="Include\CmCoreObjectManager.h" />
+    <ClInclude Include="Include\CmCoreThreadAccessor.h" />
+    <ClInclude Include="Include\CmDepthStencilStateRTTI.h" />
+    <ClInclude Include="Include\CmDepthStencilState.h" />
+    <ClInclude Include="Include\CmFont.h" />
+    <ClInclude Include="Include\CmFontDesc.h" />
+    <ClInclude Include="Include\CmFontImportOptions.h" />
+    <ClInclude Include="Include\CmFontImportOptionsRTTI.h" />
+    <ClInclude Include="Include\CmFontManager.h" />
+    <ClInclude Include="Include\CmFontRTTI.h" />
+    <ClInclude Include="Include\CmGpuBuffer.h" />
+    <ClInclude Include="Include\CmGpuBufferView.h" />
+    <ClInclude Include="Include\CmGpuParamBlock.h" />
+    <ClInclude Include="Include\CmGpuParamDesc.h" />
+    <ClInclude Include="Include\CmGpuParams.h" />
+    <ClInclude Include="Include\CmGpuProgInclude.h" />
+    <ClInclude Include="Include\CmGpuProgram.h" />
+    <ClInclude Include="Include\CmGpuProgramImporter.h" />
+    <ClInclude Include="Include\CmGpuProgramImportOptions.h" />
+    <ClInclude Include="Include\CmGpuProgramImportOptionsRTTI.h" />
+    <ClInclude Include="Include\CmGpuProgramRTTI.h" />
+    <ClInclude Include="Include\CmHardwareBuffer.h" />
+    <ClInclude Include="Include\CmHardwareBufferManager.h" />
+    <ClInclude Include="Include\CmImportOptions.h" />
+    <ClInclude Include="Include\CmImportOptionsRTTI.h" />
+    <ClInclude Include="Include\CmIndexBuffer.h" />
+    <ClInclude Include="Include\CmMaterialManager.h" />
+    <ClInclude Include="Include\CmMeshManager.h" />
+    <ClInclude Include="Include\CmOcclusionQuery.h" />
+    <ClInclude Include="Include\CmPixelBuffer.h" />
+    <ClInclude Include="Include\CmGpuProgIncludeImporter.h" />
+    <ClInclude Include="Include\CmSubMesh.h" />
+    <ClInclude Include="Include\CmTextureView.h" />
+    <ClInclude Include="Include\CmTextData.h" />
+    <ClInclude Include="Include\CmTimerQuery.h" />
+    <ClInclude Include="Include\CmTransientMesh.h" />
+    <ClInclude Include="Include\CmUUID.h" />
+    <ClInclude Include="Include\CmVertexBuffer.h" />
+    <ClInclude Include="Include\CmGpuProgramManager.h" />
+    <ClInclude Include="Include\CmImporter.h" />
+    <ClInclude Include="Include\CmInput.h" />
+    <ClInclude Include="Include\CmRawInputHandler.h" />
+    <ClInclude Include="Include\CmMaterial.h" />
+    <ClInclude Include="Include\CmMaterialRTTI.h" />
+    <ClInclude Include="Include\CmMesh.h" />
+    <ClInclude Include="Include\CmMeshData.h" />
+    <ClInclude Include="Include\CmMeshDataRTTI.h" />
+    <ClInclude Include="Include\CmMultiRenderTexture.h" />
+    <ClInclude Include="Include\CmPass.h" />
+    <ClInclude Include="Include\CmPassRTTI.h" />
+    <ClInclude Include="Include\CmPrerequisites.h" />
+    <ClInclude Include="Include\CmRasterizerState.h" />
+    <ClInclude Include="Include\CmRasterizerStateRTTI.h" />
+    <ClInclude Include="Include\CmRenderer.h" />
+    <ClInclude Include="Include\CmRendererFactory.h" />
+    <ClInclude Include="Include\CmRendererManager.h" />
+    <ClInclude Include="Include\CmRenderStateManager.h" />
+    <ClInclude Include="Include\CmRenderSystem.h" />
+    <ClInclude Include="Include\CmRenderSystemCapabilities.h" />
+    <ClInclude Include="Include\CmRenderSystemFactory.h" />
+    <ClInclude Include="Include\CmRenderSystemManager.h" />
+    <ClInclude Include="Include\CmRenderTarget.h" />
+    <ClInclude Include="Include\CmRenderTexture.h" />
+    <ClInclude Include="Include\CmRenderWindow.h" />
+    <ClInclude Include="Include\CmRenderWindowManager.h" />
+    <ClInclude Include="Include\CmResource.h" />
+    <ClInclude Include="Include\CmResourceHandle.h" />
+    <ClInclude Include="Include\CmResourceHandleRTTI.h" />
+    <ClInclude Include="Include\CmResources.h" />
+    <ClInclude Include="Include\CmSamplerStateRTTI.h" />
+    <ClInclude Include="Include\CmSceneManager.h" />
+    <ClInclude Include="Include\CmShaderRTTI.h" />
+    <ClInclude Include="Include\CmSpecificImporter.h" />
+    <ClInclude Include="Include\CmTechniqueRTTI.h" />
+    <ClInclude Include="Include\CmTexture.h" />
+    <ClInclude Include="Include\CmTextureManager.h" />
+    <ClInclude Include="Include\CmTextureRTTI.h" />
+    <ClInclude Include="Include\CmSamplerState.h" />
+    <ClInclude Include="Include\CmIndexData.h" />
+    <ClInclude Include="Include\CmVertexDataDesc.h" />
+    <ClInclude Include="Include\CmVertexDataDescRTTI.h" />
+    <ClInclude Include="Include\CmVertexDeclaration.h" />
+    <ClInclude Include="Include\CmVertexData.h" />
+    <ClInclude Include="Include\CmVideoModeInfo.h" />
+    <ClInclude Include="Include\CmViewport.h" />
+    <ClInclude Include="Include\CmResourceRTTI.h" />
+    <ClInclude Include="Include\CmSceneObject.h" />
+    <ClInclude Include="Include\CmComponent.h" />
+    <ClInclude Include="Include\CmShader.h" />
+    <ClInclude Include="Include\CmBlendState.h" />
+    <ClInclude Include="Include\CmVertexDeclarationRTTI.h" />
+    <ClInclude Include="Include\CmTechnique.h" />
+    <ClInclude Include="Include\Win32\CmPlatformImpl.h" />
+    <ClInclude Include="Include\Win32\CmWin32Defs.h" />
+    <ClInclude Include="Include\Win32\CmWin32DropTarget.h" />
+    <ClInclude Include="Include\Win32\CmWin32FolderMonitor.h" />
+    <ClInclude Include="Source\CmMeshRTTI.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\CmBindableGpuParamBlock.cpp" />
+    <ClCompile Include="Source\CmBindableGpuParams.cpp" />
+    <ClCompile Include="Source\CmCoreThread.cpp" />
+    <ClCompile Include="Source\CmCPUProfiler.cpp" />
+    <ClCompile Include="Source\CmDefaultRenderQueue.cpp" />
+    <ClCompile Include="Source\CmDeferredCallManager.cpp" />
+    <ClCompile Include="Source\CmDrawOps.cpp" />
+    <ClCompile Include="Source\CmEventQuery.cpp" />
+    <ClCompile Include="Source\CmGameObjectHandle.cpp" />
+    <ClCompile Include="Source\CmGameObject.cpp" />
+    <ClCompile Include="Source\CmApplication.cpp" />
+    <ClCompile Include="Source\CmBlendState.cpp" />
+    <ClCompile Include="Source\CmCommandQueue.cpp" />
+    <ClCompile Include="Source\CmCoreObject.cpp" />
+    <ClCompile Include="Source\CmCoreObjectManager.cpp" />
+    <ClCompile Include="Source\CmCoreThreadAccessor.cpp" />
+    <ClCompile Include="Source\CmDepthStencilState.cpp" />
+    <ClCompile Include="Source\CmFont.cpp" />
+    <ClCompile Include="Source\CmFontImportOptions.cpp" />
+    <ClCompile Include="Source\CmFontManager.cpp" />
+    <ClCompile Include="Source\CmGameObjectManager.cpp" />
+    <ClCompile Include="Source\CmGpuBuffer.cpp" />
+    <ClCompile Include="Source\CmGpuBufferView.cpp" />
+    <ClCompile Include="Source\CmGpuParamBlock.cpp" />
+    <ClCompile Include="Source\CmGpuParamBlockBuffer.cpp" />
+    <ClCompile Include="Source\CmGpuParams.cpp" />
+    <ClCompile Include="Source\BsGPUProfiler.cpp" />
+    <ClCompile Include="Source\CmGpuProgInclude.cpp" />
+    <ClCompile Include="Source\CmGpuProgram.cpp" />
+    <ClCompile Include="Source\CmGpuProgramImporter.cpp" />
+    <ClCompile Include="Source\CmGpuProgramImportOptions.cpp" />
+    <ClCompile Include="Source\CmGpuResource.cpp" />
+    <ClCompile Include="Source\CmGpuResourceData.cpp" />
+    <ClCompile Include="Source\CmHardwareBufferManager.cpp" />
+    <ClCompile Include="Source\CmGpuParam.cpp" />
+    <ClCompile Include="Source\CmImportOptions.cpp" />
+    <ClCompile Include="Source\CmIndexBuffer.cpp" />
+    <ClCompile Include="Source\CmIndexData.cpp" />
+    <ClCompile Include="Source\CmMaterialManager.cpp" />
+    <ClCompile Include="Source\CmMeshBase.cpp" />
+    <ClCompile Include="Source\CmMeshHeap.cpp" />
+    <ClCompile Include="Source\CmMeshManager.cpp" />
+    <ClCompile Include="Source\CmOcclusionQuery.cpp" />
+    <ClCompile Include="Source\CmOSInputHandler.cpp" />
+    <ClCompile Include="Source\CmPixelBuffer.cpp" />
+    <ClCompile Include="Source\CmGpuProgIncludeImporter.cpp" />
+    <ClCompile Include="Source\CmPixelData.cpp" />
+    <ClCompile Include="Source\CmPixelUtil.cpp" />
+    <ClCompile Include="Source\CmPixelVolume.cpp" />
+    <ClCompile Include="Source\CmPlatform.cpp" />
+    <ClCompile Include="Source\CmProfiler.cpp" />
+    <ClCompile Include="Source\CmQueryManager.cpp" />
+    <ClCompile Include="Source\CmRenderer.cpp" />
+    <ClCompile Include="Source\CmRenderQueue.cpp" />
+    <ClCompile Include="Source\CmResourceManifest.cpp" />
+    <ClCompile Include="Source\CmTextureView.cpp" />
+    <ClCompile Include="Source\CmTextData.cpp" />
+    <ClCompile Include="Source\CmTimerQuery.cpp" />
+    <ClCompile Include="Source\CmTransientMesh.cpp" />
+    <ClCompile Include="Source\CmUUID.cpp" />
+    <ClCompile Include="Source\CmVertexBuffer.cpp" />
+    <ClCompile Include="Source\CmGpuProgramManager.cpp" />
+    <ClCompile Include="Source\CmImporter.cpp" />
+    <ClCompile Include="Source\CmInput.cpp" />
+    <ClCompile Include="Source\CmMaterial.cpp" />
+    <ClCompile Include="Source\CmMaterialRTTI.cpp" />
+    <ClCompile Include="Source\CmMesh.cpp" />
+    <ClCompile Include="Source\CmMeshData.cpp" />
+    <ClCompile Include="Source\CmMultiRenderTexture.cpp" />
+    <ClCompile Include="Source\CmPass.cpp" />
+    <ClCompile Include="Source\CmRasterizerState.cpp" />
+    <ClCompile Include="Source\CmRendererManager.cpp" />
+    <ClCompile Include="Source\CmRenderSystem.cpp" />
+    <ClCompile Include="Source\CmRenderSystemCapabilities.cpp" />
+    <ClCompile Include="Source\CmRenderSystemManager.cpp" />
+    <ClCompile Include="Source\CmRenderTarget.cpp" />
+    <ClCompile Include="Source\CmRenderTexture.cpp" />
+    <ClCompile Include="Source\CmRenderWindow.cpp" />
+    <ClCompile Include="Source\CmRenderWindowManager.cpp" />
+    <ClCompile Include="Source\CmResource.cpp" />
+    <ClCompile Include="Source\CmResourceHandle.cpp" />
+    <ClCompile Include="Source\CmResources.cpp" />
+    <ClCompile Include="Source\CmRenderStateManager.cpp" />
+    <ClCompile Include="Source\CmSceneManager.cpp" />
+    <ClCompile Include="Source\CmShader.cpp" />
+    <ClCompile Include="Source\CmSpecificImporter.cpp" />
+    <ClCompile Include="Source\CmTechnique.cpp" />
+    <ClCompile Include="Source\CmTexture.cpp" />
+    <ClCompile Include="Source\CmTextureManager.cpp" />
+    <ClCompile Include="Source\CmSamplerState.cpp" />
+    <ClCompile Include="Source\CmVertexDataDesc.cpp" />
+    <ClCompile Include="Source\CmVertexDeclaration.cpp" />
+    <ClCompile Include="Source\CmVertexData.cpp" />
+    <ClCompile Include="Source\CmVideoModeInfo.cpp" />
+    <ClCompile Include="Source\CmViewport.cpp" />
+    <ClCompile Include="Source\CmSceneObject.cpp" />
+    <ClCompile Include="Source\CmComponent.cpp" />
+    <ClCompile Include="Source\Win32\CmPlatformImpl.cpp" />
+    <ClCompile Include="Source\Win32\CmPlatformWndProc.cpp" />
+    <ClCompile Include="Source\Win32\CmWin32FolderMonitor.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
 </Project>

+ 824 - 824
CamelotCore/CamelotCore.vcxproj.filters → BansheeCore/BansheeCore.vcxproj.filters

@@ -1,825 +1,825 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-    <Filter Include="Header Files\Utility">
-      <UniqueIdentifier>{2c09857e-4a4a-480f-8ebb-1661a9ce78dd}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\RenderSystem">
-      <UniqueIdentifier>{3480589d-111c-44b8-b0f1-a178cd00f31e}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\RenderSystem">
-      <UniqueIdentifier>{e0bdc5fc-afd1-46f9-9e3e-f85ca3e220b8}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Importer">
-      <UniqueIdentifier>{f1fb2bc5-43c6-476a-89e3-b7de86c5aebe}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Resources">
-      <UniqueIdentifier>{e091a28f-6a0f-44ab-a88f-83e3c970c2f3}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Importer">
-      <UniqueIdentifier>{7ac6e5cb-48f7-4a49-a793-fb2ccfabe895}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Resources">
-      <UniqueIdentifier>{6df1cc13-bf9e-45e7-90ae-337999c702cf}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Scene">
-      <UniqueIdentifier>{327fbccb-fd0d-4fb1-af08-5d00cd7d56a7}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Scene">
-      <UniqueIdentifier>{2211ce11-e426-4aad-a5e6-73727d44bb98}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\RTTI">
-      <UniqueIdentifier>{75249db9-4f2e-43c3-8df4-37250c4b60a2}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Input">
-      <UniqueIdentifier>{7f8e94f3-6990-4723-965a-2b4f9346a7ee}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Input">
-      <UniqueIdentifier>{724588b9-04e2-4e9b-9467-b064ed44f05e}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Material">
-      <UniqueIdentifier>{299ec378-4e67-4818-92f6-ab5ffb9aa9ad}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Material">
-      <UniqueIdentifier>{96caf3fa-c267-4fb4-aaa8-83519666d079}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Renderer">
-      <UniqueIdentifier>{5303462d-20d9-4c00-86b8-162e3a430b07}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Renderer">
-      <UniqueIdentifier>{307618fb-e6a0-41ed-b274-fb1f5f4c6f74}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\RTTI">
-      <UniqueIdentifier>{dc50e07b-6351-4bc2-8bfa-cc3fc1d26c39}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Win32">
-      <UniqueIdentifier>{1d3fe8eb-ec10-4356-90f0-b27f89f01a13}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Win32">
-      <UniqueIdentifier>{5a1e28c5-e784-44e6-974f-f1d0d66474ed}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Text">
-      <UniqueIdentifier>{1daa1a6e-95c0-4e63-b339-4a884773fa64}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Text">
-      <UniqueIdentifier>{96b913ee-4ffb-4c60-9aa9-a51e0faf8060}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Core">
-      <UniqueIdentifier>{62281c40-1fc0-47f6-bc61-ff28314d8e13}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Core">
-      <UniqueIdentifier>{402fe837-7d94-4343-a288-c8308fda8c18}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Platform">
-      <UniqueIdentifier>{d53f502a-b966-4162-a828-af2654f0408f}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Platform">
-      <UniqueIdentifier>{88dfbdf1-6999-424c-ac32-1ffe65b6c9f6}</UniqueIdentifier>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\CmApplication.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmViewport.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderWindow.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderTexture.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderTarget.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderSystemManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderSystemFactory.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderSystem.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderSystemCapabilities.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmHardwareBuffer.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmHardwareBufferManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuProgram.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmImporter.h">
-      <Filter>Header Files\Importer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmSpecificImporter.h">
-      <Filter>Header Files\Importer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmResource.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmResources.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmComponent.h">
-      <Filter>Header Files\Scene</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmSceneManager.h">
-      <Filter>Header Files\Scene</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTexture.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTextureManager.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMesh.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMeshDataRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\CmMeshRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmResourceRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTextureRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmVertexDeclarationRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmInput.h">
-      <Filter>Header Files\Input</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmComponentRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTechnique.h">
-      <Filter>Header Files\Material</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPass.h">
-      <Filter>Header Files\Material</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmShader.h">
-      <Filter>Header Files\Material</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMaterial.h">
-      <Filter>Header Files\Material</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuProgramRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderer.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRendererFactory.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRendererManager.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPassRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTechniqueRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmShaderRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMaterialRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmSamplerState.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmResourceHandle.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmResourceHandleRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmDepthStencilState.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderStateManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmSamplerStateRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRasterizerState.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmBlendState.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmBlendStateRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRasterizerStateRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmDepthStencilStateRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderWindowManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMultiRenderTexture.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuParamDesc.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuParams.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmVertexDeclaration.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmIndexBuffer.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmOcclusionQuery.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPixelBuffer.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmVertexBuffer.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuBuffer.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuBufferView.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTextureView.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmIndexData.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmVertexData.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuParamBlock.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMeshManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMaterialManager.h">
-      <Filter>Header Files\Material</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuProgIncludeImporter.h">
-      <Filter>Header Files\Importer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuProgInclude.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuProgramImporter.h">
-      <Filter>Header Files\Importer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmImportOptions.h">
-      <Filter>Header Files\Importer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmImportOptionsRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuProgramImportOptions.h">
-      <Filter>Header Files\Importer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuProgramImportOptionsRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmFont.h">
-      <Filter>Header Files\Text</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmFontDesc.h">
-      <Filter>Header Files\Text</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmFontRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmFontManager.h">
-      <Filter>Header Files\Text</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmFontImportOptions.h">
-      <Filter>Header Files\Text</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmFontImportOptionsRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGameObjectHandle.h">
-      <Filter>Header Files\Scene</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmSceneObject.h">
-      <Filter>Header Files\Scene</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmSceneObjectRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGameObject.h">
-      <Filter>Header Files\Scene</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGameObjectRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuParamBlockBuffer.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuResource.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuResourceData.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuResourceRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPixelUtil.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPixelDataRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPixelData.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuResourceDataRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmOSInputHandler.h">
-      <Filter>Header Files\Input</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRawInputHandler.h">
-      <Filter>Header Files\Input</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmInputFwd.h">
-      <Filter>Header Files\Input</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmCommandQueue.h">
-      <Filter>Header Files\Core</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmCoreObject.h">
-      <Filter>Header Files\Core</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmCoreObjectManager.h">
-      <Filter>Header Files\Core</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmCoreThreadAccessor.h">
-      <Filter>Header Files\Core</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmCoreThread.h">
-      <Filter>Header Files\Core</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmDeferredCallManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmDefaultRenderQueue.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderOperation.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmRenderQueue.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\Win32\CmPlatformImpl.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPlatformWndProc.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmProfiler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmCPUProfiler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\Win32\CmWin32DropTarget.h">
-      <Filter>Header Files\Platform</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmDrawOps.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTextData.h">
-      <Filter>Header Files\Text</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmBindableGpuParams.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmBindableGpuParamBlock.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuParam.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMeshData.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmVertexDataDesc.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmVertexDataDescRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmSubMesh.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmEventQuery.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmQueryManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMeshHeap.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTransientMesh.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMeshBase.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmMeshBaseRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPixelVolume.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGameObjectManager.h">
-      <Filter>Header Files\Scene</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGameObjectHandleRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmResourceManifest.h">
-      <Filter>Header Files\Resources</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmResourceManifestRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmFolderMonitor.h">
-      <Filter>Header Files\Platform</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmUUID.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGpuProgramManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGPUProfiler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderStats.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmTimerQuery.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmVideoModeInfo.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\Win32\CmWin32Defs.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\Win32\CmWin32FolderMonitor.h">
-      <Filter>Header Files\Platform</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPlatform.h">
-      <Filter>Header Files\Platform</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsCommonTypes.h">
-      <Filter>Header Files\Utility</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\CmApplication.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmViewport.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuProgram.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmHardwareBufferManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderSystem.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderSystemCapabilities.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderSystemManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderTarget.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderTexture.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderWindow.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmImporter.cpp">
-      <Filter>Source Files\Importer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmResources.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmResource.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmComponent.cpp">
-      <Filter>Source Files\Scene</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmSceneManager.cpp">
-      <Filter>Source Files\Scene</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmTexture.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmTextureManager.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMesh.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmInput.cpp">
-      <Filter>Source Files\Input</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmPass.cpp">
-      <Filter>Source Files\Material</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmShader.cpp">
-      <Filter>Source Files\Material</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmTechnique.cpp">
-      <Filter>Source Files\Material</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMaterial.cpp">
-      <Filter>Source Files\Material</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRendererManager.cpp">
-      <Filter>Source Files\Renderer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMaterialRTTI.cpp">
-      <Filter>Source Files\RTTI</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmSamplerState.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmResourceHandle.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmSpecificImporter.cpp">
-      <Filter>Source Files\Importer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmDepthStencilState.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderStateManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRasterizerState.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmBlendState.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderWindowManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMultiRenderTexture.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuParams.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmVertexDeclaration.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmIndexBuffer.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmOcclusionQuery.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmPixelBuffer.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmVertexBuffer.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuBufferView.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuBuffer.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmTextureView.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmIndexData.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmVertexData.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuParamBlock.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMeshManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuProgIncludeImporter.cpp">
-      <Filter>Source Files\Importer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuProgInclude.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuProgramImporter.cpp">
-      <Filter>Source Files\Importer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmImportOptions.cpp">
-      <Filter>Source Files\Importer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuProgramImportOptions.cpp">
-      <Filter>Source Files\Importer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmFont.cpp">
-      <Filter>Source Files\Text</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmFontManager.cpp">
-      <Filter>Source Files\Text</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmFontImportOptions.cpp">
-      <Filter>Source Files\Text</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGameObjectHandle.cpp">
-      <Filter>Source Files\Scene</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmSceneObject.cpp">
-      <Filter>Source Files\Scene</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGameObject.cpp">
-      <Filter>Source Files\Scene</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuParamBlockBuffer.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuResourceData.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuResource.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmPixelUtil.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmPixelData.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmOSInputHandler.cpp">
-      <Filter>Source Files\Input</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmCoreThread.cpp">
-      <Filter>Source Files\Core</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmCommandQueue.cpp">
-      <Filter>Source Files\Core</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmCoreObject.cpp">
-      <Filter>Source Files\Core</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmCoreObjectManager.cpp">
-      <Filter>Source Files\Core</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmCoreThreadAccessor.cpp">
-      <Filter>Source Files\Core</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmDeferredCallManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmDefaultRenderQueue.cpp">
-      <Filter>Source Files\Renderer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderQueue.cpp">
-      <Filter>Source Files\Renderer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmRenderer.cpp">
-      <Filter>Source Files\Renderer</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\Win32\CmPlatformImpl.cpp">
-      <Filter>Source Files\Win32</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmProfiler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmCPUProfiler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmPlatform.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmTextData.cpp">
-      <Filter>Source Files\Text</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmBindableGpuParams.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmBindableGpuParamBlock.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuParam.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMeshData.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmVertexDataDesc.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmQueryManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmEventQuery.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmTimerQuery.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMeshHeap.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmTransientMesh.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMeshBase.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmPixelVolume.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGameObjectManager.cpp">
-      <Filter>Source Files\Scene</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmResourceManifest.cpp">
-      <Filter>Source Files\Resources</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmUUID.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmGpuProgramManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGPUProfiler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmDrawOps.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmVideoModeInfo.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmMaterialManager.cpp">
-      <Filter>Source Files\Material</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\Win32\CmPlatformWndProc.cpp">
-      <Filter>Source Files\Win32</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\Win32\CmWin32FolderMonitor.cpp">
-      <Filter>Source Files\Platform</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+    <Filter Include="Header Files\Utility">
+      <UniqueIdentifier>{2c09857e-4a4a-480f-8ebb-1661a9ce78dd}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\RenderSystem">
+      <UniqueIdentifier>{3480589d-111c-44b8-b0f1-a178cd00f31e}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\RenderSystem">
+      <UniqueIdentifier>{e0bdc5fc-afd1-46f9-9e3e-f85ca3e220b8}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Importer">
+      <UniqueIdentifier>{f1fb2bc5-43c6-476a-89e3-b7de86c5aebe}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Resources">
+      <UniqueIdentifier>{e091a28f-6a0f-44ab-a88f-83e3c970c2f3}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Importer">
+      <UniqueIdentifier>{7ac6e5cb-48f7-4a49-a793-fb2ccfabe895}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Resources">
+      <UniqueIdentifier>{6df1cc13-bf9e-45e7-90ae-337999c702cf}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Scene">
+      <UniqueIdentifier>{327fbccb-fd0d-4fb1-af08-5d00cd7d56a7}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Scene">
+      <UniqueIdentifier>{2211ce11-e426-4aad-a5e6-73727d44bb98}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\RTTI">
+      <UniqueIdentifier>{75249db9-4f2e-43c3-8df4-37250c4b60a2}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Input">
+      <UniqueIdentifier>{7f8e94f3-6990-4723-965a-2b4f9346a7ee}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Input">
+      <UniqueIdentifier>{724588b9-04e2-4e9b-9467-b064ed44f05e}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Material">
+      <UniqueIdentifier>{299ec378-4e67-4818-92f6-ab5ffb9aa9ad}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Material">
+      <UniqueIdentifier>{96caf3fa-c267-4fb4-aaa8-83519666d079}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Renderer">
+      <UniqueIdentifier>{5303462d-20d9-4c00-86b8-162e3a430b07}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Renderer">
+      <UniqueIdentifier>{307618fb-e6a0-41ed-b274-fb1f5f4c6f74}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\RTTI">
+      <UniqueIdentifier>{dc50e07b-6351-4bc2-8bfa-cc3fc1d26c39}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Win32">
+      <UniqueIdentifier>{1d3fe8eb-ec10-4356-90f0-b27f89f01a13}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Win32">
+      <UniqueIdentifier>{5a1e28c5-e784-44e6-974f-f1d0d66474ed}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Text">
+      <UniqueIdentifier>{1daa1a6e-95c0-4e63-b339-4a884773fa64}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Text">
+      <UniqueIdentifier>{96b913ee-4ffb-4c60-9aa9-a51e0faf8060}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Core">
+      <UniqueIdentifier>{62281c40-1fc0-47f6-bc61-ff28314d8e13}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Core">
+      <UniqueIdentifier>{402fe837-7d94-4343-a288-c8308fda8c18}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Platform">
+      <UniqueIdentifier>{d53f502a-b966-4162-a828-af2654f0408f}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Platform">
+      <UniqueIdentifier>{88dfbdf1-6999-424c-ac32-1ffe65b6c9f6}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\CmApplication.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmViewport.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderWindow.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderTexture.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderTarget.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderSystemManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderSystemFactory.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderSystem.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderSystemCapabilities.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmHardwareBuffer.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmHardwareBufferManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuProgram.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmImporter.h">
+      <Filter>Header Files\Importer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmSpecificImporter.h">
+      <Filter>Header Files\Importer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmResource.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmResources.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmComponent.h">
+      <Filter>Header Files\Scene</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmSceneManager.h">
+      <Filter>Header Files\Scene</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTexture.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTextureManager.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMesh.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMeshDataRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\CmMeshRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmResourceRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTextureRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmVertexDeclarationRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmInput.h">
+      <Filter>Header Files\Input</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmComponentRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTechnique.h">
+      <Filter>Header Files\Material</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPass.h">
+      <Filter>Header Files\Material</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmShader.h">
+      <Filter>Header Files\Material</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMaterial.h">
+      <Filter>Header Files\Material</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuProgramRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderer.h">
+      <Filter>Header Files\Renderer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRendererFactory.h">
+      <Filter>Header Files\Renderer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRendererManager.h">
+      <Filter>Header Files\Renderer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPassRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTechniqueRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmShaderRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMaterialRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmSamplerState.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmResourceHandle.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmResourceHandleRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmDepthStencilState.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderStateManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmSamplerStateRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRasterizerState.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmBlendState.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmBlendStateRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRasterizerStateRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmDepthStencilStateRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderWindowManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMultiRenderTexture.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuParamDesc.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuParams.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmVertexDeclaration.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmIndexBuffer.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmOcclusionQuery.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPixelBuffer.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmVertexBuffer.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuBuffer.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuBufferView.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTextureView.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmIndexData.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmVertexData.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuParamBlock.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMeshManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMaterialManager.h">
+      <Filter>Header Files\Material</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuProgIncludeImporter.h">
+      <Filter>Header Files\Importer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuProgInclude.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuProgramImporter.h">
+      <Filter>Header Files\Importer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmImportOptions.h">
+      <Filter>Header Files\Importer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmImportOptionsRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuProgramImportOptions.h">
+      <Filter>Header Files\Importer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuProgramImportOptionsRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFont.h">
+      <Filter>Header Files\Text</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFontDesc.h">
+      <Filter>Header Files\Text</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFontRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFontManager.h">
+      <Filter>Header Files\Text</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFontImportOptions.h">
+      <Filter>Header Files\Text</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFontImportOptionsRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGameObjectHandle.h">
+      <Filter>Header Files\Scene</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmSceneObject.h">
+      <Filter>Header Files\Scene</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmSceneObjectRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGameObject.h">
+      <Filter>Header Files\Scene</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGameObjectRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuParamBlockBuffer.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuResource.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuResourceData.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuResourceRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPixelUtil.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPixelDataRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPixelData.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuResourceDataRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmOSInputHandler.h">
+      <Filter>Header Files\Input</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRawInputHandler.h">
+      <Filter>Header Files\Input</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmInputFwd.h">
+      <Filter>Header Files\Input</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmCommandQueue.h">
+      <Filter>Header Files\Core</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmCoreObject.h">
+      <Filter>Header Files\Core</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmCoreObjectManager.h">
+      <Filter>Header Files\Core</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmCoreThreadAccessor.h">
+      <Filter>Header Files\Core</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmCoreThread.h">
+      <Filter>Header Files\Core</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmDeferredCallManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmDefaultRenderQueue.h">
+      <Filter>Header Files\Renderer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderOperation.h">
+      <Filter>Header Files\Renderer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmRenderQueue.h">
+      <Filter>Header Files\Renderer</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\Win32\CmPlatformImpl.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPlatformWndProc.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmProfiler.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmCPUProfiler.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\Win32\CmWin32DropTarget.h">
+      <Filter>Header Files\Platform</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmDrawOps.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTextData.h">
+      <Filter>Header Files\Text</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmBindableGpuParams.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmBindableGpuParamBlock.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuParam.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMeshData.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmVertexDataDesc.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmVertexDataDescRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmSubMesh.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmEventQuery.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmQueryManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMeshHeap.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTransientMesh.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMeshBase.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmMeshBaseRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPixelVolume.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGameObjectManager.h">
+      <Filter>Header Files\Scene</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGameObjectHandleRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmResourceManifest.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmResourceManifestRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFolderMonitor.h">
+      <Filter>Header Files\Platform</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmUUID.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmGpuProgramManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGPUProfiler.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRenderStats.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmTimerQuery.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmVideoModeInfo.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\Win32\CmWin32Defs.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\Win32\CmWin32FolderMonitor.h">
+      <Filter>Header Files\Platform</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPlatform.h">
+      <Filter>Header Files\Platform</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCommonTypes.h">
+      <Filter>Header Files\Utility</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\CmApplication.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmViewport.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuProgram.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmHardwareBufferManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderSystem.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderSystemCapabilities.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderSystemManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderTarget.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderTexture.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderWindow.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmImporter.cpp">
+      <Filter>Source Files\Importer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmResources.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmResource.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmComponent.cpp">
+      <Filter>Source Files\Scene</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmSceneManager.cpp">
+      <Filter>Source Files\Scene</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmTexture.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmTextureManager.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMesh.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmInput.cpp">
+      <Filter>Source Files\Input</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmPass.cpp">
+      <Filter>Source Files\Material</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmShader.cpp">
+      <Filter>Source Files\Material</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmTechnique.cpp">
+      <Filter>Source Files\Material</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMaterial.cpp">
+      <Filter>Source Files\Material</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRendererManager.cpp">
+      <Filter>Source Files\Renderer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMaterialRTTI.cpp">
+      <Filter>Source Files\RTTI</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmSamplerState.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmResourceHandle.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmSpecificImporter.cpp">
+      <Filter>Source Files\Importer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmDepthStencilState.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderStateManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRasterizerState.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmBlendState.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderWindowManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMultiRenderTexture.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuParams.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmVertexDeclaration.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmIndexBuffer.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmOcclusionQuery.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmPixelBuffer.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmVertexBuffer.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuBufferView.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuBuffer.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmTextureView.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmIndexData.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmVertexData.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuParamBlock.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMeshManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuProgIncludeImporter.cpp">
+      <Filter>Source Files\Importer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuProgInclude.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuProgramImporter.cpp">
+      <Filter>Source Files\Importer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmImportOptions.cpp">
+      <Filter>Source Files\Importer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuProgramImportOptions.cpp">
+      <Filter>Source Files\Importer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmFont.cpp">
+      <Filter>Source Files\Text</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmFontManager.cpp">
+      <Filter>Source Files\Text</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmFontImportOptions.cpp">
+      <Filter>Source Files\Text</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGameObjectHandle.cpp">
+      <Filter>Source Files\Scene</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmSceneObject.cpp">
+      <Filter>Source Files\Scene</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGameObject.cpp">
+      <Filter>Source Files\Scene</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuParamBlockBuffer.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuResourceData.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuResource.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmPixelUtil.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmPixelData.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmOSInputHandler.cpp">
+      <Filter>Source Files\Input</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmCoreThread.cpp">
+      <Filter>Source Files\Core</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmCommandQueue.cpp">
+      <Filter>Source Files\Core</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmCoreObject.cpp">
+      <Filter>Source Files\Core</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmCoreObjectManager.cpp">
+      <Filter>Source Files\Core</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmCoreThreadAccessor.cpp">
+      <Filter>Source Files\Core</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmDeferredCallManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmDefaultRenderQueue.cpp">
+      <Filter>Source Files\Renderer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderQueue.cpp">
+      <Filter>Source Files\Renderer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmRenderer.cpp">
+      <Filter>Source Files\Renderer</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\Win32\CmPlatformImpl.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmProfiler.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmCPUProfiler.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmPlatform.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmTextData.cpp">
+      <Filter>Source Files\Text</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmBindableGpuParams.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmBindableGpuParamBlock.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuParam.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMeshData.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmVertexDataDesc.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmQueryManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmEventQuery.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmTimerQuery.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMeshHeap.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmTransientMesh.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMeshBase.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmPixelVolume.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGameObjectManager.cpp">
+      <Filter>Source Files\Scene</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmResourceManifest.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmUUID.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmGpuProgramManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGPUProfiler.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmDrawOps.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmVideoModeInfo.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmMaterialManager.cpp">
+      <Filter>Source Files\Material</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\Win32\CmPlatformWndProc.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\Win32\CmWin32FolderMonitor.cpp">
+      <Filter>Source Files\Platform</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 0 - 0
CamelotCore/Include/BsCommonTypes.h → BansheeCore/Include/BsCommonTypes.h


+ 1 - 1
CamelotCore/Include/BsGPUProfiler.h → BansheeCore/Include/BsGPUProfiler.h

@@ -56,7 +56,7 @@ namespace BansheeEngine
 	 *
 	 * @note	Core thread only.
 	 */
-	class CM_EXPORT GPUProfiler : public Module<GPUProfiler>
+	class BS_CORE_EXPORT GPUProfiler : public Module<GPUProfiler>
 	{
 	private:
 		struct ActiveSample

+ 0 - 0
CamelotCore/Include/BsRenderStats.h → BansheeCore/Include/BsRenderStats.h


+ 120 - 120
CamelotCore/Include/CmApplication.h → BansheeCore/Include/CmApplication.h

@@ -1,121 +1,121 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmCoreThreadAccessor.h"
-#include "CmRenderWindow.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Structure containing parameters for starting the application.
-	 */
-	struct START_UP_DESC
-	{
-		String renderSystem; /**< Name of the render system plugin to use. */
-		String renderer; /**< Name of the renderer plugin to use. */
-
-		String input; /**< Name of the input plugin to use. */
-		String sceneManager; /**< Name of the scene manager plugin to use. */
-
-		RENDER_WINDOW_DESC primaryWindowDesc; /**< Describes the window to create during start-up. */
-
-		Vector<String> importers; /**< A list of importer plugins to load. */
-	};
-
-	/**
-	 * @brief	Represents the primary entry point to the engine. Handles
-	 *			start-up, shutdown, primary loop and allows you to load and unload
-	 *			plugins.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class CM_EXPORT Application
-	{
-		public:
-			Application();
-
-			/**
-			 * @brief	Starts the application using the specified options. 
-			 * 			This is how you start the engine. Must be called before any other engine method.
-			 */
-			void startUp(START_UP_DESC& desc);
-
-			/**
-			 * @brief	Executes the main loop. This will update your components and modules, queue objects 
-			 *			for rendering and run the simulation. Usually called immediately after startUp().
-			 * 			
-			 *			This will run infinitely until stopMainLoop is called (usually from another thread or internally).
-			 */
-			void runMainLoop();
-
-			/**
-			 * @brief	Stops a (infinite) main loop from running. The loop will complete its current cycle before stopping.
-			 */
-			void stopMainLoop();
-
-			/**
-			 * @brief	Frees up all resources allocated during startUp, and while the application was running.
-			 */
-			void shutDown();
-
-			/**
-			 * @brief	
-			 */
-			RenderWindowPtr getPrimaryWindow() const { return mPrimaryWindow; }
-
-			/**
-			 * @brief	Loads a plugin.
-			 *
-			 * @param	pluginName		Name of the plugin to load, without extension.
-			 * @param	[out] library	Specify as not null to receive a reference to 
-			 *							the loaded library.
-			 * 
-			 * @returns	Value returned from the plugin start-up method.
-			 */
-			void* loadPlugin(const String& pluginName, DynLib** library = nullptr);
-
-			/**
-			 * @brief	Unloads a previously loaded plugin. 
-			 */
-			void unloadPlugin(DynLib* library);
-
-			/**
-			 * @brief	Called every frame by the main loop, after scene update and before rendering.
-			 */
-			Event<void()> mainLoopCallback;
-
-	private:
-		/**
-		 * @brief	Called when the frame finishes rendering.
-		 */
-		void frameRenderingFinishedCallback();
-
-		/**
-		 * @brief	Called by the core thread to begin profiling.
-		 */
-		void beginCoreProfiling();
-
-		/**
-		 * @brief	Called by the core thread to end profiling.
-		 */
-		void endCoreProfiling();
-
-	private:
-		RenderWindowPtr mPrimaryWindow;
-
-		DynLib* mSceneManagerPlugin;
-
-		bool mIsFrameRenderingFinished;
-		CM_MUTEX(mFrameRenderingFinishedMutex);
-		CM_THREAD_SYNCHRONISER(mFrameRenderingFinishedCondition);
-
-		volatile bool mRunMainLoop;
-	};
-
-	/**
-	 * @brief	Provides easy access to primary entry point for the engine.
-	 */
-	CM_EXPORT Application& gApplication();
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmCoreThreadAccessor.h"
+#include "CmRenderWindow.h"
+#include "BsEvent.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Structure containing parameters for starting the application.
+	 */
+	struct START_UP_DESC
+	{
+		String renderSystem; /**< Name of the render system plugin to use. */
+		String renderer; /**< Name of the renderer plugin to use. */
+
+		String input; /**< Name of the input plugin to use. */
+		String sceneManager; /**< Name of the scene manager plugin to use. */
+
+		RENDER_WINDOW_DESC primaryWindowDesc; /**< Describes the window to create during start-up. */
+
+		Vector<String> importers; /**< A list of importer plugins to load. */
+	};
+
+	/**
+	 * @brief	Represents the primary entry point to the engine. Handles
+	 *			start-up, shutdown, primary loop and allows you to load and unload
+	 *			plugins.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT Application
+	{
+		public:
+			Application();
+
+			/**
+			 * @brief	Starts the application using the specified options. 
+			 * 			This is how you start the engine. Must be called before any other engine method.
+			 */
+			void startUp(START_UP_DESC& desc);
+
+			/**
+			 * @brief	Executes the main loop. This will update your components and modules, queue objects 
+			 *			for rendering and run the simulation. Usually called immediately after startUp().
+			 * 			
+			 *			This will run infinitely until stopMainLoop is called (usually from another thread or internally).
+			 */
+			void runMainLoop();
+
+			/**
+			 * @brief	Stops a (infinite) main loop from running. The loop will complete its current cycle before stopping.
+			 */
+			void stopMainLoop();
+
+			/**
+			 * @brief	Frees up all resources allocated during startUp, and while the application was running.
+			 */
+			void shutDown();
+
+			/**
+			 * @brief	
+			 */
+			RenderWindowPtr getPrimaryWindow() const { return mPrimaryWindow; }
+
+			/**
+			 * @brief	Loads a plugin.
+			 *
+			 * @param	pluginName		Name of the plugin to load, without extension.
+			 * @param	[out] library	Specify as not null to receive a reference to 
+			 *							the loaded library.
+			 * 
+			 * @returns	Value returned from the plugin start-up method.
+			 */
+			void* loadPlugin(const String& pluginName, DynLib** library = nullptr);
+
+			/**
+			 * @brief	Unloads a previously loaded plugin. 
+			 */
+			void unloadPlugin(DynLib* library);
+
+			/**
+			 * @brief	Called every frame by the main loop, after scene update and before rendering.
+			 */
+			Event<void()> mainLoopCallback;
+
+	private:
+		/**
+		 * @brief	Called when the frame finishes rendering.
+		 */
+		void frameRenderingFinishedCallback();
+
+		/**
+		 * @brief	Called by the core thread to begin profiling.
+		 */
+		void beginCoreProfiling();
+
+		/**
+		 * @brief	Called by the core thread to end profiling.
+		 */
+		void endCoreProfiling();
+
+	private:
+		RenderWindowPtr mPrimaryWindow;
+
+		DynLib* mSceneManagerPlugin;
+
+		bool mIsFrameRenderingFinished;
+		CM_MUTEX(mFrameRenderingFinishedMutex);
+		CM_THREAD_SYNCHRONISER(mFrameRenderingFinishedCondition);
+
+		volatile bool mRunMainLoop;
+	};
+
+	/**
+	 * @brief	Provides easy access to primary entry point for the engine.
+	 */
+	BS_CORE_EXPORT Application& gApplication();
 }

+ 42 - 42
CamelotCore/Include/CmBindableGpuParamBlock.h → BansheeCore/Include/CmBindableGpuParamBlock.h

@@ -1,43 +1,43 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmCoreObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Specialized class for binding GPU parameters to the render system. Represents a single
-	 * 			parameter block buffer and is used for temporary storage of GPU parameters.
-	 * 
-	 * @note	Due to the way allocation is handled, this class is not allowed to have a destructor.
-	 * 			
-	 * @see		BindableGpuParams
- 	 */
-	class CM_EXPORT BindableGpuParamBlock
-	{
-	public:
-		BindableGpuParamBlock();
-
-		/**
-		 * @brief	Uploads the current data to the specified buffer, and marks the block a non-dirty.
-		 * 			
-		 * @note	Core thread only.			
-		 */
-		void uploadToBuffer(GpuParamBlockBufferPtr buffer);
-
-		/**
-		 * @brief	Query if this object is dirty. If dirty the data of this block
-		 * 			will need to be uploaded to a GPU buffer.
-		 *
-		 * @note	Core thread only.
-		 */
-		bool isDirty() const { return mDirty; }
-	protected:
-		friend class GpuParams;
-		friend class BindableGpuParams;
-
-		UINT8* mData;
-		UINT32 mSize;
-		bool mDirty;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmCoreObject.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Specialized class for binding GPU parameters to the render system. Represents a single
+	 * 			parameter block buffer and is used for temporary storage of GPU parameters.
+	 * 
+	 * @note	Due to the way allocation is handled, this class is not allowed to have a destructor.
+	 * 			
+	 * @see		BindableGpuParams
+ 	 */
+	class BS_CORE_EXPORT BindableGpuParamBlock
+	{
+	public:
+		BindableGpuParamBlock();
+
+		/**
+		 * @brief	Uploads the current data to the specified buffer, and marks the block a non-dirty.
+		 * 			
+		 * @note	Core thread only.			
+		 */
+		void uploadToBuffer(GpuParamBlockBufferPtr buffer);
+
+		/**
+		 * @brief	Query if this object is dirty. If dirty the data of this block
+		 * 			will need to be uploaded to a GPU buffer.
+		 *
+		 * @note	Core thread only.
+		 */
+		bool isDirty() const { return mDirty; }
+	protected:
+		friend class GpuParams;
+		friend class BindableGpuParams;
+
+		UINT8* mData;
+		UINT32 mSize;
+		bool mDirty;
+	};
 }

+ 72 - 72
CamelotCore/Include/CmBindableGpuParams.h → BansheeCore/Include/CmBindableGpuParams.h

@@ -1,73 +1,73 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Specialized class for binding GPU parameters to the render system. This is a temporary class that
-	 * 			is used for temporarily saving parameter data while parameters are scheduled to be bound to the GPU.
-	 * 			This allows us to freely modify base GpuParams without worrying about changing scheduled by still 
-	 * 			not executed parameter binds.
-	 * 			
-	 * @note	Upon assignment this class transfers ownership of its internal data. Internal data
-	 * 			is destroyed when last assigned instance goes out of scope.
-	 * 			(In short, you should never have more than one active copy of an instance of this class)
-	 * 			
-	 *			Created on the sim thread and used exclusively on the core thread.
-	 *			
-	 * @see		CoreThreadAccessorBase::bindGpuParams
-	**/
-	class CM_EXPORT BindableGpuParams
-	{
-	public:
-		BindableGpuParams(const GpuParamsPtr& sourceParams, FrameAlloc* allocator);
-		BindableGpuParams(const BindableGpuParams& source);
-		~BindableGpuParams();
-
-		/**
-		 * @brief	Uploads all CPU stored parameter buffer data to the GPU buffers.
-		 */
-		void updateHardwareBuffers();
-
-		/**
-		 * @brief	Gets a parameter block buffer from the specified slot.
-		 */
-		GpuParamBlockBufferPtr getParamBlockBuffer(UINT32 slot) const;
-
-		/**
-		 * @brief	Gets a parameter block buffer by name.
-		 */
-		GpuParamBlockBufferPtr getParamBlockBuffer(const String& name) const;
-
-		/**
-		 * @brief	Gets a texture bound to the specified slot.
-		 */
-		HTexture getTexture(UINT32 slot);
-
-		/**
-		 * @brief	Gets a sampler state bound to the specified slot.
-		 */
-		HSamplerState getSamplerState(UINT32 slot);
-
-		/**
-		 * @brief	Gets a description of all parameters stored in this class.
-		 */
-		const GpuParamDesc& getParamDesc() const { return mParamDesc; }
-
-	private:
-		mutable bool mOwnsData;
-		const GpuParamDesc& mParamDesc;
-		UINT8* mData;
-
-		UINT32 mNumParamBlocks;
-		UINT32 mNumTextures;
-		UINT32 mNumSamplerStates;
-
-		FrameAlloc* mAllocator;
-		BindableGpuParamBlock** mParamBlocks;
-		GpuParamBlockBufferPtr* mParamBlockBuffers;
-		HTexture* mTextures;
-		HSamplerState* mSamplerStates;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Specialized class for binding GPU parameters to the render system. This is a temporary class that
+	 * 			is used for temporarily saving parameter data while parameters are scheduled to be bound to the GPU.
+	 * 			This allows us to freely modify base GpuParams without worrying about changing scheduled by still 
+	 * 			not executed parameter binds.
+	 * 			
+	 * @note	Upon assignment this class transfers ownership of its internal data. Internal data
+	 * 			is destroyed when last assigned instance goes out of scope.
+	 * 			(In short, you should never have more than one active copy of an instance of this class)
+	 * 			
+	 *			Created on the sim thread and used exclusively on the core thread.
+	 *			
+	 * @see		CoreThreadAccessorBase::bindGpuParams
+	**/
+	class BS_CORE_EXPORT BindableGpuParams
+	{
+	public:
+		BindableGpuParams(const GpuParamsPtr& sourceParams, FrameAlloc* allocator);
+		BindableGpuParams(const BindableGpuParams& source);
+		~BindableGpuParams();
+
+		/**
+		 * @brief	Uploads all CPU stored parameter buffer data to the GPU buffers.
+		 */
+		void updateHardwareBuffers();
+
+		/**
+		 * @brief	Gets a parameter block buffer from the specified slot.
+		 */
+		GpuParamBlockBufferPtr getParamBlockBuffer(UINT32 slot) const;
+
+		/**
+		 * @brief	Gets a parameter block buffer by name.
+		 */
+		GpuParamBlockBufferPtr getParamBlockBuffer(const String& name) const;
+
+		/**
+		 * @brief	Gets a texture bound to the specified slot.
+		 */
+		HTexture getTexture(UINT32 slot);
+
+		/**
+		 * @brief	Gets a sampler state bound to the specified slot.
+		 */
+		HSamplerState getSamplerState(UINT32 slot);
+
+		/**
+		 * @brief	Gets a description of all parameters stored in this class.
+		 */
+		const GpuParamDesc& getParamDesc() const { return mParamDesc; }
+
+	private:
+		mutable bool mOwnsData;
+		const GpuParamDesc& mParamDesc;
+		UINT8* mData;
+
+		UINT32 mNumParamBlocks;
+		UINT32 mNumTextures;
+		UINT32 mNumSamplerStates;
+
+		FrameAlloc* mAllocator;
+		BindableGpuParamBlock** mParamBlocks;
+		GpuParamBlockBufferPtr* mParamBlockBuffers;
+		HTexture* mTextures;
+		HSamplerState* mSamplerStates;
+	};
 }

+ 169 - 169
CamelotCore/Include/CmBlendState.h → BansheeCore/Include/CmBlendState.h

@@ -1,170 +1,170 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmResource.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Structure that describes blend states for a single render
-	 * 			target. Used internally by BLEND_STATE_DESC for initializing a BlendState.
-	 * 			
-	 * @see		BLEND_STATE_DESC
-	 * @see		BlendState
-	 */
-	struct CM_EXPORT RENDER_TARGET_BLEND_STATE_DESC
-	{
-		RENDER_TARGET_BLEND_STATE_DESC()
-			: blendEnable(false)
-			, srcBlend(BF_ONE)
-			, dstBlend(BF_ZERO)
-			, blendOp(BO_ADD)
-			, srcBlendAlpha(BF_ONE)
-			, dstBlendAlpha(BF_ZERO)
-			, blendOpAlpha(BO_ADD)
-			, renderTargetWriteMask(0xFF)
-		{ }
-
-		bool blendEnable;
-		BlendFactor srcBlend;
-		BlendFactor dstBlend;
-		BlendOperation blendOp;
-		BlendFactor srcBlendAlpha;
-		BlendFactor dstBlendAlpha;
-		BlendOperation blendOpAlpha;
-		// Enable write to RGBA channels separately by setting first four bits (0 - R, 1 - G, 2 - B, 3 - A)
-		UINT8 renderTargetWriteMask;
-	};
-
-	/**
-	 * @brief	Structure that describes render pipeline blend states. Used for initializing
-	 * 			BlendState.
-	 * 			
-	 * @see		BlendState.
-	 */
-	struct CM_EXPORT BLEND_STATE_DESC
-	{
-		BLEND_STATE_DESC()
-			: alphaToCoverageEnable(false)
-			, independantBlendEnable(false)
-		{ }
-
-		bool alphaToCoverageEnable;
-		bool independantBlendEnable;
-		RENDER_TARGET_BLEND_STATE_DESC renderTargetDesc[CM_MAX_MULTIPLE_RENDER_TARGETS];
-	};
-
-	/**
-	 * @brief	Render system pipeline state that allows you to modify how an object is rendered. 
-	 * 			More exactly this state allows to you to control how is a rendered
-	 * 			object blended with any previously renderer objects.
-	 * 			
-	 * @note	Blend states are immutable. Thread safe.
-	 */
-	class CM_EXPORT BlendState : public Resource
-	{
-	public:
-		virtual ~BlendState() {}
-
-		/**
-		 * @brief	Alpha to coverage allows you to perform blending without needing to worry about order of
-		 * 			rendering like regular blending does. It requires multi-sampling to be active in order to
-		 * 			work, and you need to supply an alpha texture that determines object transparency.
-		 *
-		 *			Blending is then performed by only using sub-samples covered by the alpha texture for the current
-		 *			pixel and combining them with sub-samples previously stored. 
-		 *			
-		 *			Be aware this is a limited technique only useful for certain situations. Unless you are having performance
-		 *			problems use regular blending.
-		 */
-		bool getAlphaToCoverageEnabled() const { return mData.alphaToCoverageEnable; }
-
-		/**
-		 * @brief	When not set, only the first render target blend descriptor will be used for all
-		 * 			render targets. If set each render target will use its own blend descriptor.
-		 */
-		bool getIndependantBlendEnable() const { return mData.independantBlendEnable; }
-
-		/**
-		 * @brief	Queries is blending enabled for the specified render target. Blending
-		 * 			allows you to combine the color from current and previous pixel based on
-		 * 			some value.
-		 */
-		bool getBlendEnabled(UINT32 renderTargetIdx) const;
-
-		/**
-		 * @brief	Determines what should the source blend factor be. This value determines
-		 * 			what will the color being generated currently be multiplied by.
-		 */
-		BlendFactor getSrcBlend(UINT32 renderTargetIdx) const;
-
-		/**
-		 * @brief	Determines what should the destination blend factor be. This value determines
-		 * 			what will the color already in render target be multiplied by.
-		 */
-		BlendFactor getDstBlend(UINT32 renderTargetIdx) const;
-
-		/**
-		 * @brief	Determines how are source and destination colors combined (after they are multiplied
-		 * 			by their respective blend factors).
-		 */
-		BlendOperation getBlendOperation(UINT32 renderTargetIdx) const;
-
-		/**
-		 * @brief	Determines what should the alpha source blend factor be. This value determines
-		 * 			what will the alpha value being generated currently be multiplied by.
-		 */
-		BlendFactor getAlphaSrcBlend(UINT32 renderTargetIdx) const;
-
-		/**
-		 * @brief	Determines what should the alpha destination blend factor be. This value determines
-		 * 			what will the alpha value already in render target be multiplied by.
-		 */
-		BlendFactor getAlphaDstBlend(UINT32 renderTargetIdx) const;
-
-		/**
-		 * @brief	Determines how are source and destination alpha values combined (after they are multiplied
-		 * 			by their respective blend factors).
-		 */
-		BlendOperation getAlphaBlendOperation(UINT32 renderTargetIdx) const;
-
-		/**
-		 * @brief	Render target write mask allows to choose which pixel components should the pixel shader
-		 * 			output.
-		 * 			
-		 *			Only the first four bits are used. First bit representing red, second green, third blue and
-		 *			fourth alpha value. Set bits means pixel shader will output those channels.
-		 */
-		UINT8 getRenderTargetWriteMask(UINT32 renderTargetIdx) const;
-
-		/**
-		 * @brief	Creates a new blend state using the specified blend state description structure.
-		 */
-		static HBlendState create(const BLEND_STATE_DESC& desc);
-
-		/**
-		 * @brief	Returns the default blend state that you may use
-		 * 			when no other is available.
-		 */
-		static const BlendStatePtr& getDefault();
-
-	protected:
-		friend class RenderStateManager;
-
-		/**
-		 * @brief	Initializes the blend state. Must be called right after construction.
-		 */
-		virtual void initialize(const BLEND_STATE_DESC& desc);
-
-		BLEND_STATE_DESC mData;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class BlendStateRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmResource.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Structure that describes blend states for a single render
+	 * 			target. Used internally by BLEND_STATE_DESC for initializing a BlendState.
+	 * 			
+	 * @see		BLEND_STATE_DESC
+	 * @see		BlendState
+	 */
+	struct BS_CORE_EXPORT RENDER_TARGET_BLEND_STATE_DESC
+	{
+		RENDER_TARGET_BLEND_STATE_DESC()
+			: blendEnable(false)
+			, srcBlend(BF_ONE)
+			, dstBlend(BF_ZERO)
+			, blendOp(BO_ADD)
+			, srcBlendAlpha(BF_ONE)
+			, dstBlendAlpha(BF_ZERO)
+			, blendOpAlpha(BO_ADD)
+			, renderTargetWriteMask(0xFF)
+		{ }
+
+		bool blendEnable;
+		BlendFactor srcBlend;
+		BlendFactor dstBlend;
+		BlendOperation blendOp;
+		BlendFactor srcBlendAlpha;
+		BlendFactor dstBlendAlpha;
+		BlendOperation blendOpAlpha;
+		// Enable write to RGBA channels separately by setting first four bits (0 - R, 1 - G, 2 - B, 3 - A)
+		UINT8 renderTargetWriteMask;
+	};
+
+	/**
+	 * @brief	Structure that describes render pipeline blend states. Used for initializing
+	 * 			BlendState.
+	 * 			
+	 * @see		BlendState.
+	 */
+	struct BS_CORE_EXPORT BLEND_STATE_DESC
+	{
+		BLEND_STATE_DESC()
+			: alphaToCoverageEnable(false)
+			, independantBlendEnable(false)
+		{ }
+
+		bool alphaToCoverageEnable;
+		bool independantBlendEnable;
+		RENDER_TARGET_BLEND_STATE_DESC renderTargetDesc[CM_MAX_MULTIPLE_RENDER_TARGETS];
+	};
+
+	/**
+	 * @brief	Render system pipeline state that allows you to modify how an object is rendered. 
+	 * 			More exactly this state allows to you to control how is a rendered
+	 * 			object blended with any previously renderer objects.
+	 * 			
+	 * @note	Blend states are immutable. Thread safe.
+	 */
+	class BS_CORE_EXPORT BlendState : public Resource
+	{
+	public:
+		virtual ~BlendState() {}
+
+		/**
+		 * @brief	Alpha to coverage allows you to perform blending without needing to worry about order of
+		 * 			rendering like regular blending does. It requires multi-sampling to be active in order to
+		 * 			work, and you need to supply an alpha texture that determines object transparency.
+		 *
+		 *			Blending is then performed by only using sub-samples covered by the alpha texture for the current
+		 *			pixel and combining them with sub-samples previously stored. 
+		 *			
+		 *			Be aware this is a limited technique only useful for certain situations. Unless you are having performance
+		 *			problems use regular blending.
+		 */
+		bool getAlphaToCoverageEnabled() const { return mData.alphaToCoverageEnable; }
+
+		/**
+		 * @brief	When not set, only the first render target blend descriptor will be used for all
+		 * 			render targets. If set each render target will use its own blend descriptor.
+		 */
+		bool getIndependantBlendEnable() const { return mData.independantBlendEnable; }
+
+		/**
+		 * @brief	Queries is blending enabled for the specified render target. Blending
+		 * 			allows you to combine the color from current and previous pixel based on
+		 * 			some value.
+		 */
+		bool getBlendEnabled(UINT32 renderTargetIdx) const;
+
+		/**
+		 * @brief	Determines what should the source blend factor be. This value determines
+		 * 			what will the color being generated currently be multiplied by.
+		 */
+		BlendFactor getSrcBlend(UINT32 renderTargetIdx) const;
+
+		/**
+		 * @brief	Determines what should the destination blend factor be. This value determines
+		 * 			what will the color already in render target be multiplied by.
+		 */
+		BlendFactor getDstBlend(UINT32 renderTargetIdx) const;
+
+		/**
+		 * @brief	Determines how are source and destination colors combined (after they are multiplied
+		 * 			by their respective blend factors).
+		 */
+		BlendOperation getBlendOperation(UINT32 renderTargetIdx) const;
+
+		/**
+		 * @brief	Determines what should the alpha source blend factor be. This value determines
+		 * 			what will the alpha value being generated currently be multiplied by.
+		 */
+		BlendFactor getAlphaSrcBlend(UINT32 renderTargetIdx) const;
+
+		/**
+		 * @brief	Determines what should the alpha destination blend factor be. This value determines
+		 * 			what will the alpha value already in render target be multiplied by.
+		 */
+		BlendFactor getAlphaDstBlend(UINT32 renderTargetIdx) const;
+
+		/**
+		 * @brief	Determines how are source and destination alpha values combined (after they are multiplied
+		 * 			by their respective blend factors).
+		 */
+		BlendOperation getAlphaBlendOperation(UINT32 renderTargetIdx) const;
+
+		/**
+		 * @brief	Render target write mask allows to choose which pixel components should the pixel shader
+		 * 			output.
+		 * 			
+		 *			Only the first four bits are used. First bit representing red, second green, third blue and
+		 *			fourth alpha value. Set bits means pixel shader will output those channels.
+		 */
+		UINT8 getRenderTargetWriteMask(UINT32 renderTargetIdx) const;
+
+		/**
+		 * @brief	Creates a new blend state using the specified blend state description structure.
+		 */
+		static HBlendState create(const BLEND_STATE_DESC& desc);
+
+		/**
+		 * @brief	Returns the default blend state that you may use
+		 * 			when no other is available.
+		 */
+		static const BlendStatePtr& getDefault();
+
+	protected:
+		friend class RenderStateManager;
+
+		/**
+		 * @brief	Initializes the blend state. Must be called right after construction.
+		 */
+		virtual void initialize(const BLEND_STATE_DESC& desc);
+
+		BLEND_STATE_DESC mData;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class BlendStateRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
 }

+ 93 - 93
CamelotCore/Include/CmBlendStateRTTI.h → BansheeCore/Include/CmBlendStateRTTI.h

@@ -1,94 +1,94 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmBlendState.h"
-#include "CmRenderStateManager.h"
-
-namespace BansheeEngine
-{
-	template<> struct RTTIPlainType<BLEND_STATE_DESC>
-	{	
-		enum { id = TID_BLEND_STATE_DESC }; enum { hasDynamicSize = 1 };
-
-		static void toMemory(const BLEND_STATE_DESC& data, char* memory)
-		{ 
-			UINT32 size = getDynamicSize(data);
-
-			memcpy(memory, &size, sizeof(UINT32));
-			memory += sizeof(UINT32);
-			size -= sizeof(UINT32);
-			memcpy(memory, &data, size); 
-		}
-
-		static UINT32 fromMemory(BLEND_STATE_DESC& data, char* memory)
-		{ 
-			UINT32 size;
-			memcpy(&size, memory, sizeof(UINT32)); 
-			memory += sizeof(UINT32);
-
-			UINT32 dataSize = size - sizeof(UINT32);
-			memcpy((void*)&data, memory, dataSize); 
-
-			return size;
-		}
-
-		static UINT32 getDynamicSize(const BLEND_STATE_DESC& data)	
-		{ 
-			UINT64 dataSize = sizeof(data) + sizeof(UINT32);
-
-#if CM_DEBUG_MODE
-			if(dataSize > std::numeric_limits<UINT32>::max())
-			{
-				CM_EXCEPT(InternalErrorException, "Data overflow! Size doesn't fit into 32 bits.");
-			}
-#endif
-
-			return (UINT32)dataSize;
-		}	
-	}; 
-
-	class CM_EXPORT BlendStateRTTI : public RTTIType<BlendState, IReflectable, BlendStateRTTI>
-	{
-	private:
-		BLEND_STATE_DESC& getData(BlendState* obj) { return obj->mData; }
-		void setData(BlendState* obj, BLEND_STATE_DESC& val) 
-		{ 
-			obj->mRTTIData = val;
-		} 
-
-	public:
-		BlendStateRTTI()
-		{
-			addPlainField("mData", 0, &BlendStateRTTI::getData, &BlendStateRTTI::setData);
-		}
-
-		virtual void onDeserializationEnded(IReflectable* obj)
-		{
-			BlendState* blendState = static_cast<BlendState*>(obj);
-			if(!blendState->mRTTIData.empty())
-			{
-				BLEND_STATE_DESC desc = any_cast<BLEND_STATE_DESC>(blendState->mRTTIData);
-
-				blendState->initialize(desc);
-			}
-
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "BlendState";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_BlendState;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return RenderStateManager::instance().createEmptyBlendState();
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmBlendState.h"
+#include "CmRenderStateManager.h"
+
+namespace BansheeEngine
+{
+	template<> struct RTTIPlainType<BLEND_STATE_DESC>
+	{	
+		enum { id = TID_BLEND_STATE_DESC }; enum { hasDynamicSize = 1 };
+
+		static void toMemory(const BLEND_STATE_DESC& data, char* memory)
+		{ 
+			UINT32 size = getDynamicSize(data);
+
+			memcpy(memory, &size, sizeof(UINT32));
+			memory += sizeof(UINT32);
+			size -= sizeof(UINT32);
+			memcpy(memory, &data, size); 
+		}
+
+		static UINT32 fromMemory(BLEND_STATE_DESC& data, char* memory)
+		{ 
+			UINT32 size;
+			memcpy(&size, memory, sizeof(UINT32)); 
+			memory += sizeof(UINT32);
+
+			UINT32 dataSize = size - sizeof(UINT32);
+			memcpy((void*)&data, memory, dataSize); 
+
+			return size;
+		}
+
+		static UINT32 getDynamicSize(const BLEND_STATE_DESC& data)	
+		{ 
+			UINT64 dataSize = sizeof(data) + sizeof(UINT32);
+
+#if CM_DEBUG_MODE
+			if(dataSize > std::numeric_limits<UINT32>::max())
+			{
+				CM_EXCEPT(InternalErrorException, "Data overflow! Size doesn't fit into 32 bits.");
+			}
+#endif
+
+			return (UINT32)dataSize;
+		}	
+	}; 
+
+	class BS_CORE_EXPORT BlendStateRTTI : public RTTIType<BlendState, IReflectable, BlendStateRTTI>
+	{
+	private:
+		BLEND_STATE_DESC& getData(BlendState* obj) { return obj->mData; }
+		void setData(BlendState* obj, BLEND_STATE_DESC& val) 
+		{ 
+			obj->mRTTIData = val;
+		} 
+
+	public:
+		BlendStateRTTI()
+		{
+			addPlainField("mData", 0, &BlendStateRTTI::getData, &BlendStateRTTI::setData);
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj)
+		{
+			BlendState* blendState = static_cast<BlendState*>(obj);
+			if(!blendState->mRTTIData.empty())
+			{
+				BLEND_STATE_DESC desc = any_cast<BLEND_STATE_DESC>(blendState->mRTTIData);
+
+				blendState->initialize(desc);
+			}
+
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "BlendState";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_BlendState;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return RenderStateManager::instance().createEmptyBlendState();
+		}
+	};
 }

+ 452 - 452
CamelotCore/Include/CmCPUProfiler.h → BansheeCore/Include/CmCPUProfiler.h

@@ -1,453 +1,453 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	class CPUProfilerReport;
-
-	/**
-	 * @brief	Provides various performance measuring methods.
-	 * 			
-	 * @note	Thread safe. Matching begin*\end* calls
-	 * 			must belong to the same thread though.
-	 */
-	class CM_EXPORT CPUProfiler
-	{
-		/**
-		 * @brief	Timer class responsible for tracking elapsed time.
-		 */
-		class Timer
-		{
-		public:
-			Timer();
-
-			/**
-			 * @brief	Sets the start time for the timer.
-			 */
-			void start();
-
-			/**
-			 * @brief	Stops the timer and calculates the elapsed time
-			 *			from start time to now.
-			 */
-			void stop();
-
-			/**
-			 * @brief	Resets the elapsed time to zero.
-			 */
-			void reset();
-
-			double time;
-		private:
-			double startTime;
-
-			/**
-			 * @brief	Returns time elapsed since CPU was started in millseconds.
-			 */
-			static inline double getCurrentTime();
-		};
-
-		/**
-		 * @brief	Timer class responsible for tracking number of elapsed CPU cycles.
-		 */
-		class TimerPrecise
-		{
-		public:
-			TimerPrecise();
-
-			/**
-			 * @brief	Starts the counter marking the current number of executed
-			 *			CPU cycles since CPU was started.
-			 */
-			void start();
-
-			/**
-			 * @brief	Ends the counter and calculates the number of CPU cycles between
-			 *			now and the start time.
-			 */
-			void stop();
-
-			/**
-			 * @brief	Resets the cycle count to zero.
-			 */
-			void reset();
-
-			UINT64 cycles;
-		private:
-			UINT64 startCycles;
-
-			/**
-			 * @brief	Queries the CPU for the current number of CPU cycles executed since the
-			 *			program was started.
-			 */
-			static inline UINT64 getNumCycles();
-		};
-
-		/**
-		 * @brief	Contains data about a single profiler sample (counting time in milliseconds).
-		 *	
-		 * @note	A sample is created whenever a named profile block is entered. e.g. if you have a function
-		 *			you are profiling, and it gets called 10 times, there will be 10 samples.
-		 */
-		struct ProfileSample
-		{
-			ProfileSample(double _time, UINT64 _numAllocs, UINT64 _numFrees)
-				:time(_time), numAllocs(_numAllocs), numFrees(_numFrees)
-			{ }
-
-			double time;
-			UINT64 numAllocs;
-			UINT64 numFrees;
-		};
-
-		/**
-		 * @brief	Contains data about a single precise profiler sample (counting CPU cycles).
-		 *
-		 * @note	A sample is created whenever a named profile block is entered. e.g. if you have a function
-		 *			you are profiling, and it gets called 10 times, there will be 10 samples.
-		 */
-		struct PreciseProfileSample
-		{
-			PreciseProfileSample(UINT64 _cycles, UINT64 _numAllocs, UINT64 _numFrees)
-				:cycles(_cycles), numAllocs(_numAllocs), numFrees(_numFrees)
-			{ }
-
-			UINT64 cycles;
-			UINT64 numAllocs;
-			UINT64 numFrees;
-		};
-
-		/**
-		 * @brief	Contains basic (time based) profiling data contained in a profiling block.
-		 */
-		struct ProfileData
-		{
-			/**
-			 * @brief	Begins a new sample and records current sample state. Previous sample must
-			 *			not be active.
-			 */
-			void beginSample();
-
-			/**
-			 * @brief	Records current sample state and creates a new sample based on start and end state.
-			 *			Adds the sample to the sample list.
-			 */
-			void endSample();
-
-			/**
-			 * @brief	Removes the last added sample from the sample list and makes it active again. You must
-			 *			call endSample when done as if you called beginSample.
-			 */
-			void resumeLastSample();
-
-			ProfilerVector<ProfileSample> samples;
-			Timer timer;
-
-			UINT64 memAllocs;
-			UINT64 memFrees;
-		};
-
-		/**
-		 * @brief	Contains precise (CPU cycle based) profiling data contained in a profiling block.
-		 */
-		struct PreciseProfileData
-		{
-			/**
-			 * @brief	Begins a new sample and records current sample state. Previous sample must
-			 *			not be active.
-			 */
-			void beginSample();
-
-			/**
-			 * @brief	Records current sample state and creates a new sample based on start and end state.
-			 *			Adds the sample to the sample list.
-			 */
-			void endSample();
-
-			/**
-			 * @brief	Removes the last added sample from the sample list and makes it active again. You must
-			 *			call endSample when done as if you called beginSample.
-			 */
-			void resumeLastSample();
-
-			ProfilerVector<PreciseProfileSample> samples;
-			TimerPrecise timer;
-
-			UINT64 memAllocs;
-			UINT64 memFrees;
-		};
-
-		/**
-		 * @brief	Contains all sampling information about a single named profiling block.
-		 *			Each block has its own sampling information and optionally child blocks.
-		 */
-		struct ProfiledBlock
-		{
-			ProfiledBlock();
-			~ProfiledBlock();
-
-			/**
-			 * @brief	Attempts to find a child block with the specified name. Returns
-			 *			null if not found.
-			 */
-			ProfiledBlock* findChild(const ProfilerString& name) const;
-
-			ProfilerString name;
-			
-			ProfileData basic;
-			PreciseProfileData precise;
-
-			ProfilerVector<ProfiledBlock*> children;
-		};
-
-		/**
-		 * @brief	CPU sampling type.
-		 */
-		enum class ActiveSamplingType
-		{
-			Basic, /**< Sample using milliseconds. */
-			Precise /**< Sample using CPU cycles. */
-		};
-
-		/**
-		 * @brief	Contains data about the currently active profiling block.
-		 */
-		struct ActiveBlock
-		{
-			ActiveBlock()
-				:type(ActiveSamplingType::Basic), block(nullptr)
-			{ }
-
-			ActiveBlock(ActiveSamplingType _type, ProfiledBlock* _block)
-				:type(_type), block(_block)
-			{ }
-
-			ActiveSamplingType type;
-			ProfiledBlock* block;
-		};
-
-		/**
-		 * @brief	Contains data about an active profiling thread.
-		 */
-		struct ThreadInfo
-		{
-			ThreadInfo();
-
-			/**
-			 * @brief	Starts profiling on the thread. New primary profiling block
-			 *			is created with the given name.
-			 */
-			void begin(const ProfilerString& _name);
-
-			/**
-			 * @brief	Ends profiling on the thread. You should end all samples before calling this,
-			 *			but if you don't they will be terminated automatically.
-			 */
-			void end();
-
-			/**
-			 * @brief	Deletes all internal profiling data and makes the object ready for another
-			 *			iteration. Should be called after end in order to delete any existing data.
-			 */
-			void reset();
-
-			/**
-			 * @brief	Gets the primary profiling block used by the thread.
-			 */
-			ProfiledBlock* getBlock();
-			
-			/**
-			 * @brief	Deletes the provided block.
-			 */
-			void releaseBlock(ProfiledBlock* block);
-
-			static CM_THREADLOCAL ThreadInfo* activeThread;
-			bool isActive;
-
-			ProfiledBlock* rootBlock;
-
-			ProfilerStack<ActiveBlock> activeBlocks;
-			ActiveBlock activeBlock;
-		};
-
-	public:
-		CPUProfiler();
-		~CPUProfiler();
-
-		/**
-		 * @brief	Registers a new thread we will be doing sampling in. This needs to be called before any beginSample*\endSample* calls
-		 * 			are made in that thread.
-		 *
-		 * @param	name	Name that will allow you to more easily identify the thread.
-		 */
-		void beginThread(const ProfilerString& name);
-
-		/**
-		 * @brief	Ends sampling for the current thread. No beginSample*\endSample* calls after this point.
-		 */
-		void endThread();
-
-		/**
-		 * @brief	Begins sample measurement. Must be followed by endSample. 
-		 *
-		 * @param	name	Unique name for the sample you can later use to find the sampling data.
-		 */
-		void beginSample(const ProfilerString& name);
-
-		/**
-		 * @brief	Ends sample measurement.
-		 *
-		 * @param	name	Unique name for the sample. 
-		 * 					
-		 * @note	Unique name is primarily needed to more easily identify mismatched
-		 * 			begin/end sample pairs. Otherwise the name in beginSample would be enough.
-		 */
-		void endSample(const ProfilerString& name);
-
-		/**
-		 * @brief	Begins sample measurement. Must be followed by endSample. 
-		 *
-		 * @param	name	Unique name for the sample you can later use to find the sampling data.
-		 * 					
-		 * @note	This method uses very precise CPU counters to determine variety of data not
-		 * 			provided by standard beginSample. However due to the way these counters work you should
-		 * 			not use this method for larger parts of code. It does not consider context switches so if the OS
-		 * 			decides to switch context between measurements you will get invalid data.
-		 */
-		void beginSamplePrecise(const ProfilerString& name);
-
-		/**
-		 * @brief	Ends precise sample measurement.
-		 *
-		 * @param	name	Unique name for the sample. 
-		 * 					
-		 * @note	Unique name is primarily needed to more easily identify mismatched
-		 * 			begin/end sample pairs. Otherwise the name in beginSamplePrecise would be enough.
-		 */
-		void endSamplePrecise(const ProfilerString& name);
-
-		/**
-		 * @brief	Clears all sampling data, and ends any unfinished sampling blocks.
-		 */
-		void reset();
-
-		/**
-		 * @brief	Generates a report from all previously sampled data.
-		 * 			
-		 * @note	Generating a report will stop all in-progress sampling. You should make sure
-		 * 			you call endSample* manually beforehand so this doesn't have to happen.
-		 */
-		CPUProfilerReport generateReport();
-
-	private:
-		/**
-		 * @brief	Calculates overhead that the timing and sampling methods themselves introduce
-		 *			so we might get more accurate measurements when creating reports.
-		 */
-		void estimateTimerOverhead();
-
-	private:
-		double mBasicTimerOverhead;
-		UINT64 mPreciseTimerOverhead;
-
-		double mBasicSamplingOverheadMs;
-		double mPreciseSamplingOverheadMs;
-		UINT64 mBasicSamplingOverheadCycles;
-		UINT64 mPreciseSamplingOverheadCycles;
-
-		ProfilerVector<ThreadInfo*> mActiveThreads;
-		CM_MUTEX(mThreadSync);
-	};
-
-	/**
-	 * @brief	Profiling entry containing information about a single CPU profiling block
-	 *			containing timing information.
-	 */
-	struct CM_EXPORT CPUProfilerBasicSamplingEntry
-	{
-		struct CM_EXPORT Data
-		{
-			Data();
-
-			String name; /**< Name of the profiling block. */
-			UINT32 numCalls; /**< Number of times the block was entered. */
-
-			UINT64 memAllocs; /**< Number of memory allocations that happened within the block. */
-			UINT64 memFrees; /**< Number of memory deallocations that happened within the block. */
-
-			double avgTimeMs; /**< Average time it took to execute the block, per call. In milliseconds. */
-			double maxTimeMs; /**< Maximum time of a single call in the block. In milliseconds. */
-			double totalTimeMs; /**< Total time the block took, across all calls. In milliseconds. */
-
-			double avgSelfTimeMs; /**< Average time it took to execute the block, per call. Ignores time used by child blocks. In milliseconds. */
-			double totalSelfTimeMs; /**< Total time the block took, across all calls. Ignores time used by child blocks. In milliseconds. */
-
-			double estimatedSelfOverheadMs; /**< Estimated overhead of profiling methods, only for this exact block. In milliseconds. */
-			double estimatedOverheadMs; /**< Estimated overhead of profiling methods for this block and all children. In milliseconds. */
-
-			float pctOfParent; /**< Percent of parent block time this block took to execute. Ranging [0.0, 1.0]. */
-		} data;
-
-		ProfilerVector<CPUProfilerBasicSamplingEntry> childEntries;
-	};
-
-	/**
-	* @brief	Profiling entry containing information about a single CPU profiling block
-	*			containing CPU cycle count based information.
-	*/
-	struct CM_EXPORT CPUProfilerPreciseSamplingEntry
-	{
-		struct CM_EXPORT Data
-		{
-			Data();
-
-			String name; /**< Name of the profiling block. */
-			UINT32 numCalls; /**< Number of times the block was entered. */
-
-			UINT64 memAllocs; /**< Number of memory allocations that happened within the block. */
-			UINT64 memFrees; /**< Number of memory deallocations that happened within the block. */
-
-			UINT64 avgCycles; /**< Average number of cycles it took to execute the block, per call. */
-			UINT64 maxCycles; /**< Maximum number of cycles of a single call in the block. */
-			UINT64 totalCycles; /**< Total number of cycles across all calls in the block. */
-
-			UINT64 avgSelfCycles; /**< Average number of cycles it took to execute the block, per call. Ignores cycles used by child blocks. */
-			UINT64 totalSelfCycles; /**< Total number of cycles across all calls in the block. Ignores time used by child blocks. */
-
-			UINT64 estimatedSelfOverhead; /**< Estimated overhead of profiling methods, only for this exact block. In cycles. */
-			UINT64 estimatedOverhead; /**< Estimated overhead of profiling methods for this block and all children. In cycles. */
-
-			float pctOfParent; /**< Percent of parent block cycles used by this block. Ranging [0.0, 1.0]. */
-		} data;
-
-		ProfilerVector<CPUProfilerPreciseSamplingEntry> childEntries;
-	};
-
-	/**
-	 * @brief	CPU profiling report containing all profiling information for a single profiling session.
-	 */
-	class CM_EXPORT CPUProfilerReport
-	{
-	public:
-		CPUProfilerReport();
-
-		/**
-		 * @brief	Returns root entry for the basic (time based) sampling data. Root entry always contains the
-		 *			profiling block associated with the entire thread.
-		 */
-		const CPUProfilerBasicSamplingEntry& getBasicSamplingData() const { return mBasicSamplingRootEntry; }
-
-		/**
-		 * @brief	Returns root entry for the precise (CPU cycle based) sampling data. Root entry always contains the
-		 *			profiling block associated with the entire thread.
-		 */
-		const CPUProfilerPreciseSamplingEntry& getPreciseSamplingData() const { return mPreciseSamplingRootEntry; }
-
-	private:
-		friend class CPUProfiler;
-
-		CPUProfilerBasicSamplingEntry mBasicSamplingRootEntry;
-		CPUProfilerPreciseSamplingEntry mPreciseSamplingRootEntry;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	class CPUProfilerReport;
+
+	/**
+	 * @brief	Provides various performance measuring methods.
+	 * 			
+	 * @note	Thread safe. Matching begin*\end* calls
+	 * 			must belong to the same thread though.
+	 */
+	class BS_CORE_EXPORT CPUProfiler
+	{
+		/**
+		 * @brief	Timer class responsible for tracking elapsed time.
+		 */
+		class Timer
+		{
+		public:
+			Timer();
+
+			/**
+			 * @brief	Sets the start time for the timer.
+			 */
+			void start();
+
+			/**
+			 * @brief	Stops the timer and calculates the elapsed time
+			 *			from start time to now.
+			 */
+			void stop();
+
+			/**
+			 * @brief	Resets the elapsed time to zero.
+			 */
+			void reset();
+
+			double time;
+		private:
+			double startTime;
+
+			/**
+			 * @brief	Returns time elapsed since CPU was started in millseconds.
+			 */
+			static inline double getCurrentTime();
+		};
+
+		/**
+		 * @brief	Timer class responsible for tracking number of elapsed CPU cycles.
+		 */
+		class TimerPrecise
+		{
+		public:
+			TimerPrecise();
+
+			/**
+			 * @brief	Starts the counter marking the current number of executed
+			 *			CPU cycles since CPU was started.
+			 */
+			void start();
+
+			/**
+			 * @brief	Ends the counter and calculates the number of CPU cycles between
+			 *			now and the start time.
+			 */
+			void stop();
+
+			/**
+			 * @brief	Resets the cycle count to zero.
+			 */
+			void reset();
+
+			UINT64 cycles;
+		private:
+			UINT64 startCycles;
+
+			/**
+			 * @brief	Queries the CPU for the current number of CPU cycles executed since the
+			 *			program was started.
+			 */
+			static inline UINT64 getNumCycles();
+		};
+
+		/**
+		 * @brief	Contains data about a single profiler sample (counting time in milliseconds).
+		 *	
+		 * @note	A sample is created whenever a named profile block is entered. e.g. if you have a function
+		 *			you are profiling, and it gets called 10 times, there will be 10 samples.
+		 */
+		struct ProfileSample
+		{
+			ProfileSample(double _time, UINT64 _numAllocs, UINT64 _numFrees)
+				:time(_time), numAllocs(_numAllocs), numFrees(_numFrees)
+			{ }
+
+			double time;
+			UINT64 numAllocs;
+			UINT64 numFrees;
+		};
+
+		/**
+		 * @brief	Contains data about a single precise profiler sample (counting CPU cycles).
+		 *
+		 * @note	A sample is created whenever a named profile block is entered. e.g. if you have a function
+		 *			you are profiling, and it gets called 10 times, there will be 10 samples.
+		 */
+		struct PreciseProfileSample
+		{
+			PreciseProfileSample(UINT64 _cycles, UINT64 _numAllocs, UINT64 _numFrees)
+				:cycles(_cycles), numAllocs(_numAllocs), numFrees(_numFrees)
+			{ }
+
+			UINT64 cycles;
+			UINT64 numAllocs;
+			UINT64 numFrees;
+		};
+
+		/**
+		 * @brief	Contains basic (time based) profiling data contained in a profiling block.
+		 */
+		struct ProfileData
+		{
+			/**
+			 * @brief	Begins a new sample and records current sample state. Previous sample must
+			 *			not be active.
+			 */
+			void beginSample();
+
+			/**
+			 * @brief	Records current sample state and creates a new sample based on start and end state.
+			 *			Adds the sample to the sample list.
+			 */
+			void endSample();
+
+			/**
+			 * @brief	Removes the last added sample from the sample list and makes it active again. You must
+			 *			call endSample when done as if you called beginSample.
+			 */
+			void resumeLastSample();
+
+			ProfilerVector<ProfileSample> samples;
+			Timer timer;
+
+			UINT64 memAllocs;
+			UINT64 memFrees;
+		};
+
+		/**
+		 * @brief	Contains precise (CPU cycle based) profiling data contained in a profiling block.
+		 */
+		struct PreciseProfileData
+		{
+			/**
+			 * @brief	Begins a new sample and records current sample state. Previous sample must
+			 *			not be active.
+			 */
+			void beginSample();
+
+			/**
+			 * @brief	Records current sample state and creates a new sample based on start and end state.
+			 *			Adds the sample to the sample list.
+			 */
+			void endSample();
+
+			/**
+			 * @brief	Removes the last added sample from the sample list and makes it active again. You must
+			 *			call endSample when done as if you called beginSample.
+			 */
+			void resumeLastSample();
+
+			ProfilerVector<PreciseProfileSample> samples;
+			TimerPrecise timer;
+
+			UINT64 memAllocs;
+			UINT64 memFrees;
+		};
+
+		/**
+		 * @brief	Contains all sampling information about a single named profiling block.
+		 *			Each block has its own sampling information and optionally child blocks.
+		 */
+		struct ProfiledBlock
+		{
+			ProfiledBlock();
+			~ProfiledBlock();
+
+			/**
+			 * @brief	Attempts to find a child block with the specified name. Returns
+			 *			null if not found.
+			 */
+			ProfiledBlock* findChild(const ProfilerString& name) const;
+
+			ProfilerString name;
+			
+			ProfileData basic;
+			PreciseProfileData precise;
+
+			ProfilerVector<ProfiledBlock*> children;
+		};
+
+		/**
+		 * @brief	CPU sampling type.
+		 */
+		enum class ActiveSamplingType
+		{
+			Basic, /**< Sample using milliseconds. */
+			Precise /**< Sample using CPU cycles. */
+		};
+
+		/**
+		 * @brief	Contains data about the currently active profiling block.
+		 */
+		struct ActiveBlock
+		{
+			ActiveBlock()
+				:type(ActiveSamplingType::Basic), block(nullptr)
+			{ }
+
+			ActiveBlock(ActiveSamplingType _type, ProfiledBlock* _block)
+				:type(_type), block(_block)
+			{ }
+
+			ActiveSamplingType type;
+			ProfiledBlock* block;
+		};
+
+		/**
+		 * @brief	Contains data about an active profiling thread.
+		 */
+		struct ThreadInfo
+		{
+			ThreadInfo();
+
+			/**
+			 * @brief	Starts profiling on the thread. New primary profiling block
+			 *			is created with the given name.
+			 */
+			void begin(const ProfilerString& _name);
+
+			/**
+			 * @brief	Ends profiling on the thread. You should end all samples before calling this,
+			 *			but if you don't they will be terminated automatically.
+			 */
+			void end();
+
+			/**
+			 * @brief	Deletes all internal profiling data and makes the object ready for another
+			 *			iteration. Should be called after end in order to delete any existing data.
+			 */
+			void reset();
+
+			/**
+			 * @brief	Gets the primary profiling block used by the thread.
+			 */
+			ProfiledBlock* getBlock();
+			
+			/**
+			 * @brief	Deletes the provided block.
+			 */
+			void releaseBlock(ProfiledBlock* block);
+
+			static CM_THREADLOCAL ThreadInfo* activeThread;
+			bool isActive;
+
+			ProfiledBlock* rootBlock;
+
+			ProfilerStack<ActiveBlock> activeBlocks;
+			ActiveBlock activeBlock;
+		};
+
+	public:
+		CPUProfiler();
+		~CPUProfiler();
+
+		/**
+		 * @brief	Registers a new thread we will be doing sampling in. This needs to be called before any beginSample*\endSample* calls
+		 * 			are made in that thread.
+		 *
+		 * @param	name	Name that will allow you to more easily identify the thread.
+		 */
+		void beginThread(const ProfilerString& name);
+
+		/**
+		 * @brief	Ends sampling for the current thread. No beginSample*\endSample* calls after this point.
+		 */
+		void endThread();
+
+		/**
+		 * @brief	Begins sample measurement. Must be followed by endSample. 
+		 *
+		 * @param	name	Unique name for the sample you can later use to find the sampling data.
+		 */
+		void beginSample(const ProfilerString& name);
+
+		/**
+		 * @brief	Ends sample measurement.
+		 *
+		 * @param	name	Unique name for the sample. 
+		 * 					
+		 * @note	Unique name is primarily needed to more easily identify mismatched
+		 * 			begin/end sample pairs. Otherwise the name in beginSample would be enough.
+		 */
+		void endSample(const ProfilerString& name);
+
+		/**
+		 * @brief	Begins sample measurement. Must be followed by endSample. 
+		 *
+		 * @param	name	Unique name for the sample you can later use to find the sampling data.
+		 * 					
+		 * @note	This method uses very precise CPU counters to determine variety of data not
+		 * 			provided by standard beginSample. However due to the way these counters work you should
+		 * 			not use this method for larger parts of code. It does not consider context switches so if the OS
+		 * 			decides to switch context between measurements you will get invalid data.
+		 */
+		void beginSamplePrecise(const ProfilerString& name);
+
+		/**
+		 * @brief	Ends precise sample measurement.
+		 *
+		 * @param	name	Unique name for the sample. 
+		 * 					
+		 * @note	Unique name is primarily needed to more easily identify mismatched
+		 * 			begin/end sample pairs. Otherwise the name in beginSamplePrecise would be enough.
+		 */
+		void endSamplePrecise(const ProfilerString& name);
+
+		/**
+		 * @brief	Clears all sampling data, and ends any unfinished sampling blocks.
+		 */
+		void reset();
+
+		/**
+		 * @brief	Generates a report from all previously sampled data.
+		 * 			
+		 * @note	Generating a report will stop all in-progress sampling. You should make sure
+		 * 			you call endSample* manually beforehand so this doesn't have to happen.
+		 */
+		CPUProfilerReport generateReport();
+
+	private:
+		/**
+		 * @brief	Calculates overhead that the timing and sampling methods themselves introduce
+		 *			so we might get more accurate measurements when creating reports.
+		 */
+		void estimateTimerOverhead();
+
+	private:
+		double mBasicTimerOverhead;
+		UINT64 mPreciseTimerOverhead;
+
+		double mBasicSamplingOverheadMs;
+		double mPreciseSamplingOverheadMs;
+		UINT64 mBasicSamplingOverheadCycles;
+		UINT64 mPreciseSamplingOverheadCycles;
+
+		ProfilerVector<ThreadInfo*> mActiveThreads;
+		CM_MUTEX(mThreadSync);
+	};
+
+	/**
+	 * @brief	Profiling entry containing information about a single CPU profiling block
+	 *			containing timing information.
+	 */
+	struct BS_CORE_EXPORT CPUProfilerBasicSamplingEntry
+	{
+		struct BS_CORE_EXPORT Data
+		{
+			Data();
+
+			String name; /**< Name of the profiling block. */
+			UINT32 numCalls; /**< Number of times the block was entered. */
+
+			UINT64 memAllocs; /**< Number of memory allocations that happened within the block. */
+			UINT64 memFrees; /**< Number of memory deallocations that happened within the block. */
+
+			double avgTimeMs; /**< Average time it took to execute the block, per call. In milliseconds. */
+			double maxTimeMs; /**< Maximum time of a single call in the block. In milliseconds. */
+			double totalTimeMs; /**< Total time the block took, across all calls. In milliseconds. */
+
+			double avgSelfTimeMs; /**< Average time it took to execute the block, per call. Ignores time used by child blocks. In milliseconds. */
+			double totalSelfTimeMs; /**< Total time the block took, across all calls. Ignores time used by child blocks. In milliseconds. */
+
+			double estimatedSelfOverheadMs; /**< Estimated overhead of profiling methods, only for this exact block. In milliseconds. */
+			double estimatedOverheadMs; /**< Estimated overhead of profiling methods for this block and all children. In milliseconds. */
+
+			float pctOfParent; /**< Percent of parent block time this block took to execute. Ranging [0.0, 1.0]. */
+		} data;
+
+		ProfilerVector<CPUProfilerBasicSamplingEntry> childEntries;
+	};
+
+	/**
+	* @brief	Profiling entry containing information about a single CPU profiling block
+	*			containing CPU cycle count based information.
+	*/
+	struct BS_CORE_EXPORT CPUProfilerPreciseSamplingEntry
+	{
+		struct BS_CORE_EXPORT Data
+		{
+			Data();
+
+			String name; /**< Name of the profiling block. */
+			UINT32 numCalls; /**< Number of times the block was entered. */
+
+			UINT64 memAllocs; /**< Number of memory allocations that happened within the block. */
+			UINT64 memFrees; /**< Number of memory deallocations that happened within the block. */
+
+			UINT64 avgCycles; /**< Average number of cycles it took to execute the block, per call. */
+			UINT64 maxCycles; /**< Maximum number of cycles of a single call in the block. */
+			UINT64 totalCycles; /**< Total number of cycles across all calls in the block. */
+
+			UINT64 avgSelfCycles; /**< Average number of cycles it took to execute the block, per call. Ignores cycles used by child blocks. */
+			UINT64 totalSelfCycles; /**< Total number of cycles across all calls in the block. Ignores time used by child blocks. */
+
+			UINT64 estimatedSelfOverhead; /**< Estimated overhead of profiling methods, only for this exact block. In cycles. */
+			UINT64 estimatedOverhead; /**< Estimated overhead of profiling methods for this block and all children. In cycles. */
+
+			float pctOfParent; /**< Percent of parent block cycles used by this block. Ranging [0.0, 1.0]. */
+		} data;
+
+		ProfilerVector<CPUProfilerPreciseSamplingEntry> childEntries;
+	};
+
+	/**
+	 * @brief	CPU profiling report containing all profiling information for a single profiling session.
+	 */
+	class BS_CORE_EXPORT CPUProfilerReport
+	{
+	public:
+		CPUProfilerReport();
+
+		/**
+		 * @brief	Returns root entry for the basic (time based) sampling data. Root entry always contains the
+		 *			profiling block associated with the entire thread.
+		 */
+		const CPUProfilerBasicSamplingEntry& getBasicSamplingData() const { return mBasicSamplingRootEntry; }
+
+		/**
+		 * @brief	Returns root entry for the precise (CPU cycle based) sampling data. Root entry always contains the
+		 *			profiling block associated with the entire thread.
+		 */
+		const CPUProfilerPreciseSamplingEntry& getPreciseSamplingData() const { return mPreciseSamplingRootEntry; }
+
+	private:
+		friend class CPUProfiler;
+
+		CPUProfilerBasicSamplingEntry mBasicSamplingRootEntry;
+		CPUProfilerPreciseSamplingEntry mPreciseSamplingRootEntry;
+	};
 }

+ 399 - 399
CamelotCore/Include/CmCommandQueue.h → BansheeCore/Include/CmCommandQueue.h

@@ -1,399 +1,399 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmAsyncOp.h"
-#include <functional>
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Command queue policy that provides no synchonization. Should be used
-	 * 			with command queues that are used on a single thread only.
-	 */
-	class CommandQueueNoSync
-	{
-	public:
-		CommandQueueNoSync() {}
-		virtual ~CommandQueueNoSync() {}
-
-		bool isValidThread(CM_THREAD_ID_TYPE ownerThread) const
-		{
-			return CM_THREAD_CURRENT_ID == ownerThread;
-		}
-
-		void lock() { };
-		void unlock() { }
-	};
-
-	/**
-	 * @brief	Command queue policy that provides synchonization. Should be used
-	 * 			with command queues that are used on multiple threads.
-	 */
-	class CommandQueueSync
-	{
-	public:
-		CommandQueueSync()
-			:mLock(mCommandQueueMutex, CM_DEFER_LOCK)
-		{ }
-		virtual ~CommandQueueSync() {}
-
-		bool isValidThread(CM_THREAD_ID_TYPE ownerThread) const
-		{
-			return true;
-		}
-
-		void lock() 
-		{
-			mLock.lock();
-		};
-
-		void unlock()
-		{
-			mLock.unlock();
-		}
-
-	private:
-		CM_MUTEX(mCommandQueueMutex);
-		CM_LOCK_TYPE mLock;
-	};
-
-	/**
-	 * @brief	Represents a single queued command in the command list. Contains all the data for executing the command
-	 * 			and checking up on the command status.
-	 */
-	struct QueuedCommand
-	{
-#if CM_DEBUG_MODE
-		QueuedCommand(std::function<void(AsyncOp&)> _callback, UINT32 _debugId, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callbackWithReturnValue(_callback), debugId(_debugId), returnsValue(true), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(cm_new<AsyncOp>()), ownsData(true)
-		{ }
-
-		QueuedCommand(std::function<void()> _callback, UINT32 _debugId, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callback(_callback), debugId(_debugId), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(nullptr), ownsData(true)
-		{ }
-
-		UINT32 debugId;
-#else
-		QueuedCommand(std::function<void(AsyncOp&)> _callback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callbackWithReturnValue(_callback), returnsValue(true), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(cm_new<AsyncOp>()), ownsData(true)
-		{ }
-
-		QueuedCommand(std::function<void()> _callback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-			:callback(_callback), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(nullptr), ownsData(true)
-		{ }
-#endif
-
-		~QueuedCommand()
-		{
-			if(ownsData && asyncOp != nullptr)
-				cm_delete(asyncOp);
-		}
-
-		QueuedCommand(const QueuedCommand& source)
-		{
-			ownsData = true;
-			source.ownsData = false;
-
-			callback = source.callback;
-			callbackWithReturnValue = source.callbackWithReturnValue;
-			asyncOp = source.asyncOp;
-			returnsValue = source.returnsValue;
-			callbackId = source.callbackId;
-			notifyWhenComplete = source.notifyWhenComplete;
-		}
-
-		QueuedCommand& operator=(const QueuedCommand& rhs)
-		{
-			ownsData = true;
-			rhs.ownsData = false;
-
-			callback = rhs.callback;
-			callbackWithReturnValue = rhs.callbackWithReturnValue;
-			asyncOp = rhs.asyncOp;
-			returnsValue = rhs.returnsValue;
-			callbackId = rhs.callbackId;
-			notifyWhenComplete = rhs.notifyWhenComplete;
-			
-			return *this;
-		}
-
-		std::function<void()> callback;
-		std::function<void(AsyncOp&)> callbackWithReturnValue;
-		AsyncOp* asyncOp;
-		bool returnsValue;
-		UINT32 callbackId;
-		bool notifyWhenComplete;
-
-		mutable bool ownsData;
-	};
-
-	/**
-	 * @brief	Contains a list of commands you may queue for later execution on the core thread.
-	 */
-	class CM_EXPORT CommandQueueBase
-	{
-	public:
-		/**
-		 * @brief	Constructor.
-		 *
-		 * @param	threadId	   	Identifier for the thread the command queue will be getting commands from.					
-		 */
-		CommandQueueBase(CM_THREAD_ID_TYPE threadId);
-		virtual ~CommandQueueBase();
-
-		/**
-		 * @brief	Gets the thread identifier the command queue is used on.
-		 * 			
-		 * @note	If the command queue is using a synchonized access policy generally this
-		 * 			is not relevant as it may be used on multiple threads.
-		 */
-		CM_THREAD_ID_TYPE getThreadId() const { return mMyThreadId; }
-
-		/**
-		 * @brief	Executes all provided commands one by one in order. To get the commands you should call flush().
-		 *
-		 * @param	notifyCallback  	Callback that will be called if a command that has "notifyOnComplete" flag set.
-		 * 								The callback will receive "callbackId" of the command.
-		 */
-		void playbackWithNotify(Queue<QueuedCommand>* commands, std::function<void(UINT32)> notifyCallback);
-
-		/**
-		 * @brief	Executes all provided commands one by one in order. To get the commands you should call flush().
-		 */
-		void playback(Queue<QueuedCommand>* commands);
-
-		/**
-		 * @brief	Allows you to set a breakpoint that will trigger when the specified command is executed.
-		 * 			
-		 * @note	This is helpful when you receive an error on the executing thread and you cannot tell from where was
-		 * 			the command that caused the error queued from. However you can make a note of the queue and command index
-		 * 			and set a breakpoint so that it gets triggered next time you run the program. At that point you can know 
-		 * 			exactly which part of code queued the command by examining the stack trace.
-		 *
-		 * @param	queueIdx  	Zero-based index of the queue the command was queued on.
-		 * @param	commandIdx	Zero-based index of the command.
-		 */
-		static void addBreakpoint(UINT32 queueIdx, UINT32 commandIdx);
-
-		/**
-		 * @brief	Queue up a new command to execute. Make sure the provided function has all of its
-		 * 			parameters properly bound. Last parameter must be unbound and of AsyncOp& type.
-		 * 			This is used to signal that the command is completed, and also for storing the return
-		 * 			value.
-		 * 			
-		 * 			@note	Callback method also needs to call AsyncOp::markAsResolved once it is done
-		 * 			processing. (If it doesn't it will still be called automatically, but the return
-		 * 			value will default to nullptr)
-		 *
-		 * @param	_notifyWhenComplete	(optional) Call the notify method (provided in the call to CommandQueue::playback)
-		 * 								when the command is complete.
-		 * @param	_callbackId			(optional) Identifier for the callback so you can then later find it
-		 * 								if needed.
-		 *
-		 * @return	Async operation object that you can continuously check until the command completes. After
-		 * 			it completes AsyncOp::isResolved will return true and return data will be valid (if
-		 * 			the callback provided any).
-		 */
-		AsyncOp queueReturn(std::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0);
-
-		/**
-		 * @brief	Queue up a new command to execute. Make sure the provided function has all of its
-		 * 			parameters properly bound. Provided command is not expected to return a value. If you
-		 * 			wish to return a value from the callback use the queueReturn which accepts an AsyncOp parameter.
-		 *
-		 * @param	_notifyWhenComplete	(optional) Call the notify method (provided in the call to CommandQueue::playback)
-		 * 								when the command is complete.
-		 * @param	_callbackId		   	(optional) Identifier for the callback so you can then later find
-		 * 								it if needed.
-		 */
-		void queue(std::function<void()> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0);
-
-		/**
-		 * @brief	Returns a copy of all queued commands and makes room for new ones. Must be called from the thread
-		 * 			that created the command queue. Returned commands MUST be passed to "playback" method.
-		 */
-		BansheeEngine::Queue<QueuedCommand>* flush();
-
-		/**
-		 * @brief	Cancels all currently queued commands.
-		 */
-		void cancelAll();
-
-		/**
-		 * @brief	Returns true if no commands are queued.
-		 */
-		bool isEmpty();
-
-	protected:
-		/**
-		 * @brief	Helper method that throws an "Invalid thread" exception. Used primarily
-		 * 			so we can avoid including Exception include in this header.
-		 */
-		void throwInvalidThreadException(const String& message) const;
-
-	private:
-		BansheeEngine::Queue<QueuedCommand>* mCommands;
-		Stack<BansheeEngine::Queue<QueuedCommand>*> mEmptyCommandQueues; // List of empty queues for reuse
-
-		CM_THREAD_ID_TYPE mMyThreadId;
-
-		// Various variables that allow for easier debugging by allowing us to trigger breakpoints
-		// when a certain command was queued.
-#if CM_DEBUG_MODE
-		struct QueueBreakpoint
-		{
-			class HashFunction
-			{
-			public:
-				size_t operator()(const QueueBreakpoint &key) const;
-			};
-
-			class EqualFunction
-			{
-			public:
-				bool operator()(const QueueBreakpoint &a, const QueueBreakpoint &b) const;
-			};
-
-			QueueBreakpoint(UINT32 _queueIdx, UINT32 _commandIdx)
-				:queueIdx(_queueIdx), commandIdx(_commandIdx)
-			{ }
-
-			UINT32 queueIdx;
-			UINT32 commandIdx;
-
-			inline size_t operator()(const QueueBreakpoint& v) const;
-		};
-
-		UINT32 mMaxDebugIdx;
-		UINT32 mCommandQueueIdx;
-
-		static UINT32 MaxCommandQueueIdx;
-		static UnorderedSet<QueueBreakpoint, QueueBreakpoint::HashFunction, QueueBreakpoint::EqualFunction> SetBreakpoints;
-		CM_STATIC_MUTEX(CommandQueueBreakpointMutex);
-
-		/**
-		 * @brief	Checks if the specified command has a breakpoint and throw an assert if it does.
-		 */
-		static void breakIfNeeded(UINT32 queueIdx, UINT32 commandIdx);
-#endif
-	};
-
-	/**
-	 * @copydoc CommandQueueBase
-	 * 			
-	 * @brief	Use SyncPolicy to choose whether you want command queue be synchonized or not. Synchonized
-	 * 			command queues may be used across multiple threads and non-synchonized only on one.
-	 */
-	template<class SyncPolicy = CommandQueueNoSync>
-	class CommandQueue : public CommandQueueBase, public SyncPolicy
-	{
-	public:
-		/**
-		 * @copydoc CommandQueueBase::CommandQueueBase
-		 */
-		CommandQueue(CM_THREAD_ID_TYPE threadId)
-			:CommandQueueBase(threadId)
-		{ }
-
-		~CommandQueue() 
-		{
-#if CM_DEBUG_MODE
-#if CM_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-		}
-
-		/**
-		 * @copydoc CommandQueueBase::queueReturn
-		 */
-		AsyncOp queueReturn(std::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-		{
-#if CM_DEBUG_MODE
-#if CM_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			AsyncOp asyncOp = CommandQueueBase::queueReturn(commandCallback, _notifyWhenComplete, _callbackId);
-			unlock();
-
-			return asyncOp;
-		}
-
-		/**
-		 * @copydoc CommandQueueBase::queue
-		 */
-		void queue(std::function<void()> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
-		{
-#if CM_DEBUG_MODE
-#if CM_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			CommandQueueBase::queue(commandCallback, _notifyWhenComplete, _callbackId);
-			unlock();
-		}
-
-		/**
-		 * @copydoc CommandQueueBase::flush
-		 */
-		BansheeEngine::Queue<QueuedCommand>* flush()
-		{
-#if CM_DEBUG_MODE
-#if CM_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			BansheeEngine::Queue<QueuedCommand>* commands = CommandQueueBase::flush();
-			unlock();
-
-			return commands;
-		}
-
-		/**
-		 * @copydoc CommandQueueBase::cancelAll
-		 */
-		void cancelAll()
-		{
-#if CM_DEBUG_MODE
-#if CM_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			CommandQueueBase::cancelAll();
-			unlock();
-		}
-
-		/**
-		 * @copydoc CommandQueueBase::isEmpty
-		 */
-		bool isEmpty()
-		{
-#if CM_DEBUG_MODE
-#if CM_THREAD_SUPPORT != 0
-			if(!isValidThread(getThreadId()))
-				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
-#endif
-#endif
-
-			lock();
-			bool empty = CommandQueueBase::isEmpty();
-			unlock();
-
-			return empty;
-		}
-	};
-}
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmAsyncOp.h"
+#include <functional>
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Command queue policy that provides no synchonization. Should be used
+	 * 			with command queues that are used on a single thread only.
+	 */
+	class CommandQueueNoSync
+	{
+	public:
+		CommandQueueNoSync() {}
+		virtual ~CommandQueueNoSync() {}
+
+		bool isValidThread(CM_THREAD_ID_TYPE ownerThread) const
+		{
+			return CM_THREAD_CURRENT_ID == ownerThread;
+		}
+
+		void lock() { };
+		void unlock() { }
+	};
+
+	/**
+	 * @brief	Command queue policy that provides synchonization. Should be used
+	 * 			with command queues that are used on multiple threads.
+	 */
+	class CommandQueueSync
+	{
+	public:
+		CommandQueueSync()
+			:mLock(mCommandQueueMutex, CM_DEFER_LOCK)
+		{ }
+		virtual ~CommandQueueSync() {}
+
+		bool isValidThread(CM_THREAD_ID_TYPE ownerThread) const
+		{
+			return true;
+		}
+
+		void lock() 
+		{
+			mLock.lock();
+		};
+
+		void unlock()
+		{
+			mLock.unlock();
+		}
+
+	private:
+		CM_MUTEX(mCommandQueueMutex);
+		CM_LOCK_TYPE mLock;
+	};
+
+	/**
+	 * @brief	Represents a single queued command in the command list. Contains all the data for executing the command
+	 * 			and checking up on the command status.
+	 */
+	struct QueuedCommand
+	{
+#if CM_DEBUG_MODE
+		QueuedCommand(std::function<void(AsyncOp&)> _callback, UINT32 _debugId, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+			:callbackWithReturnValue(_callback), debugId(_debugId), returnsValue(true), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(cm_new<AsyncOp>()), ownsData(true)
+		{ }
+
+		QueuedCommand(std::function<void()> _callback, UINT32 _debugId, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+			:callback(_callback), debugId(_debugId), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(nullptr), ownsData(true)
+		{ }
+
+		UINT32 debugId;
+#else
+		QueuedCommand(std::function<void(AsyncOp&)> _callback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+			:callbackWithReturnValue(_callback), returnsValue(true), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(cm_new<AsyncOp>()), ownsData(true)
+		{ }
+
+		QueuedCommand(std::function<void()> _callback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+			:callback(_callback), returnsValue(false), notifyWhenComplete(_notifyWhenComplete), callbackId(_callbackId), asyncOp(nullptr), ownsData(true)
+		{ }
+#endif
+
+		~QueuedCommand()
+		{
+			if(ownsData && asyncOp != nullptr)
+				cm_delete(asyncOp);
+		}
+
+		QueuedCommand(const QueuedCommand& source)
+		{
+			ownsData = true;
+			source.ownsData = false;
+
+			callback = source.callback;
+			callbackWithReturnValue = source.callbackWithReturnValue;
+			asyncOp = source.asyncOp;
+			returnsValue = source.returnsValue;
+			callbackId = source.callbackId;
+			notifyWhenComplete = source.notifyWhenComplete;
+		}
+
+		QueuedCommand& operator=(const QueuedCommand& rhs)
+		{
+			ownsData = true;
+			rhs.ownsData = false;
+
+			callback = rhs.callback;
+			callbackWithReturnValue = rhs.callbackWithReturnValue;
+			asyncOp = rhs.asyncOp;
+			returnsValue = rhs.returnsValue;
+			callbackId = rhs.callbackId;
+			notifyWhenComplete = rhs.notifyWhenComplete;
+			
+			return *this;
+		}
+
+		std::function<void()> callback;
+		std::function<void(AsyncOp&)> callbackWithReturnValue;
+		AsyncOp* asyncOp;
+		bool returnsValue;
+		UINT32 callbackId;
+		bool notifyWhenComplete;
+
+		mutable bool ownsData;
+	};
+
+	/**
+	 * @brief	Contains a list of commands you may queue for later execution on the core thread.
+	 */
+	class BS_CORE_EXPORT CommandQueueBase
+	{
+	public:
+		/**
+		 * @brief	Constructor.
+		 *
+		 * @param	threadId	   	Identifier for the thread the command queue will be getting commands from.					
+		 */
+		CommandQueueBase(CM_THREAD_ID_TYPE threadId);
+		virtual ~CommandQueueBase();
+
+		/**
+		 * @brief	Gets the thread identifier the command queue is used on.
+		 * 			
+		 * @note	If the command queue is using a synchonized access policy generally this
+		 * 			is not relevant as it may be used on multiple threads.
+		 */
+		CM_THREAD_ID_TYPE getThreadId() const { return mMyThreadId; }
+
+		/**
+		 * @brief	Executes all provided commands one by one in order. To get the commands you should call flush().
+		 *
+		 * @param	notifyCallback  	Callback that will be called if a command that has "notifyOnComplete" flag set.
+		 * 								The callback will receive "callbackId" of the command.
+		 */
+		void playbackWithNotify(Queue<QueuedCommand>* commands, std::function<void(UINT32)> notifyCallback);
+
+		/**
+		 * @brief	Executes all provided commands one by one in order. To get the commands you should call flush().
+		 */
+		void playback(Queue<QueuedCommand>* commands);
+
+		/**
+		 * @brief	Allows you to set a breakpoint that will trigger when the specified command is executed.
+		 * 			
+		 * @note	This is helpful when you receive an error on the executing thread and you cannot tell from where was
+		 * 			the command that caused the error queued from. However you can make a note of the queue and command index
+		 * 			and set a breakpoint so that it gets triggered next time you run the program. At that point you can know 
+		 * 			exactly which part of code queued the command by examining the stack trace.
+		 *
+		 * @param	queueIdx  	Zero-based index of the queue the command was queued on.
+		 * @param	commandIdx	Zero-based index of the command.
+		 */
+		static void addBreakpoint(UINT32 queueIdx, UINT32 commandIdx);
+
+		/**
+		 * @brief	Queue up a new command to execute. Make sure the provided function has all of its
+		 * 			parameters properly bound. Last parameter must be unbound and of AsyncOp& type.
+		 * 			This is used to signal that the command is completed, and also for storing the return
+		 * 			value.
+		 * 			
+		 * 			@note	Callback method also needs to call AsyncOp::markAsResolved once it is done
+		 * 			processing. (If it doesn't it will still be called automatically, but the return
+		 * 			value will default to nullptr)
+		 *
+		 * @param	_notifyWhenComplete	(optional) Call the notify method (provided in the call to CommandQueue::playback)
+		 * 								when the command is complete.
+		 * @param	_callbackId			(optional) Identifier for the callback so you can then later find it
+		 * 								if needed.
+		 *
+		 * @return	Async operation object that you can continuously check until the command completes. After
+		 * 			it completes AsyncOp::isResolved will return true and return data will be valid (if
+		 * 			the callback provided any).
+		 */
+		AsyncOp queueReturn(std::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0);
+
+		/**
+		 * @brief	Queue up a new command to execute. Make sure the provided function has all of its
+		 * 			parameters properly bound. Provided command is not expected to return a value. If you
+		 * 			wish to return a value from the callback use the queueReturn which accepts an AsyncOp parameter.
+		 *
+		 * @param	_notifyWhenComplete	(optional) Call the notify method (provided in the call to CommandQueue::playback)
+		 * 								when the command is complete.
+		 * @param	_callbackId		   	(optional) Identifier for the callback so you can then later find
+		 * 								it if needed.
+		 */
+		void queue(std::function<void()> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0);
+
+		/**
+		 * @brief	Returns a copy of all queued commands and makes room for new ones. Must be called from the thread
+		 * 			that created the command queue. Returned commands MUST be passed to "playback" method.
+		 */
+		BansheeEngine::Queue<QueuedCommand>* flush();
+
+		/**
+		 * @brief	Cancels all currently queued commands.
+		 */
+		void cancelAll();
+
+		/**
+		 * @brief	Returns true if no commands are queued.
+		 */
+		bool isEmpty();
+
+	protected:
+		/**
+		 * @brief	Helper method that throws an "Invalid thread" exception. Used primarily
+		 * 			so we can avoid including Exception include in this header.
+		 */
+		void throwInvalidThreadException(const String& message) const;
+
+	private:
+		BansheeEngine::Queue<QueuedCommand>* mCommands;
+		Stack<BansheeEngine::Queue<QueuedCommand>*> mEmptyCommandQueues; // List of empty queues for reuse
+
+		CM_THREAD_ID_TYPE mMyThreadId;
+
+		// Various variables that allow for easier debugging by allowing us to trigger breakpoints
+		// when a certain command was queued.
+#if CM_DEBUG_MODE
+		struct QueueBreakpoint
+		{
+			class HashFunction
+			{
+			public:
+				size_t operator()(const QueueBreakpoint &key) const;
+			};
+
+			class EqualFunction
+			{
+			public:
+				bool operator()(const QueueBreakpoint &a, const QueueBreakpoint &b) const;
+			};
+
+			QueueBreakpoint(UINT32 _queueIdx, UINT32 _commandIdx)
+				:queueIdx(_queueIdx), commandIdx(_commandIdx)
+			{ }
+
+			UINT32 queueIdx;
+			UINT32 commandIdx;
+
+			inline size_t operator()(const QueueBreakpoint& v) const;
+		};
+
+		UINT32 mMaxDebugIdx;
+		UINT32 mCommandQueueIdx;
+
+		static UINT32 MaxCommandQueueIdx;
+		static UnorderedSet<QueueBreakpoint, QueueBreakpoint::HashFunction, QueueBreakpoint::EqualFunction> SetBreakpoints;
+		CM_STATIC_MUTEX(CommandQueueBreakpointMutex);
+
+		/**
+		 * @brief	Checks if the specified command has a breakpoint and throw an assert if it does.
+		 */
+		static void breakIfNeeded(UINT32 queueIdx, UINT32 commandIdx);
+#endif
+	};
+
+	/**
+	 * @copydoc CommandQueueBase
+	 * 			
+	 * @brief	Use SyncPolicy to choose whether you want command queue be synchonized or not. Synchonized
+	 * 			command queues may be used across multiple threads and non-synchonized only on one.
+	 */
+	template<class SyncPolicy = CommandQueueNoSync>
+	class CommandQueue : public CommandQueueBase, public SyncPolicy
+	{
+	public:
+		/**
+		 * @copydoc CommandQueueBase::CommandQueueBase
+		 */
+		CommandQueue(CM_THREAD_ID_TYPE threadId)
+			:CommandQueueBase(threadId)
+		{ }
+
+		~CommandQueue() 
+		{
+#if CM_DEBUG_MODE
+#if CM_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+		}
+
+		/**
+		 * @copydoc CommandQueueBase::queueReturn
+		 */
+		AsyncOp queueReturn(std::function<void(AsyncOp&)> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+		{
+#if CM_DEBUG_MODE
+#if CM_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			AsyncOp asyncOp = CommandQueueBase::queueReturn(commandCallback, _notifyWhenComplete, _callbackId);
+			unlock();
+
+			return asyncOp;
+		}
+
+		/**
+		 * @copydoc CommandQueueBase::queue
+		 */
+		void queue(std::function<void()> commandCallback, bool _notifyWhenComplete = false, UINT32 _callbackId = 0)
+		{
+#if CM_DEBUG_MODE
+#if CM_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			CommandQueueBase::queue(commandCallback, _notifyWhenComplete, _callbackId);
+			unlock();
+		}
+
+		/**
+		 * @copydoc CommandQueueBase::flush
+		 */
+		BansheeEngine::Queue<QueuedCommand>* flush()
+		{
+#if CM_DEBUG_MODE
+#if CM_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			BansheeEngine::Queue<QueuedCommand>* commands = CommandQueueBase::flush();
+			unlock();
+
+			return commands;
+		}
+
+		/**
+		 * @copydoc CommandQueueBase::cancelAll
+		 */
+		void cancelAll()
+		{
+#if CM_DEBUG_MODE
+#if CM_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			CommandQueueBase::cancelAll();
+			unlock();
+		}
+
+		/**
+		 * @copydoc CommandQueueBase::isEmpty
+		 */
+		bool isEmpty()
+		{
+#if CM_DEBUG_MODE
+#if CM_THREAD_SUPPORT != 0
+			if(!isValidThread(getThreadId()))
+				throwInvalidThreadException("Command queue accessed outside of its creation thread.");
+#endif
+#endif
+
+			lock();
+			bool empty = CommandQueueBase::isEmpty();
+			unlock();
+
+			return empty;
+		}
+	};
+}

+ 65 - 65
CamelotCore/Include/CmComponent.h → BansheeCore/Include/CmComponent.h

@@ -1,66 +1,66 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmGameObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Components represent primarily logic elements in the scene. 
-	 *			They are attached to scene objects.
-	 */
-	class CM_EXPORT Component : public GameObject
-	{
-	public:
-		/**
-		 * @brief	Returns the SceneObject this Component is assigned to.
-		 */
-		HSceneObject sceneObject() const { return mParent; }
-
-		/**
-		 * @copydoc	sceneObject
-		 */
-		HSceneObject SO() const { return sceneObject(); }
-
-		/**
-		 * @brief	Called once per frame on all components.
-		 * 			
-		 * @note	Internal method.
-		 */
-		virtual void update() { }
-
-		/**
-		 * @brief	Removes the component from parent SceneObject and deletes it. All
-		 * 			the references to this component will be marked as destroyed and you
-		 * 			will get an exception if you try to use them.
-		 */
-		void destroy();
-
-	protected:
-		friend class SceneObject;
-
-		Component(const HSceneObject& parent);
-		virtual ~Component();
-
-		/**
-		 * @brief	Called just before the component is destroyed.
-		 */
-		virtual void onDestroyed() {}
-	private:
-		Component(const Component& other) { }
-
-	protected:
-		HSceneObject mParent;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class ComponentRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-
-	protected:
-		Component() {} // Serialization only
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmGameObject.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Components represent primarily logic elements in the scene. 
+	 *			They are attached to scene objects.
+	 */
+	class BS_CORE_EXPORT Component : public GameObject
+	{
+	public:
+		/**
+		 * @brief	Returns the SceneObject this Component is assigned to.
+		 */
+		HSceneObject sceneObject() const { return mParent; }
+
+		/**
+		 * @copydoc	sceneObject
+		 */
+		HSceneObject SO() const { return sceneObject(); }
+
+		/**
+		 * @brief	Called once per frame on all components.
+		 * 			
+		 * @note	Internal method.
+		 */
+		virtual void update() { }
+
+		/**
+		 * @brief	Removes the component from parent SceneObject and deletes it. All
+		 * 			the references to this component will be marked as destroyed and you
+		 * 			will get an exception if you try to use them.
+		 */
+		void destroy();
+
+	protected:
+		friend class SceneObject;
+
+		Component(const HSceneObject& parent);
+		virtual ~Component();
+
+		/**
+		 * @brief	Called just before the component is destroyed.
+		 */
+		virtual void onDestroyed() {}
+	private:
+		Component(const Component& other) { }
+
+	protected:
+		HSceneObject mParent;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class ComponentRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+
+	protected:
+		Component() {} // Serialization only
+	};
 }

+ 34 - 34
CamelotCore/Include/CmComponentRTTI.h → BansheeCore/Include/CmComponentRTTI.h

@@ -1,35 +1,35 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmComponent.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT ComponentRTTI : public RTTIType<Component, GameObject, ComponentRTTI>
-	{
-	private:
-
-	public:
-		ComponentRTTI()
-		{
-
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "Component";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_Component;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmComponent.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT ComponentRTTI : public RTTIType<Component, GameObject, ComponentRTTI>
+	{
+	private:
+
+	public:
+		ComponentRTTI()
+		{
+
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "Component";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_Component;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
+		}
+	};
 }

+ 265 - 265
CamelotCore/Include/CmCoreObject.h → BansheeCore/Include/CmCoreObject.h

@@ -1,266 +1,266 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmAsyncOp.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	This class provides some common functionality that all low-level objects
-	 * 			used on the core thread need to implement.
-	 * 			
-	 * @note	This involves initializing, keeping track of, and releasing GPU resources.
-	 * 			All core GPU objects are initialized on the core thread, and destroyed on the core thread,
-	 * 			so majority of these methods will just schedule object initialization/destruction.
-	 * 			Non-GPU core objects can normally be initialized on the caller thread.
-	 */
-	class CM_EXPORT CoreObject
-	{
-	protected:
-		/**
-		 * @brief	Values that represent current state of the object
-		 */
-		enum Flags
-		{
-			CGO_INITIALIZED = 0x01, /**< Object has been fully initialized and may be used. */
-			CGO_INIT_ON_CORE_THREAD = 0x02, /**< Object requires initialization on core thread. */
-			CGO_SCHEDULED_FOR_INIT = 0x04, /**< Object has been scheduled for initialization but core thread has not completed it yet. */
-			CGO_SCHEDULED_FOR_DELETE = 0x08 /**< Object has been scheduled for deletion but core thread has not completed it yet. */
-		};
-
-	public:
-		/**
-		 * @brief	Constructs a new core object.
-		 *
-		 * @param	requiresGpuInit	(optional) If true the objects initialize_internal and destroy_internal methods
-		 * 							will be called from the core thread asynchronously. Otherwise they will be called 
-		 * 							by the caller thread synchronously.
-		 */
-		CoreObject(bool requiresGpuInit = true);
-		virtual ~CoreObject();
-
-		/**
-		 * @brief	Destroys all GPU resources of this object.
-		 * 			
-		 * @note	If is created with "CGO_INIT_ON_CORE_THREAD" flag destruction is not done immediately, 
-		 * 			and is instead just scheduled on the core thread. 
-		 * 			Unless called from core thread in which case it is executed immediately.
-		 * 			Objects without "CGO_INIT_ON_CORE_THREAD" flag are destructed immediately.
-		 */
-		virtual void destroy();
-
-		/**
-		 * @brief	Initializes all the internal resources of this object. Should be called by the
-		 * 			factory creation methods automatically after construction and not by user directly.
-		 * 					
-		 * @note	If is created with "CGO_INIT_ON_CORE_THREAD" flag initialization is not done immediately, 
-		 * 			and is instead just scheduled on the core thread. 
-		 * 			Unless called from core thread in which case it is executed immediately.
-		 * 			Objects without "CGO_INIT_ON_CORE_THREAD" flag are initialized immediately.
-		 */
-		virtual void initialize();
-
-		/**
-		 * @brief	Returns true if the object has been properly initialized. You are not
-		 * 			allowed to call any methods on the resource until you are sure resource is initialized.
-		 * 			
-		 * @note	Normally CPU objects are initialized on creation and this will never be false, and GPU
-		 * 			objects are initialized when the core thread processes them.
-		 */
-		bool isInitialized() const { return (mFlags & CGO_INITIALIZED) != 0; }
-
-		/**
-		 * @brief	Blocks the current thread until the resource is fully initialized.
-		 * 			
-		 * @note	If you call this without calling initialize first a deadlock will occur.
-		 * 			You should not call this from core thread.
-		 */
-		void synchronize();
-
-		/**
-		 * @brief	Internal method. Sets a shared this pointer to this object. This MUST be called immediately after construction.
-		 *
-		 * @note	Called automatically by the factory creation methods so user should not call this manually.
-		 */
-		void _setThisPtr(std::shared_ptr<CoreObject> ptrThis);
-
-		/**
-		 * @brief	Returns an unique identifier for this object.
-		 */
-		UINT64 getInternalID() const { return mInternalID; }
-
-		/**
-		 * @brief	Internal method. Schedules the object to be destroyed, and then deleted.
-		 */
-		template<class T, class MemAlloc>
-		static void _deleteDelayed(CoreObject* obj)
-		{
-			_deleteDelayedInternal(obj);
-
-			if(obj->isInitialized())
-			{
-				std::shared_ptr<CoreObject> thisPtr(obj);
-				obj->_setThisPtr(thisPtr);
-				obj->destroy();
-			}
-			else
-			{
-				cm_delete<MemAlloc, T>((T*)obj);
-			}
-		}
-
-		/**
-		 * @brief	Returns a shared_ptr version of "this" pointer.
-		 */
-		std::shared_ptr<CoreObject> getThisPtr() const { return mThis.lock(); }
-
-	protected:
-		/**
-		 * @brief	Frees all of the objects dynamically allocated memory. All derived classes that have something to free
-		 * 			should do it here instead of their destructor. All derived classes need to call this base method when they're done.
-		 * 			
-		 * @note	For objects with "CGO_INIT_ON_CORE_THREAD" flag this is scheduled to be executed on the core thread, 
-		 * 			so normally you want to destroy all GPU specific resources here.
-		 */
-		virtual void destroy_internal();
-
-		/**
-		 * @brief	Initializes all the internal resources of this object. Needs to be called before doing
-		 * 			any operations with the object. All derived classes also need to call this base method.
-		 * 			
-		 * @note	For objects with "CGO_INIT_ON_CORE_THREAD" flag this is scheduled to be executed on the core thread, 
-		 * 			so normally you want to initialize all GPU specific resources here.
-		 */
-		virtual void initialize_internal();
-
-		/**
-		 * @brief	Performs some internal checks when an object is being deleted.
-		 */
-		static void _deleteDelayedInternal(CoreObject* obj);
-
-		/**
-		 * @brief	Queues a command to be executed on the core thread, without a return value.
-		 * 			
-		 * @note	Requires a shared pointer to the object this function will be executed on, in order to 
-		 * 			make sure the object is not deleted before the command executes. Can be null if the 
-		 * 			function is static or global.
-		 */
-		static void queueGpuCommand(std::shared_ptr<CoreObject>& obj, std::function<void()> func);
-
-		/**
-		 * @brief	Queues a command to be executed on the core thread, with a return value in the form of AsyncOp.
-		 * 			
-		 * @see		AsyncOp
-		 * 			
-		 * @note	Requires a shared pointer to the object this function will be executed on, in order to
-		 * 			make sure the object is not deleted before the command executes. Can be null if the
-		 * 			function is static or global.
-		 */
-		static AsyncOp queueReturnGpuCommand(std::shared_ptr<CoreObject>& obj, std::function<void(AsyncOp&)> func);
-
-		bool isScheduledToBeInitialized() const { return (mFlags & CGO_SCHEDULED_FOR_INIT) != 0; }
-		bool isScheduledToBeDeleted() const { return (mFlags & CGO_SCHEDULED_FOR_DELETE) != 0; }
-		bool requiresInitOnCoreThread() const { return (mFlags & CGO_INIT_ON_CORE_THREAD) != 0; }
-
-		void setIsInitialized(bool initialized) { mFlags = initialized ? mFlags | CGO_INITIALIZED : mFlags & ~CGO_INITIALIZED; }
-		void setScheduledToBeInitialized(bool scheduled) { mFlags = scheduled ? mFlags | CGO_SCHEDULED_FOR_INIT : mFlags & ~CGO_SCHEDULED_FOR_INIT; }
-		void setScheduledToBeDeleted(bool scheduled) { mFlags = scheduled ? mFlags | CGO_SCHEDULED_FOR_DELETE : mFlags & ~CGO_SCHEDULED_FOR_DELETE; }
-	private:
-		friend class CoreObjectManager;
-
-		volatile UINT8 mFlags;
-		UINT64 mInternalID; // ID == 0 is not a valid ID
-		std::weak_ptr<CoreObject> mThis;
-
-		CM_STATIC_THREAD_SYNCHRONISER(mCoreGpuObjectLoadedCondition)
-		CM_STATIC_MUTEX(mCoreGpuObjectLoadedMutex)
-
-		/**
-		 * @brief	Queues object initialization command on the core thread. The command is added to the
-		 * 			primary core thread queue and will be executed as soon as the core thread is ready.
-		 */
-		static void queueInitializeGpuCommand(std::shared_ptr<CoreObject>& obj);
-
-		/**
-		 * @brief	Queues object destruction command on the core thread. The command is added to the
-		 * 			core thread accessor of this thread and will be executed after accessor commands
-		 * 			are submitted and any previously queued commands are executed.
-		 *
-		 * @note	It is up to the caller to ensure no other accessors attempt to use this object.
-		 */
-		static void queueDestroyGpuCommand(std::shared_ptr<CoreObject>& obj);
-
-		/**
-		 * @brief	Helper wrapper method used for queuing commands with no return value on the core thread.
-		 */
-		static void executeGpuCommand(std::shared_ptr<CoreObject>& obj, std::function<void()> func);
-
-		/**
-		 * @brief	Helper wrapper method used for queuing commands with a return value on the core thread.
-		 */
-		static void executeReturnGpuCommand(std::shared_ptr<CoreObject>& obj, std::function<void(AsyncOp&)> func, AsyncOp& op); 
-	};
-
-	/**
-	 * @brief	Creates a new core object using the specified allocators and returns a shared pointer to it.
-	 *
-	 * @note	All core thread object shared pointers must be created using this method or its overloads
-	 * 			and you should not create them manually.
-	 */
-	template<class Type, class MainAlloc, class PtrDataAlloc, class... Args>
-	std::shared_ptr<Type> cm_core_ptr(Args &&...args)
-	{
-		return std::shared_ptr<Type>(cm_new<Type, MainAlloc>(std::forward<Args>(args)...),
-			&CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<PtrDataAlloc>());
-	}
-
-	/**
-	 * @brief	Creates a new core object using the specified allocator and returns a shared pointer to it.
-	 *
-	 * @note	All core thread object shared pointers must be created using this method or its overloads
-	 * 			and you should not create them manually.
-	 */
-	template<class Type, class MainAlloc, class... Args>
-	std::shared_ptr<Type> cm_core_ptr(Args &&...args)
-	{
-		return std::shared_ptr<Type>(cm_new<Type, MainAlloc>(std::forward<Args>(args)...),
-			&CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<GenAlloc>());
-	}
-
-	/**
-	 * @brief	Creates a new core object and returns a shared pointer to it.
-	 *
-	 * @note	All core thread object shared pointers must be created using this method or its overloads
-	 * 			and you should not create them manually.
-	 */
-	template<class Type, class... Args>
-	std::shared_ptr<Type> cm_core_ptr(Args &&...args)
-	{
-		return std::shared_ptr<Type>(cm_new<Type, GenAlloc>(std::forward<Args>(args)...),
-			&CoreObject::_deleteDelayed<Type, GenAlloc>, StdAlloc<GenAlloc>());
-	}
-
-	/**
-	 * @brief	Creates a core object shared pointer using a previously constructed object.
-	 *
-	 * @note	All core thread object shared pointers must be created using this method or its overloads
-	 * 			and you should not create them manually.
-	 */
-	template<class Type, class MainAlloc>
-	std::shared_ptr<Type> cm_core_ptr(Type* data)
-	{
-		return std::shared_ptr<Type>(data, &CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<GenAlloc>());  
-	}
-
-	/**
-	 * @brief	Creates a core object shared pointer using a previously constructed object.
-	 *
-	 * @note	All core thread object shared pointers must be created using this method or its overloads
-	 * 			and you should not create them manually.
-	 */
-	template<class Type, class MainAlloc, class PtrDataAlloc>
-	std::shared_ptr<Type> cm_core_ptr(Type* data)
-	{
-		return std::shared_ptr<Type>(data, &CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<PtrDataAlloc>());  
-	}
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmAsyncOp.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	This class provides some common functionality that all low-level objects
+	 * 			used on the core thread need to implement.
+	 * 			
+	 * @note	This involves initializing, keeping track of, and releasing GPU resources.
+	 * 			All core GPU objects are initialized on the core thread, and destroyed on the core thread,
+	 * 			so majority of these methods will just schedule object initialization/destruction.
+	 * 			Non-GPU core objects can normally be initialized on the caller thread.
+	 */
+	class BS_CORE_EXPORT CoreObject
+	{
+	protected:
+		/**
+		 * @brief	Values that represent current state of the object
+		 */
+		enum Flags
+		{
+			CGO_INITIALIZED = 0x01, /**< Object has been fully initialized and may be used. */
+			CGO_INIT_ON_CORE_THREAD = 0x02, /**< Object requires initialization on core thread. */
+			CGO_SCHEDULED_FOR_INIT = 0x04, /**< Object has been scheduled for initialization but core thread has not completed it yet. */
+			CGO_SCHEDULED_FOR_DELETE = 0x08 /**< Object has been scheduled for deletion but core thread has not completed it yet. */
+		};
+
+	public:
+		/**
+		 * @brief	Constructs a new core object.
+		 *
+		 * @param	requiresGpuInit	(optional) If true the objects initialize_internal and destroy_internal methods
+		 * 							will be called from the core thread asynchronously. Otherwise they will be called 
+		 * 							by the caller thread synchronously.
+		 */
+		CoreObject(bool requiresGpuInit = true);
+		virtual ~CoreObject();
+
+		/**
+		 * @brief	Destroys all GPU resources of this object.
+		 * 			
+		 * @note	If is created with "CGO_INIT_ON_CORE_THREAD" flag destruction is not done immediately, 
+		 * 			and is instead just scheduled on the core thread. 
+		 * 			Unless called from core thread in which case it is executed immediately.
+		 * 			Objects without "CGO_INIT_ON_CORE_THREAD" flag are destructed immediately.
+		 */
+		virtual void destroy();
+
+		/**
+		 * @brief	Initializes all the internal resources of this object. Should be called by the
+		 * 			factory creation methods automatically after construction and not by user directly.
+		 * 					
+		 * @note	If is created with "CGO_INIT_ON_CORE_THREAD" flag initialization is not done immediately, 
+		 * 			and is instead just scheduled on the core thread. 
+		 * 			Unless called from core thread in which case it is executed immediately.
+		 * 			Objects without "CGO_INIT_ON_CORE_THREAD" flag are initialized immediately.
+		 */
+		virtual void initialize();
+
+		/**
+		 * @brief	Returns true if the object has been properly initialized. You are not
+		 * 			allowed to call any methods on the resource until you are sure resource is initialized.
+		 * 			
+		 * @note	Normally CPU objects are initialized on creation and this will never be false, and GPU
+		 * 			objects are initialized when the core thread processes them.
+		 */
+		bool isInitialized() const { return (mFlags & CGO_INITIALIZED) != 0; }
+
+		/**
+		 * @brief	Blocks the current thread until the resource is fully initialized.
+		 * 			
+		 * @note	If you call this without calling initialize first a deadlock will occur.
+		 * 			You should not call this from core thread.
+		 */
+		void synchronize();
+
+		/**
+		 * @brief	Internal method. Sets a shared this pointer to this object. This MUST be called immediately after construction.
+		 *
+		 * @note	Called automatically by the factory creation methods so user should not call this manually.
+		 */
+		void _setThisPtr(std::shared_ptr<CoreObject> ptrThis);
+
+		/**
+		 * @brief	Returns an unique identifier for this object.
+		 */
+		UINT64 getInternalID() const { return mInternalID; }
+
+		/**
+		 * @brief	Internal method. Schedules the object to be destroyed, and then deleted.
+		 */
+		template<class T, class MemAlloc>
+		static void _deleteDelayed(CoreObject* obj)
+		{
+			_deleteDelayedInternal(obj);
+
+			if(obj->isInitialized())
+			{
+				std::shared_ptr<CoreObject> thisPtr(obj);
+				obj->_setThisPtr(thisPtr);
+				obj->destroy();
+			}
+			else
+			{
+				cm_delete<MemAlloc, T>((T*)obj);
+			}
+		}
+
+		/**
+		 * @brief	Returns a shared_ptr version of "this" pointer.
+		 */
+		std::shared_ptr<CoreObject> getThisPtr() const { return mThis.lock(); }
+
+	protected:
+		/**
+		 * @brief	Frees all of the objects dynamically allocated memory. All derived classes that have something to free
+		 * 			should do it here instead of their destructor. All derived classes need to call this base method when they're done.
+		 * 			
+		 * @note	For objects with "CGO_INIT_ON_CORE_THREAD" flag this is scheduled to be executed on the core thread, 
+		 * 			so normally you want to destroy all GPU specific resources here.
+		 */
+		virtual void destroy_internal();
+
+		/**
+		 * @brief	Initializes all the internal resources of this object. Needs to be called before doing
+		 * 			any operations with the object. All derived classes also need to call this base method.
+		 * 			
+		 * @note	For objects with "CGO_INIT_ON_CORE_THREAD" flag this is scheduled to be executed on the core thread, 
+		 * 			so normally you want to initialize all GPU specific resources here.
+		 */
+		virtual void initialize_internal();
+
+		/**
+		 * @brief	Performs some internal checks when an object is being deleted.
+		 */
+		static void _deleteDelayedInternal(CoreObject* obj);
+
+		/**
+		 * @brief	Queues a command to be executed on the core thread, without a return value.
+		 * 			
+		 * @note	Requires a shared pointer to the object this function will be executed on, in order to 
+		 * 			make sure the object is not deleted before the command executes. Can be null if the 
+		 * 			function is static or global.
+		 */
+		static void queueGpuCommand(std::shared_ptr<CoreObject>& obj, std::function<void()> func);
+
+		/**
+		 * @brief	Queues a command to be executed on the core thread, with a return value in the form of AsyncOp.
+		 * 			
+		 * @see		AsyncOp
+		 * 			
+		 * @note	Requires a shared pointer to the object this function will be executed on, in order to
+		 * 			make sure the object is not deleted before the command executes. Can be null if the
+		 * 			function is static or global.
+		 */
+		static AsyncOp queueReturnGpuCommand(std::shared_ptr<CoreObject>& obj, std::function<void(AsyncOp&)> func);
+
+		bool isScheduledToBeInitialized() const { return (mFlags & CGO_SCHEDULED_FOR_INIT) != 0; }
+		bool isScheduledToBeDeleted() const { return (mFlags & CGO_SCHEDULED_FOR_DELETE) != 0; }
+		bool requiresInitOnCoreThread() const { return (mFlags & CGO_INIT_ON_CORE_THREAD) != 0; }
+
+		void setIsInitialized(bool initialized) { mFlags = initialized ? mFlags | CGO_INITIALIZED : mFlags & ~CGO_INITIALIZED; }
+		void setScheduledToBeInitialized(bool scheduled) { mFlags = scheduled ? mFlags | CGO_SCHEDULED_FOR_INIT : mFlags & ~CGO_SCHEDULED_FOR_INIT; }
+		void setScheduledToBeDeleted(bool scheduled) { mFlags = scheduled ? mFlags | CGO_SCHEDULED_FOR_DELETE : mFlags & ~CGO_SCHEDULED_FOR_DELETE; }
+	private:
+		friend class CoreObjectManager;
+
+		volatile UINT8 mFlags;
+		UINT64 mInternalID; // ID == 0 is not a valid ID
+		std::weak_ptr<CoreObject> mThis;
+
+		CM_STATIC_THREAD_SYNCHRONISER(mCoreGpuObjectLoadedCondition)
+		CM_STATIC_MUTEX(mCoreGpuObjectLoadedMutex)
+
+		/**
+		 * @brief	Queues object initialization command on the core thread. The command is added to the
+		 * 			primary core thread queue and will be executed as soon as the core thread is ready.
+		 */
+		static void queueInitializeGpuCommand(std::shared_ptr<CoreObject>& obj);
+
+		/**
+		 * @brief	Queues object destruction command on the core thread. The command is added to the
+		 * 			core thread accessor of this thread and will be executed after accessor commands
+		 * 			are submitted and any previously queued commands are executed.
+		 *
+		 * @note	It is up to the caller to ensure no other accessors attempt to use this object.
+		 */
+		static void queueDestroyGpuCommand(std::shared_ptr<CoreObject>& obj);
+
+		/**
+		 * @brief	Helper wrapper method used for queuing commands with no return value on the core thread.
+		 */
+		static void executeGpuCommand(std::shared_ptr<CoreObject>& obj, std::function<void()> func);
+
+		/**
+		 * @brief	Helper wrapper method used for queuing commands with a return value on the core thread.
+		 */
+		static void executeReturnGpuCommand(std::shared_ptr<CoreObject>& obj, std::function<void(AsyncOp&)> func, AsyncOp& op); 
+	};
+
+	/**
+	 * @brief	Creates a new core object using the specified allocators and returns a shared pointer to it.
+	 *
+	 * @note	All core thread object shared pointers must be created using this method or its overloads
+	 * 			and you should not create them manually.
+	 */
+	template<class Type, class MainAlloc, class PtrDataAlloc, class... Args>
+	std::shared_ptr<Type> cm_core_ptr(Args &&...args)
+	{
+		return std::shared_ptr<Type>(cm_new<Type, MainAlloc>(std::forward<Args>(args)...),
+			&CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<PtrDataAlloc>());
+	}
+
+	/**
+	 * @brief	Creates a new core object using the specified allocator and returns a shared pointer to it.
+	 *
+	 * @note	All core thread object shared pointers must be created using this method or its overloads
+	 * 			and you should not create them manually.
+	 */
+	template<class Type, class MainAlloc, class... Args>
+	std::shared_ptr<Type> cm_core_ptr(Args &&...args)
+	{
+		return std::shared_ptr<Type>(cm_new<Type, MainAlloc>(std::forward<Args>(args)...),
+			&CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<GenAlloc>());
+	}
+
+	/**
+	 * @brief	Creates a new core object and returns a shared pointer to it.
+	 *
+	 * @note	All core thread object shared pointers must be created using this method or its overloads
+	 * 			and you should not create them manually.
+	 */
+	template<class Type, class... Args>
+	std::shared_ptr<Type> cm_core_ptr(Args &&...args)
+	{
+		return std::shared_ptr<Type>(cm_new<Type, GenAlloc>(std::forward<Args>(args)...),
+			&CoreObject::_deleteDelayed<Type, GenAlloc>, StdAlloc<GenAlloc>());
+	}
+
+	/**
+	 * @brief	Creates a core object shared pointer using a previously constructed object.
+	 *
+	 * @note	All core thread object shared pointers must be created using this method or its overloads
+	 * 			and you should not create them manually.
+	 */
+	template<class Type, class MainAlloc>
+	std::shared_ptr<Type> cm_core_ptr(Type* data)
+	{
+		return std::shared_ptr<Type>(data, &CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<GenAlloc>());  
+	}
+
+	/**
+	 * @brief	Creates a core object shared pointer using a previously constructed object.
+	 *
+	 * @note	All core thread object shared pointers must be created using this method or its overloads
+	 * 			and you should not create them manually.
+	 */
+	template<class Type, class MainAlloc, class PtrDataAlloc>
+	std::shared_ptr<Type> cm_core_ptr(Type* data)
+	{
+		return std::shared_ptr<Type>(data, &CoreObject::_deleteDelayed<Type, MainAlloc>, StdAlloc<PtrDataAlloc>());  
+	}
 }

+ 38 - 38
CamelotCore/Include/CmCoreObjectManager.h → BansheeCore/Include/CmCoreObjectManager.h

@@ -1,39 +1,39 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-
-namespace BansheeEngine
-{
-	// TODO Low priority - Add debug option that would remember a call stack for each resource initialization,
-	// so when we fail to release one we know which one it is.
-	
-	/**
-	 * @brief	Manager that keeps track of all active CoreObjects.
-	 * 			
-	 * @note	Thread safe.
-	 */
-	class CM_EXPORT CoreObjectManager : public Module<CoreObjectManager>
-	{
-	public:
-		CoreObjectManager();
-		~CoreObjectManager();
-
-		/**
-		 * @brief	Registers a new CoreObject notifying the manager the object
-		 * 			is created.
-		 */
-		UINT64 registerObject(CoreObject* object);
-
-		/**
-		 * @brief	Unregisters a CoreObject notifying the manager the object
-		 * 			is destroyed.
-		 */
-		void unregisterObject(CoreObject* object);
-
-	private:
-		UINT64 mNextAvailableID;
-		Map<UINT64, CoreObject*> mObjects;
-		CM_MUTEX(mObjectsMutex);
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+
+namespace BansheeEngine
+{
+	// TODO Low priority - Add debug option that would remember a call stack for each resource initialization,
+	// so when we fail to release one we know which one it is.
+	
+	/**
+	 * @brief	Manager that keeps track of all active CoreObjects.
+	 * 			
+	 * @note	Thread safe.
+	 */
+	class BS_CORE_EXPORT CoreObjectManager : public Module<CoreObjectManager>
+	{
+	public:
+		CoreObjectManager();
+		~CoreObjectManager();
+
+		/**
+		 * @brief	Registers a new CoreObject notifying the manager the object
+		 * 			is created.
+		 */
+		UINT64 registerObject(CoreObject* object);
+
+		/**
+		 * @brief	Unregisters a CoreObject notifying the manager the object
+		 * 			is destroyed.
+		 */
+		void unregisterObject(CoreObject* object);
+
+	private:
+		UINT64 mNextAvailableID;
+		Map<UINT64, CoreObject*> mObjects;
+		CM_MUTEX(mObjectsMutex);
+	};
 }

+ 203 - 203
CamelotCore/Include/CmCoreThread.h → BansheeCore/Include/CmCoreThread.h

@@ -1,204 +1,204 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmCommandQueue.h"
-#include "CmCoreThreadAccessor.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Manager for the core thread. Takes care of starting, running, queuing commands
-	 * 			and shutting down the core thread.
-	 * 			
-	 * @note	How threading works:
-	 * 			 - This class contains a queue which is filled by commands from other threads via queueCommand and queueReturnCommand  
-	 * 			 - Commands are executed on the core thread as soon as they are queued (if core thread is not busy with previous commands)  
-	 * 			 - Core thread accessors are helpers for queuing commands. They serve two purposes:  
-	 * 				- They contain helper methods for various common Core thread commands.
-	 * 				- They perform better than queuing each command directly using queueCommand or queueReturnCommand    
-	 * 			 - Accessors contain a command queue of their own, and queuing commands in them will not automatically start executing the commands  
-	 * 			   like with queueCommand or queueReturnCommand. Instead you must manually call "submitAccessors" when you are ready to send their
-	 * 			   commands to the core thread.
-	 * 			 - Synced accessor is a special type of accessor which may be accessed from any thread. Its commands are always executed after all other  
-	 * 			   non-synced accessors. It is primarily useful when multiple threads are managing the same resource and you must ensure proper order of operations.
-	 * 			   You should use normal accessors whenever possible as synced accessors involve potentially slow synchronization operations.
-	 */
-	class CoreThread : public Module<CoreThread>
-	{
-		struct AccessorContainer
-		{
-			CoreAccessorPtr accessor;
-		};
-
-public:
-	CM_EXPORT CoreThread();
-	CM_EXPORT ~CoreThread();
-
-	/**
-		* @brief	Returns the id of the core thread. 
-		*/
-	CM_EXPORT CM_THREAD_ID_TYPE getCoreThreadId() { return mCoreThreadId; }
-
-	/**
-		* @brief	Creates or retrieves an accessor that you can use for executing commands on the core thread from 
-		* 			a non-core thread. The accessor will be bound to the thread you call this method on.
-		* 			
-		* @note		Accessors contain their own command queue and their commands will only start to get executed once that queue is submitted
-		* 			to the core thread via "submitAccessors" method.
-		*/
-	CM_EXPORT CoreAccessorPtr getAccessor();
-
-	/**
-	* @brief	Retrieves an accessor that you can use for executing commands on the core thread from
-	* 			a non-core thread. There is only one synchronized accessor and you may access it from any thread you wish.
-	* 			Note however that it is much more efficient to retrieve a separate non-synchronized accessor using
-	* 			"getAccessor" for each thread you will be using it on.
-	* 			
-	* @note		Accessors contain their own command queue and their commands will only start to get executed once that queue is submitted
-	* 			to the core thread via "submitAccessors" method.
-	* 			
-	*			Synced accessor commands are sent after all non-synced accessor commands are sent.
-	*/
-	CM_EXPORT SyncedCoreAccessor& getSyncedAccessor();
-
-	/**
-	 * @brief	Queues all the accessor commands and starts executing them on the core thread.
-	 */
-	CM_EXPORT void submitAccessors(bool blockUntilComplete = false);
-
-	/**
-		* @brief	Queues a new command that will be added to the global command queue. You are allowed to call this from any thread,
-		* 			however be aware that it involves possibly slow synchronization primitives, so limit your usage.
-		* 			
-		* @param	blockUntilComplete If true the thread will be blocked until the command executes. Be aware that there may be many commands queued before it
-		* 							   and they all need to be executed in order before the current command is reached, which might take a long time.
-		* 	
-		* @see		CommandQueue::queueReturn
-		*/
-	CM_EXPORT AsyncOp queueReturnCommand(std::function<void(AsyncOp&)> commandCallback, bool blockUntilComplete = false);
-
-	/**
-	* @brief	Queues a new command that will be added to the global command queue.You are allowed to call this from any thread,
-		* 			however be aware that it involves possibly slow synchronization primitives, so limit your usage.
-		* 	
-		* @param	blockUntilComplete If true the thread will be blocked until the command executes. Be aware that there may be many commands queued before it
-		* 							   and they all need to be executed in order before the current command is reached, which might take a long time.
-		* @see		CommandQueue::queue
-		*/
-	CM_EXPORT void queueCommand(std::function<void()> commandCallback, bool blockUntilComplete = false);
-
-	/**
-	 * @brief	Called once every frame.
-	 * 			
-	 * @note	Must be called before sim thread schedules any core thread operations for the frame. 
-	 */
-	CM_EXPORT void update();
-
-	/**
-	 * @brief	Returns a frame allocator that should be used for allocating temporary data being passed to the
-	 * 			core thread. As the name implies the data only lasts one frame, so you need to be careful not
-	 * 			to use it for longer than that.
-	 * 			
-	 * @note	Sim thread only.
-	 */
-	CM_EXPORT FrameAlloc* getFrameAlloc() const;
-private:
-	/**
-	 * @brief	Double buffered frame allocators. Means sim thread cannot be more than 1 frame ahead of core thread
-	 *			(If that changes you should be able to easily add more).
-	 */
-	FrameAlloc* mFrameAllocs[2]; 
-	UINT32 mActiveFrameAlloc;
-
-	static CM_THREADLOCAL AccessorContainer* mAccessor;
-	Vector<AccessorContainer*> mAccessors;
-
-	volatile bool mCoreThreadShutdown;
-
-	CM_THREAD_ID_TYPE mCoreThreadId;
-	CM_MUTEX(mCommandQueueMutex)
-	CM_MUTEX(mAccessorMutex)
-	CM_THREAD_SYNCHRONISER(mCommandReadyCondition)
-	CM_MUTEX(mCommandNotifyMutex)
-	CM_THREAD_SYNCHRONISER(mCommandCompleteCondition)
-
-	CommandQueue<CommandQueueSync>* mCommandQueue;
-
-	UINT32 mMaxCommandNotifyId; /**< ID that will be assigned to the next command with a notifier callback. */
-	Vector<UINT32> mCommandsCompleted; /**< Completed commands that have notifier callbacks set up */
-
-	SyncedCoreAccessor* mSyncedCoreAccessor;
-
-	/**
-		* @brief	Starts the core thread worker method. Should only be called once.
-		*/
-	void initCoreThread();
-
-	/**
-		* @brief	Main worker method of the core thread. Called once thread is started.
-		*/
-	void runCoreThread();
-
-	/**
-		* @brief	Shutdowns the core thread. It will complete all ready commands
-		* 			before shutdown.
-		*/
-	void shutdownCoreThread();
-
-	/**
-		* @brief	Blocks the calling thread until the command with the specified ID completes.
-		* 			Make sure that the specified ID actually exists, otherwise this will block forever.
-		*/
-	void blockUntilCommandCompleted(UINT32 commandId);
-
-	/**
-		* @brief	Callback called by the command list when a specific command finishes executing.
-		* 			This is only called on commands that have a special notify on complete flag set.
-		*
-		* @param	commandId	Identifier for the command.
-		*/
-	void commandCompletedNotify(UINT32 commandId);
-	};
-
-	/**
-	 * @brief	Returns the core thread manager used for dealing with the core thread from external threads.
-	 * 			
-	 * @see		CoreThread
-	 */
-	CM_EXPORT CoreThread& gCoreThread();
-
-	/**
-	 * @brief	Returns a core thread accessor for the current thread. Accessor is retrieved or created depending
-	 * 			if it previously existed. Each thread has its own accessor.
-	 * 	
-	 * @see		CoreThread
-	 */
-	CM_EXPORT CoreThreadAccessor<CommandQueueNoSync>& gCoreAccessor();
-
-	/**
-	 * @brief	Returns a synchronized core accessor you may call from any thread for working with the core thread.
-	 * 			Only one of these exists.
-	 * 			
-	 * @see		CoreThread
-	 */
-	CM_EXPORT CoreThreadAccessor<CommandQueueSync>& gSyncedCoreAccessor();
-
-	/**
-	  * @brief	Throws an exception if current thread isn't the core thread;
-	  */
-	CM_EXPORT void throwIfNotCoreThread();
-
-	/**
-	  * @brief	Throws an exception if current thread is the core thread;
-	  */
-	CM_EXPORT void throwIfCoreThread();
-
-#if CM_DEBUG_MODE
-#define THROW_IF_NOT_CORE_THREAD throwIfNotCoreThread();
-#define THROW_IF_CORE_THREAD throwIfCoreThread();
-#else
-#define THROW_IF_NOT_CORE_THREAD 
-#define THROW_IF_CORE_THREAD
-#endif
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmCommandQueue.h"
+#include "CmCoreThreadAccessor.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Manager for the core thread. Takes care of starting, running, queuing commands
+	 * 			and shutting down the core thread.
+	 * 			
+	 * @note	How threading works:
+	 * 			 - This class contains a queue which is filled by commands from other threads via queueCommand and queueReturnCommand  
+	 * 			 - Commands are executed on the core thread as soon as they are queued (if core thread is not busy with previous commands)  
+	 * 			 - Core thread accessors are helpers for queuing commands. They serve two purposes:  
+	 * 				- They contain helper methods for various common Core thread commands.
+	 * 				- They perform better than queuing each command directly using queueCommand or queueReturnCommand    
+	 * 			 - Accessors contain a command queue of their own, and queuing commands in them will not automatically start executing the commands  
+	 * 			   like with queueCommand or queueReturnCommand. Instead you must manually call "submitAccessors" when you are ready to send their
+	 * 			   commands to the core thread.
+	 * 			 - Synced accessor is a special type of accessor which may be accessed from any thread. Its commands are always executed after all other  
+	 * 			   non-synced accessors. It is primarily useful when multiple threads are managing the same resource and you must ensure proper order of operations.
+	 * 			   You should use normal accessors whenever possible as synced accessors involve potentially slow synchronization operations.
+	 */
+	class CoreThread : public Module<CoreThread>
+	{
+		struct AccessorContainer
+		{
+			CoreAccessorPtr accessor;
+		};
+
+public:
+	BS_CORE_EXPORT CoreThread();
+	BS_CORE_EXPORT ~CoreThread();
+
+	/**
+		* @brief	Returns the id of the core thread. 
+		*/
+	BS_CORE_EXPORT CM_THREAD_ID_TYPE getCoreThreadId() { return mCoreThreadId; }
+
+	/**
+		* @brief	Creates or retrieves an accessor that you can use for executing commands on the core thread from 
+		* 			a non-core thread. The accessor will be bound to the thread you call this method on.
+		* 			
+		* @note		Accessors contain their own command queue and their commands will only start to get executed once that queue is submitted
+		* 			to the core thread via "submitAccessors" method.
+		*/
+	BS_CORE_EXPORT CoreAccessorPtr getAccessor();
+
+	/**
+	* @brief	Retrieves an accessor that you can use for executing commands on the core thread from
+	* 			a non-core thread. There is only one synchronized accessor and you may access it from any thread you wish.
+	* 			Note however that it is much more efficient to retrieve a separate non-synchronized accessor using
+	* 			"getAccessor" for each thread you will be using it on.
+	* 			
+	* @note		Accessors contain their own command queue and their commands will only start to get executed once that queue is submitted
+	* 			to the core thread via "submitAccessors" method.
+	* 			
+	*			Synced accessor commands are sent after all non-synced accessor commands are sent.
+	*/
+	BS_CORE_EXPORT SyncedCoreAccessor& getSyncedAccessor();
+
+	/**
+	 * @brief	Queues all the accessor commands and starts executing them on the core thread.
+	 */
+	BS_CORE_EXPORT void submitAccessors(bool blockUntilComplete = false);
+
+	/**
+		* @brief	Queues a new command that will be added to the global command queue. You are allowed to call this from any thread,
+		* 			however be aware that it involves possibly slow synchronization primitives, so limit your usage.
+		* 			
+		* @param	blockUntilComplete If true the thread will be blocked until the command executes. Be aware that there may be many commands queued before it
+		* 							   and they all need to be executed in order before the current command is reached, which might take a long time.
+		* 	
+		* @see		CommandQueue::queueReturn
+		*/
+	BS_CORE_EXPORT AsyncOp queueReturnCommand(std::function<void(AsyncOp&)> commandCallback, bool blockUntilComplete = false);
+
+	/**
+	* @brief	Queues a new command that will be added to the global command queue.You are allowed to call this from any thread,
+		* 			however be aware that it involves possibly slow synchronization primitives, so limit your usage.
+		* 	
+		* @param	blockUntilComplete If true the thread will be blocked until the command executes. Be aware that there may be many commands queued before it
+		* 							   and they all need to be executed in order before the current command is reached, which might take a long time.
+		* @see		CommandQueue::queue
+		*/
+	BS_CORE_EXPORT void queueCommand(std::function<void()> commandCallback, bool blockUntilComplete = false);
+
+	/**
+	 * @brief	Called once every frame.
+	 * 			
+	 * @note	Must be called before sim thread schedules any core thread operations for the frame. 
+	 */
+	BS_CORE_EXPORT void update();
+
+	/**
+	 * @brief	Returns a frame allocator that should be used for allocating temporary data being passed to the
+	 * 			core thread. As the name implies the data only lasts one frame, so you need to be careful not
+	 * 			to use it for longer than that.
+	 * 			
+	 * @note	Sim thread only.
+	 */
+	BS_CORE_EXPORT FrameAlloc* getFrameAlloc() const;
+private:
+	/**
+	 * @brief	Double buffered frame allocators. Means sim thread cannot be more than 1 frame ahead of core thread
+	 *			(If that changes you should be able to easily add more).
+	 */
+	FrameAlloc* mFrameAllocs[2]; 
+	UINT32 mActiveFrameAlloc;
+
+	static CM_THREADLOCAL AccessorContainer* mAccessor;
+	Vector<AccessorContainer*> mAccessors;
+
+	volatile bool mCoreThreadShutdown;
+
+	CM_THREAD_ID_TYPE mCoreThreadId;
+	CM_MUTEX(mCommandQueueMutex)
+	CM_MUTEX(mAccessorMutex)
+	CM_THREAD_SYNCHRONISER(mCommandReadyCondition)
+	CM_MUTEX(mCommandNotifyMutex)
+	CM_THREAD_SYNCHRONISER(mCommandCompleteCondition)
+
+	CommandQueue<CommandQueueSync>* mCommandQueue;
+
+	UINT32 mMaxCommandNotifyId; /**< ID that will be assigned to the next command with a notifier callback. */
+	Vector<UINT32> mCommandsCompleted; /**< Completed commands that have notifier callbacks set up */
+
+	SyncedCoreAccessor* mSyncedCoreAccessor;
+
+	/**
+		* @brief	Starts the core thread worker method. Should only be called once.
+		*/
+	void initCoreThread();
+
+	/**
+		* @brief	Main worker method of the core thread. Called once thread is started.
+		*/
+	void runCoreThread();
+
+	/**
+		* @brief	Shutdowns the core thread. It will complete all ready commands
+		* 			before shutdown.
+		*/
+	void shutdownCoreThread();
+
+	/**
+		* @brief	Blocks the calling thread until the command with the specified ID completes.
+		* 			Make sure that the specified ID actually exists, otherwise this will block forever.
+		*/
+	void blockUntilCommandCompleted(UINT32 commandId);
+
+	/**
+		* @brief	Callback called by the command list when a specific command finishes executing.
+		* 			This is only called on commands that have a special notify on complete flag set.
+		*
+		* @param	commandId	Identifier for the command.
+		*/
+	void commandCompletedNotify(UINT32 commandId);
+	};
+
+	/**
+	 * @brief	Returns the core thread manager used for dealing with the core thread from external threads.
+	 * 			
+	 * @see		CoreThread
+	 */
+	BS_CORE_EXPORT CoreThread& gCoreThread();
+
+	/**
+	 * @brief	Returns a core thread accessor for the current thread. Accessor is retrieved or created depending
+	 * 			if it previously existed. Each thread has its own accessor.
+	 * 	
+	 * @see		CoreThread
+	 */
+	BS_CORE_EXPORT CoreThreadAccessor<CommandQueueNoSync>& gCoreAccessor();
+
+	/**
+	 * @brief	Returns a synchronized core accessor you may call from any thread for working with the core thread.
+	 * 			Only one of these exists.
+	 * 			
+	 * @see		CoreThread
+	 */
+	BS_CORE_EXPORT CoreThreadAccessor<CommandQueueSync>& gSyncedCoreAccessor();
+
+	/**
+	  * @brief	Throws an exception if current thread isn't the core thread;
+	  */
+	BS_CORE_EXPORT void throwIfNotCoreThread();
+
+	/**
+	  * @brief	Throws an exception if current thread is the core thread;
+	  */
+	BS_CORE_EXPORT void throwIfCoreThread();
+
+#if CM_DEBUG_MODE
+#define THROW_IF_NOT_CORE_THREAD throwIfNotCoreThread();
+#define THROW_IF_CORE_THREAD throwIfCoreThread();
+#else
+#define THROW_IF_NOT_CORE_THREAD 
+#define THROW_IF_CORE_THREAD
+#endif
 }

+ 204 - 204
CamelotCore/Include/CmCoreThreadAccessor.h → BansheeCore/Include/CmCoreThreadAccessor.h

@@ -1,205 +1,205 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRenderSystem.h"
-#include "CmCommandQueue.h"
-#include "CmAsyncOp.h"
-#include "CmColor.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains some base functionality used for CoreThreadAccessor.
-	 * 			
-	 * @see		CoreThreadAccesor
-	 */
-	class CM_EXPORT CoreThreadAccessorBase
-	{
-	public:
-		CoreThreadAccessorBase(CommandQueueBase* commandQueue);
-		virtual ~CoreThreadAccessorBase();
-
-		/** @copydoc RenderSystem::disableTextureUnit() */
-		void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
-
-		/** @copydoc RenderSystem::setTexture() */
-		void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const TexturePtr &texPtr);
-
-		/** @copydoc RenderSystem::setSamplerState() */
-		void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SamplerStatePtr& samplerState);
-
-		/** @copydoc RenderSystem::setBlendState() */
-		void setBlendState(const BlendStatePtr& blendState);
-
-		/** @copydoc RenderSystem::setRasterizerState() */
-		void setRasterizerState(const RasterizerStatePtr& rasterizerState);
-
-		/** @copydoc RenderSystem::setRasterizerState() */
-		void setDepthStencilState(const DepthStencilStatePtr& depthStencilState, UINT32 stencilRefValue);
-
-		/** @copydoc RenderSystem::setViewport() */
-		void setViewport(const ViewportPtr& vp);
-
-		/** @copydoc RenderSystem::setDrawOperation() */
-		void setDrawOperation(DrawOperationType op);
-
-		/** @copydoc RenderSystem::setClipPlanes() */
-		void setClipPlanes(const PlaneList& clipPlanes);
-
-		/** @copydoc RenderSystem::addClipPlane(const Plane&) */
-		void addClipPlane(const Plane& p);
-
-		/** @copydoc RenderSystem::resetClipPlanes() */
-		void resetClipPlanes();
-
-		/** @copydoc RenderSystem::setScissorTest() */
-		void setScissorTest(UINT32 left = 0, UINT32 top = 0, UINT32 right = 800, UINT32 bottom = 600);
-
-		/** @copydoc RenderSystem::setRenderTarget() */
-		void setRenderTarget(RenderTargetPtr target);
-
-		/** @copydoc RenderSystem::bindGpuProgram() */
-		void bindGpuProgram(HGpuProgram prg);
-
-		/** @copydoc RenderSystem::unbindGpuProgram() */
-		void unbindGpuProgram(GpuProgramType gptype);
-
-		/** @copydoc RenderSystem::bindGpuParams() */
-		void bindGpuParams(GpuProgramType gptype, const GpuParamsPtr& params);
-
-		/** @copydoc RenderSystem::beginFrame() */
-		void beginRender();
-
-		/** @copydoc RenderSystem::endFrame() */
-		void endRender();
-
-		/** @copydoc RenderSystem::clearRenderTarget() */
-		void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0);
-
-		/** @copydoc RenderSystem::clearViewport() */
-		void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0);
-
-		/** @copydoc RenderSystem::swapBuffers() */
-		void swapBuffers(RenderTargetPtr target);
-
-		/** @copydoc RenderSystem::render() */
-		void render(const MeshBasePtr& mesh, UINT32 indexOffset = 0, UINT32 indexCount = 0, bool useIndices = true, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/** @copydoc RenderSystem::draw() */
-		void draw(UINT32 vertexOffset, UINT32 vertexCount);
-
-		/** @copydoc RenderSystem::drawIndexed() */
-		void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount);
-
-		/**
-		 * @brief	Binds the specified parameters to the pass GPU programs and activates the pass and its
-		 * 			states for any further rendering.
-		 */
-		void setPass(const PassPtr& pass, const PassParametersPtr& params);
-
-		/**
-		 * @copydoc RenderSystem::writeSubresource()
-		 *
-		 * @param discardEntireBuffer When true the existing contents of the resource you are updating will be discarded. This can make the
-		 * 							  operation faster. Resources with certain buffer types might require this flag to be in a specific state
-		 * 							  otherwise the operation will fail. 
-		 *
-		 * @note Resource is updated with data from "data" parameter when the async operation completes. 
-		 * 		 Until the async operation completes "data" is owned by the core thread and you won't
-		 * 		 be able to access it. 
-		 * 		 
-		 *		Normally dynamic buffers will require you to enable "discardEntireBuffer" flag, while static buffers require it disabled.
-		 */
-		AsyncOp writeSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data, bool discardEntireBuffer = false);
-
-		/**
-		 * @copydoc RenderSystem::readSubresource()
-		 *
-		 * @note "data" parameter is populated with subresource data when the async operation completes. 
-		 * 		 Until the async operation completes "data" is owned by the core thread and you won't
-		 * 		 be able to access it.
-		 */
-		AsyncOp readSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data);
-
-		/**
-		 * @brief	Resize the provided window to specified width and height in pixels.
-		 */
-		void resizeWindow(RenderWindowPtr& renderWindow, UINT32 width, UINT32 height);
-
-		/**
-		 * @brief	Move the provided window to specified screen coordinates.
-		 */
-		void moveWindow(RenderWindowPtr& renderWindow, INT32 left, INT32 top);
-
-		/**
-		 * @brief	Hide the provided window. (Does not destroy it, just hides it).
-		 */
-		void hideWindow(RenderWindowPtr& renderWindow);
-
-		/**
-		 * @brief	Shows a previously hidden window.
-		 */
-		void showWindow(RenderWindowPtr& renderWindow);
-
-		/**
-		 * @copydoc RenderWindow::setFullscreen(UINT32, UINT32, float, UINT32)
-		 */
-		void setFullscreen(RenderWindowPtr& renderWindow, UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
-
-		/**
-		 * @copydoc RenderWindow::setFullscreen(const VideoMode&)
-		 */
-		void setFullscreen(RenderWindowPtr& renderWindow, const VideoMode& mode);
-
-		/**
-		 * @copydoc RenderWindow::setWindowed
-		 */
-		void setWindowed(RenderWindowPtr& renderWindow);
-
-		/**
-		* @brief	Queues a new generic command that will be added to the command queue.
-		*/
-		AsyncOp queueReturnCommand(std::function<void(AsyncOp&)> commandCallback);
-
-		/**
-		* @brief	Queues a new generic command that will be added to the command queue.
-		*/
-		void queueCommand(std::function<void()> commandCallback);
-
-		/**
-		 * @brief	Makes all the currently queued commands available to the core thread. They will be executed
-		 * 			as soon as the core thread is ready. All queued commands are removed from the accessor.
-		 */
-		void submitToCoreThread(bool blockUntilComplete = false);
-
-		/**
-		 * @brief	Cancels all commands in the queue.
-		 */
-		void cancelAll();
-
-	private:
-		CommandQueueBase* mCommandQueue;
-	};
-
-	/**
-	 * @brief	Core thread accessor allows you to schedule core commands outside of the core thread. Provides a set of common
-	 * 			methods you may want to execute on the core thread, as well as a general command queuing methods.
-	 * 			
-	 * @note	Queued commands are only executed after the call to submitToCoreThread, in the order they were submitted.
-	 */
-	template <class CommandQueueSyncPolicy = CommandQueueNoSync>
-	class CM_EXPORT CoreThreadAccessor : public CoreThreadAccessorBase
-	{
-	public:
-		/**
-		 * @brief	Constructor.
-		 *
-		 * @param	threadId		Identifier for the thread that created the accessor.
-		 */
-		CoreThreadAccessor(CM_THREAD_ID_TYPE threadId)
-			:CoreThreadAccessorBase(cm_new<CommandQueue<CommandQueueSyncPolicy>>(threadId))
-		{
-
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRenderSystem.h"
+#include "CmCommandQueue.h"
+#include "CmAsyncOp.h"
+#include "CmColor.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Contains some base functionality used for CoreThreadAccessor.
+	 * 			
+	 * @see		CoreThreadAccesor
+	 */
+	class BS_CORE_EXPORT CoreThreadAccessorBase
+	{
+	public:
+		CoreThreadAccessorBase(CommandQueueBase* commandQueue);
+		virtual ~CoreThreadAccessorBase();
+
+		/** @copydoc RenderSystem::disableTextureUnit() */
+		void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
+
+		/** @copydoc RenderSystem::setTexture() */
+		void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const TexturePtr &texPtr);
+
+		/** @copydoc RenderSystem::setSamplerState() */
+		void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SamplerStatePtr& samplerState);
+
+		/** @copydoc RenderSystem::setBlendState() */
+		void setBlendState(const BlendStatePtr& blendState);
+
+		/** @copydoc RenderSystem::setRasterizerState() */
+		void setRasterizerState(const RasterizerStatePtr& rasterizerState);
+
+		/** @copydoc RenderSystem::setRasterizerState() */
+		void setDepthStencilState(const DepthStencilStatePtr& depthStencilState, UINT32 stencilRefValue);
+
+		/** @copydoc RenderSystem::setViewport() */
+		void setViewport(const ViewportPtr& vp);
+
+		/** @copydoc RenderSystem::setDrawOperation() */
+		void setDrawOperation(DrawOperationType op);
+
+		/** @copydoc RenderSystem::setClipPlanes() */
+		void setClipPlanes(const PlaneList& clipPlanes);
+
+		/** @copydoc RenderSystem::addClipPlane(const Plane&) */
+		void addClipPlane(const Plane& p);
+
+		/** @copydoc RenderSystem::resetClipPlanes() */
+		void resetClipPlanes();
+
+		/** @copydoc RenderSystem::setScissorTest() */
+		void setScissorTest(UINT32 left = 0, UINT32 top = 0, UINT32 right = 800, UINT32 bottom = 600);
+
+		/** @copydoc RenderSystem::setRenderTarget() */
+		void setRenderTarget(RenderTargetPtr target);
+
+		/** @copydoc RenderSystem::bindGpuProgram() */
+		void bindGpuProgram(HGpuProgram prg);
+
+		/** @copydoc RenderSystem::unbindGpuProgram() */
+		void unbindGpuProgram(GpuProgramType gptype);
+
+		/** @copydoc RenderSystem::bindGpuParams() */
+		void bindGpuParams(GpuProgramType gptype, const GpuParamsPtr& params);
+
+		/** @copydoc RenderSystem::beginFrame() */
+		void beginRender();
+
+		/** @copydoc RenderSystem::endFrame() */
+		void endRender();
+
+		/** @copydoc RenderSystem::clearRenderTarget() */
+		void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0);
+
+		/** @copydoc RenderSystem::clearViewport() */
+		void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0);
+
+		/** @copydoc RenderSystem::swapBuffers() */
+		void swapBuffers(RenderTargetPtr target);
+
+		/** @copydoc RenderSystem::render() */
+		void render(const MeshBasePtr& mesh, UINT32 indexOffset = 0, UINT32 indexCount = 0, bool useIndices = true, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/** @copydoc RenderSystem::draw() */
+		void draw(UINT32 vertexOffset, UINT32 vertexCount);
+
+		/** @copydoc RenderSystem::drawIndexed() */
+		void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount);
+
+		/**
+		 * @brief	Binds the specified parameters to the pass GPU programs and activates the pass and its
+		 * 			states for any further rendering.
+		 */
+		void setPass(const PassPtr& pass, const PassParametersPtr& params);
+
+		/**
+		 * @copydoc RenderSystem::writeSubresource()
+		 *
+		 * @param discardEntireBuffer When true the existing contents of the resource you are updating will be discarded. This can make the
+		 * 							  operation faster. Resources with certain buffer types might require this flag to be in a specific state
+		 * 							  otherwise the operation will fail. 
+		 *
+		 * @note Resource is updated with data from "data" parameter when the async operation completes. 
+		 * 		 Until the async operation completes "data" is owned by the core thread and you won't
+		 * 		 be able to access it. 
+		 * 		 
+		 *		Normally dynamic buffers will require you to enable "discardEntireBuffer" flag, while static buffers require it disabled.
+		 */
+		AsyncOp writeSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data, bool discardEntireBuffer = false);
+
+		/**
+		 * @copydoc RenderSystem::readSubresource()
+		 *
+		 * @note "data" parameter is populated with subresource data when the async operation completes. 
+		 * 		 Until the async operation completes "data" is owned by the core thread and you won't
+		 * 		 be able to access it.
+		 */
+		AsyncOp readSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data);
+
+		/**
+		 * @brief	Resize the provided window to specified width and height in pixels.
+		 */
+		void resizeWindow(RenderWindowPtr& renderWindow, UINT32 width, UINT32 height);
+
+		/**
+		 * @brief	Move the provided window to specified screen coordinates.
+		 */
+		void moveWindow(RenderWindowPtr& renderWindow, INT32 left, INT32 top);
+
+		/**
+		 * @brief	Hide the provided window. (Does not destroy it, just hides it).
+		 */
+		void hideWindow(RenderWindowPtr& renderWindow);
+
+		/**
+		 * @brief	Shows a previously hidden window.
+		 */
+		void showWindow(RenderWindowPtr& renderWindow);
+
+		/**
+		 * @copydoc RenderWindow::setFullscreen(UINT32, UINT32, float, UINT32)
+		 */
+		void setFullscreen(RenderWindowPtr& renderWindow, UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
+
+		/**
+		 * @copydoc RenderWindow::setFullscreen(const VideoMode&)
+		 */
+		void setFullscreen(RenderWindowPtr& renderWindow, const VideoMode& mode);
+
+		/**
+		 * @copydoc RenderWindow::setWindowed
+		 */
+		void setWindowed(RenderWindowPtr& renderWindow);
+
+		/**
+		* @brief	Queues a new generic command that will be added to the command queue.
+		*/
+		AsyncOp queueReturnCommand(std::function<void(AsyncOp&)> commandCallback);
+
+		/**
+		* @brief	Queues a new generic command that will be added to the command queue.
+		*/
+		void queueCommand(std::function<void()> commandCallback);
+
+		/**
+		 * @brief	Makes all the currently queued commands available to the core thread. They will be executed
+		 * 			as soon as the core thread is ready. All queued commands are removed from the accessor.
+		 */
+		void submitToCoreThread(bool blockUntilComplete = false);
+
+		/**
+		 * @brief	Cancels all commands in the queue.
+		 */
+		void cancelAll();
+
+	private:
+		CommandQueueBase* mCommandQueue;
+	};
+
+	/**
+	 * @brief	Core thread accessor allows you to schedule core commands outside of the core thread. Provides a set of common
+	 * 			methods you may want to execute on the core thread, as well as a general command queuing methods.
+	 * 			
+	 * @note	Queued commands are only executed after the call to submitToCoreThread, in the order they were submitted.
+	 */
+	template <class CommandQueueSyncPolicy = CommandQueueNoSync>
+	class BS_CORE_EXPORT CoreThreadAccessor : public CoreThreadAccessorBase
+	{
+	public:
+		/**
+		 * @brief	Constructor.
+		 *
+		 * @param	threadId		Identifier for the thread that created the accessor.
+		 */
+		CoreThreadAccessor(CM_THREAD_ID_TYPE threadId)
+			:CoreThreadAccessorBase(cm_new<CommandQueue<CommandQueueSyncPolicy>>(threadId))
+		{
+
+		}
+	};
 }

+ 16 - 16
CamelotCore/Include/CmDefaultRenderQueue.h → BansheeCore/Include/CmDefaultRenderQueue.h

@@ -1,17 +1,17 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRenderQueue.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Default implementation of a render queue. Just passes
-	 * 			through elements unmodified as they were queued in.
-	 */
-	class CM_EXPORT DefaultRenderQueue : public RenderQueue
-	{
-	public:
-		void sort();
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRenderQueue.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Default implementation of a render queue. Just passes
+	 * 			through elements unmodified as they were queued in.
+	 */
+	class BS_CORE_EXPORT DefaultRenderQueue : public RenderQueue
+	{
+	public:
+		void sort();
+	};
 }

+ 36 - 36
CamelotCore/Include/CmDeferredCallManager.h → BansheeCore/Include/CmDeferredCallManager.h

@@ -1,37 +1,37 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Allows you to queue calls that can get executed later.
-	 * 			
-	 * @note	Sim thread only.
-	 */
-	class CM_EXPORT DeferredCallManager : public Module<DeferredCallManager>
-	{
-	public:
-		DeferredCallManager();
-
-		/**
-		 * @brief	Register a deferred call that will be executed once at the start of next frame.
-		 *
-		 * @param	func		The function to execute.
-		 */
-		void queueDeferredCall(std::function<void()> func);
-
-		/**
-		 * @brief	Executes all the scheduled calls. To be called once per frame.
-		 *
-		 * @note	Internal method.
-		 */
-		void _update();
-
-	private:
-		friend class DeferredCall;
-
-		Vector<std::function<void()>> mCallbacks;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Allows you to queue calls that can get executed later.
+	 * 			
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT DeferredCallManager : public Module<DeferredCallManager>
+	{
+	public:
+		DeferredCallManager();
+
+		/**
+		 * @brief	Register a deferred call that will be executed once at the start of next frame.
+		 *
+		 * @param	func		The function to execute.
+		 */
+		void queueDeferredCall(std::function<void()> func);
+
+		/**
+		 * @brief	Executes all the scheduled calls. To be called once per frame.
+		 *
+		 * @note	Internal method.
+		 */
+		void _update();
+
+	private:
+		friend class DeferredCall;
+
+		Vector<std::function<void()>> mCallbacks;
+	};
 }

+ 170 - 170
CamelotCore/Include/CmDepthStencilState.h → BansheeCore/Include/CmDepthStencilState.h

@@ -1,171 +1,171 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmResource.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Descriptor structured used for initializing DepthStencilState.
-	 *
-	 * @see		DepthStencilState
-	 */
-	struct CM_EXPORT DEPTH_STENCIL_STATE_DESC
-	{
-		DEPTH_STENCIL_STATE_DESC()
-			: depthReadEnable(true)
-			, depthWriteEnable(true)
-			, depthComparisonFunc(CMPF_LESS)
-			, stencilEnable(false)
-			, stencilReadMask(0xFF)
-			, stencilWriteMask(0xFF)
-			, frontStencilFailOp(SOP_KEEP)
-			, frontStencilZFailOp(SOP_KEEP)
-			, frontStencilPassOp(SOP_KEEP)
-			, frontStencilComparisonFunc(CMPF_ALWAYS_PASS)
-			, backStencilFailOp(SOP_KEEP)
-			, backStencilZFailOp(SOP_KEEP)
-			, backStencilPassOp(SOP_KEEP)
-			, backStencilComparisonFunc(CMPF_ALWAYS_PASS)
-		{ }
-
-		bool depthReadEnable;
-		bool depthWriteEnable;
-		CompareFunction depthComparisonFunc;
-
-		bool stencilEnable;
-		UINT8 stencilReadMask;
-		UINT8 stencilWriteMask;
-
-		StencilOperation frontStencilFailOp;
-		StencilOperation frontStencilZFailOp;
-		StencilOperation frontStencilPassOp;
-		CompareFunction frontStencilComparisonFunc;
-
-		StencilOperation backStencilFailOp;
-		StencilOperation backStencilZFailOp;
-		StencilOperation backStencilPassOp;
-		CompareFunction backStencilComparisonFunc;
-	};
-
-	CM_ALLOW_MEMCPY_SERIALIZATION(DEPTH_STENCIL_STATE_DESC);
-
-	/**
-	* @brief	Render system pipeline state that allows you to modify how an object is rendered.
-	* 			More exactly this state allows to you to control how are depth and stencil buffers
-	*			modified upon rendering.
-	*
-	* @note		Depth stencil states are immutable. Thread safe.
-	*/
-	class CM_EXPORT DepthStencilState : public Resource
-	{
-	public:
-		virtual ~DepthStencilState() {}
-
-		/**
-		 * @brief	If enabled, any pixel about to be written will be tested against the depth value
-		 *			currently in the buffer. If the depth test passes (depending on the set value
-		 *			and chosen depth comparison function), that pixel is written and depth is
-		 *			updated (if depth write is enabled).
-		 */
-		bool getDepthReadEnable() const { return mData.depthReadEnable; }
-
-		/**
-		 * @brief	If enabled rendering pixels will update the depth buffer value. 
-		 */
-		bool getDepthWriteEnable() const { return mData.depthWriteEnable; }
-
-		/**
-		 * @brief	Determines what operation should the renderer use when comparing previous and 
-		 *			current depth value. If the operation passes, pixel with the current depth
-		 *			value will be considered visible.
-		 */
-		CompareFunction getDepthComparisonFunc() const { return mData.depthComparisonFunc; }
-
-		/**
-		 * @brief	If true then stencil buffer will also be updated when a pixel is written, and
-		 *			pixels will be tested against the stencil buffer before rendering.
-		 */
-		bool getStencilEnable() const { return mData.stencilEnable; }
-
-		/**
-		 * @brief	Mask to apply to any value read from the stencil buffer, before applying the
-		 *			stencil comparison function.
-		 */
-		UINT8 getStencilReadMask() const { return mData.stencilReadMask; }
-
-		/**
-		 * @brief	Mask to apply to any value about to be written in the stencil buffer.
-		 */
-		UINT8 getStencilWriteMask() const { return mData.stencilWriteMask; }
-
-		/**
-		 * @brief	Operation that happens when stencil comparison function fails on a front facing polygon.
-		 */
-		StencilOperation getStencilFrontFailOp() const { return mData.frontStencilFailOp; }
-
-		/**
-		* @brief	Operation that happens when stencil comparison function passes but depth test fails
-		*			on a front facing polygon.
-		*/
-		StencilOperation getStencilFrontZFailOp() const { return mData.frontStencilZFailOp; }
-
-		/**
-		* @brief	Operation that happens when stencil comparison function passes on a front facing polygon.
-		*/
-		StencilOperation getStencilFrontPassOp() const { return mData.frontStencilPassOp; }
-
-		/**
-		 * @brief	Stencil comparison function used for front facing polygons. Stencil buffer will be modified according
-		 *			to previously set stencil operations depending whether this comparison passes or fails.
-		 */
-		CompareFunction getStencilFrontCompFunc() const { return mData.frontStencilComparisonFunc; }
-
-		/**
-		* @brief	Operation that happens when stencil comparison function fails on a back facing polygon.
-		*/
-		StencilOperation getStencilBackFailOp() const { return mData.backStencilFailOp; }
-
-		/**
-		* @brief	Operation that happens when stencil comparison function passes but depth test fails
-		*			on a back facing polygon.
-		*/
-		StencilOperation getStencilBackZFailOp() const { return mData.backStencilZFailOp; }
-
-		/**
-		* @brief	Operation that happens when stencil comparison function passes on a back facing polygon.
-		*/
-		StencilOperation getStencilBackPassOp() const { return mData.backStencilPassOp; }
-
-		/**
-		* @brief	Stencil comparison function used for back facing polygons. Stencil buffer will be modified according
-		*			to previously set stencil operations depending whether this comparison passes or fails.
-		*/
-		CompareFunction getStencilBackCompFunc() const { return mData.backStencilComparisonFunc; }
-
-		/**
-		 * @brief	Creates a new depth stencil state using the specified depth stencil state description structure.
-		 */
-		static HDepthStencilState create(const DEPTH_STENCIL_STATE_DESC& desc);
-
-		/**
-		 * @brief	Returns the default depth stencil state that you may use when no other is available.
-		 */
-		static const DepthStencilStatePtr& getDefault();
-	protected:
-		friend class RenderStateManager;
-
-		virtual void initialize(const DEPTH_STENCIL_STATE_DESC& desc);
-
-		DEPTH_STENCIL_STATE_DESC mData;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class DepthStencilStateRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmResource.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Descriptor structured used for initializing DepthStencilState.
+	 *
+	 * @see		DepthStencilState
+	 */
+	struct BS_CORE_EXPORT DEPTH_STENCIL_STATE_DESC
+	{
+		DEPTH_STENCIL_STATE_DESC()
+			: depthReadEnable(true)
+			, depthWriteEnable(true)
+			, depthComparisonFunc(CMPF_LESS)
+			, stencilEnable(false)
+			, stencilReadMask(0xFF)
+			, stencilWriteMask(0xFF)
+			, frontStencilFailOp(SOP_KEEP)
+			, frontStencilZFailOp(SOP_KEEP)
+			, frontStencilPassOp(SOP_KEEP)
+			, frontStencilComparisonFunc(CMPF_ALWAYS_PASS)
+			, backStencilFailOp(SOP_KEEP)
+			, backStencilZFailOp(SOP_KEEP)
+			, backStencilPassOp(SOP_KEEP)
+			, backStencilComparisonFunc(CMPF_ALWAYS_PASS)
+		{ }
+
+		bool depthReadEnable;
+		bool depthWriteEnable;
+		CompareFunction depthComparisonFunc;
+
+		bool stencilEnable;
+		UINT8 stencilReadMask;
+		UINT8 stencilWriteMask;
+
+		StencilOperation frontStencilFailOp;
+		StencilOperation frontStencilZFailOp;
+		StencilOperation frontStencilPassOp;
+		CompareFunction frontStencilComparisonFunc;
+
+		StencilOperation backStencilFailOp;
+		StencilOperation backStencilZFailOp;
+		StencilOperation backStencilPassOp;
+		CompareFunction backStencilComparisonFunc;
+	};
+
+	CM_ALLOW_MEMCPY_SERIALIZATION(DEPTH_STENCIL_STATE_DESC);
+
+	/**
+	* @brief	Render system pipeline state that allows you to modify how an object is rendered.
+	* 			More exactly this state allows to you to control how are depth and stencil buffers
+	*			modified upon rendering.
+	*
+	* @note		Depth stencil states are immutable. Thread safe.
+	*/
+	class BS_CORE_EXPORT DepthStencilState : public Resource
+	{
+	public:
+		virtual ~DepthStencilState() {}
+
+		/**
+		 * @brief	If enabled, any pixel about to be written will be tested against the depth value
+		 *			currently in the buffer. If the depth test passes (depending on the set value
+		 *			and chosen depth comparison function), that pixel is written and depth is
+		 *			updated (if depth write is enabled).
+		 */
+		bool getDepthReadEnable() const { return mData.depthReadEnable; }
+
+		/**
+		 * @brief	If enabled rendering pixels will update the depth buffer value. 
+		 */
+		bool getDepthWriteEnable() const { return mData.depthWriteEnable; }
+
+		/**
+		 * @brief	Determines what operation should the renderer use when comparing previous and 
+		 *			current depth value. If the operation passes, pixel with the current depth
+		 *			value will be considered visible.
+		 */
+		CompareFunction getDepthComparisonFunc() const { return mData.depthComparisonFunc; }
+
+		/**
+		 * @brief	If true then stencil buffer will also be updated when a pixel is written, and
+		 *			pixels will be tested against the stencil buffer before rendering.
+		 */
+		bool getStencilEnable() const { return mData.stencilEnable; }
+
+		/**
+		 * @brief	Mask to apply to any value read from the stencil buffer, before applying the
+		 *			stencil comparison function.
+		 */
+		UINT8 getStencilReadMask() const { return mData.stencilReadMask; }
+
+		/**
+		 * @brief	Mask to apply to any value about to be written in the stencil buffer.
+		 */
+		UINT8 getStencilWriteMask() const { return mData.stencilWriteMask; }
+
+		/**
+		 * @brief	Operation that happens when stencil comparison function fails on a front facing polygon.
+		 */
+		StencilOperation getStencilFrontFailOp() const { return mData.frontStencilFailOp; }
+
+		/**
+		* @brief	Operation that happens when stencil comparison function passes but depth test fails
+		*			on a front facing polygon.
+		*/
+		StencilOperation getStencilFrontZFailOp() const { return mData.frontStencilZFailOp; }
+
+		/**
+		* @brief	Operation that happens when stencil comparison function passes on a front facing polygon.
+		*/
+		StencilOperation getStencilFrontPassOp() const { return mData.frontStencilPassOp; }
+
+		/**
+		 * @brief	Stencil comparison function used for front facing polygons. Stencil buffer will be modified according
+		 *			to previously set stencil operations depending whether this comparison passes or fails.
+		 */
+		CompareFunction getStencilFrontCompFunc() const { return mData.frontStencilComparisonFunc; }
+
+		/**
+		* @brief	Operation that happens when stencil comparison function fails on a back facing polygon.
+		*/
+		StencilOperation getStencilBackFailOp() const { return mData.backStencilFailOp; }
+
+		/**
+		* @brief	Operation that happens when stencil comparison function passes but depth test fails
+		*			on a back facing polygon.
+		*/
+		StencilOperation getStencilBackZFailOp() const { return mData.backStencilZFailOp; }
+
+		/**
+		* @brief	Operation that happens when stencil comparison function passes on a back facing polygon.
+		*/
+		StencilOperation getStencilBackPassOp() const { return mData.backStencilPassOp; }
+
+		/**
+		* @brief	Stencil comparison function used for back facing polygons. Stencil buffer will be modified according
+		*			to previously set stencil operations depending whether this comparison passes or fails.
+		*/
+		CompareFunction getStencilBackCompFunc() const { return mData.backStencilComparisonFunc; }
+
+		/**
+		 * @brief	Creates a new depth stencil state using the specified depth stencil state description structure.
+		 */
+		static HDepthStencilState create(const DEPTH_STENCIL_STATE_DESC& desc);
+
+		/**
+		 * @brief	Returns the default depth stencil state that you may use when no other is available.
+		 */
+		static const DepthStencilStatePtr& getDefault();
+	protected:
+		friend class RenderStateManager;
+
+		virtual void initialize(const DEPTH_STENCIL_STATE_DESC& desc);
+
+		DEPTH_STENCIL_STATE_DESC mData;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class DepthStencilStateRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
 }

+ 51 - 51
CamelotCore/Include/CmDepthStencilStateRTTI.h → BansheeCore/Include/CmDepthStencilStateRTTI.h

@@ -1,52 +1,52 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmDepthStencilState.h"
-#include "CmRenderStateManager.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT DepthStencilStateRTTI : public RTTIType<DepthStencilState, IReflectable, DepthStencilStateRTTI>
-	{
-	private:
-		DEPTH_STENCIL_STATE_DESC& getData(DepthStencilState* obj) { return obj->mData; }
-		void setData(DepthStencilState* obj, DEPTH_STENCIL_STATE_DESC& val) 
-		{ 
-			obj->mRTTIData = val;
-		} 
-
-	public:
-		DepthStencilStateRTTI()
-		{
-			addPlainField("mData", 0, &DepthStencilStateRTTI::getData, &DepthStencilStateRTTI::setData);
-		}
-
-		virtual void onDeserializationEnded(IReflectable* obj)
-		{
-			DepthStencilState* depthStencilState = static_cast<DepthStencilState*>(obj);
-			if(!depthStencilState->mRTTIData.empty())
-			{
-				DEPTH_STENCIL_STATE_DESC desc = any_cast<DEPTH_STENCIL_STATE_DESC>(depthStencilState->mRTTIData);
-
-				depthStencilState->initialize(desc);
-			}
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "DepthStencilState";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_DepthStencilState;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return RenderStateManager::instance().createEmptyDepthStencilState();
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmDepthStencilState.h"
+#include "CmRenderStateManager.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT DepthStencilStateRTTI : public RTTIType<DepthStencilState, IReflectable, DepthStencilStateRTTI>
+	{
+	private:
+		DEPTH_STENCIL_STATE_DESC& getData(DepthStencilState* obj) { return obj->mData; }
+		void setData(DepthStencilState* obj, DEPTH_STENCIL_STATE_DESC& val) 
+		{ 
+			obj->mRTTIData = val;
+		} 
+
+	public:
+		DepthStencilStateRTTI()
+		{
+			addPlainField("mData", 0, &DepthStencilStateRTTI::getData, &DepthStencilStateRTTI::setData);
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj)
+		{
+			DepthStencilState* depthStencilState = static_cast<DepthStencilState*>(obj);
+			if(!depthStencilState->mRTTIData.empty())
+			{
+				DEPTH_STENCIL_STATE_DESC desc = any_cast<DEPTH_STENCIL_STATE_DESC>(depthStencilState->mRTTIData);
+
+				depthStencilState->initialize(desc);
+			}
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "DepthStencilState";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_DepthStencilState;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return RenderStateManager::instance().createEmptyDepthStencilState();
+		}
+	};
 }

+ 25 - 25
CamelotCore/Include/CmDrawOps.h → BansheeCore/Include/CmDrawOps.h

@@ -1,26 +1,26 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Describes operation that will be used for rendering a certain
-	 *			set of vertices.
-	 */
-	enum DrawOperationType 
-	{
-		DOT_POINT_LIST = 1,
-		DOT_LINE_LIST = 2,
-		DOT_LINE_STRIP = 3,
-		DOT_TRIANGLE_LIST = 4,
-		DOT_TRIANGLE_STRIP = 5,
-		DOT_TRIANGLE_FAN = 6
-	};
-
-	/**
-	* @brief	Converts the number of vertices to number of primitives
-	* 			based on the specified draw operation.
-	*/
-	UINT32 CM_EXPORT vertexCountToPrimCount(DrawOperationType type, UINT32 elementCount);
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Describes operation that will be used for rendering a certain
+	 *			set of vertices.
+	 */
+	enum DrawOperationType 
+	{
+		DOT_POINT_LIST = 1,
+		DOT_LINE_LIST = 2,
+		DOT_LINE_STRIP = 3,
+		DOT_TRIANGLE_LIST = 4,
+		DOT_TRIANGLE_STRIP = 5,
+		DOT_TRIANGLE_FAN = 6
+	};
+
+	/**
+	* @brief	Converts the number of vertices to number of primitives
+	* 			based on the specified draw operation.
+	*/
+	UINT32 BS_CORE_EXPORT vertexCountToPrimCount(DrawOperationType type, UINT32 elementCount);
 }

+ 57 - 57
CamelotCore/Include/CmEventQuery.h → BansheeCore/Include/CmEventQuery.h

@@ -1,58 +1,58 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Represents a GPU query that gets triggered when GPU starts processing the query.
-	 * 			
-	 * @note	Normally GPU will have many commands in its command buffer. When EventQuery::begin is called it is placed
-	 * 			in that command buffer. Once the buffer empties and GPU reaches the EventQuery command, the query
-	 * 			callback is triggered.
-	 * 			
-	 *			Core thread only.
-	 */
-	class CM_EXPORT EventQuery
-	{
-	public:
-		EventQuery()
-			:mActive(false) {}
-		virtual ~EventQuery() {}
-
-		/**
-		 * @brief	Starts the query. 
-		 * 			
-		 * @note	Once the query is started you may poll "isReady" method to check when query has finished,
-		 * 			or you may hook up an "onTriggered" callback and be notified that way.
-		 */
-		virtual void begin() = 0;
-
-		/**
-		 * @brief	Check if GPU has processed the query.
-		 */
-		virtual bool isReady() const = 0;
-
-		/**
-		 * @brief	Triggered when GPU starts processing the query.
-		 */
-		Event<void()> onTriggered;
-
-		/**
-		 * @brief	Creates a new query, but does not schedule it on GPU.
-		 */
-		static EventQueryPtr create();
-
-	protected:
-		friend class QueryManager;
-
-		/**
-		 * @brief	Returns true if the has still not been completed by the GPU.
-		 */
-		bool isActive() const { return mActive; }
-		void setActive(bool active) { mActive = active; }
-
-	protected:
-		bool mActive;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Represents a GPU query that gets triggered when GPU starts processing the query.
+	 * 			
+	 * @note	Normally GPU will have many commands in its command buffer. When EventQuery::begin is called it is placed
+	 * 			in that command buffer. Once the buffer empties and GPU reaches the EventQuery command, the query
+	 * 			callback is triggered.
+	 * 			
+	 *			Core thread only.
+	 */
+	class BS_CORE_EXPORT EventQuery
+	{
+	public:
+		EventQuery()
+			:mActive(false) {}
+		virtual ~EventQuery() {}
+
+		/**
+		 * @brief	Starts the query. 
+		 * 			
+		 * @note	Once the query is started you may poll "isReady" method to check when query has finished,
+		 * 			or you may hook up an "onTriggered" callback and be notified that way.
+		 */
+		virtual void begin() = 0;
+
+		/**
+		 * @brief	Check if GPU has processed the query.
+		 */
+		virtual bool isReady() const = 0;
+
+		/**
+		 * @brief	Triggered when GPU starts processing the query.
+		 */
+		Event<void()> onTriggered;
+
+		/**
+		 * @brief	Creates a new query, but does not schedule it on GPU.
+		 */
+		static EventQueryPtr create();
+
+	protected:
+		friend class QueryManager;
+
+		/**
+		 * @brief	Returns true if the has still not been completed by the GPU.
+		 */
+		bool isActive() const { return mActive; }
+		void setActive(bool active) { mActive = active; }
+
+	protected:
+		bool mActive;
+	};
 }

+ 6 - 6
CamelotCore/Include/CmFolderMonitor.h → BansheeCore/Include/CmFolderMonitor.h

@@ -1,7 +1,7 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-#if CM_PLATFORM == CM_PLATFORM_WIN32
-#include "Win32/CmWin32FolderMonitor.h"
+#pragma once
+
+#include "CmPrerequisites.h"
+
+#if CM_PLATFORM == CM_PLATFORM_WIN32
+#include "Win32/CmWin32FolderMonitor.h"
 #endif

+ 97 - 97
CamelotCore/Include/CmFont.h → BansheeCore/Include/CmFont.h

@@ -1,98 +1,98 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmResource.h"
-#include "CmFontDesc.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains data about font characters of a specific size. Contains
-	 *			textures in which the characters are located and information
-	 *			about each individual character.
-	 */
-	struct CM_EXPORT FontData : public IReflectable
-	{
-		/**
-		 * @brief	Returns a character description for the character with the specified ID.
-		 */
-		const CHAR_DESC& getCharDesc(UINT32 charId) const;
-
-		UINT32 size; /**< Font size for which the data is contained. */
-		FONT_DESC fontDesc; /**< Font description containing per-character and general font data. */
-		Vector<HTexture> texturePages; /**< Textures in which the characters are stored. */
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class FontDataRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
-
-	// TODO - When saved on disk font currently stores a copy of the texture pages. This should be acceptable
-	// if you import a new TrueType or OpenType font since the texture will be generated on the spot
-	// but if you use a bitmap texture to initialize the font manually, then you will potentially have duplicate textures.
-	// Also, changing the source texture will not automatically update the font because there is no direct link between them.
-	// -- This is probably not a large problem, but it is something to keep an eye out.
-
-	/**
-	 * @brief	Font resource containing data about textual characters
-	 *			and how to render text.
-	 */
-	class CM_EXPORT Font : public Resource
-	{
-	public:
-		virtual ~Font();
-
-		/**
-		 * @brief	Initializes the font with specified per-size font data.
-		 *
-		 * @note	Internal method. Factory methods will call this automatically for you.
-		 */
-		void initialize(const Vector<FontData>& fontData);
-
-		/**
-		 * @brief	Returns font data for a specific size if it exists, null otherwise.
-		 */
-		const FontData* getFontDataForSize(UINT32 size) const;
-
-		/**
-		 * @brief	Attempts to find nearest available size next to the provided size.
-		 */
-		INT32 getClosestAvailableSize(UINT32 size) const;
-
-		/************************************************************************/
-		/* 								STATICS		                     		*/
-		/************************************************************************/
-
-		/**
-		 * @brief	Creates a new font from the provided per-size font data.
-		 */
-		static HFont create(const Vector<FontData>& fontInitData);
-
-		/**
-		 * @brief	Creates a new font pointer.
-		 *
-		 * @note	Internal method.
-		 */
-		static FontPtr _createPtr(const Vector<FontData>& fontInitData);
-
-	protected:
-		friend class FontManager;
-
-		Font();
-
-	private:
-		Map<UINT32, FontData> mFontDataPerSize;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class FontRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmResource.h"
+#include "CmFontDesc.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Contains data about font characters of a specific size. Contains
+	 *			textures in which the characters are located and information
+	 *			about each individual character.
+	 */
+	struct BS_CORE_EXPORT FontData : public IReflectable
+	{
+		/**
+		 * @brief	Returns a character description for the character with the specified ID.
+		 */
+		const CHAR_DESC& getCharDesc(UINT32 charId) const;
+
+		UINT32 size; /**< Font size for which the data is contained. */
+		FONT_DESC fontDesc; /**< Font description containing per-character and general font data. */
+		Vector<HTexture> texturePages; /**< Textures in which the characters are stored. */
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class FontDataRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
+
+	// TODO - When saved on disk font currently stores a copy of the texture pages. This should be acceptable
+	// if you import a new TrueType or OpenType font since the texture will be generated on the spot
+	// but if you use a bitmap texture to initialize the font manually, then you will potentially have duplicate textures.
+	// Also, changing the source texture will not automatically update the font because there is no direct link between them.
+	// -- This is probably not a large problem, but it is something to keep an eye out.
+
+	/**
+	 * @brief	Font resource containing data about textual characters
+	 *			and how to render text.
+	 */
+	class BS_CORE_EXPORT Font : public Resource
+	{
+	public:
+		virtual ~Font();
+
+		/**
+		 * @brief	Initializes the font with specified per-size font data.
+		 *
+		 * @note	Internal method. Factory methods will call this automatically for you.
+		 */
+		void initialize(const Vector<FontData>& fontData);
+
+		/**
+		 * @brief	Returns font data for a specific size if it exists, null otherwise.
+		 */
+		const FontData* getFontDataForSize(UINT32 size) const;
+
+		/**
+		 * @brief	Attempts to find nearest available size next to the provided size.
+		 */
+		INT32 getClosestAvailableSize(UINT32 size) const;
+
+		/************************************************************************/
+		/* 								STATICS		                     		*/
+		/************************************************************************/
+
+		/**
+		 * @brief	Creates a new font from the provided per-size font data.
+		 */
+		static HFont create(const Vector<FontData>& fontInitData);
+
+		/**
+		 * @brief	Creates a new font pointer.
+		 *
+		 * @note	Internal method.
+		 */
+		static FontPtr _createPtr(const Vector<FontData>& fontInitData);
+
+	protected:
+		friend class FontManager;
+
+		Font();
+
+	private:
+		Map<UINT32, FontData> mFontDataPerSize;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class FontRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
 }

+ 162 - 162
CamelotCore/Include/CmFontDesc.h → BansheeCore/Include/CmFontDesc.h

@@ -1,163 +1,163 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Kerning pair representing extra or less offset between
-	 *			a specific pair of characters.
-	 */
-	struct KerningPair
-	{
-		UINT32 otherCharId;
-		INT32 amount;
-	};
-
-	/**
-	 * @brief	Describes a single character in a font.
-	 */
-	struct CHAR_DESC
-	{
-		UINT32 charId; /**< Character ID, corresponding to a Unicode key. */
-		UINT32 page; /**< Index of the texture the character is located on. */
-		float uvX, uvY; /**< Texture coordinates of the character in the page texture. */
-		float uvWidth, uvHeight; /**< Width/height of the character in texture coordinates. */
-		UINT32 width, height; /**< Width/height of the character in pixels. */
-		INT32 xOffset, yOffset; /**< Determines offset for the visible portion of the character in pixels. */
-		INT32 xAdvance, yAdvance; /**< Determines how much to advance the pen after writing this character. In pixels. */
-
-		Vector<KerningPair> kerningPairs; /**< Pairs that determine if certain character pairs should be closer or father together. e.g. "AV" combination */
-	};
-
-	/**
-	 * @brief	Describes a font.
-	 */
-	struct FONT_DESC
-	{
-		Map<UINT32, CHAR_DESC> characters; /**< All characters in the font referenced by character ID. */
-		INT32 baselineOffset; /**< Y offset to the baseline on which the characters are placed. In pixels. */
-		UINT32 lineHeight; /**< Height of a single line of the font. In pixels. */
-		CHAR_DESC missingGlyph; /**< Character index to use when data for a character is missing. */
-		UINT32 spaceWidth; /**< Determines width of the space in pixels. */
-	};
-
-	// Make CHAR_DESC serializable
-	template<> struct RTTIPlainType<CHAR_DESC>
-	{	
-		enum { id = TID_CHAR_DESC }; enum { hasDynamicSize = 1 };
-
-		static void toMemory(const CHAR_DESC& data, char* memory)
-		{ 
-			UINT32 size = getDynamicSize(data);
-
-			memcpy(memory, &size, sizeof(UINT32));
-			memory += sizeof(UINT32);
-
-			memory = rttiWriteElem(data.charId, memory);
-			memory = rttiWriteElem(data.page, memory);
-			memory = rttiWriteElem(data.uvX, memory);
-			memory = rttiWriteElem(data.uvY, memory);
-			memory = rttiWriteElem(data.uvWidth, memory);
-			memory = rttiWriteElem(data.uvHeight, memory);
-			memory = rttiWriteElem(data.width, memory);
-			memory = rttiWriteElem(data.height, memory);
-			memory = rttiWriteElem(data.xOffset, memory);
-			memory = rttiWriteElem(data.yOffset, memory);
-			memory = rttiWriteElem(data.xAdvance, memory);
-			memory = rttiWriteElem(data.yAdvance, memory);
-			memory = rttiWriteElem(data.kerningPairs, memory);
-		}
-
-		static UINT32 fromMemory(CHAR_DESC& data, char* memory)
-		{ 
-			UINT32 size;
-			memcpy(&size, memory, sizeof(UINT32)); 
-			memory += sizeof(UINT32);
-
-			memory = rttiReadElem(data.charId, memory);
-			memory = rttiReadElem(data.page, memory);
-			memory = rttiReadElem(data.uvX, memory);
-			memory = rttiReadElem(data.uvY, memory);
-			memory = rttiReadElem(data.uvWidth, memory);
-			memory = rttiReadElem(data.uvHeight, memory);
-			memory = rttiReadElem(data.width, memory);
-			memory = rttiReadElem(data.height, memory);
-			memory = rttiReadElem(data.xOffset, memory);
-			memory = rttiReadElem(data.yOffset, memory);
-			memory = rttiReadElem(data.xAdvance, memory);
-			memory = rttiReadElem(data.yAdvance, memory);
-			memory = rttiReadElem(data.kerningPairs, memory);
-
-			return size;
-		}
-
-		static UINT32 getDynamicSize(const CHAR_DESC& data)	
-		{ 
-			UINT64 dataSize = sizeof(data.charId)
-				+ sizeof(data.page)
-				+ sizeof(data.uvX)
-				+ sizeof(data.uvY)
-				+ sizeof(data.uvWidth)
-				+ sizeof(data.uvHeight)
-				+ sizeof(data.width)
-				+ sizeof(data.height)
-				+ sizeof(data.xOffset)
-				+ sizeof(data.yOffset)
-				+ sizeof(data.xAdvance)
-				+ sizeof(data.yAdvance)
-				+ RTTIPlainType<Vector<KerningPair>>::getDynamicSize(data.kerningPairs);
-
-			dataSize += sizeof(UINT32);
-
-			return (UINT32)dataSize;
-		}	
-	}; 
-
-	// Make FONT_DESC serializable
-	template<> struct RTTIPlainType<FONT_DESC>
-	{	
-		enum { id = TID_FONT_DESC }; enum { hasDynamicSize = 1 };
-
-		static void toMemory(const FONT_DESC& data, char* memory)
-		{ 
-			UINT32 size = getDynamicSize(data);
-
-			memcpy(memory, &size, sizeof(UINT32));
-			memory += sizeof(UINT32);
-			
-			RTTIPlainType<Map<UINT32, CHAR_DESC>>::toMemory(data.characters, memory);
-			rttiWriteElem(data.baselineOffset, memory);
-			rttiWriteElem(data.lineHeight, memory);
-			rttiWriteElem(data.missingGlyph, memory);
-			rttiWriteElem(data.spaceWidth, memory);
-		}
-
-		static UINT32 fromMemory(FONT_DESC& data, char* memory)
-		{ 
-			UINT32 size;
-			memcpy(&size, memory, sizeof(UINT32)); 
-			memory += sizeof(UINT32);
-
-			RTTIPlainType<Map<UINT32, CHAR_DESC>>::fromMemory(data.characters, memory);
-			rttiReadElem(data.baselineOffset, memory);
-			rttiReadElem(data.lineHeight, memory);
-			rttiReadElem(data.missingGlyph, memory);
-			rttiReadElem(data.spaceWidth, memory);
-
-			return size;
-		}
-
-		static UINT32 getDynamicSize(const FONT_DESC& data)	
-		{ 
-			UINT64 dataSize = sizeof(UINT32);
-			dataSize += RTTIPlainType<Map<UINT32, CHAR_DESC>>::getDynamicSize(data.characters);
-			dataSize += rttiGetElemSize(data.baselineOffset);
-			dataSize += rttiGetElemSize(data.lineHeight);
-			dataSize += rttiGetElemSize(data.missingGlyph);
-			dataSize += rttiGetElemSize(data.spaceWidth);
-
-			return (UINT32)dataSize;
-		}	
-	}; 
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Kerning pair representing extra or less offset between
+	 *			a specific pair of characters.
+	 */
+	struct KerningPair
+	{
+		UINT32 otherCharId;
+		INT32 amount;
+	};
+
+	/**
+	 * @brief	Describes a single character in a font.
+	 */
+	struct CHAR_DESC
+	{
+		UINT32 charId; /**< Character ID, corresponding to a Unicode key. */
+		UINT32 page; /**< Index of the texture the character is located on. */
+		float uvX, uvY; /**< Texture coordinates of the character in the page texture. */
+		float uvWidth, uvHeight; /**< Width/height of the character in texture coordinates. */
+		UINT32 width, height; /**< Width/height of the character in pixels. */
+		INT32 xOffset, yOffset; /**< Determines offset for the visible portion of the character in pixels. */
+		INT32 xAdvance, yAdvance; /**< Determines how much to advance the pen after writing this character. In pixels. */
+
+		Vector<KerningPair> kerningPairs; /**< Pairs that determine if certain character pairs should be closer or father together. e.g. "AV" combination */
+	};
+
+	/**
+	 * @brief	Describes a font.
+	 */
+	struct FONT_DESC
+	{
+		Map<UINT32, CHAR_DESC> characters; /**< All characters in the font referenced by character ID. */
+		INT32 baselineOffset; /**< Y offset to the baseline on which the characters are placed. In pixels. */
+		UINT32 lineHeight; /**< Height of a single line of the font. In pixels. */
+		CHAR_DESC missingGlyph; /**< Character index to use when data for a character is missing. */
+		UINT32 spaceWidth; /**< Determines width of the space in pixels. */
+	};
+
+	// Make CHAR_DESC serializable
+	template<> struct RTTIPlainType<CHAR_DESC>
+	{	
+		enum { id = TID_CHAR_DESC }; enum { hasDynamicSize = 1 };
+
+		static void toMemory(const CHAR_DESC& data, char* memory)
+		{ 
+			UINT32 size = getDynamicSize(data);
+
+			memcpy(memory, &size, sizeof(UINT32));
+			memory += sizeof(UINT32);
+
+			memory = rttiWriteElem(data.charId, memory);
+			memory = rttiWriteElem(data.page, memory);
+			memory = rttiWriteElem(data.uvX, memory);
+			memory = rttiWriteElem(data.uvY, memory);
+			memory = rttiWriteElem(data.uvWidth, memory);
+			memory = rttiWriteElem(data.uvHeight, memory);
+			memory = rttiWriteElem(data.width, memory);
+			memory = rttiWriteElem(data.height, memory);
+			memory = rttiWriteElem(data.xOffset, memory);
+			memory = rttiWriteElem(data.yOffset, memory);
+			memory = rttiWriteElem(data.xAdvance, memory);
+			memory = rttiWriteElem(data.yAdvance, memory);
+			memory = rttiWriteElem(data.kerningPairs, memory);
+		}
+
+		static UINT32 fromMemory(CHAR_DESC& data, char* memory)
+		{ 
+			UINT32 size;
+			memcpy(&size, memory, sizeof(UINT32)); 
+			memory += sizeof(UINT32);
+
+			memory = rttiReadElem(data.charId, memory);
+			memory = rttiReadElem(data.page, memory);
+			memory = rttiReadElem(data.uvX, memory);
+			memory = rttiReadElem(data.uvY, memory);
+			memory = rttiReadElem(data.uvWidth, memory);
+			memory = rttiReadElem(data.uvHeight, memory);
+			memory = rttiReadElem(data.width, memory);
+			memory = rttiReadElem(data.height, memory);
+			memory = rttiReadElem(data.xOffset, memory);
+			memory = rttiReadElem(data.yOffset, memory);
+			memory = rttiReadElem(data.xAdvance, memory);
+			memory = rttiReadElem(data.yAdvance, memory);
+			memory = rttiReadElem(data.kerningPairs, memory);
+
+			return size;
+		}
+
+		static UINT32 getDynamicSize(const CHAR_DESC& data)	
+		{ 
+			UINT64 dataSize = sizeof(data.charId)
+				+ sizeof(data.page)
+				+ sizeof(data.uvX)
+				+ sizeof(data.uvY)
+				+ sizeof(data.uvWidth)
+				+ sizeof(data.uvHeight)
+				+ sizeof(data.width)
+				+ sizeof(data.height)
+				+ sizeof(data.xOffset)
+				+ sizeof(data.yOffset)
+				+ sizeof(data.xAdvance)
+				+ sizeof(data.yAdvance)
+				+ RTTIPlainType<Vector<KerningPair>>::getDynamicSize(data.kerningPairs);
+
+			dataSize += sizeof(UINT32);
+
+			return (UINT32)dataSize;
+		}	
+	}; 
+
+	// Make FONT_DESC serializable
+	template<> struct RTTIPlainType<FONT_DESC>
+	{	
+		enum { id = TID_FONT_DESC }; enum { hasDynamicSize = 1 };
+
+		static void toMemory(const FONT_DESC& data, char* memory)
+		{ 
+			UINT32 size = getDynamicSize(data);
+
+			memcpy(memory, &size, sizeof(UINT32));
+			memory += sizeof(UINT32);
+			
+			RTTIPlainType<Map<UINT32, CHAR_DESC>>::toMemory(data.characters, memory);
+			rttiWriteElem(data.baselineOffset, memory);
+			rttiWriteElem(data.lineHeight, memory);
+			rttiWriteElem(data.missingGlyph, memory);
+			rttiWriteElem(data.spaceWidth, memory);
+		}
+
+		static UINT32 fromMemory(FONT_DESC& data, char* memory)
+		{ 
+			UINT32 size;
+			memcpy(&size, memory, sizeof(UINT32)); 
+			memory += sizeof(UINT32);
+
+			RTTIPlainType<Map<UINT32, CHAR_DESC>>::fromMemory(data.characters, memory);
+			rttiReadElem(data.baselineOffset, memory);
+			rttiReadElem(data.lineHeight, memory);
+			rttiReadElem(data.missingGlyph, memory);
+			rttiReadElem(data.spaceWidth, memory);
+
+			return size;
+		}
+
+		static UINT32 getDynamicSize(const FONT_DESC& data)	
+		{ 
+			UINT64 dataSize = sizeof(UINT32);
+			dataSize += RTTIPlainType<Map<UINT32, CHAR_DESC>>::getDynamicSize(data.characters);
+			dataSize += rttiGetElemSize(data.baselineOffset);
+			dataSize += rttiGetElemSize(data.lineHeight);
+			dataSize += rttiGetElemSize(data.missingGlyph);
+			dataSize += rttiGetElemSize(data.spaceWidth);
+
+			return (UINT32)dataSize;
+		}	
+	}; 
 }

+ 76 - 76
CamelotCore/Include/CmFontImportOptions.h → BansheeCore/Include/CmFontImportOptions.h

@@ -1,77 +1,77 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmImportOptions.h"
-#include "CmFont.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Import options that allow you to control how is a font
-	 *			imported.
-	 */
-	class CM_EXPORT FontImportOptions : public ImportOptions
-	{
-	public:
-		FontImportOptions();
-
-		/**
-		 * @brief	Sets font sizes you wish to import. Sizes are in points.
-		 */
-		void setFontSizes(const Vector<UINT32>& fontSizes) { mFontSizes = fontSizes; }
-
-		/**
-		 * @brief	Adds an index range of characters to import. 
-		 */
-		void addCharIndexRange(UINT32 from, UINT32 to);
-
-		/**
-		 * @brief	Clears all character indexes, so no character are imported.
-		 */
-		void clearCharIndexRanges();
-
-		/**
-		 * @brief	Sets dots per inch scale to use when rendering the characters into the texture.
-		 */
-		void setDPI(UINT32 dpi) { mDPI = dpi; }
-
-		/**
-		 * @brief	Set to true if you want your characters to be antialiased.
-		 */
-		void setAntialiasing(bool enabled) { mAntialiasing = enabled; }
-
-		/**
-		 * @brief	Gets the sizes that are to be imported.
-		 */
-		Vector<UINT32> getFontSizes() const { return mFontSizes; }
-
-		/**
-		 * @brief	Gets character index ranges to import.
-		 */
-		Vector<std::pair<UINT32, UINT32>> getCharIndexRanges() const { return mCharIndexRanges; }
-
-		/**
-		 * @brief	Returns dots per inch scale that will be used when rendering the characters.
-		 */
-		UINT32 getDPI() const { return mDPI; }
-
-		/**
-		 * @brief	Query if antialiasing will be used when rendering the characters.
-		 */
-		bool getAntialiasing() const { return mAntialiasing; }
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class FontImportOptionsRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-
-	private:
-		Vector<UINT32> mFontSizes;
-		Vector<std::pair<UINT32, UINT32>> mCharIndexRanges;
-		UINT32 mDPI;
-		bool mAntialiasing;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmImportOptions.h"
+#include "CmFont.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Import options that allow you to control how is a font
+	 *			imported.
+	 */
+	class BS_CORE_EXPORT FontImportOptions : public ImportOptions
+	{
+	public:
+		FontImportOptions();
+
+		/**
+		 * @brief	Sets font sizes you wish to import. Sizes are in points.
+		 */
+		void setFontSizes(const Vector<UINT32>& fontSizes) { mFontSizes = fontSizes; }
+
+		/**
+		 * @brief	Adds an index range of characters to import. 
+		 */
+		void addCharIndexRange(UINT32 from, UINT32 to);
+
+		/**
+		 * @brief	Clears all character indexes, so no character are imported.
+		 */
+		void clearCharIndexRanges();
+
+		/**
+		 * @brief	Sets dots per inch scale to use when rendering the characters into the texture.
+		 */
+		void setDPI(UINT32 dpi) { mDPI = dpi; }
+
+		/**
+		 * @brief	Set to true if you want your characters to be antialiased.
+		 */
+		void setAntialiasing(bool enabled) { mAntialiasing = enabled; }
+
+		/**
+		 * @brief	Gets the sizes that are to be imported.
+		 */
+		Vector<UINT32> getFontSizes() const { return mFontSizes; }
+
+		/**
+		 * @brief	Gets character index ranges to import.
+		 */
+		Vector<std::pair<UINT32, UINT32>> getCharIndexRanges() const { return mCharIndexRanges; }
+
+		/**
+		 * @brief	Returns dots per inch scale that will be used when rendering the characters.
+		 */
+		UINT32 getDPI() const { return mDPI; }
+
+		/**
+		 * @brief	Query if antialiasing will be used when rendering the characters.
+		 */
+		bool getAntialiasing() const { return mAntialiasing; }
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class FontImportOptionsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+
+	private:
+		Vector<UINT32> mFontSizes;
+		Vector<std::pair<UINT32, UINT32>> mCharIndexRanges;
+		UINT32 mDPI;
+		bool mAntialiasing;
+	};
 }

+ 48 - 48
CamelotCore/Include/CmFontImportOptionsRTTI.h → BansheeCore/Include/CmFontImportOptionsRTTI.h

@@ -1,49 +1,49 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmFontImportOptions.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT FontImportOptionsRTTI : public RTTIType<FontImportOptions, IReflectable, FontImportOptionsRTTI>
-	{
-	private:
-		Vector<UINT32>& getFontSizes(FontImportOptions* obj) { return obj->mFontSizes; }
-		void setFontSizes(FontImportOptions* obj, Vector<UINT32>& value) { obj->mFontSizes = value; }
-
-		Vector<std::pair<UINT32, UINT32>>& getCharIndexRanges(FontImportOptions* obj) { return obj->mCharIndexRanges; }
-		void setCharIndexRanges(FontImportOptions* obj, Vector<std::pair<UINT32, UINT32>>& value) { obj->mCharIndexRanges = value; }
-
-		UINT32& getDPI(FontImportOptions* obj) { return obj->mDPI; }
-		void setDPI(FontImportOptions* obj, UINT32& value) { obj->mDPI = value; }
-
-		bool& getAntialiasing(FontImportOptions* obj) { return obj->mAntialiasing; }
-		void setAntialiasing(FontImportOptions* obj, bool& value) { obj->mAntialiasing = value; }
-
-	public:
-		FontImportOptionsRTTI()
-		{
-			addPlainField("mFontSizes", 0, &FontImportOptionsRTTI::getFontSizes, &FontImportOptionsRTTI::setFontSizes);
-			addPlainField("mCharIndexRanges", 1, &FontImportOptionsRTTI::getCharIndexRanges, &FontImportOptionsRTTI::setCharIndexRanges);
-			addPlainField("mDPI", 2, &FontImportOptionsRTTI::getDPI, &FontImportOptionsRTTI::setDPI);
-			addPlainField("mAntialiasing", 3, &FontImportOptionsRTTI::getAntialiasing, &FontImportOptionsRTTI::setAntialiasing);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "FontImportOptions";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_FontImportOptions;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return cm_shared_ptr<FontImportOptions, PoolAlloc>();
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmFontImportOptions.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT FontImportOptionsRTTI : public RTTIType<FontImportOptions, IReflectable, FontImportOptionsRTTI>
+	{
+	private:
+		Vector<UINT32>& getFontSizes(FontImportOptions* obj) { return obj->mFontSizes; }
+		void setFontSizes(FontImportOptions* obj, Vector<UINT32>& value) { obj->mFontSizes = value; }
+
+		Vector<std::pair<UINT32, UINT32>>& getCharIndexRanges(FontImportOptions* obj) { return obj->mCharIndexRanges; }
+		void setCharIndexRanges(FontImportOptions* obj, Vector<std::pair<UINT32, UINT32>>& value) { obj->mCharIndexRanges = value; }
+
+		UINT32& getDPI(FontImportOptions* obj) { return obj->mDPI; }
+		void setDPI(FontImportOptions* obj, UINT32& value) { obj->mDPI = value; }
+
+		bool& getAntialiasing(FontImportOptions* obj) { return obj->mAntialiasing; }
+		void setAntialiasing(FontImportOptions* obj, bool& value) { obj->mAntialiasing = value; }
+
+	public:
+		FontImportOptionsRTTI()
+		{
+			addPlainField("mFontSizes", 0, &FontImportOptionsRTTI::getFontSizes, &FontImportOptionsRTTI::setFontSizes);
+			addPlainField("mCharIndexRanges", 1, &FontImportOptionsRTTI::getCharIndexRanges, &FontImportOptionsRTTI::setCharIndexRanges);
+			addPlainField("mDPI", 2, &FontImportOptionsRTTI::getDPI, &FontImportOptionsRTTI::setDPI);
+			addPlainField("mAntialiasing", 3, &FontImportOptionsRTTI::getAntialiasing, &FontImportOptionsRTTI::setAntialiasing);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "FontImportOptions";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_FontImportOptions;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return cm_shared_ptr<FontImportOptions, PoolAlloc>();
+		}
+	};
 }

+ 25 - 25
CamelotCore/Include/CmFontManager.h → BansheeCore/Include/CmFontManager.h

@@ -1,26 +1,26 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation of fonts.
-	 */
-	class CM_EXPORT FontManager : public Module<FontManager>
-	{
-	public:
-		/**
-		 * @brief	Creates a new font from the provided populated font data structure.
-		 */
-		FontPtr create(const Vector<FontData>& fontData) const;
-
-		/**
-		 * @brief	Creates an empty font.
-		 *
-		 * @note	Internal method. Used by factory methods.
-		 */
-		FontPtr _createEmpty() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Handles creation of fonts.
+	 */
+	class BS_CORE_EXPORT FontManager : public Module<FontManager>
+	{
+	public:
+		/**
+		 * @brief	Creates a new font from the provided populated font data structure.
+		 */
+		FontPtr create(const Vector<FontData>& fontData) const;
+
+		/**
+		 * @brief	Creates an empty font.
+		 *
+		 * @note	Internal method. Used by factory methods.
+		 */
+		FontPtr _createEmpty() const;
+	};
 }

+ 158 - 158
CamelotCore/Include/CmFontRTTI.h → BansheeCore/Include/CmFontRTTI.h

@@ -1,159 +1,159 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmFont.h"
-#include "CmFontManager.h"
-#include "CmTexture.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT FontDataRTTI : public RTTIType<FontData, Resource, FontDataRTTI>
-	{
-	private:
-		UINT32& getSize(FontData* obj)
-		{
-			return obj->size;
-		}
-
-		void setSize(FontData* obj, UINT32& size)
-		{
-			obj->size = size;
-		}
-
-		FONT_DESC& getFontDesc(FontData* obj)
-		{
-			return obj->fontDesc;
-		}
-
-		void setFontDesc(FontData* obj, FONT_DESC& val)
-		{
-			obj->fontDesc = val;
-		}
-
-		HTexture& getTexture(FontData* obj, UINT32 idx)
-		{
-			return obj->texturePages.at(idx);
-		}
-
-		void setTexture(FontData* obj, UINT32 idx, HTexture& value)
-		{
-			obj->texturePages[idx] = value;
-		}
-
-		UINT32 getTextureArraySize(FontData* obj)
-		{
-			return (UINT32)obj->texturePages.size();
-		}
-
-		void setTextureArraySize(FontData* obj, UINT32 size)
-		{
-			obj->texturePages.resize(size);
-		}
-
-	public:
-		FontDataRTTI()
-		{
-			addPlainField("size", 0, &FontDataRTTI::getSize, &FontDataRTTI::setSize);
-			addPlainField("fontDesc", 1, &FontDataRTTI::getFontDesc, &FontDataRTTI::setFontDesc);
-			addReflectableArrayField("texturePages", 2, &FontDataRTTI::getTexture, &FontDataRTTI::getTextureArraySize, &FontDataRTTI::setTexture, &FontDataRTTI::setTextureArraySize);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "FontData";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_FontData;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return cm_shared_ptr<FontData, PoolAlloc>();
-		}
-	};
-
-	class CM_EXPORT FontRTTI : public RTTIType<Font, Resource, FontRTTI>
-	{
-		struct FontInitData
-		{
-			Vector<FontData> fontDataPerSize;
-		};
-
-	private:
-		FontData& getFontData(Font* obj, UINT32 idx)
-		{
-			if(idx >= obj->mFontDataPerSize.size())
-				CM_EXCEPT(InternalErrorException, "Index out of range: " + toString(idx) + ". Valid range: 0 .. " + toString((int)obj->mFontDataPerSize.size()));
-
-			auto iter = obj->mFontDataPerSize.begin();
-			for(UINT32 i = 0; i < idx; i++, ++iter)
-			{ }
-
-			return iter->second;
-		}
-
-		void setFontData(Font* obj, UINT32 idx, FontData& value)
-		{
-			FontInitData* initData = any_cast<FontInitData*>(obj->mRTTIData);
-
-			initData->fontDataPerSize[idx] = value;
-		}
-
-		UINT32 getNumFontData(Font* obj)
-		{
-			return (UINT32)obj->mFontDataPerSize.size();
-		}
-
-		void setNumFontData(Font* obj, UINT32 size)
-		{
-			FontInitData* initData = any_cast<FontInitData*>(obj->mRTTIData);
-
-			initData->fontDataPerSize.resize(size);
-		}
-
-	public:
-		FontRTTI()
-		{
-			addReflectableArrayField("mFontDataPerSize", 0, &FontRTTI::getFontData, &FontRTTI::getNumFontData, &FontRTTI::setFontData, &FontRTTI::setNumFontData);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "Font";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_Font;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return FontManager::instance()._createEmpty();
-		}
-
-	protected:
-		virtual void onDeserializationStarted(IReflectable* obj)
-		{
-			FontInitData* initData = cm_new<FontInitData, PoolAlloc>();
-
-			Font* font = static_cast<Font*>(obj);
-			font->mRTTIData = initData;
-		}
-
-		virtual void onDeserializationEnded(IReflectable* obj)
-		{
-			Font* font = static_cast<Font*>(obj);
-			FontInitData* initData = any_cast<FontInitData*>(font->mRTTIData);
-
-			font->initialize(initData->fontDataPerSize);
-
-			cm_delete<PoolAlloc>(initData);
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmFont.h"
+#include "CmFontManager.h"
+#include "CmTexture.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT FontDataRTTI : public RTTIType<FontData, Resource, FontDataRTTI>
+	{
+	private:
+		UINT32& getSize(FontData* obj)
+		{
+			return obj->size;
+		}
+
+		void setSize(FontData* obj, UINT32& size)
+		{
+			obj->size = size;
+		}
+
+		FONT_DESC& getFontDesc(FontData* obj)
+		{
+			return obj->fontDesc;
+		}
+
+		void setFontDesc(FontData* obj, FONT_DESC& val)
+		{
+			obj->fontDesc = val;
+		}
+
+		HTexture& getTexture(FontData* obj, UINT32 idx)
+		{
+			return obj->texturePages.at(idx);
+		}
+
+		void setTexture(FontData* obj, UINT32 idx, HTexture& value)
+		{
+			obj->texturePages[idx] = value;
+		}
+
+		UINT32 getTextureArraySize(FontData* obj)
+		{
+			return (UINT32)obj->texturePages.size();
+		}
+
+		void setTextureArraySize(FontData* obj, UINT32 size)
+		{
+			obj->texturePages.resize(size);
+		}
+
+	public:
+		FontDataRTTI()
+		{
+			addPlainField("size", 0, &FontDataRTTI::getSize, &FontDataRTTI::setSize);
+			addPlainField("fontDesc", 1, &FontDataRTTI::getFontDesc, &FontDataRTTI::setFontDesc);
+			addReflectableArrayField("texturePages", 2, &FontDataRTTI::getTexture, &FontDataRTTI::getTextureArraySize, &FontDataRTTI::setTexture, &FontDataRTTI::setTextureArraySize);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "FontData";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_FontData;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return cm_shared_ptr<FontData, PoolAlloc>();
+		}
+	};
+
+	class BS_CORE_EXPORT FontRTTI : public RTTIType<Font, Resource, FontRTTI>
+	{
+		struct FontInitData
+		{
+			Vector<FontData> fontDataPerSize;
+		};
+
+	private:
+		FontData& getFontData(Font* obj, UINT32 idx)
+		{
+			if(idx >= obj->mFontDataPerSize.size())
+				CM_EXCEPT(InternalErrorException, "Index out of range: " + toString(idx) + ". Valid range: 0 .. " + toString((int)obj->mFontDataPerSize.size()));
+
+			auto iter = obj->mFontDataPerSize.begin();
+			for(UINT32 i = 0; i < idx; i++, ++iter)
+			{ }
+
+			return iter->second;
+		}
+
+		void setFontData(Font* obj, UINT32 idx, FontData& value)
+		{
+			FontInitData* initData = any_cast<FontInitData*>(obj->mRTTIData);
+
+			initData->fontDataPerSize[idx] = value;
+		}
+
+		UINT32 getNumFontData(Font* obj)
+		{
+			return (UINT32)obj->mFontDataPerSize.size();
+		}
+
+		void setNumFontData(Font* obj, UINT32 size)
+		{
+			FontInitData* initData = any_cast<FontInitData*>(obj->mRTTIData);
+
+			initData->fontDataPerSize.resize(size);
+		}
+
+	public:
+		FontRTTI()
+		{
+			addReflectableArrayField("mFontDataPerSize", 0, &FontRTTI::getFontData, &FontRTTI::getNumFontData, &FontRTTI::setFontData, &FontRTTI::setNumFontData);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "Font";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_Font;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return FontManager::instance()._createEmpty();
+		}
+
+	protected:
+		virtual void onDeserializationStarted(IReflectable* obj)
+		{
+			FontInitData* initData = cm_new<FontInitData, PoolAlloc>();
+
+			Font* font = static_cast<Font*>(obj);
+			font->mRTTIData = initData;
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj)
+		{
+			Font* font = static_cast<Font*>(obj);
+			FontInitData* initData = any_cast<FontInitData*>(font->mRTTIData);
+
+			font->initialize(initData->fontDataPerSize);
+
+			cm_delete<PoolAlloc>(initData);
+		}
+	};
 }

+ 79 - 79
CamelotCore/Include/CmGameObject.h → BansheeCore/Include/CmGameObject.h

@@ -1,80 +1,80 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmIReflectable.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains instance data that is held by all GameObject handles.
-	 */
-	struct GameObjectInstanceData
-	{
-		GameObjectInstanceData()
-			:mInstanceId(0), object(nullptr)
-		{ }
-
-		std::shared_ptr<GameObject> object;
-		UINT64 mInstanceId;
-	};
-
-	/**
-	 * @brief	Type of object that can be referenced by a GameObject handle.
-	 *			Each object has an unique ID and is registered with the GameObjectManager.
-	 */
-	class CM_EXPORT GameObject : public IReflectable
-	{
-	public:
-		GameObject();
-		virtual ~GameObject();
-
-		/**
-		 * @brief	Returns the unique instance ID of the GameObject.
-		 */
-		UINT64 getInstanceId() const { return mInstanceData->mInstanceId; }
-
-		/**
-		 * @brief	Gets the name of the object.
-		 */
-		const String& getName() const { return mName; }
-
-		/**
-		 * @brief	Sets the name of the object.
-		 */
-		void setName(const String& name) { mName = name; }
-
-	protected:
-		friend class GameObjectHandleBase;
-		friend class GameObjectManager;
-
-		/**
-		 * @brief	Initializes the GameObject after construction.
-		 */
-		void initialize(const std::shared_ptr<GameObject>& object, UINT64 instanceId);
-
-	protected:
-		String mName;
-
-	private:
-		std::shared_ptr<GameObjectInstanceData> mInstanceData;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class GameObjectRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
-}
-
-#include "CmGameObjectHandle.h"
-
-namespace BansheeEngine
-{
-	// Game object handles
-	typedef GameObjectHandle<GameObject> HGameObject;
-	typedef GameObjectHandle<SceneObject> HSceneObject;
-	typedef GameObjectHandle<Component> HComponent;
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmIReflectable.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Contains instance data that is held by all GameObject handles.
+	 */
+	struct GameObjectInstanceData
+	{
+		GameObjectInstanceData()
+			:mInstanceId(0), object(nullptr)
+		{ }
+
+		std::shared_ptr<GameObject> object;
+		UINT64 mInstanceId;
+	};
+
+	/**
+	 * @brief	Type of object that can be referenced by a GameObject handle.
+	 *			Each object has an unique ID and is registered with the GameObjectManager.
+	 */
+	class BS_CORE_EXPORT GameObject : public IReflectable
+	{
+	public:
+		GameObject();
+		virtual ~GameObject();
+
+		/**
+		 * @brief	Returns the unique instance ID of the GameObject.
+		 */
+		UINT64 getInstanceId() const { return mInstanceData->mInstanceId; }
+
+		/**
+		 * @brief	Gets the name of the object.
+		 */
+		const String& getName() const { return mName; }
+
+		/**
+		 * @brief	Sets the name of the object.
+		 */
+		void setName(const String& name) { mName = name; }
+
+	protected:
+		friend class GameObjectHandleBase;
+		friend class GameObjectManager;
+
+		/**
+		 * @brief	Initializes the GameObject after construction.
+		 */
+		void initialize(const std::shared_ptr<GameObject>& object, UINT64 instanceId);
+
+	protected:
+		String mName;
+
+	private:
+		std::shared_ptr<GameObjectInstanceData> mInstanceData;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class GameObjectRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
+}
+
+#include "CmGameObjectHandle.h"
+
+namespace BansheeEngine
+{
+	// Game object handles
+	typedef GameObjectHandle<GameObject> HGameObject;
+	typedef GameObjectHandle<SceneObject> HSceneObject;
+	typedef GameObjectHandle<Component> HComponent;
 }

+ 298 - 298
CamelotCore/Include/CmGameObjectHandle.h → BansheeCore/Include/CmGameObjectHandle.h

@@ -1,299 +1,299 @@
-#pragma once
-
-namespace BansheeEngine
-{
-	class GameObjectManager;
-
-	/**
-	 * @brief	Internal data shared between GameObject handles.
-	 */
-	struct CM_EXPORT GameObjectHandleData
-	{
-		GameObjectHandleData()
-			:mPtr(nullptr), mInstanceId(0)
-		{ }
-
-		GameObjectHandleData(const std::shared_ptr<GameObjectInstanceData>& ptr)
-		{
-			mPtr = ptr;
-			if(ptr != nullptr)
-				mInstanceId = ptr->object->getInstanceId();
-			else
-				mInstanceId = 0;
-		}
-
-		std::shared_ptr<GameObjectInstanceData> mPtr;
-		UINT64 mInstanceId;
-	};
-
-	/**
-	 * @brief	A handle that can point to various types of game objects.
-	 * 			It primarily keeps track if the object is still alive, so anything
-	 * 			still referencing it doesn't accidentally use it.
-	 * 			
-	 * @note	This class exists because references between game objects should be quite loose.
-	 * 			For example one game object should be able to reference another one without the other
-	 * 			one knowing. But if that is the case I also need to handle the case when the other
-	 * 			object we're referencing has been deleted, and that is the main purpose of this class.
-	 * 			
-	 */
-	class CM_EXPORT GameObjectHandleBase : public IReflectable
-	{
-	public:
-		GameObjectHandleBase();
-
-		/**
-		 * @brief	Returns true if the object the handle is pointing to has been destroyed.
-		 */
-		bool isDestroyed() const { return mData->mPtr == nullptr || mData->mPtr->object == nullptr; }
-
-		/**
-		 * @brief	Returns the instance ID of the object the handle is referencing.
-		 */
-		UINT64 getInstanceId() const { return mData->mInstanceId; }
-
-		/**
-		 * @brief	Returns pointer to the referenced GameObject.
-		 *
-		 * @note	Throws exception if the GameObject was destroyed.
-		 */
-		GameObject* get() const 
-		{ 
-			throwIfDestroyed();
-
-			return mData->mPtr->object.get(); 
-		}
-
-		/**
-		 * @brief	Returns a smart pointer to the referenced GameObject.
-		 *
-		 * @note	Throws exception if the GameObject was destroyed.
-		 */
-		std::shared_ptr<GameObject> getInternalPtr() const
-		{
-			throwIfDestroyed();
-
-			return mData->mPtr->object;
-		}
-
-		/**
-		 * @brief	Returns pointer to the referenced GameObject.
-		 *
-		 * @note	Throws exception if the GameObject was destroyed.
-		 */
-		GameObject* operator->() const { return get(); }
-
-		/**
-		 * @brief	Returns reference to the referenced GameObject.
-		 *
-		 * @note	Throws exception if the GameObject was destroyed.
-		 */
-		GameObject& operator*() const { return *get(); }
-
-		/**
-		 * @brief	Returns internal handle data.
-		 *
-		 * @note	Internal method.
-		 */
-		std::shared_ptr<GameObjectHandleData> _getHandleData() const { return mData; }
-
-		/**
-		 * @brief	Resolves a handle to a proper GameObject in case it was created uninitialized.
-		 *
-		 * @note	Internal method.
-		 */
-		void _resolve(const GameObjectHandleBase& object);
-
-	protected:
-		friend class SceneObject;
-		friend class SceneObjectRTTI;
-		friend class GameObjectManager;
-
-		GameObjectHandleBase(const std::shared_ptr<GameObject> ptr);
-		GameObjectHandleBase(const std::shared_ptr<GameObjectHandleData>& data);
-		GameObjectHandleBase(std::nullptr_t ptr);
-
-		/**
-		 * @brief	Throws an exception if the referenced GameObject has been destroyed.
-		 */
-		inline void throwIfDestroyed() const;
-		
-		/**
-		 * @brief	Invalidates the handle signifiying the referenced object was destroyed.
-		 */
-		void destroy()
-		{
-			// We need to clear mData->mPtr before we clear mData->mPtr->object,
-			// as this handle could be stored within the "object" and destroyed when
-			// we set it to null 
-			std::shared_ptr<GameObjectInstanceData> instanceData = mData->mPtr;
-			mData->mPtr = nullptr;
-
-			if(instanceData != nullptr)
-				instanceData->object = nullptr;
-		}
-
-		std::shared_ptr<GameObjectHandleData> mData;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class GameObjectHandleRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
-
-	/**
-	 * @copydoc	GameObjectHandleBase
-	 *
-	 * @note	It is important this class contains no data since we often 
-	 *			value cast it to its base.
-	 */
-	template <typename T>
-	class GameObjectHandle : public GameObjectHandleBase
-	{
-	public:
-		/**
-		 * @brief	Constructs a new empty handle.
-		 */
-		GameObjectHandle()
-			:GameObjectHandleBase()
-		{	
-			mData = cm_shared_ptr<GameObjectHandleData, PoolAlloc>();
-		}
-
-		/**
-		 * @brief	Copy constructor from another handle of the same type.
-		 */
-		template <typename T1>
-		GameObjectHandle(const GameObjectHandle<T1>& ptr)
-			:GameObjectHandleBase()
-		{ 	
-			mData = ptr._getHandleData();
-		}
-
-		/**
-		 * @brief	Copy constructor from another handle of the base type.
-		 */
-		GameObjectHandle(const GameObjectHandleBase& ptr)
-			:GameObjectHandleBase()
-		{ 	
-			mData = ptr._getHandleData();
-		}
-
-		/**
-		 * @brief	Invalidates the handle.
-		 */
-		inline GameObjectHandle<T>& operator=(std::nullptr_t ptr)
-		{ 	
-			mData = cm_shared_ptr<GameObjectHandleData, PoolAlloc>();
-
-			return *this;
-		}
-
-		/**
-		 * @brief	Casts a specific handle to the base handle.
-		 */
-		inline operator GameObjectHandleBase()
-		{
-			GameObjectHandleBase base(mData);
-
-			return base;
-		}
-
-		/**
-		 * @brief	Returns a pointer to the referenced GameObject.
-		 *
-		 * @note	Throws exception if the GameObject was destroyed.
-		 */
-		T* get() const 
-		{ 
-			throwIfDestroyed();
-
-			return reinterpret_cast<T*>(mData->mPtr->object.get()); 
-		}
-
-		/**
-		 * @brief	Returns a smart pointer to the referenced GameObject.
-		 *
-		 * @note	Throws exception if the GameObject was destroyed.
-		 */
-		std::shared_ptr<T> getInternalPtr() const
-		{
-			throwIfDestroyed();
-
-			return std::static_pointer_cast<T>(mData->mPtr->object);
-		}
-
-		/**
-		 * @brief	Returns pointer to the referenced GameObject.
-		 *
-		 * @note	Throws exception if the GameObject was destroyed.
-		 */
-		T* operator->() const { return get(); }
-
-		/**
-		 * @brief	Returns reference to the referenced GameObject.
-		 *
-		 * @note	Throws exception if the GameObject was destroyed.
-		 */
-		T& operator*() const { return *get(); }
-
-		template<class _Ty>
-		struct Bool_struct
-		{
-			int _Member;
-		};
-
-		/**
-		 * @brief	Allows direct conversion of handle to bool.
-		 *
-		 * @note	This is needed because we can't directly convert to bool
-		 *			since then we can assign pointer to bool and that's weird.
-		 */
-		operator int Bool_struct<T>::*() const
-		{
-			return (((mData->mPtr != nullptr) && (mData->mPtr->object != nullptr)) ? &Bool_struct<T>::_Member : 0);
-		}
-
-	private:
-		friend class SceneObject;
-		friend class SceneObjectRTTI;
-		friend class GameObjectManager;
-
-		/**
-		 * @brief	Creates a handle from a smart pointer.
-		 */
-		explicit GameObjectHandle(const std::shared_ptr<T> ptr)
-			:GameObjectHandleBase(ptr)
-		{ }
-	};
-
-	/**
-	 * @brief	Casts one handle type to another.
-	 */
-	template<class _Ty1, class _Ty2>
-		GameObjectHandle<_Ty1> static_object_cast(const GameObjectHandle<_Ty2>& other)
-	{	
-		return GameObjectHandle<_Ty1>(other);
-	}
-
-	/**
-	 * @brief	Compares if two handles point to the same GameObject.
-	 */
-	template<class _Ty1, class _Ty2>
-	bool operator==(const GameObjectHandle<_Ty1>& _Left, const GameObjectHandle<_Ty2>& _Right)
-	{	
-		return (_Left == nullptr && _Right == nullptr) || (_Left != nullptr && _Right != nullptr && _Left.get() == _Right.get());
-	}
-
-	/**
-	 * @brief	Compares if two handles point to different GameObjects.
-	 */
-	template<class _Ty1, class _Ty2>
-	bool operator!=(const GameObjectHandle<_Ty1>& _Left, const GameObjectHandle<_Ty2>& _Right)
-	{	
-		return (!(_Left == _Right));
-	}
+#pragma once
+
+namespace BansheeEngine
+{
+	class GameObjectManager;
+
+	/**
+	 * @brief	Internal data shared between GameObject handles.
+	 */
+	struct BS_CORE_EXPORT GameObjectHandleData
+	{
+		GameObjectHandleData()
+			:mPtr(nullptr), mInstanceId(0)
+		{ }
+
+		GameObjectHandleData(const std::shared_ptr<GameObjectInstanceData>& ptr)
+		{
+			mPtr = ptr;
+			if(ptr != nullptr)
+				mInstanceId = ptr->object->getInstanceId();
+			else
+				mInstanceId = 0;
+		}
+
+		std::shared_ptr<GameObjectInstanceData> mPtr;
+		UINT64 mInstanceId;
+	};
+
+	/**
+	 * @brief	A handle that can point to various types of game objects.
+	 * 			It primarily keeps track if the object is still alive, so anything
+	 * 			still referencing it doesn't accidentally use it.
+	 * 			
+	 * @note	This class exists because references between game objects should be quite loose.
+	 * 			For example one game object should be able to reference another one without the other
+	 * 			one knowing. But if that is the case I also need to handle the case when the other
+	 * 			object we're referencing has been deleted, and that is the main purpose of this class.
+	 * 			
+	 */
+	class BS_CORE_EXPORT GameObjectHandleBase : public IReflectable
+	{
+	public:
+		GameObjectHandleBase();
+
+		/**
+		 * @brief	Returns true if the object the handle is pointing to has been destroyed.
+		 */
+		bool isDestroyed() const { return mData->mPtr == nullptr || mData->mPtr->object == nullptr; }
+
+		/**
+		 * @brief	Returns the instance ID of the object the handle is referencing.
+		 */
+		UINT64 getInstanceId() const { return mData->mInstanceId; }
+
+		/**
+		 * @brief	Returns pointer to the referenced GameObject.
+		 *
+		 * @note	Throws exception if the GameObject was destroyed.
+		 */
+		GameObject* get() const 
+		{ 
+			throwIfDestroyed();
+
+			return mData->mPtr->object.get(); 
+		}
+
+		/**
+		 * @brief	Returns a smart pointer to the referenced GameObject.
+		 *
+		 * @note	Throws exception if the GameObject was destroyed.
+		 */
+		std::shared_ptr<GameObject> getInternalPtr() const
+		{
+			throwIfDestroyed();
+
+			return mData->mPtr->object;
+		}
+
+		/**
+		 * @brief	Returns pointer to the referenced GameObject.
+		 *
+		 * @note	Throws exception if the GameObject was destroyed.
+		 */
+		GameObject* operator->() const { return get(); }
+
+		/**
+		 * @brief	Returns reference to the referenced GameObject.
+		 *
+		 * @note	Throws exception if the GameObject was destroyed.
+		 */
+		GameObject& operator*() const { return *get(); }
+
+		/**
+		 * @brief	Returns internal handle data.
+		 *
+		 * @note	Internal method.
+		 */
+		std::shared_ptr<GameObjectHandleData> _getHandleData() const { return mData; }
+
+		/**
+		 * @brief	Resolves a handle to a proper GameObject in case it was created uninitialized.
+		 *
+		 * @note	Internal method.
+		 */
+		void _resolve(const GameObjectHandleBase& object);
+
+	protected:
+		friend class SceneObject;
+		friend class SceneObjectRTTI;
+		friend class GameObjectManager;
+
+		GameObjectHandleBase(const std::shared_ptr<GameObject> ptr);
+		GameObjectHandleBase(const std::shared_ptr<GameObjectHandleData>& data);
+		GameObjectHandleBase(std::nullptr_t ptr);
+
+		/**
+		 * @brief	Throws an exception if the referenced GameObject has been destroyed.
+		 */
+		inline void throwIfDestroyed() const;
+		
+		/**
+		 * @brief	Invalidates the handle signifiying the referenced object was destroyed.
+		 */
+		void destroy()
+		{
+			// We need to clear mData->mPtr before we clear mData->mPtr->object,
+			// as this handle could be stored within the "object" and destroyed when
+			// we set it to null 
+			std::shared_ptr<GameObjectInstanceData> instanceData = mData->mPtr;
+			mData->mPtr = nullptr;
+
+			if(instanceData != nullptr)
+				instanceData->object = nullptr;
+		}
+
+		std::shared_ptr<GameObjectHandleData> mData;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class GameObjectHandleRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
+
+	/**
+	 * @copydoc	GameObjectHandleBase
+	 *
+	 * @note	It is important this class contains no data since we often 
+	 *			value cast it to its base.
+	 */
+	template <typename T>
+	class GameObjectHandle : public GameObjectHandleBase
+	{
+	public:
+		/**
+		 * @brief	Constructs a new empty handle.
+		 */
+		GameObjectHandle()
+			:GameObjectHandleBase()
+		{	
+			mData = cm_shared_ptr<GameObjectHandleData, PoolAlloc>();
+		}
+
+		/**
+		 * @brief	Copy constructor from another handle of the same type.
+		 */
+		template <typename T1>
+		GameObjectHandle(const GameObjectHandle<T1>& ptr)
+			:GameObjectHandleBase()
+		{ 	
+			mData = ptr._getHandleData();
+		}
+
+		/**
+		 * @brief	Copy constructor from another handle of the base type.
+		 */
+		GameObjectHandle(const GameObjectHandleBase& ptr)
+			:GameObjectHandleBase()
+		{ 	
+			mData = ptr._getHandleData();
+		}
+
+		/**
+		 * @brief	Invalidates the handle.
+		 */
+		inline GameObjectHandle<T>& operator=(std::nullptr_t ptr)
+		{ 	
+			mData = cm_shared_ptr<GameObjectHandleData, PoolAlloc>();
+
+			return *this;
+		}
+
+		/**
+		 * @brief	Casts a specific handle to the base handle.
+		 */
+		inline operator GameObjectHandleBase()
+		{
+			GameObjectHandleBase base(mData);
+
+			return base;
+		}
+
+		/**
+		 * @brief	Returns a pointer to the referenced GameObject.
+		 *
+		 * @note	Throws exception if the GameObject was destroyed.
+		 */
+		T* get() const 
+		{ 
+			throwIfDestroyed();
+
+			return reinterpret_cast<T*>(mData->mPtr->object.get()); 
+		}
+
+		/**
+		 * @brief	Returns a smart pointer to the referenced GameObject.
+		 *
+		 * @note	Throws exception if the GameObject was destroyed.
+		 */
+		std::shared_ptr<T> getInternalPtr() const
+		{
+			throwIfDestroyed();
+
+			return std::static_pointer_cast<T>(mData->mPtr->object);
+		}
+
+		/**
+		 * @brief	Returns pointer to the referenced GameObject.
+		 *
+		 * @note	Throws exception if the GameObject was destroyed.
+		 */
+		T* operator->() const { return get(); }
+
+		/**
+		 * @brief	Returns reference to the referenced GameObject.
+		 *
+		 * @note	Throws exception if the GameObject was destroyed.
+		 */
+		T& operator*() const { return *get(); }
+
+		template<class _Ty>
+		struct Bool_struct
+		{
+			int _Member;
+		};
+
+		/**
+		 * @brief	Allows direct conversion of handle to bool.
+		 *
+		 * @note	This is needed because we can't directly convert to bool
+		 *			since then we can assign pointer to bool and that's weird.
+		 */
+		operator int Bool_struct<T>::*() const
+		{
+			return (((mData->mPtr != nullptr) && (mData->mPtr->object != nullptr)) ? &Bool_struct<T>::_Member : 0);
+		}
+
+	private:
+		friend class SceneObject;
+		friend class SceneObjectRTTI;
+		friend class GameObjectManager;
+
+		/**
+		 * @brief	Creates a handle from a smart pointer.
+		 */
+		explicit GameObjectHandle(const std::shared_ptr<T> ptr)
+			:GameObjectHandleBase(ptr)
+		{ }
+	};
+
+	/**
+	 * @brief	Casts one handle type to another.
+	 */
+	template<class _Ty1, class _Ty2>
+		GameObjectHandle<_Ty1> static_object_cast(const GameObjectHandle<_Ty2>& other)
+	{	
+		return GameObjectHandle<_Ty1>(other);
+	}
+
+	/**
+	 * @brief	Compares if two handles point to the same GameObject.
+	 */
+	template<class _Ty1, class _Ty2>
+	bool operator==(const GameObjectHandle<_Ty1>& _Left, const GameObjectHandle<_Ty2>& _Right)
+	{	
+		return (_Left == nullptr && _Right == nullptr) || (_Left != nullptr && _Right != nullptr && _Left.get() == _Right.get());
+	}
+
+	/**
+	 * @brief	Compares if two handles point to different GameObjects.
+	 */
+	template<class _Ty1, class _Ty2>
+	bool operator!=(const GameObjectHandle<_Ty1>& _Left, const GameObjectHandle<_Ty2>& _Right)
+	{	
+		return (!(_Left == _Right));
+	}
 }

+ 46 - 46
CamelotCore/Include/CmGameObjectHandleRTTI.h → BansheeCore/Include/CmGameObjectHandleRTTI.h

@@ -1,47 +1,47 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmGameObjectHandle.h"
-#include "CmGameObjectManager.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT GameObjectHandleRTTI : public RTTIType<GameObjectHandleBase, IReflectable, GameObjectHandleRTTI>
-	{
-	private:
-		UINT64& getInstanceId(GameObjectHandleBase* obj) { return obj->mData->mInstanceId; }
-		void setInstanceId(GameObjectHandleBase* obj, UINT64& value) { obj->mData->mInstanceId = value; } 
-
-	public:
-		GameObjectHandleRTTI()
-		{
-			addPlainField("mInstanceID", 0, &GameObjectHandleRTTI::getInstanceId, &GameObjectHandleRTTI::setInstanceId);
-		}
-
-		void onDeserializationEnded(IReflectable* obj)
-		{
-			GameObjectHandleBase* gameObjectHandle = static_cast<GameObjectHandleBase*>(obj);
-
-			GameObjectManager::instance().registerUnresolvedHandle(*gameObjectHandle);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "GameObjectHandleBase";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_GameObjectHandleBase;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			std::shared_ptr<GameObjectHandleBase> obj = cm_shared_ptr<GameObjectHandleBase, PoolAlloc>(new (cm_alloc<GameObjectHandleBase, PoolAlloc>()) GameObjectHandleBase());
-
-			return obj;
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmGameObjectHandle.h"
+#include "CmGameObjectManager.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT GameObjectHandleRTTI : public RTTIType<GameObjectHandleBase, IReflectable, GameObjectHandleRTTI>
+	{
+	private:
+		UINT64& getInstanceId(GameObjectHandleBase* obj) { return obj->mData->mInstanceId; }
+		void setInstanceId(GameObjectHandleBase* obj, UINT64& value) { obj->mData->mInstanceId = value; } 
+
+	public:
+		GameObjectHandleRTTI()
+		{
+			addPlainField("mInstanceID", 0, &GameObjectHandleRTTI::getInstanceId, &GameObjectHandleRTTI::setInstanceId);
+		}
+
+		void onDeserializationEnded(IReflectable* obj)
+		{
+			GameObjectHandleBase* gameObjectHandle = static_cast<GameObjectHandleBase*>(obj);
+
+			GameObjectManager::instance().registerUnresolvedHandle(*gameObjectHandle);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "GameObjectHandleBase";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GameObjectHandleBase;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			std::shared_ptr<GameObjectHandleBase> obj = cm_shared_ptr<GameObjectHandleBase, PoolAlloc>(new (cm_alloc<GameObjectHandleBase, PoolAlloc>()) GameObjectHandleBase());
+
+			return obj;
+		}
+	};
 }

+ 101 - 101
CamelotCore/Include/CmGameObjectManager.h → BansheeCore/Include/CmGameObjectManager.h

@@ -1,102 +1,102 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmGameObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Tracks GameObject creation and destructions. Also resolves
-	 *			GameObject references from GameObject handles.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class CM_EXPORT GameObjectManager : public Module<GameObjectManager>
-	{
-	public:
-		GameObjectManager();
-		~GameObjectManager();
-
-		/**
-		 * @brief	Registers a new GameObject and returns the handle to the object.
-		 */
-		GameObjectHandleBase registerObject(const std::shared_ptr<GameObject>& object);
-
-		/**
-		 * @brief	Unregisters a GameObject.
-		 */
-		void unregisterObject(const GameObjectHandleBase& object);
-
-		/**
-		 * @brief	Attempts to find a GameObject handle based on the GameObject instance ID.
-		 *			Returns empty handle if ID cannot be found.
-		 */
-		GameObjectHandleBase getObject(UINT64 id) const;
-
-		/**
-		 * @brief	Attempts to find a GameObject handle based on the GameObject instance ID.
-		 *			Returns true if object with the specified ID is found, false otherwise.
-		 */
-		bool tryGetObject(UINT64 id, GameObjectHandleBase& object) const;
-
-		/**
-		 * @brief	Checks if the GameObject with the specified instance ID exists.
-		 */
-		bool objectExists(UINT64 id) const;
-
-		/************************************************************************/
-		/* 							DESERIALIZATION                      		*/
-		/************************************************************************/
-		// Note: GameObjects need a bit of special handling when it comes to deserialization,
-		// which is what this part of the code is used for. It performs two main actions:
-		//  - 1. Resolves all GameObjectHandles on deserialization
-		//    - We can't just resolve them as we go because during deserialization not all objects
-		//      have necessarily been created.
-		//  - 2. Maps serialized IDs to actual in-engine ids. 
-
-		/**
-		 * @brief	Needs to be called whenever GameObject deserialization starts. Must be followed
-		 * 			by endDeserialization call.
-		 */
-		void startDeserialization();
-
-		/**
-		 * @brief	Needs to be called whenever GameObject deserialization ends. Must be preceded
-		 * 			by startDeserialization call.
-		 */
-		void endDeserialization();
-
-		/**
-		 * @brief	Returns true if GameObject deserialization is currently in progress.
-		 */
-		bool isGameObjectDeserializationActive() const { return mIsDeserializationActive; }
-
-		/**
-		 * @brief	Registers an id that was deserialized, and has been remapped to
-		 * 			an actual in-engine ID. This will be used when resolving GameObjectHandles
-		 * 			(since they might point to the invalid deserialized id).
-		 */
-		void registerDeserializedId(UINT64 deserializedId, UINT64 actualId);
-
-		/**
-		 * @brief	Queues the specified handle and resolves it when deserialization ends.
-		 */
-		void registerUnresolvedHandle(const GameObjectHandleBase& object);
-
-		/**
-		 * @brief	Registers a callback that will be triggered when GameObject serialization ends.
-		 */
-		void registerOnDeserializationEndCallback(std::function<void()> callback);
-
-	private:
-		UINT64 mNextAvailableID; // 0 is not a valid ID
-		Map<UINT64, GameObjectHandleBase> mObjects;
-
-		GameObject* mActiveDeserializedObject;
-		bool mIsDeserializationActive;
-		Map<UINT64, UINT64> mIdMapping;
-		Vector<GameObjectHandleBase> mUnresolvedHandles;
-		Vector<std::function<void()>> mEndCallbacks;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmGameObject.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Tracks GameObject creation and destructions. Also resolves
+	 *			GameObject references from GameObject handles.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT GameObjectManager : public Module<GameObjectManager>
+	{
+	public:
+		GameObjectManager();
+		~GameObjectManager();
+
+		/**
+		 * @brief	Registers a new GameObject and returns the handle to the object.
+		 */
+		GameObjectHandleBase registerObject(const std::shared_ptr<GameObject>& object);
+
+		/**
+		 * @brief	Unregisters a GameObject.
+		 */
+		void unregisterObject(const GameObjectHandleBase& object);
+
+		/**
+		 * @brief	Attempts to find a GameObject handle based on the GameObject instance ID.
+		 *			Returns empty handle if ID cannot be found.
+		 */
+		GameObjectHandleBase getObject(UINT64 id) const;
+
+		/**
+		 * @brief	Attempts to find a GameObject handle based on the GameObject instance ID.
+		 *			Returns true if object with the specified ID is found, false otherwise.
+		 */
+		bool tryGetObject(UINT64 id, GameObjectHandleBase& object) const;
+
+		/**
+		 * @brief	Checks if the GameObject with the specified instance ID exists.
+		 */
+		bool objectExists(UINT64 id) const;
+
+		/************************************************************************/
+		/* 							DESERIALIZATION                      		*/
+		/************************************************************************/
+		// Note: GameObjects need a bit of special handling when it comes to deserialization,
+		// which is what this part of the code is used for. It performs two main actions:
+		//  - 1. Resolves all GameObjectHandles on deserialization
+		//    - We can't just resolve them as we go because during deserialization not all objects
+		//      have necessarily been created.
+		//  - 2. Maps serialized IDs to actual in-engine ids. 
+
+		/**
+		 * @brief	Needs to be called whenever GameObject deserialization starts. Must be followed
+		 * 			by endDeserialization call.
+		 */
+		void startDeserialization();
+
+		/**
+		 * @brief	Needs to be called whenever GameObject deserialization ends. Must be preceded
+		 * 			by startDeserialization call.
+		 */
+		void endDeserialization();
+
+		/**
+		 * @brief	Returns true if GameObject deserialization is currently in progress.
+		 */
+		bool isGameObjectDeserializationActive() const { return mIsDeserializationActive; }
+
+		/**
+		 * @brief	Registers an id that was deserialized, and has been remapped to
+		 * 			an actual in-engine ID. This will be used when resolving GameObjectHandles
+		 * 			(since they might point to the invalid deserialized id).
+		 */
+		void registerDeserializedId(UINT64 deserializedId, UINT64 actualId);
+
+		/**
+		 * @brief	Queues the specified handle and resolves it when deserialization ends.
+		 */
+		void registerUnresolvedHandle(const GameObjectHandleBase& object);
+
+		/**
+		 * @brief	Registers a callback that will be triggered when GameObject serialization ends.
+		 */
+		void registerOnDeserializationEndCallback(std::function<void()> callback);
+
+	private:
+		UINT64 mNextAvailableID; // 0 is not a valid ID
+		Map<UINT64, GameObjectHandleBase> mObjects;
+
+		GameObject* mActiveDeserializedObject;
+		bool mIsDeserializationActive;
+		Map<UINT64, UINT64> mIdMapping;
+		Vector<GameObjectHandleBase> mUnresolvedHandles;
+		Vector<std::function<void()>> mEndCallbacks;
+	};
 }

+ 54 - 54
CamelotCore/Include/CmGameObjectRTTI.h → BansheeCore/Include/CmGameObjectRTTI.h

@@ -1,55 +1,55 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmGameObject.h"
-#include "CmSceneObject.h"
-#include "CmGameObjectManager.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT GameObjectRTTI : public RTTIType<GameObject, IReflectable, GameObjectRTTI>
-	{
-	private:
-		String& getName(GameObject* obj) { return obj->mName; }
-		void setName(GameObject* obj, String& name) { obj->mName = name; }
-
-		UINT64& getInstanceID(GameObject* obj) { return obj->mInstanceData->mInstanceId; }
-		void setInstanceID(GameObject* obj, UINT64& instanceId) 
-		{  
-			// The system will have already assigned the instance ID, but since other objects might be referencing
-			// the old (serialized) ID we store it in the GameObjectSerializationManager so we can map from old to new id.
-			GameObjectManager::instance().registerDeserializedId(instanceId, obj->getInstanceId());
-		}
-
-	public:
-		template <typename T>
-		static std::shared_ptr<T> createGameObject()
-		{
-			return SceneObject::createEmptyComponent<T>();
-		}
-
-	public:
-		GameObjectRTTI()
-		{
-			addPlainField("mInstanceID", 0, &GameObjectRTTI::getInstanceID, &GameObjectRTTI::setInstanceID);
-			addPlainField("mName", 1, &GameObjectRTTI::getName, &GameObjectRTTI::setName);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "GameObject";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_GameObject;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmGameObject.h"
+#include "CmSceneObject.h"
+#include "CmGameObjectManager.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT GameObjectRTTI : public RTTIType<GameObject, IReflectable, GameObjectRTTI>
+	{
+	private:
+		String& getName(GameObject* obj) { return obj->mName; }
+		void setName(GameObject* obj, String& name) { obj->mName = name; }
+
+		UINT64& getInstanceID(GameObject* obj) { return obj->mInstanceData->mInstanceId; }
+		void setInstanceID(GameObject* obj, UINT64& instanceId) 
+		{  
+			// The system will have already assigned the instance ID, but since other objects might be referencing
+			// the old (serialized) ID we store it in the GameObjectSerializationManager so we can map from old to new id.
+			GameObjectManager::instance().registerDeserializedId(instanceId, obj->getInstanceId());
+		}
+
+	public:
+		template <typename T>
+		static std::shared_ptr<T> createGameObject()
+		{
+			return SceneObject::createEmptyComponent<T>();
+		}
+
+	public:
+		GameObjectRTTI()
+		{
+			addPlainField("mInstanceID", 0, &GameObjectRTTI::getInstanceID, &GameObjectRTTI::setInstanceID);
+			addPlainField("mName", 1, &GameObjectRTTI::getName, &GameObjectRTTI::setName);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "GameObject";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GameObject;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
+		}
+	};
 }

+ 184 - 184
CamelotCore/Include/CmGpuBuffer.h → BansheeCore/Include/CmGpuBuffer.h

@@ -1,184 +1,184 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmGpuBufferView.h"
-#include "CmCoreObject.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Handles a generic GPU buffer that you may use for storing any kind of data you wish to be accessible
-	 *			to the GPU. These buffers may be bounds to GPU program binding slots and accessed from a GPU program,
-	 *			or may be used by fixed pipeline in some way.
-	 *
-	 *			Buffer types:
-	 *			  - Raw buffers containing a block of bytes that are up to the GPU program to interpret.
-	 *			  - Structured buffer containing an array of structures compliant to a certain layout. Similar to raw
-	 *				buffer but easier to interpret the data.
-	 *			  - Random read/write buffers that allow you to write to random parts of the buffer from within
-	 *				the GPU program, and then read it later. These can only be bound to pixel and compute stages.
-	 *			  - Append/Consume buffers also allow you to write to them, but in a stack-like fashion, usually where one set
-	 *				of programs produces data while other set consumes it from the same buffer. Append/Consume buffers are structured
-	 *				by default.
-	 *
-	 * @note	Core thread only.
-	 */
-	class CM_EXPORT GpuBuffer : public CoreObject
-    {
-    public:
-        virtual ~GpuBuffer();
-
-		/**
-		 * @brief	Locks the buffer returning a pointer to the internal buffer data that you may then
-		 *			read or write to. Caller must ensure it will only perform actions promised in the
-		 *			provided GPU lock options parameter.
-		 *
-		 * @param	offset	Number of bytes at which to lock the buffer. Returned pointer points to this location.
-		 * @param	length	Number of bytes to lock.
-		 * @param	options How to lock the buffer. Certain options offer better performance than others.
-		 */
-		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
-
-		/**
-		 * @brief	Unlocks a previously locked buffer. Any pointers to internal buffers returned when
-		 *			it was locked will become invalid.
-		 */
-		virtual void unlock() = 0;
-
-		/**
-		 * @brief	Reads buffer data into the previously allocated buffer.
-		 *
-		 * @param	offset	Number of bytes at which to start reading the buffer.
-		 * @param	length	Number of bytes to read.
-		 * @param	pDest	Previously allocated buffer of "length" bytes size.
-		 */
-        virtual void readData(UINT32 offset, UINT32 length, void* pDest) = 0;
-
-		/**
-		* @brief	Writes data into the buffer.
-		*
-		* @param	offset		Number of bytes at which to start writing to the buffer.
-		* @param	length		Number of bytes to write.
-		* @param	pDest		Previously allocated buffer used to retrieve the data from.
-		* @param	writeFlags  Flags that may be used to improve performance for specific use cases.
-		*/
-        virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal) = 0;
-
-		/**
-		 * @brief	Copies data from another buffer into this buffer.
-		 *
-		 * @param	srcBuffer			Buffer to copy the data from.
-		 * @param	srcOffset			Offset in bytes into the source buffer - this is where reading starts from.
-		 * @param	dstOffset			Offset in bytes into the destination buffer - this is where writing starts from.
-		 * @param	length				Number of bytes to copy from source to destination.
-		 * @param	discardWholeBuffer	If true, the contents of the current buffer will be entirely discarded. This can improve
-		 *								performance if you know you wont be needing that data any more.
-		 */
-		virtual void copyData(GpuBuffer& srcBuffer, UINT32 srcOffset, 
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) = 0;
-
-		/**
-		 * @brief	Creates a buffer view that may be used for binding a buffer to a slot in the pipeline. Views allow you to specify
-		 *			how is data in the buffer organized to make it easier for the pipeline to interpret.
-		 *
-		 * @param	buffer			Buffer to create the view for.
-		 * @param	firstElement	Position of the first element visible by the view.
-		 * @param	elementWidth	Width of one element in bytes.
-		 * @param	numElements		Number of elements in the buffer.
-		 * @param	useCounter		Should the buffer allow use of a counter. This is only relevant for random read write buffers.
-		 * @param	usage			Determines type of the view we are creating, and which slots in the pipeline will the view be bindable to.
-		 *
-		 * @note	If a view with this exact parameters already exists, it will be returned and new one will not be created.
-		 *
-		 *			Only Default and RandomWrite views are supported for this type of buffer. 
-		 *			TODO Low Priority: Perhaps reflect this limitation by having an enum with only
-		 *			those two options?
-		 */
-		static GpuBufferView* requestView(GpuBufferPtr buffer, UINT32 firstElement, UINT32 elementWidth, UINT32 numElements, bool useCounter, GpuViewUsage usage);
-
-		/**
-		 * @brief	Releases a view created with requestView. 
-		 *
-		 * @note	View will only truly get released once all references to it are released.
-		 */
-		static void releaseView(GpuBufferView* view);
-
-		/**
-		 * @brief	Returns the type of the GPU buffer. Type determines which kind of views (if any) can be created
-		 *			for the buffer, and how is data read or modified in it.
-		 */
-		GpuBufferType getType() const { return mType; }
-
-		/**
-		 * @brief	Returns buffer usage which determines how are planning on updating the buffer contents.
-		 */
-		GpuBufferUsage getUsage() const { return mUsage; }
-
-		/**
-		 * @brief	Return whether the buffer supports random reads and writes within the GPU programs.
-		 */
-		bool getRandomGpuWrite() const { return mRandomGpuWrite; }
-
-		/**
-		 * @brief	Returns whether the buffer supports counter use within GPU programs.
-		 */
-		bool getUseCounter() const { return mUseCounter; }
-
-		/**
-		 * @brief	Returns number of elements in the buffer.
-		 */
-		UINT32 getElementCount() const { return mElementCount; }
-
-		/**
-		 * @brief	Returns size of a single element in the buffer in bytes.
-		 */
-		UINT32 getElementSize() const { return mElementSize; }
-
-	protected:
-		GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
-
-		/**
-		 * @brief	Creates an empty view for the current buffer.
-		 */
-		virtual GpuBufferView* createView() = 0;
-
-		/**
-		 * @brief	Destroys a view previously created for this buffer.
-		 */
-		virtual void destroyView(GpuBufferView* view) = 0;
-
-		/**
-		 * @brief	Destroys all buffer views regardless if their reference count is
-		 *			zero or not.
-		 */
-		void clearBufferViews();
-
-		/**
-		 * @copydoc CoreObject::destroy_internal()
-		 */
-		virtual void destroy_internal();
-
-		/**
-		 * @brief	Helper class to help with reference counting for GPU buffer views.
-		 */
-		struct GpuBufferReference
-		{
-			GpuBufferReference(GpuBufferView* _view)
-				:view(_view), refCount(0)
-			{ }
-
-			GpuBufferView* view;
-			UINT32 refCount;
-		};
-
-		UnorderedMap<GPU_BUFFER_DESC, GpuBufferReference*, GpuBufferView::HashFunction, GpuBufferView::EqualFunction> mBufferViews;
-
-	protected:
-		GpuBufferType mType;
-		GpuBufferUsage mUsage;
-		bool mRandomGpuWrite;
-		bool mUseCounter;
-		UINT32 mElementCount;
-		UINT32 mElementSize;
-    };
-}
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmGpuBufferView.h"
+#include "CmCoreObject.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Handles a generic GPU buffer that you may use for storing any kind of data you wish to be accessible
+	 *			to the GPU. These buffers may be bounds to GPU program binding slots and accessed from a GPU program,
+	 *			or may be used by fixed pipeline in some way.
+	 *
+	 *			Buffer types:
+	 *			  - Raw buffers containing a block of bytes that are up to the GPU program to interpret.
+	 *			  - Structured buffer containing an array of structures compliant to a certain layout. Similar to raw
+	 *				buffer but easier to interpret the data.
+	 *			  - Random read/write buffers that allow you to write to random parts of the buffer from within
+	 *				the GPU program, and then read it later. These can only be bound to pixel and compute stages.
+	 *			  - Append/Consume buffers also allow you to write to them, but in a stack-like fashion, usually where one set
+	 *				of programs produces data while other set consumes it from the same buffer. Append/Consume buffers are structured
+	 *				by default.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT GpuBuffer : public CoreObject
+    {
+    public:
+        virtual ~GpuBuffer();
+
+		/**
+		 * @brief	Locks the buffer returning a pointer to the internal buffer data that you may then
+		 *			read or write to. Caller must ensure it will only perform actions promised in the
+		 *			provided GPU lock options parameter.
+		 *
+		 * @param	offset	Number of bytes at which to lock the buffer. Returned pointer points to this location.
+		 * @param	length	Number of bytes to lock.
+		 * @param	options How to lock the buffer. Certain options offer better performance than others.
+		 */
+		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
+
+		/**
+		 * @brief	Unlocks a previously locked buffer. Any pointers to internal buffers returned when
+		 *			it was locked will become invalid.
+		 */
+		virtual void unlock() = 0;
+
+		/**
+		 * @brief	Reads buffer data into the previously allocated buffer.
+		 *
+		 * @param	offset	Number of bytes at which to start reading the buffer.
+		 * @param	length	Number of bytes to read.
+		 * @param	pDest	Previously allocated buffer of "length" bytes size.
+		 */
+        virtual void readData(UINT32 offset, UINT32 length, void* pDest) = 0;
+
+		/**
+		* @brief	Writes data into the buffer.
+		*
+		* @param	offset		Number of bytes at which to start writing to the buffer.
+		* @param	length		Number of bytes to write.
+		* @param	pDest		Previously allocated buffer used to retrieve the data from.
+		* @param	writeFlags  Flags that may be used to improve performance for specific use cases.
+		*/
+        virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal) = 0;
+
+		/**
+		 * @brief	Copies data from another buffer into this buffer.
+		 *
+		 * @param	srcBuffer			Buffer to copy the data from.
+		 * @param	srcOffset			Offset in bytes into the source buffer - this is where reading starts from.
+		 * @param	dstOffset			Offset in bytes into the destination buffer - this is where writing starts from.
+		 * @param	length				Number of bytes to copy from source to destination.
+		 * @param	discardWholeBuffer	If true, the contents of the current buffer will be entirely discarded. This can improve
+		 *								performance if you know you wont be needing that data any more.
+		 */
+		virtual void copyData(GpuBuffer& srcBuffer, UINT32 srcOffset, 
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false) = 0;
+
+		/**
+		 * @brief	Creates a buffer view that may be used for binding a buffer to a slot in the pipeline. Views allow you to specify
+		 *			how is data in the buffer organized to make it easier for the pipeline to interpret.
+		 *
+		 * @param	buffer			Buffer to create the view for.
+		 * @param	firstElement	Position of the first element visible by the view.
+		 * @param	elementWidth	Width of one element in bytes.
+		 * @param	numElements		Number of elements in the buffer.
+		 * @param	useCounter		Should the buffer allow use of a counter. This is only relevant for random read write buffers.
+		 * @param	usage			Determines type of the view we are creating, and which slots in the pipeline will the view be bindable to.
+		 *
+		 * @note	If a view with this exact parameters already exists, it will be returned and new one will not be created.
+		 *
+		 *			Only Default and RandomWrite views are supported for this type of buffer. 
+		 *			TODO Low Priority: Perhaps reflect this limitation by having an enum with only
+		 *			those two options?
+		 */
+		static GpuBufferView* requestView(GpuBufferPtr buffer, UINT32 firstElement, UINT32 elementWidth, UINT32 numElements, bool useCounter, GpuViewUsage usage);
+
+		/**
+		 * @brief	Releases a view created with requestView. 
+		 *
+		 * @note	View will only truly get released once all references to it are released.
+		 */
+		static void releaseView(GpuBufferView* view);
+
+		/**
+		 * @brief	Returns the type of the GPU buffer. Type determines which kind of views (if any) can be created
+		 *			for the buffer, and how is data read or modified in it.
+		 */
+		GpuBufferType getType() const { return mType; }
+
+		/**
+		 * @brief	Returns buffer usage which determines how are planning on updating the buffer contents.
+		 */
+		GpuBufferUsage getUsage() const { return mUsage; }
+
+		/**
+		 * @brief	Return whether the buffer supports random reads and writes within the GPU programs.
+		 */
+		bool getRandomGpuWrite() const { return mRandomGpuWrite; }
+
+		/**
+		 * @brief	Returns whether the buffer supports counter use within GPU programs.
+		 */
+		bool getUseCounter() const { return mUseCounter; }
+
+		/**
+		 * @brief	Returns number of elements in the buffer.
+		 */
+		UINT32 getElementCount() const { return mElementCount; }
+
+		/**
+		 * @brief	Returns size of a single element in the buffer in bytes.
+		 */
+		UINT32 getElementSize() const { return mElementSize; }
+
+	protected:
+		GpuBuffer(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
+
+		/**
+		 * @brief	Creates an empty view for the current buffer.
+		 */
+		virtual GpuBufferView* createView() = 0;
+
+		/**
+		 * @brief	Destroys a view previously created for this buffer.
+		 */
+		virtual void destroyView(GpuBufferView* view) = 0;
+
+		/**
+		 * @brief	Destroys all buffer views regardless if their reference count is
+		 *			zero or not.
+		 */
+		void clearBufferViews();
+
+		/**
+		 * @copydoc CoreObject::destroy_internal()
+		 */
+		virtual void destroy_internal();
+
+		/**
+		 * @brief	Helper class to help with reference counting for GPU buffer views.
+		 */
+		struct GpuBufferReference
+		{
+			GpuBufferReference(GpuBufferView* _view)
+				:view(_view), refCount(0)
+			{ }
+
+			GpuBufferView* view;
+			UINT32 refCount;
+		};
+
+		UnorderedMap<GPU_BUFFER_DESC, GpuBufferReference*, GpuBufferView::HashFunction, GpuBufferView::EqualFunction> mBufferViews;
+
+	protected:
+		GpuBufferType mType;
+		GpuBufferUsage mUsage;
+		bool mRandomGpuWrite;
+		bool mUseCounter;
+		UINT32 mElementCount;
+		UINT32 mElementSize;
+    };
+}

+ 97 - 97
CamelotCore/Include/CmGpuBufferView.h → BansheeCore/Include/CmGpuBufferView.h

@@ -1,98 +1,98 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Descriptor structure used for initializing a GPU buffer view.
-	 *
-	 * @see		GpuBufferView
-	 * @see		GpuBuffer
-	 */
-	struct CM_EXPORT GPU_BUFFER_DESC
-	{
-		UINT32 firstElement;
-		UINT32 elementWidth;
-		UINT32 numElements;
-		bool useCounter;
-		GpuViewUsage usage;
-	};
-
-	/**
-	 * @brief	Holds information about a GPU buffer view. Views allow you to specify
-	 *			how is data in a buffer organized to make it easier for the pipeline to interpret.
-	 *			
-	 * @note	Buffers don't get bound to the pipeline directly, views do.
-	 *			Core thread only.
-	 *
-	 * @see		GpuBuffer
-	 */
-	class CM_EXPORT GpuBufferView
-	{
-	public:
-		class HashFunction
-		{
-		public:
-			size_t operator()(const GPU_BUFFER_DESC& key) const;
-		};
-
-		class EqualFunction
-		{
-		public:
-			bool operator()(const GPU_BUFFER_DESC& a, const GPU_BUFFER_DESC& b) const;
-		};
-
-		GpuBufferView();
-		virtual ~GpuBufferView();
-
-		/**
-		 * @brief	Initializes the GPU buffer view. Must be called right after
-		 *			construction.
-		 */
-		virtual void initialize(GpuBufferPtr buffer, GPU_BUFFER_DESC& desc);
-
-		/**
-		 * @brief	Returns a descriptor structure used for creating the view.
-		 */
-		const GPU_BUFFER_DESC& getDesc() const { return mDesc; }
-
-		/**
-		 * @brief	Returns the buffer this view was created for.
-		 */
-		GpuBufferPtr getBuffer() const { return mBuffer; }
-
-		/**
-		 * @brief	Returns index of first element in the buffer that this view
-		 *			provides access to.
-		 */
-		UINT32 getFirstElement() const { return mDesc.firstElement; }
-
-		/**
-		 * @brief	Returns width of an element in the buffer, in bytes.
-		 */
-		UINT32 getElementWidth() const { return mDesc.elementWidth; }
-
-		/**
-		 * @brief	Returns the total number of elements this buffer provides
-		 *			access to.
-		 */
-		UINT32 getNumElements() const { return mDesc.numElements; }
-
-		/**
-		 * @brief	Returns true if this view allows a GPU program to use counters on
-		 *			the bound buffer.
-		 */
-		bool getUseCounter() const { return mDesc.useCounter; }
-
-		/**
-		 * @brief	Returns view usage which determines where in the pipeline 
-		 *			can the view be bound.
-		 */
-		GpuViewUsage getUsage() const { return mDesc.usage; }
-
-	protected:
-		GPU_BUFFER_DESC mDesc;
-		GpuBufferPtr mBuffer;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Descriptor structure used for initializing a GPU buffer view.
+	 *
+	 * @see		GpuBufferView
+	 * @see		GpuBuffer
+	 */
+	struct BS_CORE_EXPORT GPU_BUFFER_DESC
+	{
+		UINT32 firstElement;
+		UINT32 elementWidth;
+		UINT32 numElements;
+		bool useCounter;
+		GpuViewUsage usage;
+	};
+
+	/**
+	 * @brief	Holds information about a GPU buffer view. Views allow you to specify
+	 *			how is data in a buffer organized to make it easier for the pipeline to interpret.
+	 *			
+	 * @note	Buffers don't get bound to the pipeline directly, views do.
+	 *			Core thread only.
+	 *
+	 * @see		GpuBuffer
+	 */
+	class BS_CORE_EXPORT GpuBufferView
+	{
+	public:
+		class HashFunction
+		{
+		public:
+			size_t operator()(const GPU_BUFFER_DESC& key) const;
+		};
+
+		class EqualFunction
+		{
+		public:
+			bool operator()(const GPU_BUFFER_DESC& a, const GPU_BUFFER_DESC& b) const;
+		};
+
+		GpuBufferView();
+		virtual ~GpuBufferView();
+
+		/**
+		 * @brief	Initializes the GPU buffer view. Must be called right after
+		 *			construction.
+		 */
+		virtual void initialize(GpuBufferPtr buffer, GPU_BUFFER_DESC& desc);
+
+		/**
+		 * @brief	Returns a descriptor structure used for creating the view.
+		 */
+		const GPU_BUFFER_DESC& getDesc() const { return mDesc; }
+
+		/**
+		 * @brief	Returns the buffer this view was created for.
+		 */
+		GpuBufferPtr getBuffer() const { return mBuffer; }
+
+		/**
+		 * @brief	Returns index of first element in the buffer that this view
+		 *			provides access to.
+		 */
+		UINT32 getFirstElement() const { return mDesc.firstElement; }
+
+		/**
+		 * @brief	Returns width of an element in the buffer, in bytes.
+		 */
+		UINT32 getElementWidth() const { return mDesc.elementWidth; }
+
+		/**
+		 * @brief	Returns the total number of elements this buffer provides
+		 *			access to.
+		 */
+		UINT32 getNumElements() const { return mDesc.numElements; }
+
+		/**
+		 * @brief	Returns true if this view allows a GPU program to use counters on
+		 *			the bound buffer.
+		 */
+		bool getUseCounter() const { return mDesc.useCounter; }
+
+		/**
+		 * @brief	Returns view usage which determines where in the pipeline 
+		 *			can the view be bound.
+		 */
+		GpuViewUsage getUsage() const { return mDesc.usage; }
+
+	protected:
+		GPU_BUFFER_DESC mDesc;
+		GpuBufferPtr mBuffer;
+	};
 }

+ 330 - 330
CamelotCore/Include/CmGpuParam.h → BansheeCore/Include/CmGpuParam.h

@@ -1,331 +1,331 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmGpuParamDesc.h"
-#include "CmGpuParamBlock.h"
-#include "CmDebug.h"
-#include "CmException.h"
-#include "CmMatrix3.h"
-#include "CmMatrix4.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	A handle that allows you to set a GpuProgram parameter. Internally keeps a reference to the 
-	 *			GPU parameter buffer and the necessary offsets. You should specialize this type for specific 
-	 *			parameter types. 
-	 *
-	 *			Object of this type must be returned by a Material. Setting/Getting parameter values will internally
-	 *			access a GPU parameter buffer attached to the Material this parameter was created from. Anything
-	 *			rendered with that material will then use those set values.
-	 * 			
-	 * @note	Normally you can set a GpuProgram parameter by calling various set/get methods on a Material.
-	 *			This class primarily used an as optimization in performance critical bits of code
-	 * 			where it is important to locate and set parameters quickly without any lookups
-	 *			(Mentioned set/get methods expect a parameter name). You just retrieve the handle 
-	 *			once and then set the parameter value many times with minimal performance impact.
-	 * 
-	 * @see		Material
-	 *
-	 * @note	Sim thread only.
-	 */
-	template<class T>
-	class CM_EXPORT GpuDataParamBase
-	{
-	private:
-		friend class GpuParams;
-
-		/**
-		 * @brief	Internal data that is shared between GpuDataParam instances.
-		 */
-		struct InternalData
-		{
-			InternalData(GpuParamDataDesc* paramDesc, GpuParamBlock** paramBlocks, bool transpose)
-				:paramDesc(paramDesc), paramBlocks(paramBlocks), transpose(transpose), isDestroyed(false)
-			{ }
-
-			InternalData()
-				:paramDesc(nullptr), paramBlocks(nullptr), transpose(false), isDestroyed(true)
-			{ }
-
-			~InternalData()
-			{ }
-
-			GpuParamDataDesc* paramDesc;
-			GpuParamBlock** paramBlocks;
-			bool transpose;
-			bool isDestroyed;
-		};
-
-		/**
-		 * @brief	Policy class that allows us to re-use this template class for matrices which might
-		 *			need transposing, and other types which do not. Matrix needs to be transposed for
-		 *			certain render systems depending on how they store them in memory.
-		 */
-		template<class Type>
-		struct TransposePolicy
-		{
-			static Type transpose(const Type& value) { return value; }
-			static bool transposeEnabled(bool enabled) { return false; }
-		};
-
-		/**
-		 * @brief	Transpose policy for 3x3 matrix.
-		 */
-		template<>
-		struct TransposePolicy<Matrix3>
-		{
-			static Matrix3 transpose(const Matrix3& value) { return value.transpose(); }
-			static bool transposeEnabled(bool enabled) { return enabled; }
-		};
-
-		/**
-		* @brief	Transpose policy for 4x4 matrix.
-		*/
-		template<>
-		struct TransposePolicy<Matrix4>
-		{
-			static Matrix4 transpose(const Matrix4& value) { return value.transpose(); }
-			static bool transposeEnabled(bool enabled) { return enabled; }
-		};
-
-	public:
-		GpuDataParamBase()
-			:mData(cm_shared_ptr<InternalData>())
-		{ }
-
-		/**
-		 * @brief	Sets a parameter value at the specified array index. If parameter does not
-		 *			contain an array leave the index at 0.
-		 *
-		 * @note	Like with all GPU parameters, the actual GPU buffer will not be updated until rendering
-		 *			with material this parameter was created from starts on the core thread.
-		 */
-		void set(const T& value, UINT32 arrayIdx = 0)
-		{
-			if(mData->isDestroyed)
-				CM_EXCEPT(InternalErrorException, "Trying to access a destroyed gpu parameter.");
-
-			GpuParamDataDesc* paramDesc = mData->paramDesc;
-
-#if CM_DEBUG_MODE
-			if(arrayIdx >= paramDesc->arraySize)
-			{
-				CM_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " + 
-					toString(paramDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
-			}
-#endif
-
-			UINT32 elementSizeBytes = paramDesc->elementSize * sizeof(UINT32);
-			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T)); // Truncate if it doesn't fit within parameter size
-			GpuParamBlock* paramBlock = mData->paramBlocks[paramDesc->paramBlockSlot];
-
-			if(TransposePolicy<T>::transposeEnabled(mData->transpose))
-			{
-				T transposed = TransposePolicy<T>::transpose(value);
-				paramBlock->write((paramDesc->cpuMemOffset + arrayIdx * paramDesc->arrayElementStride) * sizeof(UINT32), &transposed, sizeBytes);
-			}
-			else
-				paramBlock->write((paramDesc->cpuMemOffset + arrayIdx * paramDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
-
-			// Set unused bytes to 0
-			if(sizeBytes < elementSizeBytes)
-			{
-				UINT32 diffSize = elementSizeBytes - sizeBytes;
-				paramBlock->zeroOut((paramDesc->cpuMemOffset + arrayIdx * paramDesc->arrayElementStride)  * sizeof(UINT32) + sizeBytes, diffSize);
-			}
-		}
-
-		/**
-		 * @brief	Returns a value of a parameter at the specified array index. If parameter does not
-		 *			contain an array leave the index at 0.
-		 *
-		 * @note	No GPU reads are done. Data returned was cached when it was written. 
-		 */
-		T get(UINT32 arrayIdx = 0)
-		{
-			if(mData->isDestroyed)
-				CM_EXCEPT(InternalErrorException, "Trying to access a destroyed gpu parameter.");
-
-			GpuParamDataDesc* paramDesc = mData->paramDesc;
-
-#if CM_DEBUG_MODE
-			if(arrayIdx >= paramDesc->arraySize)
-			{
-				CM_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " + 
-					toString(paramDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
-			}
-#endif
-
-			UINT32 elementSizeBytes = paramDesc->elementSize * sizeof(UINT32);
-			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T));
-			GpuParamBlock* paramBlock = mData->paramBlocks[paramDesc->paramBlockSlot];
-
-			T value;
-			paramBlock->read((paramDesc->cpuMemOffset + arrayIdx * paramDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
-
-			if(TransposePolicy<T>::transposeEnabled(mData->transpose))
-				return TransposePolicy<T>::transpose(value);
-			else
-				return value;
-		}
-
-		/**
-		 * @brief	Called by the material when this handle is no longer valid (shader changed or material
-		 *			got destroyed).
-		 */
-		void _destroy()
-		{
-			mData->isDestroyed = true;
-		}
-
-	private:
-		GpuDataParamBase(GpuParamDataDesc* paramDesc, GpuParamBlock** paramBlocks, bool transpose)
-			:mData(cm_shared_ptr<InternalData>(paramDesc, paramBlocks, transpose))
-		{ }
-
-	private:
-		std::shared_ptr<InternalData> mData;
-	};
-
-	typedef GpuDataParamBase<float> GpuParamFloat;
-	typedef GpuDataParamBase<Vector2> GpuParamVec2;
-	typedef GpuDataParamBase<Vector3> GpuParamVec3;
-	typedef GpuDataParamBase<Vector4> GpuParamVec4;
-	typedef GpuDataParamBase<Matrix3> GpuParamMat3;
-	typedef GpuDataParamBase<Matrix4> GpuParamMat4;
-
-	/**
-	 * @copydoc GpuDataParamBase
-	 */
-	class CM_EXPORT GpuParamStruct
-	{
-	private:
-		friend class GpuParams;
-
-		struct InternalData
-		{
-			InternalData(GpuParamDataDesc* paramDesc, GpuParamBlock** paramBlocks);
-			InternalData();
-			~InternalData();
-
-			GpuParamDataDesc* paramDesc;
-			GpuParamBlock** paramBlocks;
-			bool isDestroyed;
-		};
-
-	public:
-		GpuParamStruct();
-
-		/**
-		 * @copydoc	GpuDataParamBase::set
-		 */
-		void set(const void* value, UINT32 sizeBytes, UINT32 arrayIdx = 0);
-
-		/**
-		 * @copydoc	GpuDataParamBase::get
-		 */
-		void get(void* value, UINT32 sizeBytes, UINT32 arrayIdx = 0);
-
-		/**
-		 * @brief	Returns the size of the struct in bytes.
-		 */
-		UINT32 getElementSize() const;
-
-		/**
-		 * @copydoc	GpuDataParamBase::_destroy
-		 */
-		void _destroy();
-	private:
-		GpuParamStruct(GpuParamDataDesc* paramDesc, GpuParamBlock** paramBlocks);
-
-	private:
-		std::shared_ptr<InternalData> mData;
-	};
-
-	/**
-	 * @copydoc GpuDataParamBase
-	 */
-	class CM_EXPORT GpuParamTexture
-	{
-	private:
-		friend class GpuParams;
-
-		struct InternalData
-		{
-			InternalData(GpuParamObjectDesc* paramDesc, HTexture* textures);
-			InternalData();
-			~InternalData();
-
-			GpuParamObjectDesc* paramDesc;
-			HTexture* textures;
-			bool isDestroyed;
-		};
-
-	public:
-		GpuParamTexture();
-
-		/**
-		* @copydoc	GpuDataParamBase::set
-		*/
-		void set(const HTexture& texture);
-
-		/**
-		* @copydoc	GpuDataParamBase::get
-		*/
-		HTexture get();
-		
-		/**
-		* @copydoc	GpuDataParamBase::_destroy
-		*/
-		void _destroy();
-	private:
-		GpuParamTexture(GpuParamObjectDesc* paramDesc, HTexture* textures);
-
-	private:
-		std::shared_ptr<InternalData> mData;
-	};
-
-	/**
-	 * @copydoc GpuDataParamBase
-	 */
-	class CM_EXPORT GpuParamSampState
-	{
-	private:
-		friend class GpuParams;
-
-		struct InternalData
-		{
-			InternalData(GpuParamObjectDesc* paramDesc, HSamplerState* samplerStates);
-			InternalData();
-			~InternalData();
-
-			GpuParamObjectDesc* paramDesc;
-			HSamplerState* samplerStates;
-			bool isDestroyed;
-		};
-
-	public:
-		GpuParamSampState();
-
-		/**
-		* @copydoc	GpuDataParamBase::set
-		*/
-		void set(const HSamplerState& texture);
-
-		/**
-		* @copydoc	GpuDataParamBase::get
-		*/
-		HSamplerState get();
-
-		/**
-		* @copydoc	GpuDataParamBase::_destroy
-		*/
-		void _destroy();
-	private:
-		GpuParamSampState(GpuParamObjectDesc* paramDesc, HSamplerState* samplerStates);
-
-	private:
-		std::shared_ptr<InternalData> mData;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmGpuParamDesc.h"
+#include "CmGpuParamBlock.h"
+#include "CmDebug.h"
+#include "CmException.h"
+#include "CmMatrix3.h"
+#include "CmMatrix4.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	A handle that allows you to set a GpuProgram parameter. Internally keeps a reference to the 
+	 *			GPU parameter buffer and the necessary offsets. You should specialize this type for specific 
+	 *			parameter types. 
+	 *
+	 *			Object of this type must be returned by a Material. Setting/Getting parameter values will internally
+	 *			access a GPU parameter buffer attached to the Material this parameter was created from. Anything
+	 *			rendered with that material will then use those set values.
+	 * 			
+	 * @note	Normally you can set a GpuProgram parameter by calling various set/get methods on a Material.
+	 *			This class primarily used an as optimization in performance critical bits of code
+	 * 			where it is important to locate and set parameters quickly without any lookups
+	 *			(Mentioned set/get methods expect a parameter name). You just retrieve the handle 
+	 *			once and then set the parameter value many times with minimal performance impact.
+	 * 
+	 * @see		Material
+	 *
+	 * @note	Sim thread only.
+	 */
+	template<class T>
+	class BS_CORE_EXPORT GpuDataParamBase
+	{
+	private:
+		friend class GpuParams;
+
+		/**
+		 * @brief	Internal data that is shared between GpuDataParam instances.
+		 */
+		struct InternalData
+		{
+			InternalData(GpuParamDataDesc* paramDesc, GpuParamBlock** paramBlocks, bool transpose)
+				:paramDesc(paramDesc), paramBlocks(paramBlocks), transpose(transpose), isDestroyed(false)
+			{ }
+
+			InternalData()
+				:paramDesc(nullptr), paramBlocks(nullptr), transpose(false), isDestroyed(true)
+			{ }
+
+			~InternalData()
+			{ }
+
+			GpuParamDataDesc* paramDesc;
+			GpuParamBlock** paramBlocks;
+			bool transpose;
+			bool isDestroyed;
+		};
+
+		/**
+		 * @brief	Policy class that allows us to re-use this template class for matrices which might
+		 *			need transposing, and other types which do not. Matrix needs to be transposed for
+		 *			certain render systems depending on how they store them in memory.
+		 */
+		template<class Type>
+		struct TransposePolicy
+		{
+			static Type transpose(const Type& value) { return value; }
+			static bool transposeEnabled(bool enabled) { return false; }
+		};
+
+		/**
+		 * @brief	Transpose policy for 3x3 matrix.
+		 */
+		template<>
+		struct TransposePolicy<Matrix3>
+		{
+			static Matrix3 transpose(const Matrix3& value) { return value.transpose(); }
+			static bool transposeEnabled(bool enabled) { return enabled; }
+		};
+
+		/**
+		* @brief	Transpose policy for 4x4 matrix.
+		*/
+		template<>
+		struct TransposePolicy<Matrix4>
+		{
+			static Matrix4 transpose(const Matrix4& value) { return value.transpose(); }
+			static bool transposeEnabled(bool enabled) { return enabled; }
+		};
+
+	public:
+		GpuDataParamBase()
+			:mData(cm_shared_ptr<InternalData>())
+		{ }
+
+		/**
+		 * @brief	Sets a parameter value at the specified array index. If parameter does not
+		 *			contain an array leave the index at 0.
+		 *
+		 * @note	Like with all GPU parameters, the actual GPU buffer will not be updated until rendering
+		 *			with material this parameter was created from starts on the core thread.
+		 */
+		void set(const T& value, UINT32 arrayIdx = 0)
+		{
+			if(mData->isDestroyed)
+				CM_EXCEPT(InternalErrorException, "Trying to access a destroyed gpu parameter.");
+
+			GpuParamDataDesc* paramDesc = mData->paramDesc;
+
+#if CM_DEBUG_MODE
+			if(arrayIdx >= paramDesc->arraySize)
+			{
+				CM_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " + 
+					toString(paramDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
+			}
+#endif
+
+			UINT32 elementSizeBytes = paramDesc->elementSize * sizeof(UINT32);
+			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T)); // Truncate if it doesn't fit within parameter size
+			GpuParamBlock* paramBlock = mData->paramBlocks[paramDesc->paramBlockSlot];
+
+			if(TransposePolicy<T>::transposeEnabled(mData->transpose))
+			{
+				T transposed = TransposePolicy<T>::transpose(value);
+				paramBlock->write((paramDesc->cpuMemOffset + arrayIdx * paramDesc->arrayElementStride) * sizeof(UINT32), &transposed, sizeBytes);
+			}
+			else
+				paramBlock->write((paramDesc->cpuMemOffset + arrayIdx * paramDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
+
+			// Set unused bytes to 0
+			if(sizeBytes < elementSizeBytes)
+			{
+				UINT32 diffSize = elementSizeBytes - sizeBytes;
+				paramBlock->zeroOut((paramDesc->cpuMemOffset + arrayIdx * paramDesc->arrayElementStride)  * sizeof(UINT32) + sizeBytes, diffSize);
+			}
+		}
+
+		/**
+		 * @brief	Returns a value of a parameter at the specified array index. If parameter does not
+		 *			contain an array leave the index at 0.
+		 *
+		 * @note	No GPU reads are done. Data returned was cached when it was written. 
+		 */
+		T get(UINT32 arrayIdx = 0)
+		{
+			if(mData->isDestroyed)
+				CM_EXCEPT(InternalErrorException, "Trying to access a destroyed gpu parameter.");
+
+			GpuParamDataDesc* paramDesc = mData->paramDesc;
+
+#if CM_DEBUG_MODE
+			if(arrayIdx >= paramDesc->arraySize)
+			{
+				CM_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " + 
+					toString(paramDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
+			}
+#endif
+
+			UINT32 elementSizeBytes = paramDesc->elementSize * sizeof(UINT32);
+			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T));
+			GpuParamBlock* paramBlock = mData->paramBlocks[paramDesc->paramBlockSlot];
+
+			T value;
+			paramBlock->read((paramDesc->cpuMemOffset + arrayIdx * paramDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
+
+			if(TransposePolicy<T>::transposeEnabled(mData->transpose))
+				return TransposePolicy<T>::transpose(value);
+			else
+				return value;
+		}
+
+		/**
+		 * @brief	Called by the material when this handle is no longer valid (shader changed or material
+		 *			got destroyed).
+		 */
+		void _destroy()
+		{
+			mData->isDestroyed = true;
+		}
+
+	private:
+		GpuDataParamBase(GpuParamDataDesc* paramDesc, GpuParamBlock** paramBlocks, bool transpose)
+			:mData(cm_shared_ptr<InternalData>(paramDesc, paramBlocks, transpose))
+		{ }
+
+	private:
+		std::shared_ptr<InternalData> mData;
+	};
+
+	typedef GpuDataParamBase<float> GpuParamFloat;
+	typedef GpuDataParamBase<Vector2> GpuParamVec2;
+	typedef GpuDataParamBase<Vector3> GpuParamVec3;
+	typedef GpuDataParamBase<Vector4> GpuParamVec4;
+	typedef GpuDataParamBase<Matrix3> GpuParamMat3;
+	typedef GpuDataParamBase<Matrix4> GpuParamMat4;
+
+	/**
+	 * @copydoc GpuDataParamBase
+	 */
+	class BS_CORE_EXPORT GpuParamStruct
+	{
+	private:
+		friend class GpuParams;
+
+		struct InternalData
+		{
+			InternalData(GpuParamDataDesc* paramDesc, GpuParamBlock** paramBlocks);
+			InternalData();
+			~InternalData();
+
+			GpuParamDataDesc* paramDesc;
+			GpuParamBlock** paramBlocks;
+			bool isDestroyed;
+		};
+
+	public:
+		GpuParamStruct();
+
+		/**
+		 * @copydoc	GpuDataParamBase::set
+		 */
+		void set(const void* value, UINT32 sizeBytes, UINT32 arrayIdx = 0);
+
+		/**
+		 * @copydoc	GpuDataParamBase::get
+		 */
+		void get(void* value, UINT32 sizeBytes, UINT32 arrayIdx = 0);
+
+		/**
+		 * @brief	Returns the size of the struct in bytes.
+		 */
+		UINT32 getElementSize() const;
+
+		/**
+		 * @copydoc	GpuDataParamBase::_destroy
+		 */
+		void _destroy();
+	private:
+		GpuParamStruct(GpuParamDataDesc* paramDesc, GpuParamBlock** paramBlocks);
+
+	private:
+		std::shared_ptr<InternalData> mData;
+	};
+
+	/**
+	 * @copydoc GpuDataParamBase
+	 */
+	class BS_CORE_EXPORT GpuParamTexture
+	{
+	private:
+		friend class GpuParams;
+
+		struct InternalData
+		{
+			InternalData(GpuParamObjectDesc* paramDesc, HTexture* textures);
+			InternalData();
+			~InternalData();
+
+			GpuParamObjectDesc* paramDesc;
+			HTexture* textures;
+			bool isDestroyed;
+		};
+
+	public:
+		GpuParamTexture();
+
+		/**
+		* @copydoc	GpuDataParamBase::set
+		*/
+		void set(const HTexture& texture);
+
+		/**
+		* @copydoc	GpuDataParamBase::get
+		*/
+		HTexture get();
+		
+		/**
+		* @copydoc	GpuDataParamBase::_destroy
+		*/
+		void _destroy();
+	private:
+		GpuParamTexture(GpuParamObjectDesc* paramDesc, HTexture* textures);
+
+	private:
+		std::shared_ptr<InternalData> mData;
+	};
+
+	/**
+	 * @copydoc GpuDataParamBase
+	 */
+	class BS_CORE_EXPORT GpuParamSampState
+	{
+	private:
+		friend class GpuParams;
+
+		struct InternalData
+		{
+			InternalData(GpuParamObjectDesc* paramDesc, HSamplerState* samplerStates);
+			InternalData();
+			~InternalData();
+
+			GpuParamObjectDesc* paramDesc;
+			HSamplerState* samplerStates;
+			bool isDestroyed;
+		};
+
+	public:
+		GpuParamSampState();
+
+		/**
+		* @copydoc	GpuDataParamBase::set
+		*/
+		void set(const HSamplerState& texture);
+
+		/**
+		* @copydoc	GpuDataParamBase::get
+		*/
+		HSamplerState get();
+
+		/**
+		* @copydoc	GpuDataParamBase::_destroy
+		*/
+		void _destroy();
+	private:
+		GpuParamSampState(GpuParamObjectDesc* paramDesc, HSamplerState* samplerStates);
+
+	private:
+		std::shared_ptr<InternalData> mData;
+	};
 }

+ 65 - 65
CamelotCore/Include/CmGpuParamBlock.h → BansheeCore/Include/CmGpuParamBlock.h

@@ -1,66 +1,66 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmCoreObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Stores data (e.g. int, float, Vector2) GPU parameters in a raw buffer. 
-	 *			Used primarily for caching GPU parameters on the CPU before they're submitted 
-	 *			to the actual GPU parameter buffer.
-	 */
-	class CM_EXPORT GpuParamBlock
-	{
-	public:
-		GpuParamBlock(UINT32 size);
-		GpuParamBlock(GpuParamBlock* otherBlock);
-
-		virtual ~GpuParamBlock();
-
-		/**
-		 * @brief	Write some data to the specified offset in the buffer. 
-		 *			Marks the block as dirty.
-		 *			All values are in bytes.
-		 */
-		void write(UINT32 offset, const void* data, UINT32 size);
-
-		/**
-		 * @brief	Read some data from the specified offset in the buffer.
-		 *			All values are in bytes.
-		 */
-		void read(UINT32 offset, void* data, UINT32 size);
-
-		/**
-		 * @brief	Clear specified section of the buffer to zero.
-		 *			All values are in bytes.
-		 */
-		void zeroOut(UINT32 offset, UINT32 size);
-
-		/**
-		 * @brief	Returns size of the internal buffer in bytes.
-		 */
-		UINT32 getSize() const { return mSize; }
-
-		/**
-		 * @brief	Returns a raw pointer to the internal buffer.
-		 */
-		UINT8* getData() const { return mData; }
-
-		/**
-		 * @brief	Checks if something has been written to the buffer
-		 *			since the last time object was clean.
-		 */
-		bool isDirty() const { return mDirty; }
-
-		/**
-		 * @brief	Marks the object as dirty or clean. Signifies
-		 *			whether or not some new data has been written in the buffer.
-		 */
-		void setDirty() { mDirty = true; }
-	protected:
-		UINT8* mData;
-		UINT32 mSize;
-		bool mDirty;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmCoreObject.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Stores data (e.g. int, float, Vector2) GPU parameters in a raw buffer. 
+	 *			Used primarily for caching GPU parameters on the CPU before they're submitted 
+	 *			to the actual GPU parameter buffer.
+	 */
+	class BS_CORE_EXPORT GpuParamBlock
+	{
+	public:
+		GpuParamBlock(UINT32 size);
+		GpuParamBlock(GpuParamBlock* otherBlock);
+
+		virtual ~GpuParamBlock();
+
+		/**
+		 * @brief	Write some data to the specified offset in the buffer. 
+		 *			Marks the block as dirty.
+		 *			All values are in bytes.
+		 */
+		void write(UINT32 offset, const void* data, UINT32 size);
+
+		/**
+		 * @brief	Read some data from the specified offset in the buffer.
+		 *			All values are in bytes.
+		 */
+		void read(UINT32 offset, void* data, UINT32 size);
+
+		/**
+		 * @brief	Clear specified section of the buffer to zero.
+		 *			All values are in bytes.
+		 */
+		void zeroOut(UINT32 offset, UINT32 size);
+
+		/**
+		 * @brief	Returns size of the internal buffer in bytes.
+		 */
+		UINT32 getSize() const { return mSize; }
+
+		/**
+		 * @brief	Returns a raw pointer to the internal buffer.
+		 */
+		UINT8* getData() const { return mData; }
+
+		/**
+		 * @brief	Checks if something has been written to the buffer
+		 *			since the last time object was clean.
+		 */
+		bool isDirty() const { return mDirty; }
+
+		/**
+		 * @brief	Marks the object as dirty or clean. Signifies
+		 *			whether or not some new data has been written in the buffer.
+		 */
+		void setDirty() { mDirty = true; }
+	protected:
+		UINT8* mData;
+		UINT32 mSize;
+		bool mDirty;
+	};
 }

+ 100 - 100
CamelotCore/Include/CmGpuParamBlockBuffer.h → BansheeCore/Include/CmGpuParamBlockBuffer.h

@@ -1,101 +1,101 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmCoreObject.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Represents a GPU parameter block buffer. Parameter block buffers
-	 *			are bound to GPU programs which then fetch parameters from those buffers.
-	 *
-	 *			Writing or reading from this buffer will translate directly to API calls
-	 *			that update the GPU.
-	 * 			
-	 * @note	Core thread only.
-	 */
-	class CM_EXPORT GpuParamBlockBuffer : public CoreObject
-	{
-	public:
-		GpuParamBlockBuffer();
-		virtual ~GpuParamBlockBuffer();
-
-		/**
-		 * @brief	Initializes a buffer with the specified size in bytes and usage.
-		 *			Specify dynamic usage if you plan on modifying the buffer often,
-		 *			otherwise specify static usage.
-		 *
-		 * @see		CoreObject::initialize
-		 * 
-		 * @note	Must be called right after construction.
-		 */
-		void initialize(UINT32 size, GpuParamBlockUsage usage);
-
-		/**
-		 * @brief	Writes all of the specified data to the buffer.
-		 * 			Data size must be the same size as the buffer;
-		 */
-		virtual void writeData(const UINT8* data) = 0;
-
-		/**
-		 * @brief	Copies data from the internal buffer to a pre-allocated array. 
-		 * 			Be aware this generally isn't a very fast operation as reading
-		 *			from the GPU will most definitely involve a CPU-GPU sync point.
-		 *
-		 * @param [in,out]	data	Array where the data will be written to. Must be of
-		 * 							"getSize()" bytes.
-		 */
-		virtual void readData(UINT8* data) const = 0;
-
-		/**
-		 * @brief	Returns the size of the buffer in bytes.
-		 */
-		UINT32 getSize() const { return mSize; }
-
-		/**
-		 * @brief	Returns	a parameter block buffer which is used for caching 
-		 *			the parameter information on the CPU. Essentially a CPU
-		 *			copy of the GPU buffer.
-		 *
-		 * @note	Sim thread only.
-		 */
-		GpuParamBlock* getParamBlock() const { return mParamBlock; }
-
-	protected:
-		GpuParamBlockUsage mUsage;
-		UINT32 mSize;
-
-		GpuParamBlock* mParamBlock;
-	};
-
-	/**
-	 * @brief	Implementation of a GpuParamBlock buffer that doesn't use a GPU buffer
-	 *			for storage. Used with APIs that do not support GPU parameter buffers.
-	 */
-	class CM_EXPORT GenericGpuParamBlockBuffer : public GpuParamBlockBuffer
-	{
-	public:
-		/**
-		 * @copydoc	GpuParamBlockBuffer::writeData
-		 */
-		void writeData(const UINT8* data);
-
-		/**
-		 * @copydoc GpuParamBlockBuffer::readData.
-		 */
-		void readData(UINT8* data) const;
-
-	protected:
-		UINT8* mData;
-
-		/**
-		 * @copydoc CoreObject::initialize_internal.
-		 */
-		virtual void initialize_internal();
-
-		/**
-		 * @copydoc CoreObject::destroy_internal.
-		 */
-		virtual void destroy_internal();
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmCoreObject.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Represents a GPU parameter block buffer. Parameter block buffers
+	 *			are bound to GPU programs which then fetch parameters from those buffers.
+	 *
+	 *			Writing or reading from this buffer will translate directly to API calls
+	 *			that update the GPU.
+	 * 			
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT GpuParamBlockBuffer : public CoreObject
+	{
+	public:
+		GpuParamBlockBuffer();
+		virtual ~GpuParamBlockBuffer();
+
+		/**
+		 * @brief	Initializes a buffer with the specified size in bytes and usage.
+		 *			Specify dynamic usage if you plan on modifying the buffer often,
+		 *			otherwise specify static usage.
+		 *
+		 * @see		CoreObject::initialize
+		 * 
+		 * @note	Must be called right after construction.
+		 */
+		void initialize(UINT32 size, GpuParamBlockUsage usage);
+
+		/**
+		 * @brief	Writes all of the specified data to the buffer.
+		 * 			Data size must be the same size as the buffer;
+		 */
+		virtual void writeData(const UINT8* data) = 0;
+
+		/**
+		 * @brief	Copies data from the internal buffer to a pre-allocated array. 
+		 * 			Be aware this generally isn't a very fast operation as reading
+		 *			from the GPU will most definitely involve a CPU-GPU sync point.
+		 *
+		 * @param [in,out]	data	Array where the data will be written to. Must be of
+		 * 							"getSize()" bytes.
+		 */
+		virtual void readData(UINT8* data) const = 0;
+
+		/**
+		 * @brief	Returns the size of the buffer in bytes.
+		 */
+		UINT32 getSize() const { return mSize; }
+
+		/**
+		 * @brief	Returns	a parameter block buffer which is used for caching 
+		 *			the parameter information on the CPU. Essentially a CPU
+		 *			copy of the GPU buffer.
+		 *
+		 * @note	Sim thread only.
+		 */
+		GpuParamBlock* getParamBlock() const { return mParamBlock; }
+
+	protected:
+		GpuParamBlockUsage mUsage;
+		UINT32 mSize;
+
+		GpuParamBlock* mParamBlock;
+	};
+
+	/**
+	 * @brief	Implementation of a GpuParamBlock buffer that doesn't use a GPU buffer
+	 *			for storage. Used with APIs that do not support GPU parameter buffers.
+	 */
+	class BS_CORE_EXPORT GenericGpuParamBlockBuffer : public GpuParamBlockBuffer
+	{
+	public:
+		/**
+		 * @copydoc	GpuParamBlockBuffer::writeData
+		 */
+		void writeData(const UINT8* data);
+
+		/**
+		 * @copydoc GpuParamBlockBuffer::readData.
+		 */
+		void readData(UINT8* data) const;
+
+	protected:
+		UINT8* mData;
+
+		/**
+		 * @copydoc CoreObject::initialize_internal.
+		 */
+		virtual void initialize_internal();
+
+		/**
+		 * @copydoc CoreObject::destroy_internal.
+		 */
+		virtual void destroy_internal();
+	};
 }

+ 57 - 57
CamelotCore/Include/CmGpuParamDesc.h → BansheeCore/Include/CmGpuParamDesc.h

@@ -1,58 +1,58 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Describes a single GPU program data (e.g. int, float, Vector2) parameter.
-	 */
-	struct GpuParamDataDesc
-	{
-		String name;
-		UINT32 elementSize; // Multiple of 4 bytes
-		UINT32 arraySize;
-		UINT32 arrayElementStride; // Multiple of 4 bytes
-		GpuParamDataType type;
-
-		UINT32 paramBlockSlot;
-		UINT32 gpuMemOffset;
-		UINT32 cpuMemOffset;
-	};
-
-	/**
-	 * @brief	Describes a single GPU program object (e.g. texture, sampler state) parameter.
-	 */
-	struct GpuParamObjectDesc
-	{
-		String name;
-		GpuParamObjectType type;
-
-		UINT32 slot;
-	};
-
-	/**
-	 * @brief	Describes a GPU program parameter block (collection of GPU program data parameters).
-	 */
-	struct GpuParamBlockDesc
-	{
-		String name;
-		UINT32 slot;
-		UINT32 blockSize;
-		bool isShareable;
-	};
-
-	/**
-	 * @brief	Contains all parameter information for a GPU program, including data and object parameters,
-	 *			plus parameter blocks.
-	 */
-	struct GpuParamDesc
-	{
-		Map<String, GpuParamBlockDesc> paramBlocks;
-		Map<String, GpuParamDataDesc> params;
-
-		Map<String, GpuParamObjectDesc> samplers;
-		Map<String, GpuParamObjectDesc> textures;
-		Map<String, GpuParamObjectDesc> buffers;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Describes a single GPU program data (e.g. int, float, Vector2) parameter.
+	 */
+	struct GpuParamDataDesc
+	{
+		String name;
+		UINT32 elementSize; // Multiple of 4 bytes
+		UINT32 arraySize;
+		UINT32 arrayElementStride; // Multiple of 4 bytes
+		GpuParamDataType type;
+
+		UINT32 paramBlockSlot;
+		UINT32 gpuMemOffset;
+		UINT32 cpuMemOffset;
+	};
+
+	/**
+	 * @brief	Describes a single GPU program object (e.g. texture, sampler state) parameter.
+	 */
+	struct GpuParamObjectDesc
+	{
+		String name;
+		GpuParamObjectType type;
+
+		UINT32 slot;
+	};
+
+	/**
+	 * @brief	Describes a GPU program parameter block (collection of GPU program data parameters).
+	 */
+	struct GpuParamBlockDesc
+	{
+		String name;
+		UINT32 slot;
+		UINT32 blockSize;
+		bool isShareable;
+	};
+
+	/**
+	 * @brief	Contains all parameter information for a GPU program, including data and object parameters,
+	 *			plus parameter blocks.
+	 */
+	struct GpuParamDesc
+	{
+		Map<String, GpuParamBlockDesc> paramBlocks;
+		Map<String, GpuParamDataDesc> params;
+
+		Map<String, GpuParamObjectDesc> samplers;
+		Map<String, GpuParamObjectDesc> textures;
+		Map<String, GpuParamObjectDesc> buffers;
+	};
 }

+ 233 - 233
CamelotCore/Include/CmGpuParams.h → BansheeCore/Include/CmGpuParams.h

@@ -1,234 +1,234 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmGpuParam.h"
-#include "CmBindableGpuParams.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains descriptions for all parameters in a GPU program and also
-	 *			allows you to write and read those parameters. All parameter values
-	 *			are stored internally on the CPU, and are only submitted to the GPU
-	 *			once the parameters are bound to the pipeline.
-	 *
-	 * @see		CoreThreadAccessor::bindGpuParams
-	 *
-	 * @note	Sim thread only.
-	 */
-	class CM_EXPORT GpuParams
-	{
-	public:
-		/**
-		 * @brief	Creates new GpuParams object using the specified parameter descriptions.
-		 *
-		 * @param	transposeMatrices	If true the stored matrices will be transposed before
-		 *								submitted to the GPU (some APIs require different
-		 *								matrix layout).
-		 *
-		 * @note	You normally do not want to call this manually. Instead use GpuProgram::createParameters.
-		 */
-		GpuParams(GpuParamDesc& paramDesc, bool transposeMatrices);
-		~GpuParams();
-
-		/**
-		 * @brief	Binds a new parameter buffer to the specified slot. Any following parameter reads or
-		 *			writes that are referencing that buffer slot will use the new buffer.
-		 *
-		 * @note	This is useful if you want to share a parameter buffer among multiple GPU programs. 
-		 *			You would only set the values once and then share the buffer among all other GpuParams.
-		 *
-		 *			It is up to the caller to guarantee the provided buffer matches parameter block
-		 *			descriptor for this slot.
-		 */
-		void setParamBlockBuffer(UINT32 slot, const GpuParamBlockBufferPtr& paramBlockBuffer);
-
-		/**
-		* @brief	Replaces the parameter buffer with the specified name. Any following parameter reads or
-		*			writes that are referencing that buffer will use the new buffer.
-		*
-		* @note		This is useful if you want to share a parameter buffer among multiple GPU programs.
-		*			You would only set the values once and then share the buffer among all other GpuParams.
-		*
-		*			It is up to the caller to guarantee the provided buffer matches parameter block
-		*			descriptor for this slot.
-		*/
-		void setParamBlockBuffer(const String& name, const GpuParamBlockBufferPtr& paramBlockBuffer);
-
-		/**
-		 * @brief	Returns a description of all stored parameters.
-		 */
-		const GpuParamDesc& getParamDesc() const { return mParamDesc; }
-
-		/**
-		 * @brief	Returns the size of a data parameter with the specified name, in bytes.
-		 *			Returns 0 if such parameter doesn't exist.
-		 */
-		UINT32 getDataParamSize(const String& name) const;
-
-		/**
-		 * @brief	Checks if parameter with the specified name exists.
-		 */
-		bool hasParam(const String& name) const;
-
-		/**
-		* @brief	Checks if texture parameter with the specified name exists.
-		*/
-		bool hasTexture(const String& name) const;
-
-		/**
-		* @brief	Checks if sampler state parameter with the specified name exists.
-		*/
-		bool hasSamplerState(const String& name) const;
-
-		/**
-		 * @brief	Checks if a parameter block with the specified name exists.
-		 */
-		bool hasParamBlock(const String& name) const;
-
-		/**
-		 * @brief	Returns a handle for the parameter with the specified name. 
-		 *			Handle may then be stored and used for quickly setting or retrieving
-		 *			values to/from that parameter.
-		 *
-		 *			Throws exception if parameter with that name and type doesn't exist.
-		 *
-		 *			Parameter handles will be invalidated when their parent GpuParams object changes.
-		 */
-		template<class T> void getParam(const String& name, GpuDataParamBase<T>& output) const
-		{
-			CM_EXCEPT(InvalidParametersException, "Unsupported parameter type");
-		}
-
-		/**
-		 * @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		 */
-		template<>
-		void getParam<float>(const String& name, GpuDataParamBase<float>& output) const
-		{
-			auto iterFind = mFloatParams.find(name);
-
-			if(iterFind == mFloatParams.end())
-				CM_EXCEPT(InvalidParametersException, "Cannot find float parameter with the name '" + name + "'");
-
-			output = iterFind->second;
-		}
-
-		/**
-		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		*/
-		template<>
-		void getParam<Vector2>(const String& name, GpuDataParamBase<Vector2>& output) const
-		{
-			auto iterFind = mVec2Params.find(name);
-
-			if(iterFind == mVec2Params.end())
-				CM_EXCEPT(InvalidParametersException, "Cannot find vector(2) parameter with the name '" + name + "'");
-
-			output = iterFind->second;
-		}
-
-		/**
-		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		*/
-		template<>
-		void getParam<Vector3>(const String& name, GpuDataParamBase<Vector3>& output) const
-		{
-			auto iterFind = mVec3Params.find(name);
-
-			if(iterFind == mVec3Params.end())
-				CM_EXCEPT(InvalidParametersException, "Cannot find vector(3) parameter with the name '" + name + "'");
-
-			output = iterFind->second;
-		}
-
-		/**
-		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		*/
-		template<>
-		void getParam<Vector4>(const String& name, GpuDataParamBase<Vector4>& output) const
-		{
-			auto iterFind = mVec4Params.find(name);
-
-			if(iterFind == mVec4Params.end())
-				CM_EXCEPT(InvalidParametersException, "Cannot find vector(4) parameter with the name '" + name + "'");
-
-			output = iterFind->second;
-		}
-
-		/**
-		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		*/
-		template<>
-		void getParam<Matrix3>(const String& name, GpuDataParamBase<Matrix3>& output) const
-		{
-			auto iterFind = mMat3Params.find(name);
-
-			if(iterFind == mMat3Params.end())
-				CM_EXCEPT(InvalidParametersException, "Cannot find matrix(3x3) parameter with the name '" + name + "'");
-
-			output = iterFind->second;
-		}
-
-		/**
-		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		*/
-		template<>
-		void getParam<Matrix4>(const String& name, GpuDataParamBase<Matrix4>& output) const
-		{
-			auto iterFind = mMat4Params.find(name);
-
-			if(iterFind == mMat4Params.end())
-				CM_EXCEPT(InvalidParametersException, "Cannot find matrix(4x4) parameter with the name '" + name + "'");
-
-			output = iterFind->second;
-		}
-
-		/**
-		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		*/
-		void getStructParam(const String& name, GpuParamStruct& output) const;
-
-		/**
-		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		*/
-		void getTextureParam(const String& name, GpuParamTexture& output) const;
-
-		/**
-		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
-		*/
-		void getSamplerStateParam(const String& name, GpuParamSampState& output) const;
-
-	private:
-		friend class BindableGpuParams;
-
-		GpuParamDesc& mParamDesc;
-		bool mTransposeMatrices;
-
-		/**
-		 * @brief	Gets a descriptor for a data parameter with the specified name.
-		 */
-		GpuParamDataDesc* getParamDesc(const String& name) const;
-
-		UINT8* mData;
-
-		UINT32 mNumParamBlocks;
-		UINT32 mNumTextures;
-		UINT32 mNumSamplerStates;
-
-		GpuParamBlock** mParamBlocks;
-		GpuParamBlockBufferPtr* mParamBlockBuffers;
-		HTexture* mTextures;
-		HSamplerState* mSamplerStates;
-
-		mutable Map<String, GpuParamFloat> mFloatParams;
-		mutable Map<String, GpuParamVec2> mVec2Params;
-		mutable Map<String, GpuParamVec3> mVec3Params;
-		mutable Map<String, GpuParamVec4> mVec4Params;
-		mutable Map<String, GpuParamMat3> mMat3Params;
-		mutable Map<String, GpuParamMat4> mMat4Params;
-		mutable Map<String, GpuParamStruct> mStructParams;
-		mutable Map<String, GpuParamTexture> mTextureParams;
-		mutable Map<String, GpuParamSampState> mSampStateParams;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmGpuParam.h"
+#include "CmBindableGpuParams.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Contains descriptions for all parameters in a GPU program and also
+	 *			allows you to write and read those parameters. All parameter values
+	 *			are stored internally on the CPU, and are only submitted to the GPU
+	 *			once the parameters are bound to the pipeline.
+	 *
+	 * @see		CoreThreadAccessor::bindGpuParams
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT GpuParams
+	{
+	public:
+		/**
+		 * @brief	Creates new GpuParams object using the specified parameter descriptions.
+		 *
+		 * @param	transposeMatrices	If true the stored matrices will be transposed before
+		 *								submitted to the GPU (some APIs require different
+		 *								matrix layout).
+		 *
+		 * @note	You normally do not want to call this manually. Instead use GpuProgram::createParameters.
+		 */
+		GpuParams(GpuParamDesc& paramDesc, bool transposeMatrices);
+		~GpuParams();
+
+		/**
+		 * @brief	Binds a new parameter buffer to the specified slot. Any following parameter reads or
+		 *			writes that are referencing that buffer slot will use the new buffer.
+		 *
+		 * @note	This is useful if you want to share a parameter buffer among multiple GPU programs. 
+		 *			You would only set the values once and then share the buffer among all other GpuParams.
+		 *
+		 *			It is up to the caller to guarantee the provided buffer matches parameter block
+		 *			descriptor for this slot.
+		 */
+		void setParamBlockBuffer(UINT32 slot, const GpuParamBlockBufferPtr& paramBlockBuffer);
+
+		/**
+		* @brief	Replaces the parameter buffer with the specified name. Any following parameter reads or
+		*			writes that are referencing that buffer will use the new buffer.
+		*
+		* @note		This is useful if you want to share a parameter buffer among multiple GPU programs.
+		*			You would only set the values once and then share the buffer among all other GpuParams.
+		*
+		*			It is up to the caller to guarantee the provided buffer matches parameter block
+		*			descriptor for this slot.
+		*/
+		void setParamBlockBuffer(const String& name, const GpuParamBlockBufferPtr& paramBlockBuffer);
+
+		/**
+		 * @brief	Returns a description of all stored parameters.
+		 */
+		const GpuParamDesc& getParamDesc() const { return mParamDesc; }
+
+		/**
+		 * @brief	Returns the size of a data parameter with the specified name, in bytes.
+		 *			Returns 0 if such parameter doesn't exist.
+		 */
+		UINT32 getDataParamSize(const String& name) const;
+
+		/**
+		 * @brief	Checks if parameter with the specified name exists.
+		 */
+		bool hasParam(const String& name) const;
+
+		/**
+		* @brief	Checks if texture parameter with the specified name exists.
+		*/
+		bool hasTexture(const String& name) const;
+
+		/**
+		* @brief	Checks if sampler state parameter with the specified name exists.
+		*/
+		bool hasSamplerState(const String& name) const;
+
+		/**
+		 * @brief	Checks if a parameter block with the specified name exists.
+		 */
+		bool hasParamBlock(const String& name) const;
+
+		/**
+		 * @brief	Returns a handle for the parameter with the specified name. 
+		 *			Handle may then be stored and used for quickly setting or retrieving
+		 *			values to/from that parameter.
+		 *
+		 *			Throws exception if parameter with that name and type doesn't exist.
+		 *
+		 *			Parameter handles will be invalidated when their parent GpuParams object changes.
+		 */
+		template<class T> void getParam(const String& name, GpuDataParamBase<T>& output) const
+		{
+			CM_EXCEPT(InvalidParametersException, "Unsupported parameter type");
+		}
+
+		/**
+		 * @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		 */
+		template<>
+		void getParam<float>(const String& name, GpuDataParamBase<float>& output) const
+		{
+			auto iterFind = mFloatParams.find(name);
+
+			if(iterFind == mFloatParams.end())
+				CM_EXCEPT(InvalidParametersException, "Cannot find float parameter with the name '" + name + "'");
+
+			output = iterFind->second;
+		}
+
+		/**
+		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		*/
+		template<>
+		void getParam<Vector2>(const String& name, GpuDataParamBase<Vector2>& output) const
+		{
+			auto iterFind = mVec2Params.find(name);
+
+			if(iterFind == mVec2Params.end())
+				CM_EXCEPT(InvalidParametersException, "Cannot find vector(2) parameter with the name '" + name + "'");
+
+			output = iterFind->second;
+		}
+
+		/**
+		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		*/
+		template<>
+		void getParam<Vector3>(const String& name, GpuDataParamBase<Vector3>& output) const
+		{
+			auto iterFind = mVec3Params.find(name);
+
+			if(iterFind == mVec3Params.end())
+				CM_EXCEPT(InvalidParametersException, "Cannot find vector(3) parameter with the name '" + name + "'");
+
+			output = iterFind->second;
+		}
+
+		/**
+		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		*/
+		template<>
+		void getParam<Vector4>(const String& name, GpuDataParamBase<Vector4>& output) const
+		{
+			auto iterFind = mVec4Params.find(name);
+
+			if(iterFind == mVec4Params.end())
+				CM_EXCEPT(InvalidParametersException, "Cannot find vector(4) parameter with the name '" + name + "'");
+
+			output = iterFind->second;
+		}
+
+		/**
+		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		*/
+		template<>
+		void getParam<Matrix3>(const String& name, GpuDataParamBase<Matrix3>& output) const
+		{
+			auto iterFind = mMat3Params.find(name);
+
+			if(iterFind == mMat3Params.end())
+				CM_EXCEPT(InvalidParametersException, "Cannot find matrix(3x3) parameter with the name '" + name + "'");
+
+			output = iterFind->second;
+		}
+
+		/**
+		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		*/
+		template<>
+		void getParam<Matrix4>(const String& name, GpuDataParamBase<Matrix4>& output) const
+		{
+			auto iterFind = mMat4Params.find(name);
+
+			if(iterFind == mMat4Params.end())
+				CM_EXCEPT(InvalidParametersException, "Cannot find matrix(4x4) parameter with the name '" + name + "'");
+
+			output = iterFind->second;
+		}
+
+		/**
+		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		*/
+		void getStructParam(const String& name, GpuParamStruct& output) const;
+
+		/**
+		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		*/
+		void getTextureParam(const String& name, GpuParamTexture& output) const;
+
+		/**
+		* @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		*/
+		void getSamplerStateParam(const String& name, GpuParamSampState& output) const;
+
+	private:
+		friend class BindableGpuParams;
+
+		GpuParamDesc& mParamDesc;
+		bool mTransposeMatrices;
+
+		/**
+		 * @brief	Gets a descriptor for a data parameter with the specified name.
+		 */
+		GpuParamDataDesc* getParamDesc(const String& name) const;
+
+		UINT8* mData;
+
+		UINT32 mNumParamBlocks;
+		UINT32 mNumTextures;
+		UINT32 mNumSamplerStates;
+
+		GpuParamBlock** mParamBlocks;
+		GpuParamBlockBufferPtr* mParamBlockBuffers;
+		HTexture* mTextures;
+		HSamplerState* mSamplerStates;
+
+		mutable Map<String, GpuParamFloat> mFloatParams;
+		mutable Map<String, GpuParamVec2> mVec2Params;
+		mutable Map<String, GpuParamVec3> mVec3Params;
+		mutable Map<String, GpuParamVec4> mVec4Params;
+		mutable Map<String, GpuParamMat3> mMat3Params;
+		mutable Map<String, GpuParamMat4> mMat4Params;
+		mutable Map<String, GpuParamStruct> mStructParams;
+		mutable Map<String, GpuParamTexture> mTextureParams;
+		mutable Map<String, GpuParamSampState> mSampStateParams;
+	};
 }

+ 34 - 34
CamelotCore/Include/CmGpuProgInclude.h → BansheeCore/Include/CmGpuProgInclude.h

@@ -1,35 +1,35 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmResource.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Raw text resource that serves as an include file for GPU programs.
-	 */
-	class CM_EXPORT GpuProgInclude : public Resource
-	{
-	public:
-		/**
-		 * @brief	Text of the include file.
-		 */
-		const String& getString() const { return mString; }
-
-		/**
-		 * @brief	Creates a new include file resource with the specified include string.
-		 */
-		static HGpuProgInclude create(const String& includeString);
-
-		/**
-		 * @brief	Creates an include file resource with the specified include string.
-		 *
-		 * @note	Internal method. Use "create" for normal use.
-		 */
-		static GpuProgIncludePtr _createPtr(const String& includeString);
-	private:
-		GpuProgInclude(const String& includeString);
-
-		String mString;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmResource.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Raw text resource that serves as an include file for GPU programs.
+	 */
+	class BS_CORE_EXPORT GpuProgInclude : public Resource
+	{
+	public:
+		/**
+		 * @brief	Text of the include file.
+		 */
+		const String& getString() const { return mString; }
+
+		/**
+		 * @brief	Creates a new include file resource with the specified include string.
+		 */
+		static HGpuProgInclude create(const String& includeString);
+
+		/**
+		 * @brief	Creates an include file resource with the specified include string.
+		 *
+		 * @note	Internal method. Use "create" for normal use.
+		 */
+		static GpuProgIncludePtr _createPtr(const String& includeString);
+	private:
+		GpuProgInclude(const String& includeString);
+
+		String mString;
+	};
 }

+ 27 - 27
CamelotCore/Include/CmGpuProgIncludeImporter.h → BansheeCore/Include/CmGpuProgIncludeImporter.h

@@ -1,28 +1,28 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmSpecificImporter.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Importer using for importing GPU program (i.e. shader) include files.
-	 * 			Include files are just text files ending with ".gpuproginc" extension.
-	 */
-	class CM_EXPORT GpuProgIncludeImporter : public SpecificImporter
-	{
-	public:
-		GpuProgIncludeImporter();
-		virtual ~GpuProgIncludeImporter();
-
-		/** @copydoc SpecificImporter::isExtensionSupported */
-		virtual bool isExtensionSupported(const WString& ext) const;
-
-		/** @copydoc SpecificImporter::isMagicNumberSupported */
-		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
-
-		/** @copydoc SpecificImporter::import */
-		virtual ResourcePtr import(const Path& filePath, ConstImportOptionsPtr importOptions);
-	private:
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmSpecificImporter.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Importer using for importing GPU program (i.e. shader) include files.
+	 * 			Include files are just text files ending with ".gpuproginc" extension.
+	 */
+	class BS_CORE_EXPORT GpuProgIncludeImporter : public SpecificImporter
+	{
+	public:
+		GpuProgIncludeImporter();
+		virtual ~GpuProgIncludeImporter();
+
+		/** @copydoc SpecificImporter::isExtensionSupported */
+		virtual bool isExtensionSupported(const WString& ext) const;
+
+		/** @copydoc SpecificImporter::isMagicNumberSupported */
+		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
+
+		/** @copydoc SpecificImporter::import */
+		virtual ResourcePtr import(const Path& filePath, ConstImportOptionsPtr importOptions);
+	private:
+	};
 }

+ 201 - 201
CamelotCore/Include/CmGpuProgram.h → BansheeCore/Include/CmGpuProgram.h

@@ -1,202 +1,202 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmDrawOps.h"
-#include "CmResource.h"
-#include "CmGpuParamDesc.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Types of programs that may run on GPU.
-	 */
-	enum GpuProgramType
-	{
-		GPT_VERTEX_PROGRAM,
-		GPT_FRAGMENT_PROGRAM,
-		GPT_GEOMETRY_PROGRAM,
-		GPT_DOMAIN_PROGRAM,
-		GPT_HULL_PROGRAM,
-		GPT_COMPUTE_PROGRAM
-	};
-
-	/**
-	 * @brief	GPU program profiles representing supported
-	 *			feature sets.
-	 */
-	enum GpuProgramProfile
-	{
-		GPP_NONE,
-		GPP_PS_1_1,
-		GPP_PS_1_2,
-		GPP_PS_1_3,
-		GPP_PS_1_4,
-		GPP_PS_2_0,
-		GPP_PS_2_x,
-		GPP_PS_2_a,
-		GPP_PS_2_b,
-		GPP_PS_3_0,
-		GPP_PS_3_x,
-		GPP_PS_4_0,
-		GPP_PS_4_1,
-		GPP_PS_5_0,
-		GPP_VS_1_1,
-		GPP_VS_2_0,
-		GPP_VS_2_x,
-		GPP_VS_2_a,
-		GPP_VS_3_0,
-		GPP_VS_4_0,
-		GPP_VS_4_1,
-		GPP_VS_5_0,
-		GPP_GS_4_0,
-		GPP_GS_4_1,
-		GPP_GS_5_0,
-		GPP_HS_5_0,
-		GPP_DS_5_0,
-		GPP_CS_5_0
-	};
-
-	/**
-	 * @brief	Contains a GPU program such as vertex or fragment program which gets
-	 *			compiled from the provided source code.
-	 *
-	 * @note	Core thread only.
-	 */
-	class CM_EXPORT GpuProgram : public Resource
-	{
-	public:
-		virtual ~GpuProgram();
-
-        /**
-         * @brief	Source used for creating this program.
-         */
-        virtual const String& getSource() const { return mSource; }
-        
-		/**
-		 * @brief	Type of GPU program (e.g. fragment, vertex)
-		 */
-        virtual GpuProgramType getType() const { return mType; }
-
-		/**
-		 * @brief	Profile of the GPU program (e.g. VS_4_0, VS_5_0)
-		 */
-		virtual GpuProgramProfile getProfile() const { return mProfile; }
-
-		/**
-		 * @brief	Name of the program entry method (e.g. "main")
-		 */
-		virtual const String& getEntryPoint() const { return mEntryPoint; }
-
-		/**
-		 * @brief	Returns whether this program can be supported on the current renderer and hardware.
-		 */
-        virtual bool isSupported() const;
-
-		/**
-		 * @brief	Returns true if shader was successfully compiled. 
-		 *
-		 * @note	Thread safe. Only valid after core thread has initialized the program.
-		 */
-		virtual bool isCompiled() const { return mIsCompiled; }
-
-		/**
-		 * @brief	Returns an error message returned by the compiler, if the compilation failed.
-		 *
-		 * @note	Thread safe. Only valid after core thread has initialized the program.
-		 */
-		virtual String getCompileErrorMessage() const { return mCompileError; }
-
-		/**
-		 * @brief	Sets whether this geometry program requires adjacency information
-		 *			from the input primitives.
-		 *
-		 * @note	Only relevant for geometry programs.
-		 */
-		virtual void setAdjacencyInfoRequired(bool required) { mNeedsAdjacencyInfo = required; }
-
-		/**
-		 * @brief	Returns whether this geometry program requires adjacency information
-		 *			from the input primitives.
-		 *
-		 * @note	Only relevant for geometry programs.
-		 */
-		virtual bool isAdjacencyInfoRequired() const { return mNeedsAdjacencyInfo; }
-
-		/**
-		 * @brief	Creates a new parameters object compatible with this program definition. You
-		 *			may populate the returned object with actual parameter values and bind it
-		 *			to the pipeline to render an object using those values and this program.
-		 */
-		virtual GpuParamsPtr createParameters();
-
-		/**
-		 * @brief	Returns description of all parameters in this GPU program.
-		 */
-		const GpuParamDesc& getParamDesc() const { return mParametersDesc; }
-
-		/**
-		* @brief	Language this shader was created from (e.g. HLSL, GLSL).
-		*/
-        virtual const String& getLanguage() const;
-
-		/**
-		 * @brief	Creates a new GPU program using the provided source code. If compilation fails or program is not supported
-		 *			"isCompiled" with return false, and you will be able to retrieve the error message via "getCompileErrorMessage".
-		 *
-		 * @param	source		Source code to compile the shader from.
-		 * @param	entryPoint	Name of the entry point function, e.g. "main".
-		 * @param	language	Language the source is written in, e.g. "hlsl" or "glsl".
-		 * @param	gptype		Type of the program, e.g. vertex or fragment.
-		 * @param	profile		Program profile specifying supported feature-set. Must match the type.
-		 * @param	includes	Optional includes to append to the source before compiling.
-		 * @param	requiresAdjacency	If true then adjacency information will be provided when rendering using this program.
-		 */
-		static HGpuProgram create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype,
-			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes = nullptr, bool requiresAdjacency = false);
-
-		/**
-		 * @copydoc	create
-		 *
-		 * @note	Internal method. For normal use call "create".
-		 */
-		static GpuProgramPtr _createPtr(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, 
-			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes = nullptr, bool requiresAdjacency = false);
-
-	protected:
-		friend class GpuProgramManager;
-
-		GpuProgram(const String& source, const String& entryPoint, 
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, 
-			bool isAdjacencyInfoRequired = false);
-
-		/**
-		 * @brief	Returns whether required capabilities for this program is supported.
-		 */
-        bool isRequiredCapabilitiesSupported() const;
-
-		/**
-		 * @copydoc Resource::calculateSize
-		 */
-		size_t calculateSize() const { return 0; } // TODO 
-
-	protected:
-		GpuProgramType mType;
-		bool mNeedsAdjacencyInfo;
-		String mEntryPoint;
-		GpuProgramProfile mProfile;
-        String mSource;
-
-		bool mIsCompiled;
-		String mCompileError;
-
-		GpuParamDesc mParametersDesc;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class GpuProgramRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmDrawOps.h"
+#include "CmResource.h"
+#include "CmGpuParamDesc.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Types of programs that may run on GPU.
+	 */
+	enum GpuProgramType
+	{
+		GPT_VERTEX_PROGRAM,
+		GPT_FRAGMENT_PROGRAM,
+		GPT_GEOMETRY_PROGRAM,
+		GPT_DOMAIN_PROGRAM,
+		GPT_HULL_PROGRAM,
+		GPT_COMPUTE_PROGRAM
+	};
+
+	/**
+	 * @brief	GPU program profiles representing supported
+	 *			feature sets.
+	 */
+	enum GpuProgramProfile
+	{
+		GPP_NONE,
+		GPP_PS_1_1,
+		GPP_PS_1_2,
+		GPP_PS_1_3,
+		GPP_PS_1_4,
+		GPP_PS_2_0,
+		GPP_PS_2_x,
+		GPP_PS_2_a,
+		GPP_PS_2_b,
+		GPP_PS_3_0,
+		GPP_PS_3_x,
+		GPP_PS_4_0,
+		GPP_PS_4_1,
+		GPP_PS_5_0,
+		GPP_VS_1_1,
+		GPP_VS_2_0,
+		GPP_VS_2_x,
+		GPP_VS_2_a,
+		GPP_VS_3_0,
+		GPP_VS_4_0,
+		GPP_VS_4_1,
+		GPP_VS_5_0,
+		GPP_GS_4_0,
+		GPP_GS_4_1,
+		GPP_GS_5_0,
+		GPP_HS_5_0,
+		GPP_DS_5_0,
+		GPP_CS_5_0
+	};
+
+	/**
+	 * @brief	Contains a GPU program such as vertex or fragment program which gets
+	 *			compiled from the provided source code.
+	 *
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT GpuProgram : public Resource
+	{
+	public:
+		virtual ~GpuProgram();
+
+        /**
+         * @brief	Source used for creating this program.
+         */
+        virtual const String& getSource() const { return mSource; }
+        
+		/**
+		 * @brief	Type of GPU program (e.g. fragment, vertex)
+		 */
+        virtual GpuProgramType getType() const { return mType; }
+
+		/**
+		 * @brief	Profile of the GPU program (e.g. VS_4_0, VS_5_0)
+		 */
+		virtual GpuProgramProfile getProfile() const { return mProfile; }
+
+		/**
+		 * @brief	Name of the program entry method (e.g. "main")
+		 */
+		virtual const String& getEntryPoint() const { return mEntryPoint; }
+
+		/**
+		 * @brief	Returns whether this program can be supported on the current renderer and hardware.
+		 */
+        virtual bool isSupported() const;
+
+		/**
+		 * @brief	Returns true if shader was successfully compiled. 
+		 *
+		 * @note	Thread safe. Only valid after core thread has initialized the program.
+		 */
+		virtual bool isCompiled() const { return mIsCompiled; }
+
+		/**
+		 * @brief	Returns an error message returned by the compiler, if the compilation failed.
+		 *
+		 * @note	Thread safe. Only valid after core thread has initialized the program.
+		 */
+		virtual String getCompileErrorMessage() const { return mCompileError; }
+
+		/**
+		 * @brief	Sets whether this geometry program requires adjacency information
+		 *			from the input primitives.
+		 *
+		 * @note	Only relevant for geometry programs.
+		 */
+		virtual void setAdjacencyInfoRequired(bool required) { mNeedsAdjacencyInfo = required; }
+
+		/**
+		 * @brief	Returns whether this geometry program requires adjacency information
+		 *			from the input primitives.
+		 *
+		 * @note	Only relevant for geometry programs.
+		 */
+		virtual bool isAdjacencyInfoRequired() const { return mNeedsAdjacencyInfo; }
+
+		/**
+		 * @brief	Creates a new parameters object compatible with this program definition. You
+		 *			may populate the returned object with actual parameter values and bind it
+		 *			to the pipeline to render an object using those values and this program.
+		 */
+		virtual GpuParamsPtr createParameters();
+
+		/**
+		 * @brief	Returns description of all parameters in this GPU program.
+		 */
+		const GpuParamDesc& getParamDesc() const { return mParametersDesc; }
+
+		/**
+		* @brief	Language this shader was created from (e.g. HLSL, GLSL).
+		*/
+        virtual const String& getLanguage() const;
+
+		/**
+		 * @brief	Creates a new GPU program using the provided source code. If compilation fails or program is not supported
+		 *			"isCompiled" with return false, and you will be able to retrieve the error message via "getCompileErrorMessage".
+		 *
+		 * @param	source		Source code to compile the shader from.
+		 * @param	entryPoint	Name of the entry point function, e.g. "main".
+		 * @param	language	Language the source is written in, e.g. "hlsl" or "glsl".
+		 * @param	gptype		Type of the program, e.g. vertex or fragment.
+		 * @param	profile		Program profile specifying supported feature-set. Must match the type.
+		 * @param	includes	Optional includes to append to the source before compiling.
+		 * @param	requiresAdjacency	If true then adjacency information will be provided when rendering using this program.
+		 */
+		static HGpuProgram create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype,
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes = nullptr, bool requiresAdjacency = false);
+
+		/**
+		 * @copydoc	create
+		 *
+		 * @note	Internal method. For normal use call "create".
+		 */
+		static GpuProgramPtr _createPtr(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes = nullptr, bool requiresAdjacency = false);
+
+	protected:
+		friend class GpuProgramManager;
+
+		GpuProgram(const String& source, const String& entryPoint, 
+			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, 
+			bool isAdjacencyInfoRequired = false);
+
+		/**
+		 * @brief	Returns whether required capabilities for this program is supported.
+		 */
+        bool isRequiredCapabilitiesSupported() const;
+
+		/**
+		 * @copydoc Resource::calculateSize
+		 */
+		size_t calculateSize() const { return 0; } // TODO 
+
+	protected:
+		GpuProgramType mType;
+		bool mNeedsAdjacencyInfo;
+		String mEntryPoint;
+		GpuProgramProfile mProfile;
+        String mSource;
+
+		bool mIsCompiled;
+		String mCompileError;
+
+		GpuParamDesc mParametersDesc;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class GpuProgramRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
 }

+ 86 - 86
CamelotCore/Include/CmGpuProgramImportOptions.h → BansheeCore/Include/CmGpuProgramImportOptions.h

@@ -1,87 +1,87 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmImportOptions.h"
-#include "CmGpuProgram.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains import options you may use to control how is a GPU program (i.e. shader)
-	 * 			file imported.
-	 */
-	class CM_EXPORT GpuProgramImportOptions : public ImportOptions
-	{
-	public:
-		GpuProgramImportOptions();
-
-		/**
-		 * @brief	Sets the name of the GPU program entry point method (e.g. "main").
-		 */
-		void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
-
-		/**
-		 * @brief	Sets the language the GPU program is written in (e.g. HLSL9, GLSL, HLSL11).
-		 */
-		void setLanguage(const String& language) { mLanguage = language; }
-
-		/**
-		 * @brief	Sets GPU program profile. Determines minimal feature-set the GPU program
-		 * 			requires in order to function.
-		 */
-		void setProfile(GpuProgramProfile profile) { mProfile = profile; }
-
-		/**
-		 * @brief	Sets GPU program type (e.g. vertex, pixel, etc.).
-		 */
-		void setType(GpuProgramType type) { mType = type; }
-
-		/**
-		 * @brief	Sets optional GPU program include files which may be used
-		 * 			for sharing code across multiple programs.
-		 */
-		void setIncludes(const Vector<HGpuProgInclude>& includes) { mIncludes = includes; }
-
-		/**
-		 * @brief	Gets the name of the GPU program entry point method (e.g. "main").
-		 */
-		const String& getEntryPoint() const { return mEntryPoint; }
-
-		/**
-		 * @brief	Gets the language the GPU program is written in (e.g. HLSL9, GLSL, HLSL11).
-		 */
-		const String& getLanguage() const { return mLanguage; }
-
-		/**
-		 * @brief	Gets GPU program profile. Determines minimal feature-set the GPU program
-		 * 			requires in order to function.
-		 */
-		GpuProgramProfile getProfile() const { return mProfile; }
-
-		/**
-		 * @brief	Gets GPU program type (e.g. vertex, pixel, etc.).
-		 */
-		GpuProgramType getType() const { return mType; }
-
-		/**
-		 * @brief	Gets optional GPU program include files which may be used
-		 * 			for sharing code across multiple programs.
-		 */
-		const Vector<HGpuProgInclude>& getIncludes() const { return mIncludes; }
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class GpuProgramImportOptionsRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-
-	private:
-		String mEntryPoint;
-		String mLanguage;
-		GpuProgramProfile mProfile;
-		GpuProgramType mType;
-		Vector<HGpuProgInclude> mIncludes;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmImportOptions.h"
+#include "CmGpuProgram.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Contains import options you may use to control how is a GPU program (i.e. shader)
+	 * 			file imported.
+	 */
+	class BS_CORE_EXPORT GpuProgramImportOptions : public ImportOptions
+	{
+	public:
+		GpuProgramImportOptions();
+
+		/**
+		 * @brief	Sets the name of the GPU program entry point method (e.g. "main").
+		 */
+		void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
+
+		/**
+		 * @brief	Sets the language the GPU program is written in (e.g. HLSL9, GLSL, HLSL11).
+		 */
+		void setLanguage(const String& language) { mLanguage = language; }
+
+		/**
+		 * @brief	Sets GPU program profile. Determines minimal feature-set the GPU program
+		 * 			requires in order to function.
+		 */
+		void setProfile(GpuProgramProfile profile) { mProfile = profile; }
+
+		/**
+		 * @brief	Sets GPU program type (e.g. vertex, pixel, etc.).
+		 */
+		void setType(GpuProgramType type) { mType = type; }
+
+		/**
+		 * @brief	Sets optional GPU program include files which may be used
+		 * 			for sharing code across multiple programs.
+		 */
+		void setIncludes(const Vector<HGpuProgInclude>& includes) { mIncludes = includes; }
+
+		/**
+		 * @brief	Gets the name of the GPU program entry point method (e.g. "main").
+		 */
+		const String& getEntryPoint() const { return mEntryPoint; }
+
+		/**
+		 * @brief	Gets the language the GPU program is written in (e.g. HLSL9, GLSL, HLSL11).
+		 */
+		const String& getLanguage() const { return mLanguage; }
+
+		/**
+		 * @brief	Gets GPU program profile. Determines minimal feature-set the GPU program
+		 * 			requires in order to function.
+		 */
+		GpuProgramProfile getProfile() const { return mProfile; }
+
+		/**
+		 * @brief	Gets GPU program type (e.g. vertex, pixel, etc.).
+		 */
+		GpuProgramType getType() const { return mType; }
+
+		/**
+		 * @brief	Gets optional GPU program include files which may be used
+		 * 			for sharing code across multiple programs.
+		 */
+		const Vector<HGpuProgInclude>& getIncludes() const { return mIncludes; }
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class GpuProgramImportOptionsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+
+	private:
+		String mEntryPoint;
+		String mLanguage;
+		GpuProgramProfile mProfile;
+		GpuProgramType mType;
+		Vector<HGpuProgInclude> mIncludes;
+	};
 }

+ 55 - 55
CamelotCore/Include/CmGpuProgramImportOptionsRTTI.h → BansheeCore/Include/CmGpuProgramImportOptionsRTTI.h

@@ -1,56 +1,56 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmGpuProgramImportOptions.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT GpuProgramImportOptionsRTTI : public RTTIType<GpuProgramImportOptions, IReflectable, GpuProgramImportOptionsRTTI>
-	{
-	private:
-		String& getEntryPoint(GpuProgramImportOptions* obj) { return obj->mEntryPoint; }
-		void setEntryPoint(GpuProgramImportOptions* obj, String& value) { obj->mEntryPoint = value; }
-
-		String& getLanguage(GpuProgramImportOptions* obj) { return obj->mLanguage; }
-		void setLanguage(GpuProgramImportOptions* obj, String& value) { obj->mLanguage = value; }
-
-		GpuProgramProfile& getProfile(GpuProgramImportOptions* obj) { return obj->mProfile; }
-		void setProfile(GpuProgramImportOptions* obj, GpuProgramProfile& value) { obj->mProfile = value; }
-
-		GpuProgramType& getType(GpuProgramImportOptions* obj) { return obj->mType; }
-		void setType(GpuProgramImportOptions* obj, GpuProgramType& value) { obj->mType = value; }
-
-		HGpuProgInclude& getInclude(GpuProgramImportOptions* obj, UINT32 arrIdx) { return obj->mIncludes[arrIdx]; }
-		void setInclude(GpuProgramImportOptions* obj, UINT32 arrIdx, HGpuProgInclude& value) { obj->mIncludes[arrIdx] = value; }
-		UINT32 getNumIncludes(GpuProgramImportOptions* obj) { return (UINT32)obj->mIncludes.size(); }
-		void setNumIncludes(GpuProgramImportOptions* obj, UINT32 num) { obj->mIncludes.clear(); obj->mIncludes.resize(num); }
-
-	public:
-		GpuProgramImportOptionsRTTI()
-		{
-			addPlainField("mEntryPoint", 0, &GpuProgramImportOptionsRTTI::getEntryPoint, &GpuProgramImportOptionsRTTI::setEntryPoint);
-			addPlainField("mLanguage", 1, &GpuProgramImportOptionsRTTI::getLanguage, &GpuProgramImportOptionsRTTI::setLanguage);
-			addPlainField("mProfile", 2, &GpuProgramImportOptionsRTTI::getProfile, &GpuProgramImportOptionsRTTI::setProfile);
-			addPlainField("mType", 3, &GpuProgramImportOptionsRTTI::getType, &GpuProgramImportOptionsRTTI::setType);
-			addReflectableArrayField("mIncludes", 4, &GpuProgramImportOptionsRTTI::getInclude, &GpuProgramImportOptionsRTTI::getNumIncludes, 
-				&GpuProgramImportOptionsRTTI::setInclude, &GpuProgramImportOptionsRTTI::setNumIncludes);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "GpuProgramImportOptions";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_GpuProgramImportOptions;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return cm_shared_ptr<GpuProgramImportOptions, PoolAlloc>();
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmGpuProgramImportOptions.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT GpuProgramImportOptionsRTTI : public RTTIType<GpuProgramImportOptions, IReflectable, GpuProgramImportOptionsRTTI>
+	{
+	private:
+		String& getEntryPoint(GpuProgramImportOptions* obj) { return obj->mEntryPoint; }
+		void setEntryPoint(GpuProgramImportOptions* obj, String& value) { obj->mEntryPoint = value; }
+
+		String& getLanguage(GpuProgramImportOptions* obj) { return obj->mLanguage; }
+		void setLanguage(GpuProgramImportOptions* obj, String& value) { obj->mLanguage = value; }
+
+		GpuProgramProfile& getProfile(GpuProgramImportOptions* obj) { return obj->mProfile; }
+		void setProfile(GpuProgramImportOptions* obj, GpuProgramProfile& value) { obj->mProfile = value; }
+
+		GpuProgramType& getType(GpuProgramImportOptions* obj) { return obj->mType; }
+		void setType(GpuProgramImportOptions* obj, GpuProgramType& value) { obj->mType = value; }
+
+		HGpuProgInclude& getInclude(GpuProgramImportOptions* obj, UINT32 arrIdx) { return obj->mIncludes[arrIdx]; }
+		void setInclude(GpuProgramImportOptions* obj, UINT32 arrIdx, HGpuProgInclude& value) { obj->mIncludes[arrIdx] = value; }
+		UINT32 getNumIncludes(GpuProgramImportOptions* obj) { return (UINT32)obj->mIncludes.size(); }
+		void setNumIncludes(GpuProgramImportOptions* obj, UINT32 num) { obj->mIncludes.clear(); obj->mIncludes.resize(num); }
+
+	public:
+		GpuProgramImportOptionsRTTI()
+		{
+			addPlainField("mEntryPoint", 0, &GpuProgramImportOptionsRTTI::getEntryPoint, &GpuProgramImportOptionsRTTI::setEntryPoint);
+			addPlainField("mLanguage", 1, &GpuProgramImportOptionsRTTI::getLanguage, &GpuProgramImportOptionsRTTI::setLanguage);
+			addPlainField("mProfile", 2, &GpuProgramImportOptionsRTTI::getProfile, &GpuProgramImportOptionsRTTI::setProfile);
+			addPlainField("mType", 3, &GpuProgramImportOptionsRTTI::getType, &GpuProgramImportOptionsRTTI::setType);
+			addReflectableArrayField("mIncludes", 4, &GpuProgramImportOptionsRTTI::getInclude, &GpuProgramImportOptionsRTTI::getNumIncludes, 
+				&GpuProgramImportOptionsRTTI::setInclude, &GpuProgramImportOptionsRTTI::setNumIncludes);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "GpuProgramImportOptions";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GpuProgramImportOptions;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return cm_shared_ptr<GpuProgramImportOptions, PoolAlloc>();
+		}
+	};
 }

+ 26 - 26
CamelotCore/Include/CmGpuProgramImporter.h → BansheeCore/Include/CmGpuProgramImporter.h

@@ -1,27 +1,27 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmSpecificImporter.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Importer for GPU programs (i.e. shaders). File must end with ".gpuprog" extension,
-	 * 			and actual type of the program is determined via import options.
-	 */
-	class CM_EXPORT GpuProgramImporter : public SpecificImporter
-	{
-	public:
-		/** @copydoc SpecificImporter::isExtensionSupported */
-		virtual bool isExtensionSupported(const WString& ext) const;
-
-		/** @copydoc SpecificImporter::isMagicNumberSupported */
-		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
-
-		/** @copydoc SpecificImporter::import */
-		virtual ResourcePtr import(const Path& filePath, ConstImportOptionsPtr importOptions);
-
-		/** @copydoc SpecificImporter::createImportOptions */
-		virtual ImportOptionsPtr createImportOptions() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmSpecificImporter.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Importer for GPU programs (i.e. shaders). File must end with ".gpuprog" extension,
+	 * 			and actual type of the program is determined via import options.
+	 */
+	class BS_CORE_EXPORT GpuProgramImporter : public SpecificImporter
+	{
+	public:
+		/** @copydoc SpecificImporter::isExtensionSupported */
+		virtual bool isExtensionSupported(const WString& ext) const;
+
+		/** @copydoc SpecificImporter::isMagicNumberSupported */
+		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
+
+		/** @copydoc SpecificImporter::import */
+		virtual ResourcePtr import(const Path& filePath, ConstImportOptionsPtr importOptions);
+
+		/** @copydoc SpecificImporter::createImportOptions */
+		virtual ImportOptionsPtr createImportOptions() const;
+	};
 }

+ 100 - 100
CamelotCore/Include/CmGpuProgramManager.h → BansheeCore/Include/CmGpuProgramManager.h

@@ -1,101 +1,101 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmException.h"
-#include "CmGpuProgram.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Factory responsible for creating GPU programs of a certain type.
-	 */
-	class CM_EXPORT GpuProgramFactory
-	{
-	public:
-        GpuProgramFactory() {}
-        virtual ~GpuProgramFactory();
-
-		/**
-		 * @brief	Returns GPU program language this factory is capable creating GPU programs from.
-		 */
-		virtual const String& getLanguage() const = 0;
-
-		virtual GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
-			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacencyInformation) = 0;
-
-		/**
-		 * @copydoc	GpuProgramManager::createEmpty
-		 */
-		virtual GpuProgramPtr create(GpuProgramType type) = 0;
-	};
-
-	/**
-	 * @brief	Manager responsible for creating GPU programs. It will automatically
-	 *			try to find the approriate handler for a specific GPU program language
-	 *			and create the program if possible.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class CM_EXPORT GpuProgramManager : public Module<GpuProgramManager>
-	{
-	public:
-		
-	public:
-		GpuProgramManager();
-		~GpuProgramManager();
-
-		/**
-		 * @brief	Registers a new factory that is able to create GPU programs for a certain language.
-		 *			If any other factory for the same language exists, it will overwrite it.
-		 */
-		void addFactory(GpuProgramFactory* factory);
-
-		/**
-		 * @brief	Unregisters a GPU program factory, essentially making it not possible to create GPU programs
-		 *			using the language the factory supported.
-		 */
-		void removeFactory(GpuProgramFactory* factory);
-
-		/**
-		 * @brief	Query if a GPU program language is supported. (.e.g. "hlsl", "glsl").
-		 */
-		bool isLanguageSupported(const String& lang);
-
-		/**
-		 * @brief	Creates a new GPU program using the provided source code. If compilation fails or program is not supported
-		 *			"isCompiled" method on the returned program will return false, and you will be able to retrieve the error message 
-		 *			via "getCompileErrorMessage".
-		 *
-		 * @param	source		Source code to compile the shader from.
-		 * @param	entryPoint	Name of the entry point function, e.g. "main".
-		 * @param	language	Language the source is written in, e.g. "hlsl" or "glsl".
-		 * @param	gptype		Type of the program, e.g. vertex or fragment.
-		 * @param	profile		Program profile specifying supported feature-set. Must match the type.
-		 * @param	includes	Optional includes to append to the source before compiling.
-		 * @param	requiresAdjacency	If true then adjacency information will be provided when rendering using this program.
-		 */
-		GpuProgramPtr create(const String& source, const String& entryPoint, const String& language, 
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
-			bool requiresAdjacency = false);
-
-		/**
-		 * @brief	Creates a completely empty and uninitialized GpuProgram.
-		 * 			Should only be used for specific purposes, like deserialization,
-		 * 			as it requires additional manual initialization that is not required normally.
-		 */
-		GpuProgramPtr createEmpty(const String& language, GpuProgramType type);
-
-	protected:
-		/**
-		 * @brief	Attempts to find a factory for the specified language. Returns null if it cannot find one.
-		 */
-		GpuProgramFactory* getFactory(const String& language);
-
-	protected:
-		typedef Map<String, GpuProgramFactory*> FactoryMap;
-
-		FactoryMap mFactories;
-		GpuProgramFactory* mNullFactory; /**< Factory for dealing with GPU programs that can't be created. */
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmException.h"
+#include "CmGpuProgram.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Factory responsible for creating GPU programs of a certain type.
+	 */
+	class BS_CORE_EXPORT GpuProgramFactory
+	{
+	public:
+        GpuProgramFactory() {}
+        virtual ~GpuProgramFactory();
+
+		/**
+		 * @brief	Returns GPU program language this factory is capable creating GPU programs from.
+		 */
+		virtual const String& getLanguage() const = 0;
+
+		virtual GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacencyInformation) = 0;
+
+		/**
+		 * @copydoc	GpuProgramManager::createEmpty
+		 */
+		virtual GpuProgramPtr create(GpuProgramType type) = 0;
+	};
+
+	/**
+	 * @brief	Manager responsible for creating GPU programs. It will automatically
+	 *			try to find the approriate handler for a specific GPU program language
+	 *			and create the program if possible.
+	 *
+	 * @note	Sim thread only.
+	 */
+	class BS_CORE_EXPORT GpuProgramManager : public Module<GpuProgramManager>
+	{
+	public:
+		
+	public:
+		GpuProgramManager();
+		~GpuProgramManager();
+
+		/**
+		 * @brief	Registers a new factory that is able to create GPU programs for a certain language.
+		 *			If any other factory for the same language exists, it will overwrite it.
+		 */
+		void addFactory(GpuProgramFactory* factory);
+
+		/**
+		 * @brief	Unregisters a GPU program factory, essentially making it not possible to create GPU programs
+		 *			using the language the factory supported.
+		 */
+		void removeFactory(GpuProgramFactory* factory);
+
+		/**
+		 * @brief	Query if a GPU program language is supported. (.e.g. "hlsl", "glsl").
+		 */
+		bool isLanguageSupported(const String& lang);
+
+		/**
+		 * @brief	Creates a new GPU program using the provided source code. If compilation fails or program is not supported
+		 *			"isCompiled" method on the returned program will return false, and you will be able to retrieve the error message 
+		 *			via "getCompileErrorMessage".
+		 *
+		 * @param	source		Source code to compile the shader from.
+		 * @param	entryPoint	Name of the entry point function, e.g. "main".
+		 * @param	language	Language the source is written in, e.g. "hlsl" or "glsl".
+		 * @param	gptype		Type of the program, e.g. vertex or fragment.
+		 * @param	profile		Program profile specifying supported feature-set. Must match the type.
+		 * @param	includes	Optional includes to append to the source before compiling.
+		 * @param	requiresAdjacency	If true then adjacency information will be provided when rendering using this program.
+		 */
+		GpuProgramPtr create(const String& source, const String& entryPoint, const String& language, 
+			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool requiresAdjacency = false);
+
+		/**
+		 * @brief	Creates a completely empty and uninitialized GpuProgram.
+		 * 			Should only be used for specific purposes, like deserialization,
+		 * 			as it requires additional manual initialization that is not required normally.
+		 */
+		GpuProgramPtr createEmpty(const String& language, GpuProgramType type);
+
+	protected:
+		/**
+		 * @brief	Attempts to find a factory for the specified language. Returns null if it cannot find one.
+		 */
+		GpuProgramFactory* getFactory(const String& language);
+
+	protected:
+		typedef Map<String, GpuProgramFactory*> FactoryMap;
+
+		FactoryMap mFactories;
+		GpuProgramFactory* mNullFactory; /**< Factory for dealing with GPU programs that can't be created. */
+	};
 }

+ 53 - 53
CamelotCore/Include/CmGpuProgramRTTI.h → BansheeCore/Include/CmGpuProgramRTTI.h

@@ -1,54 +1,54 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmGpuProgram.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT GpuProgramRTTI : public RTTIType<GpuProgram, Resource, GpuProgramRTTI>
-	{
-	private:
-		CM_SETGET_MEMBER(mSize, UINT32, GpuProgram)
-
-		CM_SETGET_MEMBER(mType, GpuProgramType, GpuProgram);
-		CM_SETGET_MEMBER(mNeedsAdjacencyInfo, bool, GpuProgram);
-		CM_SETGET_MEMBER(mEntryPoint, String, GpuProgram);
-		CM_SETGET_MEMBER(mProfile, GpuProgramProfile, GpuProgram);
-		CM_SETGET_MEMBER(mSource, String, GpuProgram);
-
-	public:
-		GpuProgramRTTI()
-		{
-			CM_ADD_PLAINFIELD(mSize, 0, GpuProgramRTTI)
-
-			CM_ADD_PLAINFIELD(mType, 2, GpuProgramRTTI)
-			CM_ADD_PLAINFIELD(mNeedsAdjacencyInfo, 3, GpuProgramRTTI)
-			CM_ADD_PLAINFIELD(mEntryPoint, 4, GpuProgramRTTI)
-			CM_ADD_PLAINFIELD(mProfile, 5, GpuProgramRTTI)
-			CM_ADD_PLAINFIELD(mSource, 6, GpuProgramRTTI)
-		}
-
-		virtual void onDeserializationEnded(IReflectable* obj)
-		{
-			GpuProgram* gpuProgram = static_cast<GpuProgram*>(obj);
-			gpuProgram->initialize();
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "GpuProgram";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_GpuProgram;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			CM_EXCEPT(InternalErrorException, "Cannot instantiate abstract class!"); // TODO - Need to initialize this properly
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmGpuProgram.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT GpuProgramRTTI : public RTTIType<GpuProgram, Resource, GpuProgramRTTI>
+	{
+	private:
+		CM_SETGET_MEMBER(mSize, UINT32, GpuProgram)
+
+		CM_SETGET_MEMBER(mType, GpuProgramType, GpuProgram);
+		CM_SETGET_MEMBER(mNeedsAdjacencyInfo, bool, GpuProgram);
+		CM_SETGET_MEMBER(mEntryPoint, String, GpuProgram);
+		CM_SETGET_MEMBER(mProfile, GpuProgramProfile, GpuProgram);
+		CM_SETGET_MEMBER(mSource, String, GpuProgram);
+
+	public:
+		GpuProgramRTTI()
+		{
+			CM_ADD_PLAINFIELD(mSize, 0, GpuProgramRTTI)
+
+			CM_ADD_PLAINFIELD(mType, 2, GpuProgramRTTI)
+			CM_ADD_PLAINFIELD(mNeedsAdjacencyInfo, 3, GpuProgramRTTI)
+			CM_ADD_PLAINFIELD(mEntryPoint, 4, GpuProgramRTTI)
+			CM_ADD_PLAINFIELD(mProfile, 5, GpuProgramRTTI)
+			CM_ADD_PLAINFIELD(mSource, 6, GpuProgramRTTI)
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj)
+		{
+			GpuProgram* gpuProgram = static_cast<GpuProgram*>(obj);
+			gpuProgram->initialize();
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "GpuProgram";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GpuProgram;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			CM_EXCEPT(InternalErrorException, "Cannot instantiate abstract class!"); // TODO - Need to initialize this properly
+		}
+	};
 }

+ 42 - 42
CamelotCore/Include/CmGpuResource.h → BansheeCore/Include/CmGpuResource.h

@@ -1,43 +1,43 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmResource.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Represents a resource that in some way deals directly with the rendering
-	 *			API and the GPU.
-	 *
-	 * @note	e.g. texture, mesh, buffer, etc.
-	 */
-	class CM_EXPORT GpuResource : public Resource
-	{
-	public:
-		/**
-		 * @brief	Updates a part of the current resource with the provided data. Specific resource
-		 * 			implementations provide a way to retrieve a subresource index.
-		 * 			
-		 * @note	Core thread only.
-		 */
-		virtual void writeSubresource(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer) = 0;
-
-		/**
-		 * @brief	Reads a part of the current resource into the provided "data" parameter.
-		 * 			Data buffer needs to be pre-allocated. Specific resource implementations 
-		 * 			provide a way to retrieve a subresource index and a way to allocate
-		 * 			the GpuResourceData buffer.
-		 * 			
-		 * @note	Core thread only.
-		 */
-		virtual void readSubresource(UINT32 subresourceIdx, GpuResourceData& data) = 0;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class GpuResourceRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmResource.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Represents a resource that in some way deals directly with the rendering
+	 *			API and the GPU.
+	 *
+	 * @note	e.g. texture, mesh, buffer, etc.
+	 */
+	class BS_CORE_EXPORT GpuResource : public Resource
+	{
+	public:
+		/**
+		 * @brief	Updates a part of the current resource with the provided data. Specific resource
+		 * 			implementations provide a way to retrieve a subresource index.
+		 * 			
+		 * @note	Core thread only.
+		 */
+		virtual void writeSubresource(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer) = 0;
+
+		/**
+		 * @brief	Reads a part of the current resource into the provided "data" parameter.
+		 * 			Data buffer needs to be pre-allocated. Specific resource implementations 
+		 * 			provide a way to retrieve a subresource index and a way to allocate
+		 * 			the GpuResourceData buffer.
+		 * 			
+		 * @note	Core thread only.
+		 */
+		virtual void readSubresource(UINT32 subresourceIdx, GpuResourceData& data) = 0;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class GpuResourceRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
 }

+ 99 - 99
CamelotCore/Include/CmGpuResourceData.h → BansheeCore/Include/CmGpuResourceData.h

@@ -1,100 +1,100 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	You can use this class as a storage for reading and writing from/to various GPU resources. 
-	 *			It is meant to be created on sim thread and used on the core thread. This class is abstract
-	 *			and specific resource types need to implement their own type of GpuResourceData.
-	 * 			
-	 * @note	Normal use of this class involves requesting an instance of GpuResourceData from a GpuResource,
-	 *			then scheduling a read or write on that resource using the provided instance.
-	 *			Instance will be locked while it is used by the core thread and sim thread will be allowed to
-	 *			access it when the operation ends. Caller can track AsyncOps regarding the read/write operation
-	 *			to be notified when it is complete.
-	 *
-	 *			If you allocate an internal buffer to store the resource data, the ownership of the buffer
-	 * 			will always remain with the initial instance of the class. If that initial instance
-	 * 			is deleted, any potential copies will point to garbage data.
-	 */
-	class CM_EXPORT GpuResourceData : public IReflectable
-	{
-	public:
-		GpuResourceData();
-		GpuResourceData(const GpuResourceData& copy);
-		virtual ~GpuResourceData();
-
-		GpuResourceData& operator=(const GpuResourceData& rhs);
-
-		/**
-		 * @brief	Returns pointer to the internal buffer.
-		 */
-		UINT8* getData() const;
-
-		/**
-		 * @brief	Allocates an internal buffer of a certain size. If there is another
-		 * 			buffer already allocated, it will be freed and new one will be allocated.
-		 * 			Buffer size is determined based on parameters used for initializing the class.
-		 */
-		void allocateInternalBuffer();
-
-		/**
-		 * @brief	Allocates an internal buffer of a certain size. If there is another
-		 * 			buffer already allocated, it will be freed and new one will be allocated.
-		 *
-		 * @param	size	The size of the buffer in bytes.
-		 */
-		void allocateInternalBuffer(UINT32 size);
-
-		/**
-		 * @brief	Frees the internal buffer that was allocated using "allocateInternal". Called automatically
-		 * 			when the instance of the class is destroyed.
-		 */
-		void freeInternalBuffer();
-
-		/**
-		 * @brief	Makes the internal data pointer point to some external data. No copying is done, 
-		 * 			so you must ensure that external data exists as long as this class uses it. You are also
-		 * 			responsible for deleting the data when you are done with it.
-		 *
-		 * @note	If any internal data is allocated, it is freed.
-		 */
-		void setExternalBuffer(UINT8* data);
-
-		/**
-		 * @brief	Locks the data and makes it available only to the core thread. 
-		 *
-		 * @note	Internal method.
-		 */
-		void _lock() const;
-
-		/**
-		 * @brief	Unlocks the data and makes it available to all threads. 
-		 *
-		 * @note	Internal method.
-		 */
-		void _unlock() const;
-
-	protected:
-		/**
-		 * @brief	Returns the size of the internal buffer in bytes. This is calculated based
-		 *			on parameters provided upon construction and specific implementation details.
-		 */
-		virtual UINT32 getInternalBufferSize() = 0;
-
-	private:
-		UINT8* mData;
-		bool mOwnsData;
-		mutable bool mLocked;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class GpuResourceDataRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	You can use this class as a storage for reading and writing from/to various GPU resources. 
+	 *			It is meant to be created on sim thread and used on the core thread. This class is abstract
+	 *			and specific resource types need to implement their own type of GpuResourceData.
+	 * 			
+	 * @note	Normal use of this class involves requesting an instance of GpuResourceData from a GpuResource,
+	 *			then scheduling a read or write on that resource using the provided instance.
+	 *			Instance will be locked while it is used by the core thread and sim thread will be allowed to
+	 *			access it when the operation ends. Caller can track AsyncOps regarding the read/write operation
+	 *			to be notified when it is complete.
+	 *
+	 *			If you allocate an internal buffer to store the resource data, the ownership of the buffer
+	 * 			will always remain with the initial instance of the class. If that initial instance
+	 * 			is deleted, any potential copies will point to garbage data.
+	 */
+	class BS_CORE_EXPORT GpuResourceData : public IReflectable
+	{
+	public:
+		GpuResourceData();
+		GpuResourceData(const GpuResourceData& copy);
+		virtual ~GpuResourceData();
+
+		GpuResourceData& operator=(const GpuResourceData& rhs);
+
+		/**
+		 * @brief	Returns pointer to the internal buffer.
+		 */
+		UINT8* getData() const;
+
+		/**
+		 * @brief	Allocates an internal buffer of a certain size. If there is another
+		 * 			buffer already allocated, it will be freed and new one will be allocated.
+		 * 			Buffer size is determined based on parameters used for initializing the class.
+		 */
+		void allocateInternalBuffer();
+
+		/**
+		 * @brief	Allocates an internal buffer of a certain size. If there is another
+		 * 			buffer already allocated, it will be freed and new one will be allocated.
+		 *
+		 * @param	size	The size of the buffer in bytes.
+		 */
+		void allocateInternalBuffer(UINT32 size);
+
+		/**
+		 * @brief	Frees the internal buffer that was allocated using "allocateInternal". Called automatically
+		 * 			when the instance of the class is destroyed.
+		 */
+		void freeInternalBuffer();
+
+		/**
+		 * @brief	Makes the internal data pointer point to some external data. No copying is done, 
+		 * 			so you must ensure that external data exists as long as this class uses it. You are also
+		 * 			responsible for deleting the data when you are done with it.
+		 *
+		 * @note	If any internal data is allocated, it is freed.
+		 */
+		void setExternalBuffer(UINT8* data);
+
+		/**
+		 * @brief	Locks the data and makes it available only to the core thread. 
+		 *
+		 * @note	Internal method.
+		 */
+		void _lock() const;
+
+		/**
+		 * @brief	Unlocks the data and makes it available to all threads. 
+		 *
+		 * @note	Internal method.
+		 */
+		void _unlock() const;
+
+	protected:
+		/**
+		 * @brief	Returns the size of the internal buffer in bytes. This is calculated based
+		 *			on parameters provided upon construction and specific implementation details.
+		 */
+		virtual UINT32 getInternalBufferSize() = 0;
+
+	private:
+		UINT8* mData;
+		bool mOwnsData;
+		mutable bool mLocked;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class GpuResourceDataRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
 }

+ 32 - 32
CamelotCore/Include/CmGpuResourceDataRTTI.h → BansheeCore/Include/CmGpuResourceDataRTTI.h

@@ -1,33 +1,33 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmGpuResourceData.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT GpuResourceDataRTTI : public RTTIType<GpuResourceData, IReflectable, GpuResourceDataRTTI>
-	{
-	public:
-		GpuResourceDataRTTI()
-		{
-
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "GpuResourceData";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_GpuResourceData;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmGpuResourceData.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT GpuResourceDataRTTI : public RTTIType<GpuResourceData, IReflectable, GpuResourceDataRTTI>
+	{
+	public:
+		GpuResourceDataRTTI()
+		{
+
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "GpuResourceData";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GpuResourceData;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
+		}
+	};
 }

+ 32 - 32
CamelotCore/Include/CmGpuResourceRTTI.h → BansheeCore/Include/CmGpuResourceRTTI.h

@@ -1,33 +1,33 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmGpuResource.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT GpuResourceRTTI : public RTTIType<GpuResource, Resource, GpuResourceRTTI>
-	{
-	public:
-		GpuResourceRTTI()
-		{
-
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "GpuResource";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_GpuResource;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmGpuResource.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT GpuResourceRTTI : public RTTIType<GpuResource, Resource, GpuResourceRTTI>
+	{
+	public:
+		GpuResourceRTTI()
+		{
+
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "GpuResource";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GpuResource;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
+		}
+	};
 }

+ 173 - 173
CamelotCore/Include/CmHardwareBuffer.h → BansheeCore/Include/CmHardwareBuffer.h

@@ -1,173 +1,173 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Abstract class defining common features of hardware buffers. Hardware buffers usually
-	 *			represent areas of memory the GPU or the driver can access directly.
-	 *
-	 * @note	Be aware that reading from non-system memory hardware buffers is usually slow and should be avoided.
-	 */
-	class CM_EXPORT HardwareBuffer
-    {
-    public:
-        virtual ~HardwareBuffer() {}
-
-		/**
-		 * @brief	Locks a portion of the buffer and returns pointer to the locked area.
-		 *			You must call "unlock" when done.
-		 *
-		 * @param	offset	Offset in bytes from which to lock the buffer.
-		 * @param	length	Length of the area you want to lock, in bytes.
-		 * @param	options	Signifies what you want to do with the returned pointer.
-		 *					Caller must ensure not to do anything he hasn't requested.
-		 *					(e.g. don't try to read from the buffer unless you requested
-		 *					it here).
-		 */
-		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options)
-        {
-            assert(!isLocked() && "Cannot lock this buffer, it is already locked!");
-            void* ret = lockImpl(offset, length, options);
-            mIsLocked = true;
-
-			mLockStart = offset;
-			mLockSize = length;
-            return ret;
-        }
-
-		/**
-		 * @brief	Locks the entire buffer and returns pointer to the locked area.
-		 *			You must call "unlock" when done.
-		 *
-		 * @param	options	Signifies what you want to do with the returned pointer.
-		 *					Caller must ensure not to do anything he hasn't requested.
-		 *					(e.g. don't try to read from the buffer unless you requested
-		 *					it here).
-		 */
-        void* lock(GpuLockOptions options)
-        {
-            return this->lock(0, mSizeInBytes, options);
-        }
-
-		/**
-		 * @brief	Releases the lock on this buffer. 
-		 */
-		virtual void unlock()
-        {
-            assert(isLocked() && "Cannot unlock this buffer, it is not locked!");
-
-            unlockImpl();
-            mIsLocked = false;
-        }
-
-		/**
-		 * @brief	Reads data from a portion of the buffer and copies it to the destination
-		 *			buffer. Caller must ensure destination buffer is large enough.
-		 *
-		 * @param	offset	Offset in bytes from which to copy the data.
-		 * @param	length	Length of the area you want to copy, in bytes.
-		 * @param	dest	Destination buffer large enough to store the read data.
-		 */
-        virtual void readData(UINT32 offset, UINT32 length, void* dest) = 0;
-
-		/**
-		 * @brief	Writes data into a portion of the buffer from the source memory. 
-		 *
-		 * @param	offset		Offset in bytes from which to copy the data.
-		 * @param	length		Length of the area you want to copy, in bytes.
-		 * @param	source		Source buffer containing the data to write.
-		 * @param	writeFlags	Optional write flags that may affect performance.
-		 */
-        virtual void writeData(UINT32 offset, UINT32 length, const void* source,
-				BufferWriteType writeFlags = BufferWriteType::Normal) = 0;
-
-		/**
-		 * @brief	Copies data from a specific portion of the source buffer into a specific portion
-		 *			of this buffer.
-		 *
-		 * @param	srcBuffer			Buffer to copy from.
-		 * @param	srcOffset			Offset into the source buffer to start copying from, in bytes.
-		 * @param	dstOffset			Offset into this buffer to start copying to, in bytes.
-		 * @param	length				Size of the data to copy, in bytes.
-		 * @param	discardWholeBuffer	Specify true if the data in the current buffer can be entirely discarded. This
-		 *								may improve performance.
-		 */
-		virtual void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 
-			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false)
-		{
-			const void *srcData = srcBuffer.lock(
-				srcOffset, length, GBL_READ_ONLY);
-			this->writeData(dstOffset, length, srcData, discardWholeBuffer ? BufferWriteType::Discard : BufferWriteType::Normal);
-			srcBuffer.unlock();
-		}
-
-		/**
-		 * @brief	Copy data from the provided buffer into this buffer. If buffers
-		 *			are not the same size, smaller size will be used.
-		 */
-		virtual void copyData(HardwareBuffer& srcBuffer)
-		{
-			UINT32 sz = std::min(getSizeInBytes(), srcBuffer.getSizeInBytes()); 
-			copyData(srcBuffer, 0, 0, sz, true);
-		}
-			
-		/**
-		 * @brief	Returns the size of this buffer in bytes.
-		 */
-        UINT32 getSizeInBytes(void) const { return mSizeInBytes; }
-
-		/**
-		 * @brief	Returns the Usage flags with which this buffer was created.
-		 */
-        GpuBufferUsage getUsage() const { return mUsage; }
-
-		/**
-		 * @brief	Returns whether this buffer is held in system memory.
-		 */
-		bool isSystemMemory() const { return mSystemMemory; }
-
-		/**
-		 * @brief	Returns whether or not this buffer is currently locked.
-		 */
-        bool isLocked() const { return mIsLocked; }	
-
-	protected:
-		friend class HardwareBufferManager;
-
-		/**
-		 * @brief	Constructs a new buffer.
-		 *
-		 * @param	usage			Determines most common usage of the buffer. Usually has effect on what
-		 *							type of memory will be buffer allocated in but that depends on render API.
-		 *							Specify dynamic if you plan on modifying it often, static otherwise.
-		 * @param	systemMemory	If enabled the the buffer will be kept in the system memory. System memory
-		 *							buffers are often used as a source or destination for copies from/to other
-		 *							buffers. Some APIs don't allow reading from non-system memory buffers.
-		 */
-		HardwareBuffer(GpuBufferUsage usage, bool systemMemory)
-			: mUsage(usage), mIsLocked(false), mSystemMemory(systemMemory)
-		{  }
-
-		/**
-		 * @copydoc	lock
-		 */
-		virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
-
-		/**
-		 * @copydoc	unlock
-		 */
-		virtual void unlockImpl() = 0;
-
-	protected:
-		UINT32 mSizeInBytes;
-		GpuBufferUsage mUsage;
-		bool mIsLocked;
-		UINT32 mLockStart;
-		UINT32 mLockSize;
-		bool mSystemMemory;
-    };
-}
-
-
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Abstract class defining common features of hardware buffers. Hardware buffers usually
+	 *			represent areas of memory the GPU or the driver can access directly.
+	 *
+	 * @note	Be aware that reading from non-system memory hardware buffers is usually slow and should be avoided.
+	 */
+	class BS_CORE_EXPORT HardwareBuffer
+    {
+    public:
+        virtual ~HardwareBuffer() {}
+
+		/**
+		 * @brief	Locks a portion of the buffer and returns pointer to the locked area.
+		 *			You must call "unlock" when done.
+		 *
+		 * @param	offset	Offset in bytes from which to lock the buffer.
+		 * @param	length	Length of the area you want to lock, in bytes.
+		 * @param	options	Signifies what you want to do with the returned pointer.
+		 *					Caller must ensure not to do anything he hasn't requested.
+		 *					(e.g. don't try to read from the buffer unless you requested
+		 *					it here).
+		 */
+		virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options)
+        {
+            assert(!isLocked() && "Cannot lock this buffer, it is already locked!");
+            void* ret = lockImpl(offset, length, options);
+            mIsLocked = true;
+
+			mLockStart = offset;
+			mLockSize = length;
+            return ret;
+        }
+
+		/**
+		 * @brief	Locks the entire buffer and returns pointer to the locked area.
+		 *			You must call "unlock" when done.
+		 *
+		 * @param	options	Signifies what you want to do with the returned pointer.
+		 *					Caller must ensure not to do anything he hasn't requested.
+		 *					(e.g. don't try to read from the buffer unless you requested
+		 *					it here).
+		 */
+        void* lock(GpuLockOptions options)
+        {
+            return this->lock(0, mSizeInBytes, options);
+        }
+
+		/**
+		 * @brief	Releases the lock on this buffer. 
+		 */
+		virtual void unlock()
+        {
+            assert(isLocked() && "Cannot unlock this buffer, it is not locked!");
+
+            unlockImpl();
+            mIsLocked = false;
+        }
+
+		/**
+		 * @brief	Reads data from a portion of the buffer and copies it to the destination
+		 *			buffer. Caller must ensure destination buffer is large enough.
+		 *
+		 * @param	offset	Offset in bytes from which to copy the data.
+		 * @param	length	Length of the area you want to copy, in bytes.
+		 * @param	dest	Destination buffer large enough to store the read data.
+		 */
+        virtual void readData(UINT32 offset, UINT32 length, void* dest) = 0;
+
+		/**
+		 * @brief	Writes data into a portion of the buffer from the source memory. 
+		 *
+		 * @param	offset		Offset in bytes from which to copy the data.
+		 * @param	length		Length of the area you want to copy, in bytes.
+		 * @param	source		Source buffer containing the data to write.
+		 * @param	writeFlags	Optional write flags that may affect performance.
+		 */
+        virtual void writeData(UINT32 offset, UINT32 length, const void* source,
+				BufferWriteType writeFlags = BufferWriteType::Normal) = 0;
+
+		/**
+		 * @brief	Copies data from a specific portion of the source buffer into a specific portion
+		 *			of this buffer.
+		 *
+		 * @param	srcBuffer			Buffer to copy from.
+		 * @param	srcOffset			Offset into the source buffer to start copying from, in bytes.
+		 * @param	dstOffset			Offset into this buffer to start copying to, in bytes.
+		 * @param	length				Size of the data to copy, in bytes.
+		 * @param	discardWholeBuffer	Specify true if the data in the current buffer can be entirely discarded. This
+		 *								may improve performance.
+		 */
+		virtual void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, 
+			UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false)
+		{
+			const void *srcData = srcBuffer.lock(
+				srcOffset, length, GBL_READ_ONLY);
+			this->writeData(dstOffset, length, srcData, discardWholeBuffer ? BufferWriteType::Discard : BufferWriteType::Normal);
+			srcBuffer.unlock();
+		}
+
+		/**
+		 * @brief	Copy data from the provided buffer into this buffer. If buffers
+		 *			are not the same size, smaller size will be used.
+		 */
+		virtual void copyData(HardwareBuffer& srcBuffer)
+		{
+			UINT32 sz = std::min(getSizeInBytes(), srcBuffer.getSizeInBytes()); 
+			copyData(srcBuffer, 0, 0, sz, true);
+		}
+			
+		/**
+		 * @brief	Returns the size of this buffer in bytes.
+		 */
+        UINT32 getSizeInBytes(void) const { return mSizeInBytes; }
+
+		/**
+		 * @brief	Returns the Usage flags with which this buffer was created.
+		 */
+        GpuBufferUsage getUsage() const { return mUsage; }
+
+		/**
+		 * @brief	Returns whether this buffer is held in system memory.
+		 */
+		bool isSystemMemory() const { return mSystemMemory; }
+
+		/**
+		 * @brief	Returns whether or not this buffer is currently locked.
+		 */
+        bool isLocked() const { return mIsLocked; }	
+
+	protected:
+		friend class HardwareBufferManager;
+
+		/**
+		 * @brief	Constructs a new buffer.
+		 *
+		 * @param	usage			Determines most common usage of the buffer. Usually has effect on what
+		 *							type of memory will be buffer allocated in but that depends on render API.
+		 *							Specify dynamic if you plan on modifying it often, static otherwise.
+		 * @param	systemMemory	If enabled the the buffer will be kept in the system memory. System memory
+		 *							buffers are often used as a source or destination for copies from/to other
+		 *							buffers. Some APIs don't allow reading from non-system memory buffers.
+		 */
+		HardwareBuffer(GpuBufferUsage usage, bool systemMemory)
+			: mUsage(usage), mIsLocked(false), mSystemMemory(systemMemory)
+		{  }
+
+		/**
+		 * @copydoc	lock
+		 */
+		virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options) = 0;
+
+		/**
+		 * @copydoc	unlock
+		 */
+		virtual void unlockImpl() = 0;
+
+	protected:
+		UINT32 mSizeInBytes;
+		GpuBufferUsage mUsage;
+		bool mIsLocked;
+		UINT32 mLockStart;
+		UINT32 mLockSize;
+		bool mSystemMemory;
+    };
+}
+
+

+ 107 - 107
CamelotCore/Include/CmHardwareBufferManager.h → BansheeCore/Include/CmHardwareBufferManager.h

@@ -1,107 +1,107 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmVertexBuffer.h"
-#include "CmIndexBuffer.h"
-#include "CmVertexDeclaration.h"
-#include "CmGpuParamBlock.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Handles creation of various hardware buffers.
-	 *
-	 * @note	Thread safe.
-	 */
-	class CM_EXPORT HardwareBufferManager : public Module<HardwareBufferManager>
-	{
-    public:
-        HardwareBufferManager();
-        virtual ~HardwareBufferManager();
-
-		/**
-		 * @brief	Creates a new vertex buffer used for holding number of vertices and other
-		 *			per-vertex data. Buffer can be bound to the pipeline and its data can
-		 *			be passed to the active vertex GPU program.
-		 *
-		 * @param	vertexSize	Size of a single vertex in the buffer, in bytes.
-		 * @param	numVerts	Number of vertices the buffer can hold.
-		 * @param	usage		Usage that tells the hardware how will be buffer be used. 
-		 * @param	streamOut	If true the buffer will be usable for streaming out data from the GPU.
-		 */
-		virtual VertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
-
-		/**
-		 * @brief	Creates a new index buffer that holds indices referencing vertices in a vertex buffer.
-		 *			Indices are interpreted by the pipeline and vertices are drawn in the order specified in
-		 *			the index buffer.
-		 *
-		 * @param	itype		Index type, determines size of an index.
-		 * @param	numIndexes	Number of indexes can buffer can hold.
-		 * @param	usage		Usage that tells the hardware how will be buffer be used. 
-		 */
-		virtual IndexBufferPtr createIndexBuffer(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
-
-		/**
-		 * @brief	Creates an GPU parameter block that you can use for setting parameters for GPU programs.
-		 *			Parameter blocks may be used for sharing parameter data between multiple GPU programs, requiring
-		 *			you to update only one buffer for all of them, potentially improving performance.
-		 *
-		 * @param	size	Size of the parameter buffer in bytes.
-		 * @param	usage	Usage that tells the hardware how will be buffer be used. 
-		 */
-		virtual GpuParamBlockBufferPtr createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
-
-		/**
-		 * @brief	Creates a generic buffer that can be passed as a parameter to a shader. This type of buffer can hold
-		 *			various type of data and can be used for various purposes. See "GpuBufferType" for explanation of
-		 *			different buffer types.
-		 *
-		 * @param	elementCount  	Number of elements in the buffer. 
-		 * @param	elementSize   	Size of each individual element in the buffer, in bytes.
-		 * @param	type		  	Type of the buffer.
-		 * @param	usage		  	Usage that tells the hardware how will be buffer be used. 
-		 * @param	randomGpuWrite	(optional) Allows the GPU to write to the resource.
-		 * @param	useCounter	  	(optional) Binds a counter that can be used from a GPU program on the buffer.
-		 *
-		 * @note	Be aware that due to some render API restrictions some of these settings cannot be used together, 
-		 *			and if so you will receive an assert in debug mode.
-		 */
-		virtual GpuBufferPtr createGpuBuffer(UINT32 elementCount, UINT32 elementSize, 
-			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
-
-		/**
-		 * @brief	Creates a new vertex declaration from a list of vertex elements.
-		 */
-		virtual VertexDeclarationPtr createVertexDeclaration(const VertexDeclaration::VertexElementList& elements);
-
-	protected:
-		/**
-		 * @copydoc	createVertexBuffer
-		 */
-		virtual VertexBufferPtr createVertexBufferImpl(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) = 0;
-
-		/**
-		 * @copydoc	createIndexBuffer
-		 */
-		virtual IndexBufferPtr createIndexBufferImpl(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) = 0;
-
-		/**
-		 * @copydoc	createGpuParamBlockBuffer
-		 */
-		virtual GpuParamBlockBufferPtr createGpuParamBlockBufferImpl() = 0;
-
-		/**
-		 * @copydoc	createGpuBuffer
-		 */
-		virtual GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, 
-			bool randomGpuWrite = false, bool useCounter = false) = 0;
-
-		/**
-		 * @copydoc	createVertexDeclaration
-		 */
-		virtual VertexDeclarationPtr createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements);
-	};
-}
-
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmVertexBuffer.h"
+#include "CmIndexBuffer.h"
+#include "CmVertexDeclaration.h"
+#include "CmGpuParamBlock.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Handles creation of various hardware buffers.
+	 *
+	 * @note	Thread safe.
+	 */
+	class BS_CORE_EXPORT HardwareBufferManager : public Module<HardwareBufferManager>
+	{
+    public:
+        HardwareBufferManager();
+        virtual ~HardwareBufferManager();
+
+		/**
+		 * @brief	Creates a new vertex buffer used for holding number of vertices and other
+		 *			per-vertex data. Buffer can be bound to the pipeline and its data can
+		 *			be passed to the active vertex GPU program.
+		 *
+		 * @param	vertexSize	Size of a single vertex in the buffer, in bytes.
+		 * @param	numVerts	Number of vertices the buffer can hold.
+		 * @param	usage		Usage that tells the hardware how will be buffer be used. 
+		 * @param	streamOut	If true the buffer will be usable for streaming out data from the GPU.
+		 */
+		virtual VertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
+
+		/**
+		 * @brief	Creates a new index buffer that holds indices referencing vertices in a vertex buffer.
+		 *			Indices are interpreted by the pipeline and vertices are drawn in the order specified in
+		 *			the index buffer.
+		 *
+		 * @param	itype		Index type, determines size of an index.
+		 * @param	numIndexes	Number of indexes can buffer can hold.
+		 * @param	usage		Usage that tells the hardware how will be buffer be used. 
+		 */
+		virtual IndexBufferPtr createIndexBuffer(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
+
+		/**
+		 * @brief	Creates an GPU parameter block that you can use for setting parameters for GPU programs.
+		 *			Parameter blocks may be used for sharing parameter data between multiple GPU programs, requiring
+		 *			you to update only one buffer for all of them, potentially improving performance.
+		 *
+		 * @param	size	Size of the parameter buffer in bytes.
+		 * @param	usage	Usage that tells the hardware how will be buffer be used. 
+		 */
+		virtual GpuParamBlockBufferPtr createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
+
+		/**
+		 * @brief	Creates a generic buffer that can be passed as a parameter to a shader. This type of buffer can hold
+		 *			various type of data and can be used for various purposes. See "GpuBufferType" for explanation of
+		 *			different buffer types.
+		 *
+		 * @param	elementCount  	Number of elements in the buffer. 
+		 * @param	elementSize   	Size of each individual element in the buffer, in bytes.
+		 * @param	type		  	Type of the buffer.
+		 * @param	usage		  	Usage that tells the hardware how will be buffer be used. 
+		 * @param	randomGpuWrite	(optional) Allows the GPU to write to the resource.
+		 * @param	useCounter	  	(optional) Binds a counter that can be used from a GPU program on the buffer.
+		 *
+		 * @note	Be aware that due to some render API restrictions some of these settings cannot be used together, 
+		 *			and if so you will receive an assert in debug mode.
+		 */
+		virtual GpuBufferPtr createGpuBuffer(UINT32 elementCount, UINT32 elementSize, 
+			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
+
+		/**
+		 * @brief	Creates a new vertex declaration from a list of vertex elements.
+		 */
+		virtual VertexDeclarationPtr createVertexDeclaration(const VertexDeclaration::VertexElementList& elements);
+
+	protected:
+		/**
+		 * @copydoc	createVertexBuffer
+		 */
+		virtual VertexBufferPtr createVertexBufferImpl(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) = 0;
+
+		/**
+		 * @copydoc	createIndexBuffer
+		 */
+		virtual IndexBufferPtr createIndexBufferImpl(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) = 0;
+
+		/**
+		 * @copydoc	createGpuParamBlockBuffer
+		 */
+		virtual GpuParamBlockBufferPtr createGpuParamBlockBufferImpl() = 0;
+
+		/**
+		 * @copydoc	createGpuBuffer
+		 */
+		virtual GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, 
+			bool randomGpuWrite = false, bool useCounter = false) = 0;
+
+		/**
+		 * @copydoc	createVertexDeclaration
+		 */
+		virtual VertexDeclarationPtr createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements);
+	};
+}
+

+ 24 - 24
CamelotCore/Include/CmImportOptions.h → BansheeCore/Include/CmImportOptions.h

@@ -1,25 +1,25 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmIReflectable.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Base class for creating import options from. Import options
-	 *			are specific for each importer and control how is data imported.
-	 */
-	class CM_EXPORT ImportOptions : public IReflectable
-	{
-	public:
-		virtual ~ImportOptions() {}
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class ImportOptionsRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmIReflectable.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Base class for creating import options from. Import options
+	 *			are specific for each importer and control how is data imported.
+	 */
+	class BS_CORE_EXPORT ImportOptions : public IReflectable
+	{
+	public:
+		virtual ~ImportOptions() {}
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class ImportOptionsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
 }

+ 31 - 31
CamelotCore/Include/CmImportOptionsRTTI.h → BansheeCore/Include/CmImportOptionsRTTI.h

@@ -1,32 +1,32 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmImportOptions.h"
-#include "CmRTTIType.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT ImportOptionsRTTI : public RTTIType<ImportOptions, IReflectable, ImportOptionsRTTI>
-	{
-	public:
-		ImportOptionsRTTI()
-		{
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "ImportOptions";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_ImportOptions;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return cm_shared_ptr<ImportOptions, PoolAlloc>();
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmImportOptions.h"
+#include "CmRTTIType.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT ImportOptionsRTTI : public RTTIType<ImportOptions, IReflectable, ImportOptionsRTTI>
+	{
+	public:
+		ImportOptionsRTTI()
+		{
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "ImportOptions";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_ImportOptions;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return cm_shared_ptr<ImportOptions, PoolAlloc>();
+		}
+	};
 }

+ 88 - 88
CamelotCore/Include/CmImporter.h → BansheeCore/Include/CmImporter.h

@@ -1,89 +1,89 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Module responsible for importing various asset types and converting
-	 * 			them to types usable by the engine.
-	 */
-	class CM_EXPORT Importer : public Module<Importer>
-	{
-	public:
-		Importer(); 
-		~Importer(); 
-
-		/**
-		 * @brief	Imports a resource at the specified location, and returns the loaded data.
-		 *
-		 * @param	inputFilePath	Pathname of the input file.
-		 * @param	importOptions	(optional) Options for controlling the import. Caller must
-		 *							ensure import options actually match the type of the importer used
-		 *							for the file type.
-		 *
-		 * @see		createImportOptions
-		 */
-		HResource import(const Path& inputFilePath, ConstImportOptionsPtr importOptions = nullptr);
-
-		/**
-		 * @brief	Imports a resource and replaces the contents of the provided existing resource with new imported data.
-		 *
-		 * @param	inputFilePath	Pathname of the input file.
-		 * @param	importOptions	(optional) Options for controlling the import. Caller must
-		 *							ensure import options actually match the type of the importer used
-		 *							for the file type. 
-		 *
-		 * @see		createImportOptions
-		 */
-		void reimport(HResource& existingResource, const Path& inputFilePath, ConstImportOptionsPtr importOptions = nullptr);
-
-		/**
-		 * @brief	Automatically detects the importer needed for the provided file and returns valid type of
-		 * 			import options for that importer.
-		 *
-		 * @param	inputFilePath	Pathname of the input file.
-		 *
-		 * @return	The new import options.
-		 * 			
-		 * @note	You will need to type cast the importer options to a valid type,
-		 * 			taking into consideration exact importer you expect to be used for this file type.
-		 * 			If you don't use a proper import options type, an exception will be thrown during import.
-		 * 			
-		 *			nullptr is returned if the file path is not valid, or if a valid importer cannot be found for
-		 *			the specified file.
-		 */
-		ImportOptionsPtr createImportOptions(const Path& inputFilePath);
-
-		/**
-		 * @brief	Checks if we can import a file with the specified extension.
-		 *
-		 * @param	extension	The extension without the leading dot.
-		 */
-		bool supportsFileType(const WString& extension) const;
-
-		/**
-		 * @brief	Checks if we can import a file with the specified magic number.
-		 *
-		 * @param	magicNumber 	The buffer containing the magic number.
-		 * @param	magicNumSize	Size of the magic number buffer.
-		 */
-		bool supportsFileType(const UINT8* magicNumber, UINT32 magicNumSize) const;
-
-		/**
-		 * @brief	Adds a new asset importer for the specified file extension. If an asset importer for that extension
-		 * 			already exists, it is removed and replaced with the current one.
-		 * 			
-		 * @note	Internal method. This method should only be called by asset importers themselves on startup.
-		 *
-		 * @param [in]	importer	The importer that is able to handle files with the specified extension. nullptr if you
-		 * 							want to remove an asset importer for the extension.
-		 */
-		void _registerAssetImporter(SpecificImporter* importer);
-	private:
-		Vector<SpecificImporter*> mAssetImporters;
-
-		SpecificImporter* getImporterForFile(const Path& inputFilePath) const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Module responsible for importing various asset types and converting
+	 * 			them to types usable by the engine.
+	 */
+	class BS_CORE_EXPORT Importer : public Module<Importer>
+	{
+	public:
+		Importer(); 
+		~Importer(); 
+
+		/**
+		 * @brief	Imports a resource at the specified location, and returns the loaded data.
+		 *
+		 * @param	inputFilePath	Pathname of the input file.
+		 * @param	importOptions	(optional) Options for controlling the import. Caller must
+		 *							ensure import options actually match the type of the importer used
+		 *							for the file type.
+		 *
+		 * @see		createImportOptions
+		 */
+		HResource import(const Path& inputFilePath, ConstImportOptionsPtr importOptions = nullptr);
+
+		/**
+		 * @brief	Imports a resource and replaces the contents of the provided existing resource with new imported data.
+		 *
+		 * @param	inputFilePath	Pathname of the input file.
+		 * @param	importOptions	(optional) Options for controlling the import. Caller must
+		 *							ensure import options actually match the type of the importer used
+		 *							for the file type. 
+		 *
+		 * @see		createImportOptions
+		 */
+		void reimport(HResource& existingResource, const Path& inputFilePath, ConstImportOptionsPtr importOptions = nullptr);
+
+		/**
+		 * @brief	Automatically detects the importer needed for the provided file and returns valid type of
+		 * 			import options for that importer.
+		 *
+		 * @param	inputFilePath	Pathname of the input file.
+		 *
+		 * @return	The new import options.
+		 * 			
+		 * @note	You will need to type cast the importer options to a valid type,
+		 * 			taking into consideration exact importer you expect to be used for this file type.
+		 * 			If you don't use a proper import options type, an exception will be thrown during import.
+		 * 			
+		 *			nullptr is returned if the file path is not valid, or if a valid importer cannot be found for
+		 *			the specified file.
+		 */
+		ImportOptionsPtr createImportOptions(const Path& inputFilePath);
+
+		/**
+		 * @brief	Checks if we can import a file with the specified extension.
+		 *
+		 * @param	extension	The extension without the leading dot.
+		 */
+		bool supportsFileType(const WString& extension) const;
+
+		/**
+		 * @brief	Checks if we can import a file with the specified magic number.
+		 *
+		 * @param	magicNumber 	The buffer containing the magic number.
+		 * @param	magicNumSize	Size of the magic number buffer.
+		 */
+		bool supportsFileType(const UINT8* magicNumber, UINT32 magicNumSize) const;
+
+		/**
+		 * @brief	Adds a new asset importer for the specified file extension. If an asset importer for that extension
+		 * 			already exists, it is removed and replaced with the current one.
+		 * 			
+		 * @note	Internal method. This method should only be called by asset importers themselves on startup.
+		 *
+		 * @param [in]	importer	The importer that is able to handle files with the specified extension. nullptr if you
+		 * 							want to remove an asset importer for the extension.
+		 */
+		void _registerAssetImporter(SpecificImporter* importer);
+	private:
+		Vector<SpecificImporter*> mAssetImporters;
+
+		SpecificImporter* getImporterForFile(const Path& inputFilePath) const;
+	};
 }

+ 48 - 48
CamelotCore/Include/CmIndexBuffer.h → BansheeCore/Include/CmIndexBuffer.h

@@ -1,49 +1,49 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmHardwareBuffer.h"
-#include "CmCoreObject.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Hardware buffer that hold indices that reference vertices in a vertex buffer.
-	 */
-    class CM_EXPORT IndexBuffer : public HardwareBuffer, public CoreObject
-    {
-	public:
-		/**
-		 * @brief	Type of the indices used, used for determining size.
-		 */
-		enum IndexType 
-		{
-			IT_16BIT,
-			IT_32BIT
-		};
-
-		~IndexBuffer();
-
-		/**
-		 * @brief	Returns the type of indices stored.
-		 */
-		IndexType getType() const { return mIndexType; }
-
-		/**
-		 * @brief	Returns the number of indices this buffer can hold.
-		 */
-		UINT32 getNumIndexes() const { return mNumIndexes; }
-
-		/**
-		 * @brief	Returns the size of a single index in bytes.
-		 */
-		UINT32 getIndexSize() const { return mIndexSize; }
-
-	protected:
-		IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory);
-
-	protected:
-		IndexType mIndexType;
-		UINT32 mNumIndexes;
-		UINT32 mIndexSize;
-    };
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmHardwareBuffer.h"
+#include "CmCoreObject.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Hardware buffer that hold indices that reference vertices in a vertex buffer.
+	 */
+    class BS_CORE_EXPORT IndexBuffer : public HardwareBuffer, public CoreObject
+    {
+	public:
+		/**
+		 * @brief	Type of the indices used, used for determining size.
+		 */
+		enum IndexType 
+		{
+			IT_16BIT,
+			IT_32BIT
+		};
+
+		~IndexBuffer();
+
+		/**
+		 * @brief	Returns the type of indices stored.
+		 */
+		IndexType getType() const { return mIndexType; }
+
+		/**
+		 * @brief	Returns the number of indices this buffer can hold.
+		 */
+		UINT32 getNumIndexes() const { return mNumIndexes; }
+
+		/**
+		 * @brief	Returns the size of a single index in bytes.
+		 */
+		UINT32 getIndexSize() const { return mIndexSize; }
+
+	protected:
+		IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory);
+
+	protected:
+		IndexType mIndexType;
+		UINT32 mNumIndexes;
+		UINT32 mIndexSize;
+    };
 }

+ 21 - 21
CamelotCore/Include/CmIndexData.h → BansheeCore/Include/CmIndexData.h

@@ -1,22 +1,22 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmIndexBuffer.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Container that holds data about indices in a subset of an index buffer.
-	 */
-	class CM_EXPORT IndexData
-	{
-    public:
-        IndexData();
-        ~IndexData();
-
-		IndexBufferPtr indexBuffer; /**< Reference to an index buffer to fetch the indices from. */
-
-		UINT32 indexStart; /**< Starting index of the subset. */
-		UINT32 indexCount; /**< Number of indices in the subset. */
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmIndexBuffer.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Container that holds data about indices in a subset of an index buffer.
+	 */
+	class BS_CORE_EXPORT IndexData
+	{
+    public:
+        IndexData();
+        ~IndexData();
+
+		IndexBufferPtr indexBuffer; /**< Reference to an index buffer to fetch the indices from. */
+
+		UINT32 indexStart; /**< Starting index of the subset. */
+		UINT32 indexCount; /**< Number of indices in the subset. */
+	};
 }

+ 197 - 197
CamelotCore/Include/CmInput.h → BansheeCore/Include/CmInput.h

@@ -1,198 +1,198 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmRectI.h"
-#include "CmOSInputHandler.h"
-#include "CmRawInputHandler.h"
-#include "CmInputFwd.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Primary module used for dealing with input. Allows you to receieve 
-	 *			and query raw or OS input for mouse/keyboard/gamepad.
-	 *
-	 *			All inputs are received through an input handler, which can be overriden to 
-	 *			provide custom input functionality.
-	 */
-	class CM_EXPORT Input : public Module<Input>
-	{
-		/**
-		 * @brief	Possible button states
-		 */
-		enum class ButtonState
-		{
-			Off, /**< Button is not being pressed. */
-			On, /**< Button is being pressed. */
-			ToggledOn, /**< Button has been pressed this frame. */
-			ToggledOff /**< Button has been released this frame. */
-		};
-
-	public:
-		Input();
-		~Input();
-
-		/**
-		 * @brief	Triggered whenever a button is first pressed.
-		 */
-		Event<void(const ButtonEvent&)> onButtonDown;
-
-		/**
-		 * @brief	Triggered whenever a button is first released.
-		 */
-		Event<void(const ButtonEvent&)> onButtonUp;
-
-		/**
-		 * @brief	Triggered whenever user inputs a text character. 
-		 */
-		Event<void(const TextInputEvent&)> onCharInput;
-
-		/**
-		 * @brief	Triggers when some pointing device (mouse cursor, touch) moves.
-		 */
-		Event<void(const PointerEvent&)> onPointerMoved;
-
-		/**
-		 * @brief	Triggers when some pointing device (mouse cursor, touch) button is pressed.
-		 */
-		Event<void(const PointerEvent&)> onPointerPressed;
-
-		/**
-		 * @brief	Triggers when some pointing device (mouse cursor, touch) button is released.
-		 */
-		Event<void(const PointerEvent&)> onPointerReleased;
-
-		/**
-		 * @brief	Triggers when some pointing device (mouse cursor, touch) button is double clicked.
-		 */
-		Event<void(const PointerEvent&)> onPointerDoubleClick;
-
-		// TODO Low priority: Remove this, I can emulate it using virtual input
-		/**
-		 * @brief	Triggers on special input commands.
-		 */
-		Event<void(InputCommandType)> onInputCommand;
-
-		/**
-		 * @brief	Registers a new input handler. Replaces any previous input handler.
-		 *
-		 * @note	Internal method.
-		 */
-		void _registerRawInputHandler(std::shared_ptr<RawInputHandler> inputHandler);
-
-		/**
-		 * @brief	Called every frame. Dispatches any callbacks resulting from input by the user.
-		 *
-		 * @note	Internal method.
-		 */
-		void _update();
-
-		/**
-		 * @brief	Returns smoothed mouse/joystick input in the horizontal axis.
-		 *
-		 * @return	The horizontal axis value ranging [-1.0f, 1.0f].
-		 */
-		float getHorizontalAxis() const;
-
-		/**
-		 * @brief	Returns smoothed mouse/joystick input in the vertical axis.
-		 *
-		 * @return	The vertical axis value ranging [-1.0f, 1.0f].
-		 */
-		float getVerticalAxis() const;
-
-		/**
-		 * @brief	Query if the provided button is currently being held (this frame or previous frames).
-		 */
-		bool isButtonHeld(ButtonCode keyCode) const;
-
-		/**
-		 * @brief	Query if the provided button is currently being released (one true for one frame).
-		 */
-		bool isButtonUp(ButtonCode keyCode) const;
-
-		/**
-		 * @brief	Query if the provided button is currently being pressed (one true for one frame).
-		 */
-		bool isButtonDown(ButtonCode keyCode) const;
-
-		/**
-		 * @brief	Returns mouse cursor position.
-		 */
-		Vector2I getCursorPosition() const { return mMouseAbsPos; }
-	private:
-		std::shared_ptr<RawInputHandler> mRawInputHandler;
-		std::shared_ptr<OSInputHandler> mOSInputHandler;
-
-		float mSmoothHorizontalAxis;
-		float mSmoothVerticalAxis;
-
-		float* mHorizontalHistoryBuffer;
-		float* mVerticalHistoryBuffer;
-		float* mTimesHistoryBuffer;
-		int	mCurrentBufferIdx;
-
-		Vector2I mMouseLastRel;
-		Vector2I mMouseAbsPos;
-
-		RawAxisState mAxes[RawInputAxis::Count];
-		ButtonState mKeyState[BC_Count];
-
-		void buttonDown(ButtonCode code, UINT64 timestamp);
-		void buttonUp(ButtonCode code, UINT64 timestamp);
-
-		void charInput(UINT32 chr);
-
-		/**
-		 * @brief	Raw mouse/joystick axis input.
-		 */
-		void axisMoved(const RawAxisState& state, RawInputAxis axis);
-
-		/**
-		 * @brief	Cursor movement as OS reports it. Used for screen cursor position.
-		 */
-		void cursorMoved(const PointerEvent& event);
-
-		/**
-		 * @brief	Cursor button presses as OS reports it. 
-		 */
-		void cursorPressed(const PointerEvent& event);
-
-		/**
-		 * @brief	Cursor button releases as OS reports it.
-		 */
-		void cursorReleased(const PointerEvent& event);
-		
-		/**
-		 * @brief	Cursor button releases as OS reports it.
-		 */
-		void cursorDoubleClick(const PointerEvent& event);
-
-		/**
-		 * @brief	Input commands as OS reports them.
-		 */
-		void inputCommandEntered(InputCommandType commandType);
-
-		/**
-		 * @brief	Updates the axis input values that need smoothing.
-		 */
-		void updateSmoothInput();
-
-		/**
-		 * @brief	Called when window in focus changes, as reported by the OS.
-		 */
-		void inputWindowChanged(RenderWindow& win);
-
-		/************************************************************************/
-		/* 								STATICS		                      		*/
-		/************************************************************************/
-		static const int HISTORY_BUFFER_SIZE; // Size of buffer used for input smoothing
-		static const float WEIGHT_MODIFIER;
-	};
-
-	/**
-	 * @copydoc	Input
-	 */
-	CM_EXPORT Input& gInput();
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmRectI.h"
+#include "CmOSInputHandler.h"
+#include "CmRawInputHandler.h"
+#include "CmInputFwd.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Primary module used for dealing with input. Allows you to receieve 
+	 *			and query raw or OS input for mouse/keyboard/gamepad.
+	 *
+	 *			All inputs are received through an input handler, which can be overriden to 
+	 *			provide custom input functionality.
+	 */
+	class BS_CORE_EXPORT Input : public Module<Input>
+	{
+		/**
+		 * @brief	Possible button states
+		 */
+		enum class ButtonState
+		{
+			Off, /**< Button is not being pressed. */
+			On, /**< Button is being pressed. */
+			ToggledOn, /**< Button has been pressed this frame. */
+			ToggledOff /**< Button has been released this frame. */
+		};
+
+	public:
+		Input();
+		~Input();
+
+		/**
+		 * @brief	Triggered whenever a button is first pressed.
+		 */
+		Event<void(const ButtonEvent&)> onButtonDown;
+
+		/**
+		 * @brief	Triggered whenever a button is first released.
+		 */
+		Event<void(const ButtonEvent&)> onButtonUp;
+
+		/**
+		 * @brief	Triggered whenever user inputs a text character. 
+		 */
+		Event<void(const TextInputEvent&)> onCharInput;
+
+		/**
+		 * @brief	Triggers when some pointing device (mouse cursor, touch) moves.
+		 */
+		Event<void(const PointerEvent&)> onPointerMoved;
+
+		/**
+		 * @brief	Triggers when some pointing device (mouse cursor, touch) button is pressed.
+		 */
+		Event<void(const PointerEvent&)> onPointerPressed;
+
+		/**
+		 * @brief	Triggers when some pointing device (mouse cursor, touch) button is released.
+		 */
+		Event<void(const PointerEvent&)> onPointerReleased;
+
+		/**
+		 * @brief	Triggers when some pointing device (mouse cursor, touch) button is double clicked.
+		 */
+		Event<void(const PointerEvent&)> onPointerDoubleClick;
+
+		// TODO Low priority: Remove this, I can emulate it using virtual input
+		/**
+		 * @brief	Triggers on special input commands.
+		 */
+		Event<void(InputCommandType)> onInputCommand;
+
+		/**
+		 * @brief	Registers a new input handler. Replaces any previous input handler.
+		 *
+		 * @note	Internal method.
+		 */
+		void _registerRawInputHandler(std::shared_ptr<RawInputHandler> inputHandler);
+
+		/**
+		 * @brief	Called every frame. Dispatches any callbacks resulting from input by the user.
+		 *
+		 * @note	Internal method.
+		 */
+		void _update();
+
+		/**
+		 * @brief	Returns smoothed mouse/joystick input in the horizontal axis.
+		 *
+		 * @return	The horizontal axis value ranging [-1.0f, 1.0f].
+		 */
+		float getHorizontalAxis() const;
+
+		/**
+		 * @brief	Returns smoothed mouse/joystick input in the vertical axis.
+		 *
+		 * @return	The vertical axis value ranging [-1.0f, 1.0f].
+		 */
+		float getVerticalAxis() const;
+
+		/**
+		 * @brief	Query if the provided button is currently being held (this frame or previous frames).
+		 */
+		bool isButtonHeld(ButtonCode keyCode) const;
+
+		/**
+		 * @brief	Query if the provided button is currently being released (one true for one frame).
+		 */
+		bool isButtonUp(ButtonCode keyCode) const;
+
+		/**
+		 * @brief	Query if the provided button is currently being pressed (one true for one frame).
+		 */
+		bool isButtonDown(ButtonCode keyCode) const;
+
+		/**
+		 * @brief	Returns mouse cursor position.
+		 */
+		Vector2I getCursorPosition() const { return mMouseAbsPos; }
+	private:
+		std::shared_ptr<RawInputHandler> mRawInputHandler;
+		std::shared_ptr<OSInputHandler> mOSInputHandler;
+
+		float mSmoothHorizontalAxis;
+		float mSmoothVerticalAxis;
+
+		float* mHorizontalHistoryBuffer;
+		float* mVerticalHistoryBuffer;
+		float* mTimesHistoryBuffer;
+		int	mCurrentBufferIdx;
+
+		Vector2I mMouseLastRel;
+		Vector2I mMouseAbsPos;
+
+		RawAxisState mAxes[RawInputAxis::Count];
+		ButtonState mKeyState[BC_Count];
+
+		void buttonDown(ButtonCode code, UINT64 timestamp);
+		void buttonUp(ButtonCode code, UINT64 timestamp);
+
+		void charInput(UINT32 chr);
+
+		/**
+		 * @brief	Raw mouse/joystick axis input.
+		 */
+		void axisMoved(const RawAxisState& state, RawInputAxis axis);
+
+		/**
+		 * @brief	Cursor movement as OS reports it. Used for screen cursor position.
+		 */
+		void cursorMoved(const PointerEvent& event);
+
+		/**
+		 * @brief	Cursor button presses as OS reports it. 
+		 */
+		void cursorPressed(const PointerEvent& event);
+
+		/**
+		 * @brief	Cursor button releases as OS reports it.
+		 */
+		void cursorReleased(const PointerEvent& event);
+		
+		/**
+		 * @brief	Cursor button releases as OS reports it.
+		 */
+		void cursorDoubleClick(const PointerEvent& event);
+
+		/**
+		 * @brief	Input commands as OS reports them.
+		 */
+		void inputCommandEntered(InputCommandType commandType);
+
+		/**
+		 * @brief	Updates the axis input values that need smoothing.
+		 */
+		void updateSmoothInput();
+
+		/**
+		 * @brief	Called when window in focus changes, as reported by the OS.
+		 */
+		void inputWindowChanged(RenderWindow& win);
+
+		/************************************************************************/
+		/* 								STATICS		                      		*/
+		/************************************************************************/
+		static const int HISTORY_BUFFER_SIZE; // Size of buffer used for input smoothing
+		static const float WEIGHT_MODIFIER;
+	};
+
+	/**
+	 * @copydoc	Input
+	 */
+	BS_CORE_EXPORT Input& gInput();
 }

+ 376 - 376
CamelotCore/Include/CmInputFwd.h → BansheeCore/Include/CmInputFwd.h

@@ -1,377 +1,377 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmVector2I.h"
-
-namespace BansheeEngine
-{
-	// Contains all possible keys, including keyboard scan codes, mouse buttons and gamepad buttons
-	// Note: These KeyCodes are only keyboard scan codes. This means that exact scan code identifier might 
-	// not correspond to that exact character on users keyboard, depending on users input locale. 
-	// Only for US locale will these scan code names will match the actual keyboard input. Think of the US key
-	// code names as only a convenience for more easily identifying which location on the keyboard a scan code represents.
-	//
-	// When storing these sequentially make sure to only reference the low order 2 bytes. Two high order bytes are used for various flags.
-	enum ButtonCode
-	{
-		BC_UNASSIGNED  = 0x00,
-		BC_ESCAPE      = 0x01,
-		BC_1           = 0x02,
-		BC_2           = 0x03,
-		BC_3           = 0x04,
-		BC_4           = 0x05,
-		BC_5           = 0x06,
-		BC_6           = 0x07,
-		BC_7           = 0x08,
-		BC_8           = 0x09,
-		BC_9           = 0x0A,
-		BC_0           = 0x0B,
-		BC_MINUS       = 0x0C,    // - on main keyboard
-		BC_EQUALS      = 0x0D,
-		BC_BACK        = 0x0E,    // backspace
-		BC_TAB         = 0x0F,
-		BC_Q           = 0x10,
-		BC_W           = 0x11,
-		BC_E           = 0x12,
-		BC_R           = 0x13,
-		BC_T           = 0x14,
-		BC_Y           = 0x15,
-		BC_U           = 0x16,
-		BC_I           = 0x17,
-		BC_O           = 0x18,
-		BC_P           = 0x19,
-		BC_LBRACKET    = 0x1A,
-		BC_RBRACKET    = 0x1B,
-		BC_RETURN      = 0x1C,    // Enter on main keyboard
-		BC_LCONTROL    = 0x1D,
-		BC_A           = 0x1E,
-		BC_S           = 0x1F,
-		BC_D           = 0x20,
-		BC_F           = 0x21,
-		BC_G           = 0x22,
-		BC_H           = 0x23,
-		BC_J           = 0x24,
-		BC_K           = 0x25,
-		BC_L           = 0x26,
-		BC_SEMICOLON   = 0x27,
-		BC_APOSTROPHE  = 0x28,
-		BC_GRAVE       = 0x29,    // accent
-		BC_LSHIFT      = 0x2A,
-		BC_BACKSLASH   = 0x2B,
-		BC_Z           = 0x2C,
-		BC_X           = 0x2D,
-		BC_C           = 0x2E,
-		BC_V           = 0x2F,
-		BC_B           = 0x30,
-		BC_N           = 0x31,
-		BC_M           = 0x32,
-		BC_COMMA       = 0x33,
-		BC_PERIOD      = 0x34,    // . on main keyboard
-		BC_SLASH       = 0x35,    // / on main keyboard
-		BC_RSHIFT      = 0x36,
-		BC_MULTIPLY    = 0x37,    // * on numeric keypad
-		BC_LMENU       = 0x38,    // left Alt
-		BC_SPACE       = 0x39,
-		BC_CAPITAL     = 0x3A,
-		BC_F1          = 0x3B,
-		BC_F2          = 0x3C,
-		BC_F3          = 0x3D,
-		BC_F4          = 0x3E,
-		BC_F5          = 0x3F,
-		BC_F6          = 0x40,
-		BC_F7          = 0x41,
-		BC_F8          = 0x42,
-		BC_F9          = 0x43,
-		BC_F10         = 0x44,
-		BC_NUMLOCK     = 0x45,
-		BC_SCROLL      = 0x46,    // Scroll Lock
-		BC_NUMPAD7     = 0x47,
-		BC_NUMPAD8     = 0x48,
-		BC_NUMPAD9     = 0x49,
-		BC_SUBTRACT    = 0x4A,    // - on numeric keypad
-		BC_NUMPAD4     = 0x4B,
-		BC_NUMPAD5     = 0x4C,
-		BC_NUMPAD6     = 0x4D,
-		BC_ADD         = 0x4E,    // + on numeric keypad
-		BC_NUMPAD1     = 0x4F,
-		BC_NUMPAD2     = 0x50,
-		BC_NUMPAD3     = 0x51,
-		BC_NUMPAD0     = 0x52,
-		BC_DECIMAL     = 0x53,    // . on numeric keypad
-		BC_OEM_102     = 0x56,    // < > | on UK/Germany keyboards
-		BC_F11         = 0x57,
-		BC_F12         = 0x58,
-		BC_F13         = 0x64,    //                     (NEC PC98)
-		BC_F14         = 0x65,    //                     (NEC PC98)
-		BC_F15         = 0x66,    //                     (NEC PC98)
-		BC_KANA        = 0x70,    // (Japanese keyboard)
-		BC_ABNT_C1     = 0x73,    // / ? on Portugese (Brazilian) keyboards
-		BC_CONVERT     = 0x79,    // (Japanese keyboard)
-		BC_NOCONVERT   = 0x7B,    // (Japanese keyboard)
-		BC_YEN         = 0x7D,    // (Japanese keyboard)
-		BC_ABNT_C2     = 0x7E,    // Numpad . on Portugese (Brazilian) keyboards
-		BC_NUMPADEQUALS= 0x8D,    // = on numeric keypad (NEC PC98)
-		BC_PREVTRACK   = 0x90,    // Previous Track (BC_CIRCUMFLEX on Japanese keyboard)
-		BC_AT          = 0x91,    //                     (NEC PC98)
-		BC_COLON       = 0x92,    //                     (NEC PC98)
-		BC_UNDERLINE   = 0x93,    //                     (NEC PC98)
-		BC_KANJI       = 0x94,    // (Japanese keyboard)
-		BC_STOP        = 0x95,    //                     (NEC PC98)
-		BC_AX          = 0x96,    //                     (Japan AX)
-		BC_UNLABELED   = 0x97,    //                        (J3100)
-		BC_NEXTTRACK   = 0x99,    // Next Track
-		BC_NUMPADENTER = 0x9C,    // Enter on numeric keypad
-		BC_RCONTROL    = 0x9D,
-		BC_MUTE        = 0xA0,    // Mute
-		BC_CALCULATOR  = 0xA1,    // Calculator
-		BC_PLAYPAUSE   = 0xA2,    // Play / Pause
-		BC_MEDIASTOP   = 0xA4,    // Media Stop
-		BC_VOLUMEDOWN  = 0xAE,    // Volume -
-		BC_VOLUMEUP    = 0xB0,    // Volume +
-		BC_WEBHOME     = 0xB2,    // Web home
-		BC_NUMPADCOMMA = 0xB3,    // , on numeric keypad (NEC PC98)
-		BC_DIVIDE      = 0xB5,    // / on numeric keypad
-		BC_SYSRQ       = 0xB7,
-		BC_RMENU       = 0xB8,    // right Alt
-		BC_PAUSE       = 0xC5,    // Pause
-		BC_HOME        = 0xC7,    // Home on arrow keypad
-		BC_UP          = 0xC8,    // UpArrow on arrow keypad
-		BC_PGUP        = 0xC9,    // PgUp on arrow keypad
-		BC_LEFT        = 0xCB,    // LeftArrow on arrow keypad
-		BC_RIGHT       = 0xCD,    // RightArrow on arrow keypad
-		BC_END         = 0xCF,    // End on arrow keypad
-		BC_DOWN        = 0xD0,    // DownArrow on arrow keypad
-		BC_PGDOWN      = 0xD1,    // PgDn on arrow keypad
-		BC_INSERT      = 0xD2,    // Insert on arrow keypad
-		BC_DELETE      = 0xD3,    // Delete on arrow keypad
-		BC_LWIN        = 0xDB,    // Left Windows key
-		BC_RWIN        = 0xDC,    // Right Windows key
-		BC_APPS        = 0xDD,    // AppMenu key
-		BC_POWER       = 0xDE,    // System Power
-		BC_SLEEP       = 0xDF,    // System Sleep
-		BC_WAKE        = 0xE3,    // System Wake
-		BC_WEBSEARCH   = 0xE5,    // Web Search
-		BC_WEBFAVORITES= 0xE6,    // Web Favorites
-		BC_WEBREFRESH  = 0xE7,    // Web Refresh
-		BC_WEBSTOP     = 0xE8,    // Web Stop
-		BC_WEBFORWARD  = 0xE9,    // Web Forward
-		BC_WEBBACK     = 0xEA,    // Web Back
-		BC_MYCOMPUTER  = 0xEB,    // My Computer
-		BC_MAIL        = 0xEC,    // Mail
-		BC_MEDIASELECT = 0xED,     // Media Select
-		BC_MOUSE_LEFT = 0x800000EE, // Mouse buttons - Most important bit signifies this key is a mouse button
-		BC_MOUSE_RIGHT = 0x800000EF,
-		BC_MOUSE_MIDDLE = 0x800000F0,
-		BC_MOUSE_BTN4 = 0x800000F1,
-		BC_MOUSE_BTN5 = 0x800000F2,
-		BC_MOUSE_BTN6 = 0x800000F3,
-		BC_MOUSE_BTN7 = 0x800000F4,
-		BC_MOUSE_BTN8 = 0x800000F5,
-		BC_MOUSE_BTN9 = 0x800000F6,
-		BC_MOUSE_BTN10 = 0x800000F7,
-		BC_MOUSE_BTN11 = 0x800000F8,
-		BC_MOUSE_BTN12 = 0x800000F9,
-		BC_MOUSE_BTN13 = 0x800000FA,
-		BC_MOUSE_BTN14 = 0x800000FB,
-		BC_MOUSE_BTN15 = 0x800000FC,
-		BC_MOUSE_BTN16 = 0x800000FD,
-		BC_MOUSE_BTN17 = 0x800000FE,
-		BC_MOUSE_BTN18 = 0x800000FF,
-		BC_MOUSE_BTN19 = 0x80000101,
-		BC_MOUSE_BTN20 = 0x80000102,
-		BC_MOUSE_BTN21 = 0x80000103,
-		BC_MOUSE_BTN22 = 0x80000104,
-		BC_MOUSE_BTN23 = 0x80000105,
-		BC_MOUSE_BTN24 = 0x80000106,
-		BC_MOUSE_BTN25 = 0x80000107,
-		BC_MOUSE_BTN26 = 0x80000108,
-		BC_MOUSE_BTN27 = 0x80000109,
-		BC_MOUSE_BTN28 = 0x8000010A,
-		BC_MOUSE_BTN29 = 0x8000010B,
-		BC_MOUSE_BTN30 = 0x8000010C,
-		BC_MOUSE_BTN31 = 0x8000010D,
-		BC_MOUSE_BTN32 = 0x8000010E,
-		BC_JOY_BTN1 = 0x4000010F, // Joystick/Gamepad buttons- Second most important bit signifies key is a joystick button
-		BC_JOY_BTN2 = 0x40000110,
-		BC_JOY_BTN3 = 0x40000111,
-		BC_JOY_BTN4 = 0x40000112,
-		BC_JOY_BTN5 = 0x40000113,
-		BC_JOY_BTN6 = 0x40000114,
-		BC_JOY_BTN7 = 0x40000115,
-		BC_JOY_BTN8 = 0x40000116,
-		BC_JOY_BTN9 = 0x40000117,
-		BC_JOY_BTN10 = 0x40000118,
-		BC_JOY_BTN11 = 0x40000119,
-		BC_JOY_BTN12 = 0x4000011A,
-		BC_JOY_BTN13 = 0x4000011B,
-		BC_JOY_BTN14 = 0x4000011C,
-		BC_JOY_BTN15 = 0x4000011D,
-		BC_JOY_BTN16 = 0x4000011E,
-		BC_JOY_BTN17 = 0x4000011F,
-		BC_JOY_BTN18 = 0x40000120,
-		BC_JOY_BTN19 = 0x40000121,
-		BC_JOY_BTN20 = 0x40000123,
-		BC_JOY_BTN21 = 0x40000124,
-		BC_JOY_BTN22 = 0x40000125,
-		BC_JOY_BTN23 = 0x40000126,
-		BC_JOY_BTN24 = 0x40000127,
-		BC_JOY_BTN25 = 0x40000128,
-		BC_JOY_BTN26 = 0x40000129,
-		BC_JOY_BTN27 = 0x4000012A,
-		BC_JOY_BTN28 = 0x4000012B,
-		BC_JOY_BTN29 = 0x4000012C,
-		BC_JOY_BTN30 = 0x4000012D,
-		BC_JOY_BTN31 = 0x4000012E,
-		BC_JOY_BTN32 = 0x4000012F,
-		BC_Count = 0x00000130,
-		BC_NumKeys = 0xEE, // IMPORTANT: Make sure to update these if you modify the values above
-		BC_NumMouse = 0x20,
-		BC_NumJoy = 0x20,
-	};
-
-	/**
-	 * @brief	Structure containing information about a button input event.
-	 */
-	struct ButtonEvent
-	{
-	public:
-		ButtonEvent()
-			:mIsUsed(false)
-		{ }
-
-		ButtonCode buttonCode; /**< Button code this event is referring to. */
-		UINT64 timestamp; /**< Timestamp in ticks when the event happened. */
-
-		/**
-		 * @brief	Query is the pressed button a keyboard button.
-		 */
-		bool isKeyboard() const { return (buttonCode & 0xC0000000) == 0; }
-
-		/**
-		 * @brief	Query is the pressed button a mouse button.
-		 */
-		bool isMouse() const { return (buttonCode & 0x80000000) != 0; }
-
-		/**
-		 * @brief	Query is the pressed button a gamepad button.
-		 */
-		bool isGamepad() const { return (buttonCode & 0x40000000) != 0; }
-
-		/**
-		 * @brief	Check if the event has been marked as used. Internally this means nothing
-		 *			but caller might choose to ignore an used event.
-		 */
-		bool isUsed() const { return mIsUsed; }
-
-		/**
-		 * @brief	Mark the event as used. Internally this means nothing
-		 *			but caller might choose to ignore an used event.
-		 */
-		void markAsUsed() const { mIsUsed = true; }
-	private:
-		mutable bool mIsUsed;
-	};
-
-	/**
-	 * @brief	Pointer buttons. Generally these correspond to mouse
-	 * 			buttons, but may be used in some form for touch input as well.
-	 */
-	enum class PointerEventButton
-	{
-		Left, Middle, Right, Count
-	};
-
-	/**
-	 * @brief	Type of pointer event.
-	 */
-	enum class PointerEventType
-	{
-		CursorMoved,
-		ButtonPressed,
-		ButtonReleased,
-		DoubleClick
-	};
-
-	/**
-	 * @brief	Event that gets sent out when user interacts with the screen in some way,
-	 * 			usually by moving the mouse cursor or using touch input.
-	 */
-	struct PointerEvent
-	{
-	public:
-		PointerEvent()
-			:mIsUsed(false), mouseWheelScrollAmount(0.0f), type(PointerEventType::CursorMoved),
-			shift(false), control(false), alt(false), button(PointerEventButton::Left)
-		{
-			buttonStates[0] = false;
-			buttonStates[1] = false;
-			buttonStates[2] = false;
-		}
-
-		Vector2I screenPos; /**< Screen position where the input event occurred. */
-		bool buttonStates[PointerEventButton::Count]; /**< States of the pointer buttons (e.g. mouse buttons). */
-		PointerEventButton button; /**< Button that triggered the pointer event. Might be irrelevant 
-										depending on event type. (e.g. move events don't correspond to a button. */
-		PointerEventType type; /**< Type of the pointer event. */
-
-		bool shift; /**< Is Shift button on the keyboard being held down. */
-		bool control; /**< Is Control button on the keyboard being held down. */
-		bool alt; /**< Is Alt button on the keyboard being held down. */
-
-		float mouseWheelScrollAmount; /**< If mouse wheel is being scrolled, what is the amount. Only relevant on move events. */
-
-		/**
-		 * @brief	Check if the event has been marked as used. Internally this means nothing
-		 *			but caller might choose to ignore an used event.
-		 */
-		bool isUsed() const { return mIsUsed; }
-
-		/**
-		 * @brief	Mark the event as used. Internally this means nothing
-		 *			but caller might choose to ignore an used event.
-		 */
-		void markAsUsed() const { mIsUsed = true; }
-
-	private:
-		mutable bool mIsUsed;
-	};
-
-	/**
-	 * @brief	Type of special input command types.
-	 */
-	enum class InputCommandType
-	{
-		CursorMoveLeft, CursorMoveRight, CursorMoveUp, CursorMoveDown, 
-		SelectLeft, SelectRight, SelectUp, SelectDown,
-		Escape, Delete, Backspace, Return
-	};
-
-	/**
-	 * @brief	Event that gets sent out when user inputs some text. These events may be preceeded by
-	 *			normal button events if user is typing on a keyboard. 
-	 */
-	struct TextInputEvent
-	{
-	public:
-		TextInputEvent()
-			:mIsUsed(false)
-		{ }
-
-		UINT32 textChar; /**< Character the user is inputting. */
-
-		/**
-		 * @brief	Check if the event has been marked as used. Internally this means nothing
-		 *			but caller might choose to ignore an used event.
-		 */
-		bool isUsed() const { return mIsUsed; }
-
-		/**
-		 * @brief	Mark the event as used. Internally this means nothing
-		 *			but caller might choose to ignore an used event.
-		 */
-		void markAsUsed() const { mIsUsed = true; }
-
-	private:
-		mutable bool mIsUsed;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmVector2I.h"
+
+namespace BansheeEngine
+{
+	// Contains all possible keys, including keyboard scan codes, mouse buttons and gamepad buttons
+	// Note: These KeyCodes are only keyboard scan codes. This means that exact scan code identifier might 
+	// not correspond to that exact character on users keyboard, depending on users input locale. 
+	// Only for US locale will these scan code names will match the actual keyboard input. Think of the US key
+	// code names as only a convenience for more easily identifying which location on the keyboard a scan code represents.
+	//
+	// When storing these sequentially make sure to only reference the low order 2 bytes. Two high order bytes are used for various flags.
+	enum ButtonCode
+	{
+		BC_UNASSIGNED  = 0x00,
+		BC_ESCAPE      = 0x01,
+		BC_1           = 0x02,
+		BC_2           = 0x03,
+		BC_3           = 0x04,
+		BC_4           = 0x05,
+		BC_5           = 0x06,
+		BC_6           = 0x07,
+		BC_7           = 0x08,
+		BC_8           = 0x09,
+		BC_9           = 0x0A,
+		BC_0           = 0x0B,
+		BC_MINUS       = 0x0C,    // - on main keyboard
+		BC_EQUALS      = 0x0D,
+		BC_BACK        = 0x0E,    // backspace
+		BC_TAB         = 0x0F,
+		BC_Q           = 0x10,
+		BC_W           = 0x11,
+		BC_E           = 0x12,
+		BC_R           = 0x13,
+		BC_T           = 0x14,
+		BC_Y           = 0x15,
+		BC_U           = 0x16,
+		BC_I           = 0x17,
+		BC_O           = 0x18,
+		BC_P           = 0x19,
+		BC_LBRACKET    = 0x1A,
+		BC_RBRACKET    = 0x1B,
+		BC_RETURN      = 0x1C,    // Enter on main keyboard
+		BC_LCONTROL    = 0x1D,
+		BC_A           = 0x1E,
+		BC_S           = 0x1F,
+		BC_D           = 0x20,
+		BC_F           = 0x21,
+		BC_G           = 0x22,
+		BC_H           = 0x23,
+		BC_J           = 0x24,
+		BC_K           = 0x25,
+		BC_L           = 0x26,
+		BC_SEMICOLON   = 0x27,
+		BC_APOSTROPHE  = 0x28,
+		BC_GRAVE       = 0x29,    // accent
+		BC_LSHIFT      = 0x2A,
+		BC_BACKSLASH   = 0x2B,
+		BC_Z           = 0x2C,
+		BC_X           = 0x2D,
+		BC_C           = 0x2E,
+		BC_V           = 0x2F,
+		BC_B           = 0x30,
+		BC_N           = 0x31,
+		BC_M           = 0x32,
+		BC_COMMA       = 0x33,
+		BC_PERIOD      = 0x34,    // . on main keyboard
+		BC_SLASH       = 0x35,    // / on main keyboard
+		BC_RSHIFT      = 0x36,
+		BC_MULTIPLY    = 0x37,    // * on numeric keypad
+		BC_LMENU       = 0x38,    // left Alt
+		BC_SPACE       = 0x39,
+		BC_CAPITAL     = 0x3A,
+		BC_F1          = 0x3B,
+		BC_F2          = 0x3C,
+		BC_F3          = 0x3D,
+		BC_F4          = 0x3E,
+		BC_F5          = 0x3F,
+		BC_F6          = 0x40,
+		BC_F7          = 0x41,
+		BC_F8          = 0x42,
+		BC_F9          = 0x43,
+		BC_F10         = 0x44,
+		BC_NUMLOCK     = 0x45,
+		BC_SCROLL      = 0x46,    // Scroll Lock
+		BC_NUMPAD7     = 0x47,
+		BC_NUMPAD8     = 0x48,
+		BC_NUMPAD9     = 0x49,
+		BC_SUBTRACT    = 0x4A,    // - on numeric keypad
+		BC_NUMPAD4     = 0x4B,
+		BC_NUMPAD5     = 0x4C,
+		BC_NUMPAD6     = 0x4D,
+		BC_ADD         = 0x4E,    // + on numeric keypad
+		BC_NUMPAD1     = 0x4F,
+		BC_NUMPAD2     = 0x50,
+		BC_NUMPAD3     = 0x51,
+		BC_NUMPAD0     = 0x52,
+		BC_DECIMAL     = 0x53,    // . on numeric keypad
+		BC_OEM_102     = 0x56,    // < > | on UK/Germany keyboards
+		BC_F11         = 0x57,
+		BC_F12         = 0x58,
+		BC_F13         = 0x64,    //                     (NEC PC98)
+		BC_F14         = 0x65,    //                     (NEC PC98)
+		BC_F15         = 0x66,    //                     (NEC PC98)
+		BC_KANA        = 0x70,    // (Japanese keyboard)
+		BC_ABNT_C1     = 0x73,    // / ? on Portugese (Brazilian) keyboards
+		BC_CONVERT     = 0x79,    // (Japanese keyboard)
+		BC_NOCONVERT   = 0x7B,    // (Japanese keyboard)
+		BC_YEN         = 0x7D,    // (Japanese keyboard)
+		BC_ABNT_C2     = 0x7E,    // Numpad . on Portugese (Brazilian) keyboards
+		BC_NUMPADEQUALS= 0x8D,    // = on numeric keypad (NEC PC98)
+		BC_PREVTRACK   = 0x90,    // Previous Track (BC_CIRCUMFLEX on Japanese keyboard)
+		BC_AT          = 0x91,    //                     (NEC PC98)
+		BC_COLON       = 0x92,    //                     (NEC PC98)
+		BC_UNDERLINE   = 0x93,    //                     (NEC PC98)
+		BC_KANJI       = 0x94,    // (Japanese keyboard)
+		BC_STOP        = 0x95,    //                     (NEC PC98)
+		BC_AX          = 0x96,    //                     (Japan AX)
+		BC_UNLABELED   = 0x97,    //                        (J3100)
+		BC_NEXTTRACK   = 0x99,    // Next Track
+		BC_NUMPADENTER = 0x9C,    // Enter on numeric keypad
+		BC_RCONTROL    = 0x9D,
+		BC_MUTE        = 0xA0,    // Mute
+		BC_CALCULATOR  = 0xA1,    // Calculator
+		BC_PLAYPAUSE   = 0xA2,    // Play / Pause
+		BC_MEDIASTOP   = 0xA4,    // Media Stop
+		BC_VOLUMEDOWN  = 0xAE,    // Volume -
+		BC_VOLUMEUP    = 0xB0,    // Volume +
+		BC_WEBHOME     = 0xB2,    // Web home
+		BC_NUMPADCOMMA = 0xB3,    // , on numeric keypad (NEC PC98)
+		BC_DIVIDE      = 0xB5,    // / on numeric keypad
+		BC_SYSRQ       = 0xB7,
+		BC_RMENU       = 0xB8,    // right Alt
+		BC_PAUSE       = 0xC5,    // Pause
+		BC_HOME        = 0xC7,    // Home on arrow keypad
+		BC_UP          = 0xC8,    // UpArrow on arrow keypad
+		BC_PGUP        = 0xC9,    // PgUp on arrow keypad
+		BC_LEFT        = 0xCB,    // LeftArrow on arrow keypad
+		BC_RIGHT       = 0xCD,    // RightArrow on arrow keypad
+		BC_END         = 0xCF,    // End on arrow keypad
+		BC_DOWN        = 0xD0,    // DownArrow on arrow keypad
+		BC_PGDOWN      = 0xD1,    // PgDn on arrow keypad
+		BC_INSERT      = 0xD2,    // Insert on arrow keypad
+		BC_DELETE      = 0xD3,    // Delete on arrow keypad
+		BC_LWIN        = 0xDB,    // Left Windows key
+		BC_RWIN        = 0xDC,    // Right Windows key
+		BC_APPS        = 0xDD,    // AppMenu key
+		BC_POWER       = 0xDE,    // System Power
+		BC_SLEEP       = 0xDF,    // System Sleep
+		BC_WAKE        = 0xE3,    // System Wake
+		BC_WEBSEARCH   = 0xE5,    // Web Search
+		BC_WEBFAVORITES= 0xE6,    // Web Favorites
+		BC_WEBREFRESH  = 0xE7,    // Web Refresh
+		BC_WEBSTOP     = 0xE8,    // Web Stop
+		BC_WEBFORWARD  = 0xE9,    // Web Forward
+		BC_WEBBACK     = 0xEA,    // Web Back
+		BC_MYCOMPUTER  = 0xEB,    // My Computer
+		BC_MAIL        = 0xEC,    // Mail
+		BC_MEDIASELECT = 0xED,     // Media Select
+		BC_MOUSE_LEFT = 0x800000EE, // Mouse buttons - Most important bit signifies this key is a mouse button
+		BC_MOUSE_RIGHT = 0x800000EF,
+		BC_MOUSE_MIDDLE = 0x800000F0,
+		BC_MOUSE_BTN4 = 0x800000F1,
+		BC_MOUSE_BTN5 = 0x800000F2,
+		BC_MOUSE_BTN6 = 0x800000F3,
+		BC_MOUSE_BTN7 = 0x800000F4,
+		BC_MOUSE_BTN8 = 0x800000F5,
+		BC_MOUSE_BTN9 = 0x800000F6,
+		BC_MOUSE_BTN10 = 0x800000F7,
+		BC_MOUSE_BTN11 = 0x800000F8,
+		BC_MOUSE_BTN12 = 0x800000F9,
+		BC_MOUSE_BTN13 = 0x800000FA,
+		BC_MOUSE_BTN14 = 0x800000FB,
+		BC_MOUSE_BTN15 = 0x800000FC,
+		BC_MOUSE_BTN16 = 0x800000FD,
+		BC_MOUSE_BTN17 = 0x800000FE,
+		BC_MOUSE_BTN18 = 0x800000FF,
+		BC_MOUSE_BTN19 = 0x80000101,
+		BC_MOUSE_BTN20 = 0x80000102,
+		BC_MOUSE_BTN21 = 0x80000103,
+		BC_MOUSE_BTN22 = 0x80000104,
+		BC_MOUSE_BTN23 = 0x80000105,
+		BC_MOUSE_BTN24 = 0x80000106,
+		BC_MOUSE_BTN25 = 0x80000107,
+		BC_MOUSE_BTN26 = 0x80000108,
+		BC_MOUSE_BTN27 = 0x80000109,
+		BC_MOUSE_BTN28 = 0x8000010A,
+		BC_MOUSE_BTN29 = 0x8000010B,
+		BC_MOUSE_BTN30 = 0x8000010C,
+		BC_MOUSE_BTN31 = 0x8000010D,
+		BC_MOUSE_BTN32 = 0x8000010E,
+		BC_JOY_BTN1 = 0x4000010F, // Joystick/Gamepad buttons- Second most important bit signifies key is a joystick button
+		BC_JOY_BTN2 = 0x40000110,
+		BC_JOY_BTN3 = 0x40000111,
+		BC_JOY_BTN4 = 0x40000112,
+		BC_JOY_BTN5 = 0x40000113,
+		BC_JOY_BTN6 = 0x40000114,
+		BC_JOY_BTN7 = 0x40000115,
+		BC_JOY_BTN8 = 0x40000116,
+		BC_JOY_BTN9 = 0x40000117,
+		BC_JOY_BTN10 = 0x40000118,
+		BC_JOY_BTN11 = 0x40000119,
+		BC_JOY_BTN12 = 0x4000011A,
+		BC_JOY_BTN13 = 0x4000011B,
+		BC_JOY_BTN14 = 0x4000011C,
+		BC_JOY_BTN15 = 0x4000011D,
+		BC_JOY_BTN16 = 0x4000011E,
+		BC_JOY_BTN17 = 0x4000011F,
+		BC_JOY_BTN18 = 0x40000120,
+		BC_JOY_BTN19 = 0x40000121,
+		BC_JOY_BTN20 = 0x40000123,
+		BC_JOY_BTN21 = 0x40000124,
+		BC_JOY_BTN22 = 0x40000125,
+		BC_JOY_BTN23 = 0x40000126,
+		BC_JOY_BTN24 = 0x40000127,
+		BC_JOY_BTN25 = 0x40000128,
+		BC_JOY_BTN26 = 0x40000129,
+		BC_JOY_BTN27 = 0x4000012A,
+		BC_JOY_BTN28 = 0x4000012B,
+		BC_JOY_BTN29 = 0x4000012C,
+		BC_JOY_BTN30 = 0x4000012D,
+		BC_JOY_BTN31 = 0x4000012E,
+		BC_JOY_BTN32 = 0x4000012F,
+		BC_Count = 0x00000130,
+		BC_NumKeys = 0xEE, // IMPORTANT: Make sure to update these if you modify the values above
+		BC_NumMouse = 0x20,
+		BC_NumJoy = 0x20,
+	};
+
+	/**
+	 * @brief	Structure containing information about a button input event.
+	 */
+	struct ButtonEvent
+	{
+	public:
+		ButtonEvent()
+			:mIsUsed(false)
+		{ }
+
+		ButtonCode buttonCode; /**< Button code this event is referring to. */
+		UINT64 timestamp; /**< Timestamp in ticks when the event happened. */
+
+		/**
+		 * @brief	Query is the pressed button a keyboard button.
+		 */
+		bool isKeyboard() const { return (buttonCode & 0xC0000000) == 0; }
+
+		/**
+		 * @brief	Query is the pressed button a mouse button.
+		 */
+		bool isMouse() const { return (buttonCode & 0x80000000) != 0; }
+
+		/**
+		 * @brief	Query is the pressed button a gamepad button.
+		 */
+		bool isGamepad() const { return (buttonCode & 0x40000000) != 0; }
+
+		/**
+		 * @brief	Check if the event has been marked as used. Internally this means nothing
+		 *			but caller might choose to ignore an used event.
+		 */
+		bool isUsed() const { return mIsUsed; }
+
+		/**
+		 * @brief	Mark the event as used. Internally this means nothing
+		 *			but caller might choose to ignore an used event.
+		 */
+		void markAsUsed() const { mIsUsed = true; }
+	private:
+		mutable bool mIsUsed;
+	};
+
+	/**
+	 * @brief	Pointer buttons. Generally these correspond to mouse
+	 * 			buttons, but may be used in some form for touch input as well.
+	 */
+	enum class PointerEventButton
+	{
+		Left, Middle, Right, Count
+	};
+
+	/**
+	 * @brief	Type of pointer event.
+	 */
+	enum class PointerEventType
+	{
+		CursorMoved,
+		ButtonPressed,
+		ButtonReleased,
+		DoubleClick
+	};
+
+	/**
+	 * @brief	Event that gets sent out when user interacts with the screen in some way,
+	 * 			usually by moving the mouse cursor or using touch input.
+	 */
+	struct PointerEvent
+	{
+	public:
+		PointerEvent()
+			:mIsUsed(false), mouseWheelScrollAmount(0.0f), type(PointerEventType::CursorMoved),
+			shift(false), control(false), alt(false), button(PointerEventButton::Left)
+		{
+			buttonStates[0] = false;
+			buttonStates[1] = false;
+			buttonStates[2] = false;
+		}
+
+		Vector2I screenPos; /**< Screen position where the input event occurred. */
+		bool buttonStates[PointerEventButton::Count]; /**< States of the pointer buttons (e.g. mouse buttons). */
+		PointerEventButton button; /**< Button that triggered the pointer event. Might be irrelevant 
+										depending on event type. (e.g. move events don't correspond to a button. */
+		PointerEventType type; /**< Type of the pointer event. */
+
+		bool shift; /**< Is Shift button on the keyboard being held down. */
+		bool control; /**< Is Control button on the keyboard being held down. */
+		bool alt; /**< Is Alt button on the keyboard being held down. */
+
+		float mouseWheelScrollAmount; /**< If mouse wheel is being scrolled, what is the amount. Only relevant on move events. */
+
+		/**
+		 * @brief	Check if the event has been marked as used. Internally this means nothing
+		 *			but caller might choose to ignore an used event.
+		 */
+		bool isUsed() const { return mIsUsed; }
+
+		/**
+		 * @brief	Mark the event as used. Internally this means nothing
+		 *			but caller might choose to ignore an used event.
+		 */
+		void markAsUsed() const { mIsUsed = true; }
+
+	private:
+		mutable bool mIsUsed;
+	};
+
+	/**
+	 * @brief	Type of special input command types.
+	 */
+	enum class InputCommandType
+	{
+		CursorMoveLeft, CursorMoveRight, CursorMoveUp, CursorMoveDown, 
+		SelectLeft, SelectRight, SelectUp, SelectDown,
+		Escape, Delete, Backspace, Return
+	};
+
+	/**
+	 * @brief	Event that gets sent out when user inputs some text. These events may be preceeded by
+	 *			normal button events if user is typing on a keyboard. 
+	 */
+	struct TextInputEvent
+	{
+	public:
+		TextInputEvent()
+			:mIsUsed(false)
+		{ }
+
+		UINT32 textChar; /**< Character the user is inputting. */
+
+		/**
+		 * @brief	Check if the event has been marked as used. Internally this means nothing
+		 *			but caller might choose to ignore an used event.
+		 */
+		bool isUsed() const { return mIsUsed; }
+
+		/**
+		 * @brief	Mark the event as used. Internally this means nothing
+		 *			but caller might choose to ignore an used event.
+		 */
+		void markAsUsed() const { mIsUsed = true; }
+
+	private:
+		mutable bool mIsUsed;
+	};
 }

+ 516 - 516
CamelotCore/Include/CmMaterial.h → BansheeCore/Include/CmMaterial.h

@@ -1,517 +1,517 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmResource.h"
-#include "CmGpuParam.h"
-#include "CmVector2.h"
-#include "CmVector3.h"
-#include "CmVector4.h"
-#include "CmMatrix3.h"
-#include "CmMatrix4.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Helper class containing parameters for all types
-	 * 			of GPU programs used in a pass.
-	 */
-	class CM_EXPORT PassParameters
-	{
-	public:
-		GpuParamsPtr mVertParams;
-		GpuParamsPtr mFragParams;
-		GpuParamsPtr mGeomParams;
-		GpuParamsPtr mHullParams;
-		GpuParamsPtr mDomainParams;
-		GpuParamsPtr mComputeParams;
-
-		/**
-		 * @brief	Returns a set of GPU parameters based on an index.
-		 *
-		 * @note	Useful when needing to iterate over all sets of GPU parameters.
-		 */
-		GpuParamsPtr& getParamByIdx(UINT32 idx)
-		{
-			GpuParamsPtr* paramArray[] = {&mVertParams, &mFragParams, &mGeomParams, &mHullParams, &mDomainParams, &mComputeParams};
-
-			return *paramArray[idx];
-		}
-
-		/**
-		 * @brief	Returns the total number of stored sets of 
-		 * 			GPU parameters in this object.
-		 */
-		UINT32 getNumParams() const { return 6; }
-	};
-
-	/**
-	 * @brief	Material represents a shader and parameters used to set up
-	 * 			that shader. It provides a simple interface for manipulating the
-	 * 			parameters.
-	 */
-	class CM_EXPORT Material : public Resource
-	{
-	public:
-		/**
-		 * @brief	Data used to described a structure defined within a shader.
-		 */
-		struct StructData
-		{
-			StructData()
-				:size(0), data(nullptr)
-			{ }
-
-			StructData(UINT32 _size)
-				:size(_size)
-			{
-				data = std::shared_ptr<void>(cm_alloc<ScratchAlloc>(_size), &cm_free<ScratchAlloc>);
-			}
-
-			/**
-			 * @brief	Writes the specified data to the internal buffer. Caller
-			 * 			must ensure size of the provided buffer is correct.
-			 */
-			void write(void* _data)
-			{
-				memcpy(data.get(), _data, size);
-			}
-
-			std::shared_ptr<void> data;
-			UINT32 size;
-		};
-
-		~Material();
-
-		/**
-		 * @brief	Sets a shader that will be used by the material. Best technique within the
-		 * 			provided shader will be used for the material.
-		 *
-		 * @note	Shader must be set before doing any other operations with the material.
-		 * 			
-		 * 			After setting the shader if change any systems that a shader technique is 
-		 * 			dependent upon (render system, renderer, etc), you will need to call this 
-		 * 			method again on all your Materials to make sure technique used is updated.
-		 */
-		void setShader(ShaderPtr shader);
-
-		/**
-		 * @brief	Returns the currently active shader.
-		 */
-		ShaderPtr getShader() const { return mShader; }
-
-		/** @brief	Assigns a texture to the shader parameter with the specified name. */
-		void setTexture(const String& name, const HTexture& value)								{ return getParamTexture(name).set(value); }
-
-		/** @brief	Assigns a sampler state to the shader parameter with the specified name. */
-		void setSamplerState(const String& name, const HSamplerState& value)					{ return getParamSamplerState(name).set(value); }
-
-		/**   
-		 *  @brief	Assigns a float value to the shader parameter with the specified name. 
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setFloat(const String& name, float value, UINT32 arrayIdx = 0)						{ return getParamFloat(name).set(value, arrayIdx); }
-
-		/**   
-		 *  @brief	Assigns a color to the shader parameter with the specified name. 
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setColor(const String& name, const Color& value, UINT32 arrayIdx = 0);
-
-		/**   
-		 *  @brief	Assigns a 2D vector to the shader parameter with the specified name. 
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setVec2(const String& name, const Vector2& value, UINT32 arrayIdx = 0)				{ return getParamVec2(name).set(value, arrayIdx); }
-
-		/**   
-		 *  @brief	Assigns a 3D vector to the shader parameter with the specified name. 
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setVec3(const String& name, const Vector3& value, UINT32 arrayIdx = 0)				{ return getParamVec3(name).set(value, arrayIdx); }
-
-		/**   
-		 *  @brief	Assigns a 4D vector to the shader parameter with the specified name. 
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setVec4(const String& name, const Vector4& value, UINT32 arrayIdx = 0)				{ return getParamVec4(name).set(value, arrayIdx); }
-
-		/**   
-		 *  @brief	Assigns a 3x3 matrix to the shader parameter with the specified name. 
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setMat3(const String& name, const Matrix3& value, UINT32 arrayIdx = 0)				{ return getParamMat3(name).set(value, arrayIdx); }
-
-		/**   
-		 *  @brief	Assigns a 4x4 matrix to the shader parameter with the specified name. 
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setMat4(const String& name, const Matrix4& value, UINT32 arrayIdx = 0)				{ return getParamMat4(name).set(value, arrayIdx); }
-
-		/**   
-		 *  @brief	Assigns a structure to the shader parameter with the specified name.
-		 *  		
-		 *			Structure is provided as a raw buffer and caller must ensure structure in buffer
-		 *			matches what the shader expects.
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
-		 */
-		void setStructData(const String& name, void* value, UINT32 size, UINT32 arrayIdx = 0)	{ return getParamStruct(name).set(value, size, arrayIdx); }
-
-		/**
-		* @brief	Sets a render queue in which will objects with this material be rendered in. Objects
-		* 			with smaller render queue number will get rendered before objects with a large one.
-		 * 			
-		 * @note	This flag can be differently interpreted by renderers but normally you want to separate out
-		 * 			opaque and transparent objects as they usually require slightly different render ordering. 
-		 */
-		void setRenderQueue(INT16 renderQueue) { mRenderQueue = renderQueue; }
-
-		/**
-		 * @brief	Assign a parameter block buffer with the specified name.
-		 *
-		 * @note	Parameter block buffers can be used as quick way of setting multiple parameters on a material at once, or
-		 * 			potentially sharing parameters between multiple materials. This reduces driver overhead as the parameters
-		 * 			in the buffers need only be set once and then reused multiple times.
-		 */
-		void setParamBlockBuffer(const String& name, const GpuParamBlockBufferPtr& paramBlock);
-
-		/** @brief	Returns a texture assigned with the parameter with the specified name. */
-		HTexture getTexture(const String& name) const										{ return getParamTexture(name).get(); }
-
-		/** @brief	Returns a sampler state assigned with the parameter with the specified name. */
-		HSamplerState getSamplerState(const String& name) const								{ return getParamSamplerState(name).get(); }
-
-		/**
-		 * @brief	Returns a float value assigned with the parameter with the specified name.
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		float getFloat(const String& name, UINT32 arrayIdx = 0) const						{ return getParamFloat(name).get(arrayIdx); }
-
-		/**
-		 * @brief	Returns a 2D vector assigned with the parameter with the specified name.
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Vector2 getVec2(const String& name, UINT32 arrayIdx = 0) const						{ return getParamVec2(name).get(arrayIdx); }
-
-		/**
-		 * @brief	Returns a 3D vector assigned with the parameter with the specified name.
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Vector3 getVec3(const String& name, UINT32 arrayIdx = 0) const						{ return getParamVec3(name).get(arrayIdx); }
-
-		/**
-		 * @brief	Returns a 4D vector assigned with the parameter with the specified name.
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Vector4 getVec4(const String& name, UINT32 arrayIdx = 0) const						{ return getParamVec4(name).get(arrayIdx); }
-
-		/**
-		 * @brief	Returns a 3x3 matrix assigned with the parameter with the specified name.
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Matrix3 getMat3(const String& name, UINT32 arrayIdx = 0) const						{ return getParamMat3(name).get(arrayIdx); }
-
-		/**
-		 * @brief	Returns a 4x4 matrix assigned with the parameter with the specified name.
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		Matrix4 getMat4(const String& name, UINT32 arrayIdx = 0) const						{ return getParamMat4(name).get(arrayIdx); }
-
-		/**
-		 * @brief	Returns a buffer representing a structure assigned to the parameter with the specified name.
-		 *
-		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
-		 */
-		StructData getStructData(const String& name, UINT32 arrayIdx = 0) const;
-
-		/**
-		 * @brief	Returns a float GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamFloat getParamFloat(const String& name) const;
-
-		/**
-		 * @brief	Returns a 2D vector GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamVec2 getParamVec2(const String& name) const;
-
-		/**
-		 * @brief	Returns a 3D vector GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamVec3 getParamVec3(const String& name) const;
-
-		/**
-		 * @brief	Returns a 4D vector GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamVec4 getParamVec4(const String& name) const;
-
-		/**
-		 * @brief	Returns a 3x3 matrix GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamMat3 getParamMat3(const String& name) const;
-
-		/**
-		 * @brief	Returns a 4x4 matrix GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamMat4 getParamMat4(const String& name) const;
-
-		/**
-		 * @brief	Returns a structure GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamStruct getParamStruct(const String& name) const;
-
-		/**
-		 * @brief	Returns a texture GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamTexture getParamTexture(const String& name) const;
-
-		/**
-		 * @brief	Returns a sampler state GPU parameter. This parameter may be used for
-		 * 			more efficiently getting/setting GPU parameter values than calling
-		 * 			Material::get* / Material::set* methods. 
-		 *
-		 * @note	Expected behavior is that you would retrieve this parameter when
-		 * 			initially constructing the material, and then use it throughout material
-		 * 			lifetime to assign and retrieve parameter values.
-		 * 			
-		 *			If material shader changes this handle will be invalidated.
-		 */
-		GpuParamSampState getParamSamplerState(const String& name) const;
-
-		/**
-		 * @brief	Returns the currently set render queue.
-		 *
-		 * @see		Material::setRenderQueue
-		 */
-		INT16 getRenderQueue() const { return mRenderQueue; }
-
-		/**
-		 * @brief	Returns the number of passes that are used
-		 * 			by the shader contained in the material.
-		 */
-		UINT32 getNumPasses() const;
-
-		/**
-		 * @brief	Retrieves a specific shader pass.
-		 */
-		PassPtr getPass(UINT32 passIdx) const;
-
-		/**
-		 * @brief	Returns a set of parameters for all GPU programs
-		 * 			in the specified shader pass.
-		 */
-		PassParametersPtr getPassParameters(UINT32 passIdx) const;
-
-		/**
-		 * @brief	Creates a new empty material.
-		 * 			
-		 * @note	Make sure you call Material::setShader before using it.
-		 */
-		static HMaterial create();
-
-		/**
-		 * @brief	Creates a new material with the specified shader.
-		 */
-		static HMaterial create(ShaderPtr shader);
-	protected:
-		/**
-		 * @copydoc	Resource::destroy_internal
-		 */
-		void destroy_internal();
-
-		/**
-		 * @brief	Allows you to retrieve a handle to a parameter that you can then use for quickly
-		 * 			setting and retrieving parameter data. This allows you to set/get parameter data
-		 * 			without all the cost of extra lookups otherwise required.
-		 * 			
-		 * @note	All of these handles will be invalidated if material shader ever changes. It is up to the
-		 * 			caller to keep track of that.
-		 */
-		template <typename T>
-		void getParam(const String& name, GpuDataParamBase<T>& output) const
-		{
-			throwIfNotInitialized();
-
-			auto iterFind = mValidParams.find(name);
-			if(iterFind == mValidParams.end())
-			{
-				LOGWRN("Material doesn't have a parameter named " + name);
-				return;
-			}
-
-			const String& gpuVarName = iterFind->second;
-			GpuParamsPtr params = findParamsWithName(gpuVarName);
-
-			params->getParam<T>(gpuVarName, output);
-		}
-
-	private:
-		friend class MaterialManager;
-
-		ShaderPtr mShader;
-		TechniquePtr mBestTechnique;
-		INT16 mRenderQueue;
-
-		Set<String> mValidShareableParamBlocks;
-		Map<String, String> mValidParams; // Also maps Shader param name -> gpu variable name
-
-		Vector<PassParametersPtr> mParametersPerPass;
-		Vector<GpuParamBlockBufferPtr> mParamBuffers;
-
-		Material();
-
-		/**
-		 * @brief	Throw an exception if no shader is set, or no acceptable
-		 * 			technique was found.
-		 */
-		void throwIfNotInitialized() const;
-
-		/**
-		 * @brief	Retrieves a list of all shader GPU parameters, and the GPU program variable names they map to.
-		 */
-		const Map<String, String>& getValidParamNames() const { return mValidParams; }
-
-		/**
-		 * @brief	Initializes the material by using the best technique from the currently set shader. Shader
-		 * 			must contain the technique that matches the current renderer and render system.
-		 */
-		void initBestTechnique();
-
-		/**
-		 * @brief	Constructs a map containing all data parameters (e.g. float, vector3, color).
-		 * 			Map contains parameter names and descriptions.
-		 */
-		Map<String, const GpuParamDataDesc*> determineValidDataParameters(const Vector<const GpuParamDesc*>& paramDescs) const;
-
-		/**
-		 * @brief	Constructs a list containing all object parameter (e.g. texture, sampler state) names.
-		 */
-		Set<String> determineValidObjectParameters(const Vector<const GpuParamDesc*>& paramDescs) const;
-
-		/**
-		 * @brief	Constructs a list containing all shareable parameter block names. Shareable blocks may be shared between
-		 * 			different GPU programs, passes or even materials. 
-		 */
-		Set<String> determineValidShareableParamBlocks(const Vector<const GpuParamDesc*>& paramDescs) const;
-
-		/**
-		 * @brief	Constructs a map that maps parameter names to a parameter block.
-		 */
-		Map<String, String> determineParameterToBlockMapping(const Vector<const GpuParamDesc*>& paramDescs);
-
-		/**
-		 * @brief	Checks are the specified two parameters equal
-		 *
-		 * @param	paramA			   	The parameter a to compare.
-		 * @param	paramB			   	The parameter b to compare.
-		 * @param	ignoreBufferOffsets	(optional) If true, parameter offsets into the parameter buffer will be ignored
-		 * 								when comparing.
-		 */
-		bool areParamsEqual(const GpuParamDataDesc& paramA, const GpuParamDataDesc& paramB, bool ignoreBufferOffsets = false) const;
-
-		/**
-		 * @brief	Frees all parameter block buffers.
-		 */
-		void freeParamBuffers();
-
-		/**
-		 * @brief	Finds a set of GPU parameters containing a data (e.g. float, vector2) parameter with the provided name.
-		 */
-		GpuParamsPtr findParamsWithName(const String& name) const;
-
-		/**
-		 * @brief	Finds a set of GPU parameters containing a texture parameter with the provided name.
-		 */
-		GpuParamsPtr findTexWithName(const String& name) const;
-
-		/**
-		 * @brief	Finds a set of GPU parameters containing a sampler state parameter with the provided name.
-		 */
-		GpuParamsPtr findSamplerStateWithName(const String& name) const;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-		
-	public:
-		friend class MaterialRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmResource.h"
+#include "CmGpuParam.h"
+#include "CmVector2.h"
+#include "CmVector3.h"
+#include "CmVector4.h"
+#include "CmMatrix3.h"
+#include "CmMatrix4.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Helper class containing parameters for all types
+	 * 			of GPU programs used in a pass.
+	 */
+	class BS_CORE_EXPORT PassParameters
+	{
+	public:
+		GpuParamsPtr mVertParams;
+		GpuParamsPtr mFragParams;
+		GpuParamsPtr mGeomParams;
+		GpuParamsPtr mHullParams;
+		GpuParamsPtr mDomainParams;
+		GpuParamsPtr mComputeParams;
+
+		/**
+		 * @brief	Returns a set of GPU parameters based on an index.
+		 *
+		 * @note	Useful when needing to iterate over all sets of GPU parameters.
+		 */
+		GpuParamsPtr& getParamByIdx(UINT32 idx)
+		{
+			GpuParamsPtr* paramArray[] = {&mVertParams, &mFragParams, &mGeomParams, &mHullParams, &mDomainParams, &mComputeParams};
+
+			return *paramArray[idx];
+		}
+
+		/**
+		 * @brief	Returns the total number of stored sets of 
+		 * 			GPU parameters in this object.
+		 */
+		UINT32 getNumParams() const { return 6; }
+	};
+
+	/**
+	 * @brief	Material represents a shader and parameters used to set up
+	 * 			that shader. It provides a simple interface for manipulating the
+	 * 			parameters.
+	 */
+	class BS_CORE_EXPORT Material : public Resource
+	{
+	public:
+		/**
+		 * @brief	Data used to described a structure defined within a shader.
+		 */
+		struct StructData
+		{
+			StructData()
+				:size(0), data(nullptr)
+			{ }
+
+			StructData(UINT32 _size)
+				:size(_size)
+			{
+				data = std::shared_ptr<void>(cm_alloc<ScratchAlloc>(_size), &cm_free<ScratchAlloc>);
+			}
+
+			/**
+			 * @brief	Writes the specified data to the internal buffer. Caller
+			 * 			must ensure size of the provided buffer is correct.
+			 */
+			void write(void* _data)
+			{
+				memcpy(data.get(), _data, size);
+			}
+
+			std::shared_ptr<void> data;
+			UINT32 size;
+		};
+
+		~Material();
+
+		/**
+		 * @brief	Sets a shader that will be used by the material. Best technique within the
+		 * 			provided shader will be used for the material.
+		 *
+		 * @note	Shader must be set before doing any other operations with the material.
+		 * 			
+		 * 			After setting the shader if change any systems that a shader technique is 
+		 * 			dependent upon (render system, renderer, etc), you will need to call this 
+		 * 			method again on all your Materials to make sure technique used is updated.
+		 */
+		void setShader(ShaderPtr shader);
+
+		/**
+		 * @brief	Returns the currently active shader.
+		 */
+		ShaderPtr getShader() const { return mShader; }
+
+		/** @brief	Assigns a texture to the shader parameter with the specified name. */
+		void setTexture(const String& name, const HTexture& value)								{ return getParamTexture(name).set(value); }
+
+		/** @brief	Assigns a sampler state to the shader parameter with the specified name. */
+		void setSamplerState(const String& name, const HSamplerState& value)					{ return getParamSamplerState(name).set(value); }
+
+		/**   
+		 *  @brief	Assigns a float value to the shader parameter with the specified name. 
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setFloat(const String& name, float value, UINT32 arrayIdx = 0)						{ return getParamFloat(name).set(value, arrayIdx); }
+
+		/**   
+		 *  @brief	Assigns a color to the shader parameter with the specified name. 
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setColor(const String& name, const Color& value, UINT32 arrayIdx = 0);
+
+		/**   
+		 *  @brief	Assigns a 2D vector to the shader parameter with the specified name. 
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setVec2(const String& name, const Vector2& value, UINT32 arrayIdx = 0)				{ return getParamVec2(name).set(value, arrayIdx); }
+
+		/**   
+		 *  @brief	Assigns a 3D vector to the shader parameter with the specified name. 
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setVec3(const String& name, const Vector3& value, UINT32 arrayIdx = 0)				{ return getParamVec3(name).set(value, arrayIdx); }
+
+		/**   
+		 *  @brief	Assigns a 4D vector to the shader parameter with the specified name. 
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setVec4(const String& name, const Vector4& value, UINT32 arrayIdx = 0)				{ return getParamVec4(name).set(value, arrayIdx); }
+
+		/**   
+		 *  @brief	Assigns a 3x3 matrix to the shader parameter with the specified name. 
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setMat3(const String& name, const Matrix3& value, UINT32 arrayIdx = 0)				{ return getParamMat3(name).set(value, arrayIdx); }
+
+		/**   
+		 *  @brief	Assigns a 4x4 matrix to the shader parameter with the specified name. 
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setMat4(const String& name, const Matrix4& value, UINT32 arrayIdx = 0)				{ return getParamMat4(name).set(value, arrayIdx); }
+
+		/**   
+		 *  @brief	Assigns a structure to the shader parameter with the specified name.
+		 *  		
+		 *			Structure is provided as a raw buffer and caller must ensure structure in buffer
+		 *			matches what the shader expects.
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index to assign the value to.
+		 */
+		void setStructData(const String& name, void* value, UINT32 size, UINT32 arrayIdx = 0)	{ return getParamStruct(name).set(value, size, arrayIdx); }
+
+		/**
+		* @brief	Sets a render queue in which will objects with this material be rendered in. Objects
+		* 			with smaller render queue number will get rendered before objects with a large one.
+		 * 			
+		 * @note	This flag can be differently interpreted by renderers but normally you want to separate out
+		 * 			opaque and transparent objects as they usually require slightly different render ordering. 
+		 */
+		void setRenderQueue(INT16 renderQueue) { mRenderQueue = renderQueue; }
+
+		/**
+		 * @brief	Assign a parameter block buffer with the specified name.
+		 *
+		 * @note	Parameter block buffers can be used as quick way of setting multiple parameters on a material at once, or
+		 * 			potentially sharing parameters between multiple materials. This reduces driver overhead as the parameters
+		 * 			in the buffers need only be set once and then reused multiple times.
+		 */
+		void setParamBlockBuffer(const String& name, const GpuParamBlockBufferPtr& paramBlock);
+
+		/** @brief	Returns a texture assigned with the parameter with the specified name. */
+		HTexture getTexture(const String& name) const										{ return getParamTexture(name).get(); }
+
+		/** @brief	Returns a sampler state assigned with the parameter with the specified name. */
+		HSamplerState getSamplerState(const String& name) const								{ return getParamSamplerState(name).get(); }
+
+		/**
+		 * @brief	Returns a float value assigned with the parameter with the specified name.
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		float getFloat(const String& name, UINT32 arrayIdx = 0) const						{ return getParamFloat(name).get(arrayIdx); }
+
+		/**
+		 * @brief	Returns a 2D vector assigned with the parameter with the specified name.
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Vector2 getVec2(const String& name, UINT32 arrayIdx = 0) const						{ return getParamVec2(name).get(arrayIdx); }
+
+		/**
+		 * @brief	Returns a 3D vector assigned with the parameter with the specified name.
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Vector3 getVec3(const String& name, UINT32 arrayIdx = 0) const						{ return getParamVec3(name).get(arrayIdx); }
+
+		/**
+		 * @brief	Returns a 4D vector assigned with the parameter with the specified name.
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Vector4 getVec4(const String& name, UINT32 arrayIdx = 0) const						{ return getParamVec4(name).get(arrayIdx); }
+
+		/**
+		 * @brief	Returns a 3x3 matrix assigned with the parameter with the specified name.
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Matrix3 getMat3(const String& name, UINT32 arrayIdx = 0) const						{ return getParamMat3(name).get(arrayIdx); }
+
+		/**
+		 * @brief	Returns a 4x4 matrix assigned with the parameter with the specified name.
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		Matrix4 getMat4(const String& name, UINT32 arrayIdx = 0) const						{ return getParamMat4(name).get(arrayIdx); }
+
+		/**
+		 * @brief	Returns a buffer representing a structure assigned to the parameter with the specified name.
+		 *
+		 *			Optionally if the parameter is an array you may provide an array index you which to retrieve.
+		 */
+		StructData getStructData(const String& name, UINT32 arrayIdx = 0) const;
+
+		/**
+		 * @brief	Returns a float GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamFloat getParamFloat(const String& name) const;
+
+		/**
+		 * @brief	Returns a 2D vector GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamVec2 getParamVec2(const String& name) const;
+
+		/**
+		 * @brief	Returns a 3D vector GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamVec3 getParamVec3(const String& name) const;
+
+		/**
+		 * @brief	Returns a 4D vector GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamVec4 getParamVec4(const String& name) const;
+
+		/**
+		 * @brief	Returns a 3x3 matrix GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamMat3 getParamMat3(const String& name) const;
+
+		/**
+		 * @brief	Returns a 4x4 matrix GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamMat4 getParamMat4(const String& name) const;
+
+		/**
+		 * @brief	Returns a structure GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamStruct getParamStruct(const String& name) const;
+
+		/**
+		 * @brief	Returns a texture GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamTexture getParamTexture(const String& name) const;
+
+		/**
+		 * @brief	Returns a sampler state GPU parameter. This parameter may be used for
+		 * 			more efficiently getting/setting GPU parameter values than calling
+		 * 			Material::get* / Material::set* methods. 
+		 *
+		 * @note	Expected behavior is that you would retrieve this parameter when
+		 * 			initially constructing the material, and then use it throughout material
+		 * 			lifetime to assign and retrieve parameter values.
+		 * 			
+		 *			If material shader changes this handle will be invalidated.
+		 */
+		GpuParamSampState getParamSamplerState(const String& name) const;
+
+		/**
+		 * @brief	Returns the currently set render queue.
+		 *
+		 * @see		Material::setRenderQueue
+		 */
+		INT16 getRenderQueue() const { return mRenderQueue; }
+
+		/**
+		 * @brief	Returns the number of passes that are used
+		 * 			by the shader contained in the material.
+		 */
+		UINT32 getNumPasses() const;
+
+		/**
+		 * @brief	Retrieves a specific shader pass.
+		 */
+		PassPtr getPass(UINT32 passIdx) const;
+
+		/**
+		 * @brief	Returns a set of parameters for all GPU programs
+		 * 			in the specified shader pass.
+		 */
+		PassParametersPtr getPassParameters(UINT32 passIdx) const;
+
+		/**
+		 * @brief	Creates a new empty material.
+		 * 			
+		 * @note	Make sure you call Material::setShader before using it.
+		 */
+		static HMaterial create();
+
+		/**
+		 * @brief	Creates a new material with the specified shader.
+		 */
+		static HMaterial create(ShaderPtr shader);
+	protected:
+		/**
+		 * @copydoc	Resource::destroy_internal
+		 */
+		void destroy_internal();
+
+		/**
+		 * @brief	Allows you to retrieve a handle to a parameter that you can then use for quickly
+		 * 			setting and retrieving parameter data. This allows you to set/get parameter data
+		 * 			without all the cost of extra lookups otherwise required.
+		 * 			
+		 * @note	All of these handles will be invalidated if material shader ever changes. It is up to the
+		 * 			caller to keep track of that.
+		 */
+		template <typename T>
+		void getParam(const String& name, GpuDataParamBase<T>& output) const
+		{
+			throwIfNotInitialized();
+
+			auto iterFind = mValidParams.find(name);
+			if(iterFind == mValidParams.end())
+			{
+				LOGWRN("Material doesn't have a parameter named " + name);
+				return;
+			}
+
+			const String& gpuVarName = iterFind->second;
+			GpuParamsPtr params = findParamsWithName(gpuVarName);
+
+			params->getParam<T>(gpuVarName, output);
+		}
+
+	private:
+		friend class MaterialManager;
+
+		ShaderPtr mShader;
+		TechniquePtr mBestTechnique;
+		INT16 mRenderQueue;
+
+		Set<String> mValidShareableParamBlocks;
+		Map<String, String> mValidParams; // Also maps Shader param name -> gpu variable name
+
+		Vector<PassParametersPtr> mParametersPerPass;
+		Vector<GpuParamBlockBufferPtr> mParamBuffers;
+
+		Material();
+
+		/**
+		 * @brief	Throw an exception if no shader is set, or no acceptable
+		 * 			technique was found.
+		 */
+		void throwIfNotInitialized() const;
+
+		/**
+		 * @brief	Retrieves a list of all shader GPU parameters, and the GPU program variable names they map to.
+		 */
+		const Map<String, String>& getValidParamNames() const { return mValidParams; }
+
+		/**
+		 * @brief	Initializes the material by using the best technique from the currently set shader. Shader
+		 * 			must contain the technique that matches the current renderer and render system.
+		 */
+		void initBestTechnique();
+
+		/**
+		 * @brief	Constructs a map containing all data parameters (e.g. float, vector3, color).
+		 * 			Map contains parameter names and descriptions.
+		 */
+		Map<String, const GpuParamDataDesc*> determineValidDataParameters(const Vector<const GpuParamDesc*>& paramDescs) const;
+
+		/**
+		 * @brief	Constructs a list containing all object parameter (e.g. texture, sampler state) names.
+		 */
+		Set<String> determineValidObjectParameters(const Vector<const GpuParamDesc*>& paramDescs) const;
+
+		/**
+		 * @brief	Constructs a list containing all shareable parameter block names. Shareable blocks may be shared between
+		 * 			different GPU programs, passes or even materials. 
+		 */
+		Set<String> determineValidShareableParamBlocks(const Vector<const GpuParamDesc*>& paramDescs) const;
+
+		/**
+		 * @brief	Constructs a map that maps parameter names to a parameter block.
+		 */
+		Map<String, String> determineParameterToBlockMapping(const Vector<const GpuParamDesc*>& paramDescs);
+
+		/**
+		 * @brief	Checks are the specified two parameters equal
+		 *
+		 * @param	paramA			   	The parameter a to compare.
+		 * @param	paramB			   	The parameter b to compare.
+		 * @param	ignoreBufferOffsets	(optional) If true, parameter offsets into the parameter buffer will be ignored
+		 * 								when comparing.
+		 */
+		bool areParamsEqual(const GpuParamDataDesc& paramA, const GpuParamDataDesc& paramB, bool ignoreBufferOffsets = false) const;
+
+		/**
+		 * @brief	Frees all parameter block buffers.
+		 */
+		void freeParamBuffers();
+
+		/**
+		 * @brief	Finds a set of GPU parameters containing a data (e.g. float, vector2) parameter with the provided name.
+		 */
+		GpuParamsPtr findParamsWithName(const String& name) const;
+
+		/**
+		 * @brief	Finds a set of GPU parameters containing a texture parameter with the provided name.
+		 */
+		GpuParamsPtr findTexWithName(const String& name) const;
+
+		/**
+		 * @brief	Finds a set of GPU parameters containing a sampler state parameter with the provided name.
+		 */
+		GpuParamsPtr findSamplerStateWithName(const String& name) const;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+		
+	public:
+		friend class MaterialRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
 }

+ 25 - 25
CamelotCore/Include/CmMaterialManager.h → BansheeCore/Include/CmMaterialManager.h

@@ -1,26 +1,26 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Material manager handles material creation.
-	 */
-	class CM_EXPORT MaterialManager : public Module<MaterialManager>
-	{
-	public:
-		/**
-		 * @brief	Creates a new material without any assigned shader.
-		 *
-		 * @note	Make sure to call Material::setShader before using it.
-		 */
-		MaterialPtr create() const;
-
-		/**
-		 * @brief	Creates a new material with the specified shader.
-		 */
-		MaterialPtr create(ShaderPtr shader) const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Material manager handles material creation.
+	 */
+	class BS_CORE_EXPORT MaterialManager : public Module<MaterialManager>
+	{
+	public:
+		/**
+		 * @brief	Creates a new material without any assigned shader.
+		 *
+		 * @note	Make sure to call Material::setShader before using it.
+		 */
+		MaterialPtr create() const;
+
+		/**
+		 * @brief	Creates a new material with the specified shader.
+		 */
+		MaterialPtr create(ShaderPtr shader) const;
+	};
 }

+ 590 - 590
CamelotCore/Include/CmMaterialRTTI.h → BansheeCore/Include/CmMaterialRTTI.h

@@ -1,591 +1,591 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmVector2.h"
-#include "CmVector3.h"
-#include "CmVector4.h"
-#include "CmMatrix3.h"
-#include "CmMatrix4.h"
-#include "CmMaterial.h"
-#include "CmGpuParams.h"
-#include "CmShader.h"
-#include "CmDebug.h"
-#include "CmException.h"
-
-namespace BansheeEngine
-{
-	/************************************************************************/
-	/* 					HELPER STRUCTS TO HELP SERIALIZING                  */
-	/************************************************************************/
-
-	class CM_EXPORT MaterialFloatParam : public IReflectable
-	{
-	public:
-		String name;
-		float value;
-		UINT32 arrayIdx;
-
-		friend class MaterialFloatParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialVec2Param : public IReflectable
-	{
-	public:
-		String name;
-		Vector2 value;
-		UINT32 arrayIdx;
-
-		friend class MaterialVec2ParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialVec3Param : public IReflectable
-	{
-	public:
-		String name;
-		Vector3 value;
-		UINT32 arrayIdx;
-
-		friend class MaterialVec3ParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialVec4Param : public IReflectable
-	{
-	public:
-		String name;
-		Vector4 value;
-		UINT32 arrayIdx;
-
-		friend class MaterialVec4ParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialMat3Param : public IReflectable
-	{
-	public:
-		String name;
-		Matrix3 value;
-		UINT32 arrayIdx;
-
-		friend class MaterialMat3ParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialMat4Param : public IReflectable
-	{
-	public:
-		String name;
-		Matrix4 value;
-		UINT32 arrayIdx;
-
-		friend class MaterialMat4ParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialStructParam : public IReflectable
-	{
-	public:
-		String name;
-		Material::StructData value;
-		UINT32 arrayIdx;
-		UINT32 elementSize;
-
-		friend class MaterialStructParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialTextureParam : public IReflectable
-	{
-	public:
-		String name;
-		HTexture value;
-
-		friend class MaterialTextureParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialSamplerStateParam : public IReflectable
-	{
-	public:
-		String name;
-		HSamplerState value;
-
-		friend class MaterialSamplerStateParamRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	class CM_EXPORT MaterialParams : public IReflectable
-	{
-	public:
-		Vector<MaterialFloatParam> floatParams;
-		Vector<MaterialVec2Param> vec2Params;
-		Vector<MaterialVec3Param> vec3Params;
-		Vector<MaterialVec4Param> vec4Params;
-		Vector<MaterialMat3Param> mat3Params;
-		Vector<MaterialMat4Param> mat4Params;
-		Vector<MaterialStructParam> structParams;
-		Vector<MaterialTextureParam> textureParams;
-		Vector<MaterialSamplerStateParam> samplerStateParams;
-
-		friend class MaterialParamsRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
-
-	/************************************************************************/
-	/* 				RTTI FOR HELPER STRUCTS TO HELP SERIALIZING             */
-	/************************************************************************/
-
-	class CM_EXPORT MaterialFloatParamRTTI : public RTTIType<MaterialFloatParam, IReflectable, MaterialFloatParamRTTI>
-	{
-	public:
-		String& getName(MaterialFloatParam* obj) { return obj->name; }
-		void setName(MaterialFloatParam* obj, String& name) { obj->name = name; }
-
-		float& getValue(MaterialFloatParam* obj) { return obj->value; }
-		void setValue(MaterialFloatParam* obj, float& value) { obj->value = value; }
-
-		UINT32& getArrayIdx(MaterialFloatParam* obj) { return obj->arrayIdx; }
-		void setArrayIdx(MaterialFloatParam* obj, UINT32& value) { obj->arrayIdx = value; }
-
-		MaterialFloatParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialFloatParamRTTI::getName, &MaterialFloatParamRTTI::setName);
-			addPlainField("value", 1, &MaterialFloatParamRTTI::getValue, &MaterialFloatParamRTTI::setValue);
-			addPlainField("arrayIdx", 2, &MaterialFloatParamRTTI::getArrayIdx, &MaterialFloatParamRTTI::setArrayIdx);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialFloatParam";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamFloat; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialFloatParam, ScratchAlloc>(); 
-		}
-	};
-
-	class CM_EXPORT MaterialVec2ParamRTTI : public RTTIType<MaterialVec2Param, IReflectable, MaterialVec2ParamRTTI>
-	{
-	public:
-		String& getName(MaterialVec2Param* obj) { return obj->name; }
-		void setName(MaterialVec2Param* obj, String& name) { obj->name = name; }
-
-		Vector2& getValue(MaterialVec2Param* obj) { return obj->value; }
-		void setValue(MaterialVec2Param* obj, Vector2& value) { obj->value = value; }
-
-		UINT32& getArrayIdx(MaterialVec2Param* obj) { return obj->arrayIdx; }
-		void setArrayIdx(MaterialVec2Param* obj, UINT32& value) { obj->arrayIdx = value; }
-
-		MaterialVec2ParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialVec2ParamRTTI::getName, &MaterialVec2ParamRTTI::setName);
-			addPlainField("value", 1, &MaterialVec2ParamRTTI::getValue, &MaterialVec2ParamRTTI::setValue);
-			addPlainField("arrayIdx", 2, &MaterialVec2ParamRTTI::getArrayIdx, &MaterialVec2ParamRTTI::setArrayIdx);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialVec2Param";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamVec2; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialVec2Param, ScratchAlloc>(); 
-		}
-	};
-
-	class CM_EXPORT MaterialVec3ParamRTTI : public RTTIType<MaterialVec3Param, IReflectable, MaterialVec3ParamRTTI>
-	{
-	public:
-		String& getName(MaterialVec3Param* obj) { return obj->name; }
-		void setName(MaterialVec3Param* obj, String& name) { obj->name = name; }
-
-		Vector3& getValue(MaterialVec3Param* obj) { return obj->value; }
-		void setValue(MaterialVec3Param* obj, Vector3& value) { obj->value = value; }
-
-		UINT32& getArrayIdx(MaterialVec3Param* obj) { return obj->arrayIdx; }
-		void setArrayIdx(MaterialVec3Param* obj, UINT32& value) { obj->arrayIdx = value; }
-
-		MaterialVec3ParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialVec3ParamRTTI::getName, &MaterialVec3ParamRTTI::setName);
-			addPlainField("value", 1, &MaterialVec3ParamRTTI::getValue, &MaterialVec3ParamRTTI::setValue);
-			addPlainField("arrayIdx", 2, &MaterialVec3ParamRTTI::getArrayIdx, &MaterialVec3ParamRTTI::setArrayIdx);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialVec3Param";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamVec3; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialVec3Param, ScratchAlloc>(); 
-		}
-	};
-
-	class CM_EXPORT MaterialVec4ParamRTTI : public RTTIType<MaterialVec4Param, IReflectable, MaterialVec4ParamRTTI>
-	{
-	public:
-		String& getName(MaterialVec4Param* obj) { return obj->name; }
-		void setName(MaterialVec4Param* obj, String& name) { obj->name = name; }
-
-		Vector4& getValue(MaterialVec4Param* obj) { return obj->value; }
-		void setValue(MaterialVec4Param* obj, Vector4& value) { obj->value = value; }
-
-		UINT32& getArrayIdx(MaterialVec4Param* obj) { return obj->arrayIdx; }
-		void setArrayIdx(MaterialVec4Param* obj, UINT32& value) { obj->arrayIdx = value; }
-
-		MaterialVec4ParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialVec4ParamRTTI::getName, &MaterialVec4ParamRTTI::setName);
-			addPlainField("value", 1, &MaterialVec4ParamRTTI::getValue, &MaterialVec4ParamRTTI::setValue);
-			addPlainField("arrayIdx", 2, &MaterialVec4ParamRTTI::getArrayIdx, &MaterialVec4ParamRTTI::setArrayIdx);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialVec4Param";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamVec4; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{
-			return cm_shared_ptr<MaterialVec4Param, ScratchAlloc>();
-		}
-	};
-
-	class CM_EXPORT MaterialMat3ParamRTTI : public RTTIType<MaterialMat3Param, IReflectable, MaterialMat3ParamRTTI>
-	{
-	public:
-		String& getName(MaterialMat3Param* obj) { return obj->name; }
-		void setName(MaterialMat3Param* obj, String& name) { obj->name = name; }
-
-		Matrix3& getValue(MaterialMat3Param* obj) { return obj->value; }
-		void setValue(MaterialMat3Param* obj, Matrix3& value) { obj->value = value; }
-
-		UINT32& getArrayIdx(MaterialMat3Param* obj) { return obj->arrayIdx; }
-		void setArrayIdx(MaterialMat3Param* obj, UINT32& value) { obj->arrayIdx = value; }
-
-		MaterialMat3ParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialMat3ParamRTTI::getName, &MaterialMat3ParamRTTI::setName);
-			addPlainField("value", 1, &MaterialMat3ParamRTTI::getValue, &MaterialMat3ParamRTTI::setValue);
-			addPlainField("arrayIdx", 2, &MaterialMat3ParamRTTI::getArrayIdx, &MaterialMat3ParamRTTI::setArrayIdx);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialMat3Param";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamMat3; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialMat3Param, ScratchAlloc>();
-		}
-	};
-
-	class CM_EXPORT MaterialMat4ParamRTTI : public RTTIType<MaterialMat4Param, IReflectable, MaterialMat4ParamRTTI>
-	{
-	public:
-		String& getName(MaterialMat4Param* obj) { return obj->name; }
-		void setName(MaterialMat4Param* obj, String& name) { obj->name = name; }
-
-		Matrix4& getValue(MaterialMat4Param* obj) { return obj->value; }
-		void setValue(MaterialMat4Param* obj, Matrix4& value) { obj->value = value; }
-
-		UINT32& getArrayIdx(MaterialMat4Param* obj) { return obj->arrayIdx; }
-		void setArrayIdx(MaterialMat4Param* obj, UINT32& value) { obj->arrayIdx = value; }
-
-		MaterialMat4ParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialMat4ParamRTTI::getName, &MaterialMat4ParamRTTI::setName);
-			addPlainField("value", 1, &MaterialMat4ParamRTTI::getValue, &MaterialMat4ParamRTTI::setValue);
-			addPlainField("arrayIdx", 2, &MaterialMat4ParamRTTI::getArrayIdx, &MaterialMat4ParamRTTI::setArrayIdx);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialMat4Param";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamMat4; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialMat4Param, ScratchAlloc>();
-		}
-	};
-
-	class CM_EXPORT MaterialStructParamRTTI : public RTTIType<MaterialStructParam, IReflectable, MaterialStructParamRTTI>
-	{
-	public:
-		String& getName(MaterialStructParam* obj) { return obj->name; }
-		void setName(MaterialStructParam* obj, String& name) { obj->name = name; }
-
-		ManagedDataBlock getValue(MaterialStructParam* obj) 
-		{ 
-			ManagedDataBlock returnValue(obj->value.size);
-
-			UINT8* data = returnValue.getData();
-			memcpy(data, obj->value.data.get(), obj->value.size);
-
-			return returnValue; 
-		}
-
-		void setValue(MaterialStructParam* obj, ManagedDataBlock value) 
-		{ 
-			obj->value = Material::StructData(value.getSize()); 
-			obj->value.write(value.getData());
-			
-		}
-
-		UINT32& getArrayIdx(MaterialStructParam* obj) { return obj->arrayIdx; }
-		void setArrayIdx(MaterialStructParam* obj, UINT32& value) { obj->arrayIdx = value; }
-
-		UINT32& getElementSize(MaterialStructParam* obj) { return obj->elementSize; }
-		void setElementSize(MaterialStructParam* obj, UINT32& value) { obj->elementSize = value; }
-
-		MaterialStructParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialStructParamRTTI::getName, &MaterialStructParamRTTI::setName);
-			addDataBlockField("value", 1, &MaterialStructParamRTTI::getValue, &MaterialStructParamRTTI::setValue);
-			addPlainField("arrayIdx", 2, &MaterialStructParamRTTI::getArrayIdx, &MaterialStructParamRTTI::setArrayIdx);
-			addPlainField("elementSize", 3, &MaterialStructParamRTTI::getElementSize, &MaterialStructParamRTTI::setElementSize);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialStructParam";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamStruct; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialStructParam, ScratchAlloc>();
-		}
-	};
-
-	class CM_EXPORT MaterialTextureParamRTTI : public RTTIType<MaterialTextureParam, IReflectable, MaterialTextureParamRTTI>
-	{
-	public:
-		String& getName(MaterialTextureParam* obj) { return obj->name; }
-		void setName(MaterialTextureParam* obj, String& name) { obj->name = name; }
-
-		HTexture& getValue(MaterialTextureParam* obj) { return obj->value; }
-		void setValue(MaterialTextureParam* obj, HTexture& value) { obj->value = value; }
-
-		MaterialTextureParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialTextureParamRTTI::getName, &MaterialTextureParamRTTI::setName);
-			addReflectableField("value", 1, &MaterialTextureParamRTTI::getValue, &MaterialTextureParamRTTI::setValue);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialTextureParam";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamTexture; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialTextureParam, ScratchAlloc>();
-		}
-	};
-
-	class CM_EXPORT MaterialSamplerStateParamRTTI : public RTTIType<MaterialSamplerStateParam, IReflectable, MaterialSamplerStateParamRTTI>
-	{
-	public:
-		String& getName(MaterialSamplerStateParam* obj) { return obj->name; }
-		void setName(MaterialSamplerStateParam* obj, String& name) { obj->name = name; }
-
-		HSamplerState& getValue(MaterialSamplerStateParam* obj) { return obj->value; }
-		void setValue(MaterialSamplerStateParam* obj, HSamplerState& value) { obj->value = value; }
-
-		MaterialSamplerStateParamRTTI()
-		{
-			addPlainField("name", 0, &MaterialSamplerStateParamRTTI::getName, &MaterialSamplerStateParamRTTI::setName);
-			addReflectableField("value", 1, &MaterialSamplerStateParamRTTI::getValue, &MaterialSamplerStateParamRTTI::setValue);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialSamplerStateParam";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParamSamplerState; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialSamplerStateParam, ScratchAlloc>();
-		}
-	};
-
-	class CM_EXPORT MaterialParamsRTTI : public RTTIType<MaterialParams, IReflectable, MaterialParamsRTTI>
-	{
-	public:
-		MaterialFloatParam& getFloatParam(MaterialParams* obj, UINT32 idx) { return obj->floatParams[idx]; }
-		void setFloatParam(MaterialParams* obj, UINT32 idx, MaterialFloatParam& param) { obj->floatParams[idx] = param; }
-		UINT32 getFloatArraySize(MaterialParams* obj) { return (UINT32)obj->floatParams.size(); }
-		void setFloatArraySize(MaterialParams* obj, UINT32 size) { obj->floatParams.resize(size); }
-
-		MaterialVec2Param& getVec2Param(MaterialParams* obj, UINT32 idx) { return obj->vec2Params[idx]; }
-		void setVec2Param(MaterialParams* obj, UINT32 idx, MaterialVec2Param& param) { obj->vec2Params[idx] = param; }
-		UINT32 getVec2ArraySize(MaterialParams* obj) { return (UINT32)obj->vec2Params.size(); }
-		void setVec2ArraySize(MaterialParams* obj, UINT32 size) { obj->vec2Params.resize(size); }
-
-		MaterialVec3Param& getVec3Param(MaterialParams* obj, UINT32 idx) { return obj->vec3Params[idx]; }
-		void setVec3Param(MaterialParams* obj, UINT32 idx, MaterialVec3Param& param) { obj->vec3Params[idx] = param; }
-		UINT32 getVec3ArraySize(MaterialParams* obj) { return (UINT32)obj->vec3Params.size(); }
-		void setVec3ArraySize(MaterialParams* obj, UINT32 size) { obj->vec3Params.resize(size); }
-
-		MaterialVec4Param& getVec4Param(MaterialParams* obj, UINT32 idx) { return obj->vec4Params[idx]; }
-		void setVec4Param(MaterialParams* obj, UINT32 idx, MaterialVec4Param& param) { obj->vec4Params[idx] = param; }
-		UINT32 getVec4ArraySize(MaterialParams* obj) { return (UINT32)obj->vec4Params.size(); }
-		void setVec4ArraySize(MaterialParams* obj, UINT32 size) { obj->vec4Params.resize(size); }
-
-		MaterialMat3Param& getMat3Param(MaterialParams* obj, UINT32 idx) { return obj->mat3Params[idx]; }
-		void setMat3Param(MaterialParams* obj, UINT32 idx, MaterialMat3Param& param) { obj->mat3Params[idx] = param; }
-		UINT32 getMat3ArraySize(MaterialParams* obj) { return (UINT32)obj->mat3Params.size(); }
-		void setMat3ArraySize(MaterialParams* obj, UINT32 size) { obj->mat3Params.resize(size); }
-
-		MaterialMat4Param& getMat4Param(MaterialParams* obj, UINT32 idx) { return obj->mat4Params[idx]; }
-		void setMat4Param(MaterialParams* obj, UINT32 idx, MaterialMat4Param& param) { obj->mat4Params[idx] = param; }
-		UINT32 getMat4ArraySize(MaterialParams* obj) { return (UINT32)obj->mat4Params.size(); }
-		void setMat4ArraySize(MaterialParams* obj, UINT32 size) { obj->mat4Params.resize(size); }
-
-		MaterialStructParam& getStructParam(MaterialParams* obj, UINT32 idx) { return obj->structParams[idx]; }
-		void setStructParam(MaterialParams* obj, UINT32 idx, MaterialStructParam& param) { obj->structParams[idx] = param; }
-		UINT32 getStructArraySize(MaterialParams* obj) { return (UINT32)obj->structParams.size(); }
-		void setStructArraySize(MaterialParams* obj, UINT32 size) { obj->structParams.resize(size); }
-
-		MaterialTextureParam& getTextureParam(MaterialParams* obj, UINT32 idx) { return obj->textureParams[idx]; }
-		void setTextureParam(MaterialParams* obj, UINT32 idx, MaterialTextureParam& param) { obj->textureParams[idx] = param; }
-		UINT32 getTextureArraySize(MaterialParams* obj) { return (UINT32)obj->textureParams.size(); }
-		void setTextureArraySize(MaterialParams* obj, UINT32 size) { obj->textureParams.resize(size); }
-
-		MaterialSamplerStateParam& getSamplerStateParam(MaterialParams* obj, UINT32 idx) { return obj->samplerStateParams[idx]; }
-		void setSamplerStateParam(MaterialParams* obj, UINT32 idx, MaterialSamplerStateParam& param) { obj->samplerStateParams[idx] = param; }
-		UINT32 getSamplerStateArraySize(MaterialParams* obj) { return (UINT32)obj->samplerStateParams.size(); }
-		void setSamplerStateArraySize(MaterialParams* obj, UINT32 size) { obj->samplerStateParams.resize(size); }
-
-		MaterialParamsRTTI()
-		{
-			addReflectableArrayField("floatParams", 0, &MaterialParamsRTTI::getFloatParam, 
-				&MaterialParamsRTTI::getFloatArraySize, &MaterialParamsRTTI::setFloatParam, &MaterialParamsRTTI::setFloatArraySize);
-
-			addReflectableArrayField("vec2Params", 1, &MaterialParamsRTTI::getVec2Param, 
-				&MaterialParamsRTTI::getVec2ArraySize, &MaterialParamsRTTI::setVec2Param, &MaterialParamsRTTI::setVec2ArraySize);
-
-			addReflectableArrayField("vec3Params", 2, &MaterialParamsRTTI::getVec3Param, 
-				&MaterialParamsRTTI::getVec3ArraySize, &MaterialParamsRTTI::setVec3Param, &MaterialParamsRTTI::setVec3ArraySize);
-
-			addReflectableArrayField("vec4Params", 3, &MaterialParamsRTTI::getVec4Param, 
-				&MaterialParamsRTTI::getVec4ArraySize, &MaterialParamsRTTI::setVec4Param, &MaterialParamsRTTI::setVec4ArraySize);
-
-			addReflectableArrayField("mat3Params", 4, &MaterialParamsRTTI::getMat3Param, 
-				&MaterialParamsRTTI::getMat3ArraySize, &MaterialParamsRTTI::setMat3Param, &MaterialParamsRTTI::setMat3ArraySize);
-
-			addReflectableArrayField("mat4Params", 5, &MaterialParamsRTTI::getMat4Param, 
-				&MaterialParamsRTTI::getMat4ArraySize, &MaterialParamsRTTI::setMat4Param, &MaterialParamsRTTI::setMat4ArraySize);
-
-			addReflectableArrayField("structParams", 6, &MaterialParamsRTTI::getStructParam, 
-				&MaterialParamsRTTI::getStructArraySize, &MaterialParamsRTTI::setStructParam, &MaterialParamsRTTI::setStructArraySize);
-
-			addReflectableArrayField("textureParams", 7, &MaterialParamsRTTI::getTextureParam, 
-				&MaterialParamsRTTI::getTextureArraySize, &MaterialParamsRTTI::setTextureParam, &MaterialParamsRTTI::setTextureArraySize);
-
-			addReflectableArrayField("samplerStateParams", 8, &MaterialParamsRTTI::getSamplerStateParam, 
-				&MaterialParamsRTTI::getSamplerStateArraySize, &MaterialParamsRTTI::setSamplerStateParam, &MaterialParamsRTTI::setSamplerStateArraySize);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "MaterialParams";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() { return TID_MaterialParams; }
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{ 
-			return cm_shared_ptr<MaterialParams, ScratchAlloc>();
-		}
-	};
-
-	class CM_EXPORT MaterialRTTI : public RTTIType<Material, Resource, MaterialRTTI>
-	{
-	private:
-		ShaderPtr getShader(Material* obj)
-		{
-			return obj->mShader;
-		}
-
-		void setShader(Material* obj, ShaderPtr val)
-		{
-			obj->mShader = val;
-		}
-
-		std::shared_ptr<MaterialParams> getMaterialParams(Material* obj)
-		{
-			if(obj->mRTTIData.empty())
-				return nullptr;
-
-			return any_cast<std::shared_ptr<MaterialParams>>(obj->mRTTIData);
-		}
-
-		void setMaterialParams(Material* obj, std::shared_ptr<MaterialParams> value)
-		{
-			obj->mRTTIData = value;
-		}
-
-	public:
-		MaterialRTTI()
-		{
-			addReflectablePtrField("mShader", 0, &MaterialRTTI::getShader, &MaterialRTTI::setShader);
-			addReflectablePtrField("mMaterialParams", 1, &MaterialRTTI::getMaterialParams, &MaterialRTTI::setMaterialParams);
-		}
-
-		virtual void onSerializationStarted(IReflectable* obj);
-		virtual void onSerializationEnded(IReflectable* obj);
-		virtual void onDeserializationStarted(IReflectable* obj);
-		virtual void onDeserializationEnded(IReflectable* obj);
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "Material";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_Material;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject();
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmVector2.h"
+#include "CmVector3.h"
+#include "CmVector4.h"
+#include "CmMatrix3.h"
+#include "CmMatrix4.h"
+#include "CmMaterial.h"
+#include "CmGpuParams.h"
+#include "CmShader.h"
+#include "CmDebug.h"
+#include "CmException.h"
+
+namespace BansheeEngine
+{
+	/************************************************************************/
+	/* 					HELPER STRUCTS TO HELP SERIALIZING                  */
+	/************************************************************************/
+
+	class BS_CORE_EXPORT MaterialFloatParam : public IReflectable
+	{
+	public:
+		String name;
+		float value;
+		UINT32 arrayIdx;
+
+		friend class MaterialFloatParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialVec2Param : public IReflectable
+	{
+	public:
+		String name;
+		Vector2 value;
+		UINT32 arrayIdx;
+
+		friend class MaterialVec2ParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialVec3Param : public IReflectable
+	{
+	public:
+		String name;
+		Vector3 value;
+		UINT32 arrayIdx;
+
+		friend class MaterialVec3ParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialVec4Param : public IReflectable
+	{
+	public:
+		String name;
+		Vector4 value;
+		UINT32 arrayIdx;
+
+		friend class MaterialVec4ParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialMat3Param : public IReflectable
+	{
+	public:
+		String name;
+		Matrix3 value;
+		UINT32 arrayIdx;
+
+		friend class MaterialMat3ParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialMat4Param : public IReflectable
+	{
+	public:
+		String name;
+		Matrix4 value;
+		UINT32 arrayIdx;
+
+		friend class MaterialMat4ParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialStructParam : public IReflectable
+	{
+	public:
+		String name;
+		Material::StructData value;
+		UINT32 arrayIdx;
+		UINT32 elementSize;
+
+		friend class MaterialStructParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialTextureParam : public IReflectable
+	{
+	public:
+		String name;
+		HTexture value;
+
+		friend class MaterialTextureParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialSamplerStateParam : public IReflectable
+	{
+	public:
+		String name;
+		HSamplerState value;
+
+		friend class MaterialSamplerStateParamRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	class BS_CORE_EXPORT MaterialParams : public IReflectable
+	{
+	public:
+		Vector<MaterialFloatParam> floatParams;
+		Vector<MaterialVec2Param> vec2Params;
+		Vector<MaterialVec3Param> vec3Params;
+		Vector<MaterialVec4Param> vec4Params;
+		Vector<MaterialMat3Param> mat3Params;
+		Vector<MaterialMat4Param> mat4Params;
+		Vector<MaterialStructParam> structParams;
+		Vector<MaterialTextureParam> textureParams;
+		Vector<MaterialSamplerStateParam> samplerStateParams;
+
+		friend class MaterialParamsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
+
+	/************************************************************************/
+	/* 				RTTI FOR HELPER STRUCTS TO HELP SERIALIZING             */
+	/************************************************************************/
+
+	class BS_CORE_EXPORT MaterialFloatParamRTTI : public RTTIType<MaterialFloatParam, IReflectable, MaterialFloatParamRTTI>
+	{
+	public:
+		String& getName(MaterialFloatParam* obj) { return obj->name; }
+		void setName(MaterialFloatParam* obj, String& name) { obj->name = name; }
+
+		float& getValue(MaterialFloatParam* obj) { return obj->value; }
+		void setValue(MaterialFloatParam* obj, float& value) { obj->value = value; }
+
+		UINT32& getArrayIdx(MaterialFloatParam* obj) { return obj->arrayIdx; }
+		void setArrayIdx(MaterialFloatParam* obj, UINT32& value) { obj->arrayIdx = value; }
+
+		MaterialFloatParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialFloatParamRTTI::getName, &MaterialFloatParamRTTI::setName);
+			addPlainField("value", 1, &MaterialFloatParamRTTI::getValue, &MaterialFloatParamRTTI::setValue);
+			addPlainField("arrayIdx", 2, &MaterialFloatParamRTTI::getArrayIdx, &MaterialFloatParamRTTI::setArrayIdx);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialFloatParam";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamFloat; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialFloatParam, ScratchAlloc>(); 
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialVec2ParamRTTI : public RTTIType<MaterialVec2Param, IReflectable, MaterialVec2ParamRTTI>
+	{
+	public:
+		String& getName(MaterialVec2Param* obj) { return obj->name; }
+		void setName(MaterialVec2Param* obj, String& name) { obj->name = name; }
+
+		Vector2& getValue(MaterialVec2Param* obj) { return obj->value; }
+		void setValue(MaterialVec2Param* obj, Vector2& value) { obj->value = value; }
+
+		UINT32& getArrayIdx(MaterialVec2Param* obj) { return obj->arrayIdx; }
+		void setArrayIdx(MaterialVec2Param* obj, UINT32& value) { obj->arrayIdx = value; }
+
+		MaterialVec2ParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialVec2ParamRTTI::getName, &MaterialVec2ParamRTTI::setName);
+			addPlainField("value", 1, &MaterialVec2ParamRTTI::getValue, &MaterialVec2ParamRTTI::setValue);
+			addPlainField("arrayIdx", 2, &MaterialVec2ParamRTTI::getArrayIdx, &MaterialVec2ParamRTTI::setArrayIdx);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialVec2Param";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamVec2; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialVec2Param, ScratchAlloc>(); 
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialVec3ParamRTTI : public RTTIType<MaterialVec3Param, IReflectable, MaterialVec3ParamRTTI>
+	{
+	public:
+		String& getName(MaterialVec3Param* obj) { return obj->name; }
+		void setName(MaterialVec3Param* obj, String& name) { obj->name = name; }
+
+		Vector3& getValue(MaterialVec3Param* obj) { return obj->value; }
+		void setValue(MaterialVec3Param* obj, Vector3& value) { obj->value = value; }
+
+		UINT32& getArrayIdx(MaterialVec3Param* obj) { return obj->arrayIdx; }
+		void setArrayIdx(MaterialVec3Param* obj, UINT32& value) { obj->arrayIdx = value; }
+
+		MaterialVec3ParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialVec3ParamRTTI::getName, &MaterialVec3ParamRTTI::setName);
+			addPlainField("value", 1, &MaterialVec3ParamRTTI::getValue, &MaterialVec3ParamRTTI::setValue);
+			addPlainField("arrayIdx", 2, &MaterialVec3ParamRTTI::getArrayIdx, &MaterialVec3ParamRTTI::setArrayIdx);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialVec3Param";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamVec3; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialVec3Param, ScratchAlloc>(); 
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialVec4ParamRTTI : public RTTIType<MaterialVec4Param, IReflectable, MaterialVec4ParamRTTI>
+	{
+	public:
+		String& getName(MaterialVec4Param* obj) { return obj->name; }
+		void setName(MaterialVec4Param* obj, String& name) { obj->name = name; }
+
+		Vector4& getValue(MaterialVec4Param* obj) { return obj->value; }
+		void setValue(MaterialVec4Param* obj, Vector4& value) { obj->value = value; }
+
+		UINT32& getArrayIdx(MaterialVec4Param* obj) { return obj->arrayIdx; }
+		void setArrayIdx(MaterialVec4Param* obj, UINT32& value) { obj->arrayIdx = value; }
+
+		MaterialVec4ParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialVec4ParamRTTI::getName, &MaterialVec4ParamRTTI::setName);
+			addPlainField("value", 1, &MaterialVec4ParamRTTI::getValue, &MaterialVec4ParamRTTI::setValue);
+			addPlainField("arrayIdx", 2, &MaterialVec4ParamRTTI::getArrayIdx, &MaterialVec4ParamRTTI::setArrayIdx);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialVec4Param";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamVec4; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{
+			return cm_shared_ptr<MaterialVec4Param, ScratchAlloc>();
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialMat3ParamRTTI : public RTTIType<MaterialMat3Param, IReflectable, MaterialMat3ParamRTTI>
+	{
+	public:
+		String& getName(MaterialMat3Param* obj) { return obj->name; }
+		void setName(MaterialMat3Param* obj, String& name) { obj->name = name; }
+
+		Matrix3& getValue(MaterialMat3Param* obj) { return obj->value; }
+		void setValue(MaterialMat3Param* obj, Matrix3& value) { obj->value = value; }
+
+		UINT32& getArrayIdx(MaterialMat3Param* obj) { return obj->arrayIdx; }
+		void setArrayIdx(MaterialMat3Param* obj, UINT32& value) { obj->arrayIdx = value; }
+
+		MaterialMat3ParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialMat3ParamRTTI::getName, &MaterialMat3ParamRTTI::setName);
+			addPlainField("value", 1, &MaterialMat3ParamRTTI::getValue, &MaterialMat3ParamRTTI::setValue);
+			addPlainField("arrayIdx", 2, &MaterialMat3ParamRTTI::getArrayIdx, &MaterialMat3ParamRTTI::setArrayIdx);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialMat3Param";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamMat3; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialMat3Param, ScratchAlloc>();
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialMat4ParamRTTI : public RTTIType<MaterialMat4Param, IReflectable, MaterialMat4ParamRTTI>
+	{
+	public:
+		String& getName(MaterialMat4Param* obj) { return obj->name; }
+		void setName(MaterialMat4Param* obj, String& name) { obj->name = name; }
+
+		Matrix4& getValue(MaterialMat4Param* obj) { return obj->value; }
+		void setValue(MaterialMat4Param* obj, Matrix4& value) { obj->value = value; }
+
+		UINT32& getArrayIdx(MaterialMat4Param* obj) { return obj->arrayIdx; }
+		void setArrayIdx(MaterialMat4Param* obj, UINT32& value) { obj->arrayIdx = value; }
+
+		MaterialMat4ParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialMat4ParamRTTI::getName, &MaterialMat4ParamRTTI::setName);
+			addPlainField("value", 1, &MaterialMat4ParamRTTI::getValue, &MaterialMat4ParamRTTI::setValue);
+			addPlainField("arrayIdx", 2, &MaterialMat4ParamRTTI::getArrayIdx, &MaterialMat4ParamRTTI::setArrayIdx);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialMat4Param";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamMat4; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialMat4Param, ScratchAlloc>();
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialStructParamRTTI : public RTTIType<MaterialStructParam, IReflectable, MaterialStructParamRTTI>
+	{
+	public:
+		String& getName(MaterialStructParam* obj) { return obj->name; }
+		void setName(MaterialStructParam* obj, String& name) { obj->name = name; }
+
+		ManagedDataBlock getValue(MaterialStructParam* obj) 
+		{ 
+			ManagedDataBlock returnValue(obj->value.size);
+
+			UINT8* data = returnValue.getData();
+			memcpy(data, obj->value.data.get(), obj->value.size);
+
+			return returnValue; 
+		}
+
+		void setValue(MaterialStructParam* obj, ManagedDataBlock value) 
+		{ 
+			obj->value = Material::StructData(value.getSize()); 
+			obj->value.write(value.getData());
+			
+		}
+
+		UINT32& getArrayIdx(MaterialStructParam* obj) { return obj->arrayIdx; }
+		void setArrayIdx(MaterialStructParam* obj, UINT32& value) { obj->arrayIdx = value; }
+
+		UINT32& getElementSize(MaterialStructParam* obj) { return obj->elementSize; }
+		void setElementSize(MaterialStructParam* obj, UINT32& value) { obj->elementSize = value; }
+
+		MaterialStructParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialStructParamRTTI::getName, &MaterialStructParamRTTI::setName);
+			addDataBlockField("value", 1, &MaterialStructParamRTTI::getValue, &MaterialStructParamRTTI::setValue);
+			addPlainField("arrayIdx", 2, &MaterialStructParamRTTI::getArrayIdx, &MaterialStructParamRTTI::setArrayIdx);
+			addPlainField("elementSize", 3, &MaterialStructParamRTTI::getElementSize, &MaterialStructParamRTTI::setElementSize);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialStructParam";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamStruct; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialStructParam, ScratchAlloc>();
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialTextureParamRTTI : public RTTIType<MaterialTextureParam, IReflectable, MaterialTextureParamRTTI>
+	{
+	public:
+		String& getName(MaterialTextureParam* obj) { return obj->name; }
+		void setName(MaterialTextureParam* obj, String& name) { obj->name = name; }
+
+		HTexture& getValue(MaterialTextureParam* obj) { return obj->value; }
+		void setValue(MaterialTextureParam* obj, HTexture& value) { obj->value = value; }
+
+		MaterialTextureParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialTextureParamRTTI::getName, &MaterialTextureParamRTTI::setName);
+			addReflectableField("value", 1, &MaterialTextureParamRTTI::getValue, &MaterialTextureParamRTTI::setValue);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialTextureParam";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamTexture; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialTextureParam, ScratchAlloc>();
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialSamplerStateParamRTTI : public RTTIType<MaterialSamplerStateParam, IReflectable, MaterialSamplerStateParamRTTI>
+	{
+	public:
+		String& getName(MaterialSamplerStateParam* obj) { return obj->name; }
+		void setName(MaterialSamplerStateParam* obj, String& name) { obj->name = name; }
+
+		HSamplerState& getValue(MaterialSamplerStateParam* obj) { return obj->value; }
+		void setValue(MaterialSamplerStateParam* obj, HSamplerState& value) { obj->value = value; }
+
+		MaterialSamplerStateParamRTTI()
+		{
+			addPlainField("name", 0, &MaterialSamplerStateParamRTTI::getName, &MaterialSamplerStateParamRTTI::setName);
+			addReflectableField("value", 1, &MaterialSamplerStateParamRTTI::getValue, &MaterialSamplerStateParamRTTI::setValue);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialSamplerStateParam";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParamSamplerState; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialSamplerStateParam, ScratchAlloc>();
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialParamsRTTI : public RTTIType<MaterialParams, IReflectable, MaterialParamsRTTI>
+	{
+	public:
+		MaterialFloatParam& getFloatParam(MaterialParams* obj, UINT32 idx) { return obj->floatParams[idx]; }
+		void setFloatParam(MaterialParams* obj, UINT32 idx, MaterialFloatParam& param) { obj->floatParams[idx] = param; }
+		UINT32 getFloatArraySize(MaterialParams* obj) { return (UINT32)obj->floatParams.size(); }
+		void setFloatArraySize(MaterialParams* obj, UINT32 size) { obj->floatParams.resize(size); }
+
+		MaterialVec2Param& getVec2Param(MaterialParams* obj, UINT32 idx) { return obj->vec2Params[idx]; }
+		void setVec2Param(MaterialParams* obj, UINT32 idx, MaterialVec2Param& param) { obj->vec2Params[idx] = param; }
+		UINT32 getVec2ArraySize(MaterialParams* obj) { return (UINT32)obj->vec2Params.size(); }
+		void setVec2ArraySize(MaterialParams* obj, UINT32 size) { obj->vec2Params.resize(size); }
+
+		MaterialVec3Param& getVec3Param(MaterialParams* obj, UINT32 idx) { return obj->vec3Params[idx]; }
+		void setVec3Param(MaterialParams* obj, UINT32 idx, MaterialVec3Param& param) { obj->vec3Params[idx] = param; }
+		UINT32 getVec3ArraySize(MaterialParams* obj) { return (UINT32)obj->vec3Params.size(); }
+		void setVec3ArraySize(MaterialParams* obj, UINT32 size) { obj->vec3Params.resize(size); }
+
+		MaterialVec4Param& getVec4Param(MaterialParams* obj, UINT32 idx) { return obj->vec4Params[idx]; }
+		void setVec4Param(MaterialParams* obj, UINT32 idx, MaterialVec4Param& param) { obj->vec4Params[idx] = param; }
+		UINT32 getVec4ArraySize(MaterialParams* obj) { return (UINT32)obj->vec4Params.size(); }
+		void setVec4ArraySize(MaterialParams* obj, UINT32 size) { obj->vec4Params.resize(size); }
+
+		MaterialMat3Param& getMat3Param(MaterialParams* obj, UINT32 idx) { return obj->mat3Params[idx]; }
+		void setMat3Param(MaterialParams* obj, UINT32 idx, MaterialMat3Param& param) { obj->mat3Params[idx] = param; }
+		UINT32 getMat3ArraySize(MaterialParams* obj) { return (UINT32)obj->mat3Params.size(); }
+		void setMat3ArraySize(MaterialParams* obj, UINT32 size) { obj->mat3Params.resize(size); }
+
+		MaterialMat4Param& getMat4Param(MaterialParams* obj, UINT32 idx) { return obj->mat4Params[idx]; }
+		void setMat4Param(MaterialParams* obj, UINT32 idx, MaterialMat4Param& param) { obj->mat4Params[idx] = param; }
+		UINT32 getMat4ArraySize(MaterialParams* obj) { return (UINT32)obj->mat4Params.size(); }
+		void setMat4ArraySize(MaterialParams* obj, UINT32 size) { obj->mat4Params.resize(size); }
+
+		MaterialStructParam& getStructParam(MaterialParams* obj, UINT32 idx) { return obj->structParams[idx]; }
+		void setStructParam(MaterialParams* obj, UINT32 idx, MaterialStructParam& param) { obj->structParams[idx] = param; }
+		UINT32 getStructArraySize(MaterialParams* obj) { return (UINT32)obj->structParams.size(); }
+		void setStructArraySize(MaterialParams* obj, UINT32 size) { obj->structParams.resize(size); }
+
+		MaterialTextureParam& getTextureParam(MaterialParams* obj, UINT32 idx) { return obj->textureParams[idx]; }
+		void setTextureParam(MaterialParams* obj, UINT32 idx, MaterialTextureParam& param) { obj->textureParams[idx] = param; }
+		UINT32 getTextureArraySize(MaterialParams* obj) { return (UINT32)obj->textureParams.size(); }
+		void setTextureArraySize(MaterialParams* obj, UINT32 size) { obj->textureParams.resize(size); }
+
+		MaterialSamplerStateParam& getSamplerStateParam(MaterialParams* obj, UINT32 idx) { return obj->samplerStateParams[idx]; }
+		void setSamplerStateParam(MaterialParams* obj, UINT32 idx, MaterialSamplerStateParam& param) { obj->samplerStateParams[idx] = param; }
+		UINT32 getSamplerStateArraySize(MaterialParams* obj) { return (UINT32)obj->samplerStateParams.size(); }
+		void setSamplerStateArraySize(MaterialParams* obj, UINT32 size) { obj->samplerStateParams.resize(size); }
+
+		MaterialParamsRTTI()
+		{
+			addReflectableArrayField("floatParams", 0, &MaterialParamsRTTI::getFloatParam, 
+				&MaterialParamsRTTI::getFloatArraySize, &MaterialParamsRTTI::setFloatParam, &MaterialParamsRTTI::setFloatArraySize);
+
+			addReflectableArrayField("vec2Params", 1, &MaterialParamsRTTI::getVec2Param, 
+				&MaterialParamsRTTI::getVec2ArraySize, &MaterialParamsRTTI::setVec2Param, &MaterialParamsRTTI::setVec2ArraySize);
+
+			addReflectableArrayField("vec3Params", 2, &MaterialParamsRTTI::getVec3Param, 
+				&MaterialParamsRTTI::getVec3ArraySize, &MaterialParamsRTTI::setVec3Param, &MaterialParamsRTTI::setVec3ArraySize);
+
+			addReflectableArrayField("vec4Params", 3, &MaterialParamsRTTI::getVec4Param, 
+				&MaterialParamsRTTI::getVec4ArraySize, &MaterialParamsRTTI::setVec4Param, &MaterialParamsRTTI::setVec4ArraySize);
+
+			addReflectableArrayField("mat3Params", 4, &MaterialParamsRTTI::getMat3Param, 
+				&MaterialParamsRTTI::getMat3ArraySize, &MaterialParamsRTTI::setMat3Param, &MaterialParamsRTTI::setMat3ArraySize);
+
+			addReflectableArrayField("mat4Params", 5, &MaterialParamsRTTI::getMat4Param, 
+				&MaterialParamsRTTI::getMat4ArraySize, &MaterialParamsRTTI::setMat4Param, &MaterialParamsRTTI::setMat4ArraySize);
+
+			addReflectableArrayField("structParams", 6, &MaterialParamsRTTI::getStructParam, 
+				&MaterialParamsRTTI::getStructArraySize, &MaterialParamsRTTI::setStructParam, &MaterialParamsRTTI::setStructArraySize);
+
+			addReflectableArrayField("textureParams", 7, &MaterialParamsRTTI::getTextureParam, 
+				&MaterialParamsRTTI::getTextureArraySize, &MaterialParamsRTTI::setTextureParam, &MaterialParamsRTTI::setTextureArraySize);
+
+			addReflectableArrayField("samplerStateParams", 8, &MaterialParamsRTTI::getSamplerStateParam, 
+				&MaterialParamsRTTI::getSamplerStateArraySize, &MaterialParamsRTTI::setSamplerStateParam, &MaterialParamsRTTI::setSamplerStateArraySize);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "MaterialParams";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() { return TID_MaterialParams; }
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{ 
+			return cm_shared_ptr<MaterialParams, ScratchAlloc>();
+		}
+	};
+
+	class BS_CORE_EXPORT MaterialRTTI : public RTTIType<Material, Resource, MaterialRTTI>
+	{
+	private:
+		ShaderPtr getShader(Material* obj)
+		{
+			return obj->mShader;
+		}
+
+		void setShader(Material* obj, ShaderPtr val)
+		{
+			obj->mShader = val;
+		}
+
+		std::shared_ptr<MaterialParams> getMaterialParams(Material* obj)
+		{
+			if(obj->mRTTIData.empty())
+				return nullptr;
+
+			return any_cast<std::shared_ptr<MaterialParams>>(obj->mRTTIData);
+		}
+
+		void setMaterialParams(Material* obj, std::shared_ptr<MaterialParams> value)
+		{
+			obj->mRTTIData = value;
+		}
+
+	public:
+		MaterialRTTI()
+		{
+			addReflectablePtrField("mShader", 0, &MaterialRTTI::getShader, &MaterialRTTI::setShader);
+			addReflectablePtrField("mMaterialParams", 1, &MaterialRTTI::getMaterialParams, &MaterialRTTI::setMaterialParams);
+		}
+
+		virtual void onSerializationStarted(IReflectable* obj);
+		virtual void onSerializationEnded(IReflectable* obj);
+		virtual void onDeserializationStarted(IReflectable* obj);
+		virtual void onDeserializationEnded(IReflectable* obj);
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "Material";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_Material;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject();
+	};
 }

+ 207 - 207
CamelotCore/Include/CmMesh.h → BansheeCore/Include/CmMesh.h

@@ -1,208 +1,208 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmMeshBase.h"
-#include "CmMeshData.h"
-#include "CmVertexData.h"
-#include "CmIndexData.h"
-#include "CmDrawOps.h"
-#include "CmSubMesh.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Primary class for holding geometry. Stores data in the form of a vertex 
-	 *			buffers and optionally index buffer, which may be bound to the pipeline for drawing.
-	 *			May contain multiple sub-meshes.
-	 */
-	class CM_EXPORT Mesh : public MeshBase
-	{
-	public:
-		virtual ~Mesh();
-
-		/**
-		 * @copydoc GpuResource::writeSubresource
-		 */
-		virtual void writeSubresource(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer);
-
-		/**
-		 * @copydoc GpuResource::readSubresource
-		 */
-		virtual void readSubresource(UINT32 subresourceIdx, GpuResourceData& data);
-
-		/**
-		 * @brief	Allocates a buffer you may use for storage when reading a subresource. You
-		 * 			need to allocate such a buffer if you are calling "readSubresource".
-		 * 			
-		 * @note	This method is thread safe.
-		 */
-		MeshDataPtr allocateSubresourceBuffer(UINT32 subresourceIdx) const;
-
-		/**
-		 * @brief	TODO - Currently does nothing. But normally it should provide a way to map subresource index to
-		 * 			a specific submesh or buffer stream. Right now you can only work with entire mesh at once, not its subsets.
-		 */
-		void mapFromSubresourceIdx(UINT32 subresourceIdx) const {}
-
-		/**
-		 * @brief	TODO - Currently does nothing. But normally it should provide a way to map submesh or stream index to
-		 * 			a specific subresource index. Right now you can only work with entire mesh at once, not its subsets.
-		 */
-		UINT32 mapToSubresourceIdx() const { return 0; }
-
-		/**
-		 * @brief	Returns an axis aligned bounding box of the geometry contained in the vertex buffers for all submeshes.
-		 */
-		const AABox& getBounds() const;
-
-		/**
-		 * @brief	Returns an axis aligned bounding box of the geometry contained in the specific sub-mesh.
-		 */
-		const AABox& getBounds(UINT32 submeshIdx) const;
-
-		/**
-		 * @copydoc MeshBase::getVertexData
-		 */
-		virtual std::shared_ptr<VertexData> _getVertexData() const;
-
-		/**
-		 * @copydoc MeshBase::getIndexData
-		 */
-		virtual std::shared_ptr<IndexData> _getIndexData() const;
-
-		/**
-		 * @brief	Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh.
-		 */
-		static HMesh dummy();
-
-	protected:
-		friend class MeshManager;
-
-		Mesh(UINT32 numVertices, UINT32 numIndices, 
-			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, 
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		Mesh(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, 
-			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST, 
-			IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		Mesh(const MeshDataPtr& initialMeshData, 
-			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		std::shared_ptr<VertexData> mVertexData; // Core thread
-		std::shared_ptr<IndexData> mIndexData; // Core thread
-
-		VertexDataDescPtr mVertexDesc; // Immutable
-		MeshBufferType mBufferType; // Immutable
-		IndexBuffer::IndexType mIndexType; // Immutable
-
-		MeshDataPtr mTempInitialMeshData; // Immutable
-
-		/**
-		 * @copydoc Resource::initialize_internal()
-		 */
-		virtual void initialize_internal();
-
-		/**
-		 * @copydoc Resource::destroy_internal()
-		 */
-		virtual void destroy_internal();
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	private:
-		Mesh(); // Serialization only
-
-	public:
-		friend class MeshRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-
-		/************************************************************************/
-		/* 								STATICS		                     		*/
-		/************************************************************************/
-		
-	public:
-		/**
-		 * @brief	Creates a new empty mesh.
-		 *
-		 * @param	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh. 
-		 * @param	vertexDesc		Vertex description structure that describes how are vertices organized in the
-		 *							vertex buffer. When binding a mesh to the pipeline you must ensure vertex description
-		 *							at least partially matches the input description of the currently bound vertex GPU program.
-		 * @param	bufferType		Specify static for buffers you don't plan on updating other reading from often. Otherwise specify
-		 *							dynamic. This parameter affects performance.
-		 * @param	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default option is triangles,
-		 *							where three indices represent a single triangle.
-		 * @param	indexType		Size of indices, use smaller size for better performance, however be careful not to go over
-		 *							the number of vertices limited by the size.
-		 */
-		static HMesh create(UINT32 numVertices, UINT32 numIndices, 
-			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, 
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		/**
-		 * @brief	Creates a new mesh and immediately writes some data to the mesh. This is faster than writing
-		 *			the data in a separate step after creation.
-		 *
-		 * @param	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh. 
-		 * @param	vertexDesc		Vertex description structure that describes how are vertices organized in the
-		 *							vertex buffer. When binding a mesh to the pipeline you must ensure vertex description
-		 *							at least partially matches the input description of the currently bound vertex GPU program.
-		 * @param	initialMeshData	Vertex and index data used for initializing the mesh. Caller must ensure the data vertex and index buffers
-		 *							match the ones in the mesh, however the data might only write to a certain subset of the mesh, it does not
-		 *							have to write to all of it.
-		 * @param	bufferType		Specify static for buffers you don't plan on updating other reading from often. Otherwise specify
-		 *							dynamic. This parameter affects performance.
-		 * @param	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default option is triangles,
-		 *							where three indices represent a single triangle.
-		 * @param	indexType		Size of indices, use smaller size for better performance, however be careful not to go over
-		 *							the number of vertices limited by the size.
-		 */
-		static HMesh create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, 
-			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST, 
-			IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		/**
-		 * @brief	Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
-		 *			by the mesh data exactly.
-		 *
-		 * @param	initialMeshData	Vertex and index data used for initializing the mesh. 
-		 * @param	bufferType		Specify static for buffers you don't plan on updating other reading from often. Otherwise specify
-		 *							dynamic. This parameter affects performance.
-		 * @param	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default option is triangles,
-		 *							where three indices represent a single triangle.
-		 */
-		static HMesh create(const MeshDataPtr& initialMeshData, MeshBufferType bufferType = MeshBufferType::Static, 
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * @copydoc	create(UINT32, UINT32, const VertexDataDescPtr&, MeshBufferType, DrawOperationType, IndexBuffer::IndexType)
-		 *
-		 * @note	Internal method. Use "create" for normal use.
-		 */
-		static MeshPtr _createPtr(UINT32 numVertices, UINT32 numIndices, 
-			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, 
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		/**
-		 * @copydoc	create(UINT32, UINT32, const VertexDataDescPtr&, const MeshDataPtr&, MeshBufferType, DrawOperationType, IndexBuffer::IndexType)
-		 *
-		 * @note	Internal method. Use "create" for normal use.
-		 */
-		static MeshPtr _createPtr(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, 
-			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST, 
-			IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		/**
-		 * @copydoc	create(const MeshDataPtr&, MeshBufferType, DrawOperationType)
-		 *
-		 * @note	Internal method. Use "create" for normal use.
-		 */
-		static MeshPtr _createPtr(const MeshDataPtr& initialMeshData, MeshBufferType bufferType = MeshBufferType::Static, 
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmMeshBase.h"
+#include "CmMeshData.h"
+#include "CmVertexData.h"
+#include "CmIndexData.h"
+#include "CmDrawOps.h"
+#include "CmSubMesh.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Primary class for holding geometry. Stores data in the form of a vertex 
+	 *			buffers and optionally index buffer, which may be bound to the pipeline for drawing.
+	 *			May contain multiple sub-meshes.
+	 */
+	class BS_CORE_EXPORT Mesh : public MeshBase
+	{
+	public:
+		virtual ~Mesh();
+
+		/**
+		 * @copydoc GpuResource::writeSubresource
+		 */
+		virtual void writeSubresource(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer);
+
+		/**
+		 * @copydoc GpuResource::readSubresource
+		 */
+		virtual void readSubresource(UINT32 subresourceIdx, GpuResourceData& data);
+
+		/**
+		 * @brief	Allocates a buffer you may use for storage when reading a subresource. You
+		 * 			need to allocate such a buffer if you are calling "readSubresource".
+		 * 			
+		 * @note	This method is thread safe.
+		 */
+		MeshDataPtr allocateSubresourceBuffer(UINT32 subresourceIdx) const;
+
+		/**
+		 * @brief	TODO - Currently does nothing. But normally it should provide a way to map subresource index to
+		 * 			a specific submesh or buffer stream. Right now you can only work with entire mesh at once, not its subsets.
+		 */
+		void mapFromSubresourceIdx(UINT32 subresourceIdx) const {}
+
+		/**
+		 * @brief	TODO - Currently does nothing. But normally it should provide a way to map submesh or stream index to
+		 * 			a specific subresource index. Right now you can only work with entire mesh at once, not its subsets.
+		 */
+		UINT32 mapToSubresourceIdx() const { return 0; }
+
+		/**
+		 * @brief	Returns an axis aligned bounding box of the geometry contained in the vertex buffers for all submeshes.
+		 */
+		const AABox& getBounds() const;
+
+		/**
+		 * @brief	Returns an axis aligned bounding box of the geometry contained in the specific sub-mesh.
+		 */
+		const AABox& getBounds(UINT32 submeshIdx) const;
+
+		/**
+		 * @copydoc MeshBase::getVertexData
+		 */
+		virtual std::shared_ptr<VertexData> _getVertexData() const;
+
+		/**
+		 * @copydoc MeshBase::getIndexData
+		 */
+		virtual std::shared_ptr<IndexData> _getIndexData() const;
+
+		/**
+		 * @brief	Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh.
+		 */
+		static HMesh dummy();
+
+	protected:
+		friend class MeshManager;
+
+		Mesh(UINT32 numVertices, UINT32 numIndices, 
+			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, 
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		Mesh(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, 
+			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST, 
+			IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		Mesh(const MeshDataPtr& initialMeshData, 
+			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		std::shared_ptr<VertexData> mVertexData; // Core thread
+		std::shared_ptr<IndexData> mIndexData; // Core thread
+
+		VertexDataDescPtr mVertexDesc; // Immutable
+		MeshBufferType mBufferType; // Immutable
+		IndexBuffer::IndexType mIndexType; // Immutable
+
+		MeshDataPtr mTempInitialMeshData; // Immutable
+
+		/**
+		 * @copydoc Resource::initialize_internal()
+		 */
+		virtual void initialize_internal();
+
+		/**
+		 * @copydoc Resource::destroy_internal()
+		 */
+		virtual void destroy_internal();
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	private:
+		Mesh(); // Serialization only
+
+	public:
+		friend class MeshRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+
+		/************************************************************************/
+		/* 								STATICS		                     		*/
+		/************************************************************************/
+		
+	public:
+		/**
+		 * @brief	Creates a new empty mesh.
+		 *
+		 * @param	numVertices		Number of vertices in the mesh.
+		 * @param	numIndices		Number of indices in the mesh. 
+		 * @param	vertexDesc		Vertex description structure that describes how are vertices organized in the
+		 *							vertex buffer. When binding a mesh to the pipeline you must ensure vertex description
+		 *							at least partially matches the input description of the currently bound vertex GPU program.
+		 * @param	bufferType		Specify static for buffers you don't plan on updating other reading from often. Otherwise specify
+		 *							dynamic. This parameter affects performance.
+		 * @param	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default option is triangles,
+		 *							where three indices represent a single triangle.
+		 * @param	indexType		Size of indices, use smaller size for better performance, however be careful not to go over
+		 *							the number of vertices limited by the size.
+		 */
+		static HMesh create(UINT32 numVertices, UINT32 numIndices, 
+			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, 
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		/**
+		 * @brief	Creates a new mesh and immediately writes some data to the mesh. This is faster than writing
+		 *			the data in a separate step after creation.
+		 *
+		 * @param	numVertices		Number of vertices in the mesh.
+		 * @param	numIndices		Number of indices in the mesh. 
+		 * @param	vertexDesc		Vertex description structure that describes how are vertices organized in the
+		 *							vertex buffer. When binding a mesh to the pipeline you must ensure vertex description
+		 *							at least partially matches the input description of the currently bound vertex GPU program.
+		 * @param	initialMeshData	Vertex and index data used for initializing the mesh. Caller must ensure the data vertex and index buffers
+		 *							match the ones in the mesh, however the data might only write to a certain subset of the mesh, it does not
+		 *							have to write to all of it.
+		 * @param	bufferType		Specify static for buffers you don't plan on updating other reading from often. Otherwise specify
+		 *							dynamic. This parameter affects performance.
+		 * @param	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default option is triangles,
+		 *							where three indices represent a single triangle.
+		 * @param	indexType		Size of indices, use smaller size for better performance, however be careful not to go over
+		 *							the number of vertices limited by the size.
+		 */
+		static HMesh create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, 
+			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST, 
+			IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		/**
+		 * @brief	Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
+		 *			by the mesh data exactly.
+		 *
+		 * @param	initialMeshData	Vertex and index data used for initializing the mesh. 
+		 * @param	bufferType		Specify static for buffers you don't plan on updating other reading from often. Otherwise specify
+		 *							dynamic. This parameter affects performance.
+		 * @param	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default option is triangles,
+		 *							where three indices represent a single triangle.
+		 */
+		static HMesh create(const MeshDataPtr& initialMeshData, MeshBufferType bufferType = MeshBufferType::Static, 
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * @copydoc	create(UINT32, UINT32, const VertexDataDescPtr&, MeshBufferType, DrawOperationType, IndexBuffer::IndexType)
+		 *
+		 * @note	Internal method. Use "create" for normal use.
+		 */
+		static MeshPtr _createPtr(UINT32 numVertices, UINT32 numIndices, 
+			const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, 
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		/**
+		 * @copydoc	create(UINT32, UINT32, const VertexDataDescPtr&, const MeshDataPtr&, MeshBufferType, DrawOperationType, IndexBuffer::IndexType)
+		 *
+		 * @note	Internal method. Use "create" for normal use.
+		 */
+		static MeshPtr _createPtr(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialMeshData, 
+			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST, 
+			IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		/**
+		 * @copydoc	create(const MeshDataPtr&, MeshBufferType, DrawOperationType)
+		 *
+		 * @note	Internal method. Use "create" for normal use.
+		 */
+		static MeshPtr _createPtr(const MeshDataPtr& initialMeshData, MeshBufferType bufferType = MeshBufferType::Static, 
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+	};
 }

+ 144 - 144
CamelotCore/Include/CmMeshBase.h → BansheeCore/Include/CmMeshBase.h

@@ -1,145 +1,145 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmGpuResource.h"
-#include "CmDrawOps.h"
-#include "CmSubMesh.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Type of buffers used by a mesh. These options usually affect performance and 
-	 *			you should specify static if you don't plan on modifying the mesh often,
-	 *			otherwise specify dynamic.
-	 */
-	enum class MeshBufferType
-	{
-		Static,
-		Dynamic
-	};
-
-	/**
-	 * @brief	Base class all mesh implementations derive from. Meshes hold geometry information,
-	 *			normally in the form of one or serveral index or vertex buffers. Different mesh implementations
-	 *			might choose to manage those buffers differently.
-	 */
-	class CM_EXPORT MeshBase : public GpuResource
-	{
-	public:
-		/**
-		 * @brief	Constructs a new instance.
-		 * @param	numVertices		Number of vertices in the mesh.
-		 * @param	numIndices		Number of indices in the mesh. 
-		 * @param	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default option is triangles,
-		 *							where three indices represent a single triangle.
-		 */
-		MeshBase(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-		virtual ~MeshBase();
-
-		/**
-		 * @brief	Removes all sub-meshes in the mesh. All indices in the mesh will be assumed to
-		 *			belong to a single mesh.
-		 *
-		 * @note	Sim thread only.
-		 */
-		void clearSubMeshes();
-
-		/**
-		 * @brief	Allows you to mark a part of the mesh as a sub-mesh so you may draw that part separately.
-		 *
-		 * @note	Sim thread only.
-		 */
-		void addSubMesh(UINT32 indexOffset, UINT32 indexCount, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * @brief	Sets a set of sub-meshes containing data used for rendering a 
-		 * 			certain portion of this mesh. Overwrites any previous sub-meshes.
-		 * 			
-		 * @note	Sim thread only.
-		 */
-		void setSubMeshes(const Vector<SubMesh>& subMeshes);
-
-		/**
-		 * @brief	Retrieves a sub-mesh containing data used for rendering a
-		 * 			certain portion of this mesh. If no sub-meshes are specified manually
-		 *			a special sub-mesh containing all indices is returned.
-		 * 			
-		 * @note	Sim thread only.
-		 */
-		const SubMesh& getSubMesh(UINT32 subMeshIdx = 0) const;
-
-		/**
-		 * @brief	Retrieves a total number of sub-meshes in this mesh.
-		 * 			
-		 * @note	Sim thread only.
-		 */
-		UINT32 getNumSubMeshes() const;
-
-		UINT32 getNumVertices() const { return mNumVertices; }
-		UINT32 getNumIndices() const { return mNumIndices; }
-
-		/**
-		 * @brief	Get vertex data used for rendering.
-		 *  
-		 * @note	Core thread only. Internal method.
-		 */
-		virtual std::shared_ptr<VertexData> _getVertexData() const = 0;
-
-		/**
-		 * @brief	Get index data used for rendering.
-		 *  
-		 * @note	Core thread only. Internal method.
-		 */
-		virtual std::shared_ptr<IndexData> _getIndexData() const = 0;
-
-		/**
-		 * @brief	Returns an offset into the vertex buffers that is returned
-		 * 			by getVertexData that signifies where this meshes vertices
-		 * 			begin.
-		 * 			
-		 * @note	Used when multiple meshes share the same buffers.
-		 * 			
-		 *			Core thread only. Internal method.
-		 */
-		virtual UINT32 _getVertexOffset() const { return 0; }
-
-		/**
-		 * @brief	Returns an offset into the index buffer that is returned
-		 * 			by getIndexData that signifies where this meshes indices
-		 * 			begin.
-		 * 			
-		 * @note	Used when multiple meshes share the same buffers.
-		 * 			
-		 *			Core thread only. Internal method.
-		 */
-		virtual UINT32 _getIndexOffset() const { return 0; }
-
-		/**
-		 * @brief	Called whenever this mesh starts being used on the GPU.
-		 * 			
-		 * @note	Needs to be called after all commands referencing this 
-		 * 			mesh have been sent to the GPU.
-		 * 			
-		 *			Core thread only. Internal method.
-		 */
-		virtual void _notifyUsedOnGPU() { }
-
-	protected:
-		Vector<SubMesh> mSubMeshes; // Sim thread
-		SubMesh mDefaultSubMesh; // Immutable
-
-		UINT32 mNumVertices; // Immutable
-		UINT32 mNumIndices; // Immutable
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	private:
-		MeshBase(); // Serialization only
-
-	public:
-		friend class MeshBaseRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmGpuResource.h"
+#include "CmDrawOps.h"
+#include "CmSubMesh.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Type of buffers used by a mesh. These options usually affect performance and 
+	 *			you should specify static if you don't plan on modifying the mesh often,
+	 *			otherwise specify dynamic.
+	 */
+	enum class MeshBufferType
+	{
+		Static,
+		Dynamic
+	};
+
+	/**
+	 * @brief	Base class all mesh implementations derive from. Meshes hold geometry information,
+	 *			normally in the form of one or serveral index or vertex buffers. Different mesh implementations
+	 *			might choose to manage those buffers differently.
+	 */
+	class BS_CORE_EXPORT MeshBase : public GpuResource
+	{
+	public:
+		/**
+		 * @brief	Constructs a new instance.
+		 * @param	numVertices		Number of vertices in the mesh.
+		 * @param	numIndices		Number of indices in the mesh. 
+		 * @param	drawOp			Determines how should the provided indices be interpreted by the pipeline. Default option is triangles,
+		 *							where three indices represent a single triangle.
+		 */
+		MeshBase(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+		virtual ~MeshBase();
+
+		/**
+		 * @brief	Removes all sub-meshes in the mesh. All indices in the mesh will be assumed to
+		 *			belong to a single mesh.
+		 *
+		 * @note	Sim thread only.
+		 */
+		void clearSubMeshes();
+
+		/**
+		 * @brief	Allows you to mark a part of the mesh as a sub-mesh so you may draw that part separately.
+		 *
+		 * @note	Sim thread only.
+		 */
+		void addSubMesh(UINT32 indexOffset, UINT32 indexCount, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * @brief	Sets a set of sub-meshes containing data used for rendering a 
+		 * 			certain portion of this mesh. Overwrites any previous sub-meshes.
+		 * 			
+		 * @note	Sim thread only.
+		 */
+		void setSubMeshes(const Vector<SubMesh>& subMeshes);
+
+		/**
+		 * @brief	Retrieves a sub-mesh containing data used for rendering a
+		 * 			certain portion of this mesh. If no sub-meshes are specified manually
+		 *			a special sub-mesh containing all indices is returned.
+		 * 			
+		 * @note	Sim thread only.
+		 */
+		const SubMesh& getSubMesh(UINT32 subMeshIdx = 0) const;
+
+		/**
+		 * @brief	Retrieves a total number of sub-meshes in this mesh.
+		 * 			
+		 * @note	Sim thread only.
+		 */
+		UINT32 getNumSubMeshes() const;
+
+		UINT32 getNumVertices() const { return mNumVertices; }
+		UINT32 getNumIndices() const { return mNumIndices; }
+
+		/**
+		 * @brief	Get vertex data used for rendering.
+		 *  
+		 * @note	Core thread only. Internal method.
+		 */
+		virtual std::shared_ptr<VertexData> _getVertexData() const = 0;
+
+		/**
+		 * @brief	Get index data used for rendering.
+		 *  
+		 * @note	Core thread only. Internal method.
+		 */
+		virtual std::shared_ptr<IndexData> _getIndexData() const = 0;
+
+		/**
+		 * @brief	Returns an offset into the vertex buffers that is returned
+		 * 			by getVertexData that signifies where this meshes vertices
+		 * 			begin.
+		 * 			
+		 * @note	Used when multiple meshes share the same buffers.
+		 * 			
+		 *			Core thread only. Internal method.
+		 */
+		virtual UINT32 _getVertexOffset() const { return 0; }
+
+		/**
+		 * @brief	Returns an offset into the index buffer that is returned
+		 * 			by getIndexData that signifies where this meshes indices
+		 * 			begin.
+		 * 			
+		 * @note	Used when multiple meshes share the same buffers.
+		 * 			
+		 *			Core thread only. Internal method.
+		 */
+		virtual UINT32 _getIndexOffset() const { return 0; }
+
+		/**
+		 * @brief	Called whenever this mesh starts being used on the GPU.
+		 * 			
+		 * @note	Needs to be called after all commands referencing this 
+		 * 			mesh have been sent to the GPU.
+		 * 			
+		 *			Core thread only. Internal method.
+		 */
+		virtual void _notifyUsedOnGPU() { }
+
+	protected:
+		Vector<SubMesh> mSubMeshes; // Sim thread
+		SubMesh mDefaultSubMesh; // Immutable
+
+		UINT32 mNumVertices; // Immutable
+		UINT32 mNumIndices; // Immutable
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	private:
+		MeshBase(); // Serialization only
+
+	public:
+		friend class MeshBaseRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
 }

+ 56 - 56
CamelotCore/Include/CmMeshBaseRTTI.h → BansheeCore/Include/CmMeshBaseRTTI.h

@@ -1,57 +1,57 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmApplication.h"
-#include "CmMeshBase.h"
-#include "CmException.h"
-
-namespace BansheeEngine
-{
-	CM_ALLOW_MEMCPY_SERIALIZATION(SubMesh);
-
-	class MeshBaseRTTI : public RTTIType<MeshBase, GpuResource, MeshBaseRTTI>
-	{
-		SubMesh& getSubMesh(MeshBase* obj, UINT32 arrayIdx) { return obj->mSubMeshes[arrayIdx]; }
-		void setSubMesh(MeshBase* obj, UINT32 arrayIdx, SubMesh& value) { obj->mSubMeshes[arrayIdx] = value; }
-		UINT32 getNumSubmeshes(MeshBase* obj) { return (UINT32)obj->mSubMeshes.size(); }
-		void setNumSubmeshes(MeshBase* obj, UINT32 numElements) { obj->mSubMeshes.resize(numElements); }
-
-		SubMesh& getDefaultSubMesh(MeshBase* obj) { return obj->mDefaultSubMesh; }
-		void setDefaultSubMesh(MeshBase* obj, SubMesh& value) { obj->mDefaultSubMesh = value; }
-
-		UINT32& getNumVertices(MeshBase* obj) { return obj->mNumVertices; }
-		void setNumVertices(MeshBase* obj, UINT32& value) { obj->mNumVertices = value; }
-
-		UINT32& getNumIndices(MeshBase* obj) { return obj->mNumIndices; }
-		void setNumIndices(MeshBase* obj, UINT32& value) { obj->mNumIndices = value; }
-
-	public:
-		MeshBaseRTTI()
-		{
-			addPlainField("mNumVertices", 0, &MeshBaseRTTI::getNumVertices, &MeshBaseRTTI::setNumVertices);
-			addPlainField("mNumIndices", 1, &MeshBaseRTTI::getNumIndices, &MeshBaseRTTI::setNumIndices);
-
-			addPlainArrayField("mSubMeshes", 2, &MeshBaseRTTI::getSubMesh, 
-				&MeshBaseRTTI::getNumSubmeshes, &MeshBaseRTTI::setSubMesh, &MeshBaseRTTI::setNumSubmeshes);
-
-			addPlainField("mDefaultSubMesh", 3, &MeshBaseRTTI::getDefaultSubMesh, &MeshBaseRTTI::setDefaultSubMesh);
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{
-			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
-		}
-
-		virtual const String& getRTTIName() 
-		{
-			static String name = "MeshBase";
-			throw name;
-		}
-
-		virtual UINT32 getRTTIId() 
-		{
-			return TID_MeshBase;
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmApplication.h"
+#include "CmMeshBase.h"
+#include "CmException.h"
+
+namespace BansheeEngine
+{
+	CM_ALLOW_MEMCPY_SERIALIZATION(SubMesh);
+
+	class MeshBaseRTTI : public RTTIType<MeshBase, GpuResource, MeshBaseRTTI>
+	{
+		SubMesh& getSubMesh(MeshBase* obj, UINT32 arrayIdx) { return obj->mSubMeshes[arrayIdx]; }
+		void setSubMesh(MeshBase* obj, UINT32 arrayIdx, SubMesh& value) { obj->mSubMeshes[arrayIdx] = value; }
+		UINT32 getNumSubmeshes(MeshBase* obj) { return (UINT32)obj->mSubMeshes.size(); }
+		void setNumSubmeshes(MeshBase* obj, UINT32 numElements) { obj->mSubMeshes.resize(numElements); }
+
+		SubMesh& getDefaultSubMesh(MeshBase* obj) { return obj->mDefaultSubMesh; }
+		void setDefaultSubMesh(MeshBase* obj, SubMesh& value) { obj->mDefaultSubMesh = value; }
+
+		UINT32& getNumVertices(MeshBase* obj) { return obj->mNumVertices; }
+		void setNumVertices(MeshBase* obj, UINT32& value) { obj->mNumVertices = value; }
+
+		UINT32& getNumIndices(MeshBase* obj) { return obj->mNumIndices; }
+		void setNumIndices(MeshBase* obj, UINT32& value) { obj->mNumIndices = value; }
+
+	public:
+		MeshBaseRTTI()
+		{
+			addPlainField("mNumVertices", 0, &MeshBaseRTTI::getNumVertices, &MeshBaseRTTI::setNumVertices);
+			addPlainField("mNumIndices", 1, &MeshBaseRTTI::getNumIndices, &MeshBaseRTTI::setNumIndices);
+
+			addPlainArrayField("mSubMeshes", 2, &MeshBaseRTTI::getSubMesh, 
+				&MeshBaseRTTI::getNumSubmeshes, &MeshBaseRTTI::setSubMesh, &MeshBaseRTTI::setNumSubmeshes);
+
+			addPlainField("mDefaultSubMesh", 3, &MeshBaseRTTI::getDefaultSubMesh, &MeshBaseRTTI::setDefaultSubMesh);
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{
+			CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
+		}
+
+		virtual const String& getRTTIName() 
+		{
+			static String name = "MeshBase";
+			throw name;
+		}
+
+		virtual UINT32 getRTTIId() 
+		{
+			return TID_MeshBase;
+		}
+	};
 }

+ 329 - 329
CamelotCore/Include/CmMeshData.h → BansheeCore/Include/CmMeshData.h

@@ -1,330 +1,330 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmGpuResourceData.h"
-#include "CmVertexBuffer.h"
-#include "CmIndexBuffer.h"
-#include "CmVertexDeclaration.h"
-#include "CmDrawOps.h"
-#include "CmSubMesh.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Iterator that allows you to easily populate or read vertex elements
-	 *			in MeshData.
-	 */
-	template<class T>
-	class VertexElemIter
-	{
-	public:
-		VertexElemIter()
-			:mData(nullptr), mEnd(nullptr), mByteStride(0), mNumElements(0)
-		{
-
-		}
-
-		VertexElemIter(UINT8* data, UINT32 byteStride, UINT32 numElements)
-			:mData(data), mByteStride(byteStride), mNumElements(numElements)
-		{
-			mEnd = mData + byteStride * numElements;
-		}
-
-		/**
-		 * @brief	Adds a new value to the iterators current position and
-		 *			advances the iterator.
-		 */
-		void addValue(T& value)
-		{
-			setValue(value);
-			moveNext();
-		}
-
-		/**
-		 * @brief	Sets a new value at the iterators current position.
-		 */
-		void setValue(T& value)
-		{
-			memcpy(mData, &value, sizeof(T));
-		}
-
-		/**
-		 * @brief	Returns the value at the iterators current position.
-		 */
-		T& getValue()
-		{
-			return *((T*)mData);
-		}
-
-		/**
-		 * @brief	Moves the iterator to the next position. Returns true
-		 *			if there are more elements.
-		 */
-		bool moveNext()
-		{
-#ifdef CM_DEBUG_MODE
-			if(mData >= mEnd)
-			{
-				CM_EXCEPT(InternalErrorException, "Vertex element iterator out of buffer bounds.");
-			}
-#endif
-
-			mData += mByteStride;
-
-			return mData < mEnd;
-		}
-
-		/**
-		 * @brief	Returns the number of elements this iterator can iterate over.
-		 */
-		UINT32 getNumElements() const { return mNumElements; }
-
-	private:
-		UINT8* mData;
-		UINT8* mEnd;
-		UINT32 mByteStride;
-		UINT32 mNumElements;
-	};
-
-	/**
-	 * @brief	Used for initializing, updating and reading mesh data from Meshes.
-	 */
-	class CM_EXPORT MeshData : public GpuResourceData
-	{
-	public:
-		/**
-		 * @brief	Constructs a new object that can hold number of vertices described by the provided vertex data description. As well
-		 *			as a number of indices of the provided type.
-		 */
-		MeshData(UINT32 numVertices, UINT32 numIndexes, const VertexDataDescPtr& vertexData, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-		~MeshData();
-
-		/**
-		 * @brief	Determines at which position in the mesh will the vertex data be written into or read from.
-		 *
-		 * @param	bytes	Offset in number of vertices.
-		 */
-		void setResourceVertexOffset(UINT32 vertices) { mResourceVertexOffset = vertices; }
-
-		/**
-		 * @brief	Determines at which position in the mesh will the index data be written into or read from.
-		 *
-		 * @param	bytes	Offset in number of indices.
-		 */
-		void setResourceIndexOffset(UINT32 indices) { mResourceIndexOffset = indices; }
-
-		/**
-		 * @brief	Determines at which position in the mesh will the vertex data be written into or read
-		 * 			from.
-		 *
-		 * @return	Offset in number of vertices.
-		 */
-		UINT32 getResourceVertexOffset() const { return mResourceVertexOffset; }
-
-		/**
-		 * @brief	Determines at which position in the mesh will the index data be written into or read from.
-		 *
-		 * @return	Offset in number of indices.
-		 */
-		UINT32 getResourceIndexOffset() const { return mResourceIndexOffset; }
-
-		/**
-		 * @brief	Copies data from "data" parameter into the internal buffer for the specified semantic.
-		 *
-		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
-		 * @param	data			Vertex data, containing at least "size" bytes.
-		 * @param	size			The size of the data. Must be the size of the vertex element type * number of vertices.
-		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
-		 */
-		void setVertexData(VertexElementSemantic semantic, UINT8* data, UINT32 size, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector2 vertex elements. This is the preferred
-		 * 			method of assigning or reading vertex data. 
-		 * 			
-		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
-		 */
-		VertexElemIter<Vector2> getVec2DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector3 vertex elements. This is the preferred
-		 * 			method of assigning or reading vertex data. 
-		 * 			
-		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
-		 */
-		VertexElemIter<Vector3> getVec3DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector4 vertex elements. This is the preferred
-		 * 			method of assigning or reading vertex data. 
-		 * 			
-		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
-		 */
-		VertexElemIter<Vector4> getVec4DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns an iterator you can use for easily retrieving or setting DWORD vertex elements. This is the preferred
-		 * 			method of assigning or reading vertex data. 
-		 * 			
-		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
-		 */
-		VertexElemIter<UINT32> getDWORDDataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
-
-		/**
-		 * @brief	Returns the total number of vertices this object can hold.
-		 */
-		UINT32 getNumVertices() const { return mNumVertices; }
-
-		/**
-		 * @brief	Returns the total number of indices this object can hold.
-		 */
-		UINT32 getNumIndices() const;
-
-		/**
-		 * @brief	Returns a 16-bit pointer to the start of the internal index buffer.
-		 */
-		UINT16* getIndices16() const;
-
-		/**
-		 * @brief	Returns a 32-bit pointer to the start of the internal index buffer.
-		 */
-		UINT32* getIndices32() const;
-
-		/**
-		 * @brief	Returns the size of an index element in bytes.
-		 */
-		UINT32 getIndexElementSize() const;
-
-		/**
-		 * @brief	Returns the type of an index element.
-		 */
-		IndexBuffer::IndexType getIndexType() const { return mIndexType; }
-
-		/**
-		 * @brief	Returns the pointer to the first element of the specified type. If you want to
-		 * 			iterate over all elements you need to call getVertexStride() to get the number
-		 * 			of bytes you need to advance between each element.
-		 *
-		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
-		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
-		 *
-		 * @return	null if it fails, else the element data.
-		 */
-		UINT8* getElementData(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
-
-		/**
-		 * @brief	Returns an offset into the internal buffer where this element with the provided semantic starts. 
-		 *			Offset is provided in number of bytes.
-		 * 
-		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
-		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
-		 */
-		UINT32 getElementOffset(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
-
-		/**
-		 * @brief	Returns an object that describes data contained in a single vertex.
-		 */
-		const VertexDataDescPtr& getVertexDesc() const { return mVertexData; }
-
-		/**
-		 * @brief	Combines a number of submeshes and their mesh data into one large mesh data buffer.
-		 *
-		 * @param	elements	Data containing vertices and indices referenced by the submeshes. Number of elements
-		 *						must be the same as number of submeshes.
-		 * @param	subMeshes	Submeshes representing vertex and index range to take from mesh data and combine. Number of
-		 *						submeshes must match the number of provided MeshData elements.
-		 * @param	[out] subMeshes		Outputs all combined sub-meshes with their new index and vertex offsets referencing
-		 *								the newly created MeshData.
-		 *
-		 * @returns	Combined mesh data containing all vertices and indexes references by the provided sub-meshes.
-		 */
-		static MeshDataPtr combine(const Vector<MeshDataPtr>& elements, const Vector<Vector<SubMesh>>& allSubMeshes,
-			Vector<SubMesh>& subMeshes);
-
-	protected:
-		/**
-		 * @brief	Returns the size of the internal buffer in bytes.
-		 */
-		UINT32 getInternalBufferSize();
-
-	private:
-		/**
-		 * @brief	Returns a pointer to the start of the index buffer.
-		 */
-		UINT8* getIndexData() const { return getData(); }
-
-		/**
-		 * @brief	Returns a pointer to the start of the specified vertex stream.
-		 */
-		UINT8* getStreamData(UINT32 streamIdx) const;
-
-		/**
-		 * @brief	Returns an offset in bytes to the start of the index buffer from the start of the
-		 *			internal buffer.
-		 */
-		UINT32 getIndexBufferOffset() const;
-
-		/**
-		 * @brief	Returns an offset in bytes to the start of the stream from the start of the
-		 *			internal buffer.
-		 */
-		UINT32 getStreamOffset(UINT32 streamIdx = 0) const;
-
-		/**
-		 * @brief	Returns the size of the index buffer in bytes.
-		 */
-		UINT32 getIndexBufferSize() const;
-
-		/**
-		 * @brief	Returns the size of the specified stream in bytes.
-		 */
-		UINT32 getStreamSize(UINT32 streamIdx) const;
-
-		/**
-		 * @brief	Returns the size of all the streams in bytes.
-		 */
-		UINT32 getStreamSize() const;
-
-		/**
-		 * @brief	Returns the data needed for iterating over the requested vertex element.
-		 *
-		 * @param	semantic   		Semantic of the element we are looking for.
-		 * @param	semanticIdx 	If there are multiple semantics with the same name, use different index to differentiate between them.
-		 * @param	streamIdx   	Zero-based index of the stream the element resides in.
-		 * @param [out] data		Pointer to the start of this elements data.
-		 * @param [out] stride		Number of bytes between vertex elements of this type.
-		 */
-		void getDataForIterator(VertexElementSemantic semantic, UINT32 semanticIdx, UINT32 streamIdx, UINT8*& data, UINT32& stride) const;
-
-	private:
-		friend class Mesh;
-		friend class MeshHeap;
-
-		UINT32 mDescBuilding;
-
-		UINT8* mData;
-
-		UINT32 mResourceVertexOffset;
-		UINT32 mResourceIndexOffset;
-
-		UINT32 mNumVertices;
-		UINT32 mNumIndices;
-		IndexBuffer::IndexType mIndexType;
-
-		VertexDataDescPtr mVertexData;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	private:
-		MeshData(); // Serialization only
-
-	public:
-		friend class MeshDataRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmGpuResourceData.h"
+#include "CmVertexBuffer.h"
+#include "CmIndexBuffer.h"
+#include "CmVertexDeclaration.h"
+#include "CmDrawOps.h"
+#include "CmSubMesh.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Iterator that allows you to easily populate or read vertex elements
+	 *			in MeshData.
+	 */
+	template<class T>
+	class VertexElemIter
+	{
+	public:
+		VertexElemIter()
+			:mData(nullptr), mEnd(nullptr), mByteStride(0), mNumElements(0)
+		{
+
+		}
+
+		VertexElemIter(UINT8* data, UINT32 byteStride, UINT32 numElements)
+			:mData(data), mByteStride(byteStride), mNumElements(numElements)
+		{
+			mEnd = mData + byteStride * numElements;
+		}
+
+		/**
+		 * @brief	Adds a new value to the iterators current position and
+		 *			advances the iterator.
+		 */
+		void addValue(T& value)
+		{
+			setValue(value);
+			moveNext();
+		}
+
+		/**
+		 * @brief	Sets a new value at the iterators current position.
+		 */
+		void setValue(T& value)
+		{
+			memcpy(mData, &value, sizeof(T));
+		}
+
+		/**
+		 * @brief	Returns the value at the iterators current position.
+		 */
+		T& getValue()
+		{
+			return *((T*)mData);
+		}
+
+		/**
+		 * @brief	Moves the iterator to the next position. Returns true
+		 *			if there are more elements.
+		 */
+		bool moveNext()
+		{
+#ifdef CM_DEBUG_MODE
+			if(mData >= mEnd)
+			{
+				CM_EXCEPT(InternalErrorException, "Vertex element iterator out of buffer bounds.");
+			}
+#endif
+
+			mData += mByteStride;
+
+			return mData < mEnd;
+		}
+
+		/**
+		 * @brief	Returns the number of elements this iterator can iterate over.
+		 */
+		UINT32 getNumElements() const { return mNumElements; }
+
+	private:
+		UINT8* mData;
+		UINT8* mEnd;
+		UINT32 mByteStride;
+		UINT32 mNumElements;
+	};
+
+	/**
+	 * @brief	Used for initializing, updating and reading mesh data from Meshes.
+	 */
+	class BS_CORE_EXPORT MeshData : public GpuResourceData
+	{
+	public:
+		/**
+		 * @brief	Constructs a new object that can hold number of vertices described by the provided vertex data description. As well
+		 *			as a number of indices of the provided type.
+		 */
+		MeshData(UINT32 numVertices, UINT32 numIndexes, const VertexDataDescPtr& vertexData, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+		~MeshData();
+
+		/**
+		 * @brief	Determines at which position in the mesh will the vertex data be written into or read from.
+		 *
+		 * @param	bytes	Offset in number of vertices.
+		 */
+		void setResourceVertexOffset(UINT32 vertices) { mResourceVertexOffset = vertices; }
+
+		/**
+		 * @brief	Determines at which position in the mesh will the index data be written into or read from.
+		 *
+		 * @param	bytes	Offset in number of indices.
+		 */
+		void setResourceIndexOffset(UINT32 indices) { mResourceIndexOffset = indices; }
+
+		/**
+		 * @brief	Determines at which position in the mesh will the vertex data be written into or read
+		 * 			from.
+		 *
+		 * @return	Offset in number of vertices.
+		 */
+		UINT32 getResourceVertexOffset() const { return mResourceVertexOffset; }
+
+		/**
+		 * @brief	Determines at which position in the mesh will the index data be written into or read from.
+		 *
+		 * @return	Offset in number of indices.
+		 */
+		UINT32 getResourceIndexOffset() const { return mResourceIndexOffset; }
+
+		/**
+		 * @brief	Copies data from "data" parameter into the internal buffer for the specified semantic.
+		 *
+		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
+		 * @param	data			Vertex data, containing at least "size" bytes.
+		 * @param	size			The size of the data. Must be the size of the vertex element type * number of vertices.
+		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
+		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
+		 */
+		void setVertexData(VertexElementSemantic semantic, UINT8* data, UINT32 size, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector2 vertex elements. This is the preferred
+		 * 			method of assigning or reading vertex data. 
+		 * 			
+		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
+		 */
+		VertexElemIter<Vector2> getVec2DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector3 vertex elements. This is the preferred
+		 * 			method of assigning or reading vertex data. 
+		 * 			
+		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
+		 */
+		VertexElemIter<Vector3> getVec3DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * @brief	Returns an iterator you can use for easily retrieving or setting Vector4 vertex elements. This is the preferred
+		 * 			method of assigning or reading vertex data. 
+		 * 			
+		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
+		 */
+		VertexElemIter<Vector4> getVec4DataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * @brief	Returns an iterator you can use for easily retrieving or setting DWORD vertex elements. This is the preferred
+		 * 			method of assigning or reading vertex data. 
+		 * 			
+		 * @note	If vertex data of this type/semantic/index/stream doesn't exist and exception will be thrown.
+		 */
+		VertexElemIter<UINT32> getDWORDDataIter(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0);
+
+		/**
+		 * @brief	Returns the total number of vertices this object can hold.
+		 */
+		UINT32 getNumVertices() const { return mNumVertices; }
+
+		/**
+		 * @brief	Returns the total number of indices this object can hold.
+		 */
+		UINT32 getNumIndices() const;
+
+		/**
+		 * @brief	Returns a 16-bit pointer to the start of the internal index buffer.
+		 */
+		UINT16* getIndices16() const;
+
+		/**
+		 * @brief	Returns a 32-bit pointer to the start of the internal index buffer.
+		 */
+		UINT32* getIndices32() const;
+
+		/**
+		 * @brief	Returns the size of an index element in bytes.
+		 */
+		UINT32 getIndexElementSize() const;
+
+		/**
+		 * @brief	Returns the type of an index element.
+		 */
+		IndexBuffer::IndexType getIndexType() const { return mIndexType; }
+
+		/**
+		 * @brief	Returns the pointer to the first element of the specified type. If you want to
+		 * 			iterate over all elements you need to call getVertexStride() to get the number
+		 * 			of bytes you need to advance between each element.
+		 *
+		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
+		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
+		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
+		 *
+		 * @return	null if it fails, else the element data.
+		 */
+		UINT8* getElementData(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
+
+		/**
+		 * @brief	Returns an offset into the internal buffer where this element with the provided semantic starts. 
+		 *			Offset is provided in number of bytes.
+		 * 
+		 * @param	semantic   		Semantic that allows the engine to connect the data to a shader input slot.
+		 * @param	semanticIdx 	(optional) If there are multiple semantics with the same name, use different index to differentiate between them.
+		 * @param	streamIdx   	(optional) Zero-based index of the stream. Each stream will internally be represented as a single vertex buffer.
+		 */
+		UINT32 getElementOffset(VertexElementSemantic semantic, UINT32 semanticIdx = 0, UINT32 streamIdx = 0) const;
+
+		/**
+		 * @brief	Returns an object that describes data contained in a single vertex.
+		 */
+		const VertexDataDescPtr& getVertexDesc() const { return mVertexData; }
+
+		/**
+		 * @brief	Combines a number of submeshes and their mesh data into one large mesh data buffer.
+		 *
+		 * @param	elements	Data containing vertices and indices referenced by the submeshes. Number of elements
+		 *						must be the same as number of submeshes.
+		 * @param	subMeshes	Submeshes representing vertex and index range to take from mesh data and combine. Number of
+		 *						submeshes must match the number of provided MeshData elements.
+		 * @param	[out] subMeshes		Outputs all combined sub-meshes with their new index and vertex offsets referencing
+		 *								the newly created MeshData.
+		 *
+		 * @returns	Combined mesh data containing all vertices and indexes references by the provided sub-meshes.
+		 */
+		static MeshDataPtr combine(const Vector<MeshDataPtr>& elements, const Vector<Vector<SubMesh>>& allSubMeshes,
+			Vector<SubMesh>& subMeshes);
+
+	protected:
+		/**
+		 * @brief	Returns the size of the internal buffer in bytes.
+		 */
+		UINT32 getInternalBufferSize();
+
+	private:
+		/**
+		 * @brief	Returns a pointer to the start of the index buffer.
+		 */
+		UINT8* getIndexData() const { return getData(); }
+
+		/**
+		 * @brief	Returns a pointer to the start of the specified vertex stream.
+		 */
+		UINT8* getStreamData(UINT32 streamIdx) const;
+
+		/**
+		 * @brief	Returns an offset in bytes to the start of the index buffer from the start of the
+		 *			internal buffer.
+		 */
+		UINT32 getIndexBufferOffset() const;
+
+		/**
+		 * @brief	Returns an offset in bytes to the start of the stream from the start of the
+		 *			internal buffer.
+		 */
+		UINT32 getStreamOffset(UINT32 streamIdx = 0) const;
+
+		/**
+		 * @brief	Returns the size of the index buffer in bytes.
+		 */
+		UINT32 getIndexBufferSize() const;
+
+		/**
+		 * @brief	Returns the size of the specified stream in bytes.
+		 */
+		UINT32 getStreamSize(UINT32 streamIdx) const;
+
+		/**
+		 * @brief	Returns the size of all the streams in bytes.
+		 */
+		UINT32 getStreamSize() const;
+
+		/**
+		 * @brief	Returns the data needed for iterating over the requested vertex element.
+		 *
+		 * @param	semantic   		Semantic of the element we are looking for.
+		 * @param	semanticIdx 	If there are multiple semantics with the same name, use different index to differentiate between them.
+		 * @param	streamIdx   	Zero-based index of the stream the element resides in.
+		 * @param [out] data		Pointer to the start of this elements data.
+		 * @param [out] stride		Number of bytes between vertex elements of this type.
+		 */
+		void getDataForIterator(VertexElementSemantic semantic, UINT32 semanticIdx, UINT32 streamIdx, UINT8*& data, UINT32& stride) const;
+
+	private:
+		friend class Mesh;
+		friend class MeshHeap;
+
+		UINT32 mDescBuilding;
+
+		UINT8* mData;
+
+		UINT32 mResourceVertexOffset;
+		UINT32 mResourceIndexOffset;
+
+		UINT32 mNumVertices;
+		UINT32 mNumIndices;
+		IndexBuffer::IndexType mIndexType;
+
+		VertexDataDescPtr mVertexData;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	private:
+		MeshData(); // Serialization only
+
+	public:
+		friend class MeshDataRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
 }

+ 74 - 74
CamelotCore/Include/CmMeshDataRTTI.h → BansheeCore/Include/CmMeshDataRTTI.h

@@ -1,75 +1,75 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmMeshData.h"
-#include "CmManagedDataBlock.h"
-#include "CmVertexDeclaration.h"
-
-namespace BansheeEngine
-{
-	CM_ALLOW_MEMCPY_SERIALIZATION(IndexBuffer::IndexType);
-
-	class CM_EXPORT MeshDataRTTI : public RTTIType<MeshData, GpuResourceData, MeshDataRTTI>
-	{
-	private:
-		VertexDataDescPtr getVertexData(MeshData* obj) { return obj->mVertexData; }
-		void setVertexData(MeshData* obj, VertexDataDescPtr value) { obj->mVertexData = value; }
-
-		IndexBuffer::IndexType& getIndexType(MeshData* obj) { return obj->mIndexType; }
-		void setIndexType(MeshData* obj, IndexBuffer::IndexType& value) { obj->mIndexType = value; }
-
-		UINT32& getNumVertices(MeshData* obj) { return obj->mNumVertices; }
-		void setNumVertices(MeshData* obj, UINT32& value) { obj->mNumVertices = value; }
-
-		UINT32& getNumIndices(MeshData* obj) { return obj->mNumIndices; }
-		void setNumIndices(MeshData* obj, UINT32& value) { obj->mNumIndices = value; }
-
-		ManagedDataBlock getData(MeshData* obj) 
-		{ 
-			ManagedDataBlock dataBlock((UINT8*)obj->getData(), obj->getInternalBufferSize());
-			return dataBlock; 
-		}
-
-		void setData(MeshData* obj, ManagedDataBlock val) 
-		{ 
-			// Nothing to do here, the pointer we provided already belongs to PixelData
-			// so the data is already written
-		}
-
-		static UINT8* allocateData(MeshData* obj, UINT32 numBytes)
-		{
-			obj->allocateInternalBuffer(numBytes);
-
-			return obj->getData();
-		}
-
-	public:
-		MeshDataRTTI()
-		{
-			addReflectablePtrField("mVertexData", 0, &MeshDataRTTI::getVertexData, &MeshDataRTTI::setVertexData);
-
-			addPlainField("mIndexType", 1, &MeshDataRTTI::getIndexType, &MeshDataRTTI::setIndexType);
-			addPlainField("mNumVertices", 2, &MeshDataRTTI::getNumVertices, &MeshDataRTTI::setNumVertices);
-			addPlainField("mNumIndices", 3, &MeshDataRTTI::getNumIndices, &MeshDataRTTI::setNumIndices);
-
-			addDataBlockField("data", 4, &MeshDataRTTI::getData, &MeshDataRTTI::setData, 0, &MeshDataRTTI::allocateData);
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject() 
-		{
-			return cm_shared_ptr<MeshData, PoolAlloc>(new (cm_alloc<MeshData, PoolAlloc>()) MeshData());
-		}
-
-		virtual const String& getRTTIName() 
-		{
-			static String name = "MeshData";
-			throw name;
-		}
-
-		virtual UINT32 getRTTIId() 
-		{
-			return TID_MeshData;
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmMeshData.h"
+#include "CmManagedDataBlock.h"
+#include "CmVertexDeclaration.h"
+
+namespace BansheeEngine
+{
+	CM_ALLOW_MEMCPY_SERIALIZATION(IndexBuffer::IndexType);
+
+	class BS_CORE_EXPORT MeshDataRTTI : public RTTIType<MeshData, GpuResourceData, MeshDataRTTI>
+	{
+	private:
+		VertexDataDescPtr getVertexData(MeshData* obj) { return obj->mVertexData; }
+		void setVertexData(MeshData* obj, VertexDataDescPtr value) { obj->mVertexData = value; }
+
+		IndexBuffer::IndexType& getIndexType(MeshData* obj) { return obj->mIndexType; }
+		void setIndexType(MeshData* obj, IndexBuffer::IndexType& value) { obj->mIndexType = value; }
+
+		UINT32& getNumVertices(MeshData* obj) { return obj->mNumVertices; }
+		void setNumVertices(MeshData* obj, UINT32& value) { obj->mNumVertices = value; }
+
+		UINT32& getNumIndices(MeshData* obj) { return obj->mNumIndices; }
+		void setNumIndices(MeshData* obj, UINT32& value) { obj->mNumIndices = value; }
+
+		ManagedDataBlock getData(MeshData* obj) 
+		{ 
+			ManagedDataBlock dataBlock((UINT8*)obj->getData(), obj->getInternalBufferSize());
+			return dataBlock; 
+		}
+
+		void setData(MeshData* obj, ManagedDataBlock val) 
+		{ 
+			// Nothing to do here, the pointer we provided already belongs to PixelData
+			// so the data is already written
+		}
+
+		static UINT8* allocateData(MeshData* obj, UINT32 numBytes)
+		{
+			obj->allocateInternalBuffer(numBytes);
+
+			return obj->getData();
+		}
+
+	public:
+		MeshDataRTTI()
+		{
+			addReflectablePtrField("mVertexData", 0, &MeshDataRTTI::getVertexData, &MeshDataRTTI::setVertexData);
+
+			addPlainField("mIndexType", 1, &MeshDataRTTI::getIndexType, &MeshDataRTTI::setIndexType);
+			addPlainField("mNumVertices", 2, &MeshDataRTTI::getNumVertices, &MeshDataRTTI::setNumVertices);
+			addPlainField("mNumIndices", 3, &MeshDataRTTI::getNumIndices, &MeshDataRTTI::setNumIndices);
+
+			addDataBlockField("data", 4, &MeshDataRTTI::getData, &MeshDataRTTI::setData, 0, &MeshDataRTTI::allocateData);
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject() 
+		{
+			return cm_shared_ptr<MeshData, PoolAlloc>(new (cm_alloc<MeshData, PoolAlloc>()) MeshData());
+		}
+
+		virtual const String& getRTTIName() 
+		{
+			static String name = "MeshData";
+			throw name;
+		}
+
+		virtual UINT32 getRTTIId() 
+		{
+			return TID_MeshData;
+		}
+	};
 }

+ 241 - 241
CamelotCore/Include/CmMeshHeap.h → BansheeCore/Include/CmMeshHeap.h

@@ -1,242 +1,242 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmCoreObject.h"
-#include "CmIndexData.h"
-#include "CmDrawOps.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Mesh heap allows you to quickly allocate and deallocate a large amounts of temporary 
-	 *			meshes without the large overhead of normal Mesh creation.
-	 * 			Only requirement is that meshes share the same vertex description and index type.
-	 * 			
-	 * @note	This class should be considered as a replacement for a normal Mesh if you are constantly 
-	 * 			updating the mesh (e.g. every frame) and you are not able to discard entire mesh contents 
-	 * 			on each update. Not using discard flag on normal meshes may introduce GPU-CPU sync points
-	 * 			which may severely limit performance. Primary purpose of this class is to avoid
-	 * 			those sync points by not forcing you to discard contents.
-	 * 			
-	 *			Downside is that this class may allocate 2-3x (or more) memory than it is actually needed
-	 *			for your data.
-	 *			
-	 *			Sim thread except where noted otherwise.
-	 */
-	class CM_EXPORT MeshHeap : public CoreObject
-	{
-		/**
-		 * @brief	Signifies how is a data chunk used.
-		 */
-		enum class UseFlags
-		{
-			Used, /**< Data chunk is used by both CPU and GPU. */
-			CPUFree, /**< Data chunk was released by CPU but not GPU. */
-			GPUFree, /**< Data chunk was released by GPU but not CPU. */
-			Free /**< Data chunk was released by both CPU and GPU. */
-		};
-
-		/**
-		 * @brief	Represents a continuous chunk of memory.
-		 */
-		struct ChunkData
-		{
-			UINT32 start, size;
-		};
-
-		/**
-		 * @brief	Represents an allocated piece of data representing a mesh.
-		 */
-		struct AllocatedData
-		{
-			UINT32 vertChunkIdx;
-			UINT32 idxChunkIdx;
-
-			UseFlags useFlags;
-			UINT32 eventQueryIdx;
-		};
-
-		/**
-		 * @brief	Data about a GPU query.
-		 */
-		struct QueryData
-		{
-			EventQueryPtr query;
-			UINT32 queryId;
-		};
-
-	public:
-		~MeshHeap();
-
-		/**
-		 * @brief	Allocates a new mesh in the heap, expanding the heap if needed. Mesh will be initialized
-		 *			with the provided meshData. You may use the returned transient mesh for drawing.
-		 *
-		 * @note	Offsets provided by MeshData are ignored. MeshHeap will determine
-		 * 			where the data will be written internally.
-		 */
-		TransientMeshPtr alloc(const MeshDataPtr& meshData, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * @brief	Deallocates the provided mesh and makes that room on the heap re-usable as soon as the GPU
-		 *			is also done with the mesh.
-		 */
-		void dealloc(const TransientMeshPtr& mesh);
-
-		/**
-		 * @brief	Creates a new mesh heap.
-		 *
-		 * @param	numVertices	Initial number of vertices the heap may store. This will grow automatically if needed.
-		 * @param	numIndices	Initial number of indices the heap may store. This will grow automatically if needed.
-		 * @param	vertexDesc	Description of the stored vertices.
-		 * @param	indexType	Type of the stored indices.
-		 */
-		static MeshHeapPtr create(UINT32 numVertices, UINT32 numIndices, 
-			const VertexDataDescPtr& vertexDesc, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-	private:
-		friend class TransientMesh;
-
-		/**
-		 * @copydoc	create
-		 */
-		MeshHeap(UINT32 numVertices, UINT32 numIndices, 
-			const VertexDataDescPtr& vertexDesc, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		/**
-		 * @copydoc Resource::initialize_internal()
-		 */
-		virtual void initialize_internal();
-
-		/**
-		 * @copydoc Resource::destroy_internal()
-		 */
-		virtual void destroy_internal();
-
-		/**
-		 * @brief	Allocates a new mesh in the heap, expanding the heap if needed. 
-		 *
-		 * @param	meshId		Unique mesh ID.
-		 * @param	meshData	Data to initialize the new mesh with.
-		 *
-		 * @note	Core thread.
-		 */
-		void allocInternal(UINT32 meshId, const MeshDataPtr& meshData);
-
-		/**
-		 * @brief	Deallocates the mesh with the provided ID. Freed memory
-		 *			will be re-used as soon as the GPU is done with the mesh
-		 *
-		 * @note	Core thread.
-		 */
-		void deallocInternal(UINT32 meshId);
-
-		/**
-		 * @brief	Resizes the vertex buffers so they max contain the provided
-		 *			number of vertices.
-		 *
-		 * @note	Core thread.
-		 */
-		void growVertexBuffer(UINT32 numVertices);
-
-		/**
-		 * @brief	Resizes the index buffer so they max contain the provided
-		 *			number of indices.
-		 *
-		 * @note	Core thread.
-		 */
-		void growIndexBuffer(UINT32 numIndices);
-
-		/**
-		 * @brief	Creates a new event query or returns an existing one from the pool
-		 *			if available. Returned value is an index into mEventQueries array.
-		 *
-		 * @note	Core thread.
-		 */
-		UINT32 createEventQuery();
-
-		/**
-		 * @brief	Frees the event query with the specified index and returns it to the
-		 *			pool so it may be reused later.
-		 *
-		 * @note	Core thread.
-		 */
-		void freeEventQuery(UINT32 idx);
-
-		/**
-		 * @brief	Gets internal vertex data for all the meshes.
-		 */
-		std::shared_ptr<VertexData> getVertexData() const;
-
-		/**
-		 * @brief	Gets internal index data for all the meshes.
-		 */
-		std::shared_ptr<IndexData> getIndexData() const;
-
-		/**
-		 * @brief	Returns the offset in vertices from the start of the buffer
-		 *			to the first vertex of the mesh with the provided ID.
-		 */
-		UINT32 getVertexOffset(UINT32 meshId) const;
-
-		/**
-		 * @brief	Returns the offset in indices from the start of the buffer
-		 *			to the first index of the mesh with the provided ID.
-		 */
-		UINT32 getIndexOffset(UINT32 meshId) const;
-
-		/**
-		 * @brief	Called by the render system when a mesh gets queued to the GPU.
-		 */
-		void notifyUsedOnGPU(UINT32 meshId);
-
-		/**
-		 * @brief	Called by an GPU event query when GPU processes the query. Normally
-		 *			signals the heap that the GPU is done with the mesh.
-		 */
-		void queryTriggered(UINT32 meshId, UINT32 queryId);
-
-		/**
-		 * @brief	Attempts to reorganize the vertex and index buffer chunks in order to 
-		 *			in order to make free memory contigous.
-		 *
-		 * @note	This will not actually copy any data from index/vertex buffers, and will only
-		 *			modify the chunk descriptors.
-		 */
-		void mergeWithNearbyChunks(UINT32 chunkVertIdx, UINT32 chunkIdxIdx);
-
-	private:
-		UINT32 mNumVertices; // Core thread
-		UINT32 mNumIndices; // Core thread
-
-		std::shared_ptr<VertexData> mVertexData; // Core thread
-		std::shared_ptr<IndexData> mIndexData; // Core thread
-
-		Vector<UINT8*> mCPUVertexData; // Core thread
-		UINT8* mCPUIndexData; // Core thread
-
-		VertexDataDescPtr mVertexDesc; // Immutable
-		IndexBuffer::IndexType mIndexType; // Immutable
-
-		Map<UINT32, TransientMeshPtr> mMeshes; // Sim thread
-		UINT32 mNextFreeId; // Sim thread
-
-		Map<UINT32, AllocatedData> mMeshAllocData; // Core thread
-
-		Vector<ChunkData> mVertChunks; // Core thread
-		Vector<ChunkData> mIdxChunks; // Core thread
-
-		Stack<UINT32> mEmptyVertChunks; // Core thread
-		Stack<UINT32> mEmptyIdxChunks; // Core thread
-
-		List<UINT32> mFreeVertChunks; // Core thread
-		List<UINT32> mFreeIdxChunks; // Core thread
-
-		Vector<QueryData> mEventQueries; // Core thread
-		Stack<UINT32> mFreeEventQueries; // Core thread
-
-		UINT32 mNextQueryId;
-
-		static const float GrowPercent;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmCoreObject.h"
+#include "CmIndexData.h"
+#include "CmDrawOps.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Mesh heap allows you to quickly allocate and deallocate a large amounts of temporary 
+	 *			meshes without the large overhead of normal Mesh creation.
+	 * 			Only requirement is that meshes share the same vertex description and index type.
+	 * 			
+	 * @note	This class should be considered as a replacement for a normal Mesh if you are constantly 
+	 * 			updating the mesh (e.g. every frame) and you are not able to discard entire mesh contents 
+	 * 			on each update. Not using discard flag on normal meshes may introduce GPU-CPU sync points
+	 * 			which may severely limit performance. Primary purpose of this class is to avoid
+	 * 			those sync points by not forcing you to discard contents.
+	 * 			
+	 *			Downside is that this class may allocate 2-3x (or more) memory than it is actually needed
+	 *			for your data.
+	 *			
+	 *			Sim thread except where noted otherwise.
+	 */
+	class BS_CORE_EXPORT MeshHeap : public CoreObject
+	{
+		/**
+		 * @brief	Signifies how is a data chunk used.
+		 */
+		enum class UseFlags
+		{
+			Used, /**< Data chunk is used by both CPU and GPU. */
+			CPUFree, /**< Data chunk was released by CPU but not GPU. */
+			GPUFree, /**< Data chunk was released by GPU but not CPU. */
+			Free /**< Data chunk was released by both CPU and GPU. */
+		};
+
+		/**
+		 * @brief	Represents a continuous chunk of memory.
+		 */
+		struct ChunkData
+		{
+			UINT32 start, size;
+		};
+
+		/**
+		 * @brief	Represents an allocated piece of data representing a mesh.
+		 */
+		struct AllocatedData
+		{
+			UINT32 vertChunkIdx;
+			UINT32 idxChunkIdx;
+
+			UseFlags useFlags;
+			UINT32 eventQueryIdx;
+		};
+
+		/**
+		 * @brief	Data about a GPU query.
+		 */
+		struct QueryData
+		{
+			EventQueryPtr query;
+			UINT32 queryId;
+		};
+
+	public:
+		~MeshHeap();
+
+		/**
+		 * @brief	Allocates a new mesh in the heap, expanding the heap if needed. Mesh will be initialized
+		 *			with the provided meshData. You may use the returned transient mesh for drawing.
+		 *
+		 * @note	Offsets provided by MeshData are ignored. MeshHeap will determine
+		 * 			where the data will be written internally.
+		 */
+		TransientMeshPtr alloc(const MeshDataPtr& meshData, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * @brief	Deallocates the provided mesh and makes that room on the heap re-usable as soon as the GPU
+		 *			is also done with the mesh.
+		 */
+		void dealloc(const TransientMeshPtr& mesh);
+
+		/**
+		 * @brief	Creates a new mesh heap.
+		 *
+		 * @param	numVertices	Initial number of vertices the heap may store. This will grow automatically if needed.
+		 * @param	numIndices	Initial number of indices the heap may store. This will grow automatically if needed.
+		 * @param	vertexDesc	Description of the stored vertices.
+		 * @param	indexType	Type of the stored indices.
+		 */
+		static MeshHeapPtr create(UINT32 numVertices, UINT32 numIndices, 
+			const VertexDataDescPtr& vertexDesc, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+	private:
+		friend class TransientMesh;
+
+		/**
+		 * @copydoc	create
+		 */
+		MeshHeap(UINT32 numVertices, UINT32 numIndices, 
+			const VertexDataDescPtr& vertexDesc, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		/**
+		 * @copydoc Resource::initialize_internal()
+		 */
+		virtual void initialize_internal();
+
+		/**
+		 * @copydoc Resource::destroy_internal()
+		 */
+		virtual void destroy_internal();
+
+		/**
+		 * @brief	Allocates a new mesh in the heap, expanding the heap if needed. 
+		 *
+		 * @param	meshId		Unique mesh ID.
+		 * @param	meshData	Data to initialize the new mesh with.
+		 *
+		 * @note	Core thread.
+		 */
+		void allocInternal(UINT32 meshId, const MeshDataPtr& meshData);
+
+		/**
+		 * @brief	Deallocates the mesh with the provided ID. Freed memory
+		 *			will be re-used as soon as the GPU is done with the mesh
+		 *
+		 * @note	Core thread.
+		 */
+		void deallocInternal(UINT32 meshId);
+
+		/**
+		 * @brief	Resizes the vertex buffers so they max contain the provided
+		 *			number of vertices.
+		 *
+		 * @note	Core thread.
+		 */
+		void growVertexBuffer(UINT32 numVertices);
+
+		/**
+		 * @brief	Resizes the index buffer so they max contain the provided
+		 *			number of indices.
+		 *
+		 * @note	Core thread.
+		 */
+		void growIndexBuffer(UINT32 numIndices);
+
+		/**
+		 * @brief	Creates a new event query or returns an existing one from the pool
+		 *			if available. Returned value is an index into mEventQueries array.
+		 *
+		 * @note	Core thread.
+		 */
+		UINT32 createEventQuery();
+
+		/**
+		 * @brief	Frees the event query with the specified index and returns it to the
+		 *			pool so it may be reused later.
+		 *
+		 * @note	Core thread.
+		 */
+		void freeEventQuery(UINT32 idx);
+
+		/**
+		 * @brief	Gets internal vertex data for all the meshes.
+		 */
+		std::shared_ptr<VertexData> getVertexData() const;
+
+		/**
+		 * @brief	Gets internal index data for all the meshes.
+		 */
+		std::shared_ptr<IndexData> getIndexData() const;
+
+		/**
+		 * @brief	Returns the offset in vertices from the start of the buffer
+		 *			to the first vertex of the mesh with the provided ID.
+		 */
+		UINT32 getVertexOffset(UINT32 meshId) const;
+
+		/**
+		 * @brief	Returns the offset in indices from the start of the buffer
+		 *			to the first index of the mesh with the provided ID.
+		 */
+		UINT32 getIndexOffset(UINT32 meshId) const;
+
+		/**
+		 * @brief	Called by the render system when a mesh gets queued to the GPU.
+		 */
+		void notifyUsedOnGPU(UINT32 meshId);
+
+		/**
+		 * @brief	Called by an GPU event query when GPU processes the query. Normally
+		 *			signals the heap that the GPU is done with the mesh.
+		 */
+		void queryTriggered(UINT32 meshId, UINT32 queryId);
+
+		/**
+		 * @brief	Attempts to reorganize the vertex and index buffer chunks in order to 
+		 *			in order to make free memory contigous.
+		 *
+		 * @note	This will not actually copy any data from index/vertex buffers, and will only
+		 *			modify the chunk descriptors.
+		 */
+		void mergeWithNearbyChunks(UINT32 chunkVertIdx, UINT32 chunkIdxIdx);
+
+	private:
+		UINT32 mNumVertices; // Core thread
+		UINT32 mNumIndices; // Core thread
+
+		std::shared_ptr<VertexData> mVertexData; // Core thread
+		std::shared_ptr<IndexData> mIndexData; // Core thread
+
+		Vector<UINT8*> mCPUVertexData; // Core thread
+		UINT8* mCPUIndexData; // Core thread
+
+		VertexDataDescPtr mVertexDesc; // Immutable
+		IndexBuffer::IndexType mIndexType; // Immutable
+
+		Map<UINT32, TransientMeshPtr> mMeshes; // Sim thread
+		UINT32 mNextFreeId; // Sim thread
+
+		Map<UINT32, AllocatedData> mMeshAllocData; // Core thread
+
+		Vector<ChunkData> mVertChunks; // Core thread
+		Vector<ChunkData> mIdxChunks; // Core thread
+
+		Stack<UINT32> mEmptyVertChunks; // Core thread
+		Stack<UINT32> mEmptyIdxChunks; // Core thread
+
+		List<UINT32> mFreeVertChunks; // Core thread
+		List<UINT32> mFreeIdxChunks; // Core thread
+
+		Vector<QueryData> mEventQueries; // Core thread
+		Stack<UINT32> mFreeEventQueries; // Core thread
+
+		UINT32 mNextQueryId;
+
+		static const float GrowPercent;
+	};
 }

+ 88 - 88
CamelotCore/Include/CmMeshManager.h → BansheeCore/Include/CmMeshManager.h

@@ -1,89 +1,89 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmMesh.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Manager that handles creation of Meshes.
-	 */
-	class CM_EXPORT MeshManager : public Module<MeshManager>
-	{
-	public:
-		MeshManager();
-		~MeshManager();
-
-		/**
-		 * @brief	Creates an empty mesh with enough space to store vertex and index data described by the parameters.
-		 *
-		 * @param	numVertices	Number of vertices in the mesh.
-		 * @param	numIndices	Number of indices in the mesh.
-		 * @param	vertexDesc	Vertex description that describes how are vertices organized within the vertex buffer(s).
-		 * @param	bufferType	Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
-		 *						updating the mesh often, or static otherwise.
-		 * @param	drawOp		Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
-		 * @param	indexType	Type of indexes in the index buffer. Determines size of an index.
-		 */
-		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, 
-			 DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		/**
-		 * @brief	Creates an mesh with enough space to store vertex and index data described by the parameters, and initializes
-		 *			a portion (or entire) mesh with some data.
-		 *
-		 * @param	numVertices	Number of vertices in the mesh.
-		 * @param	numIndices	Number of indices in the mesh.
-		 * @param	vertexDesc	Vertex description that describes how are vertices organized within the vertex buffer(s).
-		 * @param	initialData	Initial data to initialize the mesh with. Internal offsets in this object will be used to
-		 *						determine where to write the data in the Mesh buffers.
-		 * @param	bufferType	Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
-		 *						updating the mesh often, or static otherwise.
-		 * @param	drawOp		Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
-		 * @param	indexType	Type of indexes in the index buffer. Determines size of an index.
-		 */
-		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialData, 
-			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST, 
-			IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
-
-		/**
-		 * @brief	Creates a mesh and initializes it with the provided data. Mesh will be of exact size needed to hold the data.
-		 *
-		 * @param	initialData	Initial data to initialize the mesh with. Size of the buffers and vertex declaration will be taken
-		 *						from this object.
-		 * @param	bufferType	Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
-		 *						updating the mesh often, or static otherwise.
-		 * @param	drawOp		Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
-		 */
-		MeshPtr create(const MeshDataPtr& initialData, MeshBufferType bufferType = MeshBufferType::Static,
-			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * @brief	Creates a new empty and uninitialized mesh. You will need to manually initialize the mesh before using it.
-		 *	
-		 * @note	This should only be used for special cases and is not meant for normal use.
-		 */
-		MeshPtr createEmpty();
-
-		/**
-		 * @brief	Returns some dummy mesh data with one triangle you may use for initializing a mesh.
-		 */
-		MeshDataPtr getDummyMeshData() const { return mDummyMeshData; }
-
-		/**
-		 * @brief	Returns a dummy mesh containing one triangle.
-		 */
-		HMesh getDummyMesh() const { return mDummyMesh; }
-
-	protected:
-		/**
-		 * @copydoc		Module::onStartUp
-		 */
-		virtual void onStartUp();
-
-	private:
-		MeshDataPtr mDummyMeshData;
-		HMesh mDummyMesh;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmMesh.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Manager that handles creation of Meshes.
+	 */
+	class BS_CORE_EXPORT MeshManager : public Module<MeshManager>
+	{
+	public:
+		MeshManager();
+		~MeshManager();
+
+		/**
+		 * @brief	Creates an empty mesh with enough space to store vertex and index data described by the parameters.
+		 *
+		 * @param	numVertices	Number of vertices in the mesh.
+		 * @param	numIndices	Number of indices in the mesh.
+		 * @param	vertexDesc	Vertex description that describes how are vertices organized within the vertex buffer(s).
+		 * @param	bufferType	Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
+		 *						updating the mesh often, or static otherwise.
+		 * @param	drawOp		Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
+		 * @param	indexType	Type of indexes in the index buffer. Determines size of an index.
+		 */
+		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static, 
+			 DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		/**
+		 * @brief	Creates an mesh with enough space to store vertex and index data described by the parameters, and initializes
+		 *			a portion (or entire) mesh with some data.
+		 *
+		 * @param	numVertices	Number of vertices in the mesh.
+		 * @param	numIndices	Number of indices in the mesh.
+		 * @param	vertexDesc	Vertex description that describes how are vertices organized within the vertex buffer(s).
+		 * @param	initialData	Initial data to initialize the mesh with. Internal offsets in this object will be used to
+		 *						determine where to write the data in the Mesh buffers.
+		 * @param	bufferType	Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
+		 *						updating the mesh often, or static otherwise.
+		 * @param	drawOp		Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
+		 * @param	indexType	Type of indexes in the index buffer. Determines size of an index.
+		 */
+		MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialData, 
+			MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST, 
+			IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
+
+		/**
+		 * @brief	Creates a mesh and initializes it with the provided data. Mesh will be of exact size needed to hold the data.
+		 *
+		 * @param	initialData	Initial data to initialize the mesh with. Size of the buffers and vertex declaration will be taken
+		 *						from this object.
+		 * @param	bufferType	Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
+		 *						updating the mesh often, or static otherwise.
+		 * @param	drawOp		Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
+		 */
+		MeshPtr create(const MeshDataPtr& initialData, MeshBufferType bufferType = MeshBufferType::Static,
+			DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * @brief	Creates a new empty and uninitialized mesh. You will need to manually initialize the mesh before using it.
+		 *	
+		 * @note	This should only be used for special cases and is not meant for normal use.
+		 */
+		MeshPtr createEmpty();
+
+		/**
+		 * @brief	Returns some dummy mesh data with one triangle you may use for initializing a mesh.
+		 */
+		MeshDataPtr getDummyMeshData() const { return mDummyMeshData; }
+
+		/**
+		 * @brief	Returns a dummy mesh containing one triangle.
+		 */
+		HMesh getDummyMesh() const { return mDummyMesh; }
+
+	protected:
+		/**
+		 * @copydoc		Module::onStartUp
+		 */
+		virtual void onStartUp();
+
+	private:
+		MeshDataPtr mDummyMeshData;
+		HMesh mDummyMesh;
+	};
 }

+ 64 - 64
CamelotCore/Include/CmMultiRenderTexture.h → BansheeCore/Include/CmMultiRenderTexture.h

@@ -1,65 +1,65 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRenderTarget.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Descriptor class used for initializing a MultiRenderTexture.
-	 *			Contains descriptors for each individual color render surface and 
-	 *			their common depth/stencil surface.
-	 */
-	struct CM_EXPORT MULTI_RENDER_TEXTURE_DESC
-	{
-		Vector<RENDER_SURFACE_DESC> colorSurfaces;
-		RENDER_SURFACE_DESC depthStencilSurface;
-	};
-
-	/**
-	 * @brief	Object representing multiple render textures. You may bind this to the pipeline
-	 *			in order to render to all or some of the textures at once.
-	 */
-	class CM_EXPORT MultiRenderTexture : public RenderTarget
-	{
-	public:
-		virtual ~MultiRenderTexture();
-
-		/**
-		 * @copydoc	RenderTarget::initialize
-		 */
-		void initialize(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/**
-		 * @copydoc RenderTarget::isWindow.
-		 */
-		bool isWindow() const { return true; }
-
-		/**
-		 * @copydoc RenderTarget::requiresTextureFlipping.
-		 */
-		bool requiresTextureFlipping() const { return false; }
-
-	protected:
-		MultiRenderTexture();
-
-		/**
-		 * @copydoc RenderTarget::destroy_internal()
-		 */
-		virtual void destroy_internal();
-
-	private:
-		/**
-		 * @brief	Checks that all render surfaces and depth/stencil surface match. If they do not match
-		 *			an exception is thrown.
-		 */
-		void throwIfBuffersDontMatch() const;
-
-		// TODO - Not implemented
-		virtual void copyToMemory(const PixelData &dst, FrameBuffer buffer = FB_AUTO);
-
-	protected:
-		Vector<TextureViewPtr> mColorSurfaces;
-		TextureViewPtr mDepthStencilSurface;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRenderTarget.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Descriptor class used for initializing a MultiRenderTexture.
+	 *			Contains descriptors for each individual color render surface and 
+	 *			their common depth/stencil surface.
+	 */
+	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_DESC
+	{
+		Vector<RENDER_SURFACE_DESC> colorSurfaces;
+		RENDER_SURFACE_DESC depthStencilSurface;
+	};
+
+	/**
+	 * @brief	Object representing multiple render textures. You may bind this to the pipeline
+	 *			in order to render to all or some of the textures at once.
+	 */
+	class BS_CORE_EXPORT MultiRenderTexture : public RenderTarget
+	{
+	public:
+		virtual ~MultiRenderTexture();
+
+		/**
+		 * @copydoc	RenderTarget::initialize
+		 */
+		void initialize(const MULTI_RENDER_TEXTURE_DESC& desc);
+
+		/**
+		 * @copydoc RenderTarget::isWindow.
+		 */
+		bool isWindow() const { return true; }
+
+		/**
+		 * @copydoc RenderTarget::requiresTextureFlipping.
+		 */
+		bool requiresTextureFlipping() const { return false; }
+
+	protected:
+		MultiRenderTexture();
+
+		/**
+		 * @copydoc RenderTarget::destroy_internal()
+		 */
+		virtual void destroy_internal();
+
+	private:
+		/**
+		 * @brief	Checks that all render surfaces and depth/stencil surface match. If they do not match
+		 *			an exception is thrown.
+		 */
+		void throwIfBuffersDontMatch() const;
+
+		// TODO - Not implemented
+		virtual void copyToMemory(const PixelData &dst, FrameBuffer buffer = FB_AUTO);
+
+	protected:
+		Vector<TextureViewPtr> mColorSurfaces;
+		TextureViewPtr mDepthStencilSurface;
+	};
 }

+ 165 - 165
CamelotCore/Include/CmOSInputHandler.h → BansheeCore/Include/CmOSInputHandler.h

@@ -1,166 +1,166 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmPlatform.h"
-#include "BsEvent.h"
-#include "CmVector2I.h"
-
-namespace BansheeEngine
-{
-	/**
-		* @brief	Represents a specific way of acquiring OS input. InputManager (which provides a higher level input)
-		* 			must have at least one OSInputHandler attached. Attach events handler to the provided signals to handle input.
-		* 			
-		* @note		Unlike RawInputHandler this class receives input from the operating system, and is used for receiving
-		* 			text input, cursor position and similar.
-		*/
-	class CM_EXPORT OSInputHandler
-	{
-		/**
-		 * @brief	Contains information regarding a button state change event.
-		 */
-		struct ButtonStateChange
-		{
-			Vector2I cursorPos;
-			OSPointerButtonStates btnStates;
-			OSMouseButton button;
-			bool pressed;
-		};
-
-		/**
-		 * @brief	Contains information regarding a double click event.
-		 */
-		struct DoubleClick
-		{
-			Vector2I cursorPos;
-			OSPointerButtonStates btnStates;
-		};
-
-	public:
-		OSInputHandler();
-		virtual ~OSInputHandler();
-
-		/**
-		 * @brief	Triggers when user inputs a character. The character might be a result of pressing
-		 * 			multiple keys, so character input will not necessarily correspond with button presses.
-		 * 			Provide character code of the input character.
-		 */
-		Event<void(UINT32)> onCharInput;
-
-		/**
-		 * @brief	Triggers whenever user scrolls the mouse wheel. Returns the screen
-		 * 			position of the mouse cursor and delta amount of mouse scroll (can be negative or positive).
-		 */
-		Event<void(const Vector2I&, float)> onMouseWheelScrolled;
-
-		/**
-		 * @brief	Triggers whenever user moves the mouse cursor.
-		 */
-		Event<void(const PointerEvent&)> onCursorMoved;
-
-		/**
-		 * @brief	Triggers whenever user presses one of the mouse buttons.
-		 */
-		Event<void(const PointerEvent&)> onCursorPressed;
-
-		/**
-		 * @brief	Triggers whenever user releases one of the mouse buttons.
-		 */
-		Event<void(const PointerEvent&)> onCursorReleased;
-
-		/**
-		 * @brief	Triggers when user clicks a mouse button quickly twice in a row.
-		 */
-		Event<void(const PointerEvent&)> onDoubleClick;
-
-		/**
-		 * @brief	Triggers when user inputa a special input command, like commands user
-		 * 			for manipulating text input.
-		 */
-		Event<void(InputCommandType)> onInputCommand;
-
-		/**
-		 * @brief	Called once per frame. Capture input here if needed.
-		 * 			
-		 * @note	Internal method.
-		 */
-		virtual void _update();
-
-		/**
-		 * @brief	Called whenever the active window changes.
-		 *
-		 * @param	win	Newly active window.
-		 * 				
-		 * @note	Internal method.
-		 */
-		virtual void _inputWindowChanged(const RenderWindow& win) {}
-
-	private:
-		CM_MUTEX(mOSInputMutex);
-		Vector2I mLastCursorPos;
-		Vector2I mCursorPosition;
-		float mMouseScroll;
-		WString mInputString;
-		Queue<ButtonStateChange> mButtonStates;
-		Queue<DoubleClick> mDoubleClicks;
-		Queue<InputCommandType> mInputCommands;
-		OSPointerButtonStates mMouseMoveBtnState;
-
-		HEvent mCharInputConn;
-		HEvent mCursorMovedConn;
-		HEvent mCursorPressedConn;
-		HEvent mCursorReleasedConn;
-		HEvent mCursorDoubleClickConn;
-		HEvent mInputCommandConn;
-		HEvent mMouseWheelScrolledConn;
-
-		/**
-		 * @brief	Called from the message loop to notify user has entered a character.
-		 * 			
-		 * @see		onCharInput
-		 */
-		void charInput(UINT32 character);
-
-		/**
-		 * @brief	Called from the message loop to notify user has moved the cursor.
-		 * 			
-		 * @see		onCursorMoved
-		 */
-		void cursorMoved(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
-
-		/**
-		 * @brief	Called from the message loop to notify user has pressed a mouse button.
-		 * 			
-		 * @see		onCursorPressed
-		 */
-		void cursorPressed(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
-
-		/**
-		 * @brief	Called from the message loop to notify user has released a mouse button.
-		 * 			
-		 * @see		onCursorReleased
-		 */
-		void cursorReleased(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
-
-		/**
-		 * @brief	Called from the message loop to notify user has double-clicked a mouse button.
-		 * 
-		 * @see		onDoubleClick
-		 */
-		void cursorDoubleClick(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
-
-		/**
-		 * @brief	Called from the message loop to notify user has entered an input command.
-		 * 			
-		 * @see		onInputCommand
-		 */
-		void inputCommandEntered(InputCommandType commandType);
-
-		/**
-		 * @brief	Called from the message loop to notify user has scrolled the mouse wheel.
-		 * 			
-		 * @see		onMouseWheelScrolled
-		 */
-		void mouseWheelScrolled(float scrollPos);
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmPlatform.h"
+#include "BsEvent.h"
+#include "CmVector2I.h"
+
+namespace BansheeEngine
+{
+	/**
+		* @brief	Represents a specific way of acquiring OS input. InputManager (which provides a higher level input)
+		* 			must have at least one OSInputHandler attached. Attach events handler to the provided signals to handle input.
+		* 			
+		* @note		Unlike RawInputHandler this class receives input from the operating system, and is used for receiving
+		* 			text input, cursor position and similar.
+		*/
+	class BS_CORE_EXPORT OSInputHandler
+	{
+		/**
+		 * @brief	Contains information regarding a button state change event.
+		 */
+		struct ButtonStateChange
+		{
+			Vector2I cursorPos;
+			OSPointerButtonStates btnStates;
+			OSMouseButton button;
+			bool pressed;
+		};
+
+		/**
+		 * @brief	Contains information regarding a double click event.
+		 */
+		struct DoubleClick
+		{
+			Vector2I cursorPos;
+			OSPointerButtonStates btnStates;
+		};
+
+	public:
+		OSInputHandler();
+		virtual ~OSInputHandler();
+
+		/**
+		 * @brief	Triggers when user inputs a character. The character might be a result of pressing
+		 * 			multiple keys, so character input will not necessarily correspond with button presses.
+		 * 			Provide character code of the input character.
+		 */
+		Event<void(UINT32)> onCharInput;
+
+		/**
+		 * @brief	Triggers whenever user scrolls the mouse wheel. Returns the screen
+		 * 			position of the mouse cursor and delta amount of mouse scroll (can be negative or positive).
+		 */
+		Event<void(const Vector2I&, float)> onMouseWheelScrolled;
+
+		/**
+		 * @brief	Triggers whenever user moves the mouse cursor.
+		 */
+		Event<void(const PointerEvent&)> onCursorMoved;
+
+		/**
+		 * @brief	Triggers whenever user presses one of the mouse buttons.
+		 */
+		Event<void(const PointerEvent&)> onCursorPressed;
+
+		/**
+		 * @brief	Triggers whenever user releases one of the mouse buttons.
+		 */
+		Event<void(const PointerEvent&)> onCursorReleased;
+
+		/**
+		 * @brief	Triggers when user clicks a mouse button quickly twice in a row.
+		 */
+		Event<void(const PointerEvent&)> onDoubleClick;
+
+		/**
+		 * @brief	Triggers when user inputa a special input command, like commands user
+		 * 			for manipulating text input.
+		 */
+		Event<void(InputCommandType)> onInputCommand;
+
+		/**
+		 * @brief	Called once per frame. Capture input here if needed.
+		 * 			
+		 * @note	Internal method.
+		 */
+		virtual void _update();
+
+		/**
+		 * @brief	Called whenever the active window changes.
+		 *
+		 * @param	win	Newly active window.
+		 * 				
+		 * @note	Internal method.
+		 */
+		virtual void _inputWindowChanged(const RenderWindow& win) {}
+
+	private:
+		CM_MUTEX(mOSInputMutex);
+		Vector2I mLastCursorPos;
+		Vector2I mCursorPosition;
+		float mMouseScroll;
+		WString mInputString;
+		Queue<ButtonStateChange> mButtonStates;
+		Queue<DoubleClick> mDoubleClicks;
+		Queue<InputCommandType> mInputCommands;
+		OSPointerButtonStates mMouseMoveBtnState;
+
+		HEvent mCharInputConn;
+		HEvent mCursorMovedConn;
+		HEvent mCursorPressedConn;
+		HEvent mCursorReleasedConn;
+		HEvent mCursorDoubleClickConn;
+		HEvent mInputCommandConn;
+		HEvent mMouseWheelScrolledConn;
+
+		/**
+		 * @brief	Called from the message loop to notify user has entered a character.
+		 * 			
+		 * @see		onCharInput
+		 */
+		void charInput(UINT32 character);
+
+		/**
+		 * @brief	Called from the message loop to notify user has moved the cursor.
+		 * 			
+		 * @see		onCursorMoved
+		 */
+		void cursorMoved(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
+
+		/**
+		 * @brief	Called from the message loop to notify user has pressed a mouse button.
+		 * 			
+		 * @see		onCursorPressed
+		 */
+		void cursorPressed(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
+
+		/**
+		 * @brief	Called from the message loop to notify user has released a mouse button.
+		 * 			
+		 * @see		onCursorReleased
+		 */
+		void cursorReleased(const Vector2I& cursorPos, OSMouseButton button, OSPointerButtonStates& btnStates);
+
+		/**
+		 * @brief	Called from the message loop to notify user has double-clicked a mouse button.
+		 * 
+		 * @see		onDoubleClick
+		 */
+		void cursorDoubleClick(const Vector2I& cursorPos, OSPointerButtonStates& btnStates);
+
+		/**
+		 * @brief	Called from the message loop to notify user has entered an input command.
+		 * 			
+		 * @see		onInputCommand
+		 */
+		void inputCommandEntered(InputCommandType commandType);
+
+		/**
+		 * @brief	Called from the message loop to notify user has scrolled the mouse wheel.
+		 * 			
+		 * @see		onMouseWheelScrolled
+		 */
+		void mouseWheelScrolled(float scrollPos);
+	};
 }

+ 75 - 75
CamelotCore/Include/CmOcclusionQuery.h → BansheeCore/Include/CmOcclusionQuery.h

@@ -1,76 +1,76 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	* @brief	Represents a query that counts number of samples rendered by the GPU
-	*			while the query is active.
-	*
-	* @note		Core thread only.
-	*/
-	class CM_EXPORT OcclusionQuery
-	{
-	public:
-		OcclusionQuery(bool binary);
-		virtual ~OcclusionQuery() {}
-
-		/**
-		* @brief	Starts the query. Any draw calls after this call will have any rendered samples
-		*			counted in the query.
-		*
-		* @note		Place any commands you want to measure after this call. Call "end" when done.
-		*/
-		virtual void begin() = 0;
-
-		/**
-		* @brief	Stops the query. 
-		*
-		* @note		Be aware that queries are executed on the GPU and the results will not be immediately available.
-		*/
-		virtual void end() = 0;
-
-		/**
-		* @brief	Check if GPU has processed the query.
-		*/
-		virtual bool isReady() const = 0;
-
-		/**
-		 * @brief	Returns the number of samples that passed the depth and stencil test between
-		 *			query start and end.
-		 *
-		 * @note	If the query is binary, this will return 0 or 1. 1 meaning one or more samples were rendered,
-		 *			but will not give you the exact count.
-		 */
-		virtual UINT32 getNumSamples() = 0;
-
-		/**
-		 * @brief	Triggered when the query has completed. Argument provided
-		 *			is the number of samples counted by the query.
-		 */
-		Event<void(UINT32)> onComplete;
-
-		/**
-		 * @brief	Creates a new occlusion query. 
-		 *
-		 * @param binary	If query is binary it will not give you an exact count of samples rendered, but will instead
-		 *					just return 0 (no samples were rendered) or 1 (one or more samples were rendered). Binary
-		 *					queries can return sooner as they potentially do not need to wait until all of the geometry is rendered.
-		 */
-		static OcclusionQueryPtr create(bool binary);
-
-	protected:
-		friend class QueryManager;
-
-		/**
-		* @brief	Returns true if the has still not been completed by the GPU.
-		*/
-		bool isActive() const { return mActive; }
-		void setActive(bool active) { mActive = active; }
-
-	protected:
-		bool mActive;
-		bool mBinary;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	* @brief	Represents a query that counts number of samples rendered by the GPU
+	*			while the query is active.
+	*
+	* @note		Core thread only.
+	*/
+	class BS_CORE_EXPORT OcclusionQuery
+	{
+	public:
+		OcclusionQuery(bool binary);
+		virtual ~OcclusionQuery() {}
+
+		/**
+		* @brief	Starts the query. Any draw calls after this call will have any rendered samples
+		*			counted in the query.
+		*
+		* @note		Place any commands you want to measure after this call. Call "end" when done.
+		*/
+		virtual void begin() = 0;
+
+		/**
+		* @brief	Stops the query. 
+		*
+		* @note		Be aware that queries are executed on the GPU and the results will not be immediately available.
+		*/
+		virtual void end() = 0;
+
+		/**
+		* @brief	Check if GPU has processed the query.
+		*/
+		virtual bool isReady() const = 0;
+
+		/**
+		 * @brief	Returns the number of samples that passed the depth and stencil test between
+		 *			query start and end.
+		 *
+		 * @note	If the query is binary, this will return 0 or 1. 1 meaning one or more samples were rendered,
+		 *			but will not give you the exact count.
+		 */
+		virtual UINT32 getNumSamples() = 0;
+
+		/**
+		 * @brief	Triggered when the query has completed. Argument provided
+		 *			is the number of samples counted by the query.
+		 */
+		Event<void(UINT32)> onComplete;
+
+		/**
+		 * @brief	Creates a new occlusion query. 
+		 *
+		 * @param binary	If query is binary it will not give you an exact count of samples rendered, but will instead
+		 *					just return 0 (no samples were rendered) or 1 (one or more samples were rendered). Binary
+		 *					queries can return sooner as they potentially do not need to wait until all of the geometry is rendered.
+		 */
+		static OcclusionQueryPtr create(bool binary);
+
+	protected:
+		friend class QueryManager;
+
+		/**
+		* @brief	Returns true if the has still not been completed by the GPU.
+		*/
+		bool isActive() const { return mActive; }
+		void setActive(bool active) { mActive = active; }
+
+	protected:
+		bool mActive;
+		bool mBinary;
+	};
 }

+ 96 - 96
CamelotCore/Include/CmPass.h → BansheeCore/Include/CmPass.h

@@ -1,97 +1,97 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmCoreThreadAccessor.h"
-#include "CmColor.h"
-#include "CmIReflectable.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Class defining a single pass of a technique (of a material), i.e.
-	 * 			a single rendering call. 
-	 * 			
-	 *			Pass may contain multiple GPU programs (vertex, fragment, geometry, etc.), and
-	 *			a set of pipeline states (blend, rasterizer, etc.).
-	 */
-	class CM_EXPORT Pass : public IReflectable
-    {
-    public:
-		Pass();
-        Pass(const Pass& oth);
-        Pass& operator=(const Pass& oth);
-        virtual ~Pass();
-
-        bool hasVertexProgram() const { return mVertexProgram != nullptr; }
-        bool hasFragmentProgram() const { return mFragmentProgram != nullptr; }
-        bool hasGeometryProgram() const { return mGeometryProgram != nullptr; }
-		bool hasHullProgram() const { return mHullProgram != nullptr; }
-		bool hasDomainProgram() const { return mDomainProgram != nullptr; }
-		bool hasComputeProgram() const { return mComputeProgram != nullptr; }
-
-		/**
-		 * @brief	Returns true if this pass has some element of transparency.
-		 */
-		bool isTransparent() const;
-
-		void setBlendState(HBlendState& blendState);
-		HBlendState getBlendState() const;
-
-		void setRasterizerState(HRasterizerState& rasterizerState);
-		HRasterizerState getRasterizerState() const;
-
-		void setDepthStencilState(HDepthStencilState& depthStencilState);
-		HDepthStencilState getDepthStencilState() const;
-
-		/**
-		 * @brief	Sets the stencil reference value that is used when performing operations using the
-		 * 			stencil buffer.
-		 */
-		void setStencilRefValue(UINT32 refValue);
-
-		/**
-		 * @brief	Gets the stencil reference value that is used when performing operations using the
-		 * 			stencil buffer.
-		 */
-		UINT32 getStencilRefValue() const;
-
-		void setVertexProgram(HGpuProgram gpuProgram) { mVertexProgram = gpuProgram; }
-		const HGpuProgram& getVertexProgram() const { return mVertexProgram; }
-
-		void setFragmentProgram(HGpuProgram gpuProgram) { mFragmentProgram = gpuProgram; }
-		const HGpuProgram& getFragmentProgram() const { return mFragmentProgram; }
-
-		void setGeometryProgram(HGpuProgram gpuProgram) { mGeometryProgram = gpuProgram; }
-		const HGpuProgram& getGeometryProgram() const { return mGeometryProgram; }
-
-		void setHullProgram(HGpuProgram gpuProgram) { mHullProgram = gpuProgram; }
-		const HGpuProgram& getHullProgram(void) const { return mHullProgram; }
-
-		void setDomainProgram(HGpuProgram gpuProgram) { mDomainProgram = gpuProgram;}
-		const HGpuProgram& getDomainProgram(void) const { return mDomainProgram; }
-
-		void setComputeProgram(HGpuProgram gpuProgram) { mComputeProgram = gpuProgram; }
-		const HGpuProgram& getComputeProgram(void) const { return mComputeProgram; }
-
-	protected:
-		HBlendState mBlendState;
-		HRasterizerState mRasterizerState;
-		HDepthStencilState mDepthStencilState;
-		UINT32 mStencilRefValue;
-
-		HGpuProgram mVertexProgram;
-		HGpuProgram mFragmentProgram;
-		HGpuProgram mGeometryProgram;
-		HGpuProgram mHullProgram;
-		HGpuProgram mDomainProgram;
-		HGpuProgram mComputeProgram;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class PassRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-    };
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmCoreThreadAccessor.h"
+#include "CmColor.h"
+#include "CmIReflectable.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Class defining a single pass of a technique (of a material), i.e.
+	 * 			a single rendering call. 
+	 * 			
+	 *			Pass may contain multiple GPU programs (vertex, fragment, geometry, etc.), and
+	 *			a set of pipeline states (blend, rasterizer, etc.).
+	 */
+	class BS_CORE_EXPORT Pass : public IReflectable
+    {
+    public:
+		Pass();
+        Pass(const Pass& oth);
+        Pass& operator=(const Pass& oth);
+        virtual ~Pass();
+
+        bool hasVertexProgram() const { return mVertexProgram != nullptr; }
+        bool hasFragmentProgram() const { return mFragmentProgram != nullptr; }
+        bool hasGeometryProgram() const { return mGeometryProgram != nullptr; }
+		bool hasHullProgram() const { return mHullProgram != nullptr; }
+		bool hasDomainProgram() const { return mDomainProgram != nullptr; }
+		bool hasComputeProgram() const { return mComputeProgram != nullptr; }
+
+		/**
+		 * @brief	Returns true if this pass has some element of transparency.
+		 */
+		bool isTransparent() const;
+
+		void setBlendState(HBlendState& blendState);
+		HBlendState getBlendState() const;
+
+		void setRasterizerState(HRasterizerState& rasterizerState);
+		HRasterizerState getRasterizerState() const;
+
+		void setDepthStencilState(HDepthStencilState& depthStencilState);
+		HDepthStencilState getDepthStencilState() const;
+
+		/**
+		 * @brief	Sets the stencil reference value that is used when performing operations using the
+		 * 			stencil buffer.
+		 */
+		void setStencilRefValue(UINT32 refValue);
+
+		/**
+		 * @brief	Gets the stencil reference value that is used when performing operations using the
+		 * 			stencil buffer.
+		 */
+		UINT32 getStencilRefValue() const;
+
+		void setVertexProgram(HGpuProgram gpuProgram) { mVertexProgram = gpuProgram; }
+		const HGpuProgram& getVertexProgram() const { return mVertexProgram; }
+
+		void setFragmentProgram(HGpuProgram gpuProgram) { mFragmentProgram = gpuProgram; }
+		const HGpuProgram& getFragmentProgram() const { return mFragmentProgram; }
+
+		void setGeometryProgram(HGpuProgram gpuProgram) { mGeometryProgram = gpuProgram; }
+		const HGpuProgram& getGeometryProgram() const { return mGeometryProgram; }
+
+		void setHullProgram(HGpuProgram gpuProgram) { mHullProgram = gpuProgram; }
+		const HGpuProgram& getHullProgram(void) const { return mHullProgram; }
+
+		void setDomainProgram(HGpuProgram gpuProgram) { mDomainProgram = gpuProgram;}
+		const HGpuProgram& getDomainProgram(void) const { return mDomainProgram; }
+
+		void setComputeProgram(HGpuProgram gpuProgram) { mComputeProgram = gpuProgram; }
+		const HGpuProgram& getComputeProgram(void) const { return mComputeProgram; }
+
+	protected:
+		HBlendState mBlendState;
+		HRasterizerState mRasterizerState;
+		HDepthStencilState mDepthStencilState;
+		UINT32 mStencilRefValue;
+
+		HGpuProgram mVertexProgram;
+		HGpuProgram mFragmentProgram;
+		HGpuProgram mGeometryProgram;
+		HGpuProgram mHullProgram;
+		HGpuProgram mDomainProgram;
+		HGpuProgram mComputeProgram;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class PassRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+    };
 }

+ 68 - 68
CamelotCore/Include/CmPassRTTI.h → BansheeCore/Include/CmPassRTTI.h

@@ -1,69 +1,69 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmPass.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT PassRTTI : public RTTIType<Pass, IReflectable, PassRTTI>
-	{
-	private:
-		HBlendState& getBlendState(Pass* obj) { return obj->mBlendState; }
-		void setBlendState(Pass* obj, HBlendState& val) { obj->mBlendState = val; } 
-
-		HRasterizerState& getRasterizerState(Pass* obj) { return obj->mRasterizerState; }
-		void setRasterizerState(Pass* obj, HRasterizerState& val) { obj->mRasterizerState = val; } 
-
-		HDepthStencilState& getDepthStencilState(Pass* obj) { return obj->mDepthStencilState; }
-		void setDepthStencilState(Pass* obj, HDepthStencilState& val) { obj->mDepthStencilState = val; } 
-
-		HGpuProgram& getVertexProgram(Pass* obj) { return obj->mVertexProgram; }
-		void setVertexProgram(Pass* obj, HGpuProgram& val) { obj->mVertexProgram = val; } 
-
-		HGpuProgram& getFragmentProgram(Pass* obj) { return obj->mFragmentProgram; }
-		void setFragmentProgram(Pass* obj, HGpuProgram& val) { obj->mFragmentProgram = val; } 
-
-		HGpuProgram& getGeometryProgram(Pass* obj) { return obj->mGeometryProgram; }
-		void setGeometryProgram(Pass* obj, HGpuProgram& val) { obj->mGeometryProgram = val; } 
-
-		HGpuProgram& getHullProgram(Pass* obj) { return obj->mHullProgram; }
-		void setHullProgram(Pass* obj, HGpuProgram& val) { obj->mHullProgram = val; } 
-
-		HGpuProgram& getDomainProgram(Pass* obj) { return obj->mDomainProgram; }
-		void setDomainProgram(Pass* obj, HGpuProgram& val) { obj->mDomainProgram = val; } 
-
-		HGpuProgram& getComputeProgram(Pass* obj) { return obj->mComputeProgram; }
-		void setComputeProgram(Pass* obj, HGpuProgram& val) { obj->mComputeProgram = val; } 
-	public:
-		PassRTTI()
-		{
-			addReflectableField("mBlendState", 0, &PassRTTI::getBlendState, &PassRTTI::setBlendState);
-			addReflectableField("mRasterizerState", 1, &PassRTTI::getRasterizerState, &PassRTTI::setRasterizerState);
-			addReflectableField("mDepthStencilState", 2, &PassRTTI::getDepthStencilState, &PassRTTI::setDepthStencilState);
-
-			addReflectableField("mVertexProgram", 3, &PassRTTI::getVertexProgram, &PassRTTI::setVertexProgram);
-			addReflectableField("mFragmentProgram", 4, &PassRTTI::getFragmentProgram, &PassRTTI::setFragmentProgram);
-			addReflectableField("mGeometryProgram", 5, &PassRTTI::getGeometryProgram, &PassRTTI::setGeometryProgram);
-			addReflectableField("mHullProgram", 6, &PassRTTI::getHullProgram, &PassRTTI::setHullProgram);
-			addReflectableField("mDomainProgram", 7, &PassRTTI::getDomainProgram, &PassRTTI::setDomainProgram);
-			addReflectableField("mComputeProgram", 8, &PassRTTI::getComputeProgram, &PassRTTI::setComputeProgram);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "Pass";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_Pass;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return cm_shared_ptr<Pass, PoolAlloc>();
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmPass.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT PassRTTI : public RTTIType<Pass, IReflectable, PassRTTI>
+	{
+	private:
+		HBlendState& getBlendState(Pass* obj) { return obj->mBlendState; }
+		void setBlendState(Pass* obj, HBlendState& val) { obj->mBlendState = val; } 
+
+		HRasterizerState& getRasterizerState(Pass* obj) { return obj->mRasterizerState; }
+		void setRasterizerState(Pass* obj, HRasterizerState& val) { obj->mRasterizerState = val; } 
+
+		HDepthStencilState& getDepthStencilState(Pass* obj) { return obj->mDepthStencilState; }
+		void setDepthStencilState(Pass* obj, HDepthStencilState& val) { obj->mDepthStencilState = val; } 
+
+		HGpuProgram& getVertexProgram(Pass* obj) { return obj->mVertexProgram; }
+		void setVertexProgram(Pass* obj, HGpuProgram& val) { obj->mVertexProgram = val; } 
+
+		HGpuProgram& getFragmentProgram(Pass* obj) { return obj->mFragmentProgram; }
+		void setFragmentProgram(Pass* obj, HGpuProgram& val) { obj->mFragmentProgram = val; } 
+
+		HGpuProgram& getGeometryProgram(Pass* obj) { return obj->mGeometryProgram; }
+		void setGeometryProgram(Pass* obj, HGpuProgram& val) { obj->mGeometryProgram = val; } 
+
+		HGpuProgram& getHullProgram(Pass* obj) { return obj->mHullProgram; }
+		void setHullProgram(Pass* obj, HGpuProgram& val) { obj->mHullProgram = val; } 
+
+		HGpuProgram& getDomainProgram(Pass* obj) { return obj->mDomainProgram; }
+		void setDomainProgram(Pass* obj, HGpuProgram& val) { obj->mDomainProgram = val; } 
+
+		HGpuProgram& getComputeProgram(Pass* obj) { return obj->mComputeProgram; }
+		void setComputeProgram(Pass* obj, HGpuProgram& val) { obj->mComputeProgram = val; } 
+	public:
+		PassRTTI()
+		{
+			addReflectableField("mBlendState", 0, &PassRTTI::getBlendState, &PassRTTI::setBlendState);
+			addReflectableField("mRasterizerState", 1, &PassRTTI::getRasterizerState, &PassRTTI::setRasterizerState);
+			addReflectableField("mDepthStencilState", 2, &PassRTTI::getDepthStencilState, &PassRTTI::setDepthStencilState);
+
+			addReflectableField("mVertexProgram", 3, &PassRTTI::getVertexProgram, &PassRTTI::setVertexProgram);
+			addReflectableField("mFragmentProgram", 4, &PassRTTI::getFragmentProgram, &PassRTTI::setFragmentProgram);
+			addReflectableField("mGeometryProgram", 5, &PassRTTI::getGeometryProgram, &PassRTTI::setGeometryProgram);
+			addReflectableField("mHullProgram", 6, &PassRTTI::getHullProgram, &PassRTTI::setHullProgram);
+			addReflectableField("mDomainProgram", 7, &PassRTTI::getDomainProgram, &PassRTTI::setDomainProgram);
+			addReflectableField("mComputeProgram", 8, &PassRTTI::getComputeProgram, &PassRTTI::setComputeProgram);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "Pass";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_Pass;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return cm_shared_ptr<Pass, PoolAlloc>();
+		}
+	};
 }

+ 92 - 92
CamelotCore/Include/CmPixelBuffer.h → BansheeCore/Include/CmPixelBuffer.h

@@ -1,93 +1,93 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmHardwareBuffer.h"
-#include "CmPixelUtil.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Represents a hardware buffer that stores a single pixel surface.
-	 *			This may be a 1D, 2D or 3D surface, but unlike a texture it consists
-	 *			only of a single surface (no mip maps, cube map faces or similar).
-	 *
-	 * @note	Core thread only
-	 */
-    class CM_EXPORT PixelBuffer : public HardwareBuffer
-    {
-    public:
-        PixelBuffer(UINT32 mWidth, UINT32 mHeight, UINT32 mDepth, PixelFormat mFormat, 
-			GpuBufferUsage usage, bool useSystemMemory);
-        ~PixelBuffer();
-
-		// Make the other lock overloads visible.
-        using HardwareBuffer::lock;	
-
-		/**
-		 * @brief	Locks a certain region of the pixel buffer for reading and returns a pointer
-		 *			to the locked region.
-		 *
-		 * @param	lockBox		Region of the surface to lock.
-		 * @param	options		Lock options that hint the hardware on what you intend to do with the locked data.
-		 *
-		 * @note	Returned object is only valid while the lock is active.
-		 */
-		virtual const PixelData& lock(const PixelVolume& lockBox, GpuLockOptions options);
-		
-		/**
-		 * @copydoc	HardwareBuffer::lock
-		 */
-        virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
-		
-		/**
-		 * @copydoc	HardwareBuffer::readData
-		 */
-		virtual void readData(UINT32 offset, UINT32 length, void* pDest);
-
-		/**
-		 * @copydoc	HardwareBuffer::writeData
-		 */
-		virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
-
-		/**
-		 * @brief	Returns width of the surface in pixels.
-		 */
-        UINT32 getWidth() const { return mWidth; }
-
-		/**
-		 * @brief	Returns height of the surface in pixels.
-		 */
-        UINT32 getHeight() const { return mHeight; }
-
-		/**
-		 * @brief	Returns depth of the surface in pixels.
-		 */
-        UINT32 getDepth() const { return mDepth; }
-
-		/**
-		 * @brief	Returns format of the pixels in the surface.
-		 */
-        PixelFormat getFormat() const { return mFormat; }
-
-	protected:
-		friend class RenderTexture;
-
-		/**
-		 * @brief	Internal implementation of the "lock" method.
-		 */
-		virtual PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options) = 0;
-
-		/**
-		 * @copydoc	HardwareBuffer::lockImpl
-		 */
-		virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
-
-	protected:
-		UINT32 mWidth, mHeight, mDepth;
-		UINT32 mRowPitch, mSlicePitch;
-		PixelFormat mFormat;
-
-		PixelData mCurrentLock;
-		PixelVolume mLockedBox;
-    };
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmHardwareBuffer.h"
+#include "CmPixelUtil.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Represents a hardware buffer that stores a single pixel surface.
+	 *			This may be a 1D, 2D or 3D surface, but unlike a texture it consists
+	 *			only of a single surface (no mip maps, cube map faces or similar).
+	 *
+	 * @note	Core thread only
+	 */
+    class BS_CORE_EXPORT PixelBuffer : public HardwareBuffer
+    {
+    public:
+        PixelBuffer(UINT32 mWidth, UINT32 mHeight, UINT32 mDepth, PixelFormat mFormat, 
+			GpuBufferUsage usage, bool useSystemMemory);
+        ~PixelBuffer();
+
+		// Make the other lock overloads visible.
+        using HardwareBuffer::lock;	
+
+		/**
+		 * @brief	Locks a certain region of the pixel buffer for reading and returns a pointer
+		 *			to the locked region.
+		 *
+		 * @param	lockBox		Region of the surface to lock.
+		 * @param	options		Lock options that hint the hardware on what you intend to do with the locked data.
+		 *
+		 * @note	Returned object is only valid while the lock is active.
+		 */
+		virtual const PixelData& lock(const PixelVolume& lockBox, GpuLockOptions options);
+		
+		/**
+		 * @copydoc	HardwareBuffer::lock
+		 */
+        virtual void* lock(UINT32 offset, UINT32 length, GpuLockOptions options);
+		
+		/**
+		 * @copydoc	HardwareBuffer::readData
+		 */
+		virtual void readData(UINT32 offset, UINT32 length, void* pDest);
+
+		/**
+		 * @copydoc	HardwareBuffer::writeData
+		 */
+		virtual void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
+
+		/**
+		 * @brief	Returns width of the surface in pixels.
+		 */
+        UINT32 getWidth() const { return mWidth; }
+
+		/**
+		 * @brief	Returns height of the surface in pixels.
+		 */
+        UINT32 getHeight() const { return mHeight; }
+
+		/**
+		 * @brief	Returns depth of the surface in pixels.
+		 */
+        UINT32 getDepth() const { return mDepth; }
+
+		/**
+		 * @brief	Returns format of the pixels in the surface.
+		 */
+        PixelFormat getFormat() const { return mFormat; }
+
+	protected:
+		friend class RenderTexture;
+
+		/**
+		 * @brief	Internal implementation of the "lock" method.
+		 */
+		virtual PixelData lockImpl(PixelVolume lockBox, GpuLockOptions options) = 0;
+
+		/**
+		 * @copydoc	HardwareBuffer::lockImpl
+		 */
+		virtual void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
+
+	protected:
+		UINT32 mWidth, mHeight, mDepth;
+		UINT32 mRowPitch, mSlicePitch;
+		PixelFormat mFormat;
+
+		PixelData mCurrentLock;
+		PixelVolume mLockedBox;
+    };
 }

+ 324 - 324
CamelotCore/Include/CmPixelData.h → BansheeCore/Include/CmPixelData.h

@@ -1,325 +1,325 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmPixelVolume.h"
-#include "CmGpuResourceData.h"
-#include "CmIReflectable.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	The pixel format used for images, textures, and render surfaces
-	 */
-    enum PixelFormat
-    {
-        // Unknown pixel format.
-        PF_UNKNOWN = 0,
-        // 8-bit pixel format, all bits red.
-        PF_R8 = 1,
-		// 2 byte pixel format, 1 byte red, 1 byte green.
-		PF_R8G8 = 2,
-        // 24-bit pixel format, 8 bits for red, green and blue.
-        PF_R8G8B8 = 3,
-        // 24-bit pixel format, 8 bits for blue, green and red.
-        PF_B8G8R8 = 4,
-        // 32-bit pixel format, 8 bits for alpha, red, green and blue.
-        PF_A8R8G8B8 = 5,
-        // 32-bit pixel format, 8 bits for blue, green, red and alpha.
-        PF_A8B8G8R8 = 6,
-        // 32-bit pixel format, 8 bits for blue, green, red and alpha.
-        PF_B8G8R8A8 = 7,
-		// 32-bit pixel format, 8 bits for red, green, blue and alpha.
-		PF_R8G8B8A8 = 8,
-        // 32-bit pixel format, 8 bits for red, 8 bits for green, 8 bits for blue.
-        // Like PF_A8R8G8B8, but alpha will get discarded
-        PF_X8R8G8B8 = 9,
-        // 32-bit pixel format, 8 bits for blue, 8 bits for green, 8 bits for red.
-        // Like PF_A8B8G8R8, but alpha will get discarded.
-        PF_X8B8G8R8 = 10,
-		// 32-bit pixel format, 8 bits for red, 8 bits for green, 8 bits for blue.
-		// Like PF_R8G8B8A8, but alpha will get discarded.
-		PF_R8G8B8X8 = 11,
-		// 32-bit pixel format, 8 bits for blue, 8 bits for green, 8 bits for red.
-		// Like PF_B8G8R8A8, but alpha will get discarded.
-		PF_B8G8R8X8 = 12,
-		// 24-bit pixel format, 8 bits for red, green and blue.
-		PF_BYTE_RGB = PF_R8G8B8,
-		// 24-bit pixel format, 8 bits for blue, green and red.
-		PF_BYTE_BGR = PF_B8G8R8,
-		// 32-bit pixel format, 8 bits for blue, green, red and alpha.
-		PF_BYTE_BGRA = PF_B8G8R8A8,
-		// 32-bit pixel format, 8 bits for red, green, blue and alpha.
-		PF_BYTE_RGBA = PF_R8G8B8A8,      
-        // DXT1/BC1 format containing opaque RGB or 1-bit alpha RGB. 4 bits per pixel.
-        PF_DXT1 = 13,
-        // DXT2/BC2 format with premultiplied alpha. 6 bits per pixel.
-        PF_DXT2 = 14,
-        // DXT3/BC2 format with explicit alpha. 6 bits per pixel.
-        PF_DXT3 = 15,
-        // DXT4/BC3 format with premultiplied alpha. 6 bits per pixel. Better alpha gradients than DXT2.
-        PF_DXT4 = 16,
-        // DXT5/BC3 format with explicit alpha. 6 bits per pixel. Better alpha gradients than DXT3.
-        PF_DXT5 = 17,
-		// 16-bit pixel format, 16 bits (float) for red
-        PF_FLOAT16_R = 18,
-		// 32-bit, 2-channel s10e5 floating point pixel format, 16-bit red, 16-bit green
-		PF_FLOAT16_RG = 19,
-        // 48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue
-        PF_FLOAT16_RGB = 20,
-        // 64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue, 16 bits (float) for alpha
-        PF_FLOAT16_RGBA = 21,
-		// 32-bit pixel format, 32 bits (float) for red
-        PF_FLOAT32_R = 22,
-		// 64-bit, 2-channel floating point pixel format, 32-bit red, 32-bit green
-		PF_FLOAT32_RG = 23,
-        // 96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue
-        PF_FLOAT32_RGB = 24,
-        // 128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 32 bits (float) for alpha
-        PF_FLOAT32_RGBA = 25,
-		// Depth stencil format, 32bit depth, 8bit stencil + 24 unused
-		PF_D32_S8X24 = 26,
-		// Depth stencil fomrat, 24bit depth + 8bit stencil
-		PF_D24S8 = 27,
-		// Depth format, 32bits
-		PF_D32 = 28,
-		// Depth format, 16bits
-		PF_D16 = 29,
-		// Number of pixel formats currently defined
-        PF_COUNT = 30
-    };
-	typedef Vector<PixelFormat> PixelFormatList;
-
-	/**
-	 * @brief	Flags defining some properties of pixel formats.
-	 */
-    enum PixelFormatFlags {
-        // This format has an alpha channel
-        PFF_HASALPHA        = 0x00000001,      
-        // This format is compressed. This invalidates the values in elemBytes,
-        // elemBits and the bit counts as these might not be fixed in a compressed format.
-        PFF_COMPRESSED    = 0x00000002,
-        // This is a floating point format
-        PFF_FLOAT           = 0x00000004,         
-        // This is a depth format (for depth textures)
-        PFF_DEPTH           = 0x00000008,
-        // Format is in native endian. Generally true for the 16, 24 and 32 bits
-        // formats which can be represented as machine integers.
-        PFF_NATIVEENDIAN    = 0x00000010
-    };
-    
-	/**
-	 * @brief	Types of pixel components
-	 */
-    enum PixelComponentType
-    {
-        PCT_BYTE = 0,    /**< Byte per component */
-        PCT_SHORT = 1,   /**< Short per component */
-        PCT_FLOAT16 = 2, /**< 16 bit float per component */
-        PCT_FLOAT32 = 3, /**< 32 bit float per component */
-        PCT_COUNT = 4    /**< Number of pixel types */
-    };
-    
-	/**
-	 * @brief	A buffer describing a volume (3D), image (2D) or line (1D) of pixels in memory.
-	 *			Pixels are stored as a succession of "depth" slices, each containing "height" rows of
-	 *			"width" pixels.
-	 *
-	 *			As any GpuResourceData this is used primarily for reading and writing from/to a GPU resource,
-	 *			and is normally constructed by the resource itself. However you may still construct it manually
-	 *			and use it for other purposes if needed.
-	 *
-	 * @note	You must call allocateInternalBuffer or set the buffer in some other way before reading/writing
-	 *			from this object.
-	 *
-	 * @see		GpuResourceData
-	 */
-    class CM_EXPORT PixelData : public GpuResourceData
-	{
-    public:
-    	PixelData() {}
-		~PixelData() {}
-
-		/**
-		 * @brief	Constructs a new object with an internal buffer capable of holding "extents" volume of pixels, 
-		 *			where each pixel is of the specified pixel format. Extent offsets are also stored, but are not used
-		 *			internally.
-		 */
-		PixelData(const PixelVolume &extents, PixelFormat pixelFormat)
-			:mExtents(extents), mFormat(pixelFormat)
-		{
-			setConsecutive();
-		}
-
-		/**
-		 * @brief	Constructs a new object with an internal buffer capable of holding volume of pixels described by
-		 *			provided width, height and depth, where each pixel is of the specified pixel format.
-		 */
-    	PixelData(UINT32 width, UINT32 height, UINT32 depth, PixelFormat pixelFormat)
-			: mExtents(0, 0, 0, width, height, depth), mFormat(pixelFormat)
-    	{
-    		setConsecutive();
-    	}
-
-		PixelData(const PixelData& copy);
-		PixelData& operator=(const PixelData& rhs);
-
-		/**
-		 * @brief	Returns the number of pixels that offsets one row from another. This can be
-		 *			"width", but doesn't have to be as some buffers require padding.
-		 */
-		UINT32 getRowPitch() const { return mRowPitch; }
-
-		/**
-		 * @brief	Returns the number of pixels that offsets one depth slice from another. This can be
-		 *			"width * height", but doesn't have to be as some buffers require padding.
-		 */
-		UINT32 getSlicePitch() const { return mSlicePitch; }
-
-		/**
-		 * @brief	Sets the pitch (in pixels) that determines offset between rows of the pixel buffer.
-		 *			Call this before allocating the buffer.
-		 */
-		void setRowPitch(UINT32 rowPitch) { mRowPitch = rowPitch; }
-
-		/**
-		 * @brief	Sets the pitch (in pixels) that determines offset between depth slices of the pixel buffer.
-		 *			Call this before allocating the buffer.
-		 */
-        void setSlicePitch(UINT32 slicePitch) { mSlicePitch = slicePitch; }
-
-		/**
-		 * @brief	Returns the number of extra pixels in a row (non-zero only if rows are not
-		 *			consecutive (row pitch is larger than width)).
-		 */
-        UINT32 getRowSkip() const { return mRowPitch - getWidth(); }
-
-		/**
-		 * @brief	Returns the number of extra pixels in a depth slice (non-zero only if
-		 *			slices aren't consecutive (slice pitch is larger than width*height).
-		 */
-        UINT32 getSliceSkip() const { return mSlicePitch - (getHeight() * mRowPitch); }
-
-		/**
-		 * @brief	Returns the pixel format used by the internal buffer for storing the pixels.
-		 */
-		PixelFormat getFormat() const { return mFormat; }
-
-		/**
-		 * @brief	Returns width of the buffer in pixels.
-		 */
-		UINT32 getWidth() const { return mExtents.getWidth(); }
-
-		/**
-		 * @brief	Returns height of the buffer in pixels.
-		 */
-		UINT32 getHeight() const { return mExtents.getHeight(); }
-
-		/**
-		 * @brief	Returns depth of the buffer in pixels.
-		 */
-		UINT32 getDepth() const { return mExtents.getDepth(); }
-
-		/**
-		 * @brief	Returns left-most start of the pixel volume. This value is not used internally in any way.
-		 *			It is just passed through from the constructor.
-		 */
-		UINT32 getLeft() const { return mExtents.left; }
-
-		/**
-		 * @brief	Returns right-most end of the pixel volume. This value is not used internally in any way.
-		 *			It is just passed through from the constructor.
-		 */
-		UINT32 getRight() const { return mExtents.right; }
-
-		/**
-		 * @brief	Returns top-most start of the pixel volume. This value is not used internally in any way.
-		 *			It is just passed through from the constructor.
-		 */
-		UINT32 getTop() const { return mExtents.top; }
-
-		/**
-		 * @brief	Returns bottom-most end of the pixel volume. This value is not used internally in any way.
-		 *			It is just passed through from the constructor.
-		 */
-		UINT32 getBottom() const { return mExtents.bottom; }
-
-		/**
-		 * @brief	Returns front-most start of the pixel volume. This value is not used internally in any way.
-		 *			It is just passed through from the constructor.
-		 */
-		UINT32 getFront() const { return mExtents.front; }
-
-		/**
-		 * @brief	Returns back-most end of the pixel volume. This value is not used internally in any way.
-		 *			It is just passed through from the constructor.
-		 */
-		UINT32 getBack() const { return mExtents.back; }
-
-		/**
-		 * @brief	Returns extents of the pixel volume this object is capable of holding.
-		 */
-		PixelVolume getExtents() const { return mExtents; }
-
-		/**
-		 * @brief	Return whether this buffer is laid out consecutive in memory 
-		 *			(i.e. the pitches are equal to the dimensions).
-		 */
-        bool isConsecutive() const 
-		{ 
-			return mRowPitch == getWidth() && mSlicePitch == getWidth()*getHeight(); 
-		}
-
-		/**
-		 * @brief	Return the size (in bytes) this image would take if it was
-		 *			laid out consecutive in memory.
-		 */
-      	UINT32 getConsecutiveSize() const;
-
-		/**
-		 * @brief	Returns pixel data containing a sub-volume of this object. Returned
-		 *			data will not have its own buffer, but will instead point to this one.
-		 *			It is up to the caller to ensure this object outlives any sub-volume objects.
-		 */
-      	PixelData getSubVolume(const PixelVolume &def) const;
-        
-		/**
-		 * @brief	Returns pixel color at the specified coordinates.
-		 */
-        Color getColorAt(UINT32 x, UINT32 y, UINT32 z = 0);
-
-		/**
-		 * @brief	Sets the pixel color at the specified coordinates.
-		 */
-        void setColorAt(Color const &cv, UINT32 x, UINT32 y, UINT32 z = 0);
-
-	private:
-		/**
-		 * @brief	Set the rowPitch and slicePitch so that the buffer is laid out consecutive
-		 *			in memory. Does not actually modify the buffer itself.
-		 */
-		void setConsecutive()
-		{
-			mRowPitch = getWidth();
-			mSlicePitch = getWidth()*getHeight();
-		}
-
-		/**
-		 * @brief	Returns the needed size of the internal buffer, in bytes.
-		 */
-		UINT32 getInternalBufferSize();
-
-	private:
-		PixelVolume mExtents;
-        PixelFormat mFormat;
-        UINT32 mRowPitch;
-        UINT32 mSlicePitch;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class PixelDataRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-    };
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmPixelVolume.h"
+#include "CmGpuResourceData.h"
+#include "CmIReflectable.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	The pixel format used for images, textures, and render surfaces
+	 */
+    enum PixelFormat
+    {
+        // Unknown pixel format.
+        PF_UNKNOWN = 0,
+        // 8-bit pixel format, all bits red.
+        PF_R8 = 1,
+		// 2 byte pixel format, 1 byte red, 1 byte green.
+		PF_R8G8 = 2,
+        // 24-bit pixel format, 8 bits for red, green and blue.
+        PF_R8G8B8 = 3,
+        // 24-bit pixel format, 8 bits for blue, green and red.
+        PF_B8G8R8 = 4,
+        // 32-bit pixel format, 8 bits for alpha, red, green and blue.
+        PF_A8R8G8B8 = 5,
+        // 32-bit pixel format, 8 bits for blue, green, red and alpha.
+        PF_A8B8G8R8 = 6,
+        // 32-bit pixel format, 8 bits for blue, green, red and alpha.
+        PF_B8G8R8A8 = 7,
+		// 32-bit pixel format, 8 bits for red, green, blue and alpha.
+		PF_R8G8B8A8 = 8,
+        // 32-bit pixel format, 8 bits for red, 8 bits for green, 8 bits for blue.
+        // Like PF_A8R8G8B8, but alpha will get discarded
+        PF_X8R8G8B8 = 9,
+        // 32-bit pixel format, 8 bits for blue, 8 bits for green, 8 bits for red.
+        // Like PF_A8B8G8R8, but alpha will get discarded.
+        PF_X8B8G8R8 = 10,
+		// 32-bit pixel format, 8 bits for red, 8 bits for green, 8 bits for blue.
+		// Like PF_R8G8B8A8, but alpha will get discarded.
+		PF_R8G8B8X8 = 11,
+		// 32-bit pixel format, 8 bits for blue, 8 bits for green, 8 bits for red.
+		// Like PF_B8G8R8A8, but alpha will get discarded.
+		PF_B8G8R8X8 = 12,
+		// 24-bit pixel format, 8 bits for red, green and blue.
+		PF_BYTE_RGB = PF_R8G8B8,
+		// 24-bit pixel format, 8 bits for blue, green and red.
+		PF_BYTE_BGR = PF_B8G8R8,
+		// 32-bit pixel format, 8 bits for blue, green, red and alpha.
+		PF_BYTE_BGRA = PF_B8G8R8A8,
+		// 32-bit pixel format, 8 bits for red, green, blue and alpha.
+		PF_BYTE_RGBA = PF_R8G8B8A8,      
+        // DXT1/BC1 format containing opaque RGB or 1-bit alpha RGB. 4 bits per pixel.
+        PF_DXT1 = 13,
+        // DXT2/BC2 format with premultiplied alpha. 6 bits per pixel.
+        PF_DXT2 = 14,
+        // DXT3/BC2 format with explicit alpha. 6 bits per pixel.
+        PF_DXT3 = 15,
+        // DXT4/BC3 format with premultiplied alpha. 6 bits per pixel. Better alpha gradients than DXT2.
+        PF_DXT4 = 16,
+        // DXT5/BC3 format with explicit alpha. 6 bits per pixel. Better alpha gradients than DXT3.
+        PF_DXT5 = 17,
+		// 16-bit pixel format, 16 bits (float) for red
+        PF_FLOAT16_R = 18,
+		// 32-bit, 2-channel s10e5 floating point pixel format, 16-bit red, 16-bit green
+		PF_FLOAT16_RG = 19,
+        // 48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue
+        PF_FLOAT16_RGB = 20,
+        // 64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue, 16 bits (float) for alpha
+        PF_FLOAT16_RGBA = 21,
+		// 32-bit pixel format, 32 bits (float) for red
+        PF_FLOAT32_R = 22,
+		// 64-bit, 2-channel floating point pixel format, 32-bit red, 32-bit green
+		PF_FLOAT32_RG = 23,
+        // 96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue
+        PF_FLOAT32_RGB = 24,
+        // 128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 32 bits (float) for alpha
+        PF_FLOAT32_RGBA = 25,
+		// Depth stencil format, 32bit depth, 8bit stencil + 24 unused
+		PF_D32_S8X24 = 26,
+		// Depth stencil fomrat, 24bit depth + 8bit stencil
+		PF_D24S8 = 27,
+		// Depth format, 32bits
+		PF_D32 = 28,
+		// Depth format, 16bits
+		PF_D16 = 29,
+		// Number of pixel formats currently defined
+        PF_COUNT = 30
+    };
+	typedef Vector<PixelFormat> PixelFormatList;
+
+	/**
+	 * @brief	Flags defining some properties of pixel formats.
+	 */
+    enum PixelFormatFlags {
+        // This format has an alpha channel
+        PFF_HASALPHA        = 0x00000001,      
+        // This format is compressed. This invalidates the values in elemBytes,
+        // elemBits and the bit counts as these might not be fixed in a compressed format.
+        PFF_COMPRESSED    = 0x00000002,
+        // This is a floating point format
+        PFF_FLOAT           = 0x00000004,         
+        // This is a depth format (for depth textures)
+        PFF_DEPTH           = 0x00000008,
+        // Format is in native endian. Generally true for the 16, 24 and 32 bits
+        // formats which can be represented as machine integers.
+        PFF_NATIVEENDIAN    = 0x00000010
+    };
+    
+	/**
+	 * @brief	Types of pixel components
+	 */
+    enum PixelComponentType
+    {
+        PCT_BYTE = 0,    /**< Byte per component */
+        PCT_SHORT = 1,   /**< Short per component */
+        PCT_FLOAT16 = 2, /**< 16 bit float per component */
+        PCT_FLOAT32 = 3, /**< 32 bit float per component */
+        PCT_COUNT = 4    /**< Number of pixel types */
+    };
+    
+	/**
+	 * @brief	A buffer describing a volume (3D), image (2D) or line (1D) of pixels in memory.
+	 *			Pixels are stored as a succession of "depth" slices, each containing "height" rows of
+	 *			"width" pixels.
+	 *
+	 *			As any GpuResourceData this is used primarily for reading and writing from/to a GPU resource,
+	 *			and is normally constructed by the resource itself. However you may still construct it manually
+	 *			and use it for other purposes if needed.
+	 *
+	 * @note	You must call allocateInternalBuffer or set the buffer in some other way before reading/writing
+	 *			from this object.
+	 *
+	 * @see		GpuResourceData
+	 */
+    class BS_CORE_EXPORT PixelData : public GpuResourceData
+	{
+    public:
+    	PixelData() {}
+		~PixelData() {}
+
+		/**
+		 * @brief	Constructs a new object with an internal buffer capable of holding "extents" volume of pixels, 
+		 *			where each pixel is of the specified pixel format. Extent offsets are also stored, but are not used
+		 *			internally.
+		 */
+		PixelData(const PixelVolume &extents, PixelFormat pixelFormat)
+			:mExtents(extents), mFormat(pixelFormat)
+		{
+			setConsecutive();
+		}
+
+		/**
+		 * @brief	Constructs a new object with an internal buffer capable of holding volume of pixels described by
+		 *			provided width, height and depth, where each pixel is of the specified pixel format.
+		 */
+    	PixelData(UINT32 width, UINT32 height, UINT32 depth, PixelFormat pixelFormat)
+			: mExtents(0, 0, 0, width, height, depth), mFormat(pixelFormat)
+    	{
+    		setConsecutive();
+    	}
+
+		PixelData(const PixelData& copy);
+		PixelData& operator=(const PixelData& rhs);
+
+		/**
+		 * @brief	Returns the number of pixels that offsets one row from another. This can be
+		 *			"width", but doesn't have to be as some buffers require padding.
+		 */
+		UINT32 getRowPitch() const { return mRowPitch; }
+
+		/**
+		 * @brief	Returns the number of pixels that offsets one depth slice from another. This can be
+		 *			"width * height", but doesn't have to be as some buffers require padding.
+		 */
+		UINT32 getSlicePitch() const { return mSlicePitch; }
+
+		/**
+		 * @brief	Sets the pitch (in pixels) that determines offset between rows of the pixel buffer.
+		 *			Call this before allocating the buffer.
+		 */
+		void setRowPitch(UINT32 rowPitch) { mRowPitch = rowPitch; }
+
+		/**
+		 * @brief	Sets the pitch (in pixels) that determines offset between depth slices of the pixel buffer.
+		 *			Call this before allocating the buffer.
+		 */
+        void setSlicePitch(UINT32 slicePitch) { mSlicePitch = slicePitch; }
+
+		/**
+		 * @brief	Returns the number of extra pixels in a row (non-zero only if rows are not
+		 *			consecutive (row pitch is larger than width)).
+		 */
+        UINT32 getRowSkip() const { return mRowPitch - getWidth(); }
+
+		/**
+		 * @brief	Returns the number of extra pixels in a depth slice (non-zero only if
+		 *			slices aren't consecutive (slice pitch is larger than width*height).
+		 */
+        UINT32 getSliceSkip() const { return mSlicePitch - (getHeight() * mRowPitch); }
+
+		/**
+		 * @brief	Returns the pixel format used by the internal buffer for storing the pixels.
+		 */
+		PixelFormat getFormat() const { return mFormat; }
+
+		/**
+		 * @brief	Returns width of the buffer in pixels.
+		 */
+		UINT32 getWidth() const { return mExtents.getWidth(); }
+
+		/**
+		 * @brief	Returns height of the buffer in pixels.
+		 */
+		UINT32 getHeight() const { return mExtents.getHeight(); }
+
+		/**
+		 * @brief	Returns depth of the buffer in pixels.
+		 */
+		UINT32 getDepth() const { return mExtents.getDepth(); }
+
+		/**
+		 * @brief	Returns left-most start of the pixel volume. This value is not used internally in any way.
+		 *			It is just passed through from the constructor.
+		 */
+		UINT32 getLeft() const { return mExtents.left; }
+
+		/**
+		 * @brief	Returns right-most end of the pixel volume. This value is not used internally in any way.
+		 *			It is just passed through from the constructor.
+		 */
+		UINT32 getRight() const { return mExtents.right; }
+
+		/**
+		 * @brief	Returns top-most start of the pixel volume. This value is not used internally in any way.
+		 *			It is just passed through from the constructor.
+		 */
+		UINT32 getTop() const { return mExtents.top; }
+
+		/**
+		 * @brief	Returns bottom-most end of the pixel volume. This value is not used internally in any way.
+		 *			It is just passed through from the constructor.
+		 */
+		UINT32 getBottom() const { return mExtents.bottom; }
+
+		/**
+		 * @brief	Returns front-most start of the pixel volume. This value is not used internally in any way.
+		 *			It is just passed through from the constructor.
+		 */
+		UINT32 getFront() const { return mExtents.front; }
+
+		/**
+		 * @brief	Returns back-most end of the pixel volume. This value is not used internally in any way.
+		 *			It is just passed through from the constructor.
+		 */
+		UINT32 getBack() const { return mExtents.back; }
+
+		/**
+		 * @brief	Returns extents of the pixel volume this object is capable of holding.
+		 */
+		PixelVolume getExtents() const { return mExtents; }
+
+		/**
+		 * @brief	Return whether this buffer is laid out consecutive in memory 
+		 *			(i.e. the pitches are equal to the dimensions).
+		 */
+        bool isConsecutive() const 
+		{ 
+			return mRowPitch == getWidth() && mSlicePitch == getWidth()*getHeight(); 
+		}
+
+		/**
+		 * @brief	Return the size (in bytes) this image would take if it was
+		 *			laid out consecutive in memory.
+		 */
+      	UINT32 getConsecutiveSize() const;
+
+		/**
+		 * @brief	Returns pixel data containing a sub-volume of this object. Returned
+		 *			data will not have its own buffer, but will instead point to this one.
+		 *			It is up to the caller to ensure this object outlives any sub-volume objects.
+		 */
+      	PixelData getSubVolume(const PixelVolume &def) const;
+        
+		/**
+		 * @brief	Returns pixel color at the specified coordinates.
+		 */
+        Color getColorAt(UINT32 x, UINT32 y, UINT32 z = 0);
+
+		/**
+		 * @brief	Sets the pixel color at the specified coordinates.
+		 */
+        void setColorAt(Color const &cv, UINT32 x, UINT32 y, UINT32 z = 0);
+
+	private:
+		/**
+		 * @brief	Set the rowPitch and slicePitch so that the buffer is laid out consecutive
+		 *			in memory. Does not actually modify the buffer itself.
+		 */
+		void setConsecutive()
+		{
+			mRowPitch = getWidth();
+			mSlicePitch = getWidth()*getHeight();
+		}
+
+		/**
+		 * @brief	Returns the needed size of the internal buffer, in bytes.
+		 */
+		UINT32 getInternalBufferSize();
+
+	private:
+		PixelVolume mExtents;
+        PixelFormat mFormat;
+        UINT32 mRowPitch;
+        UINT32 mSlicePitch;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class PixelDataRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+    };
 }

+ 91 - 91
CamelotCore/Include/CmPixelDataRTTI.h → BansheeCore/Include/CmPixelDataRTTI.h

@@ -1,92 +1,92 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmPixelData.h"
-#include "CmRTTIType.h"
-#include "CmManagedDataBlock.h"
-
-namespace BansheeEngine
-{
-	class CM_EXPORT PixelDataRTTI : public RTTIType<PixelData, GpuResourceData, PixelDataRTTI>
-	{
-		UINT32& getLeft(PixelData* obj) { return obj->mExtents.left; }
-		void setLeft(PixelData* obj, UINT32& val) { obj->mExtents.left = val; }
-
-		UINT32& getTop(PixelData* obj) { return obj->mExtents.top; }
-		void setTop(PixelData* obj, UINT32& val) { obj->mExtents.top = val; }
-
-		UINT32& getRight(PixelData* obj) { return obj->mExtents.right; }
-		void setRight(PixelData* obj, UINT32& val) { obj->mExtents.right = val; }
-
-		UINT32& getBottom(PixelData* obj) { return obj->mExtents.bottom; }
-		void setBottom(PixelData* obj, UINT32& val) { obj->mExtents.bottom = val; }
-
-		UINT32& getFront(PixelData* obj) { return obj->mExtents.front; }
-		void setFront(PixelData* obj, UINT32& val) { obj->mExtents.front = val; }
-
-		UINT32& getBack(PixelData* obj) { return obj->mExtents.back; }
-		void setBack(PixelData* obj, UINT32& val) { obj->mExtents.back = val; }
-
-		UINT32& getRowPitch(PixelData* obj) { return obj->mRowPitch; }
-		void setRowPitch(PixelData* obj, UINT32& val) { obj->mRowPitch = val; }
-
-		UINT32& getSlicePitch(PixelData* obj) { return obj->mSlicePitch; }
-		void setSlicePitch(PixelData* obj, UINT32& val) { obj->mSlicePitch = val; }
-
-		PixelFormat& getFormat(PixelData* obj) { return obj->mFormat; }
-		void setFormat(PixelData* obj, PixelFormat& val) { obj->mFormat = val; }
-
-		ManagedDataBlock getData(PixelData* obj) 
-		{ 
-			ManagedDataBlock dataBlock((UINT8*)obj->getData(), obj->getConsecutiveSize());
-			return dataBlock; 
-		}
-
-		void setData(PixelData* obj, ManagedDataBlock val) 
-		{ 
-			// Nothing to do here, the pointer we provided already belongs to PixelData
-			// so the data is already written
-		}
-
-		static UINT8* allocateData(PixelData* obj, UINT32 numBytes)
-		{
-			obj->allocateInternalBuffer(numBytes);
-
-			return obj->getData();
-		}
-
-	public:
-		PixelDataRTTI()
-		{
-			addPlainField("left", 0, &PixelDataRTTI::getLeft, &PixelDataRTTI::setLeft);
-			addPlainField("top", 1, &PixelDataRTTI::getTop, &PixelDataRTTI::setTop);
-			addPlainField("right", 2, &PixelDataRTTI::getRight, &PixelDataRTTI::setRight);
-			addPlainField("bottom", 3, &PixelDataRTTI::getBottom, &PixelDataRTTI::setBottom);
-			addPlainField("front", 4, &PixelDataRTTI::getFront, &PixelDataRTTI::setFront);
-			addPlainField("back", 5, &PixelDataRTTI::getBack, &PixelDataRTTI::setBack);
-			addPlainField("rowPitch", 6, &PixelDataRTTI::getRowPitch, &PixelDataRTTI::setRowPitch);
-			addPlainField("slicePitch", 7, &PixelDataRTTI::getSlicePitch, &PixelDataRTTI::setSlicePitch);
-			addPlainField("format", 8, &PixelDataRTTI::getFormat, &PixelDataRTTI::setFormat);
-
-			addDataBlockField("data", 9, &PixelDataRTTI::getData, &PixelDataRTTI::setData, 0, &PixelDataRTTI::allocateData);
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "PixelData";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_PixelData;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			PixelDataPtr newPixelData = cm_shared_ptr<PixelData, PoolAlloc>();
-
-			return newPixelData;
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmPixelData.h"
+#include "CmRTTIType.h"
+#include "CmManagedDataBlock.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT PixelDataRTTI : public RTTIType<PixelData, GpuResourceData, PixelDataRTTI>
+	{
+		UINT32& getLeft(PixelData* obj) { return obj->mExtents.left; }
+		void setLeft(PixelData* obj, UINT32& val) { obj->mExtents.left = val; }
+
+		UINT32& getTop(PixelData* obj) { return obj->mExtents.top; }
+		void setTop(PixelData* obj, UINT32& val) { obj->mExtents.top = val; }
+
+		UINT32& getRight(PixelData* obj) { return obj->mExtents.right; }
+		void setRight(PixelData* obj, UINT32& val) { obj->mExtents.right = val; }
+
+		UINT32& getBottom(PixelData* obj) { return obj->mExtents.bottom; }
+		void setBottom(PixelData* obj, UINT32& val) { obj->mExtents.bottom = val; }
+
+		UINT32& getFront(PixelData* obj) { return obj->mExtents.front; }
+		void setFront(PixelData* obj, UINT32& val) { obj->mExtents.front = val; }
+
+		UINT32& getBack(PixelData* obj) { return obj->mExtents.back; }
+		void setBack(PixelData* obj, UINT32& val) { obj->mExtents.back = val; }
+
+		UINT32& getRowPitch(PixelData* obj) { return obj->mRowPitch; }
+		void setRowPitch(PixelData* obj, UINT32& val) { obj->mRowPitch = val; }
+
+		UINT32& getSlicePitch(PixelData* obj) { return obj->mSlicePitch; }
+		void setSlicePitch(PixelData* obj, UINT32& val) { obj->mSlicePitch = val; }
+
+		PixelFormat& getFormat(PixelData* obj) { return obj->mFormat; }
+		void setFormat(PixelData* obj, PixelFormat& val) { obj->mFormat = val; }
+
+		ManagedDataBlock getData(PixelData* obj) 
+		{ 
+			ManagedDataBlock dataBlock((UINT8*)obj->getData(), obj->getConsecutiveSize());
+			return dataBlock; 
+		}
+
+		void setData(PixelData* obj, ManagedDataBlock val) 
+		{ 
+			// Nothing to do here, the pointer we provided already belongs to PixelData
+			// so the data is already written
+		}
+
+		static UINT8* allocateData(PixelData* obj, UINT32 numBytes)
+		{
+			obj->allocateInternalBuffer(numBytes);
+
+			return obj->getData();
+		}
+
+	public:
+		PixelDataRTTI()
+		{
+			addPlainField("left", 0, &PixelDataRTTI::getLeft, &PixelDataRTTI::setLeft);
+			addPlainField("top", 1, &PixelDataRTTI::getTop, &PixelDataRTTI::setTop);
+			addPlainField("right", 2, &PixelDataRTTI::getRight, &PixelDataRTTI::setRight);
+			addPlainField("bottom", 3, &PixelDataRTTI::getBottom, &PixelDataRTTI::setBottom);
+			addPlainField("front", 4, &PixelDataRTTI::getFront, &PixelDataRTTI::setFront);
+			addPlainField("back", 5, &PixelDataRTTI::getBack, &PixelDataRTTI::setBack);
+			addPlainField("rowPitch", 6, &PixelDataRTTI::getRowPitch, &PixelDataRTTI::setRowPitch);
+			addPlainField("slicePitch", 7, &PixelDataRTTI::getSlicePitch, &PixelDataRTTI::setSlicePitch);
+			addPlainField("format", 8, &PixelDataRTTI::getFormat, &PixelDataRTTI::setFormat);
+
+			addDataBlockField("data", 9, &PixelDataRTTI::getData, &PixelDataRTTI::setData, 0, &PixelDataRTTI::allocateData);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "PixelData";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_PixelData;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			PixelDataPtr newPixelData = cm_shared_ptr<PixelData, PoolAlloc>();
+
+			return newPixelData;
+		}
+	};
 }

+ 194 - 194
CamelotCore/Include/CmPixelUtil.h → BansheeCore/Include/CmPixelUtil.h

@@ -1,195 +1,195 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmPixelData.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Utility methods for converting and managing pixel data and formats.
-	 */
-    class CM_EXPORT PixelUtil 
-	{
-    public:
-		/**
-		 * @brief	A list of filtering types to use when scaling images.
-		 */
-		enum Filter
-		{
-			FILTER_NEAREST,
-			FILTER_LINEAR,
-			FILTER_BILINEAR,
-			FILTER_BOX,
-			FILTER_TRIANGLE,
-			FILTER_BICUBIC
-		};
-
-		/**
-		 * @brief	Returns the size of a single pixel of the provided pixel format,
-		 *			in bytes.
-		 */
-        static UINT32 getNumElemBytes(PixelFormat format);
-
-		/**
-		 * @brief	Returns the size of a single pixel of the provided pixel format,
-		 *			in bits.
-		 */
-        static UINT32 getNumElemBits( PixelFormat format );
-
-		/**
-		 * @brief	Returns the size of the memory region of the provided size and the pixel format.
-		 */
-		static UINT32 getMemorySize(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
-		
-		/**
-		 * @brief	Returns property flags for this pixel format.
-		 *
-		 * @see		PixelFormatFlags
-		 */
-        static UINT32 getFlags(PixelFormat format);
-
-		/**
-		 * @brief	Checks if the provided pixel format has an alpha channel.
-		 */
-        static bool hasAlpha(PixelFormat format);
-
-		/**
-		 * @brief	Checks is the provided pixel format a floating point format.
-		 */
-        static bool isFloatingPoint(PixelFormat format);
-
-		/**
-		 * @brief	Checks is the provided pixel format compressed.
-		 */
-        static bool isCompressed(PixelFormat format);
-
-		/**
-		 * @brief	Checks is the provided pixel format a depth/stencil buffer format.
-		 */
-        static bool isDepth(PixelFormat format);
-
-		/**
-		 * @brief	Checks is the provided format in native endian format.
-		 */
-        static bool isNativeEndian(PixelFormat format);
-		
-		/**
-		 * @brief	Checks are the provided dimensions valid for the specified pixel format.
-		 *			Some formats (like DXT) require width/height to be multiples of four and some
-		 *			formats dont allow depth larger than 1.
-		 */
-		static bool isValidExtent(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
-
-		/**
-		 * @brief	Returns the number of bits per each element in the provided pixel format.
-		 *			This will return all zero for compressed and depth/stencil formats.
-		 */
-        static void getBitDepths(PixelFormat format, int rgba[4]);
-
-		/**
-		 * @brief	Returns bit masks that determine in what bit range is each channel stored.
-		 *
-		 * @note	e.g. if your color is stored in an UINT32 and you want to extract the red channel
-		 *			you should AND the color UINT32 with the bit-mask for the red channel and then
-		 *			right shift it by the red channel bit shift amount.
-		 */
-        static void getBitMasks(PixelFormat format, UINT32 rgba[4]);
-
-		/**
-		 * @brief	Returns number of bits you need to shift a pixel element in order
-		 *			to move it to the start of the data type.
-		 *
-		 * @note	e.g. if your color is stored in an UINT32 and you want to extract the red channel
-		 *			you should AND the color UINT32 with the bit-mask for the red channel and then
-		 *			right shift it by the red channel bit shift amount.
-		 */
-		static void getBitShifts(PixelFormat format, UINT8 rgba[4]);
-
-		/**
-		 * @brief	Returns the name of the pixel format.
-		 */
-        static String getFormatName(PixelFormat srcformat);
-
-		/**
-		 * @brief	Returns true if the pixel data in the format can be directly accessed and read.
-		 *			This is generally not true for compressed formats.
-		 */
-        static bool isAccessible(PixelFormat srcformat);
-        
-		/**
-		 * @brief	Returns the type of an individual pixel element in the provided format.
-		 */
-        static PixelComponentType getElementType(PixelFormat format);
-        
-		/**
-		 * @brief	Returns the number of pixel elements in the provided format.
-		 */
-		static UINT32 getNumElements(PixelFormat format);
-
-		/**
-		 * @brief	Returns the maximum number of mip maps that can be generated until we reach
-		 *			the minimum size possible. This does not count the base level.
-		 */
-		static UINT32 getMaxMipmaps(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
-
-		/**
-		 * @brief	Writes the color to the provided memory location.
-		 */
-        static void packColor(const Color& color, PixelFormat format, void* dest);
-
-		/**
-		 * @brief	Writes the color to the provided memory location. If the destination
-		 *			format is floating point, the byte values will be converted into [0.0, 1.0] range.
-		 */
-		static void packColor(UINT8 r, UINT8 g, UINT8 b, UINT8 a, PixelFormat format, void* dest);
-
-		/**
-		 * @brief	Writes the color to the provided memory location. If the destination format
-		 *			in non-floating point, the float values will be assumed to be in [0.0, 1.0] which
-		 *			will be converted to integer range. ([0, 255] in the case of bytes)
-		 */
-		static void packColor(float r, float g, float b, float a, const PixelFormat format, void* dest);
-
-		/**
-		 * @brief	Reads the color from the provided memory location and stores it 
-		 *			into the provided color object.
-		 */
-		static void unpackColor(Color* color, PixelFormat format, const void* src);
-
-		/**
-		 * @brief	Reads the color from the provided memory location and stores it 
-		 *			into the provided color elements, as bytes clamped to [0, 255] range.
-		 */
-		static void unpackColor(UINT8* r, UINT8* g, UINT8* b, UINT8* a, PixelFormat format, const void* src);
-
-		/**
-		 * @brief	Reads the color from the provided memory location and stores it 
-		 *			into the provided color elements. If the format is not natively floating
-		 *			point a conversion is done in such a way that returned values range [0.0, 1.0].
-		 */
-        static void unpackColor(float* r, float* g, float* b, float* a, PixelFormat format, const void* src); 
-        
-		/**
-		 * @brief	Converts pixels from one format to another. Provided pixel data objects
-		 *			must have previously allocated buffers of adequate size and their sizes must match.
-		 */
-        static void bulkPixelConversion(const PixelData& src, const PixelData& dst);
-
-		/**
-		 * @brief	Scales pixel data in the source buffer and stores the scaled data in the destination buffer.
-		 *			Provided pixel data objects must have previously allocated buffers of adequate size. You may
-		 *			also provided a filtering method to use when scaling.
-		 */
-		static void scale(const PixelData& src, const PixelData& dst, Filter filter = FILTER_BILINEAR);
-
-		/**
-		 * @brief	Applies gamma correction to the pixels in the provided buffer.
-		 *
-		 * @param	buffer	Pointer to the buffer containing the pixels.
-		 * @param	gamma	Gamma value to apply.
-		 * @param	size	Size of the buffer in bytes.
-		 * @param	bpp		Number of bits per pixel of the pixels in the buffer.
-		 */
-        static void applyGamma(UINT8* buffer, float gamma, UINT32 size, UINT8 bpp);
-    };
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmPixelData.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Utility methods for converting and managing pixel data and formats.
+	 */
+    class BS_CORE_EXPORT PixelUtil 
+	{
+    public:
+		/**
+		 * @brief	A list of filtering types to use when scaling images.
+		 */
+		enum Filter
+		{
+			FILTER_NEAREST,
+			FILTER_LINEAR,
+			FILTER_BILINEAR,
+			FILTER_BOX,
+			FILTER_TRIANGLE,
+			FILTER_BICUBIC
+		};
+
+		/**
+		 * @brief	Returns the size of a single pixel of the provided pixel format,
+		 *			in bytes.
+		 */
+        static UINT32 getNumElemBytes(PixelFormat format);
+
+		/**
+		 * @brief	Returns the size of a single pixel of the provided pixel format,
+		 *			in bits.
+		 */
+        static UINT32 getNumElemBits( PixelFormat format );
+
+		/**
+		 * @brief	Returns the size of the memory region of the provided size and the pixel format.
+		 */
+		static UINT32 getMemorySize(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
+		
+		/**
+		 * @brief	Returns property flags for this pixel format.
+		 *
+		 * @see		PixelFormatFlags
+		 */
+        static UINT32 getFlags(PixelFormat format);
+
+		/**
+		 * @brief	Checks if the provided pixel format has an alpha channel.
+		 */
+        static bool hasAlpha(PixelFormat format);
+
+		/**
+		 * @brief	Checks is the provided pixel format a floating point format.
+		 */
+        static bool isFloatingPoint(PixelFormat format);
+
+		/**
+		 * @brief	Checks is the provided pixel format compressed.
+		 */
+        static bool isCompressed(PixelFormat format);
+
+		/**
+		 * @brief	Checks is the provided pixel format a depth/stencil buffer format.
+		 */
+        static bool isDepth(PixelFormat format);
+
+		/**
+		 * @brief	Checks is the provided format in native endian format.
+		 */
+        static bool isNativeEndian(PixelFormat format);
+		
+		/**
+		 * @brief	Checks are the provided dimensions valid for the specified pixel format.
+		 *			Some formats (like DXT) require width/height to be multiples of four and some
+		 *			formats dont allow depth larger than 1.
+		 */
+		static bool isValidExtent(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
+
+		/**
+		 * @brief	Returns the number of bits per each element in the provided pixel format.
+		 *			This will return all zero for compressed and depth/stencil formats.
+		 */
+        static void getBitDepths(PixelFormat format, int rgba[4]);
+
+		/**
+		 * @brief	Returns bit masks that determine in what bit range is each channel stored.
+		 *
+		 * @note	e.g. if your color is stored in an UINT32 and you want to extract the red channel
+		 *			you should AND the color UINT32 with the bit-mask for the red channel and then
+		 *			right shift it by the red channel bit shift amount.
+		 */
+        static void getBitMasks(PixelFormat format, UINT32 rgba[4]);
+
+		/**
+		 * @brief	Returns number of bits you need to shift a pixel element in order
+		 *			to move it to the start of the data type.
+		 *
+		 * @note	e.g. if your color is stored in an UINT32 and you want to extract the red channel
+		 *			you should AND the color UINT32 with the bit-mask for the red channel and then
+		 *			right shift it by the red channel bit shift amount.
+		 */
+		static void getBitShifts(PixelFormat format, UINT8 rgba[4]);
+
+		/**
+		 * @brief	Returns the name of the pixel format.
+		 */
+        static String getFormatName(PixelFormat srcformat);
+
+		/**
+		 * @brief	Returns true if the pixel data in the format can be directly accessed and read.
+		 *			This is generally not true for compressed formats.
+		 */
+        static bool isAccessible(PixelFormat srcformat);
+        
+		/**
+		 * @brief	Returns the type of an individual pixel element in the provided format.
+		 */
+        static PixelComponentType getElementType(PixelFormat format);
+        
+		/**
+		 * @brief	Returns the number of pixel elements in the provided format.
+		 */
+		static UINT32 getNumElements(PixelFormat format);
+
+		/**
+		 * @brief	Returns the maximum number of mip maps that can be generated until we reach
+		 *			the minimum size possible. This does not count the base level.
+		 */
+		static UINT32 getMaxMipmaps(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
+
+		/**
+		 * @brief	Writes the color to the provided memory location.
+		 */
+        static void packColor(const Color& color, PixelFormat format, void* dest);
+
+		/**
+		 * @brief	Writes the color to the provided memory location. If the destination
+		 *			format is floating point, the byte values will be converted into [0.0, 1.0] range.
+		 */
+		static void packColor(UINT8 r, UINT8 g, UINT8 b, UINT8 a, PixelFormat format, void* dest);
+
+		/**
+		 * @brief	Writes the color to the provided memory location. If the destination format
+		 *			in non-floating point, the float values will be assumed to be in [0.0, 1.0] which
+		 *			will be converted to integer range. ([0, 255] in the case of bytes)
+		 */
+		static void packColor(float r, float g, float b, float a, const PixelFormat format, void* dest);
+
+		/**
+		 * @brief	Reads the color from the provided memory location and stores it 
+		 *			into the provided color object.
+		 */
+		static void unpackColor(Color* color, PixelFormat format, const void* src);
+
+		/**
+		 * @brief	Reads the color from the provided memory location and stores it 
+		 *			into the provided color elements, as bytes clamped to [0, 255] range.
+		 */
+		static void unpackColor(UINT8* r, UINT8* g, UINT8* b, UINT8* a, PixelFormat format, const void* src);
+
+		/**
+		 * @brief	Reads the color from the provided memory location and stores it 
+		 *			into the provided color elements. If the format is not natively floating
+		 *			point a conversion is done in such a way that returned values range [0.0, 1.0].
+		 */
+        static void unpackColor(float* r, float* g, float* b, float* a, PixelFormat format, const void* src); 
+        
+		/**
+		 * @brief	Converts pixels from one format to another. Provided pixel data objects
+		 *			must have previously allocated buffers of adequate size and their sizes must match.
+		 */
+        static void bulkPixelConversion(const PixelData& src, const PixelData& dst);
+
+		/**
+		 * @brief	Scales pixel data in the source buffer and stores the scaled data in the destination buffer.
+		 *			Provided pixel data objects must have previously allocated buffers of adequate size. You may
+		 *			also provided a filtering method to use when scaling.
+		 */
+		static void scale(const PixelData& src, const PixelData& dst, Filter filter = FILTER_BILINEAR);
+
+		/**
+		 * @brief	Applies gamma correction to the pixels in the provided buffer.
+		 *
+		 * @param	buffer	Pointer to the buffer containing the pixels.
+		 * @param	gamma	Gamma value to apply.
+		 * @param	size	Size of the buffer in bytes.
+		 * @param	bpp		Number of bits per pixel of the pixels in the buffer.
+		 */
+        static void applyGamma(UINT8* buffer, float gamma, UINT32 size, UINT8 bpp);
+    };
 }

+ 43 - 43
CamelotCore/Include/CmPixelVolume.h → BansheeCore/Include/CmPixelVolume.h

@@ -1,44 +1,44 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Volume of pixels used for referencing a part of
-	 * 			a texture.
-	 */
-	struct CM_EXPORT PixelVolume
-	{
-		UINT32 left, top, right, bottom, front, back;
-
-		PixelVolume()
-			: left(0), top(0), right(1), bottom(1), front(0), back(1)
-		{ }
-
-		PixelVolume(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom):
-			left(left), top(top), right(right), bottom(bottom), front(0), back(1)
-		{
-			assert(right >= left && bottom >= top && back >= front);
-		}
-
-		PixelVolume(UINT32 left, UINT32 top, UINT32 front, UINT32 right, UINT32 bottom, UINT32 back):
-			left(left), top(top), right(right), bottom(bottom), front(front), back(back)
-		{
-			assert(right >= left && bottom >= top && back >= front);
-		}
-            
-		/**
-		 * @brief	Return true if the other box is a part of this one.
-		 */
-		bool contains(const PixelVolume &volume) const
-		{
-			return (volume.left >= left && volume.top >= top && volume.front >= front &&
-				volume.right <= right && volume.bottom <= bottom && volume.back <= back);
-		}
-            
-		UINT32 getWidth() const { return right-left; }
-		UINT32 getHeight() const { return bottom-top; }
-		UINT32 getDepth() const { return back-front; }
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Volume of pixels used for referencing a part of
+	 * 			a texture.
+	 */
+	struct BS_CORE_EXPORT PixelVolume
+	{
+		UINT32 left, top, right, bottom, front, back;
+
+		PixelVolume()
+			: left(0), top(0), right(1), bottom(1), front(0), back(1)
+		{ }
+
+		PixelVolume(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom):
+			left(left), top(top), right(right), bottom(bottom), front(0), back(1)
+		{
+			assert(right >= left && bottom >= top && back >= front);
+		}
+
+		PixelVolume(UINT32 left, UINT32 top, UINT32 front, UINT32 right, UINT32 bottom, UINT32 back):
+			left(left), top(top), right(right), bottom(bottom), front(front), back(back)
+		{
+			assert(right >= left && bottom >= top && back >= front);
+		}
+            
+		/**
+		 * @brief	Return true if the other box is a part of this one.
+		 */
+		bool contains(const PixelVolume &volume) const
+		{
+			return (volume.left >= left && volume.top >= top && volume.front >= front &&
+				volume.right <= right && volume.bottom <= bottom && volume.back <= back);
+		}
+            
+		UINT32 getWidth() const { return right-left; }
+		UINT32 getHeight() const { return bottom-top; }
+		UINT32 getDepth() const { return back-front; }
+	};
 }

+ 189 - 189
CamelotCore/Include/CmPlatform.h → BansheeCore/Include/CmPlatform.h

@@ -1,189 +1,189 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains values representing default
-	 *			mouse cursor types.
-	 */
-	enum class PlatformCursorType
-	{
-		Arrow,
-		Wait,
-		IBeam,
-		Help,
-		Hand,
-		SizeAll,
-		SizeNESW,
-		SizeNS,
-		SizeNWSE,
-		SizeWE
-	};
-
-	/**
-	 * @brief	Contains values reprenting window non client areas.
-	 *
-	 * @note	These are used for things like resize/move and tell the OS
-	 *			where each of those areas are on our window.
-	 */
-	enum class NonClientAreaBorderType
-	{
-		TopLeft,
-		Top,
-		TopRight,
-		Left,
-		Right,
-		BottomLeft,
-		Bottom,
-		BottomRight	
-	};
-
-	/**
-	 * @brief	Types of mouse buttons provided by the OS.
-	 */
-	enum class OSMouseButton
-	{
-		Left, Middle, Right, Count
-	};
-
-	/**
-	 * @brief	Describes pointer (mouse, touch) states as reported
-	 *			by the OS.
-	 */
-	struct CM_EXPORT OSPointerButtonStates
-	{
-		OSPointerButtonStates()
-		{
-			mouseButtons[0] = false;
-			mouseButtons[1] = false;
-			mouseButtons[2] = false;
-
-			shift = false;
-			ctrl = false;
-		}
-
-		bool mouseButtons[OSMouseButton::Count];
-		bool shift, ctrl;
-	};
-
-	/**
-	 * @brief	Type of drop event type. This is used
-	 *			when dragging items over drop targets.
-	 */
-	enum class OSDropType
-	{
-		FileList,
-		None
-	};
-
-	/**
-	 * @brief	Drop targets allow you to register a certain portion of a window as a drop target that
-	 *			accepts certain drop types. Accepted drop types are provided by the OS and include things
-	 *			like file and item dragging.
-	 *
-	 *			You will receive events with the specified drop area as long as it is active.
-	 */
-	class CM_EXPORT OSDropTarget
-	{
-	public:
-		/**
-		 * @brief	Triggered when a pointer is being dragged over the drop area.
-		 *			Provides window coordinates of the pointer position.
-		 */
-		Event<void(INT32 x, INT32 y)> onDragOver;
-
-		/**
-		 * @brief	Triggered when the user completes a drop while pointer is over
-		 *			the drop area.
-		 *			Provides window coordinates of the pointer position.
-		 */
-		Event<void(INT32 x, INT32 y)> onDrop;
-
-		/**
-		 * @brief	Triggered when a pointer enters the drop area.
-		 *			Provides window coordinates of the pointer position.
-		 */
-		Event<void(INT32 x, INT32 y)> onEnter;
-
-		/**
-		 * @brief	Triggered when a pointer leaves the drop area.
-		 */
-		Event<void()> onLeave;
-
-		/**
-		 * @brief	Sets the drop target area, in local window coordinates.
-		 */
-		void setArea(INT32 x, INT32 y, UINT32 width, UINT32 height);
-
-		/**
-		 * @brief	Gets the type of drop that this drop target is looking for. Only
-		 *			valid after a drop has been triggered.
-		 */
-		OSDropType getDropType() const { return mDropType; }
-
-		/**
-		 * @brief	Returns a list of files received by the drop target. Only valid
-		 *			after a drop of FileList type has been triggered.
-		 */
-		const Vector<WString>& getFileList() const { return *mFileList; }
-
-		/**
-		 * @brief	Internal method. Clears all internal values.
-		 */
-		void _clear();
-
-		/**
-		 * @brief	Internal method. Sets the file list and marks the drop event as FileList.
-		 */
-		void _setFileList(const Vector<WString>& fileList);
-
-		/**
-		 * @brief	Marks the drop area as inactive or active.
-		 */
-		void _setActive(bool active) { mActive = active; }
-
-		/**
-		 * @brief	Checks is the specified position within the current drop area.
-		 *			Position should be in window local coordinates.
-		 */
-		bool _isInside(const Vector2I& pos) const;
-
-		/**
-		 * @brief	Returns true if the drop target is active.
-		 */
-		bool _isActive() const { return mActive; }
-	private:
-		friend class Platform;
-
-		OSDropTarget(const RenderWindow* ownerWindow, INT32 x, INT32 y, UINT32 width, UINT32 height);
-		~OSDropTarget();
-
-		/**
-		 * @brief	Returns a render window this drop target is attached to.
-		 */
-		const RenderWindow* getOwnerWindow() const { return mOwnerWindow; }
-	private:
-		INT32 mX, mY;
-		UINT32 mWidth, mHeight;
-		bool mActive;
-		const RenderWindow* mOwnerWindow;
-
-		OSDropType mDropType;
-
-		union 
-		{
-			Vector<WString>* mFileList;
-		};
-	};
-}
-
-// Bring in the specific platform's header file
-#if CM_PLATFORM == CM_PLATFORM_WIN32
-# include "Win32/CmPlatformImpl.h"
-#elif (CM_PLATFORM == CM_PLATFORM_LINUX)
-# include "GLX/CmPlatformImpl.h"
-#elif CM_PLATFORM == CM_PLATFORM_APPLE
-# include "OSX/CmPlatformImpl.h"
-#endif
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Contains values representing default
+	 *			mouse cursor types.
+	 */
+	enum class PlatformCursorType
+	{
+		Arrow,
+		Wait,
+		IBeam,
+		Help,
+		Hand,
+		SizeAll,
+		SizeNESW,
+		SizeNS,
+		SizeNWSE,
+		SizeWE
+	};
+
+	/**
+	 * @brief	Contains values reprenting window non client areas.
+	 *
+	 * @note	These are used for things like resize/move and tell the OS
+	 *			where each of those areas are on our window.
+	 */
+	enum class NonClientAreaBorderType
+	{
+		TopLeft,
+		Top,
+		TopRight,
+		Left,
+		Right,
+		BottomLeft,
+		Bottom,
+		BottomRight	
+	};
+
+	/**
+	 * @brief	Types of mouse buttons provided by the OS.
+	 */
+	enum class OSMouseButton
+	{
+		Left, Middle, Right, Count
+	};
+
+	/**
+	 * @brief	Describes pointer (mouse, touch) states as reported
+	 *			by the OS.
+	 */
+	struct BS_CORE_EXPORT OSPointerButtonStates
+	{
+		OSPointerButtonStates()
+		{
+			mouseButtons[0] = false;
+			mouseButtons[1] = false;
+			mouseButtons[2] = false;
+
+			shift = false;
+			ctrl = false;
+		}
+
+		bool mouseButtons[OSMouseButton::Count];
+		bool shift, ctrl;
+	};
+
+	/**
+	 * @brief	Type of drop event type. This is used
+	 *			when dragging items over drop targets.
+	 */
+	enum class OSDropType
+	{
+		FileList,
+		None
+	};
+
+	/**
+	 * @brief	Drop targets allow you to register a certain portion of a window as a drop target that
+	 *			accepts certain drop types. Accepted drop types are provided by the OS and include things
+	 *			like file and item dragging.
+	 *
+	 *			You will receive events with the specified drop area as long as it is active.
+	 */
+	class BS_CORE_EXPORT OSDropTarget
+	{
+	public:
+		/**
+		 * @brief	Triggered when a pointer is being dragged over the drop area.
+		 *			Provides window coordinates of the pointer position.
+		 */
+		Event<void(INT32 x, INT32 y)> onDragOver;
+
+		/**
+		 * @brief	Triggered when the user completes a drop while pointer is over
+		 *			the drop area.
+		 *			Provides window coordinates of the pointer position.
+		 */
+		Event<void(INT32 x, INT32 y)> onDrop;
+
+		/**
+		 * @brief	Triggered when a pointer enters the drop area.
+		 *			Provides window coordinates of the pointer position.
+		 */
+		Event<void(INT32 x, INT32 y)> onEnter;
+
+		/**
+		 * @brief	Triggered when a pointer leaves the drop area.
+		 */
+		Event<void()> onLeave;
+
+		/**
+		 * @brief	Sets the drop target area, in local window coordinates.
+		 */
+		void setArea(INT32 x, INT32 y, UINT32 width, UINT32 height);
+
+		/**
+		 * @brief	Gets the type of drop that this drop target is looking for. Only
+		 *			valid after a drop has been triggered.
+		 */
+		OSDropType getDropType() const { return mDropType; }
+
+		/**
+		 * @brief	Returns a list of files received by the drop target. Only valid
+		 *			after a drop of FileList type has been triggered.
+		 */
+		const Vector<WString>& getFileList() const { return *mFileList; }
+
+		/**
+		 * @brief	Internal method. Clears all internal values.
+		 */
+		void _clear();
+
+		/**
+		 * @brief	Internal method. Sets the file list and marks the drop event as FileList.
+		 */
+		void _setFileList(const Vector<WString>& fileList);
+
+		/**
+		 * @brief	Marks the drop area as inactive or active.
+		 */
+		void _setActive(bool active) { mActive = active; }
+
+		/**
+		 * @brief	Checks is the specified position within the current drop area.
+		 *			Position should be in window local coordinates.
+		 */
+		bool _isInside(const Vector2I& pos) const;
+
+		/**
+		 * @brief	Returns true if the drop target is active.
+		 */
+		bool _isActive() const { return mActive; }
+	private:
+		friend class Platform;
+
+		OSDropTarget(const RenderWindow* ownerWindow, INT32 x, INT32 y, UINT32 width, UINT32 height);
+		~OSDropTarget();
+
+		/**
+		 * @brief	Returns a render window this drop target is attached to.
+		 */
+		const RenderWindow* getOwnerWindow() const { return mOwnerWindow; }
+	private:
+		INT32 mX, mY;
+		UINT32 mWidth, mHeight;
+		bool mActive;
+		const RenderWindow* mOwnerWindow;
+
+		OSDropType mDropType;
+
+		union 
+		{
+			Vector<WString>* mFileList;
+		};
+	};
+}
+
+// Bring in the specific platform's header file
+#if CM_PLATFORM == CM_PLATFORM_WIN32
+# include "Win32/CmPlatformImpl.h"
+#elif (CM_PLATFORM == CM_PLATFORM_LINUX)
+# include "GLX/CmPlatformImpl.h"
+#elif CM_PLATFORM == CM_PLATFORM_APPLE
+# include "OSX/CmPlatformImpl.h"
+#endif

+ 358 - 358
CamelotCore/Include/CmPrerequisites.h → BansheeCore/Include/CmPrerequisites.h

@@ -1,359 +1,359 @@
-#pragma once
-
-#include "CmPrerequisitesUtil.h"
-
-#define CM_MAX_MULTIPLE_RENDER_TARGETS 8
-#define CM_FORCE_SINGLETHREADED_RENDERING 0
-
-// Windows Settings
-#if CM_PLATFORM == CM_PLATFORM_WIN32
-
-// If we're not including this from a client build, specify that the stuff
-// should get exported. Otherwise, import it.
-#	if defined( CM_STATIC_LIB )
-// Linux compilers don't have symbol import/export directives.
-#   	define CM_EXPORT
-#   else
-#   	if defined( CM_EXPORTS )
-#       	define CM_EXPORT __declspec( dllexport )
-#   	else
-#           if defined( __MINGW32__ )
-#               define CM_EXPORT
-#           else
-#       	    define CM_EXPORT __declspec( dllimport )
-#           endif
-#   	endif
-#	endif
-// Win32 compilers use _DEBUG for specifying debug builds.
-// for MinGW, we set DEBUG
-#   if defined(_DEBUG) || defined(DEBUG)
-#       define CM_DEBUG_MODE 1
-#   else
-#       define CM_DEBUG_MODE 0
-#   endif
-
-#endif
-
-// Linux/Apple Settings
-#if CM_PLATFORM == CM_PLATFORM_LINUX || CM_PLATFORM == CM_PLATFORM_APPLE
-
-// Enable GCC symbol visibility
-#   if defined( CM_GCC_VISIBILITY )
-#       define CM_EXPORT  __attribute__ ((visibility("default")))
-#       define CM_HIDDEN __attribute__ ((visibility("hidden")))
-#   else
-#       define CM_EXPORT
-#       define CM_HIDDEN
-#   endif
-
-// A quick define to overcome different names for the same function
-#   define stricmp strcasecmp
-
-#   ifdef DEBUG
-#       define CM_DEBUG_MODE 1
-#   else
-#       define CM_DEBUG_MODE 0
-#   endif
-
-#endif
-
-namespace BansheeEngine 
-{
-    class Color;
-    class GpuProgram;
-    class GpuProgramManager;
-    class IndexBuffer;
-    class OcclusionQuery;
-    class VertexBuffer;
-	class PixelBuffer;
-	class GpuBuffer;
-	class HighLevelGpuProgram;
-	class GpuProgramManager;
-	class GpuProgramFactory;
-    class IndexData;
-    class Pass;
-	class Technique;
-	class Shader;
-	class Material;
-    class RenderSystem;
-    class RenderSystemCapabilities;
-    class RenderTarget;
-    class RenderTexture;
-	class MultiRenderTexture;
-    class RenderWindow;
-    struct RenderOpMesh;
-    class StringInterface;
-    class SamplerState;
-    class TextureManager;
-    class Viewport;
-    class VertexData;
-    class VertexDeclaration;
-	class Input;
-	struct PointerEvent;
-	class RawInputHandler;
-	class Renderer;
-	class RendererFactory;
-	class PassParameters;
-	class AsyncOp;
-	class HardwareBufferManager;
-	class FontManager;
-	class DepthStencilState;
-	class RenderStateManager;
-	class RasterizerState;
-	class BlendState;
-	class GpuParamBlock;
-	class GpuParamBlockBuffer;
-	class GpuParams;
-	struct GpuParamDesc;
-	struct GpuParamDataDesc;
-	struct GpuParamObjectDesc;
-	struct GpuParamBlockDesc;
-	class GpuProgInclude;
-	class TextureView;
-	class CoreObject;
-	class ImportOptions;
-	struct FontData;
-	class GameObject;
-	class GpuResource;
-	class GpuResourceData;
-	class BindableGpuParams;
-	class BindableGpuParamBlock;
-	struct RenderOperation;
-	class RenderQueue;
-	struct ProfilerReport;
-	class VertexDataDesc;
-	class EventQuery;
-	class TimerQuery;
-	class OcclusionQuery;
-	class FrameAlloc;
-	class FolderMonitor;
-	class VideoMode;
-	class VideoOutputInfo;
-	class VideoModeInfo;
-	// Asset import
-	class SpecificImporter;
-	class Importer;
-	// Resources
-	class Resource;
-	class Resources;
-	class ResourceManifest;
-	class Texture;
-	class Mesh;
-	class MeshBase;
-	class TransientMesh;
-	class MeshHeap;
-	class Font;
-	class OSDropTarget;
-	// Scene
-	class SceneObject;
-	class Component;
-	class SceneManager;
-	// RTTI
-	class MeshRTTI;
-	// Desc structs
-	struct SAMPLER_STATE_DESC;
-	struct DEPTH_STENCIL_STATE_DESC;
-	struct RASTERIZER_STATE_DESC;
-	struct BLEND_STATE_DESC;
-	struct RENDER_TARGET_BLEND_STATE_DESC;
-	struct RENDER_TEXTURE_DESC;
-	struct RENDER_WINDOW_DESC;
-	struct FONT_DESC;
-
-	template<class T>
-	class CoreThreadAccessor;
-	class CommandQueueNoSync;
-	class CommandQueueSync;
-}
-
-/************************************************************************/
-/* 						Shared pointer typedefs	                    	*/
-/************************************************************************/
-
-namespace BansheeEngine
-{
-	typedef std::shared_ptr<RenderSystem> RenderSystemPtr;
-	typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
-	typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
-	typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
-	typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
-	typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
-	typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
-	typedef std::shared_ptr<Mesh> MeshPtr;
-	typedef std::shared_ptr<MeshBase> MeshBasePtr;
-	typedef std::shared_ptr<MeshHeap> MeshHeapPtr;
-	typedef std::shared_ptr<TransientMesh> TransientMeshPtr;
-	typedef std::shared_ptr<Texture> TexturePtr;
-	typedef std::shared_ptr<Resource> ResourcePtr;
-	typedef std::shared_ptr<Technique> TechniquePtr;
-	typedef std::shared_ptr<Pass> PassPtr;
-	typedef std::shared_ptr<Shader> ShaderPtr;
-	typedef std::shared_ptr<Material> MaterialPtr;
-	typedef std::shared_ptr<Renderer> RendererPtr;
-	typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
-	typedef std::shared_ptr<PassParameters> PassParametersPtr;
-	typedef std::shared_ptr<Component> ComponentPtr;
-	typedef std::shared_ptr<SceneObject> GameObjectPtr;
-	typedef std::shared_ptr<SamplerState> SamplerStatePtr;
-	typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
-	typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
-	typedef std::shared_ptr<BlendState> BlendStatePtr;
-	typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
-	typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
-	typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
-	typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
-	typedef std::shared_ptr<GpuParamBlock> GpuParamBlockPtr;
-	typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
-	typedef std::shared_ptr<GpuParams> GpuParamsPtr;
-	typedef std::shared_ptr<TextureView> TextureViewPtr;
-	typedef std::shared_ptr<Viewport> ViewportPtr;
-	typedef std::shared_ptr<GpuProgInclude> GpuProgIncludePtr;
-	typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
-	typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
-	typedef std::shared_ptr<Font> FontPtr;
-	typedef std::shared_ptr<GpuResource> GpuResourcePtr;
-	typedef std::shared_ptr<VertexDataDesc> VertexDataDescPtr;
-	typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
-	typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
-	typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
-	typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
-	typedef std::shared_ptr<EventQuery> EventQueryPtr;
-	typedef std::shared_ptr<TimerQuery> TimerQueryPtr;
-	typedef std::shared_ptr<OcclusionQuery> OcclusionQueryPtr;
-	typedef std::shared_ptr<ResourceManifest> ResourceManifestPtr;
-	typedef std::shared_ptr<VideoModeInfo> VideoModeInfoPtr;
-}
-
-/************************************************************************/
-/* 									RTTI                      			*/
-/************************************************************************/
-namespace BansheeEngine
-{
-	enum TypeID_Core
-	{
-		TID_Texture = 1001,
-		TID_Mesh = 1002,
-		TID_MeshData = 1003,
-		TID_VertexDeclaration = 1004,
-		TID_VertexElementData = 1005,
-		TID_Component = 1006,
-		TID_ResourceHandle = 1009,
-		TID_GpuProgram = 1010,
-		TID_ResourceHandleData = 1011,
-		TID_CgProgram = 1012,
-		TID_Pass = 1014,
-		TID_Technique = 1015,
-		TID_Shader = 1016,
-		TID_Material = 1017,
-		TID_MaterialParams = 1018,
-		TID_FloatParamKVP = 1019,
-		TID_MaterialTexParamKVP = 1020,
-		TID_SamplerState = 1021,
-		TID_SamplerStateParamKVP = 1022,
-		TID_BlendState = 1023,
-		TID_RasterizerState = 1024,
-		TID_DepthStencilState = 1025,
-		TID_MaterialParamFloat = 1026,
-		TID_MaterialParamVec2 = 1027,
-		TID_MaterialParamVec3 = 1028,
-		TID_MaterialParamVec4 = 1029,
-		TID_MaterialParamMat3 = 1030,
-		TID_MaterialParamMat4 = 1031,
-		TID_MaterialParamTexture = 1032,
-		TID_MaterialParamSamplerState = 1033,
-		TID_BLEND_STATE_DESC = 1034,
-		TID_SHADER_DATA_PARAM_DESC = 1035,
-		TID_SHADER_OBJECT_PARAM_DESC = 1036,
-		TID_SHADER_PARAM_BLOCK_DESC = 1047,
-		TID_ImportOptions = 1048,
-		TID_GpuProgramImportOptions = 1049,
-		TID_MaterialParamStruct = 1050,
-		TID_Font = 1051,
-		TID_FONT_DESC = 1052,
-		TID_CHAR_DESC = 1053,
-		TID_FontImportOptions = 1056,
-		TID_FontData = 1057,
-		TID_SceneObject = 1059,
-		TID_GameObject = 1060,
-		TID_GpuResource = 1061,
-		TID_PixelData = 1062,
-		TID_GpuResourceData = 1063,
-		TID_VertexDataDesc = 1064,
-		TID_MeshBase = 1065,
-		TID_GameObjectHandleBase = 1066,
-		TID_ResourceManifest = 1067,
-		TID_ResourceManifestEntry = 1068
-	};
-}
-
-/************************************************************************/
-/* 							Resource references                   		*/
-/************************************************************************/
-
-#include "CmResourceHandle.h"
-
-namespace BansheeEngine
-{
-	// Resource handles
-	typedef ResourceHandle<Resource> HResource;
-	typedef ResourceHandle<Texture> HTexture;
-	typedef ResourceHandle<Mesh> HMesh;
-	typedef ResourceHandle<GpuProgram> HGpuProgram;
-	typedef ResourceHandle<Material> HMaterial;
-	typedef ResourceHandle<SamplerState> HSamplerState;
-	typedef ResourceHandle<RasterizerState> HRasterizerState;
-	typedef ResourceHandle<DepthStencilState> HDepthStencilState;
-	typedef ResourceHandle<BlendState> HBlendState;
-	typedef ResourceHandle<GpuProgInclude> HGpuProgInclude;
-	typedef ResourceHandle<Font> HFont;
-}
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Defers function execution until the next frame. If this function is called
-	 * 			within another deferred call, then it will be executed the same frame,
-	 * 			but only after all existing deferred calls are done.
-	 * 			
-	 * @note	This method can be used for breaking dependencies among other things. If a class
-	 * 			A depends on class B having something done, but class B also depends in some way on class A,
-	 * 			you can break up the initialization into two separate steps, queuing the second step
-	 * 			using this method.
-	 * 			
-	 *			Similar situation can happen if you have multiple classes being initialized in an undefined order
-	 *			but some of them depend on others. Using this method you can defer the dependent step until next frame,
-	 *			which will ensure everything was initialized.
-	 *
-	 * @param	callback	The callback.
-	 */
-	void CM_EXPORT deferredCall(std::function<void()> callback);
-
-	// Special types for use by profilers
-	typedef std::basic_string<char, std::char_traits<char>, StdAlloc<char, ProfilerAlloc>> ProfilerString;
-
-	template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
-	using ProfilerVector = std::vector<T, A>;
-
-	template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
-	using ProfilerStack = std::stack<T, std::deque<T, A>>;
-
-	/**
-	* @brief	Banshee thread policy that performs special startup/shutdown on threads
-	*			managed by thread pool.
-	*/
-	class CM_EXPORT ThreadBansheePolicy
-	{
-	public:
-		static void onThreadStarted(const String& name)
-		{
-			MemStack::beginThread();
-		}
-
-		static void onThreadEnded(const String& name)
-		{
-			MemStack::endThread();
-		}
-	};
-}
-
+#pragma once
+
+#include "CmPrerequisitesUtil.h"
+
+#define CM_MAX_MULTIPLE_RENDER_TARGETS 8
+#define CM_FORCE_SINGLETHREADED_RENDERING 0
+
+// Windows Settings
+#if CM_PLATFORM == CM_PLATFORM_WIN32
+
+// If we're not including this from a client build, specify that the stuff
+// should get exported. Otherwise, import it.
+#	if defined(CM_STATIC_LIB)
+// Linux compilers don't have symbol import/export directives.
+#   	define BS_CORE_EXPORT
+#   else
+#   	if defined(BS_CORE_EXPORTS)
+#       	define BS_CORE_EXPORT __declspec( dllexport )
+#   	else
+#           if defined( __MINGW32__ )
+#               define BS_CORE_EXPORT
+#           else
+#       	    define BS_CORE_EXPORT __declspec( dllimport )
+#           endif
+#   	endif
+#	endif
+// Win32 compilers use _DEBUG for specifying debug builds.
+// for MinGW, we set DEBUG
+#   if defined(_DEBUG) || defined(DEBUG)
+#       define CM_DEBUG_MODE 1
+#   else
+#       define CM_DEBUG_MODE 0
+#   endif
+
+#endif
+
+// Linux/Apple Settings
+#if CM_PLATFORM == CM_PLATFORM_LINUX || CM_PLATFORM == CM_PLATFORM_APPLE
+
+// Enable GCC symbol visibility
+#   if defined( CM_GCC_VISIBILITY )
+#       define BS_CORE_EXPORT  __attribute__ ((visibility("default")))
+#       define CM_HIDDEN __attribute__ ((visibility("hidden")))
+#   else
+#       define BS_CORE_EXPORT
+#       define CM_HIDDEN
+#   endif
+
+// A quick define to overcome different names for the same function
+#   define stricmp strcasecmp
+
+#   ifdef DEBUG
+#       define CM_DEBUG_MODE 1
+#   else
+#       define CM_DEBUG_MODE 0
+#   endif
+
+#endif
+
+namespace BansheeEngine 
+{
+    class Color;
+    class GpuProgram;
+    class GpuProgramManager;
+    class IndexBuffer;
+    class OcclusionQuery;
+    class VertexBuffer;
+	class PixelBuffer;
+	class GpuBuffer;
+	class HighLevelGpuProgram;
+	class GpuProgramManager;
+	class GpuProgramFactory;
+    class IndexData;
+    class Pass;
+	class Technique;
+	class Shader;
+	class Material;
+    class RenderSystem;
+    class RenderSystemCapabilities;
+    class RenderTarget;
+    class RenderTexture;
+	class MultiRenderTexture;
+    class RenderWindow;
+    struct RenderOpMesh;
+    class StringInterface;
+    class SamplerState;
+    class TextureManager;
+    class Viewport;
+    class VertexData;
+    class VertexDeclaration;
+	class Input;
+	struct PointerEvent;
+	class RawInputHandler;
+	class Renderer;
+	class RendererFactory;
+	class PassParameters;
+	class AsyncOp;
+	class HardwareBufferManager;
+	class FontManager;
+	class DepthStencilState;
+	class RenderStateManager;
+	class RasterizerState;
+	class BlendState;
+	class GpuParamBlock;
+	class GpuParamBlockBuffer;
+	class GpuParams;
+	struct GpuParamDesc;
+	struct GpuParamDataDesc;
+	struct GpuParamObjectDesc;
+	struct GpuParamBlockDesc;
+	class GpuProgInclude;
+	class TextureView;
+	class CoreObject;
+	class ImportOptions;
+	struct FontData;
+	class GameObject;
+	class GpuResource;
+	class GpuResourceData;
+	class BindableGpuParams;
+	class BindableGpuParamBlock;
+	struct RenderOperation;
+	class RenderQueue;
+	struct ProfilerReport;
+	class VertexDataDesc;
+	class EventQuery;
+	class TimerQuery;
+	class OcclusionQuery;
+	class FrameAlloc;
+	class FolderMonitor;
+	class VideoMode;
+	class VideoOutputInfo;
+	class VideoModeInfo;
+	// Asset import
+	class SpecificImporter;
+	class Importer;
+	// Resources
+	class Resource;
+	class Resources;
+	class ResourceManifest;
+	class Texture;
+	class Mesh;
+	class MeshBase;
+	class TransientMesh;
+	class MeshHeap;
+	class Font;
+	class OSDropTarget;
+	// Scene
+	class SceneObject;
+	class Component;
+	class SceneManager;
+	// RTTI
+	class MeshRTTI;
+	// Desc structs
+	struct SAMPLER_STATE_DESC;
+	struct DEPTH_STENCIL_STATE_DESC;
+	struct RASTERIZER_STATE_DESC;
+	struct BLEND_STATE_DESC;
+	struct RENDER_TARGET_BLEND_STATE_DESC;
+	struct RENDER_TEXTURE_DESC;
+	struct RENDER_WINDOW_DESC;
+	struct FONT_DESC;
+
+	template<class T>
+	class CoreThreadAccessor;
+	class CommandQueueNoSync;
+	class CommandQueueSync;
+}
+
+/************************************************************************/
+/* 						Shared pointer typedefs	                    	*/
+/************************************************************************/
+
+namespace BansheeEngine
+{
+	typedef std::shared_ptr<RenderSystem> RenderSystemPtr;
+	typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
+	typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
+	typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
+	typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
+	typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
+	typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
+	typedef std::shared_ptr<Mesh> MeshPtr;
+	typedef std::shared_ptr<MeshBase> MeshBasePtr;
+	typedef std::shared_ptr<MeshHeap> MeshHeapPtr;
+	typedef std::shared_ptr<TransientMesh> TransientMeshPtr;
+	typedef std::shared_ptr<Texture> TexturePtr;
+	typedef std::shared_ptr<Resource> ResourcePtr;
+	typedef std::shared_ptr<Technique> TechniquePtr;
+	typedef std::shared_ptr<Pass> PassPtr;
+	typedef std::shared_ptr<Shader> ShaderPtr;
+	typedef std::shared_ptr<Material> MaterialPtr;
+	typedef std::shared_ptr<Renderer> RendererPtr;
+	typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
+	typedef std::shared_ptr<PassParameters> PassParametersPtr;
+	typedef std::shared_ptr<Component> ComponentPtr;
+	typedef std::shared_ptr<SceneObject> GameObjectPtr;
+	typedef std::shared_ptr<SamplerState> SamplerStatePtr;
+	typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
+	typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
+	typedef std::shared_ptr<BlendState> BlendStatePtr;
+	typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
+	typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
+	typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
+	typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
+	typedef std::shared_ptr<GpuParamBlock> GpuParamBlockPtr;
+	typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
+	typedef std::shared_ptr<GpuParams> GpuParamsPtr;
+	typedef std::shared_ptr<TextureView> TextureViewPtr;
+	typedef std::shared_ptr<Viewport> ViewportPtr;
+	typedef std::shared_ptr<GpuProgInclude> GpuProgIncludePtr;
+	typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
+	typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
+	typedef std::shared_ptr<Font> FontPtr;
+	typedef std::shared_ptr<GpuResource> GpuResourcePtr;
+	typedef std::shared_ptr<VertexDataDesc> VertexDataDescPtr;
+	typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
+	typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
+	typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
+	typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
+	typedef std::shared_ptr<EventQuery> EventQueryPtr;
+	typedef std::shared_ptr<TimerQuery> TimerQueryPtr;
+	typedef std::shared_ptr<OcclusionQuery> OcclusionQueryPtr;
+	typedef std::shared_ptr<ResourceManifest> ResourceManifestPtr;
+	typedef std::shared_ptr<VideoModeInfo> VideoModeInfoPtr;
+}
+
+/************************************************************************/
+/* 									RTTI                      			*/
+/************************************************************************/
+namespace BansheeEngine
+{
+	enum TypeID_Core
+	{
+		TID_Texture = 1001,
+		TID_Mesh = 1002,
+		TID_MeshData = 1003,
+		TID_VertexDeclaration = 1004,
+		TID_VertexElementData = 1005,
+		TID_Component = 1006,
+		TID_ResourceHandle = 1009,
+		TID_GpuProgram = 1010,
+		TID_ResourceHandleData = 1011,
+		TID_CgProgram = 1012,
+		TID_Pass = 1014,
+		TID_Technique = 1015,
+		TID_Shader = 1016,
+		TID_Material = 1017,
+		TID_MaterialParams = 1018,
+		TID_FloatParamKVP = 1019,
+		TID_MaterialTexParamKVP = 1020,
+		TID_SamplerState = 1021,
+		TID_SamplerStateParamKVP = 1022,
+		TID_BlendState = 1023,
+		TID_RasterizerState = 1024,
+		TID_DepthStencilState = 1025,
+		TID_MaterialParamFloat = 1026,
+		TID_MaterialParamVec2 = 1027,
+		TID_MaterialParamVec3 = 1028,
+		TID_MaterialParamVec4 = 1029,
+		TID_MaterialParamMat3 = 1030,
+		TID_MaterialParamMat4 = 1031,
+		TID_MaterialParamTexture = 1032,
+		TID_MaterialParamSamplerState = 1033,
+		TID_BLEND_STATE_DESC = 1034,
+		TID_SHADER_DATA_PARAM_DESC = 1035,
+		TID_SHADER_OBJECT_PARAM_DESC = 1036,
+		TID_SHADER_PARAM_BLOCK_DESC = 1047,
+		TID_ImportOptions = 1048,
+		TID_GpuProgramImportOptions = 1049,
+		TID_MaterialParamStruct = 1050,
+		TID_Font = 1051,
+		TID_FONT_DESC = 1052,
+		TID_CHAR_DESC = 1053,
+		TID_FontImportOptions = 1056,
+		TID_FontData = 1057,
+		TID_SceneObject = 1059,
+		TID_GameObject = 1060,
+		TID_GpuResource = 1061,
+		TID_PixelData = 1062,
+		TID_GpuResourceData = 1063,
+		TID_VertexDataDesc = 1064,
+		TID_MeshBase = 1065,
+		TID_GameObjectHandleBase = 1066,
+		TID_ResourceManifest = 1067,
+		TID_ResourceManifestEntry = 1068
+	};
+}
+
+/************************************************************************/
+/* 							Resource references                   		*/
+/************************************************************************/
+
+#include "CmResourceHandle.h"
+
+namespace BansheeEngine
+{
+	// Resource handles
+	typedef ResourceHandle<Resource> HResource;
+	typedef ResourceHandle<Texture> HTexture;
+	typedef ResourceHandle<Mesh> HMesh;
+	typedef ResourceHandle<GpuProgram> HGpuProgram;
+	typedef ResourceHandle<Material> HMaterial;
+	typedef ResourceHandle<SamplerState> HSamplerState;
+	typedef ResourceHandle<RasterizerState> HRasterizerState;
+	typedef ResourceHandle<DepthStencilState> HDepthStencilState;
+	typedef ResourceHandle<BlendState> HBlendState;
+	typedef ResourceHandle<GpuProgInclude> HGpuProgInclude;
+	typedef ResourceHandle<Font> HFont;
+}
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Defers function execution until the next frame. If this function is called
+	 * 			within another deferred call, then it will be executed the same frame,
+	 * 			but only after all existing deferred calls are done.
+	 * 			
+	 * @note	This method can be used for breaking dependencies among other things. If a class
+	 * 			A depends on class B having something done, but class B also depends in some way on class A,
+	 * 			you can break up the initialization into two separate steps, queuing the second step
+	 * 			using this method.
+	 * 			
+	 *			Similar situation can happen if you have multiple classes being initialized in an undefined order
+	 *			but some of them depend on others. Using this method you can defer the dependent step until next frame,
+	 *			which will ensure everything was initialized.
+	 *
+	 * @param	callback	The callback.
+	 */
+	void BS_CORE_EXPORT deferredCall(std::function<void()> callback);
+
+	// Special types for use by profilers
+	typedef std::basic_string<char, std::char_traits<char>, StdAlloc<char, ProfilerAlloc>> ProfilerString;
+
+	template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
+	using ProfilerVector = std::vector<T, A>;
+
+	template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
+	using ProfilerStack = std::stack<T, std::deque<T, A>>;
+
+	/**
+	* @brief	Banshee thread policy that performs special startup/shutdown on threads
+	*			managed by thread pool.
+	*/
+	class BS_CORE_EXPORT ThreadBansheePolicy
+	{
+	public:
+		static void onThreadStarted(const String& name)
+		{
+			MemStack::beginThread();
+		}
+
+		static void onThreadEnded(const String& name)
+		{
+			MemStack::endThread();
+		}
+	};
+}
+
 #include "BsCommonTypes.h"

+ 145 - 145
CamelotCore/Include/CmProfiler.h → BansheeCore/Include/CmProfiler.h

@@ -1,146 +1,146 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmCPUProfiler.h"
-
-namespace BansheeEngine
-{
-/**
- * @brief	Shortcut for profiling a single function call.
- */
-#define PROFILE_CALL(call, name)						\
-	BansheeEngine::gProfiler().beginSample(##name##);	\
-	call;												\
-	BansheeEngine::gProfiler().endSample(##name##);
-
-	/**
-	 * @brief	Contains data about a profiling session.
-	 */
-	struct ProfilerReport
-	{
-		CPUProfilerReport cpuReport;
-	};
-
-	/**
-	 * @brief	Type of thread used by the profiler.
-	 */
-	enum class ProfiledThread
-	{
-		Sim,
-		Core
-	};
-
-	/**
-	 * @brief	Provides performance measuring methods for the CPU.
-	 */
-	class CM_EXPORT Profiler : public Module<Profiler>
-	{
-	public:
-		Profiler();
-		~Profiler();
-
-		/**
-		 * @copydoc CPUProfiler::beginThread
-		 */
-		void beginThread(const ProfilerString& name) 
-		{ 
-#if CM_PROFILING_ENABLED
-			mCPUProfiler->beginThread(name); 
-#endif
-		}
-
-		/**
-		 * @copydoc CPUProfiler::endThread
-		 */
-		void endThread() 
-		{ 
-#if CM_PROFILING_ENABLED
-			mCPUProfiler->endThread(); 
-#endif
-		}
-
-		/**
-		 * @copydoc CPUProfiler::beginSample
-		 */
-		void beginSample(const ProfilerString& name) 
-		{ 
-#if CM_PROFILING_ENABLED
-			mCPUProfiler->beginSample(name); 
-#endif
-		}
-
-		/**
-		 * @copydoc CPUProfiler::endSample
-		 */
-		void endSample(const ProfilerString& name) 
-		{ 
-#if CM_PROFILING_ENABLED
-			mCPUProfiler->endSample(name); 
-#endif
-		}
-
-		/**
-		 * @copydoc CPUProfiler::beginSamplePrecise
-		 */
-		void beginSamplePrecise(const ProfilerString& name) 
-		{ 
-#if CM_PROFILING_ENABLED
-			mCPUProfiler->beginSamplePrecise(name); 
-#endif
-		}
-
-		/**
-		 * @copydoc CPUProfiler::endSamplePrecise
-		 */
-		void endSamplePrecise(const ProfilerString& name) 
-		{ 
-#if CM_PROFILING_ENABLED
-			mCPUProfiler->endSamplePrecise(name); 
-#endif
-		}
-
-		/**
-		 * @brief	Called every frame.
-		 *
-		 * @note	Internal method.
-		 */
-		void _update();
-
-		/**
-		 * @brief	Called every frame from the core thread.
-		 * 			
-		 * @note	Internal method. Only call from core thread.
-		 */
-		void _updateCore();
-
-		/**
-		 * @brief	Returns a profiler report for the specified frame, for the specified thread.
-		 *
-		 * @param	Profiler report index, ranging [0, NUM_SAVED_FRAMES]. 0 always returns the latest
-		 * 					 report. Increasing indexes return reports for older and older frames. Out of range
-		 * 					 indexes will be clamped.
-		 *
-		 * @note	Profiler reports get updated every frame. Oldest reports that no longer fit in the saved reports buffer
-		 * 			are discarded.
-		 */
-		const ProfilerReport& getReport(ProfiledThread thread, UINT32 idx = 0) const;
-
-	private:
-		static const UINT32 NUM_SAVED_FRAMES;
-		ProfilerReport* mSavedSimReports;
-		UINT32 mNextSimReportIdx;
-
-		ProfilerReport* mSavedCoreReports;
-		UINT32 mNextCoreReportIdx;
-
-		CPUProfiler* mCPUProfiler;
-
-		CM_MUTEX(mSync);
-	};
-
-	/**
-	 * @brief	Quick way to access the profiler.
-	 */
-	CM_EXPORT Profiler& gProfiler();
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmCPUProfiler.h"
+
+namespace BansheeEngine
+{
+/**
+ * @brief	Shortcut for profiling a single function call.
+ */
+#define PROFILE_CALL(call, name)						\
+	BansheeEngine::gProfiler().beginSample(##name##);	\
+	call;												\
+	BansheeEngine::gProfiler().endSample(##name##);
+
+	/**
+	 * @brief	Contains data about a profiling session.
+	 */
+	struct ProfilerReport
+	{
+		CPUProfilerReport cpuReport;
+	};
+
+	/**
+	 * @brief	Type of thread used by the profiler.
+	 */
+	enum class ProfiledThread
+	{
+		Sim,
+		Core
+	};
+
+	/**
+	 * @brief	Provides performance measuring methods for the CPU.
+	 */
+	class BS_CORE_EXPORT Profiler : public Module<Profiler>
+	{
+	public:
+		Profiler();
+		~Profiler();
+
+		/**
+		 * @copydoc CPUProfiler::beginThread
+		 */
+		void beginThread(const ProfilerString& name) 
+		{ 
+#if CM_PROFILING_ENABLED
+			mCPUProfiler->beginThread(name); 
+#endif
+		}
+
+		/**
+		 * @copydoc CPUProfiler::endThread
+		 */
+		void endThread() 
+		{ 
+#if CM_PROFILING_ENABLED
+			mCPUProfiler->endThread(); 
+#endif
+		}
+
+		/**
+		 * @copydoc CPUProfiler::beginSample
+		 */
+		void beginSample(const ProfilerString& name) 
+		{ 
+#if CM_PROFILING_ENABLED
+			mCPUProfiler->beginSample(name); 
+#endif
+		}
+
+		/**
+		 * @copydoc CPUProfiler::endSample
+		 */
+		void endSample(const ProfilerString& name) 
+		{ 
+#if CM_PROFILING_ENABLED
+			mCPUProfiler->endSample(name); 
+#endif
+		}
+
+		/**
+		 * @copydoc CPUProfiler::beginSamplePrecise
+		 */
+		void beginSamplePrecise(const ProfilerString& name) 
+		{ 
+#if CM_PROFILING_ENABLED
+			mCPUProfiler->beginSamplePrecise(name); 
+#endif
+		}
+
+		/**
+		 * @copydoc CPUProfiler::endSamplePrecise
+		 */
+		void endSamplePrecise(const ProfilerString& name) 
+		{ 
+#if CM_PROFILING_ENABLED
+			mCPUProfiler->endSamplePrecise(name); 
+#endif
+		}
+
+		/**
+		 * @brief	Called every frame.
+		 *
+		 * @note	Internal method.
+		 */
+		void _update();
+
+		/**
+		 * @brief	Called every frame from the core thread.
+		 * 			
+		 * @note	Internal method. Only call from core thread.
+		 */
+		void _updateCore();
+
+		/**
+		 * @brief	Returns a profiler report for the specified frame, for the specified thread.
+		 *
+		 * @param	Profiler report index, ranging [0, NUM_SAVED_FRAMES]. 0 always returns the latest
+		 * 					 report. Increasing indexes return reports for older and older frames. Out of range
+		 * 					 indexes will be clamped.
+		 *
+		 * @note	Profiler reports get updated every frame. Oldest reports that no longer fit in the saved reports buffer
+		 * 			are discarded.
+		 */
+		const ProfilerReport& getReport(ProfiledThread thread, UINT32 idx = 0) const;
+
+	private:
+		static const UINT32 NUM_SAVED_FRAMES;
+		ProfilerReport* mSavedSimReports;
+		UINT32 mNextSimReportIdx;
+
+		ProfilerReport* mSavedCoreReports;
+		UINT32 mNextCoreReportIdx;
+
+		CPUProfiler* mCPUProfiler;
+
+		CM_MUTEX(mSync);
+	};
+
+	/**
+	 * @brief	Quick way to access the profiler.
+	 */
+	BS_CORE_EXPORT Profiler& gProfiler();
 }

+ 70 - 70
CamelotCore/Include/CmQueryManager.h → BansheeCore/Include/CmQueryManager.h

@@ -1,71 +1,71 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmEventQuery.h"
-#include "CmModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation and destruction of GPU queries.
-	 * 			
-	 * @note	Core thread only.
-	 */
-	class CM_EXPORT QueryManager : public Module<QueryManager>
-	{
-	public:
-		QueryManager();
-
-		/**
-		 * @brief	Creates a new event query that allows you to get notified
-		 *			when GPU starts executing the query.
-		 */
-		virtual EventQueryPtr createEventQuery() const = 0;
-
-		/**
-		* @brief	Creates a new timer query that allows you to get notified
-		*			of how much time has passed between query start and end.
-		*/
-		virtual TimerQueryPtr createTimerQuery() const = 0;
-
-		/**
-		* @brief	Creates a new occlusion query that allows you to know
-		*			how many fragments were rendered between query start and end.
-		*
-		* @param binary	If query is binary it will not give you an exact count of fragments rendered, but will instead
-		*				just return 0 (no fragments were rendered) or 1 (one or more fragments were rendered). Binary
-		*				queries can return sooner as they potentially do not need to wait until all of the geometry is rendered.
-		*/
-		virtual OcclusionQueryPtr createOcclusionQuery(bool binary) const = 0;
-
-		/**
-		 * @note	Internal method, called every frame.
-		 */
-		void _update();
-
-	protected:
-		friend class EventQuery;
-		friend class TimerQuery;
-		friend class OcclusionQuery;
-
-		/**
-		 * @brief	Deletes an Event query. Always use this method and don't delete them manually.
-		 */
-		static void deleteEventQuery(EventQuery* query);
-
-		/**
-		* @brief	Deletes a Timer query. Always use this method and don't delete them manually.
-		*/
-		static void deleteTimerQuery(TimerQuery* query);
-
-		/**
-		* @brief	Deletes an Occlusion query. Always use this method and don't delete them manually.
-		*/
-		static void deleteOcclusionQuery(OcclusionQuery* query);
-
-	protected:
-		mutable Vector<EventQuery*> mEventQueries;
-		mutable Vector<TimerQuery*> mTimerQueries;
-		mutable Vector<OcclusionQuery*> mOcclusionQueries;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmEventQuery.h"
+#include "CmModule.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Handles creation and destruction of GPU queries.
+	 * 			
+	 * @note	Core thread only.
+	 */
+	class BS_CORE_EXPORT QueryManager : public Module<QueryManager>
+	{
+	public:
+		QueryManager();
+
+		/**
+		 * @brief	Creates a new event query that allows you to get notified
+		 *			when GPU starts executing the query.
+		 */
+		virtual EventQueryPtr createEventQuery() const = 0;
+
+		/**
+		* @brief	Creates a new timer query that allows you to get notified
+		*			of how much time has passed between query start and end.
+		*/
+		virtual TimerQueryPtr createTimerQuery() const = 0;
+
+		/**
+		* @brief	Creates a new occlusion query that allows you to know
+		*			how many fragments were rendered between query start and end.
+		*
+		* @param binary	If query is binary it will not give you an exact count of fragments rendered, but will instead
+		*				just return 0 (no fragments were rendered) or 1 (one or more fragments were rendered). Binary
+		*				queries can return sooner as they potentially do not need to wait until all of the geometry is rendered.
+		*/
+		virtual OcclusionQueryPtr createOcclusionQuery(bool binary) const = 0;
+
+		/**
+		 * @note	Internal method, called every frame.
+		 */
+		void _update();
+
+	protected:
+		friend class EventQuery;
+		friend class TimerQuery;
+		friend class OcclusionQuery;
+
+		/**
+		 * @brief	Deletes an Event query. Always use this method and don't delete them manually.
+		 */
+		static void deleteEventQuery(EventQuery* query);
+
+		/**
+		* @brief	Deletes a Timer query. Always use this method and don't delete them manually.
+		*/
+		static void deleteTimerQuery(TimerQuery* query);
+
+		/**
+		* @brief	Deletes an Occlusion query. Always use this method and don't delete them manually.
+		*/
+		static void deleteOcclusionQuery(OcclusionQuery* query);
+
+	protected:
+		mutable Vector<EventQuery*> mEventQueries;
+		mutable Vector<TimerQuery*> mTimerQueries;
+		mutable Vector<OcclusionQuery*> mOcclusionQueries;
+	};
 }

+ 147 - 147
CamelotCore/Include/CmRasterizerState.h → BansheeCore/Include/CmRasterizerState.h

@@ -1,148 +1,148 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmResource.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Structure that describes pipeline rasterizer state. Used for initializing
-	 *			a RasterizerState.
-	 *
-	 * @see		RasterizerState
-	 */
-	struct CM_EXPORT RASTERIZER_STATE_DESC
-	{
-		RASTERIZER_STATE_DESC()
-			: polygonMode(PM_SOLID)
-			, cullMode(CULL_COUNTERCLOCKWISE)
-			, depthBias(0)
-			, depthBiasClamp(0.0f)
-			, slopeScaledDepthBias(0.0f)
-			, depthClipEnable(true)
-			, scissorEnable(false)
-			, multisampleEnable(true)
-			, antialiasedLineEnable(false)
-		{ }
-
-		PolygonMode polygonMode;
-		CullingMode cullMode;
-
-		int depthBias;
-		float depthBiasClamp;
-		float slopeScaledDepthBias;
-
-		bool depthClipEnable;
-		bool scissorEnable;
-		bool multisampleEnable;
-		bool antialiasedLineEnable;
-	};
-
-	/**
-	 * @brief	Render system pipeline state that allows you to modify how an object is rasterized.
-	 *			i.e. how are polygons converted to pixels.
-	 *
-	 * @note	Rasterizer states are immutable. Thread safe.
-	 */
-	class CM_EXPORT RasterizerState : public Resource
-	{
-	public:
-		virtual ~RasterizerState() {}
-
-		/**
-		 * @brief	Polygon mode allows you to draw polygons as solid objects or as wireframe by
-		 *			just drawing their edges.
-		 */
-		PolygonMode getPolygonMode() const { return mData.polygonMode; }
-
-		/**
-		 * @brief	Sets vertex winding order. Faces that contain vertices with this order will 
-		 *			be culled and not rasterized. Used primarily for saving cycles by not rendering
-		 *			backfacing faces.
-		 */
-		CullingMode getCullMode() const { return mData.cullMode; }
-
-		/**
-		* @brief	Represents a constant depth bias that will offset the depth values of new pixels 
-		*			by the specified amount.
-		*
-		* @note		This is useful if you want to avoid z fighting for objects at the same or similar depth.
-		*/
-		int getDepthBias() const { return mData.depthBias; }
-
-		/**
-		 * @brief	Maximum depth bias value.
-		 */
-		float getDepthBiasClamp() const { return mData.depthBiasClamp; }
-
-		/**
-		 * @brief	Represents a dynamic depth bias that increases as the slope of the rendered polygons 
-		 *			surface increases. Resulting value offsets depth values of new pixels. This offset will 
-		 *			be added on top of the constant depth bias.
-		 *
-		 * @note	This is useful if you want to avoid z fighting for objects at the same or similar depth.
-		 */
-		float getSlopeScaledDepthBias() const { return mData.slopeScaledDepthBias; }
-
-		/**
-		 * @brief	If true, clipping of polygons past the far Z plane is enabled. This ensures proper
-		 *			Z ordering for polygons outside of valid depth range (otherwise they all have the same
-		 *			depth). It can be useful to disable if you are performing stencil operations that count on
-		 *			objects having a front and a back (like stencil shadow) and don't want to clip the back.
-		 */
-		bool getDepthClipEnable() const { return mData.depthClipEnable; }
-
-		/**
-		 * @brief	Scissor rectangle allows you to cull all pixels outside of the scissor rectangle.
-		 *			
-		 * @see		RenderSystem::setScissorRect
-		 */
-		bool getScissorEnable() const { return mData.scissorEnable; }
-
-		/**
-		 * @brief	Determines how are samples in multi-sample render targets handled.
-		 *			If disabled all samples in the render target will be written the same value, 
-		 *			and if enabled each sample will be generated separately.
-		 *			
-		 * @note	In order to get an antialiased image you need to both enable this option and use
-		 *			a MSAA render target.
-		 */
-		bool getMultisampleEnable() const { return mData.multisampleEnable; }
-
-		/**
-		 * @brief	Determines should the lines be antialiased. This is separate from multi-sample
-		 *			antialiasing setting as lines can be antialiased without multi-sampling.
-		 *
-		 * @note	This setting is usually ignored if MSAA is used, as that provides sufficient antialiasing.
-		 */
-		bool getAntialiasedLineEnable() const { return mData.antialiasedLineEnable; }
-
-		/**
-		 * @brief	Creates a new rasterizer state using the specified rasterizer state descriptor structure.
-		 */
-		static HRasterizerState create(const RASTERIZER_STATE_DESC& desc);
-
-		/**
-		 * @brief	Returns the default rasterizer state.
-		 */
-		static const RasterizerStatePtr& getDefault();
-
-	protected:
-		friend class RenderStateManager;
-
-		/**
-		* @brief	Initializes the rasterizer state. Must be called right after construction.
-		*/
-		virtual void initialize(const RASTERIZER_STATE_DESC& desc);
-		RASTERIZER_STATE_DESC mData;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-
-	public:
-		friend class RasterizerStateRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;	
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmResource.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Structure that describes pipeline rasterizer state. Used for initializing
+	 *			a RasterizerState.
+	 *
+	 * @see		RasterizerState
+	 */
+	struct BS_CORE_EXPORT RASTERIZER_STATE_DESC
+	{
+		RASTERIZER_STATE_DESC()
+			: polygonMode(PM_SOLID)
+			, cullMode(CULL_COUNTERCLOCKWISE)
+			, depthBias(0)
+			, depthBiasClamp(0.0f)
+			, slopeScaledDepthBias(0.0f)
+			, depthClipEnable(true)
+			, scissorEnable(false)
+			, multisampleEnable(true)
+			, antialiasedLineEnable(false)
+		{ }
+
+		PolygonMode polygonMode;
+		CullingMode cullMode;
+
+		int depthBias;
+		float depthBiasClamp;
+		float slopeScaledDepthBias;
+
+		bool depthClipEnable;
+		bool scissorEnable;
+		bool multisampleEnable;
+		bool antialiasedLineEnable;
+	};
+
+	/**
+	 * @brief	Render system pipeline state that allows you to modify how an object is rasterized.
+	 *			i.e. how are polygons converted to pixels.
+	 *
+	 * @note	Rasterizer states are immutable. Thread safe.
+	 */
+	class BS_CORE_EXPORT RasterizerState : public Resource
+	{
+	public:
+		virtual ~RasterizerState() {}
+
+		/**
+		 * @brief	Polygon mode allows you to draw polygons as solid objects or as wireframe by
+		 *			just drawing their edges.
+		 */
+		PolygonMode getPolygonMode() const { return mData.polygonMode; }
+
+		/**
+		 * @brief	Sets vertex winding order. Faces that contain vertices with this order will 
+		 *			be culled and not rasterized. Used primarily for saving cycles by not rendering
+		 *			backfacing faces.
+		 */
+		CullingMode getCullMode() const { return mData.cullMode; }
+
+		/**
+		* @brief	Represents a constant depth bias that will offset the depth values of new pixels 
+		*			by the specified amount.
+		*
+		* @note		This is useful if you want to avoid z fighting for objects at the same or similar depth.
+		*/
+		int getDepthBias() const { return mData.depthBias; }
+
+		/**
+		 * @brief	Maximum depth bias value.
+		 */
+		float getDepthBiasClamp() const { return mData.depthBiasClamp; }
+
+		/**
+		 * @brief	Represents a dynamic depth bias that increases as the slope of the rendered polygons 
+		 *			surface increases. Resulting value offsets depth values of new pixels. This offset will 
+		 *			be added on top of the constant depth bias.
+		 *
+		 * @note	This is useful if you want to avoid z fighting for objects at the same or similar depth.
+		 */
+		float getSlopeScaledDepthBias() const { return mData.slopeScaledDepthBias; }
+
+		/**
+		 * @brief	If true, clipping of polygons past the far Z plane is enabled. This ensures proper
+		 *			Z ordering for polygons outside of valid depth range (otherwise they all have the same
+		 *			depth). It can be useful to disable if you are performing stencil operations that count on
+		 *			objects having a front and a back (like stencil shadow) and don't want to clip the back.
+		 */
+		bool getDepthClipEnable() const { return mData.depthClipEnable; }
+
+		/**
+		 * @brief	Scissor rectangle allows you to cull all pixels outside of the scissor rectangle.
+		 *			
+		 * @see		RenderSystem::setScissorRect
+		 */
+		bool getScissorEnable() const { return mData.scissorEnable; }
+
+		/**
+		 * @brief	Determines how are samples in multi-sample render targets handled.
+		 *			If disabled all samples in the render target will be written the same value, 
+		 *			and if enabled each sample will be generated separately.
+		 *			
+		 * @note	In order to get an antialiased image you need to both enable this option and use
+		 *			a MSAA render target.
+		 */
+		bool getMultisampleEnable() const { return mData.multisampleEnable; }
+
+		/**
+		 * @brief	Determines should the lines be antialiased. This is separate from multi-sample
+		 *			antialiasing setting as lines can be antialiased without multi-sampling.
+		 *
+		 * @note	This setting is usually ignored if MSAA is used, as that provides sufficient antialiasing.
+		 */
+		bool getAntialiasedLineEnable() const { return mData.antialiasedLineEnable; }
+
+		/**
+		 * @brief	Creates a new rasterizer state using the specified rasterizer state descriptor structure.
+		 */
+		static HRasterizerState create(const RASTERIZER_STATE_DESC& desc);
+
+		/**
+		 * @brief	Returns the default rasterizer state.
+		 */
+		static const RasterizerStatePtr& getDefault();
+
+	protected:
+		friend class RenderStateManager;
+
+		/**
+		* @brief	Initializes the rasterizer state. Must be called right after construction.
+		*/
+		virtual void initialize(const RASTERIZER_STATE_DESC& desc);
+		RASTERIZER_STATE_DESC mData;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+	public:
+		friend class RasterizerStateRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;	
+	};
 }

+ 53 - 53
CamelotCore/Include/CmRasterizerStateRTTI.h → BansheeCore/Include/CmRasterizerStateRTTI.h

@@ -1,54 +1,54 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmRasterizerState.h"
-#include "CmRenderStateManager.h"
-
-namespace BansheeEngine
-{
-	CM_ALLOW_MEMCPY_SERIALIZATION(RASTERIZER_STATE_DESC);
-
-	class CM_EXPORT RasterizerStateRTTI : public RTTIType<RasterizerState, IReflectable, RasterizerStateRTTI>
-	{
-	private:
-		RASTERIZER_STATE_DESC& getData(RasterizerState* obj) { return obj->mData; }
-		void setData(RasterizerState* obj, RASTERIZER_STATE_DESC& val) 
-		{ 
-			obj->mRTTIData = val;
-		} 
-
-	public:
-		RasterizerStateRTTI()
-		{
-			addPlainField("mData", 0, &RasterizerStateRTTI::getData, &RasterizerStateRTTI::setData);
-		}
-
-		virtual void onDeserializationEnded(IReflectable* obj)
-		{
-			RasterizerState* rasterizerState = static_cast<RasterizerState*>(obj);
-			if(!rasterizerState->mRTTIData.empty())
-			{
-				RASTERIZER_STATE_DESC desc = any_cast<RASTERIZER_STATE_DESC>(rasterizerState->mRTTIData);
-
-				rasterizerState->initialize(desc);
-			}
-		}
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "RasterizerState";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_RasterizerState;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return RenderStateManager::instance().createEmptyRasterizerState();
-		}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmRTTIType.h"
+#include "CmRasterizerState.h"
+#include "CmRenderStateManager.h"
+
+namespace BansheeEngine
+{
+	CM_ALLOW_MEMCPY_SERIALIZATION(RASTERIZER_STATE_DESC);
+
+	class BS_CORE_EXPORT RasterizerStateRTTI : public RTTIType<RasterizerState, IReflectable, RasterizerStateRTTI>
+	{
+	private:
+		RASTERIZER_STATE_DESC& getData(RasterizerState* obj) { return obj->mData; }
+		void setData(RasterizerState* obj, RASTERIZER_STATE_DESC& val) 
+		{ 
+			obj->mRTTIData = val;
+		} 
+
+	public:
+		RasterizerStateRTTI()
+		{
+			addPlainField("mData", 0, &RasterizerStateRTTI::getData, &RasterizerStateRTTI::setData);
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj)
+		{
+			RasterizerState* rasterizerState = static_cast<RasterizerState*>(obj);
+			if(!rasterizerState->mRTTIData.empty())
+			{
+				RASTERIZER_STATE_DESC desc = any_cast<RASTERIZER_STATE_DESC>(rasterizerState->mRTTIData);
+
+				rasterizerState->initialize(desc);
+			}
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "RasterizerState";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_RasterizerState;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return RenderStateManager::instance().createEmptyRasterizerState();
+		}
+	};
 }

+ 94 - 94
CamelotCore/Include/CmRawInputHandler.h → BansheeCore/Include/CmRawInputHandler.h

@@ -1,95 +1,95 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmInputFwd.h"
-#include "BsEvent.h"
-#include "CmVector2I.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains relative and absolute position
-	 * 			of an input axis. Relative state represents
-	 * 			the difference between current and last state.
-	 */
-	struct RawAxisState
-	{
-		Vector2I rel;
-		Vector2I abs;
-	};
-
-	/**
-	 * @brief	Different types of input axes.
-	 */
-	enum class RawInputAxis
-	{
-		Mouse_XY,
-		Mouse_Z,
-		Joy_1,
-		Joy_2,
-		Joy_3,
-		Joy_4,
-		Joy_5,
-		Joy_6,
-		Joy_7,
-		Joy_8,
-		Joy_9,
-		Joy_10,
-		Joy_11,
-		Joy_12,
-		Joy_13,
-		Joy_14,
-		Joy_15,
-		Joy_16,
-		Count
-	};
-
-	/**
-	 * @brief	Represents a specific way of acquiring low-level input. InputManager (which provides a higher level input)
-	 * 			must have at least one RawInputHandler attached. Raw input handlers receive input as sent by the hardware
-	 * 			without OS modifications.
-	 * 			
-	 *			Attach events handler to the provided signals to handle input.
-	 */
-	class CM_EXPORT RawInputHandler
-	{
-	public:
-		RawInputHandler() {}
-		virtual ~RawInputHandler() {}
-
-		/**
-		 * @brief	Triggered when user presses a button. Parameters
-		 * 			include button code of the pressed button, and a timestamp of
-		 * 			the button press event.
-		 */
-		Event<void(ButtonCode, UINT64)> onButtonDown;
-
-		/**
-		 * @brief	Triggered when user releases a button. Parameters
-		 * 			include button code of the released button, and a timestamp of
-		 * 			the button release event.
-		 */
-		Event<void(ButtonCode, UINT64)> onButtonUp;
-
-		/**
-		 * @brief	Triggered whenever the specified axis state changes.
-		 */
-		Event<void(const RawAxisState&, RawInputAxis)> onAxisMoved;
-
-		/**
-		 * @brief	Called once per frame. Capture input here if needed.
-		 * 			
-		 * @note	Internal method.
-		 */
-		virtual void _update() {}
-
-		/**
-		 * @brief	Called whenever the active window changes.
-		 *
-		 * @param	win	Newly active window.
-		 * 				
-		 * @note	Internal method.
-		 */
-		virtual void _inputWindowChanged(const RenderWindow& win) {}
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmInputFwd.h"
+#include "BsEvent.h"
+#include "CmVector2I.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Contains relative and absolute position
+	 * 			of an input axis. Relative state represents
+	 * 			the difference between current and last state.
+	 */
+	struct RawAxisState
+	{
+		Vector2I rel;
+		Vector2I abs;
+	};
+
+	/**
+	 * @brief	Different types of input axes.
+	 */
+	enum class RawInputAxis
+	{
+		Mouse_XY,
+		Mouse_Z,
+		Joy_1,
+		Joy_2,
+		Joy_3,
+		Joy_4,
+		Joy_5,
+		Joy_6,
+		Joy_7,
+		Joy_8,
+		Joy_9,
+		Joy_10,
+		Joy_11,
+		Joy_12,
+		Joy_13,
+		Joy_14,
+		Joy_15,
+		Joy_16,
+		Count
+	};
+
+	/**
+	 * @brief	Represents a specific way of acquiring low-level input. InputManager (which provides a higher level input)
+	 * 			must have at least one RawInputHandler attached. Raw input handlers receive input as sent by the hardware
+	 * 			without OS modifications.
+	 * 			
+	 *			Attach events handler to the provided signals to handle input.
+	 */
+	class BS_CORE_EXPORT RawInputHandler
+	{
+	public:
+		RawInputHandler() {}
+		virtual ~RawInputHandler() {}
+
+		/**
+		 * @brief	Triggered when user presses a button. Parameters
+		 * 			include button code of the pressed button, and a timestamp of
+		 * 			the button press event.
+		 */
+		Event<void(ButtonCode, UINT64)> onButtonDown;
+
+		/**
+		 * @brief	Triggered when user releases a button. Parameters
+		 * 			include button code of the released button, and a timestamp of
+		 * 			the button release event.
+		 */
+		Event<void(ButtonCode, UINT64)> onButtonUp;
+
+		/**
+		 * @brief	Triggered whenever the specified axis state changes.
+		 */
+		Event<void(const RawAxisState&, RawInputAxis)> onAxisMoved;
+
+		/**
+		 * @brief	Called once per frame. Capture input here if needed.
+		 * 			
+		 * @note	Internal method.
+		 */
+		virtual void _update() {}
+
+		/**
+		 * @brief	Called whenever the active window changes.
+		 *
+		 * @param	win	Newly active window.
+		 * 				
+		 * @note	Internal method.
+		 */
+		virtual void _inputWindowChanged(const RenderWindow& win) {}
+	};
 }

+ 22 - 22
CamelotCore/Include/CmRenderOperation.h → BansheeCore/Include/CmRenderOperation.h

@@ -1,23 +1,23 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmDrawOps.h"
-#include "CmVector3.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	A render operation describing everything we need for rendering
-	 * 			a single object.
-	 */
-	struct CM_EXPORT RenderOperation
-	{
-		RenderOperation()
-		{ }
-
-		MaterialPtr material;
-		MeshBasePtr mesh;
-		UINT32 submeshIdx;
-		Vector3 worldPosition;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmDrawOps.h"
+#include "CmVector3.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	A render operation describing everything we need for rendering
+	 * 			a single object.
+	 */
+	struct BS_CORE_EXPORT RenderOperation
+	{
+		RenderOperation()
+		{ }
+
+		MaterialPtr material;
+		MeshBasePtr mesh;
+		UINT32 submeshIdx;
+		Vector3 worldPosition;
+	};
 }

+ 64 - 64
CamelotCore/Include/CmRenderQueue.h → BansheeCore/Include/CmRenderQueue.h

@@ -1,65 +1,65 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Slightly more fine grained version of RenderOperation, as each pass
-	 * 			is specified as an individual operation. Used for sorting within the RenderQueue.
-	 */
-	struct CM_EXPORT SortedRenderOp
-	{
-		SortedRenderOp()
-			:baseOperation(nullptr), passIdx(0)
-		{ }
-
-		const RenderOperation* baseOperation;
-		UINT32 passIdx;
-	};
-
-	/**
-	 * @brief	Render objects determines rendering order of objects contained within it. Normally the rendering
-	 * 			order is determined by object material, and can influence rendering of transparent or opaque objects,
-	 * 			or be used to improve performance by grouping similar objects together.
-	 * 			
-	 *			You need to provide your own implementation of the render queue sorting method. Likely the sorting method
-	 *			will need to be closely tied to the renderer used.
-	 */
-	class CM_EXPORT RenderQueue
-	{
-	public:
-		RenderQueue();
-
-		/**
-		 * @brief	Adds a new render operation to the rendering queue. These operations will be sorted
-		 * 			and rendered by the Renderer in sorted order.
-		 *
-		 * @param	material	   	The material to use for rendering the object.
-		 * @param	mesh		   	The mesh to render.
-		 * @param	submeshIdx	   	Sub-mesh index in "mesh" to render.
-		 * @param	worldPosForSort	The world position used for sorting.
-		 */
-		void add(const MaterialPtr& material, const MeshBasePtr& mesh, UINT32 submeshIdx, const Vector3& worldPosForSort);
-
-		/**
-		 * @brief	Clears all render operations from the queue.
-		 */
-		void clear();
-		
-		/**
-		 * @brief	Sorts all the render operations using user-defined rules.
-		 */
-		virtual void sort() = 0;
-
-		/**
-		 * @brief	Returns a list of sorted render operations. Caller must ensure
-		 * 			"sort" is called before this method.
-		 */
-		const Vector<SortedRenderOp>& getSortedRenderOps() const;
-
-	protected:
-		Vector<RenderOperation> mRenderOperations;
-		Vector<SortedRenderOp> mSortedRenderOps;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Slightly more fine grained version of RenderOperation, as each pass
+	 * 			is specified as an individual operation. Used for sorting within the RenderQueue.
+	 */
+	struct BS_CORE_EXPORT SortedRenderOp
+	{
+		SortedRenderOp()
+			:baseOperation(nullptr), passIdx(0)
+		{ }
+
+		const RenderOperation* baseOperation;
+		UINT32 passIdx;
+	};
+
+	/**
+	 * @brief	Render objects determines rendering order of objects contained within it. Normally the rendering
+	 * 			order is determined by object material, and can influence rendering of transparent or opaque objects,
+	 * 			or be used to improve performance by grouping similar objects together.
+	 * 			
+	 *			You need to provide your own implementation of the render queue sorting method. Likely the sorting method
+	 *			will need to be closely tied to the renderer used.
+	 */
+	class BS_CORE_EXPORT RenderQueue
+	{
+	public:
+		RenderQueue();
+
+		/**
+		 * @brief	Adds a new render operation to the rendering queue. These operations will be sorted
+		 * 			and rendered by the Renderer in sorted order.
+		 *
+		 * @param	material	   	The material to use for rendering the object.
+		 * @param	mesh		   	The mesh to render.
+		 * @param	submeshIdx	   	Sub-mesh index in "mesh" to render.
+		 * @param	worldPosForSort	The world position used for sorting.
+		 */
+		void add(const MaterialPtr& material, const MeshBasePtr& mesh, UINT32 submeshIdx, const Vector3& worldPosForSort);
+
+		/**
+		 * @brief	Clears all render operations from the queue.
+		 */
+		void clear();
+		
+		/**
+		 * @brief	Sorts all the render operations using user-defined rules.
+		 */
+		virtual void sort() = 0;
+
+		/**
+		 * @brief	Returns a list of sorted render operations. Caller must ensure
+		 * 			"sort" is called before this method.
+		 */
+		const Vector<SortedRenderOp>& getSortedRenderOps() const;
+
+	protected:
+		Vector<RenderOperation> mRenderOperations;
+		Vector<SortedRenderOp> mSortedRenderOps;
+	};
 }

+ 108 - 108
CamelotCore/Include/CmRenderStateManager.h → BansheeCore/Include/CmRenderStateManager.h

@@ -1,109 +1,109 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles creation of various render states.
-	 */
-	class CM_EXPORT RenderStateManager : public Module<RenderStateManager>
-	{
-	public:
-		/**
-		 * @brief	Creates and initializes a new SamplerState.
-		 */
-		SamplerStatePtr createSamplerState(const SAMPLER_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates and initializes a new DepthStencilState.
-		 */
-		DepthStencilStatePtr createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates and initializes a new RasterizerState.
-		 */
-		RasterizerStatePtr createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates and initializes a new BlendState.
-		 */
-		BlendStatePtr createBlendState(const BLEND_STATE_DESC& desc) const;
-
-		/**
-		 * @brief	Creates a completely empty and uninitialized SamplerState.
-		 * 			Should only be used for VERY specific purposes, like deserialization,
-		 * 			as it requires additional manual initialization that is not required normally.
-		 */
-		SamplerStatePtr createEmptySamplerState() const;
-
-		/**
-		 * @brief	Creates a completely empty and uninitialized DepthStencilState.
-		 * 			Should only be used for VERY specific purposes, like deserialization,
-		 * 			as it requires additional manual initialization that is not required normally.
-		 */
-		DepthStencilStatePtr createEmptyDepthStencilState() const;
-
-		/**
-		 * @brief	Creates a completely empty and uninitialized RasterizerState.
-		 * 			Should only be used for VERY specific purposes, like deserialization,
-		 * 			as it requires additional manual initialization that is not required normally.
-		 */
-		RasterizerStatePtr createEmptyRasterizerState() const;
-
-		/**
-		 * @brief	Creates a completely empty and uninitialized BlendState.
-		 * 			Should only be used for VERY specific purposes, like deserialization,
-		 * 			as it requires additional manual initialization that is not required normally.
-		 */
-		BlendStatePtr createEmptyBlendState() const;
-
-		/**
-		 * @brief	Gets a sampler state initialized with default options.
-		 */
-		const SamplerStatePtr& getDefaultSamplerState() const;
-		
-		/**
-		 * @brief	Gets a blend state initialized with default options.
-		 */
-		const BlendStatePtr& getDefaultBlendState() const;
-
-		/**
-		 * @brief	Gets a rasterizer state initialized with default options.
-		 */
-		const RasterizerStatePtr& getDefaultRasterizerState() const;
-
-		/**
-		 * @brief	Gets a depth stencil state initialized with default options.
-		 */
-		const DepthStencilStatePtr& getDefaultDepthStencilState() const;
-
-	protected:
-		/**
-		 * @copydoc	createSamplerState
-		 */
-		virtual SamplerStatePtr createSamplerStateImpl() const;
-
-		/**
-		 * @copydoc	createBlendState
-		 */
-		virtual BlendStatePtr createBlendStateImpl() const;
-
-		/**
-		 * @copydoc	createRasterizerState
-		 */
-		virtual RasterizerStatePtr createRasterizerStateImpl() const;
-
-		/**
-		 * @copydoc	createDepthStencilState
-		 */
-		virtual DepthStencilStatePtr createDepthStencilStateImpl() const;
-
-	private:
-		mutable SamplerStatePtr mDefaultSamplerState;
-		mutable BlendStatePtr mDefaultBlendState;
-		mutable RasterizerStatePtr mDefaultRasterizerState;
-		mutable DepthStencilStatePtr mDefaultDepthStencilState;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Handles creation of various render states.
+	 */
+	class BS_CORE_EXPORT RenderStateManager : public Module<RenderStateManager>
+	{
+	public:
+		/**
+		 * @brief	Creates and initializes a new SamplerState.
+		 */
+		SamplerStatePtr createSamplerState(const SAMPLER_STATE_DESC& desc) const;
+
+		/**
+		 * @brief	Creates and initializes a new DepthStencilState.
+		 */
+		DepthStencilStatePtr createDepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc) const;
+
+		/**
+		 * @brief	Creates and initializes a new RasterizerState.
+		 */
+		RasterizerStatePtr createRasterizerState(const RASTERIZER_STATE_DESC& desc) const;
+
+		/**
+		 * @brief	Creates and initializes a new BlendState.
+		 */
+		BlendStatePtr createBlendState(const BLEND_STATE_DESC& desc) const;
+
+		/**
+		 * @brief	Creates a completely empty and uninitialized SamplerState.
+		 * 			Should only be used for VERY specific purposes, like deserialization,
+		 * 			as it requires additional manual initialization that is not required normally.
+		 */
+		SamplerStatePtr createEmptySamplerState() const;
+
+		/**
+		 * @brief	Creates a completely empty and uninitialized DepthStencilState.
+		 * 			Should only be used for VERY specific purposes, like deserialization,
+		 * 			as it requires additional manual initialization that is not required normally.
+		 */
+		DepthStencilStatePtr createEmptyDepthStencilState() const;
+
+		/**
+		 * @brief	Creates a completely empty and uninitialized RasterizerState.
+		 * 			Should only be used for VERY specific purposes, like deserialization,
+		 * 			as it requires additional manual initialization that is not required normally.
+		 */
+		RasterizerStatePtr createEmptyRasterizerState() const;
+
+		/**
+		 * @brief	Creates a completely empty and uninitialized BlendState.
+		 * 			Should only be used for VERY specific purposes, like deserialization,
+		 * 			as it requires additional manual initialization that is not required normally.
+		 */
+		BlendStatePtr createEmptyBlendState() const;
+
+		/**
+		 * @brief	Gets a sampler state initialized with default options.
+		 */
+		const SamplerStatePtr& getDefaultSamplerState() const;
+		
+		/**
+		 * @brief	Gets a blend state initialized with default options.
+		 */
+		const BlendStatePtr& getDefaultBlendState() const;
+
+		/**
+		 * @brief	Gets a rasterizer state initialized with default options.
+		 */
+		const RasterizerStatePtr& getDefaultRasterizerState() const;
+
+		/**
+		 * @brief	Gets a depth stencil state initialized with default options.
+		 */
+		const DepthStencilStatePtr& getDefaultDepthStencilState() const;
+
+	protected:
+		/**
+		 * @copydoc	createSamplerState
+		 */
+		virtual SamplerStatePtr createSamplerStateImpl() const;
+
+		/**
+		 * @copydoc	createBlendState
+		 */
+		virtual BlendStatePtr createBlendStateImpl() const;
+
+		/**
+		 * @copydoc	createRasterizerState
+		 */
+		virtual RasterizerStatePtr createRasterizerStateImpl() const;
+
+		/**
+		 * @copydoc	createDepthStencilState
+		 */
+		virtual DepthStencilStatePtr createDepthStencilStateImpl() const;
+
+	private:
+		mutable SamplerStatePtr mDefaultSamplerState;
+		mutable BlendStatePtr mDefaultBlendState;
+		mutable RasterizerStatePtr mDefaultRasterizerState;
+		mutable DepthStencilStatePtr mDefaultDepthStencilState;
+	};
 }

+ 399 - 399
CamelotCore/Include/CmRenderSystem.h → BansheeCore/Include/CmRenderSystem.h

@@ -1,400 +1,400 @@
-#pragma once
-#include "CmPrerequisites.h"
-
-#include <memory>
-
-#include "CmString.h"
-
-#include "CmSamplerState.h"
-#include "BsRenderStats.h"
-#include "CmCommandQueue.h"
-#include "CmDrawOps.h"
-#include "CmRenderSystemCapabilities.h"
-#include "CmRenderTarget.h"
-#include "CmRenderTexture.h"
-#include "CmRenderWindow.h"
-#include "CmGpuProgram.h"
-#include "CmVertexDeclaration.h"
-#include "CmPlane.h"
-#include "CmModule.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Render system provides base functionality for a rendering API like
-	 *			DirectX or OpenGL. Most of the class is abstract and specific
-	 *			subclass for each rendering API needs to be implemented.
-	 *
-	 * @note	Core thread only unless specifically noted otherwise on per-method basis.
-	 */
-	class CM_EXPORT RenderSystem : public Module<RenderSystem>
-	{
-	public:
-		RenderSystem();
-		virtual ~RenderSystem();
-
-		/**
-		 * @brief	Returns the name of the rendering system. 
-		 *
-		 * @note	Thread safe.
-		 */
-		virtual const String& getName() const = 0;
-
-		/**
-		 * @brief	Gets the name of the primary shading language
-		 *			used by the rendering system.
-		 *
-		 * @note	Thread safe.
-		 */
-		virtual const String& getShadingLanguageName() const = 0;
-
-		/**
-		 * @brief	Sets a sampler state for the specified texture unit.
-		 *
-		 * @see		SamplerState
-		 */
-		virtual void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SamplerStatePtr& samplerState) = 0;
-
-		/**
-		 * @brief	Sets a blend state used for all active render targets.
-		 *
-		 * @see		BlendState
-		 */
-		virtual void setBlendState(const BlendStatePtr& blendState) = 0;
-
-		/**
-		 * @brief	Sets a state that controls various rasterizer options. 
-		 *
-		 * @see		RasterizerState
-		 */
-		virtual void setRasterizerState(const RasterizerStatePtr& rasterizerState) = 0;
-
-		/**
-		 * @brief	Sets a state that controls depth & stencil buffer options.
-		 *
-		 * @see		DepthStencilState
-		 */
-		virtual void setDepthStencilState(const DepthStencilStatePtr& depthStencilState, UINT32 stencilRefValue) = 0;
-
-		/**
-		 * @brief	Binds a texture to the pipeline for the specified GPU program type at the specified slot.
-		 *			If the slot matches the one configured in the GPU program the program will be able to access
-		 *			this texture on the GPU.
-		 */
-		virtual void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const TexturePtr& texPtr) = 0;
-
-		/**
-		* @brief	Turns off a texture unit.
-		*/
-		virtual void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
-
-		/**
-		 * @brief	Signals that rendering for a specific viewport has started. Any draw calls
-		 *			need to be called between beginFrame and endFrame. You may not switch render targets
-		 *			until you call endFrame.
-		 */
-		virtual void beginFrame() = 0;
-		
-		/**
-		 * @brief	Ends that rendering to a specific viewport has ended.
-		 */
-		virtual void endFrame() = 0;
-
-		/**
-		 * @brief	Sets the active viewport that will be used for all render operations.
-		 *			Viewport will change active render target if needed.
-		 */
-		virtual void setViewport(const ViewportPtr& vp) = 0;
-
-		/**
-		 * @brief	Sets the provided vertex buffers starting at the specified source index.
-		 *			Set buffer to nullptr to clear the buffer at the specified index.
-		 */
-		virtual void setVertexBuffers(UINT32 index, VertexBufferPtr* buffers, UINT32 numBuffers) = 0;
-
-		/**
-		 * @brief	Sets an index buffer to use when drawing. Indices in an index buffer
-		 * 			reference vertices in the vertex buffer, which increases cache coherency
-		 * 			and reduces the size of vertex buffers by eliminating duplicate data.
-		 */
-		virtual void setIndexBuffer(const IndexBufferPtr& buffer) = 0;
-
-		/**
-		 * @brief	Sets the vertex declaration to use when drawing. Vertex declaration
-		 * 			is used to decode contents of a single vertex in a vertex buffer.
-		 */
-		virtual void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration) = 0;
-
-		/**
-		 * @brief	Sets the draw operation that determines how to interpret the elements
-		 * 			of the index or vertex buffers.
-		 */
-		virtual void setDrawOperation(DrawOperationType op) = 0;
-
-		/**
-		 * @brief	A helper method that provides a simple way of rendering a single object. It will
-		 * 			automatically set up vertex declaration, draw operation, vertex and index buffers and
-		 * 			draw them.
-		 *
-		 * @param	mesh	   	The mesh.
-		 * @param	indexOffset	(optional) Offset into the mesh buffer to start drawing from.
-		 * @param	indexCount 	(optional) Number of indexes to draw, starting at the offset. Ignored if "drawIndexed" is false. If 0 all indices in the mesh will be drawn.
-		 * @param	useIndices	(optional) If true, drawing is done using the index buffer on the mesh and the provided offset and size, otherwise all mesh vertices are drawn sequentially.
-		 * @param	drawOp	   	(optional) Draw operation to use when rendering.
-		 */
-		virtual void render(const MeshBasePtr& mesh, UINT32 indexOffset = 0, UINT32 indexCount = 0, bool useIndices = true, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
-
-		/**
-		 * @brief	Draw an object based on currently bound GPU programs, vertex declaration and vertex buffers.
-		 * 			
-		 *			Draws directly from the vertex buffer without using indices.
-		 */
-		virtual void draw(UINT32 vertexOffset, UINT32 vertexCount) = 0;
-
-		/**
-		 * @brief	Draw an object based on currently bound GPU programs, vertex declaration, vertex 
-		 * 			and index buffers.
-		 */
-		virtual void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount) = 0;
-
-		/**
-		 * @brief	Swap the front and back buffer of the specified render target.
-		 */
-		virtual void swapBuffers(RenderTargetPtr target);
-
-		/**
-		 * @brief	Gets the capabilities of the render system.
-		 *
-		 * @note	Thread safe.
-		 */
-		const RenderSystemCapabilities* getCapabilities() const;
-
-		/**
-		 * @brief	Returns information about the driver version.
-		 */
-		virtual const DriverVersion& getDriverVersion() const;
-
-		/**
-		 * @brief	Binds the provided GPU program to the pipeline. Any following
-		 *			draw operations will use this program. 
-		 *
-		 * @note	You need to bind at least a vertex and a fragment program in order to draw something.
-		 */
-		virtual void bindGpuProgram(HGpuProgram prg);
-
-		/**
-		 * @brief	Binds GPU program parameters. Caller must ensure these match the previously
-		 *			bound GPU program.
-		 */
-		virtual void bindGpuParams(GpuProgramType gptype, BindableGpuParams& params) = 0;
-
-		/**
-		 * @brief	Unbinds a program of a given type. 
-		 */
-		virtual void unbindGpuProgram(GpuProgramType gptype);
-
-		/**
-		 * @brief	Query if a GPU program of a given type is currently bound.
-		 */
-		virtual bool isGpuProgramBound(GpuProgramType gptype);
-
-		/**
-		 * @brief	Sets up clip planes that will clip drawn geometry on the negative side of the planes.
-		 */
-		virtual void setClipPlanes(const PlaneList& clipPlanes);
-
-		/**
-		 * @brief	Adds a new clip plane. All drawn geometry will be clipped to this plane.
-		 */
-		virtual void addClipPlane(const Plane& p);
-
-		/**
-		 * @brief	Clears all clip planes.
-		 */
-		virtual void resetClipPlanes();
-
-		/**
-		 * @brief	Allows you to set up a region in which rendering can take place. Coordinates are in pixels.
-		 *			No rendering will be done to render target pixels outside of the provided region.
-		 */
-		virtual void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom) = 0;
-
-		/**
-		 * @brief	Clears the currently active render target.
-		 *
-		 * @param	buffers			Combination of one or more elements of FrameBufferType
-		 *							denoting which buffers are to be cleared.
-		 * @param	color			(optional) The color to clear the color buffer with, if enabled.
-		 * @param	depth			(optional) The value to initialise the depth buffer with, if enabled.
-		 * @param	stencil			(optional) The value to initialise the stencil buffer with, if enabled.
-		 */
-		virtual void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0) = 0;
-
-		/**
-		 * @brief	Clears the currently active viewport (i.e. it clears just a sub-area of a render-target that is covered by the viewport,
-		 * 			as opposed to clearRenderTarget which always clears the entire render target).
-		 *
-		 * @param	buffers			Combination of one or more elements of FrameBufferType
-		 *							denoting which buffers are to be cleared.
-		 * @param	color			(optional) The color to clear the color buffer with, if enabled.
-		 * @param	depth			(optional) The value to initialise the depth buffer with, if enabled.
-		 * @param	stencil			(optional) The value to initialise the stencil buffer with, if enabled.
-		 */
-		virtual void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0) = 0;
-
-		/**
-		 * @brief	Change the render target into which we want to draw.
-		 */
-        virtual void setRenderTarget(RenderTargetPtr target) = 0;
-
-		/**
-		 * @brief	Updates the resource with the specified data.
-		 *
-		 * @note	It is assumed GpuResourceData has been locked before being passed here. Data will be unlocked
-		 *			when this method finishes.
-		 */
-		void writeSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data, bool discardEntireBuffer, AsyncOp& asyncOp);
-
-		/**
-		 * @brief	Reads data from a resource into a pre-allocated GpuResourceData instance.
-		 *
-		 * @note	It is assumed GpuResourceData has been locked before being passed here. Data will be unlocked
-		 *			when this method finishes.
-		 */
-		void readSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, GpuResourceDataPtr& data, AsyncOp& asyncOp);
-
-		/**
-		 * @brief	Returns information about available output devices and their video modes.
-		 *
-		 * @note	Thread safe.
-		 */
-		const VideoModeInfo& getVideoModeInfo() const { return *mVideoModeInfo; }
-
-		/************************************************************************/
-		/* 								UTILITY METHODS                    		*/
-		/************************************************************************/
-
-		/**
-		 * @brief	Gets the native type used for vertex colors.
-		 *
-		 * @note	Thread safe.
-		 */
-		virtual VertexElementType getColorVertexElementType() const = 0;
-
-		/**
-		 * @brief	Contains a default matrix into a matrix suitable for use
-		 *			by this specific render system.
-		 *
-		 * @note	Thread safe.
-		 */
-		virtual void convertProjectionMatrix(const Matrix4& matrix,
-			Matrix4& dest, bool forGpuProgram = false) = 0;
-
-		/**
-		 * @brief	Gets horizontal texel offset used for mapping texels to pixels
-		 *			in this render system.
-		 *
-		 * @note	Thread safe.
-		 */
-		virtual float getHorizontalTexelOffset() = 0;
-
-		/**
-		 * @brief	Gets vertical texel offset used for mapping texels to pixels
-		 *			in this render system.
-		 *
-		 * @note		Thread safe.
-		 */
-		virtual float getVerticalTexelOffset() = 0;
-
-		/**
-		 * @brief	Gets the minimum (closest) depth value used by this
-		 *			render system.
-		 *
-		 * @note	Thread safe.
-		 */
-		virtual float getMinimumDepthInputValue() = 0;
-
-		/**
-		 * @brief	Gets the maximum (farthest) depth value used by this
-		 *			render system.
-		 *
-		 * @note		Thread safe.
-		 */
-		virtual float getMaximumDepthInputValue() = 0;
-
-		/**
-		 * @brief	Returns an object containing various rendering statistics.
-		 *			
-		 * @note	Do not modify the returned state unless you know what you are doing, it will
-		 *			change the actual internal object.
-		 */
-		RenderStats& getRenderStats() { return mRenderStats; }
-
-		/************************************************************************/
-		/* 							INTERNAL METHODS				        	*/
-		/************************************************************************/
-	protected:
-		/**
-		 * @brief	Initializes the render system and creates a primary render window.
-		 *
-		 * @note		Although I'd like otherwise, due to the nature of some render system implementations,
-		 * 			you cannot initialize the render system without a window.
-		 *
-		 *			Sim thread.
-		 */
-		RenderWindowPtr initialize(const RENDER_WINDOW_DESC& primaryWindowDesc);
-
-		/**
-		 * @brief	Performs second part of the initialization (on Core thread), first part
-		 *			being in initialize().
-		 */
-		virtual void initialize_internal(AsyncOp& asyncOp);
-
-		/**
-		 * @brief	Shuts down the render system and cleans up all resources.
-		 *
-		 * @note	Sim thread.
-		 */
-		void destroy();
-
-		/**
-		 * @brief	Performs second part of render system shutdown on the core thread.
-		 */
-		virtual void destroy_internal();
-
-		/**
-		 * @copydoc	setClipPlanes.
-		 */
-		virtual void setClipPlanesImpl(const PlaneList& clipPlanes) = 0;
-
-		/************************************************************************/
-		/* 								INTERNAL DATA					       	*/
-		/************************************************************************/
-	protected:
-		friend class RenderSystemManager;
-
-		RenderTargetPtr mActiveRenderTarget;
-
-		RenderStats mRenderStats;
-		DriverVersion mDriverVersion;
-		CullingMode mCullingMode;
-		UINT16 mDisabledTexUnitsFrom;
-
-		bool mVertexProgramBound;
-		bool mGeometryProgramBound;
-		bool mFragmentProgramBound;
-		bool mDomainProgramBound;
-		bool mHullProgramBound;
-		bool mComputeProgramBound;
-
-		PlaneList mClipPlanes;
-		bool mClipPlanesDirty;
-
-		RenderSystemCapabilities* mCurrentCapabilities;
-		VideoModeInfoPtr mVideoModeInfo;
-
-		// TODO - Only used between initialize and initialize_internal. Handle it better?
-		RENDER_WINDOW_DESC mPrimaryWindowDesc;
-	};
+#pragma once
+#include "CmPrerequisites.h"
+
+#include <memory>
+
+#include "CmString.h"
+
+#include "CmSamplerState.h"
+#include "BsRenderStats.h"
+#include "CmCommandQueue.h"
+#include "CmDrawOps.h"
+#include "CmRenderSystemCapabilities.h"
+#include "CmRenderTarget.h"
+#include "CmRenderTexture.h"
+#include "CmRenderWindow.h"
+#include "CmGpuProgram.h"
+#include "CmVertexDeclaration.h"
+#include "CmPlane.h"
+#include "CmModule.h"
+#include "BsEvent.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Render system provides base functionality for a rendering API like
+	 *			DirectX or OpenGL. Most of the class is abstract and specific
+	 *			subclass for each rendering API needs to be implemented.
+	 *
+	 * @note	Core thread only unless specifically noted otherwise on per-method basis.
+	 */
+	class BS_CORE_EXPORT RenderSystem : public Module<RenderSystem>
+	{
+	public:
+		RenderSystem();
+		virtual ~RenderSystem();
+
+		/**
+		 * @brief	Returns the name of the rendering system. 
+		 *
+		 * @note	Thread safe.
+		 */
+		virtual const String& getName() const = 0;
+
+		/**
+		 * @brief	Gets the name of the primary shading language
+		 *			used by the rendering system.
+		 *
+		 * @note	Thread safe.
+		 */
+		virtual const String& getShadingLanguageName() const = 0;
+
+		/**
+		 * @brief	Sets a sampler state for the specified texture unit.
+		 *
+		 * @see		SamplerState
+		 */
+		virtual void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SamplerStatePtr& samplerState) = 0;
+
+		/**
+		 * @brief	Sets a blend state used for all active render targets.
+		 *
+		 * @see		BlendState
+		 */
+		virtual void setBlendState(const BlendStatePtr& blendState) = 0;
+
+		/**
+		 * @brief	Sets a state that controls various rasterizer options. 
+		 *
+		 * @see		RasterizerState
+		 */
+		virtual void setRasterizerState(const RasterizerStatePtr& rasterizerState) = 0;
+
+		/**
+		 * @brief	Sets a state that controls depth & stencil buffer options.
+		 *
+		 * @see		DepthStencilState
+		 */
+		virtual void setDepthStencilState(const DepthStencilStatePtr& depthStencilState, UINT32 stencilRefValue) = 0;
+
+		/**
+		 * @brief	Binds a texture to the pipeline for the specified GPU program type at the specified slot.
+		 *			If the slot matches the one configured in the GPU program the program will be able to access
+		 *			this texture on the GPU.
+		 */
+		virtual void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const TexturePtr& texPtr) = 0;
+
+		/**
+		* @brief	Turns off a texture unit.
+		*/
+		virtual void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
+
+		/**
+		 * @brief	Signals that rendering for a specific viewport has started. Any draw calls
+		 *			need to be called between beginFrame and endFrame. You may not switch render targets
+		 *			until you call endFrame.
+		 */
+		virtual void beginFrame() = 0;
+		
+		/**
+		 * @brief	Ends that rendering to a specific viewport has ended.
+		 */
+		virtual void endFrame() = 0;
+
+		/**
+		 * @brief	Sets the active viewport that will be used for all render operations.
+		 *			Viewport will change active render target if needed.
+		 */
+		virtual void setViewport(const ViewportPtr& vp) = 0;
+
+		/**
+		 * @brief	Sets the provided vertex buffers starting at the specified source index.
+		 *			Set buffer to nullptr to clear the buffer at the specified index.
+		 */
+		virtual void setVertexBuffers(UINT32 index, VertexBufferPtr* buffers, UINT32 numBuffers) = 0;
+
+		/**
+		 * @brief	Sets an index buffer to use when drawing. Indices in an index buffer
+		 * 			reference vertices in the vertex buffer, which increases cache coherency
+		 * 			and reduces the size of vertex buffers by eliminating duplicate data.
+		 */
+		virtual void setIndexBuffer(const IndexBufferPtr& buffer) = 0;
+
+		/**
+		 * @brief	Sets the vertex declaration to use when drawing. Vertex declaration
+		 * 			is used to decode contents of a single vertex in a vertex buffer.
+		 */
+		virtual void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration) = 0;
+
+		/**
+		 * @brief	Sets the draw operation that determines how to interpret the elements
+		 * 			of the index or vertex buffers.
+		 */
+		virtual void setDrawOperation(DrawOperationType op) = 0;
+
+		/**
+		 * @brief	A helper method that provides a simple way of rendering a single object. It will
+		 * 			automatically set up vertex declaration, draw operation, vertex and index buffers and
+		 * 			draw them.
+		 *
+		 * @param	mesh	   	The mesh.
+		 * @param	indexOffset	(optional) Offset into the mesh buffer to start drawing from.
+		 * @param	indexCount 	(optional) Number of indexes to draw, starting at the offset. Ignored if "drawIndexed" is false. If 0 all indices in the mesh will be drawn.
+		 * @param	useIndices	(optional) If true, drawing is done using the index buffer on the mesh and the provided offset and size, otherwise all mesh vertices are drawn sequentially.
+		 * @param	drawOp	   	(optional) Draw operation to use when rendering.
+		 */
+		virtual void render(const MeshBasePtr& mesh, UINT32 indexOffset = 0, UINT32 indexCount = 0, bool useIndices = true, DrawOperationType drawOp = DOT_TRIANGLE_LIST);
+
+		/**
+		 * @brief	Draw an object based on currently bound GPU programs, vertex declaration and vertex buffers.
+		 * 			
+		 *			Draws directly from the vertex buffer without using indices.
+		 */
+		virtual void draw(UINT32 vertexOffset, UINT32 vertexCount) = 0;
+
+		/**
+		 * @brief	Draw an object based on currently bound GPU programs, vertex declaration, vertex 
+		 * 			and index buffers.
+		 */
+		virtual void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount) = 0;
+
+		/**
+		 * @brief	Swap the front and back buffer of the specified render target.
+		 */
+		virtual void swapBuffers(RenderTargetPtr target);
+
+		/**
+		 * @brief	Gets the capabilities of the render system.
+		 *
+		 * @note	Thread safe.
+		 */
+		const RenderSystemCapabilities* getCapabilities() const;
+
+		/**
+		 * @brief	Returns information about the driver version.
+		 */
+		virtual const DriverVersion& getDriverVersion() const;
+
+		/**
+		 * @brief	Binds the provided GPU program to the pipeline. Any following
+		 *			draw operations will use this program. 
+		 *
+		 * @note	You need to bind at least a vertex and a fragment program in order to draw something.
+		 */
+		virtual void bindGpuProgram(HGpuProgram prg);
+
+		/**
+		 * @brief	Binds GPU program parameters. Caller must ensure these match the previously
+		 *			bound GPU program.
+		 */
+		virtual void bindGpuParams(GpuProgramType gptype, BindableGpuParams& params) = 0;
+
+		/**
+		 * @brief	Unbinds a program of a given type. 
+		 */
+		virtual void unbindGpuProgram(GpuProgramType gptype);
+
+		/**
+		 * @brief	Query if a GPU program of a given type is currently bound.
+		 */
+		virtual bool isGpuProgramBound(GpuProgramType gptype);
+
+		/**
+		 * @brief	Sets up clip planes that will clip drawn geometry on the negative side of the planes.
+		 */
+		virtual void setClipPlanes(const PlaneList& clipPlanes);
+
+		/**
+		 * @brief	Adds a new clip plane. All drawn geometry will be clipped to this plane.
+		 */
+		virtual void addClipPlane(const Plane& p);
+
+		/**
+		 * @brief	Clears all clip planes.
+		 */
+		virtual void resetClipPlanes();
+
+		/**
+		 * @brief	Allows you to set up a region in which rendering can take place. Coordinates are in pixels.
+		 *			No rendering will be done to render target pixels outside of the provided region.
+		 */
+		virtual void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom) = 0;
+
+		/**
+		 * @brief	Clears the currently active render target.
+		 *
+		 * @param	buffers			Combination of one or more elements of FrameBufferType
+		 *							denoting which buffers are to be cleared.
+		 * @param	color			(optional) The color to clear the color buffer with, if enabled.
+		 * @param	depth			(optional) The value to initialise the depth buffer with, if enabled.
+		 * @param	stencil			(optional) The value to initialise the stencil buffer with, if enabled.
+		 */
+		virtual void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0) = 0;
+
+		/**
+		 * @brief	Clears the currently active viewport (i.e. it clears just a sub-area of a render-target that is covered by the viewport,
+		 * 			as opposed to clearRenderTarget which always clears the entire render target).
+		 *
+		 * @param	buffers			Combination of one or more elements of FrameBufferType
+		 *							denoting which buffers are to be cleared.
+		 * @param	color			(optional) The color to clear the color buffer with, if enabled.
+		 * @param	depth			(optional) The value to initialise the depth buffer with, if enabled.
+		 * @param	stencil			(optional) The value to initialise the stencil buffer with, if enabled.
+		 */
+		virtual void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0) = 0;
+
+		/**
+		 * @brief	Change the render target into which we want to draw.
+		 */
+        virtual void setRenderTarget(RenderTargetPtr target) = 0;
+
+		/**
+		 * @brief	Updates the resource with the specified data.
+		 *
+		 * @note	It is assumed GpuResourceData has been locked before being passed here. Data will be unlocked
+		 *			when this method finishes.
+		 */
+		void writeSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, const GpuResourceDataPtr& data, bool discardEntireBuffer, AsyncOp& asyncOp);
+
+		/**
+		 * @brief	Reads data from a resource into a pre-allocated GpuResourceData instance.
+		 *
+		 * @note	It is assumed GpuResourceData has been locked before being passed here. Data will be unlocked
+		 *			when this method finishes.
+		 */
+		void readSubresource(GpuResourcePtr resource, UINT32 subresourceIdx, GpuResourceDataPtr& data, AsyncOp& asyncOp);
+
+		/**
+		 * @brief	Returns information about available output devices and their video modes.
+		 *
+		 * @note	Thread safe.
+		 */
+		const VideoModeInfo& getVideoModeInfo() const { return *mVideoModeInfo; }
+
+		/************************************************************************/
+		/* 								UTILITY METHODS                    		*/
+		/************************************************************************/
+
+		/**
+		 * @brief	Gets the native type used for vertex colors.
+		 *
+		 * @note	Thread safe.
+		 */
+		virtual VertexElementType getColorVertexElementType() const = 0;
+
+		/**
+		 * @brief	Contains a default matrix into a matrix suitable for use
+		 *			by this specific render system.
+		 *
+		 * @note	Thread safe.
+		 */
+		virtual void convertProjectionMatrix(const Matrix4& matrix,
+			Matrix4& dest, bool forGpuProgram = false) = 0;
+
+		/**
+		 * @brief	Gets horizontal texel offset used for mapping texels to pixels
+		 *			in this render system.
+		 *
+		 * @note	Thread safe.
+		 */
+		virtual float getHorizontalTexelOffset() = 0;
+
+		/**
+		 * @brief	Gets vertical texel offset used for mapping texels to pixels
+		 *			in this render system.
+		 *
+		 * @note		Thread safe.
+		 */
+		virtual float getVerticalTexelOffset() = 0;
+
+		/**
+		 * @brief	Gets the minimum (closest) depth value used by this
+		 *			render system.
+		 *
+		 * @note	Thread safe.
+		 */
+		virtual float getMinimumDepthInputValue() = 0;
+
+		/**
+		 * @brief	Gets the maximum (farthest) depth value used by this
+		 *			render system.
+		 *
+		 * @note		Thread safe.
+		 */
+		virtual float getMaximumDepthInputValue() = 0;
+
+		/**
+		 * @brief	Returns an object containing various rendering statistics.
+		 *			
+		 * @note	Do not modify the returned state unless you know what you are doing, it will
+		 *			change the actual internal object.
+		 */
+		RenderStats& getRenderStats() { return mRenderStats; }
+
+		/************************************************************************/
+		/* 							INTERNAL METHODS				        	*/
+		/************************************************************************/
+	protected:
+		/**
+		 * @brief	Initializes the render system and creates a primary render window.
+		 *
+		 * @note		Although I'd like otherwise, due to the nature of some render system implementations,
+		 * 			you cannot initialize the render system without a window.
+		 *
+		 *			Sim thread.
+		 */
+		RenderWindowPtr initialize(const RENDER_WINDOW_DESC& primaryWindowDesc);
+
+		/**
+		 * @brief	Performs second part of the initialization (on Core thread), first part
+		 *			being in initialize().
+		 */
+		virtual void initialize_internal(AsyncOp& asyncOp);
+
+		/**
+		 * @brief	Shuts down the render system and cleans up all resources.
+		 *
+		 * @note	Sim thread.
+		 */
+		void destroy();
+
+		/**
+		 * @brief	Performs second part of render system shutdown on the core thread.
+		 */
+		virtual void destroy_internal();
+
+		/**
+		 * @copydoc	setClipPlanes.
+		 */
+		virtual void setClipPlanesImpl(const PlaneList& clipPlanes) = 0;
+
+		/************************************************************************/
+		/* 								INTERNAL DATA					       	*/
+		/************************************************************************/
+	protected:
+		friend class RenderSystemManager;
+
+		RenderTargetPtr mActiveRenderTarget;
+
+		RenderStats mRenderStats;
+		DriverVersion mDriverVersion;
+		CullingMode mCullingMode;
+		UINT16 mDisabledTexUnitsFrom;
+
+		bool mVertexProgramBound;
+		bool mGeometryProgramBound;
+		bool mFragmentProgramBound;
+		bool mDomainProgramBound;
+		bool mHullProgramBound;
+		bool mComputeProgramBound;
+
+		PlaneList mClipPlanes;
+		bool mClipPlanesDirty;
+
+		RenderSystemCapabilities* mCurrentCapabilities;
+		VideoModeInfoPtr mVideoModeInfo;
+
+		// TODO - Only used between initialize and initialize_internal. Handle it better?
+		RENDER_WINDOW_DESC mPrimaryWindowDesc;
+	};
 }

+ 654 - 654
CamelotCore/Include/CmRenderSystemCapabilities.h → BansheeCore/Include/CmRenderSystemCapabilities.h

@@ -1,655 +1,655 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmString.h"
-#include "CmGpuProgram.h"
-
-#define CAPS_CATEGORY_SIZE 8i64
-#define CM_CAPS_BITSHIFT (64i64 - CAPS_CATEGORY_SIZE)
-#define CAPS_CATEGORY_MASK (((1i64 << CAPS_CATEGORY_SIZE) - 1i64) << CM_CAPS_BITSHIFT)
-#define CM_CAPS_VALUE(cat, val) ((cat << CM_CAPS_BITSHIFT) | (1i64 << val))
-
-#define MAX_BOUND_VERTEX_BUFFERS 32
-
-namespace BansheeEngine 
-{
-	/// Enumerates the categories of capabilities
-	enum CapabilitiesCategory : UINT64
-	{
-		CAPS_CATEGORY_COMMON = 0,
-		CAPS_CATEGORY_D3D9 = 1,
-		CAPS_CATEGORY_GL = 2,
-		CAPS_CATEGORY_D3D11 = 3,
-		CAPS_CATEGORY_COUNT = 32 /**< Maximum number of categories. */
-	};
-
-	/**
-	 * @brief	Enum describing the different hardware capabilities we can check for.
-	 */
-	enum Capabilities : UINT64
-	{
-		RSC_AUTOMIPMAP				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 0), /**< Supports generating mipmaps in hardware. */
-		RSC_ANISOTROPY				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 1), /**< Supports anisotropic texture filtering. */
-		RSC_CUBEMAPPING				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 2), /**< Supports cube mapping. */
-		RSC_TWO_SIDED_STENCIL		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 3), /**< Supports separate stencil updates for both front and back faces. */
-		RSC_STENCIL_WRAP			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 4), /**< Supports wrapping the stencil value at the range extremes. */
-		RSC_HWOCCLUSION				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 5), /**< Supports hardware occlusion queries. */
-		RSC_USER_CLIP_PLANES		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 6), /**< Supports user clipping planes. */
-		RSC_VERTEX_FORMAT_UBYTE4	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 7), /**< Supports the VET_UBYTE4 vertex element type. */
-		RSC_INFINITE_FAR_PLANE		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 8), /**< Supports infinite far plane projection. */
-		RSC_HWRENDER_TO_TEXTURE		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 9), /**< Supports hardware render-to-texture. */
-		RSC_TEXTURE_FLOAT			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 10), /**< Supports float textures and render targets. */
-		RSC_NON_POWER_OF_2_TEXTURES = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 11), /**< Supports non-power of two textures. */
-		RSC_TEXTURE_3D				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 12), /**< Supports 3d (volume) textures. */
-		RSC_POINT_SPRITES			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 13), /**< Supports basic point sprite rendering. */
-
-		RSC_POINT_EXTENDED_PARAMETERS	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 14), /**< Supports extra point parameters (minsize, maxsize, attenuation). */
-		RSC_VERTEX_TEXTURE_FETCH		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 15), /**< Supports vertex texture fetch. */
-		RSC_MIPMAP_LOD_BIAS				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 16), /**< Supports mipmap LOD biasing. */
-		RSC_GEOMETRY_PROGRAM			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 17), /**< Supports hardware geometry programs. */
-
-		RSC_TEXTURE_COMPRESSION			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 18), /**< Supports compressed textures. */
-		RSC_TEXTURE_COMPRESSION_DXT		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 19), /**< Supports compressed textures in the DXT/ST3C formats. */
-		RSC_TEXTURE_COMPRESSION_VTC		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 20), /**< Supports compressed textures in the VTC format. */
-		RSC_TEXTURE_COMPRESSION_PVRTC	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 21), /**< Supports compressed textures in the PVRTC format. */
-		RSC_MRT_DIFFERENT_BIT_DEPTHS	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 22), /**< Supports multiple render targets with different bit depths. */
-		RSC_ALPHA_TO_COVERAGE			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 23), /**< Supports Alpha to Coverage. */
-		RSC_ADVANCED_BLEND_OPERATIONS	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 24), /**< Supports blend operations like subtract, min, max. */
-		RSC_SHADER_SUBROUTINE			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 25), /**< Supports dynamic shader linking. */
-		RSC_HWOCCLUSION_ASYNCHRONOUS	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 26), /**< Support for async occlusion queries. */
-		RSC_HWRENDER_TO_VERTEX_BUFFER	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 27), /**< Supports rendering to vertex buffers. */
-		RSC_TESSELLATION_PROGRAM		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 28), /**< Supports hardware tessellation programs. */
-		RSC_COMPUTE_PROGRAM				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 29), /**< Supports hardware compute programs. */
-
-		// ***** DirectX 9 specific caps *****
-		RSC_PERSTAGECONSTANT = CM_CAPS_VALUE(CAPS_CATEGORY_D3D9, 0), /**< Are per stage constants supported. */
-
-		// ***** GL Specific caps *****
-		RSC_FBO              = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 0), /**< Support for Frame Buffer Objects. */
-		RSC_PBUFFER			 = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 1), /**< Support for PBuffers. */
-	};
-
-	/**
-	 * @brief	Holds data about render system driver version.
-	 */
-	struct CM_EXPORT DriverVersion 
-	{
-		int major;
-		int minor;
-		int release;
-		int build;
-
-		DriverVersion() 
-		{
-			major = minor = release = build = 0;
-		}
-
-		/**
-		 * @brief	Returns the driver version as a single string.
-		 */
-		String toString() const 
-		{
-			StringStream str;
-			str << major << "." << minor << "." << release << "." << build;
-			return str.str();
-		}
-
-		/**
-		 * @brief	Parses a string in the major.minor.release.build format
-		 *			and stores the version numbers.
-		 */
-		void fromString(const String& versionString)
-		{
-			Vector<BansheeEngine::String> tokens = StringUtil::split(versionString, ".");
-			if(!tokens.empty())
-			{
-				major = parseInt(tokens[0]);
-				if (tokens.size() > 1)
-					minor = parseInt(tokens[1]);
-				if (tokens.size() > 2)
-					release = parseInt(tokens[2]);
-				if (tokens.size() > 3)
-					build = parseInt(tokens[3]);
-			}
-
-		}
-	};
-
-	/**
-	 * @brief	Types of GPU vendors
-	 */
-	enum GPUVendor
-	{
-		GPU_UNKNOWN = 0,
-		GPU_NVIDIA = 1,
-		GPU_AMD = 2, 
-		GPU_INTEL = 3,
-
-		GPU_VENDOR_COUNT = 4
-	};
-
-	/**
-	 * @brief	Holds information about render hardware and driver capabilities
-	 *			and allows you to easily set and query those capabilities.
-	 */
-	class CM_EXPORT RenderSystemCapabilities
-	{
-	public:	
-		RenderSystemCapabilities ();
-		virtual ~RenderSystemCapabilities ();
-
-		/**
-		 * @brief	Sets the current driver version.
-		 */
-		void setDriverVersion(const DriverVersion& version)
-		{
-			mDriverVersion = version;
-		}
-		
-		/**
-		 * @brief	Returns current driver version.
-		 */
-		DriverVersion getDriverVersion() const
-		{
-			return mDriverVersion;
-		}
-
-		/**
-		 * @brief	Returns vendor of the currently used GPU.
-		 */
-		GPUVendor getVendor() const
-		{
-			return mVendor;
-		}
-
-		/**
-		 * @brief	Sets the GPU vendor.
-		 */
-		void setVendor(GPUVendor v)
-		{
-			mVendor = v;
-		}
-
-		/**
-		 * @brief	Parses a vendor string and returns an enum with the vendor
-		 *			if parsed succesfully.
-		 */
-		static GPUVendor vendorFromString(const String& vendorString);
-
-		/**
-		 * @brief	Converts a vendor enum to a string.
-		 */
-		static String vendorToString(GPUVendor v);
-
-		/**
-		 * @brief	Sets the maximum number of texture units per pipeline stage.
-		 */
-		void setNumTextureUnits(GpuProgramType type, UINT16 num)
-		{
-			mNumTextureUnitsPerStage[type] = num;
-		}
-
-		/**
-		 * @brief	Sets the maximum number of texture units in all pipeline stages.
-		 */
-		void setNumCombinedTextureUnits(UINT16 num)
-		{
-			mNumCombinedTextureUnits = num;
-		}
-
-		/**
-		 * @brief	Sets the maximum number of GPU param block buffers per pipeline stage.
-		 */
-		void setNumGpuParamBlockBuffers(GpuProgramType type, UINT16 num)
-		{
-			mNumGpuParamBlocksPerStage[type] = num;
-		}
-
-		/**
-		 * @brief	Sets the maximum number of GPU param block buffers in all pipeline stages.
-		 */
-		void setNumCombinedGpuParamBlockBuffers(UINT16 num)
-		{
-			mNumCombinedUniformBlocks = num;
-		}
-
-		/**
-		 * @brief	Sets maximum stencil buffer depth in bits.
-		 */
-		void setStencilBufferBitDepth(UINT16 num)
-		{
-			mStencilBufferBitDepth = num;
-		}
-
-		/**
-		 * @brief	Sets maximum number of bound vertex buffers.
-		 */
-		void setMaxBoundVertexBuffers(UINT32 num)
-		{
-			mMaxBoundVertexBuffers = num;
-		}
-
-		/**
-		 * @brief	Sets maximum number of simultaneously set render targets.
-		 */
-		void setNumMultiRenderTargets(UINT16 num)
-		{
-			mNumMultiRenderTargets = num;
-		}
-
-		/**
-		 * @brief	Returns the number of texture units supported per pipeline stage.
-		 */
-		UINT16 getNumTextureUnits(GpuProgramType type) const
-		{
-			auto iterFind = mNumTextureUnitsPerStage.find(type);
-			if(iterFind != mNumTextureUnitsPerStage.end())
-				return iterFind->second;
-			else
-				return 0;
-		}
-
-		/**
-		* @brief	Returns the number of texture units supported in all pipeline stages.
-		*/
-		UINT16 getNumCombinedTextureUnits() const
-		{
-			return mNumCombinedTextureUnits;
-		}
-
-		/**
-		 * @brief	Returns the maximum number of bound GPU program param block 
-		 *			buffers per pipeline stage.
-		 */
-		UINT16 getNumGpuParamBlockBuffers(GpuProgramType type) const
-		{
-			auto iterFind = mNumGpuParamBlocksPerStage.find(type);
-			if(iterFind != mNumGpuParamBlocksPerStage.end())
-				return iterFind->second;
-			else
-				return 0;
-		}
-
-		/**
-		* @brief	Returns the maximum number of bound GPU program param block
-		*			buffers in all pipeline stages.
-		*/
-		UINT16 getNumCombinedGpuParamBlockBuffers() const
-		{
-			return mNumCombinedUniformBlocks;
-		}
-
-		/**
-		 * @brief	Returns the maximum number of bits available for
-		 *			the stencil buffer.
-		 */
-		UINT16 getStencilBufferBitDepth() const
-		{
-			return mStencilBufferBitDepth;
-		}
-
-		/**
-		 * @brief	Returns the maximum number of vertex buffers that can be bound
-		 *			at once.
-		 */
-		UINT32 getMaxBoundVertexBuffers() const
-		{
-			return mMaxBoundVertexBuffers;
-		}
-
-		/**
-		 * @brief	Returns the maximum number of render targets we can render to
-		 *			simultaneously.
-		 */
-		UINT16 getNumMultiRenderTargets() const
-		{
-			return mNumMultiRenderTargets;
-		}
-
-		/**
-		 * @brief	Sets a capability flag indicating this capability is supported.
-		 */
-		void setCapability(const Capabilities c) 
-		{ 
-			UINT64 index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
-			mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
-		}
-
-		/**
-		 * @brief	Remove a capability flag indicating this capability is 
-		 *			not supported (default).
-		 */
-		void unsetCapability(const Capabilities c) 
-		{ 
-			UINT64 index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
-			mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
-		}
-
-		/**
-		 * @brief	Checks is the specified capability supported.
-		 */
-		bool hasCapability(const Capabilities c) const
-		{
-			UINT64 index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
-
-			return (mCapabilities[index] & (c & ~CAPS_CATEGORY_MASK)) != 0;
-		}
-
-		/**
-		 * @brief	Adds a shader profile to the list of render-system specific supported profiles.
-		 */
-		void addShaderProfile(const String& profile)
-		{
-			mSupportedShaderProfiles.insert(profile);
-		}
-
-		/**
-		 * @brief	Adds a mapping between GPU program profile enum and render-system specific profile name.
-		 */
-		void addGpuProgramProfile(GpuProgramProfile gpuProgProfile, const String& rsSpecificProfile)
-		{
-			mGenericToSpecificShaderProfileMap[gpuProgProfile] = rsSpecificProfile;
-		}
-
-		/**
-		 * @brief	Returns true if the provided profile is supported.
-		 */
-		bool isShaderProfileSupported(const String& profile) const
-		{
-			return (mSupportedShaderProfiles.end() != mSupportedShaderProfiles.find(profile));
-		}
-
-		/**
-		 * @brief	Returns a set of all supported shader profiles.
-		 */
-		const Set<String>& getSupportedShaderProfiles() const
-		{
-			return mSupportedShaderProfiles;
-		}
-
-		/**
-		 * @brief	Converts a generic GpuProgramProfile identifier into a render-system specific one.  
-		 *			Returns an empty string if conversion cannot be done.
-		 */
-		String gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const
-		{
-			auto iterFind = mGenericToSpecificShaderProfileMap.find(gpuProgProfile);
-			if(mGenericToSpecificShaderProfileMap.end() != iterFind)
-			{
-				return iterFind->second;
-			}
-
-			return "";
-		}
-
-		/**
-		 * @brief	Gets the number of floating-point constants vertex programs support.
-		 */
-		UINT16 getVertexProgramConstantFloatCount() const
-		{
-			return mVertexProgramConstantFloatCount;           
-		}
-
-		/**
-		 * @brief	Gets the number of integer constants vertex programs support.
-		 */
-		UINT16 getVertexProgramConstantIntCount() const
-		{
-			return mVertexProgramConstantIntCount;           
-		}
-
-		/**
-		 * @brief	Gets the number of boolean constants vertex programs support.
-		 */
-		UINT16 getVertexProgramConstantBoolCount() const
-		{
-			return mVertexProgramConstantBoolCount;           
-		}
-
-		/**
-		 * @brief	Gets the number of floating-point constants geometry programs support.
-		 */
-		UINT16 getGeometryProgramConstantFloatCount() const
-		{
-			return mGeometryProgramConstantFloatCount;           
-		}
-
-		/**
-		 * @brief	 Gets the number of integer constants geometry programs support.
-		 */
-		UINT16 getGeometryProgramConstantIntCount() const
-		{
-			return mGeometryProgramConstantIntCount;           
-		}
-
-		/**
-		 * @brief	 Gets the number of boolean constants geometry programs support.
-		 */
-		UINT16 getGeometryProgramConstantBoolCount() const
-		{
-			return mGeometryProgramConstantBoolCount;           
-		}
-
-		/**
-		 * @brief	Gets the number of floating-point constants fragment programs support.
-		 */
-		UINT16 getFragmentProgramConstantFloatCount() const
-		{
-			return mFragmentProgramConstantFloatCount;           
-		}
-
-		/**
-		 * @brief	Gets the number of integer constants fragment programs support.
-		 */
-		UINT16 getFragmentProgramConstantIntCount() const
-		{
-			return mFragmentProgramConstantIntCount;           
-		}
-		
-		/**
-		 * @brief	 Gets the number of boolean constants fragment programs support.
-		 */
-		UINT16 getFragmentProgramConstantBoolCount() const
-		{
-			return mFragmentProgramConstantBoolCount;           
-		}
-
-		/**
-		 * @brief	Sets the current GPU device name.
-		 */
-		void setDeviceName(const String& name)
-		{
-			mDeviceName = name;
-		}
-
-		/**
-		 * @brief	Gets the current GPU device name.
-		 */
-		String getDeviceName() const
-		{
-			return mDeviceName;
-		}
-
-		/**
-		 * @brief	Sets the number of floating-point constants vertex programs support.
-		 */
-		void setVertexProgramConstantFloatCount(UINT16 c)
-		{
-			mVertexProgramConstantFloatCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the number of integer constants vertex programs support.
-		 */
-		void setVertexProgramConstantIntCount(UINT16 c)
-		{
-			mVertexProgramConstantIntCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the number of boolean constants vertex programs support.
-		 */
-		void setVertexProgramConstantBoolCount(UINT16 c)
-		{
-			mVertexProgramConstantBoolCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the number of floating-point constants geometry programs support.
-		 */
-		void setGeometryProgramConstantFloatCount(UINT16 c)
-		{
-			mGeometryProgramConstantFloatCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the number of integer constants geometry programs support.
-		 */
-		void setGeometryProgramConstantIntCount(UINT16 c)
-		{
-			mGeometryProgramConstantIntCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the number of boolean constants geometry programs support.
-		 */
-		void setGeometryProgramConstantBoolCount(UINT16 c)
-		{
-			mGeometryProgramConstantBoolCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the number of floating-point constants fragment programs support.
-		 */
-		void setFragmentProgramConstantFloatCount(UINT16 c)
-		{
-			mFragmentProgramConstantFloatCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the number of integer constants fragment programs support.
-		 */
-		void setFragmentProgramConstantIntCount(UINT16 c)
-		{
-			mFragmentProgramConstantIntCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the number of boolean constants fragment programs support.
-		 */
-		void setFragmentProgramConstantBoolCount(UINT16 c)
-		{
-			mFragmentProgramConstantBoolCount = c;           
-		}
-
-		/**
-		 * @brief	Sets the maximum point screen size in pixels.
-		 */
-		void setMaxPointSize(float s)
-		{
-			mMaxPointSize = s;
-		}
-
-		/**
-		 * @brief	Gets the maximum point screen size in pixels.
-		 */
-		float getMaxPointSize(void) const
-		{
-			return mMaxPointSize;
-		}
-
-		/**
-		 * @brief	Sets the number of vertices a single geometry program run can emit.
-		 */
-		void setGeometryProgramNumOutputVertices(int numOutputVertices)
-		{
-			mGeometryProgramNumOutputVertices = numOutputVertices;
-		}
-
-		/**
-		 * @brief	Gets the number of vertices a single geometry program run can emit.
-		 */
-		int getGeometryProgramNumOutputVertices(void) const
-		{
-			return mGeometryProgramNumOutputVertices;
-		}
-
-		/**
-		 * @brief	Get the identifier of the render system from which these capabilities were generated.
-		 */
-		String getRenderSystemName() const
-		{
-			return mRenderSystemName;
-		}
-
-		/**
-		 * @brief	Set the identifier of the render system from which these capabilities were generated.
-		 */
-		void setRenderSystemName(const String& rs)
-		{
-			mRenderSystemName = rs;
-		}
-
-	private:
-		/**
-		 * @brief	Initializes vendor enum -> vendor name mappings.
-		 */
-		static void initVendorStrings();
-
-	private:
-		static Vector<BansheeEngine::String> msGPUVendorStrings;
-
-		DriverVersion mDriverVersion;
-		GPUVendor mVendor = GPU_UNKNOWN;
-
-		// The number of texture units available per stage
-		Map<GpuProgramType, UINT16> mNumTextureUnitsPerStage;
-		// Total number of texture units available
-		UINT16 mNumCombinedTextureUnits = 0;
-		// The number of uniform blocks available per stage
-		Map<GpuProgramType, UINT16> mNumGpuParamBlocksPerStage;
-		// Total number of uniform blocks available
-		UINT16 mNumCombinedUniformBlocks = 0;
-		// The stencil buffer bit depth
-		UINT16 mStencilBufferBitDepth = 0;
-		// Maximum number of vertex buffers we can bind at once
-		UINT32 mMaxBoundVertexBuffers = 0;
-		// Stores the capabilities flags.
-		UINT32 mCapabilities[CAPS_CATEGORY_COUNT];
-		// The name of the device as reported by the render system
-		String mDeviceName;
-		// The identifier associated with the render system for which these capabilities are valid
-		String mRenderSystemName;
-
-		// The number of floating-point constants vertex programs support
-		UINT16 mVertexProgramConstantFloatCount = 0;
-		// The number of integer constants vertex programs support
-		UINT16 mVertexProgramConstantIntCount = 0;
-		// The number of boolean constants vertex programs support
-		UINT16 mVertexProgramConstantBoolCount = 0;
-		// The number of floating-point constants geometry programs support
-		UINT16 mGeometryProgramConstantFloatCount = 0;
-		// The number of integer constants vertex geometry support
-		UINT16 mGeometryProgramConstantIntCount = 0;
-		// The number of boolean constants vertex geometry support
-		UINT16 mGeometryProgramConstantBoolCount = 0;
-		// The number of floating-point constants fragment programs support
-		UINT16 mFragmentProgramConstantFloatCount = 0;
-		// The number of integer constants fragment programs support
-		UINT16 mFragmentProgramConstantIntCount = 0;
-		// The number of boolean constants fragment programs support
-		UINT16 mFragmentProgramConstantBoolCount = 0;
-		// The number of simultaneous render targets supported
-		UINT16 mNumMultiRenderTargets = 0;
-		// The maximum point size in pixels
-		float mMaxPointSize = 0.0f;
-		// The number of vertices a geometry program can emit in a single run
-		UINT32 mGeometryProgramNumOutputVertices = 0;
-
-		// The list of supported shader profiles
-		Set<String> mSupportedShaderProfiles;
-
-		// Allows us to convert a generic shader profile to a render-system specific one
-		UnorderedMap<GpuProgramProfile, String> mGenericToSpecificShaderProfileMap;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmString.h"
+#include "CmGpuProgram.h"
+
+#define CAPS_CATEGORY_SIZE 8i64
+#define CM_CAPS_BITSHIFT (64i64 - CAPS_CATEGORY_SIZE)
+#define CAPS_CATEGORY_MASK (((1i64 << CAPS_CATEGORY_SIZE) - 1i64) << CM_CAPS_BITSHIFT)
+#define CM_CAPS_VALUE(cat, val) ((cat << CM_CAPS_BITSHIFT) | (1i64 << val))
+
+#define MAX_BOUND_VERTEX_BUFFERS 32
+
+namespace BansheeEngine 
+{
+	/// Enumerates the categories of capabilities
+	enum CapabilitiesCategory : UINT64
+	{
+		CAPS_CATEGORY_COMMON = 0,
+		CAPS_CATEGORY_D3D9 = 1,
+		CAPS_CATEGORY_GL = 2,
+		CAPS_CATEGORY_D3D11 = 3,
+		CAPS_CATEGORY_COUNT = 32 /**< Maximum number of categories. */
+	};
+
+	/**
+	 * @brief	Enum describing the different hardware capabilities we can check for.
+	 */
+	enum Capabilities : UINT64
+	{
+		RSC_AUTOMIPMAP				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 0), /**< Supports generating mipmaps in hardware. */
+		RSC_ANISOTROPY				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 1), /**< Supports anisotropic texture filtering. */
+		RSC_CUBEMAPPING				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 2), /**< Supports cube mapping. */
+		RSC_TWO_SIDED_STENCIL		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 3), /**< Supports separate stencil updates for both front and back faces. */
+		RSC_STENCIL_WRAP			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 4), /**< Supports wrapping the stencil value at the range extremes. */
+		RSC_HWOCCLUSION				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 5), /**< Supports hardware occlusion queries. */
+		RSC_USER_CLIP_PLANES		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 6), /**< Supports user clipping planes. */
+		RSC_VERTEX_FORMAT_UBYTE4	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 7), /**< Supports the VET_UBYTE4 vertex element type. */
+		RSC_INFINITE_FAR_PLANE		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 8), /**< Supports infinite far plane projection. */
+		RSC_HWRENDER_TO_TEXTURE		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 9), /**< Supports hardware render-to-texture. */
+		RSC_TEXTURE_FLOAT			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 10), /**< Supports float textures and render targets. */
+		RSC_NON_POWER_OF_2_TEXTURES = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 11), /**< Supports non-power of two textures. */
+		RSC_TEXTURE_3D				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 12), /**< Supports 3d (volume) textures. */
+		RSC_POINT_SPRITES			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 13), /**< Supports basic point sprite rendering. */
+
+		RSC_POINT_EXTENDED_PARAMETERS	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 14), /**< Supports extra point parameters (minsize, maxsize, attenuation). */
+		RSC_VERTEX_TEXTURE_FETCH		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 15), /**< Supports vertex texture fetch. */
+		RSC_MIPMAP_LOD_BIAS				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 16), /**< Supports mipmap LOD biasing. */
+		RSC_GEOMETRY_PROGRAM			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 17), /**< Supports hardware geometry programs. */
+
+		RSC_TEXTURE_COMPRESSION			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 18), /**< Supports compressed textures. */
+		RSC_TEXTURE_COMPRESSION_DXT		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 19), /**< Supports compressed textures in the DXT/ST3C formats. */
+		RSC_TEXTURE_COMPRESSION_VTC		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 20), /**< Supports compressed textures in the VTC format. */
+		RSC_TEXTURE_COMPRESSION_PVRTC	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 21), /**< Supports compressed textures in the PVRTC format. */
+		RSC_MRT_DIFFERENT_BIT_DEPTHS	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 22), /**< Supports multiple render targets with different bit depths. */
+		RSC_ALPHA_TO_COVERAGE			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 23), /**< Supports Alpha to Coverage. */
+		RSC_ADVANCED_BLEND_OPERATIONS	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 24), /**< Supports blend operations like subtract, min, max. */
+		RSC_SHADER_SUBROUTINE			= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 25), /**< Supports dynamic shader linking. */
+		RSC_HWOCCLUSION_ASYNCHRONOUS	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 26), /**< Support for async occlusion queries. */
+		RSC_HWRENDER_TO_VERTEX_BUFFER	= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 27), /**< Supports rendering to vertex buffers. */
+		RSC_TESSELLATION_PROGRAM		= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 28), /**< Supports hardware tessellation programs. */
+		RSC_COMPUTE_PROGRAM				= CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 29), /**< Supports hardware compute programs. */
+
+		// ***** DirectX 9 specific caps *****
+		RSC_PERSTAGECONSTANT = CM_CAPS_VALUE(CAPS_CATEGORY_D3D9, 0), /**< Are per stage constants supported. */
+
+		// ***** GL Specific caps *****
+		RSC_FBO              = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 0), /**< Support for Frame Buffer Objects. */
+		RSC_PBUFFER			 = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 1), /**< Support for PBuffers. */
+	};
+
+	/**
+	 * @brief	Holds data about render system driver version.
+	 */
+	struct BS_CORE_EXPORT DriverVersion 
+	{
+		int major;
+		int minor;
+		int release;
+		int build;
+
+		DriverVersion() 
+		{
+			major = minor = release = build = 0;
+		}
+
+		/**
+		 * @brief	Returns the driver version as a single string.
+		 */
+		String toString() const 
+		{
+			StringStream str;
+			str << major << "." << minor << "." << release << "." << build;
+			return str.str();
+		}
+
+		/**
+		 * @brief	Parses a string in the major.minor.release.build format
+		 *			and stores the version numbers.
+		 */
+		void fromString(const String& versionString)
+		{
+			Vector<BansheeEngine::String> tokens = StringUtil::split(versionString, ".");
+			if(!tokens.empty())
+			{
+				major = parseInt(tokens[0]);
+				if (tokens.size() > 1)
+					minor = parseInt(tokens[1]);
+				if (tokens.size() > 2)
+					release = parseInt(tokens[2]);
+				if (tokens.size() > 3)
+					build = parseInt(tokens[3]);
+			}
+
+		}
+	};
+
+	/**
+	 * @brief	Types of GPU vendors
+	 */
+	enum GPUVendor
+	{
+		GPU_UNKNOWN = 0,
+		GPU_NVIDIA = 1,
+		GPU_AMD = 2, 
+		GPU_INTEL = 3,
+
+		GPU_VENDOR_COUNT = 4
+	};
+
+	/**
+	 * @brief	Holds information about render hardware and driver capabilities
+	 *			and allows you to easily set and query those capabilities.
+	 */
+	class BS_CORE_EXPORT RenderSystemCapabilities
+	{
+	public:	
+		RenderSystemCapabilities ();
+		virtual ~RenderSystemCapabilities ();
+
+		/**
+		 * @brief	Sets the current driver version.
+		 */
+		void setDriverVersion(const DriverVersion& version)
+		{
+			mDriverVersion = version;
+		}
+		
+		/**
+		 * @brief	Returns current driver version.
+		 */
+		DriverVersion getDriverVersion() const
+		{
+			return mDriverVersion;
+		}
+
+		/**
+		 * @brief	Returns vendor of the currently used GPU.
+		 */
+		GPUVendor getVendor() const
+		{
+			return mVendor;
+		}
+
+		/**
+		 * @brief	Sets the GPU vendor.
+		 */
+		void setVendor(GPUVendor v)
+		{
+			mVendor = v;
+		}
+
+		/**
+		 * @brief	Parses a vendor string and returns an enum with the vendor
+		 *			if parsed succesfully.
+		 */
+		static GPUVendor vendorFromString(const String& vendorString);
+
+		/**
+		 * @brief	Converts a vendor enum to a string.
+		 */
+		static String vendorToString(GPUVendor v);
+
+		/**
+		 * @brief	Sets the maximum number of texture units per pipeline stage.
+		 */
+		void setNumTextureUnits(GpuProgramType type, UINT16 num)
+		{
+			mNumTextureUnitsPerStage[type] = num;
+		}
+
+		/**
+		 * @brief	Sets the maximum number of texture units in all pipeline stages.
+		 */
+		void setNumCombinedTextureUnits(UINT16 num)
+		{
+			mNumCombinedTextureUnits = num;
+		}
+
+		/**
+		 * @brief	Sets the maximum number of GPU param block buffers per pipeline stage.
+		 */
+		void setNumGpuParamBlockBuffers(GpuProgramType type, UINT16 num)
+		{
+			mNumGpuParamBlocksPerStage[type] = num;
+		}
+
+		/**
+		 * @brief	Sets the maximum number of GPU param block buffers in all pipeline stages.
+		 */
+		void setNumCombinedGpuParamBlockBuffers(UINT16 num)
+		{
+			mNumCombinedUniformBlocks = num;
+		}
+
+		/**
+		 * @brief	Sets maximum stencil buffer depth in bits.
+		 */
+		void setStencilBufferBitDepth(UINT16 num)
+		{
+			mStencilBufferBitDepth = num;
+		}
+
+		/**
+		 * @brief	Sets maximum number of bound vertex buffers.
+		 */
+		void setMaxBoundVertexBuffers(UINT32 num)
+		{
+			mMaxBoundVertexBuffers = num;
+		}
+
+		/**
+		 * @brief	Sets maximum number of simultaneously set render targets.
+		 */
+		void setNumMultiRenderTargets(UINT16 num)
+		{
+			mNumMultiRenderTargets = num;
+		}
+
+		/**
+		 * @brief	Returns the number of texture units supported per pipeline stage.
+		 */
+		UINT16 getNumTextureUnits(GpuProgramType type) const
+		{
+			auto iterFind = mNumTextureUnitsPerStage.find(type);
+			if(iterFind != mNumTextureUnitsPerStage.end())
+				return iterFind->second;
+			else
+				return 0;
+		}
+
+		/**
+		* @brief	Returns the number of texture units supported in all pipeline stages.
+		*/
+		UINT16 getNumCombinedTextureUnits() const
+		{
+			return mNumCombinedTextureUnits;
+		}
+
+		/**
+		 * @brief	Returns the maximum number of bound GPU program param block 
+		 *			buffers per pipeline stage.
+		 */
+		UINT16 getNumGpuParamBlockBuffers(GpuProgramType type) const
+		{
+			auto iterFind = mNumGpuParamBlocksPerStage.find(type);
+			if(iterFind != mNumGpuParamBlocksPerStage.end())
+				return iterFind->second;
+			else
+				return 0;
+		}
+
+		/**
+		* @brief	Returns the maximum number of bound GPU program param block
+		*			buffers in all pipeline stages.
+		*/
+		UINT16 getNumCombinedGpuParamBlockBuffers() const
+		{
+			return mNumCombinedUniformBlocks;
+		}
+
+		/**
+		 * @brief	Returns the maximum number of bits available for
+		 *			the stencil buffer.
+		 */
+		UINT16 getStencilBufferBitDepth() const
+		{
+			return mStencilBufferBitDepth;
+		}
+
+		/**
+		 * @brief	Returns the maximum number of vertex buffers that can be bound
+		 *			at once.
+		 */
+		UINT32 getMaxBoundVertexBuffers() const
+		{
+			return mMaxBoundVertexBuffers;
+		}
+
+		/**
+		 * @brief	Returns the maximum number of render targets we can render to
+		 *			simultaneously.
+		 */
+		UINT16 getNumMultiRenderTargets() const
+		{
+			return mNumMultiRenderTargets;
+		}
+
+		/**
+		 * @brief	Sets a capability flag indicating this capability is supported.
+		 */
+		void setCapability(const Capabilities c) 
+		{ 
+			UINT64 index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
+			mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
+		}
+
+		/**
+		 * @brief	Remove a capability flag indicating this capability is 
+		 *			not supported (default).
+		 */
+		void unsetCapability(const Capabilities c) 
+		{ 
+			UINT64 index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
+			mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
+		}
+
+		/**
+		 * @brief	Checks is the specified capability supported.
+		 */
+		bool hasCapability(const Capabilities c) const
+		{
+			UINT64 index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
+
+			return (mCapabilities[index] & (c & ~CAPS_CATEGORY_MASK)) != 0;
+		}
+
+		/**
+		 * @brief	Adds a shader profile to the list of render-system specific supported profiles.
+		 */
+		void addShaderProfile(const String& profile)
+		{
+			mSupportedShaderProfiles.insert(profile);
+		}
+
+		/**
+		 * @brief	Adds a mapping between GPU program profile enum and render-system specific profile name.
+		 */
+		void addGpuProgramProfile(GpuProgramProfile gpuProgProfile, const String& rsSpecificProfile)
+		{
+			mGenericToSpecificShaderProfileMap[gpuProgProfile] = rsSpecificProfile;
+		}
+
+		/**
+		 * @brief	Returns true if the provided profile is supported.
+		 */
+		bool isShaderProfileSupported(const String& profile) const
+		{
+			return (mSupportedShaderProfiles.end() != mSupportedShaderProfiles.find(profile));
+		}
+
+		/**
+		 * @brief	Returns a set of all supported shader profiles.
+		 */
+		const Set<String>& getSupportedShaderProfiles() const
+		{
+			return mSupportedShaderProfiles;
+		}
+
+		/**
+		 * @brief	Converts a generic GpuProgramProfile identifier into a render-system specific one.  
+		 *			Returns an empty string if conversion cannot be done.
+		 */
+		String gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const
+		{
+			auto iterFind = mGenericToSpecificShaderProfileMap.find(gpuProgProfile);
+			if(mGenericToSpecificShaderProfileMap.end() != iterFind)
+			{
+				return iterFind->second;
+			}
+
+			return "";
+		}
+
+		/**
+		 * @brief	Gets the number of floating-point constants vertex programs support.
+		 */
+		UINT16 getVertexProgramConstantFloatCount() const
+		{
+			return mVertexProgramConstantFloatCount;           
+		}
+
+		/**
+		 * @brief	Gets the number of integer constants vertex programs support.
+		 */
+		UINT16 getVertexProgramConstantIntCount() const
+		{
+			return mVertexProgramConstantIntCount;           
+		}
+
+		/**
+		 * @brief	Gets the number of boolean constants vertex programs support.
+		 */
+		UINT16 getVertexProgramConstantBoolCount() const
+		{
+			return mVertexProgramConstantBoolCount;           
+		}
+
+		/**
+		 * @brief	Gets the number of floating-point constants geometry programs support.
+		 */
+		UINT16 getGeometryProgramConstantFloatCount() const
+		{
+			return mGeometryProgramConstantFloatCount;           
+		}
+
+		/**
+		 * @brief	 Gets the number of integer constants geometry programs support.
+		 */
+		UINT16 getGeometryProgramConstantIntCount() const
+		{
+			return mGeometryProgramConstantIntCount;           
+		}
+
+		/**
+		 * @brief	 Gets the number of boolean constants geometry programs support.
+		 */
+		UINT16 getGeometryProgramConstantBoolCount() const
+		{
+			return mGeometryProgramConstantBoolCount;           
+		}
+
+		/**
+		 * @brief	Gets the number of floating-point constants fragment programs support.
+		 */
+		UINT16 getFragmentProgramConstantFloatCount() const
+		{
+			return mFragmentProgramConstantFloatCount;           
+		}
+
+		/**
+		 * @brief	Gets the number of integer constants fragment programs support.
+		 */
+		UINT16 getFragmentProgramConstantIntCount() const
+		{
+			return mFragmentProgramConstantIntCount;           
+		}
+		
+		/**
+		 * @brief	 Gets the number of boolean constants fragment programs support.
+		 */
+		UINT16 getFragmentProgramConstantBoolCount() const
+		{
+			return mFragmentProgramConstantBoolCount;           
+		}
+
+		/**
+		 * @brief	Sets the current GPU device name.
+		 */
+		void setDeviceName(const String& name)
+		{
+			mDeviceName = name;
+		}
+
+		/**
+		 * @brief	Gets the current GPU device name.
+		 */
+		String getDeviceName() const
+		{
+			return mDeviceName;
+		}
+
+		/**
+		 * @brief	Sets the number of floating-point constants vertex programs support.
+		 */
+		void setVertexProgramConstantFloatCount(UINT16 c)
+		{
+			mVertexProgramConstantFloatCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the number of integer constants vertex programs support.
+		 */
+		void setVertexProgramConstantIntCount(UINT16 c)
+		{
+			mVertexProgramConstantIntCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the number of boolean constants vertex programs support.
+		 */
+		void setVertexProgramConstantBoolCount(UINT16 c)
+		{
+			mVertexProgramConstantBoolCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the number of floating-point constants geometry programs support.
+		 */
+		void setGeometryProgramConstantFloatCount(UINT16 c)
+		{
+			mGeometryProgramConstantFloatCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the number of integer constants geometry programs support.
+		 */
+		void setGeometryProgramConstantIntCount(UINT16 c)
+		{
+			mGeometryProgramConstantIntCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the number of boolean constants geometry programs support.
+		 */
+		void setGeometryProgramConstantBoolCount(UINT16 c)
+		{
+			mGeometryProgramConstantBoolCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the number of floating-point constants fragment programs support.
+		 */
+		void setFragmentProgramConstantFloatCount(UINT16 c)
+		{
+			mFragmentProgramConstantFloatCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the number of integer constants fragment programs support.
+		 */
+		void setFragmentProgramConstantIntCount(UINT16 c)
+		{
+			mFragmentProgramConstantIntCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the number of boolean constants fragment programs support.
+		 */
+		void setFragmentProgramConstantBoolCount(UINT16 c)
+		{
+			mFragmentProgramConstantBoolCount = c;           
+		}
+
+		/**
+		 * @brief	Sets the maximum point screen size in pixels.
+		 */
+		void setMaxPointSize(float s)
+		{
+			mMaxPointSize = s;
+		}
+
+		/**
+		 * @brief	Gets the maximum point screen size in pixels.
+		 */
+		float getMaxPointSize(void) const
+		{
+			return mMaxPointSize;
+		}
+
+		/**
+		 * @brief	Sets the number of vertices a single geometry program run can emit.
+		 */
+		void setGeometryProgramNumOutputVertices(int numOutputVertices)
+		{
+			mGeometryProgramNumOutputVertices = numOutputVertices;
+		}
+
+		/**
+		 * @brief	Gets the number of vertices a single geometry program run can emit.
+		 */
+		int getGeometryProgramNumOutputVertices(void) const
+		{
+			return mGeometryProgramNumOutputVertices;
+		}
+
+		/**
+		 * @brief	Get the identifier of the render system from which these capabilities were generated.
+		 */
+		String getRenderSystemName() const
+		{
+			return mRenderSystemName;
+		}
+
+		/**
+		 * @brief	Set the identifier of the render system from which these capabilities were generated.
+		 */
+		void setRenderSystemName(const String& rs)
+		{
+			mRenderSystemName = rs;
+		}
+
+	private:
+		/**
+		 * @brief	Initializes vendor enum -> vendor name mappings.
+		 */
+		static void initVendorStrings();
+
+	private:
+		static Vector<BansheeEngine::String> msGPUVendorStrings;
+
+		DriverVersion mDriverVersion;
+		GPUVendor mVendor = GPU_UNKNOWN;
+
+		// The number of texture units available per stage
+		Map<GpuProgramType, UINT16> mNumTextureUnitsPerStage;
+		// Total number of texture units available
+		UINT16 mNumCombinedTextureUnits = 0;
+		// The number of uniform blocks available per stage
+		Map<GpuProgramType, UINT16> mNumGpuParamBlocksPerStage;
+		// Total number of uniform blocks available
+		UINT16 mNumCombinedUniformBlocks = 0;
+		// The stencil buffer bit depth
+		UINT16 mStencilBufferBitDepth = 0;
+		// Maximum number of vertex buffers we can bind at once
+		UINT32 mMaxBoundVertexBuffers = 0;
+		// Stores the capabilities flags.
+		UINT32 mCapabilities[CAPS_CATEGORY_COUNT];
+		// The name of the device as reported by the render system
+		String mDeviceName;
+		// The identifier associated with the render system for which these capabilities are valid
+		String mRenderSystemName;
+
+		// The number of floating-point constants vertex programs support
+		UINT16 mVertexProgramConstantFloatCount = 0;
+		// The number of integer constants vertex programs support
+		UINT16 mVertexProgramConstantIntCount = 0;
+		// The number of boolean constants vertex programs support
+		UINT16 mVertexProgramConstantBoolCount = 0;
+		// The number of floating-point constants geometry programs support
+		UINT16 mGeometryProgramConstantFloatCount = 0;
+		// The number of integer constants vertex geometry support
+		UINT16 mGeometryProgramConstantIntCount = 0;
+		// The number of boolean constants vertex geometry support
+		UINT16 mGeometryProgramConstantBoolCount = 0;
+		// The number of floating-point constants fragment programs support
+		UINT16 mFragmentProgramConstantFloatCount = 0;
+		// The number of integer constants fragment programs support
+		UINT16 mFragmentProgramConstantIntCount = 0;
+		// The number of boolean constants fragment programs support
+		UINT16 mFragmentProgramConstantBoolCount = 0;
+		// The number of simultaneous render targets supported
+		UINT16 mNumMultiRenderTargets = 0;
+		// The maximum point size in pixels
+		float mMaxPointSize = 0.0f;
+		// The number of vertices a geometry program can emit in a single run
+		UINT32 mGeometryProgramNumOutputVertices = 0;
+
+		// The list of supported shader profiles
+		Set<String> mSupportedShaderProfiles;
+
+		// Allows us to convert a generic shader profile to a render-system specific one
+		UnorderedMap<GpuProgramProfile, String> mGenericToSpecificShaderProfileMap;
+	};
 }

+ 23 - 23
CamelotCore/Include/CmRenderSystemFactory.h → BansheeCore/Include/CmRenderSystemFactory.h

@@ -1,24 +1,24 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Factory class that you may specialize in order to start up
-	 *			a specific render system.
-	 */
-	class RenderSystemFactory
-	{
-	public:
-		/**
-		 * @brief	Creates and starts up the render system managed by this factory. 
-		 */
-		virtual void create() = 0;
-
-		/**
-		 * @brief	Returns the name of the render system this factory creates.
-		 */
-		virtual const String& name() const = 0;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Factory class that you may specialize in order to start up
+	 *			a specific render system.
+	 */
+	class RenderSystemFactory
+	{
+	public:
+		/**
+		 * @brief	Creates and starts up the render system managed by this factory. 
+		 */
+		virtual void create() = 0;
+
+		/**
+		 * @brief	Returns the name of the render system this factory creates.
+		 */
+		virtual const String& name() const = 0;
+	};
 }

+ 40 - 40
CamelotCore/Include/CmRenderSystemManager.h → BansheeCore/Include/CmRenderSystemManager.h

@@ -1,40 +1,40 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmRenderSystemFactory.h"
-
-namespace BansheeEngine
-{
-	typedef std::shared_ptr<RenderSystemFactory> RenderSystemFactoryPtr;
-
-	/**
-	 * @brief	Manager that handles render system start up.
-	 */
-	class CM_EXPORT RenderSystemManager : public Module<RenderSystemManager>
-	{
-	public:
-		RenderSystemManager();
-		~RenderSystemManager();
-
-		/**
-		 * @brief	Starts the render system with the provided name and creates the primary render window.
-		 *
-		 * @param	name				Name of the render system to start. Factory for this render system must be previously
-		 *								registered.
-		 * @param	primaryWindowDesc	Contains options used for creating the primary window.
-		 *
-		 * @returns	Created render window if initialization is successful, null otherwise.
-		 */
-		RenderWindowPtr initialize(const String& name, RENDER_WINDOW_DESC& primaryWindowDesc);
-
-		/**
-		 * @brief	Registers a new render system factory responsible for creating a specific render system type.
-		 */
-		void registerRenderSystemFactory(RenderSystemFactoryPtr factory);
-	private:
-		Vector<RenderSystemFactoryPtr> mAvailableFactories;
-		bool mRenderSystemInitialized;
-	};
-}
-
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include "CmRenderSystemFactory.h"
+
+namespace BansheeEngine
+{
+	typedef std::shared_ptr<RenderSystemFactory> RenderSystemFactoryPtr;
+
+	/**
+	 * @brief	Manager that handles render system start up.
+	 */
+	class BS_CORE_EXPORT RenderSystemManager : public Module<RenderSystemManager>
+	{
+	public:
+		RenderSystemManager();
+		~RenderSystemManager();
+
+		/**
+		 * @brief	Starts the render system with the provided name and creates the primary render window.
+		 *
+		 * @param	name				Name of the render system to start. Factory for this render system must be previously
+		 *								registered.
+		 * @param	primaryWindowDesc	Contains options used for creating the primary window.
+		 *
+		 * @returns	Created render window if initialization is successful, null otherwise.
+		 */
+		RenderWindowPtr initialize(const String& name, RENDER_WINDOW_DESC& primaryWindowDesc);
+
+		/**
+		 * @brief	Registers a new render system factory responsible for creating a specific render system type.
+		 */
+		void registerRenderSystemFactory(RenderSystemFactoryPtr factory);
+	private:
+		Vector<RenderSystemFactoryPtr> mAvailableFactories;
+		bool mRenderSystemInitialized;
+	};
+}
+

+ 170 - 170
CamelotCore/Include/CmRenderTarget.h → BansheeCore/Include/CmRenderTarget.h

@@ -1,170 +1,170 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmString.h"
-#include "CmPixelUtil.h"
-#include "CmViewport.h"
-#include "CmCoreObject.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Structure that contains information about
-	 *			what part of the texture represents the render surface.
-	 */
-	struct CM_EXPORT RENDER_SURFACE_DESC
-	{
-		TexturePtr texture;
-		UINT32 face;
-		UINT32 numFaces;
-		UINT32 mipLevel;
-	};
-
-	/**
-	 * @brief	Render target is a frame buffer or a texture that the render
-	 *			system renders to.
-	 *
-	 * @note	Thread safe, except where noted otherwise.
-	 */
-    class CM_EXPORT RenderTarget : public CoreObject
-    {
-    public:
-		/**
-		 * @brief	Frame buffer type when double-buffering is used.
-		 */
-		enum FrameBuffer
-		{
-			FB_FRONT,
-			FB_BACK,
-			FB_AUTO
-		};
-
-        virtual ~RenderTarget();
-
-		/**
-		 * @brief	Returns a name of the render target, used for easier identification.
-		 */
-        const String& getName() const { return mName; }
-
-		/**
-		 * @brief	Returns width of the render target, in pixels.
-		 */
-        UINT32 getWidth() const { return mWidth; }
-
-		/**
-		 * @brief	Returns height of the render target, in pixels.
-		 */
-        UINT32 getHeight() const { return mHeight; }
-
-		/**
-		 * @brief	Gets the number of samples used for multisampling.
-		 *			(0 if multisampling is not used).
-		 */
-		UINT32 getMultisampleCount() const { return mMultisampleCount; }
-
-		/**
-		 * @brief	Get a render-system specific hint used for determining
-		 *			multisampling type.
-		 */
-		const String& getMultisampleHint() const { return mMultisampleHint; }
-
-		/**
-		 * @brief	Returns true if the render target will wait for vertical sync 
-		 *			before swapping buffers. This will eliminate tearing but may increase
-		 *			input latency.
-		 */
-		bool getVSync() const { return mVSync; }
-
-		/**
-		 * @brief	Queries the render target for a custom attribute. This may be anything and is
-		 *			implementation specific.
-		 *
-		 * @note	Core thread only.
-		 */
-		virtual void getCustomAttribute(const String& name, void* pData) const;
-
-		/**
-		 * @brief	Returns true if the render target is a render window.
-		 */
-		virtual bool isWindow() const = 0;
-
-		/**
-		 * @brief	Returns true if the render target can be used for rendering.
-		 *
-		 * @note	Core thread only.
-		 */
-		bool isActive() const { return mActive; }
-
-		/**
-		 * @brief	Returns true if pixels written to the render target will be gamma corrected.
-		 */
-		bool isHwGammaEnabled() const { return mHwGamma; }
-
-		/**
-		 * @brief	Makes the render target active or inactive. (e.g. for a window, it will hide or restore the window).
-		 *
-		 * @note	Core thread only.
-		 */
-		virtual void setActive(bool state) { mActive = state; }
-
-		/**
-		 * @brief	Returns render target priority. Targets with higher priority will be 
-		 *			rendered before ones with lower priority.
-		 */
-		INT32 getPriority() const { return mPriority; }
-
-		/**
-		 * @brief	Sets a priority that determines in which orders the render targets the processed.
-		 * 			
-		 * @param	priority	The priority. Higher value means the target will be rendered sooner.
-		 */
-		void setPriority(INT32 priority) { mPriority = priority; }
-
-        /**
-         * @brief	Swaps the frame buffers to display the next frame.
-         * 			
-		 * @note	Core thread only.
-         */
-		virtual void swapBuffers() {};
-
-		/**
-		 * @brief	Copy data from the render target into the provided pixel buffer. 
-		 *
-		 * @param	dst		Destination buffer to copy the data to. Caller must ensure the buffer is of adequate size.
-		 * @param	buffer	Which buffer is data taken from. This is irrelevant for single buffer render targets.
-		 *
-		 * @note	Core thread only.
-		 */
-		virtual void copyToMemory(const PixelData &dst, FrameBuffer buffer = FB_AUTO) = 0;
-
-		/**
-		 * @brief	Does the texture need to be vertically flipped because of different screen space coordinate systems.
-		 *			(i.e. is origin top left or bottom left. Engine default is top left.)
-		 */
-		virtual bool requiresTextureFlipping() const = 0;
-
-		/**
-		 * @brief	Event that gets triggered whenever the render target is resized.
-		 *
-		 * @note	Sim thread only.
-		 */
-		mutable Event<void()> onResized;
-    protected:
-		RenderTarget();
-
-        String mName;
-
-        UINT32 mWidth;
-        UINT32 mHeight;
-        UINT32 mColorDepth;
-		
-		INT32 mPriority;
-
-        bool mActive;
-		bool mHwGamma;
-		bool mVSync;
-		UINT32 mMultisampleCount;
-		String mMultisampleHint;
-    };
-}
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmString.h"
+#include "CmPixelUtil.h"
+#include "CmViewport.h"
+#include "CmCoreObject.h"
+#include "BsEvent.h"
+
+namespace BansheeEngine 
+{
+	/**
+	 * @brief	Structure that contains information about
+	 *			what part of the texture represents the render surface.
+	 */
+	struct BS_CORE_EXPORT RENDER_SURFACE_DESC
+	{
+		TexturePtr texture;
+		UINT32 face;
+		UINT32 numFaces;
+		UINT32 mipLevel;
+	};
+
+	/**
+	 * @brief	Render target is a frame buffer or a texture that the render
+	 *			system renders to.
+	 *
+	 * @note	Thread safe, except where noted otherwise.
+	 */
+    class BS_CORE_EXPORT RenderTarget : public CoreObject
+    {
+    public:
+		/**
+		 * @brief	Frame buffer type when double-buffering is used.
+		 */
+		enum FrameBuffer
+		{
+			FB_FRONT,
+			FB_BACK,
+			FB_AUTO
+		};
+
+        virtual ~RenderTarget();
+
+		/**
+		 * @brief	Returns a name of the render target, used for easier identification.
+		 */
+        const String& getName() const { return mName; }
+
+		/**
+		 * @brief	Returns width of the render target, in pixels.
+		 */
+        UINT32 getWidth() const { return mWidth; }
+
+		/**
+		 * @brief	Returns height of the render target, in pixels.
+		 */
+        UINT32 getHeight() const { return mHeight; }
+
+		/**
+		 * @brief	Gets the number of samples used for multisampling.
+		 *			(0 if multisampling is not used).
+		 */
+		UINT32 getMultisampleCount() const { return mMultisampleCount; }
+
+		/**
+		 * @brief	Get a render-system specific hint used for determining
+		 *			multisampling type.
+		 */
+		const String& getMultisampleHint() const { return mMultisampleHint; }
+
+		/**
+		 * @brief	Returns true if the render target will wait for vertical sync 
+		 *			before swapping buffers. This will eliminate tearing but may increase
+		 *			input latency.
+		 */
+		bool getVSync() const { return mVSync; }
+
+		/**
+		 * @brief	Queries the render target for a custom attribute. This may be anything and is
+		 *			implementation specific.
+		 *
+		 * @note	Core thread only.
+		 */
+		virtual void getCustomAttribute(const String& name, void* pData) const;
+
+		/**
+		 * @brief	Returns true if the render target is a render window.
+		 */
+		virtual bool isWindow() const = 0;
+
+		/**
+		 * @brief	Returns true if the render target can be used for rendering.
+		 *
+		 * @note	Core thread only.
+		 */
+		bool isActive() const { return mActive; }
+
+		/**
+		 * @brief	Returns true if pixels written to the render target will be gamma corrected.
+		 */
+		bool isHwGammaEnabled() const { return mHwGamma; }
+
+		/**
+		 * @brief	Makes the render target active or inactive. (e.g. for a window, it will hide or restore the window).
+		 *
+		 * @note	Core thread only.
+		 */
+		virtual void setActive(bool state) { mActive = state; }
+
+		/**
+		 * @brief	Returns render target priority. Targets with higher priority will be 
+		 *			rendered before ones with lower priority.
+		 */
+		INT32 getPriority() const { return mPriority; }
+
+		/**
+		 * @brief	Sets a priority that determines in which orders the render targets the processed.
+		 * 			
+		 * @param	priority	The priority. Higher value means the target will be rendered sooner.
+		 */
+		void setPriority(INT32 priority) { mPriority = priority; }
+
+        /**
+         * @brief	Swaps the frame buffers to display the next frame.
+         * 			
+		 * @note	Core thread only.
+         */
+		virtual void swapBuffers() {};
+
+		/**
+		 * @brief	Copy data from the render target into the provided pixel buffer. 
+		 *
+		 * @param	dst		Destination buffer to copy the data to. Caller must ensure the buffer is of adequate size.
+		 * @param	buffer	Which buffer is data taken from. This is irrelevant for single buffer render targets.
+		 *
+		 * @note	Core thread only.
+		 */
+		virtual void copyToMemory(const PixelData &dst, FrameBuffer buffer = FB_AUTO) = 0;
+
+		/**
+		 * @brief	Does the texture need to be vertically flipped because of different screen space coordinate systems.
+		 *			(i.e. is origin top left or bottom left. Engine default is top left.)
+		 */
+		virtual bool requiresTextureFlipping() const = 0;
+
+		/**
+		 * @brief	Event that gets triggered whenever the render target is resized.
+		 *
+		 * @note	Sim thread only.
+		 */
+		mutable Event<void()> onResized;
+    protected:
+		RenderTarget();
+
+        String mName;
+
+        UINT32 mWidth;
+        UINT32 mHeight;
+        UINT32 mColorDepth;
+		
+		INT32 mPriority;
+
+        bool mActive;
+		bool mHwGamma;
+		bool mVSync;
+		UINT32 mMultisampleCount;
+		String mMultisampleHint;
+    };
+}

+ 101 - 101
CamelotCore/Include/CmRenderTexture.h → BansheeCore/Include/CmRenderTexture.h

@@ -1,102 +1,102 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmTexture.h"
-#include "CmRenderTarget.h"
-
-namespace BansheeEngine
-{    
-	/**
-	 * @brief	Structure that describes a render texture color and depth/stencil surfaces.
-	 */
-	struct CM_EXPORT RENDER_TEXTURE_DESC
-	{
-		RENDER_SURFACE_DESC colorSurface;
-		RENDER_SURFACE_DESC depthStencilSurface;
-	};
-
-	/**
-	 * @brief	Render target specialization that allows you to render into a texture you may
-	 *			later bind in further render operations.
-	 *
-	 * @note	Thread safe, except where noted otherwise.
-	 */
-    class CM_EXPORT RenderTexture : public RenderTarget
-    {
-	public:
-		virtual ~RenderTexture();
-
-		/**
-		 * @brief	Creates a new render texture with color and optionally depth/stencil surfaces.
-		 *
-		 * @param	textureType			Type of texture to render to.
-		 * @param	width				Width of the render texture, in pixels.
-		 * @param	height				Height of the render texture, in pixels.
-		 * @param	format				Pixel format used by the texture color surface.
-		 * @param	hwGamma				Should the written pixels be gamma corrected.
-		 * @param	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
-		 * @param	multisampleHint		Hint about what kind of multisampling to use. Render system specific.
-		 * @param	createDepth			Should a depth/stencil surface be created along with the color surface.
-		 * @param	depthStencilFormat	Format used by the depth stencil surface, if one is created.
-		 */
-		static RenderTexturePtr create(TextureType textureType, UINT32 width, UINT32 height, 
-			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
-			const String& multisampleHint = "", bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
-
-		/**
-		 * @copydoc RenderTarget::isWindow.
-		 */
-		bool isWindow() const { return false; }
-
-		/**
-		 * @copydoc RenderTarget::requiresTextureFlipping.
-		 */
-		bool requiresTextureFlipping() const { return false; }
-
-		/**
-		 * @brief	Returns a color surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const HTexture& getBindableColorTexture() const { return mBindableColorTex; }
-
-		/**
-		* @brief	Returns a depth/stencil surface texture you may bind as an input to an GPU program.
-		*
-		* @note		Be aware that you cannot bind a render texture for reading and writing at the same time.
-		*/
-		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
-
-	protected:
-		friend class TextureManager;
-
-		RenderTexture();
-
-		/**
-		 * @copydoc	RenderTarget::initialize
-		 */
-		void initialize(const RENDER_TEXTURE_DESC& desc);
-
-		/**
-		 * @copydoc RenderTarget::destroy_internal()
-		 */
-		virtual void destroy_internal();
-	private:
-		/**
-		 * @brief	Throws an exception of the color and depth/stencil buffers aren't compatible.
-		 */
-		void throwIfBuffersDontMatch() const;
-
-		/**
-		 * @copydoc	RenderTarget::copyToMemory
-		 */
-		virtual void copyToMemory(const PixelData &dst, FrameBuffer buffer = FB_AUTO);
-
-	protected:
-		TextureViewPtr mColorSurface;
-		TextureViewPtr mDepthStencilSurface;
-
-		HTexture mBindableColorTex;
-		HTexture mBindableDepthStencilTex;
-	};
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmTexture.h"
+#include "CmRenderTarget.h"
+
+namespace BansheeEngine
+{    
+	/**
+	 * @brief	Structure that describes a render texture color and depth/stencil surfaces.
+	 */
+	struct BS_CORE_EXPORT RENDER_TEXTURE_DESC
+	{
+		RENDER_SURFACE_DESC colorSurface;
+		RENDER_SURFACE_DESC depthStencilSurface;
+	};
+
+	/**
+	 * @brief	Render target specialization that allows you to render into a texture you may
+	 *			later bind in further render operations.
+	 *
+	 * @note	Thread safe, except where noted otherwise.
+	 */
+    class BS_CORE_EXPORT RenderTexture : public RenderTarget
+    {
+	public:
+		virtual ~RenderTexture();
+
+		/**
+		 * @brief	Creates a new render texture with color and optionally depth/stencil surfaces.
+		 *
+		 * @param	textureType			Type of texture to render to.
+		 * @param	width				Width of the render texture, in pixels.
+		 * @param	height				Height of the render texture, in pixels.
+		 * @param	format				Pixel format used by the texture color surface.
+		 * @param	hwGamma				Should the written pixels be gamma corrected.
+		 * @param	multisampleCount	If higher than 1, texture containing multiple samples per pixel is created.
+		 * @param	multisampleHint		Hint about what kind of multisampling to use. Render system specific.
+		 * @param	createDepth			Should a depth/stencil surface be created along with the color surface.
+		 * @param	depthStencilFormat	Format used by the depth stencil surface, if one is created.
+		 */
+		static RenderTexturePtr create(TextureType textureType, UINT32 width, UINT32 height, 
+			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
+			const String& multisampleHint = "", bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
+
+		/**
+		 * @copydoc RenderTarget::isWindow.
+		 */
+		bool isWindow() const { return false; }
+
+		/**
+		 * @copydoc RenderTarget::requiresTextureFlipping.
+		 */
+		bool requiresTextureFlipping() const { return false; }
+
+		/**
+		 * @brief	Returns a color surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
+		const HTexture& getBindableColorTexture() const { return mBindableColorTex; }
+
+		/**
+		* @brief	Returns a depth/stencil surface texture you may bind as an input to an GPU program.
+		*
+		* @note		Be aware that you cannot bind a render texture for reading and writing at the same time.
+		*/
+		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
+
+	protected:
+		friend class TextureManager;
+
+		RenderTexture();
+
+		/**
+		 * @copydoc	RenderTarget::initialize
+		 */
+		void initialize(const RENDER_TEXTURE_DESC& desc);
+
+		/**
+		 * @copydoc RenderTarget::destroy_internal()
+		 */
+		virtual void destroy_internal();
+	private:
+		/**
+		 * @brief	Throws an exception of the color and depth/stencil buffers aren't compatible.
+		 */
+		void throwIfBuffersDontMatch() const;
+
+		/**
+		 * @copydoc	RenderTarget::copyToMemory
+		 */
+		virtual void copyToMemory(const PixelData &dst, FrameBuffer buffer = FB_AUTO);
+
+	protected:
+		TextureViewPtr mColorSurface;
+		TextureViewPtr mDepthStencilSurface;
+
+		HTexture mBindableColorTex;
+		HTexture mBindableDepthStencilTex;
+	};
 }

Some files were not shown because too many files changed in this diff