From 9ccee73baca0fd7ecb95c90cb983133b737c6c55 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 20 Oct 2015 20:46:28 -0700 Subject: Release v1.0.0 --- .../GraphicsTools/build/Windows/EngineRoot.props | 18 + .../build/Windows/GraphicsTools-Debug.vgdbsettings | 76 +++ .../Windows/GraphicsTools-Release.vgdbsettings | 76 +++ .../build/Windows/GraphicsTools.props | 10 + .../build/Windows/GraphicsTools.vcxproj | 181 ++++++ .../build/Windows/GraphicsTools.vcxproj.filters | 32 ++ .../GraphicsTools/build/Windows/jni/Android.mk | 25 + .../GraphicsTools/build/Windows/jni/Application.mk | 7 + .../build/WindowsStore/EngineRoot.props | 18 + .../GraphicsTools.Shared.vcxitems | 32 ++ .../GraphicsTools.Shared.vcxitems.filters | 36 ++ .../GraphicsTools.Windows.vcxproj | 205 +++++++ .../GraphicsTools.Windows.vcxproj.filters | 5 + .../GraphicsTools.WindowsPhone.vcxproj | 144 +++++ .../GraphicsTools.WindowsPhone.vcxproj.filters | 5 + .../include/BasicShaderSourceStreamFactory.h | 41 ++ Graphics/GraphicsTools/include/GraphicsUtilities.h | 201 +++++++ Graphics/GraphicsTools/include/ShaderMacroHelper.h | 122 ++++ Graphics/GraphicsTools/include/pch.h | 26 + .../src/BasicShaderSourceStreamFactory.cpp | 87 +++ Graphics/GraphicsTools/src/GraphicsUtilities.cpp | 621 +++++++++++++++++++++ Graphics/GraphicsTools/src/pch.cpp | 24 + 22 files changed, 1992 insertions(+) create mode 100644 Graphics/GraphicsTools/build/Windows/EngineRoot.props create mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings create mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings create mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools.props create mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj create mode 100644 Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters create mode 100644 Graphics/GraphicsTools/build/Windows/jni/Android.mk create mode 100644 Graphics/GraphicsTools/build/Windows/jni/Application.mk create mode 100644 Graphics/GraphicsTools/build/WindowsStore/EngineRoot.props create mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems create mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems.filters create mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj create mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj.filters create mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj create mode 100644 Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj.filters create mode 100644 Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h create mode 100644 Graphics/GraphicsTools/include/GraphicsUtilities.h create mode 100644 Graphics/GraphicsTools/include/ShaderMacroHelper.h create mode 100644 Graphics/GraphicsTools/include/pch.h create mode 100644 Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp create mode 100644 Graphics/GraphicsTools/src/GraphicsUtilities.cpp create mode 100644 Graphics/GraphicsTools/src/pch.cpp (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/build/Windows/EngineRoot.props b/Graphics/GraphicsTools/build/Windows/EngineRoot.props new file mode 100644 index 00000000..6e4b958b --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows/EngineRoot.props @@ -0,0 +1,18 @@ + + + + + ..\..\..\.. + ..\..\.. + + + + + + $(EngineRoot) + + + $(GraphicsRoot) + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings b/Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings new file mode 100644 index 00000000..3f5b24b1 --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows/GraphicsTools-Debug.vgdbsettings @@ -0,0 +1,76 @@ + + + Debug + + + + MinGWWindowsSlash + + $(ProjectDir) + + + android-19 + true + true + bin;obj + false + false + + + + + + false + false + true + false + false + false + false + true + false + KillApp + + false + false + false + false + false + false + false + false + + false + false + main + true + + + false + false + 5039 + 5039 + 10000 + 0 + false + Ask + true + true + + + + + + + + + + + Default + + + + true + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings b/Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings new file mode 100644 index 00000000..669691f2 --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows/GraphicsTools-Release.vgdbsettings @@ -0,0 +1,76 @@ + + + Release + + + + MinGWWindowsSlash + + $(ProjectDir) + + + android-19 + false + true + bin;obj + false + false + + + + + + false + false + true + false + false + false + false + true + false + KillApp + + false + false + false + false + false + false + false + false + + false + false + main + true + + + false + false + 5039 + 5039 + 10000 + 0 + false + Ask + true + true + + + + + + + + + + + Default + + + + true + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools.props b/Graphics/GraphicsTools/build/Windows/GraphicsTools.props new file mode 100644 index 00000000..22851e71 --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows/GraphicsTools.props @@ -0,0 +1,10 @@ + + + + + + $(GraphicsRoot)\GraphicsTools\include;$(GraphicsRoot)\GraphicsEngine\interface;$(GraphicsRoot)\TextureLoader\interface;$(EngineRoot)\Common\include;$(EngineRoot)\Common\interface;$(EngineRoot)\Platforms\interface;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(IncludePath) + + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj b/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj new file mode 100644 index 00000000..c90a589b --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj @@ -0,0 +1,181 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {C6014499-0CF2-43EC-A773-A4E354FB2D74} + Win32Proj + GraphicsTools + + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + false + v140 + true + Unicode + + + StaticLibrary + false + v140 + true + Unicode + + + v120 + Makefile + + + v120 + Makefile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + Level3 + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + Level3 + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + + + + + + + true + true + true + true + + + true + true + true + true + + + + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters b/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters new file mode 100644 index 00000000..89d44e9e --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows/GraphicsTools.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + + + + + + jni + + + jni + + + + + android_src + + + android_src + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/Windows/jni/Android.mk b/Graphics/GraphicsTools/build/Windows/jni/Android.mk new file mode 100644 index 00000000..2b02dd54 --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows/jni/Android.mk @@ -0,0 +1,25 @@ +# Android NDK project makefile autogenerated by Premake + +# Preamble +DEPENDENCY_PATH := $(call my-dir) +LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) +include $(CLEAR_VARS) + + +# Project configuration +LOCAL_MODULE := GraphicsTools +LOCAL_CFLAGS := -std=c++11 +LOCAL_CPP_FEATURES := exceptions +LOCAL_STATIC_LIBRARIES += + +# Include paths +PROJECT_ROOT := $(LOCAL_PATH)/../../.. +GRAPHICS_ROOT := $(PROJECT_ROOT)/.. +SOLUTION_ROOT := $(GRAPHICS_ROOT)/.. +LOCAL_C_INCLUDES := $(PROJECT_ROOT)/include $(SOLUTION_ROOT)/Common/include $(SOLUTION_ROOT)/Common/interface $(SOLUTION_ROOT)/Platforms/interface $(GRAPHICS_ROOT)/GraphicsEngine/interface $(GRAPHICS_ROOT)/GraphicsTools/include $(GRAPHICS_ROOT)/TextureLoader/interface + +# Source files +#VisualGDBAndroid: AutoUpdateSourcesInNextLine +LOCAL_SRC_FILES := ../../../src/BasicShaderSourceStreamFactory.cpp ../../../src/GraphicsUtilities.cpp + +include $(BUILD_STATIC_LIBRARY) diff --git a/Graphics/GraphicsTools/build/Windows/jni/Application.mk b/Graphics/GraphicsTools/build/Windows/jni/Application.mk new file mode 100644 index 00000000..063ff721 --- /dev/null +++ b/Graphics/GraphicsTools/build/Windows/jni/Application.mk @@ -0,0 +1,7 @@ +# Generated by VisualGDB + +DEPENDENCY_PATH := $(call my-dir) +LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) +include $(LOCAL_PATH)/../../../../../Common/make/AppCommon.mk + +APP_MODULES := GraphicsTools \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/EngineRoot.props b/Graphics/GraphicsTools/build/WindowsStore/EngineRoot.props new file mode 100644 index 00000000..fcb891c0 --- /dev/null +++ b/Graphics/GraphicsTools/build/WindowsStore/EngineRoot.props @@ -0,0 +1,18 @@ + + + + + ..\..\..\..\.. + ..\..\..\.. + + + + + + $(EngineRoot) + + + $(GraphicsRoot) + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems new file mode 100644 index 00000000..6a1aa429 --- /dev/null +++ b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems @@ -0,0 +1,32 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {3bb4f2ac-1d2f-4af6-b9cc-bdc17bb8bc39} + GraphicsTools + GraphicsTools.Shared + 248F659F-DAC5-46E8-AC09-60EC9FC95053 + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + + + + Create + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems.filters b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems.filters new file mode 100644 index 00000000..ed522894 --- /dev/null +++ b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Shared/GraphicsTools.Shared.vcxitems.filters @@ -0,0 +1,36 @@ + + + + + {610cb4a4-ad9a-42e0-936c-239055f0caa6} + + + {2fa69c92-b6b7-4e73-9ccd-49a715515cc8} + + + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj new file mode 100644 index 00000000..85152c29 --- /dev/null +++ b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj @@ -0,0 +1,205 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {dac331f3-c5a2-4568-8714-9213c3487a49} + GraphicsTools + en-US + 12.0 + true + Windows Store + 8.1 + CodeSharingStaticLibrary + + + + StaticLibrary + true + v120 + + + StaticLibrary + true + v120 + + + StaticLibrary + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + false + + + false + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj.filters b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj.filters new file mode 100644 index 00000000..a7761ab0 --- /dev/null +++ b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.Windows/GraphicsTools.Windows.vcxproj.filters @@ -0,0 +1,5 @@ + + + + + diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj new file mode 100644 index 00000000..e99bf6b4 --- /dev/null +++ b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Release + ARM + + + Release + Win32 + + + + {2f340c0e-43b2-471f-b4f3-7cdce69f6e1f} + GraphicsTools + en-US + 12.0 + true + Windows Phone + 8.1 + CodeSharingStaticLibrary + + + + StaticLibrary + true + v120_wp81 + + + StaticLibrary + true + v120_wp81 + + + StaticLibrary + false + true + v120_wp81 + + + StaticLibrary + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj.filters b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj.filters new file mode 100644 index 00000000..a7761ab0 --- /dev/null +++ b/Graphics/GraphicsTools/build/WindowsStore/GraphicsTools.WindowsPhone/GraphicsTools.WindowsPhone.vcxproj.filters @@ -0,0 +1,5 @@ + + + + + diff --git a/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h b/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h new file mode 100644 index 00000000..76adc056 --- /dev/null +++ b/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h @@ -0,0 +1,41 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "BasicFileStream.h" +#include "Shader.h" + +namespace Diligent +{ + class BasicShaderSourceStreamFactory : public IShaderSourceInputStreamFactory + { + public: + BasicShaderSourceStreamFactory( const Char *SearchDirectories = nullptr ); + + virtual void CreateInputStream( const Diligent::Char *Name, IFileStream **ppStream )override; + + private: + std::vector m_SearchDirectories; + }; +} diff --git a/Graphics/GraphicsTools/include/GraphicsUtilities.h b/Graphics/GraphicsTools/include/GraphicsUtilities.h new file mode 100644 index 00000000..78002d01 --- /dev/null +++ b/Graphics/GraphicsTools/include/GraphicsUtilities.h @@ -0,0 +1,201 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +/// \file +/// Defines graphics engine utilities + +#include "GraphicsTypes.h" +#include "Shader.h" +#include "Texture.h" +#include "Buffer.h" +#include "RenderDevice.h" + +namespace Diligent +{ + +/// Template structure to convert VALUE_TYPE enumeration into C-type +template +struct VALUE_TYPE2CType +{}; + +/// VALUE_TYPE2CType<> template specialization for 8-bit integer value type. + +/// Usage example: +/// +/// VALUE_TYPE2CType::CType MyInt8Var; +template<>struct VALUE_TYPE2CType { typedef Int8 CType; }; + +/// VALUE_TYPE2CType<> template specialization for 16-bit integer value type. + +/// Usage example: +/// +/// VALUE_TYPE2CType::CType MyInt16Var; +template<>struct VALUE_TYPE2CType { typedef Int16 CType; }; + +/// VALUE_TYPE2CType<> template specialization for 32-bit integer value type. + +/// Usage example: +/// +/// VALUE_TYPE2CType::CType MyInt32Var; +template<>struct VALUE_TYPE2CType { typedef Int32 CType; }; + +/// VALUE_TYPE2CType<> template specialization for 8-bit unsigned-integer value type. + +/// Usage example: +/// +/// VALUE_TYPE2CType::CType MyUint8Var; +template<>struct VALUE_TYPE2CType { typedef Uint8 CType; }; + +/// VALUE_TYPE2CType<> template specialization for 16-bit unsigned-integer value type. + +/// Usage example: +/// +/// VALUE_TYPE2CType::CType MyUint16Var; +template<>struct VALUE_TYPE2CType{ typedef Uint16 CType; }; + +/// VALUE_TYPE2CType<> template specialization for 32-bit unsigned-integer value type. + +/// Usage example: +/// +/// VALUE_TYPE2CType::CType MyUint32Var; +template<>struct VALUE_TYPE2CType{ typedef Uint32 CType; }; + +/// VALUE_TYPE2CType<> template specialization for half-precision 16-bit floating-point value type. + +/// Usage example: +/// +/// VALUE_TYPE2CType::CType MyFloat16Var; +/// +/// \note 16-bit floating-point values have no corresponding C++ type and are translated to Uint16 +template<>struct VALUE_TYPE2CType{ typedef Uint16 CType; }; + +/// VALUE_TYPE2CType<> template specialization for full-precision 32-bit floating-point value type. + +/// Usage example: +/// +/// VALUE_TYPE2CType::CType MyFloat32Var; +template<>struct VALUE_TYPE2CType{ typedef Float32 CType; }; + + +/// Returns the size of the specified value type +Uint32 GetValueSize( VALUE_TYPE Val ); + +/// Returns the string representing the specified value type +const Char* GetValueTypeString( VALUE_TYPE Val ); + +/// Returns invariant texture format attributes, see TextureFormatAttribs for details. + +/// \param [in] Format - Texture format which attributes are requested for. +/// \return Constant reference to the TextureFormatAttribs structure containing +/// format attributes. +const TextureFormatAttribs& GetTextureFormatAttribs(TEXTURE_FORMAT Format); + + +/// Returns the literal name of a texture view type. For instance, +/// for a shader resource view, "TEXTURE_VIEW_SHADER_RESOURCE" will be returned. + +/// \param [in] ViewType - Texture view type. +/// \return Literal name of the texture view type. +const Char *GetTexViewTypeLiteralName(TEXTURE_VIEW_TYPE ViewType); + +/// Returns the literal name of a buffer view type. For instance, +/// for an unordered access view, "BUFFER_VIEW_UNORDERED_ACCESS" will be returned. + +/// \param [in] ViewType - Buffer view type. +/// \return Literal name of the buffer view type. +const Char *GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType); + +/// Returns the literal name of a shader type. For instance, +/// for a pixel shader, "SHADER_TYPE_PIXEL" will be returned. + +/// \param [in] ShaderType - Shader type. +/// \return Literal name of the shader type. +const Char *GetShaderTypeLiteralName(SHADER_TYPE ShaderType); + +/// Overloaded function that returns the literal name of a texture view type. +/// see GetTexViewTypeLiteralName(). +inline const Char* GetViewTypeLiteralName(TEXTURE_VIEW_TYPE TexViewType) +{ + return GetTexViewTypeLiteralName( TexViewType ); +} + +/// Overloaded function that returns the literal name of a buffer view type. +/// see GetBufferViewTypeLiteralName(). +inline const Char* GetViewTypeLiteralName(BUFFER_VIEW_TYPE BuffViewType) +{ + return GetBufferViewTypeLiteralName( BuffViewType ); +} + +/// Returns the string containing the usage +const Char* GetUsageString(USAGE Usage); + +/// Returns the string containing the texture type +const Char* GetTextureTypeString( TEXTURE_TYPE TexType ); + +/// Returns the string containing the bind flags +String GetBindFlagsString( Uint32 BindFlags ); + +/// Returns the string containing the CPU access flags +String GetCPUAccessFlagsString( Uint32 CpuAccessFlags ); + +/// Returns the string containing the texture description +String GetTextureDescString(const TextureDesc &Desc); + +/// Returns the string containing the buffer description +String GetBufferDescString(const BufferDesc &Desc); + + +/// Helper template function that converts object description into a string +template +String GetObjectDescString( const TObjectDescType& ) +{ + return ""; +} + +/// Template specialization for texture description +template<> +inline String GetObjectDescString( const TextureDesc& TexDesc ) +{ + String Str( "Tex desc: " ); + Str += GetTextureDescString( TexDesc ); + return Str; +} + +/// Template specialization for buffer description +template<> +inline String GetObjectDescString( const BufferDesc& BuffDesc ) +{ + String Str( "Buff desc: " ); + Str += GetBufferDescString( BuffDesc ); + return Str; +} + +Uint32 ComputeMipLevelsCount( Uint32 Width ); +Uint32 ComputeMipLevelsCount( Uint32 Width, Uint32 Height ); +Uint32 ComputeMipLevelsCount( Uint32 Width, Uint32 Height, Uint32 Depth ); + +void CreateUniformBuffer( IRenderDevice *pDevice, Uint32 Size, IBuffer **ppBuffer, USAGE Usage = USAGE_DYNAMIC, Uint32 BindFlag = BIND_UNIFORM_BUFFER, Uint32 CPUAccessFlags = CPU_ACCESS_WRITE ); + +} diff --git a/Graphics/GraphicsTools/include/ShaderMacroHelper.h b/Graphics/GraphicsTools/include/ShaderMacroHelper.h new file mode 100644 index 00000000..bcfc3e52 --- /dev/null +++ b/Graphics/GraphicsTools/include/ShaderMacroHelper.h @@ -0,0 +1,122 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +//-------------------------------------------------------------------------------------- +// Copyright 2013 Intel Corporation +// All Rights Reserved +// +// Permission is granted to use, copy, distribute and prepare derivative works of this +// software for any purpose and without fee, provided, that the above copyright notice +// and this statement appear in all copies. Intel makes no representations about the +// suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS." +// INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY, +// INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE, +// INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not +// assume any responsibility for any errors which may appear in this software nor any +// responsibility to update it. +//-------------------------------------------------------------------------------------- + +#include +#include +#include +#include +#include "BasicTypes.h" +#include "DebugUtilities.h" +#include "Shader.h" + +namespace Diligent +{ + +class ShaderMacroHelper +{ +public: + ShaderMacroHelper() : m_bIsFinalized(false) {} + + template + void AddShaderMacro( const Diligent::Char* Name, DefintionType Definition ) + { + assert( !m_bIsFinalized ); + std::ostringstream ss; + ss << Definition; + AddShaderMacro( Name, ss.str().c_str() ); + } + + void Finalize() + { + ShaderMacro LastMacro = {NULL, NULL}; + m_Macros.push_back(LastMacro); + m_bIsFinalized = true; + } + + operator const ShaderMacro* () + { + assert( !m_Macros.size() || m_bIsFinalized ); + if( m_Macros.size() && !m_bIsFinalized ) + Finalize(); + return m_Macros.size() ? &m_Macros[0] : NULL; + } + +private: + + std::vector< ShaderMacro > m_Macros; + std::set< std::string > m_DefinitionsPull; + bool m_bIsFinalized; +}; + +template<> +inline void ShaderMacroHelper::AddShaderMacro( const Diligent::Char* Name, const Diligent::Char* Definition ) +{ + VERIFY_EXPR( !m_bIsFinalized ); + ShaderMacro NewMacro = + { + Name, + m_DefinitionsPull.insert(Definition).first->c_str() + }; + m_Macros.push_back(NewMacro); +} + +template<> +inline void ShaderMacroHelper::AddShaderMacro( const Diligent::Char* Name, bool Definition ) +{ + assert( !m_bIsFinalized ); + AddShaderMacro( Name, Definition ? "1" : "0"); +} + +template<> +inline void ShaderMacroHelper::AddShaderMacro( const Diligent::Char* Name, float Definition ) +{ + assert( !m_bIsFinalized ); + std::ostringstream ss; + + // Make sure that when floating point represents integer, it is still + // written as float: 1024.0, but not 1024. This is essnetial to + // avoid type conversion issues in GLES. + if( Definition == static_cast(static_cast(Definition)) ) + ss << std::fixed << std::setprecision( 1 ); + + ss << Definition; + AddShaderMacro( Name, ss.str().c_str() ); +} + +} diff --git a/Graphics/GraphicsTools/include/pch.h b/Graphics/GraphicsTools/include/pch.h new file mode 100644 index 00000000..b2893486 --- /dev/null +++ b/Graphics/GraphicsTools/include/pch.h @@ -0,0 +1,26 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + + diff --git a/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp b/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp new file mode 100644 index 00000000..fa69c7c1 --- /dev/null +++ b/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp @@ -0,0 +1,87 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" +#include "BasicShaderSourceStreamFactory.h" +#include "RefCntAutoPtr.h" + +namespace Diligent +{ + BasicShaderSourceStreamFactory::BasicShaderSourceStreamFactory( const Char *SearchDirectories ) + { + while( SearchDirectories ) + { + const char* Semicolon = strchr( SearchDirectories, ';' ); + String SearchPath; + if( Semicolon == nullptr ) + { + SearchPath = SearchDirectories; + SearchDirectories = nullptr; + } + else + { + SearchPath = String( SearchDirectories, Semicolon ); + SearchDirectories = Semicolon + 1; + } + + if( SearchPath.length() > 0 ) + { + if( SearchPath.back() != '\\' && SearchPath.back() != '/' ) + SearchPath.push_back( '\\' ); + m_SearchDirectories.push_back( SearchPath ); + } + } + m_SearchDirectories.push_back( "" ); + } + + void BasicShaderSourceStreamFactory::CreateInputStream( const Diligent::Char *Name, IFileStream **ppStream ) + { + bool bFileCreated = false; + Diligent::RefCntAutoPtr pBasicFileStream; + for( const auto &SearchDir : m_SearchDirectories ) + { + String FullPath = SearchDir + ( (Name[0] == '\\' || Name[0] == '/') ? Name + 1 : Name); + if( !FileSystem::FileExists( FullPath.c_str() ) ) + continue; + pBasicFileStream = new BasicFileStream( FullPath.c_str(), EFileAccessMode::Read ); + if( pBasicFileStream->IsValid() ) + { + bFileCreated = true; + break; + } + else + { + pBasicFileStream.Release(); + } + } + if( bFileCreated ) + { + pBasicFileStream->QueryInterface( IID_FileStream, reinterpret_cast(ppStream) ); + } + else + { + *ppStream = nullptr; + LOG_ERROR_AND_THROW( "Failed to create input stream for source file ", Name ) + } + } +} \ No newline at end of file diff --git a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp new file mode 100644 index 00000000..05cc0a3a --- /dev/null +++ b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp @@ -0,0 +1,621 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" +#include "GraphicsUtilities.h" +#include "DebugUtilities.h" +#include + +namespace Diligent +{ + +Uint32 GetValueSize( VALUE_TYPE Val ) +{ + static Uint32 Sizes[VT_NUM_TYPES] = {}; + static bool bIsInit = false; + // Note that this implementation is thread-safe + // Even if two threads try to call the function at the same time, + // the worst thing that might happen is that the array will be + // initialized multiple times. But the result will always be correct + if( !bIsInit ) + { + Sizes[VT_UNDEFINED] = 0; +#define INIT_VALUE_SIZE( ValType ) Sizes[ValType] = sizeof(VALUE_TYPE2CType::CType) + INIT_VALUE_SIZE( VT_INT8 ); + INIT_VALUE_SIZE( VT_INT16 ); + INIT_VALUE_SIZE( VT_INT32 ); + INIT_VALUE_SIZE( VT_UINT8 ); + INIT_VALUE_SIZE( VT_UINT16 ); + INIT_VALUE_SIZE( VT_UINT32 ); + INIT_VALUE_SIZE( VT_FLOAT16 ); + INIT_VALUE_SIZE( VT_FLOAT32 ); +#undef INIT_VALUE_SIZE + static_assert(VT_NUM_TYPES == VT_FLOAT32 + 1, "Not all value type sizes initialized."); + bIsInit = true; + } + + if( Val > VT_UNDEFINED && Val < VT_NUM_TYPES ) + { + return Sizes[Val]; + } + else + { + UNEXPECTED( "Incorrect value type (", Val, ")" ) + return 0; + } +} + +const Char* GetValueTypeString( VALUE_TYPE Val ) +{ + static const Char* ValueTypeStrings[VT_NUM_TYPES] = {}; + static bool bIsInit = false; + if( !bIsInit ) + { +#define INIT_VALUE_TYPE_STR( ValType ) ValueTypeStrings[ValType] = #ValType + INIT_VALUE_TYPE_STR( VT_UNDEFINED ); + INIT_VALUE_TYPE_STR( VT_INT8 ); + INIT_VALUE_TYPE_STR( VT_INT16 ); + INIT_VALUE_TYPE_STR( VT_INT32 ); + INIT_VALUE_TYPE_STR( VT_UINT8 ); + INIT_VALUE_TYPE_STR( VT_UINT16 ); + INIT_VALUE_TYPE_STR( VT_UINT32 ); + INIT_VALUE_TYPE_STR( VT_FLOAT16 ); + INIT_VALUE_TYPE_STR( VT_FLOAT32 ); +#undef INIT_VALUE_TYPE_STR + static_assert(VT_NUM_TYPES == VT_FLOAT32 + 1, "Not all value type strings initialized."); + bIsInit = true; + } + + if( Val >= VT_UNDEFINED && Val < VT_NUM_TYPES ) + { + return ValueTypeStrings[Val]; + } + else + { + UNEXPECTED( "Incorrect value type (", Val, ")" ) + return "unknown value type"; + } +} + +const TextureFormatAttribs& GetTextureFormatAttribs( TEXTURE_FORMAT Format ) +{ + static TextureFormatAttribs FmtAttribs[TEX_FORMAT_NUM_FORMATS] = {}; + static bool bIsInit = false; + // Note that this implementation is thread-safe + // Even if two threads try to call the function at the same time, + // the worst thing that might happen is that the array will be + // initialized multiple times. But the result will always be correct. + if( !bIsInit ) + { +#define INIT_TEX_FORMAT_INFO(TexFmt, ComponentSize, NumComponents, ComponentType) \ + FmtAttribs[ TexFmt ] = TextureFormatAttribs(TexFmt, #TexFmt, ComponentSize, NumComponents, ComponentType); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA32_TYPELESS, 4, 4, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA32_FLOAT, 4, 4, COMPONENT_TYPE_FLOAT ); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA32_UINT, 4, 4, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA32_SINT, 4, 4, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGB32_TYPELESS, 4, 3, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGB32_FLOAT, 4, 3, COMPONENT_TYPE_FLOAT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGB32_UINT, 4, 3, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGB32_SINT, 4, 3, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA16_TYPELESS, 2, 4, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA16_FLOAT, 2, 4, COMPONENT_TYPE_FLOAT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA16_UNORM, 2, 4, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA16_UINT, 2, 4, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA16_SNORM, 2, 4, COMPONENT_TYPE_SNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA16_SINT, 2, 4, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG32_TYPELESS, 4, 2, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG32_FLOAT, 4, 2, COMPONENT_TYPE_FLOAT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG32_UINT, 4, 2, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG32_SINT, 4, 2, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R32G8X24_TYPELESS, 4, 2, COMPONENT_TYPE_DEPTH_STENCIL); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_D32_FLOAT_S8X24_UINT, 4, 2, COMPONENT_TYPE_DEPTH_STENCIL); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS,4, 2, COMPONENT_TYPE_DEPTH_STENCIL); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_X32_TYPELESS_G8X24_UINT, 4, 2, COMPONENT_TYPE_DEPTH_STENCIL); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGB10A2_TYPELESS, 4, 1, COMPONENT_TYPE_COMPOUND); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGB10A2_UNORM, 4, 1, COMPONENT_TYPE_COMPOUND); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGB10A2_UINT, 4, 1, COMPONENT_TYPE_COMPOUND); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R11G11B10_FLOAT, 4, 1, COMPONENT_TYPE_COMPOUND); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA8_TYPELESS, 1, 4, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA8_UNORM, 1, 4, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA8_UNORM_SRGB, 1, 4, COMPONENT_TYPE_UNORM_SRGB); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA8_UINT, 1, 4, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA8_SNORM, 1, 4, COMPONENT_TYPE_SNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGBA8_SINT, 1, 4, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG16_TYPELESS, 2, 2, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG16_FLOAT, 2, 2, COMPONENT_TYPE_FLOAT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG16_UNORM, 2, 2, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG16_UINT, 2, 2, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG16_SNORM, 2, 2, COMPONENT_TYPE_SNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG16_SINT, 2, 2, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R32_TYPELESS, 4, 1, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_D32_FLOAT, 4, 1, COMPONENT_TYPE_DEPTH); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R32_FLOAT, 4, 1, COMPONENT_TYPE_FLOAT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R32_UINT, 4, 1, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R32_SINT, 4, 1, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R24G8_TYPELESS, 4, 1, COMPONENT_TYPE_DEPTH_STENCIL); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_D24_UNORM_S8_UINT, 4, 1, COMPONENT_TYPE_DEPTH_STENCIL); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R24_UNORM_X8_TYPELESS, 4, 1, COMPONENT_TYPE_DEPTH_STENCIL); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_X24_TYPELESS_G8_UINT, 4, 1, COMPONENT_TYPE_DEPTH_STENCIL); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG8_TYPELESS, 1, 2, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG8_UNORM, 1, 2, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG8_UINT, 1, 2, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG8_SNORM, 1, 2, COMPONENT_TYPE_SNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG8_SINT, 1, 2, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R16_TYPELESS, 2, 1, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R16_FLOAT, 2, 1, COMPONENT_TYPE_FLOAT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_D16_UNORM, 2, 1, COMPONENT_TYPE_DEPTH); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R16_UNORM, 2, 1, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R16_UINT, 2, 1, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R16_SNORM, 2, 1, COMPONENT_TYPE_SNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R16_SINT, 2, 1, COMPONENT_TYPE_SINT); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R8_TYPELESS, 1, 1, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R8_UNORM, 1, 1, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R8_UINT, 1, 1, COMPONENT_TYPE_UINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R8_SNORM, 1, 1, COMPONENT_TYPE_SNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R8_SINT, 1, 1, COMPONENT_TYPE_SINT); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_A8_UNORM, 1, 1, COMPONENT_TYPE_UNORM); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R1_UNORM, 1, 1, COMPONENT_TYPE_UNORM); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RGB9E5_SHAREDEXP, 4, 1, COMPONENT_TYPE_COMPOUND); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_RG8_B8G8_UNORM, 1, 4, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_G8R8_G8B8_UNORM, 1, 4, COMPONENT_TYPE_UNORM); + + // http://www.g-truc.net/post-0335.html + // http://renderingpipeline.com/2012/07/texture-compression/ + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC1_TYPELESS, 8, 3, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC1_UNORM, 8, 3, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC1_UNORM_SRGB, 8, 3, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC2_TYPELESS, 16, 4, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC2_UNORM, 16, 4, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC2_UNORM_SRGB, 16, 4, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC3_TYPELESS, 16, 4, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC3_UNORM, 16, 4, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC3_UNORM_SRGB, 16, 4, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC4_TYPELESS, 8, 1, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC4_UNORM, 8, 1, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC4_SNORM, 8, 1, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC5_TYPELESS, 16, 2, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC5_UNORM, 16, 2, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC5_SNORM, 16, 2, COMPONENT_TYPE_COMPRESSED); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_B5G6R5_UNORM, 2, 1, COMPONENT_TYPE_COMPOUND); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_B5G5R5A1_UNORM, 2, 1, COMPONENT_TYPE_COMPOUND); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BGRA8_UNORM, 1, 4, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BGRX8_UNORM, 1, 4, COMPONENT_TYPE_UNORM); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, 4, 1, COMPONENT_TYPE_COMPOUND); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BGRA8_TYPELESS, 1, 4, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BGRA8_UNORM_SRGB, 1, 4, COMPONENT_TYPE_UNORM_SRGB); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BGRX8_TYPELESS, 1, 4, COMPONENT_TYPE_UNDEFINED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BGRX8_UNORM_SRGB, 1, 4, COMPONENT_TYPE_UNORM_SRGB); + + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC6H_TYPELESS, 16, 3, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC6H_UF16, 16, 3, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC6H_SF16, 16, 3, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC7_TYPELESS, 16, 4, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC7_UNORM, 16, 4, COMPONENT_TYPE_COMPRESSED); + INIT_TEX_FORMAT_INFO( TEX_FORMAT_BC7_UNORM_SRGB, 16, 4, COMPONENT_TYPE_COMPRESSED); +#undef INIT_TEX_FORMAT_INFO + static_assert(TEX_FORMAT_NUM_FORMATS == TEX_FORMAT_BC7_UNORM_SRGB + 1, "Not all texture formats initialized."); + +#ifdef _DEBUG + for( Uint32 Fmt = TEX_FORMAT_UNKNOWN; Fmt < TEX_FORMAT_NUM_FORMATS; ++Fmt ) + VERIFY(FmtAttribs[Fmt].Format == Fmt, "Uninitialized format"); +#endif + + bIsInit = true; + } + + if( Format >= TEX_FORMAT_UNKNOWN && Format < TEX_FORMAT_NUM_FORMATS ) + { + const auto &Attribs = FmtAttribs[Format]; + VERIFY( Attribs.Format == Format, "Unexpected format" ); + return Attribs; + } + else + { + UNEXPECTED( "Texture format (", Format, ") is out of allowed range [0, ", TEX_FORMAT_NUM_FORMATS-1, "]" ); + return FmtAttribs[0]; + } +} + + +const Char *GetTexViewTypeLiteralName( TEXTURE_VIEW_TYPE ViewType ) +{ + static const Char *TexViewLiteralNames[TEXTURE_VIEW_NUM_VIEWS] = {}; + static bool bIsInit = false; + // Note that this implementation is thread-safe + // Even if two threads try to call the function at the same time, + // the worst thing that might happen is that the array will be + // initialized multiple times. But the result will always be correct. + if( !bIsInit ) + { +#define INIT_TEX_VIEW_TYPE_NAME(ViewType)TexViewLiteralNames[ViewType] = #ViewType + INIT_TEX_VIEW_TYPE_NAME( TEXTURE_VIEW_UNDEFINED ); + INIT_TEX_VIEW_TYPE_NAME( TEXTURE_VIEW_SHADER_RESOURCE ); + INIT_TEX_VIEW_TYPE_NAME( TEXTURE_VIEW_RENDER_TARGET ); + INIT_TEX_VIEW_TYPE_NAME( TEXTURE_VIEW_DEPTH_STENCIL ); + INIT_TEX_VIEW_TYPE_NAME( TEXTURE_VIEW_UNORDERED_ACCESS ); +#undef INIT_TEX_VIEW_TYPE_NAME + static_assert(TEXTURE_VIEW_NUM_VIEWS == TEXTURE_VIEW_UNORDERED_ACCESS + 1, "Not all texture views names initialized."); + + bIsInit = true; + } + + if( ViewType >= TEXTURE_VIEW_UNDEFINED && ViewType < TEXTURE_VIEW_NUM_VIEWS ) + { + return TexViewLiteralNames[ViewType]; + } + else + { + UNEXPECTED("Texture view type (", ViewType, ") is out of allowed range [0, ", TEXTURE_VIEW_NUM_VIEWS-1, "]" ); + return ""; + } +} + +const Char *GetBufferViewTypeLiteralName( BUFFER_VIEW_TYPE ViewType ) +{ + static const Char *BuffViewLiteralNames[BUFFER_VIEW_NUM_VIEWS] = {}; + static bool bIsInit = false; + // Note that this implementation is thread-safe + // Even if two threads try to call the function at the same time, + // the worst thing that might happen is that the array will be + // initialized multiple times. But the result will always be correct. + if( !bIsInit ) + { +#define INIT_BUFF_VIEW_TYPE_NAME(ViewType)BuffViewLiteralNames[ViewType] = #ViewType + INIT_BUFF_VIEW_TYPE_NAME( BUFFER_VIEW_UNDEFINED ); + INIT_BUFF_VIEW_TYPE_NAME( BUFFER_VIEW_SHADER_RESOURCE ); + INIT_BUFF_VIEW_TYPE_NAME( BUFFER_VIEW_UNORDERED_ACCESS ); + #undef INIT_BUFF_VIEW_TYPE_NAME + static_assert(BUFFER_VIEW_NUM_VIEWS == BUFFER_VIEW_UNORDERED_ACCESS + 1, "Not all buffer views names initialized."); + + bIsInit = true; + } + + if( ViewType >= BUFFER_VIEW_UNDEFINED && ViewType < BUFFER_VIEW_NUM_VIEWS ) + { + return BuffViewLiteralNames[ViewType]; + } + else + { + UNEXPECTED( "Buffer view type (", ViewType, ") is out of allowed range [0, ", BUFFER_VIEW_NUM_VIEWS-1, "]" ) + return ""; + } +} + +const Char *GetShaderTypeLiteralName( SHADER_TYPE ShaderType ) +{ + switch( ShaderType ) + { +#define RETURN_SHADER_TYPE_NAME(ShaderType)\ + case ShaderType: return #ShaderType; + + RETURN_SHADER_TYPE_NAME( SHADER_TYPE_UNKNOWN ) + RETURN_SHADER_TYPE_NAME( SHADER_TYPE_VERTEX ) + RETURN_SHADER_TYPE_NAME( SHADER_TYPE_PIXEL ) + RETURN_SHADER_TYPE_NAME( SHADER_TYPE_GEOMETRY) + RETURN_SHADER_TYPE_NAME( SHADER_TYPE_HULL ) + RETURN_SHADER_TYPE_NAME( SHADER_TYPE_DOMAIN ) + RETURN_SHADER_TYPE_NAME( SHADER_TYPE_COMPUTE ) +#undef RETURN_SHADER_TYPE_NAME + + default: UNEXPECTED( "Unknown shader type" ); return ""; + } +} + +/// Returns the string containing the usage +const Char* GetUsageString( USAGE Usage ) +{ + static const Char* UsageStrings[4]; + static bool bUsageStringsInit = false; + if( !bUsageStringsInit ) + { +#define INIT_USGAGE_STR(Usage)UsageStrings[Usage] = #Usage + INIT_USGAGE_STR( USAGE_STATIC ); + INIT_USGAGE_STR( USAGE_DEFAULT ); + INIT_USGAGE_STR( USAGE_DYNAMIC ); + INIT_USGAGE_STR( USAGE_CPU_ACCESSIBLE ); +#undef INIT_USGAGE_STR + bUsageStringsInit = true; + } + if( Usage >= USAGE_STATIC && Usage <= USAGE_CPU_ACCESSIBLE ) + return UsageStrings[Usage]; + else + { + UNEXPECTED("Unknow usage" ) + return "Unknown usage"; + } +} + +const Char* GetTextureTypeString( TEXTURE_TYPE TexType ) +{ + static const Char* TexTypeStrings[TEXTURE_TYPE_NUM_TYPES]; + static bool bTexTypeStrsInit = false; + if( !bTexTypeStrsInit ) + { + TexTypeStrings[TEXTURE_TYPE_UNDEFINED] = "Undefined"; + TexTypeStrings[TEXTURE_TYPE_1D] = "1D"; + TexTypeStrings[TEXTURE_TYPE_1D_ARRAY] = "1D Array"; + TexTypeStrings[TEXTURE_TYPE_2D] = "2D"; + TexTypeStrings[TEXTURE_TYPE_2D_ARRAY] = "2D Array"; + TexTypeStrings[TEXTURE_TYPE_3D] = "3D"; + TexTypeStrings[TEXTURE_TYPE_2D_ARRAY] = "Cube"; + TexTypeStrings[TEXTURE_TYPE_3D] = "Cube Array"; + static_assert(TEXTURE_TYPE_NUM_TYPES == TEXTURE_TYPE_CUBE_ARRAY + 1, "Not all texture type strings initialized."); + + bTexTypeStrsInit = true; + } + if( TexType >= TEXTURE_TYPE_UNDEFINED && TexType < TEXTURE_TYPE_NUM_TYPES ) + return TexTypeStrings[TexType]; + else + { + UNEXPECTED("Unknow texture type") + return "Unknow texture type"; + } +} + +static const Char* GetSingleBindFlagString( Uint32 BindFlag ) +{ + VERIFY( (BindFlag & (BindFlag - 1)) == 0, "More than one bind flag specified" ); + switch( BindFlag ) + { +#define BIND_FLAG_STR_CASE(Flag) case Flag: return #Flag; + BIND_FLAG_STR_CASE( BIND_VERTEX_BUFFER ) + BIND_FLAG_STR_CASE( BIND_INDEX_BUFFER ) + BIND_FLAG_STR_CASE( BIND_UNIFORM_BUFFER ) + BIND_FLAG_STR_CASE( BIND_SHADER_RESOURCE ) + BIND_FLAG_STR_CASE( BIND_STREAM_OUTPUT ) + BIND_FLAG_STR_CASE( BIND_RENDER_TARGET ) + BIND_FLAG_STR_CASE( BIND_DEPTH_STENCIL ) + BIND_FLAG_STR_CASE( BIND_UNORDERED_ACCESS ) + BIND_FLAG_STR_CASE( BIND_INDIRECT_DRAW_ARGS ) +#undef BIND_FLAG_STR_CASE + default: UNEXPECTED( "Unexpected bind flag ", BindFlag ); return ""; + } +} + +String GetBindFlagsString( Uint32 BindFlags ) +{ + if( BindFlags == 0 ) + return "0"; + String Str; + for( Uint32 Flag = BIND_VERTEX_BUFFER; BindFlags && Flag <= BIND_INDIRECT_DRAW_ARGS; Flag <<= 1 ) + { + if( BindFlags&Flag ) + { + if( Str.length() ) + Str += '|'; + Str += GetSingleBindFlagString( Flag ); + BindFlags &= ~Flag; + } + } + VERIFY( BindFlags == 0, "Unknown bind flags left" ); + return Str; +} + + +static const Char* GetSingleCPUAccessFlagString( Uint32 CPUAccessFlag ) +{ + VERIFY( (CPUAccessFlag & (CPUAccessFlag - 1)) == 0, "More than one access flag specified" ); + switch( CPUAccessFlag ) + { +#define CPU_ACCESS_FLAG_STR_CASE(Flag) case Flag: return #Flag; + CPU_ACCESS_FLAG_STR_CASE( CPU_ACCESS_READ ) + CPU_ACCESS_FLAG_STR_CASE( CPU_ACCESS_WRITE ) +#undef CPU_ACCESS_FLAG_STR_CASE + default: UNEXPECTED( "Unexpected CPU access flag ", CPUAccessFlag ); return ""; + } +} + +String GetCPUAccessFlagsString( Uint32 CpuAccessFlags ) +{ + if( CpuAccessFlags == 0 ) + return "0"; + String Str; + for( Uint32 Flag = CPU_ACCESS_READ; CpuAccessFlags && Flag <= CPU_ACCESS_WRITE; Flag <<= 1 ) + { + if( CpuAccessFlags&Flag ) + { + if( Str.length() ) + Str += '|'; + Str += GetSingleCPUAccessFlagString( Flag ); + CpuAccessFlags &= ~Flag; + } + } + VERIFY( CpuAccessFlags == 0, "Unknown CPU access flags left" ); + return Str; +} + +// There is a nice standard function to_string, but there is a bug on gcc +// and it does not work +template +String ToString( T Val ) +{ + std::stringstream ss; + ss << Val; + return ss.str(); +} + +String GetTextureDescString( const TextureDesc &Desc ) +{ + String Str = "Type: "; + Str += GetTextureTypeString(Desc.Type); + Str += "; size: "; + Str += ToString(Desc.Width); + if( Desc.Type == TEXTURE_TYPE_2D || Desc.Type == TEXTURE_TYPE_2D_ARRAY || Desc.Type == TEXTURE_TYPE_3D) + { + Str += "x"; + Str += ToString( Desc.Height ); + } + + if( Desc.Type == TEXTURE_TYPE_3D ) + { + Str += "x"; + Str += ToString( Desc.Depth ); + } + + if( Desc.Type == TEXTURE_TYPE_1D_ARRAY || Desc.Type == TEXTURE_TYPE_2D_ARRAY ) + { + Str += "; Num Slices: "; + Str += ToString( Desc.ArraySize ); + } + + auto FmtName = GetTextureFormatAttribs( Desc.Format ).Name; + Str += "; Format: "; + Str += FmtName; + + Str += "; Mip levels: "; + Str += ToString( Desc.MipLevels ); + + Str += "; Sample Count: "; + Str += ToString( Desc.SampleCount ); + + Str += "; Usage: "; + Str += GetUsageString(Desc.Usage); + + Str += "; Bind Flags: "; + Str += GetBindFlagsString(Desc.BindFlags); + + Str += "; CPU access: "; + Str += GetCPUAccessFlagsString(Desc.CPUAccessFlags); + + return Str; +} + +static const Char* GetBufferModeString( BUFFER_MODE Mode ) +{ + static const Char* BufferModeStrings[BUFFER_MODE_NUM_MODES]; + static bool bBuffModeStringsInit = false; + if( !bBuffModeStringsInit ) + { +#define INIT_BUFF_MODE_STR(Mode)BufferModeStrings[Mode] = #Mode + INIT_BUFF_MODE_STR( BUFFER_MODE_UNDEFINED ); + INIT_BUFF_MODE_STR( BUFFER_MODE_FORMATED ); + INIT_BUFF_MODE_STR( BUFFER_MODE_STRUCTURED ); +#undef INIT_BUFF_MODE_STR + static_assert(BUFFER_MODE_NUM_MODES == BUFFER_MODE_STRUCTURED + 1, "Not all buffer mode strings initialized."); + bBuffModeStringsInit = true; + } + if( Mode >= BUFFER_MODE_UNDEFINED && Mode < BUFFER_MODE_NUM_MODES ) + return BufferModeStrings[Mode]; + else + { + UNEXPECTED( "Unknown buffer mode" ); + return "Unknown buffer mode"; + } +} + +String GetBufferDescString( const BufferDesc &Desc ) +{ + String Str; + Str += "Size: "; + bool bIsLarge = false; + if( Desc.uiSizeInBytes > (1 << 20) ) + { + Str += ToString( Desc.uiSizeInBytes / (1<<20) ); + Str += " Mb ("; + bIsLarge = true; + } + else if( Desc.uiSizeInBytes > (1 << 10) ) + { + Str += ToString( Desc.uiSizeInBytes / (1<<10) ); + Str += " Kb ("; + bIsLarge = true; + } + + Str += ToString( Desc.uiSizeInBytes ); + Str += " bytes"; + if( bIsLarge ) + Str += ')'; + + Str += "; Mode: "; + Str += GetBufferModeString(Desc.Mode); + if( Desc.Mode == BUFFER_MODE_FORMATED ) + { + Str += "; Format: "; + Str += GetValueTypeString( Desc.Format.ValueType ); + if( Desc.Format.IsNormalized ) + Str += " norm"; + Str += " x "; + Str += ToString(Desc.Format.NumComponents); + } + + Str += "; Usage: "; + Str += GetUsageString(Desc.Usage); + + Str += "; Bind Flags: "; + Str += GetBindFlagsString(Desc.BindFlags); + + Str += "; CPU access: "; + Str += GetCPUAccessFlagsString(Desc.CPUAccessFlags); + + Str += "; stride: "; + Str += ToString( Desc.ElementByteStride ); + Str += " bytes"; + + return Str; +} + +Uint32 ComputeMipLevelsCount( Uint32 Width ) +{ + Uint32 MipLevels = 0; + while( (Width >> MipLevels) > 1 ) + ++MipLevels; + return MipLevels; +} + +Uint32 ComputeMipLevelsCount( Uint32 Width, Uint32 Height ) +{ + return ComputeMipLevelsCount( std::max( Width, Height ) ); +} + +Uint32 ComputeMipLevelsCount( Uint32 Width, Uint32 Height, Uint32 Depth ) +{ + return ComputeMipLevelsCount( std::max(std::max( Width, Height ), Depth) ); +} + +void CreateUniformBuffer( IRenderDevice *pDevice, Uint32 Size, IBuffer **ppBuffer, USAGE Usage, Uint32 BindFlag, Uint32 CPUAccessFlags) +{ + BufferDesc CBDesc; + CBDesc.uiSizeInBytes = Size; + CBDesc.Usage = Usage; + CBDesc.BindFlags = BindFlag; + CBDesc.CPUAccessFlags = CPUAccessFlags; + pDevice->CreateBuffer( CBDesc, BufferData(), ppBuffer ); +} + +} diff --git a/Graphics/GraphicsTools/src/pch.cpp b/Graphics/GraphicsTools/src/pch.cpp new file mode 100644 index 00000000..809315e1 --- /dev/null +++ b/Graphics/GraphicsTools/src/pch.cpp @@ -0,0 +1,24 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" -- cgit v1.2.3