summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2015-10-21 03:46:28 +0000
committerEgor Yusov <egor.yusov@gmail.com>2015-10-21 03:46:28 +0000
commit9ccee73baca0fd7ecb95c90cb983133b737c6c55 (patch)
tree66fea1e6521df31727431520fe3c1ead1896bc5d /Graphics/GraphicsEngine
downloadDiligentCore-9ccee73baca0fd7ecb95c90cb983133b737c6c55.tar.gz
DiligentCore-9ccee73baca0fd7ecb95c90cb983133b737c6c55.zip
Release v1.0.0
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/build/Windows/Android/gcc_Debug.h249
-rw-r--r--Graphics/GraphicsEngine/build/Windows/Android/gcc_Release.h249
-rw-r--r--Graphics/GraphicsEngine/build/Windows/EngineRoot.props18
-rw-r--r--Graphics/GraphicsEngine/build/Windows/GraphicsEngine-Debug.vgdbsettings76
-rw-r--r--Graphics/GraphicsEngine/build/Windows/GraphicsEngine-Release.vgdbsettings76
-rw-r--r--Graphics/GraphicsEngine/build/Windows/GraphicsEngine.props10
-rw-r--r--Graphics/GraphicsEngine/build/Windows/GraphicsEngine.vcxproj194
-rw-r--r--Graphics/GraphicsEngine/build/Windows/GraphicsEngine.vcxproj.filters27
-rw-r--r--Graphics/GraphicsEngine/build/Windows/jni/Android.mk24
-rw-r--r--Graphics/GraphicsEngine/build/Windows/jni/Application.mk7
-rw-r--r--Graphics/GraphicsEngine/build/WindowsStore/EngineRoot.props18
-rw-r--r--Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Shared/GraphicsEngine.Shared.vcxitems65
-rw-r--r--Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Shared/GraphicsEngine.Shared.vcxitems.filters138
-rw-r--r--Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Windows/GraphicsEngine.Windows.vcxproj209
-rw-r--r--Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Windows/GraphicsEngine.Windows.vcxproj.filters5
-rw-r--r--Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.WindowsPhone/GraphicsEngine.WindowsPhone.vcxproj144
-rw-r--r--Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.WindowsPhone/GraphicsEngine.WindowsPhone.vcxproj.filters5
-rw-r--r--Graphics/GraphicsEngine/include/BlendStateBase.h76
-rw-r--r--Graphics/GraphicsEngine/include/BufferBase.h234
-rw-r--r--Graphics/GraphicsEngine/include/BufferViewBase.h83
-rw-r--r--Graphics/GraphicsEngine/include/Defines.h25
-rw-r--r--Graphics/GraphicsEngine/include/DepthStencilStateBase.h69
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.h659
-rw-r--r--Graphics/GraphicsEngine/include/DeviceObjectBase.h117
-rw-r--r--Graphics/GraphicsEngine/include/RasterizerStateBase.h69
-rw-r--r--Graphics/GraphicsEngine/include/RenderDeviceBase.h399
-rw-r--r--Graphics/GraphicsEngine/include/ResourceMappingImpl.h58
-rw-r--r--Graphics/GraphicsEngine/include/SamplerBase.h69
-rw-r--r--Graphics/GraphicsEngine/include/ShaderBase.h92
-rw-r--r--Graphics/GraphicsEngine/include/StateObjectsRegistry.h204
-rw-r--r--Graphics/GraphicsEngine/include/SwapChainBase.h96
-rw-r--r--Graphics/GraphicsEngine/include/TextureBase.h394
-rw-r--r--Graphics/GraphicsEngine/include/TextureViewBase.h90
-rw-r--r--Graphics/GraphicsEngine/include/VertexDescriptionBase.h96
-rw-r--r--Graphics/GraphicsEngine/include/pch.h41
-rw-r--r--Graphics/GraphicsEngine/interface/BlendState.h344
-rw-r--r--Graphics/GraphicsEngine/interface/Buffer.h234
-rw-r--r--Graphics/GraphicsEngine/interface/BufferView.h107
-rw-r--r--Graphics/GraphicsEngine/interface/Constants.h36
-rw-r--r--Graphics/GraphicsEngine/interface/DepthStencilState.h238
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceCaps.h129
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h510
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceObject.h50
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h1087
-rw-r--r--Graphics/GraphicsEngine/interface/MapHelper.h148
-rw-r--r--Graphics/GraphicsEngine/interface/RasterizerState.h194
-rw-r--r--Graphics/GraphicsEngine/interface/RenderDevice.h220
-rw-r--r--Graphics/GraphicsEngine/interface/ResourceMapping.h118
-rw-r--r--Graphics/GraphicsEngine/interface/Sampler.h174
-rw-r--r--Graphics/GraphicsEngine/interface/Shader.h208
-rw-r--r--Graphics/GraphicsEngine/interface/SwapChain.h58
-rw-r--r--Graphics/GraphicsEngine/interface/Texture.h254
-rw-r--r--Graphics/GraphicsEngine/interface/TextureView.h198
-rw-r--r--Graphics/GraphicsEngine/interface/VertexDescription.h140
-rw-r--r--Graphics/GraphicsEngine/src/ResourceMapping.cpp130
-rw-r--r--Graphics/GraphicsEngine/src/Texture.cpp191
-rw-r--r--Graphics/GraphicsEngine/src/pch.cpp31
57 files changed, 9184 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngine/build/Windows/Android/gcc_Debug.h b/Graphics/GraphicsEngine/build/Windows/Android/gcc_Debug.h
new file mode 100644
index 00000000..da574716
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/Android/gcc_Debug.h
@@ -0,0 +1,249 @@
+/*
+ This file is only used by IntelliSense (VisualStudio code suggestion system)
+ DO NOT INCLUDE THIS FILE FROM YOUR ACTUAL SOURCE FILES.
+ This file lists the preprocessor macros extracted from your GCC.
+ It is needed for IntelliSense to parse other header files correctly.
+*/
+#ifdef _MSC_VER
+#define __DBL_MIN_EXP__ (-1021)
+#define __UINT_LEAST16_MAX__ 65535
+#define __FLT_MIN__ 1.1754943508222875e-38F
+#define __UINT_LEAST8_TYPE__ unsigned char
+#define __CHAR_BIT__ 8
+#define __UINT8_MAX__ 255
+#define __ANDROID__ 1
+#define __WINT_MAX__ 4294967295U
+#define R3000 1
+#define __ORDER_LITTLE_ENDIAN__ 1234
+#define __SIZE_MAX__ 4294967295U
+#define __WCHAR_MAX__ 2147483647
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+#define __DBL_DENORM_MIN__ double(4.9406564584124654e-324L)
+#define __FLT_EVAL_METHOD__ 0
+#define __unix__ 1
+#define _MIPS_ISA _MIPS_ISA_MIPS32
+#define __UINT_FAST64_MAX__ 18446744073709551615ULL
+#define __SIG_ATOMIC_TYPE__ int
+#define __DBL_MIN_10_EXP__ (-307)
+#define __FINITE_MATH_ONLY__ 0
+#define _MIPS_TUNE "mips32"
+#define _ABIO32 1
+#define __GNUC_PATCHLEVEL__ 0
+#define __UINT_FAST8_MAX__ 255
+#define __DEC64_MAX_EXP__ 385
+#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
+#define __SHRT_MAX__ 32767
+#define __LDBL_MAX__ 1.7976931348623157e+308L
+#define __UINT_LEAST8_MAX__ 255
+#define __mips_abicalls 1
+#define __UINTMAX_TYPE__ long long unsigned int
+#define __linux 1
+#define __DEC32_EPSILON__ 1E-6DF
+#define __unix 1
+#define __UINT32_MAX__ 4294967295U
+#define __LDBL_MAX_EXP__ 1024
+#define __LANGUAGE_C_PLUS_PLUS 1
+#define __WINT_MIN__ 0U
+#define __MIPSEL__ 1
+#define __linux__ 1
+#define __SCHAR_MAX__ 127
+#define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
+#define __DBL_DIG__ 15
+#define __SIZEOF_INT__ 4
+#define __SIZEOF_POINTER__ 4
+#define __USER_LABEL_PREFIX__
+#define __STDC_HOSTED__ 1
+#define __LDBL_HAS_INFINITY__ 1
+#define __mips_fpr 32
+#define __FLT_EPSILON__ 1.1920928955078125e-7F
+#define __GXX_WEAK__ 1
+#define __mips__ 1
+#define __LDBL_MIN__ 2.2250738585072014e-308L
+#define __DEC32_MAX__ 9.999999E96DF
+#define MIPSEL 1
+#define __INT32_MAX__ 2147483647
+#define __SIZEOF_LONG__ 4
+#define __DECIMAL_DIG__ 17
+#define __LDBL_HAS_QUIET_NAN__ 1
+#define __GNUC__ 4
+#define __GXX_RTTI 1
+#define __FLT_HAS_DENORM__ 1
+#define __SIZEOF_LONG_DOUBLE__ 8
+#define _R3000 1
+#define __BIGGEST_ALIGNMENT__ 8
+#define __DBL_MAX__ double(1.7976931348623157e+308L)
+#define __INT_FAST32_MAX__ 2147483647
+#define __DBL_HAS_INFINITY__ 1
+#define __INT64_MAX__ 9223372036854775807LL
+#define __DEC32_MIN_EXP__ (-94)
+#define __INT_FAST16_TYPE__ int
+#define __LDBL_HAS_DENORM__ 1
+#define __cplusplus 1
+#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+#define __INT_LEAST32_MAX__ 2147483647
+#define __DEC32_MIN__ 1E-95DF
+#define __DEPRECATED 1
+#define __DBL_MAX_EXP__ 1024
+#define __R3000__ 1
+#define __DEC128_EPSILON__ 1E-33DL
+#define __PTRDIFF_MAX__ 2147483647
+#define mips 1
+#define __GNUG__ 4
+#define __LANGUAGE_C_PLUS_PLUS__ 1
+#define __LONG_LONG_MAX__ 9223372036854775807LL
+#define __SIZEOF_SIZE_T__ 4
+#define __SIZEOF_WINT_T__ 4
+#define __GCC_HAVE_DWARF2_CFI_ASM 1
+#define __GXX_ABI_VERSION 1002
+#define __FLT_MIN_EXP__ (-125)
+#define __INT_FAST64_TYPE__ long long int
+#define _MIPSEL 1
+#define __DBL_MIN__ double(2.2250738585072014e-308L)
+#define _MIPS_ARCH "mips32"
+#define __FLT_MIN_10_EXP__ (-37)
+#define __DEC128_MIN__ 1E-6143DL
+#define __REGISTER_PREFIX__
+#define __UINT16_MAX__ 65535
+#define __DBL_HAS_DENORM__ 1
+#define __UINT8_TYPE__ unsigned char
+#define __NO_INLINE__ 1
+#define __R3000 1
+#define __FLT_MANT_DIG__ 24
+#define __VERSION__ "4.6 20120106 (prerelease)"
+#define _LANGUAGE_C_PLUS_PLUS 1
+#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+#define __DEC64_EPSILON__ 1E-15DD
+#define __ORDER_PDP_ENDIAN__ 3412
+#define __DEC128_MIN_EXP__ (-6142)
+#define __INT_FAST32_TYPE__ int
+#define __UINT_LEAST16_TYPE__ short unsigned int
+#define unix 1
+#define _MIPS_ARCH_MIPS32 1
+#define __INT16_MAX__ 32767
+#define __SIZE_TYPE__ unsigned int
+#define __UINT64_MAX__ 18446744073709551615ULL
+#define __INT8_TYPE__ signed char
+#define __ELF__ 1
+#define __mips_isa_rev 1
+#define _MIPS_TUNE_MIPS32 1
+#define __FLT_RADIX__ 2
+#define __INT_LEAST16_TYPE__ short int
+#define __LDBL_EPSILON__ 2.2204460492503131e-16L
+#define __SIG_ATOMIC_MAX__ 2147483647
+#define __SIZEOF_PTRDIFF_T__ 4
+#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
+#define __INT_FAST16_MAX__ 2147483647
+#define _MIPS_SZPTR 32
+#define __UINT_FAST32_MAX__ 4294967295U
+#define __UINT_LEAST64_TYPE__ long long unsigned int
+#define __FLT_HAS_QUIET_NAN__ 1
+#define __FLT_MAX_10_EXP__ 38
+#define __LONG_MAX__ 2147483647L
+#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
+#define __FLT_HAS_INFINITY__ 1
+#define __UINT_FAST16_TYPE__ unsigned int
+#define __DEC64_MAX__ 9.999999999999999E384DD
+#define __CHAR16_TYPE__ short unsigned int
+#define __PRAGMA_REDEFINE_EXTNAME 1
+#define __INT_LEAST16_MAX__ 32767
+#define __DEC64_MANT_DIG__ 16
+#define __UINT_LEAST32_MAX__ 4294967295U
+#define __INT_LEAST64_TYPE__ long long int
+#define __INT16_TYPE__ short int
+#define __INT_LEAST8_TYPE__ signed char
+#define _mips 1
+#define __DEC32_MAX_EXP__ 97
+#define __INT_FAST8_MAX__ 127
+#define __INTPTR_MAX__ 2147483647
+#define linux 1
+#define _MIPS_SZINT 32
+#define __EXCEPTIONS 1
+#define __LDBL_MANT_DIG__ 53
+#define __DBL_HAS_QUIET_NAN__ 1
+#define __MIPSEL 1
+#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
+#define __GCC_HAVE_BUILTIN_MIPS_CACHE 1
+#define __INTPTR_TYPE__ int
+#define __UINT16_TYPE__ short unsigned int
+#define __WCHAR_TYPE__ int
+#define __SIZEOF_FLOAT__ 4
+#define __pic__ 1
+#define __UINTPTR_MAX__ 4294967295U
+#define __DEC64_MIN_EXP__ (-382)
+#define __INT_FAST64_MAX__ 9223372036854775807LL
+#define __FLT_DIG__ 6
+#define __UINT_FAST64_TYPE__ long long unsigned int
+#define __INT_MAX__ 2147483647
+#define __INT64_TYPE__ long long int
+#define __FLT_MAX_EXP__ 128
+#define _MIPS_SIM _ABIO32
+#define __DBL_MANT_DIG__ 53
+#define __INT_LEAST64_MAX__ 9223372036854775807LL
+#define __DEC64_MIN__ 1E-383DD
+#define __WINT_TYPE__ unsigned int
+#define __UINT_LEAST32_TYPE__ unsigned int
+#define __SIZEOF_SHORT__ 2
+#define __LDBL_MIN_EXP__ (-1021)
+#define _MIPS_FPSET 16
+#define __INT_LEAST8_MAX__ 127
+#define __LDBL_MAX_10_EXP__ 308
+#define __DBL_EPSILON__ double(2.2204460492503131e-16L)
+#define __INT_LEAST32_TYPE__ int
+#define __SIZEOF_WCHAR_T__ 4
+#define __UINT64_TYPE__ long long unsigned int
+#define __INT_FAST8_TYPE__ signed char
+#define __DBL_DECIMAL_DIG__ 17
+#define __DEC_EVAL_METHOD__ 2
+#define __ORDER_BIG_ENDIAN__ 4321
+#define __INTMAX_MAX__ 9223372036854775807LL
+#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F
+#define __INT8_MAX__ 127
+#define __PIC__ 1
+#define __UINT_FAST32_TYPE__ unsigned int
+#define __CHAR32_TYPE__ unsigned int
+#define __FLT_MAX__ 3.4028234663852886e+38F
+#define __INT32_TYPE__ int
+#define __SIZEOF_DOUBLE__ 8
+#define __INTMAX_TYPE__ long long int
+#define __DEC128_MAX_EXP__ 6145
+#define __GNUC_MINOR__ 6
+#define __UINTMAX_MAX__ 18446744073709551615ULL
+#define __DEC32_MANT_DIG__ 7
+#define __DBL_MAX_10_EXP__ 308
+#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
+#define __STDC__ 1
+#define __mips_hard_float 1
+#define __PTRDIFF_TYPE__ int
+#define __mips 32
+#define __UINT32_TYPE__ unsigned int
+#define _MIPS_SZLONG 32
+#define __UINTPTR_TYPE__ unsigned int
+#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
+#define __DEC128_MANT_DIG__ 34
+#define __LDBL_MIN_10_EXP__ (-307)
+#define __SIZEOF_LONG_LONG__ 8
+#define __LDBL_DIG__ 15
+#define __FLT_DECIMAL_DIG__ 9
+#define __UINT_FAST16_MAX__ 4294967295U
+#define __GNUC_GNU_INLINE__ 1
+#define __UINT_FAST8_TYPE__ unsigned char
+#define _GNU_SOURCE 1
+#define ANDROID
+#endif
+
+// --- Include directories begin --- //
+//C:/Android/ndk/platforms/android-9/arch-mips/usr/include
+//C:\Android\ndk\toolchains\mipsel-linux-android-4.6\prebuilt\windows\bin\../lib/gcc/mipsel-linux-android/4.6/include
+//C:\Android\ndk\toolchains\mipsel-linux-android-4.6\prebuilt\windows\bin\../lib/gcc/mipsel-linux-android/4.6/include-fixed
+// --- Library directories end --- //
+
+
+// --- Library directories begin --- //
+//C:/Android/ndk/toolchains/mipsel-linux-android-4.6/prebuilt/windows/bin/../lib/gcc/mipsel-linux-android/4.6/
+//C:/Android/ndk/toolchains/mipsel-linux-android-4.6/prebuilt/windows/bin/../lib/gcc/
+//C:/Android/ndk/toolchains/mipsel-linux-android-4.6/prebuilt/windows/bin/../lib/gcc/mipsel-linux-android/4.6/../../../../mipsel-linux-android/lib/
+// --- Library directories begin --- //
+
diff --git a/Graphics/GraphicsEngine/build/Windows/Android/gcc_Release.h b/Graphics/GraphicsEngine/build/Windows/Android/gcc_Release.h
new file mode 100644
index 00000000..da574716
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/Android/gcc_Release.h
@@ -0,0 +1,249 @@
+/*
+ This file is only used by IntelliSense (VisualStudio code suggestion system)
+ DO NOT INCLUDE THIS FILE FROM YOUR ACTUAL SOURCE FILES.
+ This file lists the preprocessor macros extracted from your GCC.
+ It is needed for IntelliSense to parse other header files correctly.
+*/
+#ifdef _MSC_VER
+#define __DBL_MIN_EXP__ (-1021)
+#define __UINT_LEAST16_MAX__ 65535
+#define __FLT_MIN__ 1.1754943508222875e-38F
+#define __UINT_LEAST8_TYPE__ unsigned char
+#define __CHAR_BIT__ 8
+#define __UINT8_MAX__ 255
+#define __ANDROID__ 1
+#define __WINT_MAX__ 4294967295U
+#define R3000 1
+#define __ORDER_LITTLE_ENDIAN__ 1234
+#define __SIZE_MAX__ 4294967295U
+#define __WCHAR_MAX__ 2147483647
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+#define __DBL_DENORM_MIN__ double(4.9406564584124654e-324L)
+#define __FLT_EVAL_METHOD__ 0
+#define __unix__ 1
+#define _MIPS_ISA _MIPS_ISA_MIPS32
+#define __UINT_FAST64_MAX__ 18446744073709551615ULL
+#define __SIG_ATOMIC_TYPE__ int
+#define __DBL_MIN_10_EXP__ (-307)
+#define __FINITE_MATH_ONLY__ 0
+#define _MIPS_TUNE "mips32"
+#define _ABIO32 1
+#define __GNUC_PATCHLEVEL__ 0
+#define __UINT_FAST8_MAX__ 255
+#define __DEC64_MAX_EXP__ 385
+#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
+#define __SHRT_MAX__ 32767
+#define __LDBL_MAX__ 1.7976931348623157e+308L
+#define __UINT_LEAST8_MAX__ 255
+#define __mips_abicalls 1
+#define __UINTMAX_TYPE__ long long unsigned int
+#define __linux 1
+#define __DEC32_EPSILON__ 1E-6DF
+#define __unix 1
+#define __UINT32_MAX__ 4294967295U
+#define __LDBL_MAX_EXP__ 1024
+#define __LANGUAGE_C_PLUS_PLUS 1
+#define __WINT_MIN__ 0U
+#define __MIPSEL__ 1
+#define __linux__ 1
+#define __SCHAR_MAX__ 127
+#define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
+#define __DBL_DIG__ 15
+#define __SIZEOF_INT__ 4
+#define __SIZEOF_POINTER__ 4
+#define __USER_LABEL_PREFIX__
+#define __STDC_HOSTED__ 1
+#define __LDBL_HAS_INFINITY__ 1
+#define __mips_fpr 32
+#define __FLT_EPSILON__ 1.1920928955078125e-7F
+#define __GXX_WEAK__ 1
+#define __mips__ 1
+#define __LDBL_MIN__ 2.2250738585072014e-308L
+#define __DEC32_MAX__ 9.999999E96DF
+#define MIPSEL 1
+#define __INT32_MAX__ 2147483647
+#define __SIZEOF_LONG__ 4
+#define __DECIMAL_DIG__ 17
+#define __LDBL_HAS_QUIET_NAN__ 1
+#define __GNUC__ 4
+#define __GXX_RTTI 1
+#define __FLT_HAS_DENORM__ 1
+#define __SIZEOF_LONG_DOUBLE__ 8
+#define _R3000 1
+#define __BIGGEST_ALIGNMENT__ 8
+#define __DBL_MAX__ double(1.7976931348623157e+308L)
+#define __INT_FAST32_MAX__ 2147483647
+#define __DBL_HAS_INFINITY__ 1
+#define __INT64_MAX__ 9223372036854775807LL
+#define __DEC32_MIN_EXP__ (-94)
+#define __INT_FAST16_TYPE__ int
+#define __LDBL_HAS_DENORM__ 1
+#define __cplusplus 1
+#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+#define __INT_LEAST32_MAX__ 2147483647
+#define __DEC32_MIN__ 1E-95DF
+#define __DEPRECATED 1
+#define __DBL_MAX_EXP__ 1024
+#define __R3000__ 1
+#define __DEC128_EPSILON__ 1E-33DL
+#define __PTRDIFF_MAX__ 2147483647
+#define mips 1
+#define __GNUG__ 4
+#define __LANGUAGE_C_PLUS_PLUS__ 1
+#define __LONG_LONG_MAX__ 9223372036854775807LL
+#define __SIZEOF_SIZE_T__ 4
+#define __SIZEOF_WINT_T__ 4
+#define __GCC_HAVE_DWARF2_CFI_ASM 1
+#define __GXX_ABI_VERSION 1002
+#define __FLT_MIN_EXP__ (-125)
+#define __INT_FAST64_TYPE__ long long int
+#define _MIPSEL 1
+#define __DBL_MIN__ double(2.2250738585072014e-308L)
+#define _MIPS_ARCH "mips32"
+#define __FLT_MIN_10_EXP__ (-37)
+#define __DEC128_MIN__ 1E-6143DL
+#define __REGISTER_PREFIX__
+#define __UINT16_MAX__ 65535
+#define __DBL_HAS_DENORM__ 1
+#define __UINT8_TYPE__ unsigned char
+#define __NO_INLINE__ 1
+#define __R3000 1
+#define __FLT_MANT_DIG__ 24
+#define __VERSION__ "4.6 20120106 (prerelease)"
+#define _LANGUAGE_C_PLUS_PLUS 1
+#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+#define __DEC64_EPSILON__ 1E-15DD
+#define __ORDER_PDP_ENDIAN__ 3412
+#define __DEC128_MIN_EXP__ (-6142)
+#define __INT_FAST32_TYPE__ int
+#define __UINT_LEAST16_TYPE__ short unsigned int
+#define unix 1
+#define _MIPS_ARCH_MIPS32 1
+#define __INT16_MAX__ 32767
+#define __SIZE_TYPE__ unsigned int
+#define __UINT64_MAX__ 18446744073709551615ULL
+#define __INT8_TYPE__ signed char
+#define __ELF__ 1
+#define __mips_isa_rev 1
+#define _MIPS_TUNE_MIPS32 1
+#define __FLT_RADIX__ 2
+#define __INT_LEAST16_TYPE__ short int
+#define __LDBL_EPSILON__ 2.2204460492503131e-16L
+#define __SIG_ATOMIC_MAX__ 2147483647
+#define __SIZEOF_PTRDIFF_T__ 4
+#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
+#define __INT_FAST16_MAX__ 2147483647
+#define _MIPS_SZPTR 32
+#define __UINT_FAST32_MAX__ 4294967295U
+#define __UINT_LEAST64_TYPE__ long long unsigned int
+#define __FLT_HAS_QUIET_NAN__ 1
+#define __FLT_MAX_10_EXP__ 38
+#define __LONG_MAX__ 2147483647L
+#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
+#define __FLT_HAS_INFINITY__ 1
+#define __UINT_FAST16_TYPE__ unsigned int
+#define __DEC64_MAX__ 9.999999999999999E384DD
+#define __CHAR16_TYPE__ short unsigned int
+#define __PRAGMA_REDEFINE_EXTNAME 1
+#define __INT_LEAST16_MAX__ 32767
+#define __DEC64_MANT_DIG__ 16
+#define __UINT_LEAST32_MAX__ 4294967295U
+#define __INT_LEAST64_TYPE__ long long int
+#define __INT16_TYPE__ short int
+#define __INT_LEAST8_TYPE__ signed char
+#define _mips 1
+#define __DEC32_MAX_EXP__ 97
+#define __INT_FAST8_MAX__ 127
+#define __INTPTR_MAX__ 2147483647
+#define linux 1
+#define _MIPS_SZINT 32
+#define __EXCEPTIONS 1
+#define __LDBL_MANT_DIG__ 53
+#define __DBL_HAS_QUIET_NAN__ 1
+#define __MIPSEL 1
+#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
+#define __GCC_HAVE_BUILTIN_MIPS_CACHE 1
+#define __INTPTR_TYPE__ int
+#define __UINT16_TYPE__ short unsigned int
+#define __WCHAR_TYPE__ int
+#define __SIZEOF_FLOAT__ 4
+#define __pic__ 1
+#define __UINTPTR_MAX__ 4294967295U
+#define __DEC64_MIN_EXP__ (-382)
+#define __INT_FAST64_MAX__ 9223372036854775807LL
+#define __FLT_DIG__ 6
+#define __UINT_FAST64_TYPE__ long long unsigned int
+#define __INT_MAX__ 2147483647
+#define __INT64_TYPE__ long long int
+#define __FLT_MAX_EXP__ 128
+#define _MIPS_SIM _ABIO32
+#define __DBL_MANT_DIG__ 53
+#define __INT_LEAST64_MAX__ 9223372036854775807LL
+#define __DEC64_MIN__ 1E-383DD
+#define __WINT_TYPE__ unsigned int
+#define __UINT_LEAST32_TYPE__ unsigned int
+#define __SIZEOF_SHORT__ 2
+#define __LDBL_MIN_EXP__ (-1021)
+#define _MIPS_FPSET 16
+#define __INT_LEAST8_MAX__ 127
+#define __LDBL_MAX_10_EXP__ 308
+#define __DBL_EPSILON__ double(2.2204460492503131e-16L)
+#define __INT_LEAST32_TYPE__ int
+#define __SIZEOF_WCHAR_T__ 4
+#define __UINT64_TYPE__ long long unsigned int
+#define __INT_FAST8_TYPE__ signed char
+#define __DBL_DECIMAL_DIG__ 17
+#define __DEC_EVAL_METHOD__ 2
+#define __ORDER_BIG_ENDIAN__ 4321
+#define __INTMAX_MAX__ 9223372036854775807LL
+#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F
+#define __INT8_MAX__ 127
+#define __PIC__ 1
+#define __UINT_FAST32_TYPE__ unsigned int
+#define __CHAR32_TYPE__ unsigned int
+#define __FLT_MAX__ 3.4028234663852886e+38F
+#define __INT32_TYPE__ int
+#define __SIZEOF_DOUBLE__ 8
+#define __INTMAX_TYPE__ long long int
+#define __DEC128_MAX_EXP__ 6145
+#define __GNUC_MINOR__ 6
+#define __UINTMAX_MAX__ 18446744073709551615ULL
+#define __DEC32_MANT_DIG__ 7
+#define __DBL_MAX_10_EXP__ 308
+#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
+#define __STDC__ 1
+#define __mips_hard_float 1
+#define __PTRDIFF_TYPE__ int
+#define __mips 32
+#define __UINT32_TYPE__ unsigned int
+#define _MIPS_SZLONG 32
+#define __UINTPTR_TYPE__ unsigned int
+#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
+#define __DEC128_MANT_DIG__ 34
+#define __LDBL_MIN_10_EXP__ (-307)
+#define __SIZEOF_LONG_LONG__ 8
+#define __LDBL_DIG__ 15
+#define __FLT_DECIMAL_DIG__ 9
+#define __UINT_FAST16_MAX__ 4294967295U
+#define __GNUC_GNU_INLINE__ 1
+#define __UINT_FAST8_TYPE__ unsigned char
+#define _GNU_SOURCE 1
+#define ANDROID
+#endif
+
+// --- Include directories begin --- //
+//C:/Android/ndk/platforms/android-9/arch-mips/usr/include
+//C:\Android\ndk\toolchains\mipsel-linux-android-4.6\prebuilt\windows\bin\../lib/gcc/mipsel-linux-android/4.6/include
+//C:\Android\ndk\toolchains\mipsel-linux-android-4.6\prebuilt\windows\bin\../lib/gcc/mipsel-linux-android/4.6/include-fixed
+// --- Library directories end --- //
+
+
+// --- Library directories begin --- //
+//C:/Android/ndk/toolchains/mipsel-linux-android-4.6/prebuilt/windows/bin/../lib/gcc/mipsel-linux-android/4.6/
+//C:/Android/ndk/toolchains/mipsel-linux-android-4.6/prebuilt/windows/bin/../lib/gcc/
+//C:/Android/ndk/toolchains/mipsel-linux-android-4.6/prebuilt/windows/bin/../lib/gcc/mipsel-linux-android/4.6/../../../../mipsel-linux-android/lib/
+// --- Library directories begin --- //
+
diff --git a/Graphics/GraphicsEngine/build/Windows/EngineRoot.props b/Graphics/GraphicsEngine/build/Windows/EngineRoot.props
new file mode 100644
index 00000000..6e4b958b
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/EngineRoot.props
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ImportGroup Label="PropertySheets" />
+ <PropertyGroup Label="UserMacros">
+ <EngineRoot>..\..\..\..</EngineRoot>
+ <GraphicsRoot>..\..\..</GraphicsRoot>
+ </PropertyGroup>
+ <PropertyGroup />
+ <ItemDefinitionGroup />
+ <ItemGroup>
+ <BuildMacro Include="EngineRoot">
+ <Value>$(EngineRoot)</Value>
+ </BuildMacro>
+ <BuildMacro Include="GraphicsRoot">
+ <Value>$(GraphicsRoot)</Value>
+ </BuildMacro>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/Windows/GraphicsEngine-Debug.vgdbsettings b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine-Debug.vgdbsettings
new file mode 100644
index 00000000..3f5b24b1
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine-Debug.vgdbsettings
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<VisualGDBProjectSettings2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <ConfigurationName>Debug</ConfigurationName>
+ <Project xsi:type="com.visualgdb.project.android">
+ <CustomSourceDirectories>
+ <Directories />
+ <PathStyle>MinGWWindowsSlash</PathStyle>
+ </CustomSourceDirectories>
+ <AndroidProjectPath>$(ProjectDir)</AndroidProjectPath>
+ </Project>
+ <Build xsi:type="com.visualgdb.build.android">
+ <AndroidPlatform>android-19</AndroidPlatform>
+ <IsDebugConfiguration>true</IsDebugConfiguration>
+ <JNIOnlyBuild>true</JNIOnlyBuild>
+ <AdditionalDirectoriesToDeleteOnClean>bin;obj</AdditionalDirectoriesToDeleteOnClean>
+ <DeleteANTFilesOnClean>false</DeleteANTFilesOnClean>
+ <DoNotEditAndroidManifest>false</DoNotEditAndroidManifest>
+ <CustomActions />
+ </Build>
+ <Debug xsi:type="com.visualgdb.debug.android">
+ <AdditionalStartupCommands />
+ <AdditionalGDBSettings>
+ <FilterSpuriousStoppedNotifications>false</FilterSpuriousStoppedNotifications>
+ <ForceSingleThreadedMode>false</ForceSingleThreadedMode>
+ <PendingBreakpointsSupported>true</PendingBreakpointsSupported>
+ <DisableChildRanges>false</DisableChildRanges>
+ <UseAppleExtensions>false</UseAppleExtensions>
+ <CanAcceptCommandsWhileRunning>false</CanAcceptCommandsWhileRunning>
+ <MakeLogFile>false</MakeLogFile>
+ <IgnoreModuleEventsWhileStepping>true</IgnoreModuleEventsWhileStepping>
+ <UseRelativePathsOnly>false</UseRelativePathsOnly>
+ <ExitAction>KillApp</ExitAction>
+ <Features>
+ <DisableAutoDetection>false</DisableAutoDetection>
+ <UseFrameParameter>false</UseFrameParameter>
+ <SimpleValuesFlagSupported>false</SimpleValuesFlagSupported>
+ <ListLocalsSupported>false</ListLocalsSupported>
+ <ByteLevelMemoryCommandsAvailable>false</ByteLevelMemoryCommandsAvailable>
+ <ThreadInfoSupported>false</ThreadInfoSupported>
+ <PendingBreakpointsSupported>false</PendingBreakpointsSupported>
+ <SupportTargetCommand>false</SupportTargetCommand>
+ </Features>
+ <DisableDisassembly>false</DisableDisassembly>
+ <ExamineMemoryWithXCommand>false</ExamineMemoryWithXCommand>
+ <StepIntoNewInstanceEntry>main</StepIntoNewInstanceEntry>
+ <ExamineRegistersInRawFormat>true</ExamineRegistersInRawFormat>
+ </AdditionalGDBSettings>
+ <LaunchGDBSettings xsi:type="GDBLaunchParametersAndroid" />
+ <GenerateCtrlBreakInsteadOfCtrlC>false</GenerateCtrlBreakInsteadOfCtrlC>
+ <UseDefaultInstallDir>false</UseDefaultInstallDir>
+ <RemotePort>5039</RemotePort>
+ <LocalPort>5039</LocalPort>
+ <GDBServerStartupTimeout>10000</GDBServerStartupTimeout>
+ <AdditionalGDBServerStartupDelay>0</AdditionalGDBServerStartupDelay>
+ <DoubleSlashWorkaround>false</DoubleSlashWorkaround>
+ <AlreadyRunningDecision>Ask</AlreadyRunningDecision>
+ <ShowLogCat>true</ShowLogCat>
+ <EnableThreadNameWatcher>true</EnableThreadNameWatcher>
+ </Debug>
+ <CustomBuild>
+ <PreBuildActions />
+ <PostBuildActions />
+ <PreCleanActions />
+ <PostCleanActions />
+ </CustomBuild>
+ <CustomDebug>
+ <PreDebugActions />
+ <PostDebugActions />
+ <BreakMode>Default</BreakMode>
+ </CustomDebug>
+ <CustomShortcuts>
+ <Shortcuts />
+ <ShowMessageAfterExecuting>true</ShowMessageAfterExecuting>
+ </CustomShortcuts>
+ <UserDefinedVariables />
+</VisualGDBProjectSettings2> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/Windows/GraphicsEngine-Release.vgdbsettings b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine-Release.vgdbsettings
new file mode 100644
index 00000000..669691f2
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine-Release.vgdbsettings
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<VisualGDBProjectSettings2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <ConfigurationName>Release</ConfigurationName>
+ <Project xsi:type="com.visualgdb.project.android">
+ <CustomSourceDirectories>
+ <Directories />
+ <PathStyle>MinGWWindowsSlash</PathStyle>
+ </CustomSourceDirectories>
+ <AndroidProjectPath>$(ProjectDir)</AndroidProjectPath>
+ </Project>
+ <Build xsi:type="com.visualgdb.build.android">
+ <AndroidPlatform>android-19</AndroidPlatform>
+ <IsDebugConfiguration>false</IsDebugConfiguration>
+ <JNIOnlyBuild>true</JNIOnlyBuild>
+ <AdditionalDirectoriesToDeleteOnClean>bin;obj</AdditionalDirectoriesToDeleteOnClean>
+ <DeleteANTFilesOnClean>false</DeleteANTFilesOnClean>
+ <DoNotEditAndroidManifest>false</DoNotEditAndroidManifest>
+ <CustomActions />
+ </Build>
+ <Debug xsi:type="com.visualgdb.debug.android">
+ <AdditionalStartupCommands />
+ <AdditionalGDBSettings>
+ <FilterSpuriousStoppedNotifications>false</FilterSpuriousStoppedNotifications>
+ <ForceSingleThreadedMode>false</ForceSingleThreadedMode>
+ <PendingBreakpointsSupported>true</PendingBreakpointsSupported>
+ <DisableChildRanges>false</DisableChildRanges>
+ <UseAppleExtensions>false</UseAppleExtensions>
+ <CanAcceptCommandsWhileRunning>false</CanAcceptCommandsWhileRunning>
+ <MakeLogFile>false</MakeLogFile>
+ <IgnoreModuleEventsWhileStepping>true</IgnoreModuleEventsWhileStepping>
+ <UseRelativePathsOnly>false</UseRelativePathsOnly>
+ <ExitAction>KillApp</ExitAction>
+ <Features>
+ <DisableAutoDetection>false</DisableAutoDetection>
+ <UseFrameParameter>false</UseFrameParameter>
+ <SimpleValuesFlagSupported>false</SimpleValuesFlagSupported>
+ <ListLocalsSupported>false</ListLocalsSupported>
+ <ByteLevelMemoryCommandsAvailable>false</ByteLevelMemoryCommandsAvailable>
+ <ThreadInfoSupported>false</ThreadInfoSupported>
+ <PendingBreakpointsSupported>false</PendingBreakpointsSupported>
+ <SupportTargetCommand>false</SupportTargetCommand>
+ </Features>
+ <DisableDisassembly>false</DisableDisassembly>
+ <ExamineMemoryWithXCommand>false</ExamineMemoryWithXCommand>
+ <StepIntoNewInstanceEntry>main</StepIntoNewInstanceEntry>
+ <ExamineRegistersInRawFormat>true</ExamineRegistersInRawFormat>
+ </AdditionalGDBSettings>
+ <LaunchGDBSettings xsi:type="GDBLaunchParametersAndroid" />
+ <GenerateCtrlBreakInsteadOfCtrlC>false</GenerateCtrlBreakInsteadOfCtrlC>
+ <UseDefaultInstallDir>false</UseDefaultInstallDir>
+ <RemotePort>5039</RemotePort>
+ <LocalPort>5039</LocalPort>
+ <GDBServerStartupTimeout>10000</GDBServerStartupTimeout>
+ <AdditionalGDBServerStartupDelay>0</AdditionalGDBServerStartupDelay>
+ <DoubleSlashWorkaround>false</DoubleSlashWorkaround>
+ <AlreadyRunningDecision>Ask</AlreadyRunningDecision>
+ <ShowLogCat>true</ShowLogCat>
+ <EnableThreadNameWatcher>true</EnableThreadNameWatcher>
+ </Debug>
+ <CustomBuild>
+ <PreBuildActions />
+ <PostBuildActions />
+ <PreCleanActions />
+ <PostCleanActions />
+ </CustomBuild>
+ <CustomDebug>
+ <PreDebugActions />
+ <PostDebugActions />
+ <BreakMode>Default</BreakMode>
+ </CustomDebug>
+ <CustomShortcuts>
+ <Shortcuts />
+ <ShowMessageAfterExecuting>true</ShowMessageAfterExecuting>
+ </CustomShortcuts>
+ <UserDefinedVariables />
+</VisualGDBProjectSettings2> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.props b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.props
new file mode 100644
index 00000000..f5ff61e5
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.props
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ImportGroup Label="PropertySheets" />
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <IncludePath>$(GraphicsRoot)\GraphicsEngine\include;$(GraphicsRoot)\GraphicsEngine\interface;$(GraphicsRoot)\GraphicsTools\include;$(EngineRoot)\Common\include;$(EngineRoot)\Common\interface;$(EngineRoot)\Platforms\interface;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <ItemDefinitionGroup />
+ <ItemGroup />
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.vcxproj b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.vcxproj
new file mode 100644
index 00000000..34dfc85e
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.vcxproj
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</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>{052DD700-477C-4512-A7F4-B05EBEF5C80E}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>RenderEngine</RootNamespace>
+ <ProjectName>GraphicsEngine</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <PlatformToolset>v120</PlatformToolset>
+ <ConfigurationType>Makefile</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <PlatformToolset>v120</PlatformToolset>
+ <ConfigurationType>Makefile</ConfigurationType>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ <Import Project="..\WindowsStore\GraphicsEngine.Shared\GraphicsEngine.Shared.vcxitems" Label="Shared" Condition="Exists('..\WindowsStore\GraphicsEngine.Shared\GraphicsEngine.Shared.vcxitems')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\Shared\build\Windows\Win32d.props" />
+ <Import Project="EngineRoot.props" />
+ <Import Project="GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\Shared\build\Windows\Win64d.props" />
+ <Import Project="EngineRoot.props" />
+ <Import Project="GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\Shared\build\Windows\Win32r.props" />
+ <Import Project="EngineRoot.props" />
+ <Import Project="GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\Shared\build\Windows\Win64r.props" />
+ <Import Project="EngineRoot.props" />
+ <Import Project="GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <Import Project="..\..\..\..\Shared\build\Windows\Android32d.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <Import Project="..\..\..\..\Shared\build\Windows\Android32r.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <NMakeForcedIncludes>$(ProjectDir)\Android\gcc_Debug.h;$(NMakeForcedIncludes)</NMakeForcedIncludes>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <NMakeForcedIncludes>$(ProjectDir)\Android\gcc_Release.h;$(NMakeForcedIncludes)</NMakeForcedIncludes>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ <Lib>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ <Lib>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <None Include="jni\Android.mk" />
+ <None Include="jni\Application.mk" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\ResourceMapping.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\src\Texture.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ </ClCompile>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.vcxproj.filters b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.vcxproj.filters
new file mode 100644
index 00000000..f9817491
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/GraphicsEngine.vcxproj.filters
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="jni">
+ <UniqueIdentifier>{8939e7b7-453a-4762-9f92-ad0a2915609f}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="android_src">
+ <UniqueIdentifier>{551d0b50-542f-47e1-8e7b-6b382176f2b1}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="jni\Application.mk">
+ <Filter>jni</Filter>
+ </None>
+ <None Include="jni\Android.mk">
+ <Filter>jni</Filter>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\ResourceMapping.cpp">
+ <Filter>android_src</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\Texture.cpp">
+ <Filter>android_src</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/Windows/jni/Android.mk b/Graphics/GraphicsEngine/build/Windows/jni/Android.mk
new file mode 100644
index 00000000..5d40b9a3
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/Windows/jni/Android.mk
@@ -0,0 +1,24 @@
+# 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 := GraphicsEngine
+LOCAL_CFLAGS := -std=c++11
+LOCAL_CPP_FEATURES := exceptions
+LOCAL_STATIC_LIBRARIES +=
+
+# Include paths
+PROJECT_ROOT := $(LOCAL_PATH)/../../..
+SOLUTION_ROOT := $(PROJECT_ROOT)/../..
+LOCAL_C_INCLUDES := $(PROJECT_ROOT)/include $(PROJECT_ROOT)/interface $(SOLUTION_ROOT)/Common/include $(SOLUTION_ROOT)/Common/interface $(SOLUTION_ROOT)/Platforms/interface $(SOLUTION_ROOT)/Graphics/GraphicsTools/include
+
+# Source files
+#VisualGDBAndroid: AutoUpdateSourcesInNextLine
+LOCAL_SRC_FILES := ../../../src/ResourceMapping.cpp ../../../src/Texture.cpp
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/Graphics/GraphicsEngine/build/Windows/jni/Application.mk b/Graphics/GraphicsEngine/build/Windows/jni/Application.mk
new file mode 100644
index 00000000..45f02b20
--- /dev/null
+++ b/Graphics/GraphicsEngine/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 := GraphicsEngine \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/WindowsStore/EngineRoot.props b/Graphics/GraphicsEngine/build/WindowsStore/EngineRoot.props
new file mode 100644
index 00000000..fcb891c0
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/WindowsStore/EngineRoot.props
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ImportGroup Label="PropertySheets" />
+ <PropertyGroup Label="UserMacros">
+ <EngineRoot>..\..\..\..\..</EngineRoot>
+ <GraphicsRoot>..\..\..\..</GraphicsRoot>
+ </PropertyGroup>
+ <PropertyGroup />
+ <ItemDefinitionGroup />
+ <ItemGroup>
+ <BuildMacro Include="EngineRoot">
+ <Value>$(EngineRoot)</Value>
+ </BuildMacro>
+ <BuildMacro Include="GraphicsRoot">
+ <Value>$(GraphicsRoot)</Value>
+ </BuildMacro>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Shared/GraphicsEngine.Shared.vcxitems b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Shared/GraphicsEngine.Shared.vcxitems
new file mode 100644
index 00000000..e8d4f5a7
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Shared/GraphicsEngine.Shared.vcxitems
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Label="Globals">
+ <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+ <HasSharedItems>true</HasSharedItems>
+ <ItemsProjectGuid>{0cdd843c-089d-4fee-be9f-c08fa2b51acb}</ItemsProjectGuid>
+ <ItemsRootNamespace>GraphicsEngine</ItemsRootNamespace>
+ <ItemsProjectName>GraphicsEngine.Shared</ItemsProjectName>
+ <CodeSharingProject>248F659F-DAC5-46E8-AC09-60EC9FC95053</CodeSharingProject>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ProjectCapability Include="SourceItemsFromImports" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\ResourceMapping.cpp" />
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\pch.cpp">
+ <PrecompiledHeader>Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\Texture.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\BlendStateBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\BufferBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\BufferViewBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\Defines.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\DepthStencilStateBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\DeviceContextBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\DeviceObjectBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\RasterizerStateBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\RenderDeviceBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\ResourceMappingImpl.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\SamplerBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\ShaderBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\StateObjectsRegistry.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\pch.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\SwapChainBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\TextureBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\TextureViewBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\VertexDescriptionBase.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\BlendState.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Buffer.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\BufferView.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Constants.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\DepthStencilState.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\DeviceCaps.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\DeviceContext.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\DeviceObject.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\MapHelper.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\RasterizerState.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\RenderDevice.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\ResourceMapping.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Sampler.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Shader.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\SwapChain.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Texture.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\TextureView.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\GraphicsTypes.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\VertexDescription.h" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Shared/GraphicsEngine.Shared.vcxitems.filters b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Shared/GraphicsEngine.Shared.vcxitems.filters
new file mode 100644
index 00000000..8014c299
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Shared/GraphicsEngine.Shared.vcxitems.filters
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="include">
+ <UniqueIdentifier>{32eded03-121f-406a-8a23-6721ca9116ee}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="src">
+ <UniqueIdentifier>{d881c412-cc78-41fb-997c-0d6543c1e477}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="interface">
+ <UniqueIdentifier>{c38a8d65-5100-44be-b1a5-453d901c892f}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\pch.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\Texture.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\src\ResourceMapping.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\DeviceObjectBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\RasterizerStateBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\RenderDeviceBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\ResourceMappingImpl.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\SamplerBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\ShaderBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\StateObjectsRegistry.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\pch.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\TextureBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\TextureViewBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\VertexDescriptionBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\BlendStateBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\BufferBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\BufferViewBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\Defines.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\DepthStencilStateBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\DeviceContextBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\DepthStencilState.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\DeviceCaps.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\DeviceContext.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\DeviceObject.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\MapHelper.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\RasterizerState.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\RenderDevice.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\ResourceMapping.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Sampler.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Shader.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Texture.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\TextureView.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\VertexDescription.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\BlendState.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Buffer.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\BufferView.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\Constants.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\SwapChain.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\include\SwapChainBase.h">
+ <Filter>include</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\interface\GraphicsTypes.h">
+ <Filter>interface</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Windows/GraphicsEngine.Windows.vcxproj b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Windows/GraphicsEngine.Windows.vcxproj
new file mode 100644
index 00000000..7a0d8593
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Windows/GraphicsEngine.Windows.vcxproj
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</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>{9df5553c-ca9d-4cb6-a06a-ca905119c00b}</ProjectGuid>
+ <RootNamespace>GraphicsEngine</RootNamespace>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
+ <AppContainerApplication>true</AppContainerApplication>
+ <ApplicationType>Windows Store</ApplicationType>
+ <ApplicationTypeRevision>8.1</ApplicationTypeRevision>
+ <ConvergedProjectType>CodeSharingStaticLibrary</ConvergedProjectType>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <Import Project="..\GraphicsEngine.Shared\GraphicsEngine.Shared.vcxitems" Label="Shared" />
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore32Dbg.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore32Rel.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStoreArmDbg.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStoreArmRel.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore64Dbg.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore64Rel.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Windows/GraphicsEngine.Windows.vcxproj.filters b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Windows/GraphicsEngine.Windows.vcxproj.filters
new file mode 100644
index 00000000..a7761ab0
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.Windows/GraphicsEngine.Windows.vcxproj.filters
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ </ItemGroup>
+</Project>
diff --git a/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.WindowsPhone/GraphicsEngine.WindowsPhone.vcxproj b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.WindowsPhone/GraphicsEngine.WindowsPhone.vcxproj
new file mode 100644
index 00000000..b3f74084
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.WindowsPhone/GraphicsEngine.WindowsPhone.vcxproj
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{aefba9a8-e16d-4b06-b16d-bc74ac799b4f}</ProjectGuid>
+ <RootNamespace>GraphicsEngine</RootNamespace>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
+ <AppContainerApplication>true</AppContainerApplication>
+ <ApplicationType>Windows Phone</ApplicationType>
+ <ApplicationTypeRevision>8.1</ApplicationTypeRevision>
+ <ConvergedProjectType>CodeSharingStaticLibrary</ConvergedProjectType>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120_wp81</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120_wp81</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120_wp81</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v120_wp81</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <Import Project="..\GraphicsEngine.Shared\GraphicsEngine.Shared.vcxitems" Label="Shared" />
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore32Dbg.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStore32Rel.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStoreArmDbg.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\..\..\..\..\Shared\build\WindowsStore\WinStoreArmRel.props" />
+ <Import Project="..\EngineRoot.props" />
+ <Import Project="..\..\Windows\GraphicsEngine.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.WindowsPhone/GraphicsEngine.WindowsPhone.vcxproj.filters b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.WindowsPhone/GraphicsEngine.WindowsPhone.vcxproj.filters
new file mode 100644
index 00000000..a7761ab0
--- /dev/null
+++ b/Graphics/GraphicsEngine/build/WindowsStore/GraphicsEngine.WindowsPhone/GraphicsEngine.WindowsPhone.vcxproj.filters
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ </ItemGroup>
+</Project>
diff --git a/Graphics/GraphicsEngine/include/BlendStateBase.h b/Graphics/GraphicsEngine/include/BlendStateBase.h
new file mode 100644
index 00000000..78494b46
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/BlendStateBase.h
@@ -0,0 +1,76 @@
+/* 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
+/// Implementation of the Diligent::BlendStateBase template class
+
+#include "BlendState.h"
+#include "DeviceObjectBase.h"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a blend state object.
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::IBlendStateD3D11 or Diligent::IBlendStateGL).
+/// \tparam RenderDeviceBaseInterface - base interface for the render device
+/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceGL,
+/// or Diligent::IRenderDeviceGLES).
+template<class BaseInterface = IBlendState, class RenderDeviceBaseInterface = IRenderDevice>
+class BlendStateBase : public DeviceObjectBase<BaseInterface, BlendStateDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, BlendStateDesc> TDeviceObjectBase;
+ typedef RenderDeviceBase < RenderDeviceBaseInterface > TRenderDeviceBase;
+
+ /// \param pDevice - pointer to the device.
+ /// \param BSDesc - blend state description.
+ /// \param bIsDeviceInternal - flag indicating if the blend state is an internal device object and
+ /// must not keep a strong reference to the device.
+ BlendStateBase( IRenderDevice *pDevice, const BlendStateDesc& BSDesc, bool bIsDeviceInternal = false ) :
+ TDeviceObjectBase( pDevice, BSDesc, nullptr, bIsDeviceInternal )
+ {
+ }
+
+ ~BlendStateBase()
+ {
+ /// \note Destructor cannot directly remove the object from the registry as this may cause a
+ /// deadlock at the point where StateObjectsRegistry::Find() locks the weak pointer: if we
+ /// are in dtor, the object is locked by Diligent::RefCountedObject::Release() and
+ /// StateObjectsRegistry::Find() will wait for that lock to be released.
+ /// A the same time this thread will be waiting for the other thread to unlock the registry.\n
+ /// Thus destructor only notifies the registry that there is a deleted object.
+ /// The reference to the object will be removed later.
+ auto &BlendStateRegistry = static_cast<TRenderDeviceBase*>(this->GetDevice())->GetBSRegistry();
+ // StateObjectsRegistry::ReportDeletedObject() does not lock the registry, but only
+ // atomically increments the outstanding deleted objects counter.
+ BlendStateRegistry.ReportDeletedObject();
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_BlendState, TDeviceObjectBase )
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/BufferBase.h b/Graphics/GraphicsEngine/include/BufferBase.h
new file mode 100644
index 00000000..43b07662
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/BufferBase.h
@@ -0,0 +1,234 @@
+/* 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
+/// Implementation of the Diligent::BufferBase template class
+
+#include "Buffer.h"
+#include "DeviceObjectBase.h"
+#include "GraphicsUtilities.h"
+#include <memory>
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a buffer object
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::IBufferD3D11 or Diligent::IBufferGL).
+/// \tparam BufferViewImplType - type of the buffer view implementation
+/// (Diligent::BufferViewD3D11Impl or Diligent::BufferVeiwGLImpl)
+template<class BaseInterface, class BufferViewImplType>
+class BufferBase : public DeviceObjectBase < BaseInterface, BufferDesc >
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, BufferDesc> TDeviceObjectBase;
+
+ /// \param pDevice - pointer to the device.
+ /// \param BuffDesc - buffer description.
+ /// \param bIsDeviceInternal - flag indicating if the buffer is an internal device object and
+ /// must not keep a strong reference to the device.
+ BufferBase( IRenderDevice *pDevice, const BufferDesc& BuffDesc, bool bIsDeviceInternal = false ) :
+ TDeviceObjectBase( pDevice, BuffDesc, nullptr, bIsDeviceInternal )
+ {
+ Uint32 AllowedBindFlags =
+ BIND_VERTEX_BUFFER | BIND_INDEX_BUFFER | BIND_UNIFORM_BUFFER |
+ BIND_SHADER_RESOURCE | BIND_STREAM_OUTPUT | BIND_UNORDERED_ACCESS |
+ BIND_INDIRECT_DRAW_ARGS;
+ const Char* strAllowedBindFlags =
+ "BIND_VERTEX_BUFFER (1), BIND_INDEX_BUFFER (2), BIND_UNIFORM_BUFFER (4), "
+ "BIND_SHADER_RESOURCE (8), BIND_STREAM_OUTPUT (16), BIND_UNORDERED_ACCESS (128), "
+ "BIND_INDIRECT_DRAW_ARGS (256)";
+
+#define VERIFY_BUFFER(Expr, ...) VERIFY(Expr, "Buffer \"", m_Desc.Name ? m_Desc.Name : "", "\": ", ##__VA_ARGS__)
+
+ VERIFY_BUFFER( (BuffDesc.BindFlags & ~AllowedBindFlags) == 0, "Incorrect bind flags specified (", BuffDesc.BindFlags & ~AllowedBindFlags, "). Only the following flags are allowed:\n", strAllowedBindFlags );
+
+ m_Desc = BuffDesc;
+ if( (m_Desc.BindFlags & BIND_UNORDERED_ACCESS) ||
+ (m_Desc.BindFlags & BIND_SHADER_RESOURCE) )
+ {
+ VERIFY_BUFFER( m_Desc.Mode > BUFFER_MODE_UNDEFINED && m_Desc.Mode < BUFFER_MODE_NUM_MODES, "Buffer mode (", m_Desc.Mode, ") is not correct" );
+ if( m_Desc.Mode == BUFFER_MODE_STRUCTURED )
+ {
+ VERIFY_BUFFER( m_Desc.ElementByteStride != 0, "Element stride cannot be zero for structured buffer" );
+ }
+
+ if( m_Desc.Mode == BUFFER_MODE_FORMATED )
+ {
+ VERIFY_BUFFER( m_Desc.Format.ValueType != VT_UNDEFINED, "Value type is not specified for a formated buffer" );
+ VERIFY_BUFFER( m_Desc.Format.NumComponents != 0, "Num components cannot be zero in a formated buffer" );
+ if( m_Desc.ElementByteStride == 0 )
+ m_Desc.ElementByteStride = static_cast<Uint32>(GetValueSize( m_Desc.Format.ValueType )) * m_Desc.Format.NumComponents;
+ }
+ }
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Buffer, TDeviceObjectBase )
+
+ virtual void UpdateData( IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData )override = 0;
+
+ virtual void CopyData( IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size )override = 0;
+
+ virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData )override;
+
+ virtual void Unmap( IDeviceContext *pContext )override = 0;
+
+ virtual void CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView )override;
+
+ virtual IBufferView* GetDefaultView( BUFFER_VIEW_TYPE ViewType )override;
+
+ void CreateDefaultViews();
+
+protected:
+ virtual void CreateViewInternal( const struct BufferViewDesc &ViewDesc, IBufferView **ppView, bool bIsDefaultView ) = 0;
+
+ void CorrectBufferViewDesc( struct BufferViewDesc &ViewDesc );
+
+ BufferDesc m_Desc;
+
+ std::unique_ptr<BufferViewImplType> m_pDefaultUAV;
+ std::unique_ptr<BufferViewImplType> m_pDefaultSRV;
+};
+
+template<class BaseInterface, class BufferViewImplType>
+void BufferBase<BaseInterface, BufferViewImplType> :: UpdateData( IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData )
+{
+ VERIFY_BUFFER( m_Desc.Usage == USAGE_DEFAULT, "Only default usage buffers can be updated with UpdateData()" );
+ VERIFY_BUFFER( Offset < m_Desc.uiSizeInBytes, "Offset (", Offset, ") exceeds the buffer size (", m_Desc.uiSizeInBytes, ")" );
+ VERIFY_BUFFER( Size + Offset <= m_Desc.uiSizeInBytes, "Update region [", Offset, ",", Size + Offset, ") is out of buffer bounds [0,",m_Desc.uiSizeInBytes,")" );
+}
+
+template<class BaseInterface, class BufferViewImplType>
+void BufferBase<BaseInterface, BufferViewImplType> :: CopyData( IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size )
+{
+ VERIFY_BUFFER( DstOffset + Size <= m_Desc.uiSizeInBytes, "Destination range [", DstOffset, ",", DstOffset + Size, ") is out of buffer bounds [0,",m_Desc.uiSizeInBytes,")" );
+ VERIFY_BUFFER( SrcOffset + Size <= pSrcBuffer->GetDesc().uiSizeInBytes, "Source range [", SrcOffset, ",", SrcOffset + Size, ") is out of buffer bounds [0,",m_Desc.uiSizeInBytes,")" );
+}
+
+
+template<class BaseInterface, class BufferViewImplType>
+void BufferBase<BaseInterface, BufferViewImplType> :: Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData )
+{
+ switch( MapType )
+ {
+ case MAP_READ:
+ VERIFY_BUFFER( m_Desc.Usage == USAGE_CPU_ACCESSIBLE, "Only buffers with usage USAGE_CPU_ACCESSIBLE can be read from" );
+ VERIFY_BUFFER( (m_Desc.CPUAccessFlags & CPU_ACCESS_READ), "Buffer being mapped for reading was not created with CPU_ACCESS_READ flag" );
+ break;
+
+ case MAP_WRITE:
+ VERIFY_BUFFER( m_Desc.Usage == USAGE_CPU_ACCESSIBLE, "Only buffers with usage USAGE_CPU_ACCESSIBLE can be written to" );
+ VERIFY_BUFFER( (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE), "Buffer being mapped for writing was not created with CPU_ACCESS_WRITE flag" );
+ break;
+
+ case MAP_READ_WRITE:
+ VERIFY_BUFFER( m_Desc.Usage == USAGE_CPU_ACCESSIBLE, "Only buffers with usage USAGE_CPU_ACCESSIBLE can be read and written" );
+ VERIFY_BUFFER( (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE), "Buffer being mapped for reading & writing was not created with CPU_ACCESS_WRITE flag" );
+ VERIFY_BUFFER( (m_Desc.CPUAccessFlags & CPU_ACCESS_READ), "Buffer being mapped for reading & writing was not created with CPU_ACCESS_READ flag" );
+ break;
+
+ case MAP_WRITE_DISCARD:
+ VERIFY_BUFFER( m_Desc.Usage == USAGE_DYNAMIC, "Only dynamic buffers can be mapped with write discard flag" );
+ VERIFY_BUFFER( (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE), "Dynamic buffer must be created with CPU_ACCESS_WRITE flag" );
+ break;
+
+ case MAP_WRITE_NO_OVERWRITE:
+ VERIFY_BUFFER( m_Desc.Usage == USAGE_DYNAMIC, "Only dynamic buffers can be mapped with write no overwrite flag" );
+ VERIFY_BUFFER( (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE), "Dynamic buffer must be created with CPU_ACCESS_WRITE flag" );
+ break;
+
+ default: UNEXPECTED( "Unknown map type" );
+ }
+}
+
+template<class BaseInterface, class BufferViewImplType>
+void BufferBase<BaseInterface, BufferViewImplType> :: Unmap( IDeviceContext *pContext )
+{
+
+}
+
+
+template<class BaseInterface, class BufferViewImplType>
+void BufferBase<BaseInterface, BufferViewImplType> :: CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView )
+{
+ CreateViewInternal( ViewDesc, ppView, false );
+}
+
+
+template<class BaseInterface, class BufferViewImplType>
+void BufferBase<BaseInterface, BufferViewImplType> :: CorrectBufferViewDesc( struct BufferViewDesc &ViewDesc )
+{
+ if( ViewDesc.ByteWidth == 0 )
+ ViewDesc.ByteWidth = m_Desc.uiSizeInBytes;
+ if( ViewDesc.ByteOffset + ViewDesc.ByteWidth > m_Desc.uiSizeInBytes )
+ LOG_ERROR_AND_THROW( "Buffer view range [", ViewDesc.ByteOffset, ", ", ViewDesc.ByteOffset + ViewDesc.ByteWidth, ") is out of the buffer boundaries [0, ", m_Desc.uiSizeInBytes, ")." );
+ if( (m_Desc.BindFlags & BIND_UNORDERED_ACCESS) ||
+ (m_Desc.BindFlags & BIND_SHADER_RESOURCE) )
+ {
+ VERIFY( m_Desc.ElementByteStride != 0, "Element byte stride is zero" );
+ if( (ViewDesc.ByteOffset % m_Desc.ElementByteStride) != 0 )
+ LOG_ERROR_AND_THROW( "Buffer view byte offset (", ViewDesc.ByteOffset, ") is not multiple of element byte stride (", m_Desc.ElementByteStride, ")." );
+ if( (ViewDesc.ByteWidth % m_Desc.ElementByteStride) != 0 )
+ LOG_ERROR_AND_THROW( "Buffer view byte width (", ViewDesc.ByteWidth, ") is not multiple of element byte stride (", m_Desc.ElementByteStride, ")." );
+ }
+}
+
+template<class BaseInterface, class BufferViewImplType>
+IBufferView* BufferBase<BaseInterface, BufferViewImplType> ::GetDefaultView( BUFFER_VIEW_TYPE ViewType )
+{
+ switch( ViewType )
+ {
+ case BUFFER_VIEW_SHADER_RESOURCE: return m_pDefaultSRV.get();
+ case BUFFER_VIEW_UNORDERED_ACCESS: return m_pDefaultUAV.get();
+ default: UNEXPECTED( "Unknown view type" ); return nullptr;
+ }
+}
+
+template<class BaseInterface, class BufferViewImplType>
+void BufferBase<BaseInterface, BufferViewImplType> :: CreateDefaultViews()
+{
+ if( m_Desc.BindFlags & BIND_UNORDERED_ACCESS )
+ {
+ BufferViewDesc ViewDesc;
+ ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS;
+ IBufferView *pUAV = nullptr;
+ CreateViewInternal( ViewDesc, &pUAV, true );
+ m_pDefaultUAV.reset( static_cast<BufferViewImplType*>(pUAV) );
+ VERIFY( m_pDefaultUAV->GetDesc().ViewType == BUFFER_VIEW_UNORDERED_ACCESS, "Unexpected view type" );
+ }
+
+ if( m_Desc.BindFlags & BIND_SHADER_RESOURCE )
+ {
+ BufferViewDesc ViewDesc;
+ ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE;
+ IBufferView* pSRV = nullptr;
+ CreateViewInternal( ViewDesc, &pSRV, true );
+ m_pDefaultSRV.reset( static_cast<BufferViewImplType*>(pSRV) );
+ VERIFY( m_pDefaultSRV->GetDesc().ViewType == BUFFER_VIEW_SHADER_RESOURCE, "Unexpected view type" );
+ }
+}
+
+}
diff --git a/Graphics/GraphicsEngine/include/BufferViewBase.h b/Graphics/GraphicsEngine/include/BufferViewBase.h
new file mode 100644
index 00000000..59ce395a
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/BufferViewBase.h
@@ -0,0 +1,83 @@
+/* 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
+/// Implementation of the Diligent::BufferViewBase template class
+
+#include "BufferView.h"
+#include "DeviceObjectBase.h"
+#include "GraphicsTypes.h"
+#include "RefCntAutoPtr.h"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a buffer view object
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::IBufferViewD3D11 or Diligent::IBufferViewGL).
+template<class BaseInterface = IBufferView>
+class BufferViewBase : public DeviceObjectBase<BaseInterface, BufferViewDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, BufferViewDesc> TDeviceObjectBase;
+
+ /// \param pDevice - pointer to the render device.
+ /// \param ViewDesc - buffer view description.
+ /// \param pBuffer - pointer to the buffer that the view is to be created for.
+ /// \param bIsDefaultView - flag indicating if the view is default view, and is thus
+ /// part of the buffer object. In this case the view will attach
+ /// to the buffer's reference counters.
+ BufferViewBase( class IRenderDevice *pDevice,
+ const BufferViewDesc& ViewDesc,
+ class IBuffer *pBuffer,
+ bool bIsDefaultView ) :
+ // Default views are created as part of the buffer, so we cannot not keep strong
+ // reference to the buffer to avoid cyclic links. Instead, we will attach to the
+ // reference counters of the buffer.
+ TDeviceObjectBase( pDevice, ViewDesc, bIsDefaultView ? pBuffer : nullptr ),
+ m_pBuffer( pBuffer ),
+ // For non-default view, we will keep strong reference to buffer
+ m_spBuffer(bIsDefaultView ? nullptr : pBuffer)
+ {}
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_BufferView, TDeviceObjectBase )
+
+ virtual IBuffer* GetBuffer()
+ {
+ return m_pBuffer;
+ }
+
+protected:
+
+ /// Reference to the buffer
+ IBuffer* m_pBuffer;
+
+ /// Strong reference to the buffer. Used for non-default views
+ /// to keep the buffer alive
+ Diligent::RefCntAutoPtr<IBuffer> m_spBuffer;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/Defines.h b/Graphics/GraphicsEngine/include/Defines.h
new file mode 100644
index 00000000..7f6a56e3
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/Defines.h
@@ -0,0 +1,25 @@
+/* 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/GraphicsEngine/include/DepthStencilStateBase.h b/Graphics/GraphicsEngine/include/DepthStencilStateBase.h
new file mode 100644
index 00000000..dbfe43d3
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/DepthStencilStateBase.h
@@ -0,0 +1,69 @@
+/* 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
+/// Implementation of the Diligent::DepthStencilStateBase template class
+
+#include "DepthStencilState.h"
+#include "DeviceObjectBase.h"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a depth stencil state object.
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::IDepthStencilStateD3D11 or Diligent::IDepthStencilStateGL).
+/// \tparam RenderDeviceBaseInterface - base interface for the render device
+/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceGL,
+/// or Diligent::IRenderDeviceGLES).
+template<class BaseInterface = IDepthStencilState, class RenderDeviceBaseInterface = IRenderDevice>
+class DepthStencilStateBase : public DeviceObjectBase<BaseInterface, DepthStencilStateDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, DepthStencilStateDesc> TDeviceObjectBase;
+ typedef RenderDeviceBase<RenderDeviceBaseInterface> TRenderDeviceBase;
+
+ /// \param pDevice - pointer to the device.
+ /// \param DSSDesc - depth-stencil state description.
+ /// \param bIsDeviceInternal - flag indicating if the state is an internal device object and
+ /// must not keep a strong reference to the device.
+ DepthStencilStateBase( IRenderDevice *pDevice, const DepthStencilStateDesc& DSSDesc, bool bIsDeviceInternal = false ) :
+ TDeviceObjectBase( pDevice, DSSDesc, nullptr, bIsDeviceInternal )
+ {
+ }
+
+ ~DepthStencilStateBase()
+ {
+ /// \note Destructor cannot directly remove the object from the registry as this may cause a
+ /// deadlock. See BlendStateBase::~BlendStateBase() for details.
+ auto &DSStateRegistry = static_cast<TRenderDeviceBase*>(this->GetDevice())->GetDSStateRegistry();
+ DSStateRegistry.ReportDeletedObject();
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_DepthStencilState, TDeviceObjectBase )
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h
new file mode 100644
index 00000000..26885aa4
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h
@@ -0,0 +1,659 @@
+/* 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
+/// Implementation of the Diligent::DeviceContextBase template class and related structures
+
+#include "DeviceContext.h"
+#include "DeviceObjectBase.h"
+#include "Defines.h"
+#include "ResourceMapping.h"
+#include "Sampler.h"
+#include "ObjectBase.h"
+#include "DebugUtilities.h"
+#include "SwapChain.h"
+#include "ValidatedCast.h"
+#include "GraphicsUtilities.h"
+
+#ifdef _DEBUG
+# define DEBUG_CHECKS
+#endif
+
+namespace Diligent
+{
+
+/// Describes input vertex stream
+struct VertexStreamInfo
+{
+ /// Strong reference to the buffer object
+ RefCntAutoPtr<IBuffer> pBuffer;
+ Uint32 Stride; ///< Stride
+ Uint32 Offset; ///< Offset
+ VertexStreamInfo() :
+ Stride( 0 ),
+ Offset( 0 )
+ {}
+};
+
+/// Base implementation of the device context.
+
+/// \tparam BaseInterface - base interface that this class will inheret.
+/// \remarks Device context keeps strong references to all objects currently bound to
+/// the pipeline: buffers, states, samplers, shaders, etc.
+/// The context also keeps strong references to the device and
+/// the swap chain.
+template<typename BaseInterface = IDeviceContext>
+class DeviceContextBase : public ObjectBase<BaseInterface>
+{
+public:
+ DeviceContextBase(IRenderDevice *pRenderDevice) :
+ m_pDevice(pRenderDevice),
+ m_IndexDataStartOffset( 0 ),
+ m_StencilRef( 0 ),
+ m_SamplesBlendMask( 0 )
+ {
+ for( int i = 0; i < 4; ++i )
+ m_BlendFactors[i] = -1;
+ m_VertexStreams.reserve( MaxBufferSlots );
+ m_Viewports.reserve( 16 );
+ m_ScissorRects.reserve( 16 );
+ // Set dummy render target array size to make sure that
+ // render targets are actually bound the first time
+ // SetRenderTargets() is called
+ m_pBoundRenderTargets.resize( 8 );
+ }
+
+ ~DeviceContextBase()
+ {
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_DeviceContext, ObjectBase<BaseInterface> )
+
+ virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags ) = 0;
+
+ virtual void ClearState() = 0;
+
+ virtual void SetShaders( IShader **ppShaders, Uint32 NumShadersToSet )
+ {
+ m_pBoundShaders.resize( NumShadersToSet );
+ for( Uint32 i = 0; i < NumShadersToSet; ++i )
+ m_pBoundShaders[i] = ppShaders[i];
+#ifdef DEBUG_CHECKS
+ {
+ Uint32 BoundShaders = 0;
+ for( auto sh = m_pBoundShaders.begin(); sh != m_pBoundShaders.end(); ++sh )
+ {
+ auto ShaderType = (*sh)->GetDesc().ShaderType;
+ if( BoundShaders & ShaderType )
+ {
+ LOG_ERROR_MESSAGE( "More than one shader of type ", GetShaderTypeLiteralName( ShaderType ), " is being set to the pipeline" );
+ BoundShaders |= ShaderType;
+ }
+ }
+ }
+#endif
+ }
+
+ virtual void BindShaderResources( IResourceMapping *pResourceMapping, Uint32 Flags )
+ {
+ }
+
+ // Body of the pure virtual function cannot be inlined
+ /// Caches the strong reference to the vertex description
+ virtual void SetVertexDescription( IVertexDescription *pVertexDesc ) = 0;
+
+ /// Caches the strong reference to the index buffer
+ virtual void SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset ) = 0;
+
+ /// If the new depth stencil parameters differ from the cached values,
+ /// updates the values and returns true. Otherwise returns false.
+ bool SetDepthStencilState( IDepthStencilState *pDSState, Uint32 StencilRef, Uint32 Dummy = 0);
+
+
+ /// If the new rasterizer state differs from the cached state,
+ /// updates the cached state and returns true. Otherwise returns false.
+ bool SetRasterizerState( IRasterizerState *pRS, Uint32 Dummy = 0 );
+
+
+ /// If the new blend parameters differ from the cached values,
+ /// updates the cached values and returns true. Otherwise returns false.
+ bool SetBlendState( IBlendState *pBS, const float* pBlendFactors, Uint32 SampleMask, Uint32 Dummy = 0 );
+
+ /// Caches the viewports
+ void SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight );
+
+ /// Caches the scissor rects
+ void SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight );
+
+ /// Caches the render target and depth stencil views. Returns true if any view is different
+ /// from the cached value and false otherwise.
+ bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, Uint32 Dummy = 0 );
+
+ /// Sets the strong pointer to the swap chain
+ void SetSwapChain( ISwapChain *pSwapChain ) { m_pSwapChain = pSwapChain; }
+
+ bool IsDefaultFBBound(){ return m_pBoundRenderTargets.size() == 0 && m_pBoundDepthStencil == nullptr; }
+
+ void GetDepthStencilState(IDepthStencilState **ppDSS, Uint32 &StencilRef);
+
+ void GetRasterizerState( IRasterizerState **ppRS );
+
+ void GetBlendState( IBlendState **ppBS, float* BlendFactors, Uint32& SamplesBlendMask );
+
+ void GetRenderTargets(Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV);
+
+ /// Creates and binds default depth stencil, rasterizer & blend states
+ void CreateDefaultStates();
+
+ void GetShaders( IShader **ppShaders, Uint32 &NumShaders );
+
+ void GetViewports( Uint32 &NumViewports, Viewport *pViewports );
+
+protected:
+ /// Returns the size of the currently bound render target
+ void GetRenderTargetSize( Uint32 &RTWidth, Uint32 &RTHeight );
+
+ /// Strong reference to the device.
+ RefCntAutoPtr<IRenderDevice> m_pDevice;
+
+ /// Strong reference to the swap chain. Swap chain holds
+ /// weak reference to the immediate context.
+ RefCntAutoPtr<ISwapChain> m_pSwapChain;
+
+ /// Vector of strong references to bound shaders
+ std::vector< RefCntAutoPtr<IShader> > m_pBoundShaders;
+
+ /// Vertex streams. Every stream holds strong reference to the buffer
+ std::vector<VertexStreamInfo> m_VertexStreams;
+
+ /// Strong reference to the bound vertex description object
+ RefCntAutoPtr<IVertexDescription> m_pVertexDesc;
+
+ /// Strong reference to the bound index buffer
+ RefCntAutoPtr<IBuffer> m_pIndexBuffer;
+
+ Uint32 m_IndexDataStartOffset;
+
+ /// Strong references to the bound depth-stencil state
+ RefCntAutoPtr< IDepthStencilState > m_pDSState;
+
+ /// Strong references to the bound rasterizer state
+ RefCntAutoPtr< IRasterizerState> m_pRasterizerState;
+
+ /// Strong references to the bound blend state
+ RefCntAutoPtr< IBlendState> m_pBlendState;
+
+ /// Current stencil reference value
+ Uint32 m_StencilRef;
+
+ /// Curent blend factors
+ Float32 m_BlendFactors[4];
+
+ /// Current samples blend mask
+ Uint32 m_SamplesBlendMask;
+
+ /// Current viewports
+ std::vector<Viewport> m_Viewports;
+
+ /// Current scissor rects
+ std::vector<Rect> m_ScissorRects;
+
+ /// Vector of strong references to bound render targets
+ std::vector< RefCntAutoPtr<ITextureView> > m_pBoundRenderTargets;
+
+ /// Strong references to the bound depth stencil view
+ RefCntAutoPtr<ITextureView> m_pBoundDepthStencil;
+
+private:
+ RefCntAutoPtr<IDepthStencilState> m_pDefaultDSS;
+ RefCntAutoPtr<IRasterizerState> m_pDefaultRS;
+ RefCntAutoPtr<IBlendState> m_pDefaultBS;
+};
+
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )
+{
+ if( StartSlot >= MaxBufferSlots )
+ {
+ LOG_ERROR_MESSAGE( "Start vertex buffer slot ", StartSlot, " is out of allowed range [0, ", MaxBufferSlots-1, "]." )
+ return;
+ }
+
+ if( StartSlot + NumBuffersSet > MaxBufferSlots )
+ {
+ LOG_ERROR_MESSAGE( "The range of vertex buffer slots being set [", StartSlot, ", ", StartSlot + NumBuffersSet - 1, "] is out of allowed range [0, ", MaxBufferSlots - 1, "]." )
+ NumBuffersSet = MaxBufferSlots - StartSlot;
+ }
+
+ if( Flags & SET_VERTEX_BUFFERS_FLAG_RESET )
+ {
+ m_VertexStreams.clear();
+ }
+ m_VertexStreams.resize( std::max(m_VertexStreams.size(), static_cast<size_t>(StartSlot + NumBuffersSet) ) );
+ for( Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff )
+ {
+ auto &CurrStream = m_VertexStreams[StartSlot + Buff];
+ CurrStream.pBuffer = RefCntAutoPtr<IBuffer>( ppBuffers ? ppBuffers[Buff] : nullptr );
+ CurrStream.Stride = pStrides ? pStrides[Buff] : 0;
+ CurrStream.Offset = pOffsets ? pOffsets[Buff] : 0;
+#ifdef DEBUG_CHECKS
+ if( CurrStream.pBuffer )
+ {
+ const auto &BuffDesc = CurrStream.pBuffer->GetDesc();
+ if( !(BuffDesc.BindFlags & BIND_VERTEX_BUFFER) )
+ {
+ LOG_ERROR_MESSAGE( "Buffer \"", BuffDesc.Name ? BuffDesc.Name : "", "\" being bound as vertex buffer to slot ", Buff," was not created with BIND_VERTEX_BUFFER flag" );
+ }
+ }
+#endif
+ }
+ // Remove null buffers from the end of the array
+ while(m_VertexStreams.size() > 0 && !m_VertexStreams.back().pBuffer)
+ m_VertexStreams.pop_back();
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: ClearState()
+{
+ UNSUPPORTED("This function is not implemented")
+ //m_VertexStreams.clear();
+ //m_pIndexBuffer.Release();
+ //m_IndexDataStartOffset = 0;
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: SetVertexDescription( IVertexDescription *pVertexDesc )
+{
+ m_pVertexDesc = pVertexDesc;
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset )
+{
+ m_pIndexBuffer = pIndexBuffer;
+ m_IndexDataStartOffset = ByteOffset;
+#ifdef DEBUG_CHECKS
+ const auto &BuffDesc = m_pIndexBuffer->GetDesc();
+ if( !(BuffDesc.BindFlags & BIND_INDEX_BUFFER) )
+ {
+ LOG_ERROR_MESSAGE( "Buffer \"", BuffDesc.Name ? BuffDesc.Name : "", "\" being bound as index buffer was not created with BIND_INDEX_BUFFER flag" );
+ }
+#endif
+}
+
+
+/// \param [in] pDSState - pointer to the new depth-stencil state interface.
+/// \param [in] StencilRef - new stencil reference value.
+/// \param [in] Dummy - dummy argument required to make function signature distinct
+/// from IDeviceContext::SetDepthStencilState(). This is required
+/// because otherwise this overloaded function will only differ in
+/// the return type which is not allowed.
+/// \return
+/// - True if either new depth stencil state or stencil reference value differs from
+/// currently cached values.
+/// - False otherwise.
+///
+/// \remarks The method caches *strong reference* to the provided interface in m_pDSState.
+template<typename BaseInterface>
+bool DeviceContextBase<BaseInterface> :: SetDepthStencilState( IDepthStencilState *pDSState, Uint32 StencilRef, Uint32 Dummy )
+{
+ // If null depth-stencil state is provided, bind default state
+ if( !pDSState )
+ pDSState = m_pDefaultDSS;
+
+ // Here m_pDSState is certainly a live object because we keep the
+ // strong reference. pDSState is also clearly live object, so we can
+ // safely compare pointers.
+ if( m_pDSState != pDSState || m_StencilRef != StencilRef )
+ {
+ m_pDSState = pDSState;
+ m_StencilRef = StencilRef;
+ return true;
+ }
+
+ return false;
+}
+
+/// \param [in] pRS - pointer to the new rasterizer state interface.
+/// \param [in] Dummy - dummy argument required to make function signature distinct
+/// from IDeviceContext::SetRasterizerState(). This is required
+/// because otherwise this overloaded function will only differ in
+/// the return type which is not allowed.
+/// \return
+/// - True if the new rasterizer state differ from the cached state.
+/// - False otherwise.
+///
+/// \remarks The method caches *strong reference* to the provided interface in m_pRasterizerState.
+template<typename BaseInterface>
+bool DeviceContextBase<BaseInterface> :: SetRasterizerState( IRasterizerState *pRS, Uint32 Dummy )
+{
+ // If null rasterizer state provided, bind default state
+ if( !pRS )
+ pRS = m_pDefaultRS;
+
+ // Here m_pRasterizerState is certainly a live object because we keep the
+ // strong reference. pRS is also clearly live object, so we can
+ // safely compare pointers.
+ if( m_pRasterizerState != pRS )
+ {
+ m_pRasterizerState = pRS;
+ return true;
+ }
+
+ return false;
+}
+
+
+/// \param [in] pBS - pointer to the new blend state interface.
+/// \param [in] pBlendFactors - new blend factors.
+/// \param [in] SampleMask - new sample mask.
+/// \param [in] Dummy - dummy argument required to make function signature distinct
+/// from IDeviceContext::SetBlendState(). This is required
+/// because otherwise this overloaded function will only differ in
+/// the return type which is not allowed.
+/// \return
+/// - True if either the new blend state, blend factors or sample mask value differs from
+/// the currently cached values.
+/// - False otherwise.
+///
+/// \remarks The method caches *strong reference* to the provided interface in m_pBlendState.
+template<typename BaseInterface>
+bool DeviceContextBase<BaseInterface> :: SetBlendState( IBlendState *pBS, const float* pBlendFactors, Uint32 SampleMask, Uint32 Dummy )
+{
+ // If null blend state provided, bind default state
+ if( !pBS )
+ pBS = m_pDefaultBS;
+
+ static const float DefaultBlendFactors[4] = { 1, 1, 1, 1 };
+ if( pBlendFactors == nullptr )
+ pBlendFactors = DefaultBlendFactors;
+
+ // Here m_pBlendState is certainly a live object because we keep the
+ // strong reference. pBS is also clearly live object, so we can
+ // safely compare pointers.
+ if( m_pBlendState != pBS ||
+ m_BlendFactors[0] != pBlendFactors[0] ||
+ m_BlendFactors[1] != pBlendFactors[1] ||
+ m_BlendFactors[2] != pBlendFactors[2] ||
+ m_BlendFactors[3] != pBlendFactors[3] ||
+ m_SamplesBlendMask != SampleMask )
+ {
+ m_pBlendState = pBS;
+ m_SamplesBlendMask = SampleMask;
+ for( int i = 0; i < 4; ++i )
+ m_BlendFactors[i] = pBlendFactors[i];
+
+ return true;
+ }
+
+ return false;
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: GetDepthStencilState(IDepthStencilState **ppDSS, Uint32 &StencilRef)
+{
+ VERIFY( ppDSS != nullptr, "Null pointer provided null" );
+ VERIFY( *ppDSS == nullptr, "Memory address contains a pointer to a non-null depth-stencil state" );
+ VERIFY( m_pDSState, "No depth-stencil state is bound. At least default state must always be bound. Did you forget to call CreateDefaultStates()?" );
+ m_pDSState->QueryInterface( IID_DepthStencilState, reinterpret_cast<IObject**>( ppDSS ) );
+ StencilRef = m_StencilRef;
+};
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: GetRasterizerState(IRasterizerState **ppRS )
+{
+ VERIFY( ppRS != nullptr, "Null pointer provided null" );
+ VERIFY( *ppRS == nullptr, "Memory address contains a pointer to a non-null rasterizer state" );
+ VERIFY( m_pRasterizerState, "No rasterizer state is bound. At least default state must always be bound. Did you forget to call CreateDefaultStates()?" );
+ m_pRasterizerState->QueryInterface( IID_RasterizerState, reinterpret_cast<IObject**>( ppRS ) );
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: GetBlendState( IBlendState **ppBS, float* BlendFactors, Uint32& SamplesBlendMask )
+{
+ VERIFY( ppBS != nullptr, "Null pointer provided null" );
+ VERIFY( *ppBS == nullptr, "Memory address contains a pointer to a non-null blend state" );
+ VERIFY( m_pBlendState, "No blend state is bound. At least default state must always be bound. Did you forget to call CreateDefaultStates()?" );
+ m_pBlendState->QueryInterface( IID_BlendState, reinterpret_cast<IObject**>( ppBS ) );
+ for( Uint32 f = 0; f < 4; ++f )
+ BlendFactors[f] = m_BlendFactors[f];
+ SamplesBlendMask = m_SamplesBlendMask;
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: GetRenderTargetSize( Uint32 &RTWidth, Uint32 &RTHeight )
+{
+ RTWidth = 0;
+ RTHeight = 0;
+ // First, try to find non-null render target
+ for( Uint32 rt = 0; rt < m_pBoundRenderTargets.size(); ++rt )
+ if( auto *pRTView = m_pBoundRenderTargets[rt].RawPtr() )
+ {
+ // Use render target size as viewport size
+ auto *pTex = pRTView->GetTexture();
+ auto MipLevel = pRTView->GetDesc().MostDetailedMip;
+ const auto &TexDesc = pTex->GetDesc();
+ RTWidth = TexDesc.Width >> MipLevel;
+ RTHeight = TexDesc.Height >> MipLevel;
+ VERIFY( RTWidth > 0 && RTHeight > 0, "RT dimension is zero" );
+ break;
+ }
+
+ // If render target was not found, check depth stencil
+ if( RTWidth == 0 || RTHeight == 0 )
+ {
+ auto *pDSView = m_pBoundDepthStencil.RawPtr();
+ if( pDSView != nullptr )
+ {
+ // Use depth stencil size
+ auto *pTex = pDSView->GetTexture();
+ const auto &TexDesc = pTex->GetDesc();
+ RTWidth = TexDesc.Width;
+ RTHeight = TexDesc.Height;
+ }
+ }
+
+ // Finally, if no render targets and depth stencil are bound,
+ // use default RT size
+ if( RTWidth == 0 || RTHeight == 0 )
+ {
+ const auto &SwapChainDesc = m_pSwapChain->GetDesc();
+ RTWidth = SwapChainDesc.Width;
+ RTHeight = SwapChainDesc.Height;
+ }
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight )
+{
+ if( RTWidth == 0 || RTHeight == 0 )
+ {
+ GetRenderTargetSize( RTWidth, RTHeight );
+ }
+
+ m_Viewports.resize(NumViewports);
+ Viewport DefaultVP( 0, 0, static_cast<float>(RTWidth), static_cast<float>(RTHeight) );
+ // If no viewports are specified, use default viewport
+ if( NumViewports == 1 && pViewports == nullptr )
+ {
+ pViewports = &DefaultVP;
+ }
+
+ for( Uint32 vp = 0; vp < NumViewports; ++vp )
+ {
+ m_Viewports[vp] = pViewports[vp];
+ VERIFY( m_Viewports[vp].Width >= 0, "Incorrect viewport width (", m_Viewports[vp].Width, ")" );
+ VERIFY( m_Viewports[vp].Height >= 0 , "Incorrect viewport height (", m_Viewports[vp].Height, ")" );
+ VERIFY( m_Viewports[vp].MaxDepth >= m_Viewports[vp].MinDepth, "Incorrect viewport depth range [", m_Viewports[vp].MinDepth, ", ", m_Viewports[vp].MaxDepth, "]" );
+ }
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: GetViewports( Uint32 &NumViewports, Viewport *pViewports )
+{
+ NumViewports = static_cast<Uint32>( m_Viewports.size() );
+ if( pViewports )
+ {
+ for( Uint32 vp = 0; vp < m_Viewports.size(); ++vp )
+ pViewports[vp] = m_Viewports[vp];
+ }
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight )
+{
+ if( RTWidth == 0 || RTHeight == 0 )
+ {
+ GetRenderTargetSize( RTWidth, RTHeight );
+ }
+
+ m_ScissorRects.resize( NumRects );
+ for( Uint32 sr = 0; sr < NumRects; ++sr )
+ {
+ m_ScissorRects[sr] = pRects[sr];
+ VERIFY( m_ScissorRects[sr].left <= m_ScissorRects[sr].right, "Incorrect horizontal bounds for a scissor rect [", m_ScissorRects[sr].left, ", ", m_ScissorRects[sr].right, ")" );
+ VERIFY( m_ScissorRects[sr].top <= m_ScissorRects[sr].bottom, "Incorrect vertical bounds for a scissor rect [", m_ScissorRects[sr].top, ", ", m_ScissorRects[sr].bottom, ")" );
+ }
+}
+
+template<typename BaseInterface>
+bool DeviceContextBase<BaseInterface> :: SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, Uint32 Dummy )
+{
+ bool bBindRenderTargets = false;
+ if( NumRenderTargets != m_pBoundRenderTargets.size() )
+ {
+ bBindRenderTargets = true;
+ m_pBoundRenderTargets.resize(NumRenderTargets);
+ }
+
+ for( Uint32 rt = 0; rt < NumRenderTargets; ++rt )
+ {
+ auto *pRTView = ppRenderTargets[rt];
+#ifdef _DEBUG
+ if( pRTView )
+ {
+ const auto &ViewDesc = pRTView->GetDesc();
+ VERIFY( ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET, "Texture view object named \"", ViewDesc.Name ? ViewDesc.Name : "", "\" has incorrect view type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), "). Render target view is expected" );
+ }
+#endif
+ // Here both views a certainly live object, since we store
+ // strong references to all bound render targets. So we
+ // can safely compare pointers.
+ if( m_pBoundRenderTargets[rt] != pRTView )
+ {
+ m_pBoundRenderTargets[rt] = pRTView;
+ bBindRenderTargets = true;
+ }
+ }
+
+#ifdef _DEBUG
+ if( pDepthStencil )
+ {
+ const auto &ViewDesc = pDepthStencil->GetDesc();
+ VERIFY( ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Texture view object named \"", ViewDesc.Name ? ViewDesc.Name : "", "\" has incorrect view type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), "). Depth stencil view is expected" );
+ }
+#endif
+
+ if( m_pBoundDepthStencil != pDepthStencil)
+ {
+ m_pBoundDepthStencil = pDepthStencil;
+ bBindRenderTargets = true;
+ }
+
+ return bBindRenderTargets;
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: GetRenderTargets( Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV )
+{
+ NumRenderTargets = static_cast<Uint32>( m_pBoundRenderTargets.size() );
+
+ if( ppRTVs )
+ {
+ for( Uint32 rt = 0; rt < NumRenderTargets; ++rt )
+ {
+ VERIFY( ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt );
+ auto pBoundRTV = m_pBoundRenderTargets[rt];
+ if( pBoundRTV )
+ pBoundRTV->QueryInterface( IID_TextureView, reinterpret_cast<IObject**>(ppRTVs + rt) );
+ else
+ ppRTVs[rt] = nullptr;
+ }
+ for( Uint32 rt = NumRenderTargets; rt < MaxRenderTargets; ++rt )
+ {
+ VERIFY( ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt );
+ ppRTVs[rt] = nullptr;
+ }
+ }
+
+ if( ppDSV )
+ {
+ VERIFY( *ppDSV == nullptr, "Non-null DSV pointer found" );
+ if( m_pBoundDepthStencil )
+ m_pBoundDepthStencil->QueryInterface( IID_TextureView, reinterpret_cast<IObject**>(ppDSV) );
+ else
+ *ppDSV = nullptr;
+ }
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: CreateDefaultStates()
+{
+ DepthStencilStateDesc DefaultDSSDesc;
+ DefaultDSSDesc.Name = "Default depth stencil state";
+ m_pDevice->CreateDepthStencilState( DefaultDSSDesc, &m_pDefaultDSS );
+
+ RasterizerStateDesc DefaultRSDesc;
+ DefaultRSDesc.Name = "Default rasterizer state";
+ m_pDevice->CreateRasterizerState( DefaultRSDesc, &m_pDefaultRS );
+
+ BlendStateDesc DefaultBlendState;
+ DefaultBlendState.Name = "Default blend state";
+ m_pDevice->CreateBlendState( DefaultBlendState, &m_pDefaultBS );
+
+ SetDepthStencilState( m_pDefaultDSS, 0 );
+ SetRasterizerState( m_pDefaultRS );
+ float BlendFactors[4] = { 1, 1, 1, 1 };
+ SetBlendState( m_pDefaultBS, BlendFactors, 0xFFFFFFFF );
+}
+
+template<typename BaseInterface>
+void DeviceContextBase<BaseInterface> :: GetShaders( IShader **ppShaders, Uint32 &NumShaders )
+{
+ NumShaders = static_cast<Uint32>( m_pBoundShaders.size() );
+ if( ppShaders == nullptr )
+ return;
+ for( Uint32 s = 0; s < NumShaders; ++s )
+ {
+ VERIFY( ppShaders[s] == nullptr, "Non-null pointer found in shader array element #", s );
+ if( auto pBoundShader = m_pBoundShaders[s] )
+ pBoundShader->QueryInterface( IID_Shader, reinterpret_cast<IObject**>( ppShaders + s ) );
+ else
+ ppShaders[s] = nullptr;
+ }
+}
+
+}
diff --git a/Graphics/GraphicsEngine/include/DeviceObjectBase.h b/Graphics/GraphicsEngine/include/DeviceObjectBase.h
new file mode 100644
index 00000000..f96b6d7c
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/DeviceObjectBase.h
@@ -0,0 +1,117 @@
+/* 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
+/// Implementation of the Diligent::DeviceObjectBase template class
+
+#include "ObjectBase.h"
+#include "UniqueIdentifier.h"
+
+namespace Diligent
+{
+
+template<typename BaseInterface>
+class RenderDeviceBase;
+
+/// Template class implementing base functionality for a device object
+template<class BaseInterface, typename ObjectDescType>
+class DeviceObjectBase : public ObjectBase<BaseInterface>
+{
+public:
+
+ /// \param pDevice - pointer to the render device.
+ /// \param ObjDesc - object description.
+ /// \param pOwner - owner object.
+ /// \param bIsDeviceInternal - flag indicating if the object is an internal device object
+ /// and must not keep a strong reference to the device.
+ DeviceObjectBase( class IRenderDevice *pDevice,
+ const ObjectDescType &ObjDesc,
+ IObject *pOwner = nullptr,
+ bool bIsDeviceInternal = false) :
+ ObjectBase<BaseInterface>(pOwner),
+ m_pDevice( pDevice ),
+ // Do not keep strong reference to the device if the object is an internal device object
+ m_spDevice( bIsDeviceInternal ? nullptr : pDevice ),
+ m_ObjectNameCopy(ObjDesc.Name ? ObjDesc.Name : ""),
+ m_Desc( ObjDesc )
+ {
+ m_Desc.Name = m_ObjectNameCopy.c_str();
+
+ // !!!WARNING!!!
+ // We cannot add resource to the hash table from here, because the object
+ // has not been completely created yet and the reference counters object
+ // is not initialized!
+ //m_pDevice->AddResourceToHash( this ); - ERROR!
+ }
+
+ virtual ~DeviceObjectBase()
+ {
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_DeviceObject, ObjectBase<BaseInterface> )
+
+ virtual const ObjectDescType& GetDesc()const override
+ {
+ return m_Desc;
+ }
+
+ /// Returns unique identifier
+ UniqueIdentifier GetUniqueID()const
+ {
+ /// \note
+ /// This unique ID is used to unambiguously identify device object for
+ /// tracking purposes.
+ /// Niether GL handle nor pointer could be safely used for this purpose
+ /// as both GL reuses released handles and the OS reuses released pointers
+ return m_UniqueID.GetID();
+ }
+
+protected:
+
+ IRenderDevice *GetDevice(){return m_pDevice;}
+
+ /// Copy of a device object name
+ const String m_ObjectNameCopy;
+
+ /// Object description
+ ObjectDescType m_Desc;
+
+ // Template argument is only used to separate counters for
+ // different groups of objects
+ UniqueIdHelper<BaseInterface> m_UniqueID;
+
+private:
+ /// Pointer to the device
+ IRenderDevice *m_pDevice;
+ /// Strong reference to the device
+ RefCntAutoPtr<IRenderDevice> m_spDevice;
+
+ DeviceObjectBase( const DeviceObjectBase& );
+ DeviceObjectBase( DeviceObjectBase&& );
+ const DeviceObjectBase& operator = ( const DeviceObjectBase& );
+ const DeviceObjectBase& operator = ( DeviceObjectBase&& );
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/RasterizerStateBase.h b/Graphics/GraphicsEngine/include/RasterizerStateBase.h
new file mode 100644
index 00000000..a3c90275
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/RasterizerStateBase.h
@@ -0,0 +1,69 @@
+/* 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
+/// Implementation of the Diligent::RasterizerStateBase template class
+
+#include "RasterizerState.h"
+#include "DeviceObjectBase.h"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a rasterizer object.
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::IRasterizerStateD3D11 or Diligent::IRasterizerStateGL).
+/// \tparam RenderDeviceBaseInterface - base interface for the render device
+/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceGL,
+/// or Diligent::IRenderDeviceGLES).
+template<class BaseInterface = IRasterizerState, class RenderDeviceBaseInterface = IRenderDevice>
+class RasterizerStateBase : public DeviceObjectBase<BaseInterface, RasterizerStateDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, RasterizerStateDesc> TDeviceObjectBase;
+ typedef RenderDeviceBase < RenderDeviceBaseInterface > TRenderDeviceBase;
+
+ /// \param pDevice - pointer to the device.
+ /// \param RSDesc - rasterizer state description.
+ /// \param bIsDeviceInternal - flag indicating if the state is an internal device object and
+ /// must not keep a strong reference to the device.
+ RasterizerStateBase( IRenderDevice *pDevice, const RasterizerStateDesc& RSDesc, bool bIsDeviceInternal = false ) :
+ TDeviceObjectBase( pDevice, RSDesc, nullptr, bIsDeviceInternal )
+ {
+ }
+
+ ~RasterizerStateBase()
+ {
+ /// \note Destructor cannot directly remove the object from the registry as this may cause a
+ /// deadlock. See BlendStateBase::~BlendStateBase() for details.
+ auto &RasterizerStateRegistry = static_cast<TRenderDeviceBase*>(this->GetDevice())->GetRSRegistry();
+ RasterizerStateRegistry.ReportDeletedObject();
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_RasterizerState, TDeviceObjectBase )
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.h b/Graphics/GraphicsEngine/include/RenderDeviceBase.h
new file mode 100644
index 00000000..97103f23
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.h
@@ -0,0 +1,399 @@
+/* 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
+/// Implementation of the Diligent::RenderDeviceBase template class and related structures
+
+#include "RenderDevice.h"
+#include "DeviceObjectBase.h"
+#include "Defines.h"
+#include "ResourceMappingImpl.h"
+#include "StateObjectsRegistry.h"
+#include "HashUtils.h"
+#include "ObjectBase.h"
+#include "DeviceContext.h"
+#include "SwapChain.h"
+#include "GraphicsUtilities.h"
+
+using Diligent::RefCntAutoPtr;
+using Diligent::RefCntWeakPtr;
+
+namespace std
+{
+ /// Hash function specialization for Diligent::SamplerDesc structure.
+ template<>
+ struct hash<Diligent::SamplerDesc>
+ {
+ size_t operator()( const Diligent::SamplerDesc &SamDesc ) const
+ {
+ // Sampler name is ignored in comparison operator
+ // and should not be hashed
+ return Diligent::ComputeHash( // SamDesc.Name,
+ static_cast<int>(SamDesc.MinFilter),
+ static_cast<int>(SamDesc.MagFilter),
+ static_cast<int>(SamDesc.MipFilter),
+ static_cast<int>(SamDesc.AddressU),
+ static_cast<int>(SamDesc.AddressV),
+ static_cast<int>(SamDesc.AddressW),
+ SamDesc.MipLODBias,
+ SamDesc.MaxAnisotropy,
+ static_cast<int>(SamDesc.ComparisonFunc),
+ SamDesc.BorderColor[0],
+ SamDesc.BorderColor[1],
+ SamDesc.BorderColor[2],
+ SamDesc.BorderColor[3],
+ SamDesc.MinLOD, SamDesc.MaxLOD );
+ }
+ };
+
+ /// Hash function specialization for Diligent::StencilOpDesc structure.
+ template<>
+ struct hash<Diligent::StencilOpDesc>
+ {
+ size_t operator()( const Diligent::StencilOpDesc &StOpDesc ) const
+ {
+ return Diligent::ComputeHash( static_cast<int>( StOpDesc.StencilFailOp ),
+ static_cast<int>( StOpDesc.StencilDepthFailOp ),
+ static_cast<int>( StOpDesc.StencilPassOp ),
+ static_cast<int>( StOpDesc.StencilFunc ) );
+ }
+ };
+
+ /// Hash function specialization for Diligent::DepthStencilStateDesc structure.
+ template<>
+ struct hash<Diligent::DepthStencilStateDesc>
+ {
+ size_t operator()( const Diligent::DepthStencilStateDesc &DSSDesc ) const
+ {
+ // Depth-stencil state name is ignored in comparison operator
+ // and should not be hashed
+ return Diligent::ComputeHash( // DSSDesc.Name,
+ DSSDesc.DepthEnable,
+ DSSDesc.DepthWriteEnable,
+ static_cast<int>(DSSDesc.DepthFunc),
+ DSSDesc.StencilEnable,
+ DSSDesc.StencilReadMask,
+ DSSDesc.StencilWriteMask,
+ DSSDesc.FrontFace,
+ DSSDesc.BackFace );
+ }
+ };
+
+ /// Hash function specialization for Diligent::RasterizerStateDesc structure.
+ template<>
+ struct hash<Diligent::RasterizerStateDesc>
+ {
+ size_t operator()( const Diligent::RasterizerStateDesc &RSDesc ) const
+ {
+ // Rasterizer state name is ignored in comparison operator
+ // and should not be hashed
+ return Diligent::ComputeHash( // RSDesc.Name,
+ static_cast<int>( RSDesc.FillMode ),
+ static_cast<int>( RSDesc.CullMode ),
+ RSDesc.FrontCounterClockwise,
+ RSDesc.DepthBias,
+ RSDesc.DepthBiasClamp,
+ RSDesc.SlopeScaledDepthBias,
+ RSDesc.DepthClipEnable,
+ RSDesc.ScissorEnable,
+ RSDesc.AntialiasedLineEnable );
+ }
+ };
+
+ /// Hash function specialization for Diligent::BlendStateDesc structure.
+ template<>
+ struct hash<Diligent::BlendStateDesc>
+ {
+ size_t operator()( const Diligent::BlendStateDesc &BSDesc ) const
+ {
+ std::size_t Seed = 0;
+ for( int i = 0; i < Diligent::BlendStateDesc::MaxRenderTargets; ++i )
+ {
+ const auto& rt = BSDesc.RenderTargets[i];
+ Diligent::HashCombine( Seed,
+ rt.BlendEnable,
+ static_cast<int>( rt.SrcBlend ),
+ static_cast<int>( rt.DestBlend ),
+ static_cast<int>( rt.BlendOp ),
+ static_cast<int>( rt.SrcBlendAlpha ),
+ static_cast<int>( rt.DestBlendAlpha ),
+ static_cast<int>( rt.BlendOpAlpha ),
+ rt.RenderTargetWriteMask );
+ }
+ Diligent::HashCombine( Seed,
+ // Blend state name is ignored in comparison operator
+ // and should not be hashed
+ // BSDesc.Name,
+ BSDesc.AlphaToCoverageEnable,
+ BSDesc.IndependentBlendEnable );
+ return Seed;
+ }
+ };
+
+
+ /// Hash function specialization for Diligent::BlendStateDesc structure.
+ template<>
+ struct hash<Diligent::TextureViewDesc>
+ {
+ size_t operator()( const Diligent::TextureViewDesc &TexViewDesc ) const
+ {
+ std::size_t Seed = 0;
+ Diligent::HashCombine( Seed,
+ static_cast<Diligent::Int32>(TexViewDesc.ViewType),
+ static_cast<Diligent::Int32>(TexViewDesc.TextureType),
+ static_cast<Diligent::Int32>(TexViewDesc.Format),
+ TexViewDesc.MostDetailedMip,
+ TexViewDesc.NumMipLevels,
+ TexViewDesc.FirstArraySlice,
+ TexViewDesc.NumArraySlices,
+ TexViewDesc.AccessFlags );
+ return Seed;
+ }
+ };
+}
+
+namespace Diligent
+{
+
+/// Base implementation of a render device
+
+/// \warning
+/// Render device must *NOT* hold strong references to any
+/// object it creates to avoid circular dependencies.
+/// Device context, swap chain and all object the device creates
+/// keep strong reference to the device.
+/// Device only holds weak reference to immediate context.
+template<typename BaseInterface = IRenderDevice>
+class RenderDeviceBase : public ObjectBase<BaseInterface>
+{
+public:
+ RenderDeviceBase() :
+ m_TextureFormatsInfo( TEX_FORMAT_NUM_FORMATS ),
+ m_TexFmtInfoInitFlags( TEX_FORMAT_NUM_FORMATS ),
+ m_SamplersRegistry("sampler"),
+ m_DSSRegistry("ds state"),
+ m_RSRegistry("rasterizer state"),
+ m_BSRegistry("blend state")
+ {
+ // Initialize texture format info
+ for( Uint32 Fmt = TEX_FORMAT_UNKNOWN; Fmt < TEX_FORMAT_NUM_FORMATS; ++Fmt )
+ static_cast<TextureFormatAttribs&>(m_TextureFormatsInfo[Fmt]) = GetTextureFormatAttribs( static_cast<TEXTURE_FORMAT>(Fmt) );
+
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ff471325(v=vs.85).aspx
+ std::vector<TEXTURE_FORMAT> FilterableFormats =
+ {
+ TEX_FORMAT_RGBA32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
+ TEX_FORMAT_RGBA16_FLOAT,
+ TEX_FORMAT_RGBA16_UNORM,
+ TEX_FORMAT_RGBA16_SNORM,
+ TEX_FORMAT_RG32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
+ TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS,
+ //TEX_FORMAT_R10G10B10A2_UNORM,
+ TEX_FORMAT_R11G11B10_FLOAT,
+ TEX_FORMAT_RGBA8_UNORM,
+ TEX_FORMAT_RGBA8_UNORM_SRGB,
+ TEX_FORMAT_RGBA8_SNORM,
+ TEX_FORMAT_RG16_FLOAT,
+ TEX_FORMAT_RG16_UNORM,
+ TEX_FORMAT_RG16_SNORM,
+ TEX_FORMAT_R32_FLOAT, // OpenGL ES3.1 does not require this format to be filterable
+ TEX_FORMAT_R24_UNORM_X8_TYPELESS,
+ TEX_FORMAT_RG8_UNORM,
+ TEX_FORMAT_RG8_SNORM,
+ TEX_FORMAT_R16_FLOAT,
+ TEX_FORMAT_R16_UNORM,
+ TEX_FORMAT_R16_SNORM,
+ TEX_FORMAT_R8_UNORM,
+ TEX_FORMAT_R8_SNORM,
+ TEX_FORMAT_A8_UNORM,
+ TEX_FORMAT_RGB9E5_SHAREDEXP,
+ TEX_FORMAT_RG8_B8G8_UNORM,
+ TEX_FORMAT_G8R8_G8B8_UNORM,
+ TEX_FORMAT_BC1_UNORM,
+ TEX_FORMAT_BC1_UNORM_SRGB,
+ TEX_FORMAT_BC2_UNORM,
+ TEX_FORMAT_BC2_UNORM_SRGB,
+ TEX_FORMAT_BC3_UNORM,
+ TEX_FORMAT_BC3_UNORM_SRGB,
+ TEX_FORMAT_BC4_UNORM,
+ TEX_FORMAT_BC4_SNORM,
+ TEX_FORMAT_BC5_UNORM,
+ TEX_FORMAT_BC5_SNORM,
+ TEX_FORMAT_B5G6R5_UNORM
+ };
+ for( auto fmt = FilterableFormats.begin(); fmt != FilterableFormats.end(); ++fmt )
+ m_TextureFormatsInfo[ *fmt ].Filterable = true;
+ }
+
+ ~RenderDeviceBase()
+ {
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_RenderDevice, ObjectBase<BaseInterface> )
+
+ virtual void CreateResourceMapping( const ResourceMappingDesc &MappingDesc, IResourceMapping **ppMapping );
+
+ virtual const DeviceCaps& GetDeviceCaps()const
+ {
+ return m_DeviceCaps;
+ }
+
+ virtual const TextureFormatInfo &GetTextureFormatInfo(TEXTURE_FORMAT TexFormat)
+ {
+ VERIFY( TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS, "Texture format out of range" );
+ const auto& TexFmtInfo = m_TextureFormatsInfo[TexFormat];
+ VERIFY( TexFmtInfo.Format == TexFormat, "Sanity check failed" );
+ return TexFmtInfo;
+ }
+
+ virtual const TextureFormatInfoExt &GetTextureFormatInfoExt( TEXTURE_FORMAT TexFormat )
+ {
+ VERIFY( TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS, "Texture format out of range" );
+ const auto& TexFmtInfo = m_TextureFormatsInfo[TexFormat];
+ VERIFY( TexFmtInfo.Format == TexFormat, "Sanity check failed" );
+ if( !m_TexFmtInfoInitFlags[TexFormat] )
+ {
+ if( TexFmtInfo.Supported )
+ TestTextureFormat(TexFormat);
+ m_TexFmtInfoInitFlags[TexFormat] = true;
+ }
+ return TexFmtInfo;
+ }
+
+ void OnCreateDeviceObject( IDeviceObject *pNewObject )
+ {
+ }
+
+ StateObjectsRegistry<SamplerDesc> &GetSamplerRegistry(){ return m_SamplersRegistry; }
+ StateObjectsRegistry<DepthStencilStateDesc> &GetDSStateRegistry(){ return m_DSSRegistry; }
+ StateObjectsRegistry<RasterizerStateDesc> &GetRSRegistry() { return m_RSRegistry; }
+ StateObjectsRegistry<BlendStateDesc> &GetBSRegistry() { return m_BSRegistry; }
+
+ /// Set weak reference to the immediate context
+ void SetImmediateContext(IDeviceContext *pImmediateContext)
+ {
+ VERIFY( m_wpImmediateContext.Lock() == nullptr, "Immediate context has already been set" );
+ m_wpImmediateContext = pImmediateContext;
+ }
+
+ RefCntAutoPtr<IDeviceContext> GetImmediateContext(){ return m_wpImmediateContext.Lock(); }
+
+protected:
+
+ virtual void TestTextureFormat(TEXTURE_FORMAT TexFormat) = 0;
+
+ /// Helper template function to facilitate device object creation
+ template<typename TObjectType, typename TObjectDescType, typename TObjectConstructor>
+ void CreateDeviceObject( const Char *ObjectTypeName, const TObjectDescType &Desc, TObjectType **ppObject, TObjectConstructor ConstructObject );
+
+ DeviceCaps m_DeviceCaps;
+
+ // All state object registries hold raw pointers.
+ // This is safe because every object unregisters itself
+ // when it is deleted.
+ StateObjectsRegistry<SamplerDesc> m_SamplersRegistry; ///< Sampler state registry
+ StateObjectsRegistry<DepthStencilStateDesc> m_DSSRegistry;///< Depth-stencil state registry
+ StateObjectsRegistry<RasterizerStateDesc> m_RSRegistry; ///< Rasterizer state registry
+ StateObjectsRegistry<BlendStateDesc> m_BSRegistry; ///< Blend state registry
+ std::vector<TextureFormatInfoExt> m_TextureFormatsInfo;
+ std::vector<bool> m_TexFmtInfoInitFlags;
+
+ /// Weak reference to the immediate context. Immediate context holds strong reference
+ /// to the device, so we must use weak reference to avoid circular dependencies.
+ Diligent::RefCntWeakPtr<IDeviceContext> m_wpImmediateContext;
+};
+
+
+template<typename BaseInterface>
+void RenderDeviceBase<BaseInterface>::CreateResourceMapping( const ResourceMappingDesc &MappingDesc, IResourceMapping **ppMapping )
+{
+ VERIFY( ppMapping != nullptr, "Null pointer provided" );
+ if( ppMapping == nullptr )
+ return;
+ VERIFY( *ppMapping == nullptr, "Overwriting reference to existing object may cause memory leaks" );
+
+ auto *pResourceMapping( new ResourceMappingImpl() );
+ pResourceMapping->QueryInterface( IID_ResourceMapping, reinterpret_cast<IObject**>(ppMapping) );
+ if( MappingDesc.pEntries )
+ {
+ for( auto *pEntry = MappingDesc.pEntries; pEntry->Name && pEntry->pObject; ++pEntry )
+ {
+ (*ppMapping)->AddResource( pEntry->Name, pEntry->pObject, true );
+ }
+ }
+}
+
+
+/// \tparam TObjectType - type of the object being created (IBuffer, ITexture, IBlendState, etc.)
+/// \tparam TObjectDescType - type of the object description structure (BufferDesc, TextureDesc, BlendStateDesc, etc.)
+/// \tparam TObjectConstructor - type of the function that constructs the object
+/// \param ObjectTypeName - string name of the object type ("buffer", "texture", etc.)
+/// \param Desc - object description
+/// \param ppObject - memory address where the pointer to the created object will be stored
+/// \param ConstructObject - function that constructs the object
+template<typename BaseInterface>
+template<typename TObjectType, typename TObjectDescType, typename TObjectConstructor>
+void RenderDeviceBase<BaseInterface> :: CreateDeviceObject( const Char *ObjectTypeName, const TObjectDescType &Desc, TObjectType **ppObject, TObjectConstructor ConstructObject )
+{
+ VERIFY( ppObject != nullptr, "Null pointer provided" );
+ if(!ppObject)
+ return;
+
+ VERIFY( *ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks" );
+ // Do not release *ppObject here!
+ // Should this happen, RefCntAutoPtr<> will take care of this!
+ //if( *ppObject )
+ //{
+ // (*ppObject)->Release();
+ // *ppObject = nullptr;
+ //}
+
+ *ppObject = nullptr;
+
+ try
+ {
+ ConstructObject();
+ }
+ catch( const std::runtime_error & )
+ {
+ VERIFY( *ppObject == nullptr, "Object was created despite error" );
+ if( *ppObject )
+ {
+ (*ppObject)->Release();
+ *ppObject = nullptr;
+ }
+ auto ObjectDescString = GetObjectDescString( Desc );
+ if( ObjectDescString.length() )
+ {
+ LOG_ERROR( "Failed to create ", ObjectTypeName, " object \"", Desc.Name ? Desc.Name : "", "\"\n", ObjectDescString )
+ }
+ else
+ {
+ LOG_ERROR( "Failed to create ", ObjectTypeName, " object \"", Desc.Name ? Desc.Name : "", "\"" )
+ }
+ }
+}
+
+}
diff --git a/Graphics/GraphicsEngine/include/ResourceMappingImpl.h b/Graphics/GraphicsEngine/include/ResourceMappingImpl.h
new file mode 100644
index 00000000..6d412485
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/ResourceMappingImpl.h
@@ -0,0 +1,58 @@
+/* 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
+/// Declaration of the Diligent::ResourceMappingImpl class
+
+#include "ResourceMapping.h"
+#include "ObjectBase.h"
+#include <unordered_map>
+#include "HashUtils.h"
+
+namespace Diligent
+{
+ /// Implementation of the resource mapping
+ class ResourceMappingImpl : public ObjectBase<IResourceMapping>
+ {
+ public:
+ ~ResourceMappingImpl();
+
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface );
+
+ virtual void AddResource( const Char *Name, IDeviceObject *pObject, bool bIsUnique );
+ virtual void RemoveResource( IDeviceObject *pObject );
+ virtual void RemoveResourceByName( const Char *Name );
+
+ /// Finds resource in the mapping. If no resource is found, nullptr is returned
+ virtual void GetResource( const Char *Name, IDeviceObject **ppResource );
+ virtual size_t GetSize();
+
+ private:
+ ThreadingTools::LockHelper Lock();
+
+ ThreadingTools::LockFlag m_LockFlag;
+ std::unordered_map< Diligent::HashMapStringKey, Diligent::RefCntAutoPtr<IDeviceObject> > m_HashTable;
+ };
+}
diff --git a/Graphics/GraphicsEngine/include/SamplerBase.h b/Graphics/GraphicsEngine/include/SamplerBase.h
new file mode 100644
index 00000000..de8ff566
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/SamplerBase.h
@@ -0,0 +1,69 @@
+/* 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
+/// Implementation of the Diligent::SamplerBase template class
+
+#include "Sampler.h"
+#include "DeviceObjectBase.h"
+#include "RenderDeviceBase.h"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a sampler object.
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::ISamplerD3D11 or Diligent::ISamplerGL).
+/// \tparam RenderDeviceBaseInterface - base interface for the render device
+/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceGL,
+/// or Diligent::IRenderDeviceGLES).
+template<class BaseInterface = ISampler, class RenderDeviceBaseInterface = IRenderDevice>
+class SamplerBase : public DeviceObjectBase<BaseInterface, SamplerDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, SamplerDesc> TDeviceObjectBase;
+ typedef RenderDeviceBase<RenderDeviceBaseInterface> TRenderDeviceBase;
+
+ /// \param pDevice - pointer to the device.
+ /// \param SamDesc - sampler description.
+ /// \param bIsDeviceInternal - flag indicating if the sampler is an internal device object and
+ /// must not keep a strong reference to the device.
+ SamplerBase( IRenderDevice *pDevice, const SamplerDesc& SamDesc, bool bIsDeviceInternal = false ) :
+ TDeviceObjectBase( pDevice, SamDesc, nullptr, bIsDeviceInternal )
+ {}
+
+ ~SamplerBase()
+ {
+ /// \note Destructor cannot directly remove the object from the registry as this may cause a
+ /// deadlock. See BlendStateBase::~BlendStateBase() for details.
+ auto &SamplerRegistry = static_cast<TRenderDeviceBase *>(this->GetDevice())->GetSamplerRegistry();
+ SamplerRegistry.ReportDeletedObject();
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Sampler, TDeviceObjectBase )
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/ShaderBase.h b/Graphics/GraphicsEngine/include/ShaderBase.h
new file mode 100644
index 00000000..b2f89341
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/ShaderBase.h
@@ -0,0 +1,92 @@
+/* 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
+/// Implementation of the Diligent::ShaderBase template class
+
+#include "Shader.h"
+#include "DeviceObjectBase.h"
+
+namespace Diligent
+{
+
+/// Base implementation of a shader variable
+struct ShaderVariableBase : public ObjectBase<IShaderVariable>
+{
+ ShaderVariableBase(IShader *pShader) :
+ // Shader variables are always created as part of the shader,
+ // so we must provide owner pointer to the base class constructor
+ ObjectBase<IShaderVariable>(pShader),
+ m_pShader(pShader)
+ {}
+
+ virtual IShader* GetShader()override
+ {
+ return m_pShader;
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_ShaderVariable, ObjectBase<IShaderVariable> )
+
+protected:
+ IShader *m_pShader;
+};
+
+/// Implementation of a dummy shader variable that silently ignores all operations
+struct DummyShaderVariable : ShaderVariableBase
+{
+ DummyShaderVariable(IShader *pShader) :
+ ShaderVariableBase(pShader)
+ {}
+
+ virtual void Set( IDeviceObject *pObject )override
+ {
+ // Ignore operation
+ // Probably output warning
+ }
+};
+
+/// Template class implementing base functionality for a shader object
+template<class BaseInterface = IShader, class RenderDeviceBaseInterface = IRenderDevice>
+class ShaderBase : public DeviceObjectBase<BaseInterface, ShaderDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, ShaderDesc> TDeviceObjectBase;
+
+ /// \param pDevice - pointer to the device.
+ /// \param ShdrDesc - shader description.
+ /// \param bIsDeviceInternal - flag indicating if the shader is an internal device object and
+ /// must not keep a strong reference to the device.
+ ShaderBase( IRenderDevice *pDevice, const ShaderDesc& ShdrDesc, bool bIsDeviceInternal = false ) :
+ TDeviceObjectBase( pDevice, ShdrDesc, nullptr, bIsDeviceInternal ),
+ m_DummyShaderVar(this)
+ {}
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Shader, TDeviceObjectBase )
+
+protected:
+ DummyShaderVariable m_DummyShaderVar; ///< Dummy shader variable
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/StateObjectsRegistry.h b/Graphics/GraphicsEngine/include/StateObjectsRegistry.h
new file mode 100644
index 00000000..e26d1183
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/StateObjectsRegistry.h
@@ -0,0 +1,204 @@
+/* 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
+/// Implementation of the Diligent::StateObjectsRegistry template class
+
+#include "DeviceObject.h"
+#include <unordered_map>
+
+namespace Diligent
+{
+ /// Template class implementing state object registry
+
+ /// \tparam ResourceDescType - type of the resource description. The type must have
+ /// operator== and a hash function defined.
+ ///
+ /// \remarks
+ /// The following strategies do not work:
+ /// - To store raw pointers and remove the object from the registry in the
+ /// object's destructor. In this case other thread may obtain a reference
+ /// to the object while it is being deleted. This scenario is possible if one thread
+ /// has just entered the destructor, but other is executing Find() and entered
+ /// the protection section.
+ /// - Strong pointers will cause circular references and result in memory leaks.
+ /// \remarks
+ /// Only weak pointers provide thread-safe solution. The object is either atomically destroyed,
+ /// so that no other thread can obtain a reference to it through weak pointers. Or it is atomically
+ /// locked, so that strong reference is obtained. In this case no other thread can destroy the object,
+ /// because there is at least one strong reference now. Note however that removing the object from the
+ /// registry in the object's destructor may cause a deadlock at the point where Find() locks the weak pointer:
+ /// if other thread has started dtor, the object will be locked by Diligent::RefCountedObject::Release().
+ /// If after that this thread locks the registry first, it will be waiting for the object to unlock in
+ /// Diligent::RefCntWeakPtr::Lock(), while the dtor thread will be waiting for the registry to unlock.
+ template<typename ResourceDescType>
+ class StateObjectsRegistry
+ {
+ public:
+ /// Number of outstanding deleted objects to purge the registry.
+ static const int DeletedObjectsToPurge = 32;
+
+ StateObjectsRegistry(const Char* RegistryName) :
+ m_RegistryName( RegistryName )
+ {}
+
+ ~StateObjectsRegistry()
+ {
+ // Object registry is part of the device, and every device
+ // object holds a strong reference to the device. So device
+ // is destroyed after all device objects are destroyed, and there
+ // may only be expired references in the registry. After we
+ // purge it, the registry must be empty.
+ Purge();
+ VERIFY( m_DescToObjHashMap.empty(), "DescToObjHashMap is not empty" );
+ }
+
+ /// Adds a new object to the registry
+
+ /// \param [in] ObjectDesc - object description.
+ /// \param [in] pObject - pointer to the object.
+ ///
+ /// Besides adding a new object, the function also checks the number of
+ /// outstanding deleted objects and calls Purge() if the number has reached
+ /// the threshold value DeletedObjectsToPurge. Creating a state object is
+ /// assumed to be an expensive operation and should be performed during
+ /// the initialization. Occasional purge operations should not add significant
+ /// cost to it.
+ void Add( const ResourceDescType& ObjectDesc, IDeviceObject *pObject )
+ {
+ ThreadingTools::LockHelper Lock( m_LockFlag );
+
+ // If the number of outstanding deleted objects reached the threshold value,
+ // purge the registry. Since we have exclusive access now, it is safe
+ // to do.
+ if( m_NumDeletedObjects >= DeletedObjectsToPurge )
+ {
+ Purge();
+ m_NumDeletedObjects = 0;
+ }
+
+ // Try to construct the new element in place
+ auto Elems = m_DescToObjHashMap.emplace( std::make_pair( ObjectDesc, Diligent::RefCntWeakPtr<IDeviceObject>(pObject) ) );
+ // It is theorertically possible that the same object can be found
+ // in the registry. This might happen if two threads try to create
+ // the same object at the same time. They both will not find the
+ // object and then will create and try to add it.
+ //
+ // If the object already exists, we replace the existing reference.
+ // This is safer as there might be scenarios where existing reference
+ // might be expired. For instance, two threads try to create the same
+ // object which is not in the registry. The first thread creates
+ // the object, adds it to the registry and then releases it. After that
+ // the second thread creates the same object and tries to add it to
+ // the registry. It will find an existing expired reference to the
+ // object.
+ if( !Elems.second )
+ {
+ VERIFY( Elems.first->first == ObjectDesc, "Incorrect object description" );
+ LOG_WARNING_MESSAGE( "Object named \"", Elems.first->first.Name, "\" with the same description already exists in the registry."
+ "Replacing with the new object named \"", ObjectDesc.Name ? ObjectDesc.Name : "", "\".");
+ Elems.first->second = pObject;
+ }
+ }
+
+ /// Finds the object in the registry
+ void Find( const ResourceDescType &Desc, IDeviceObject **ppObject )
+ {
+ VERIFY( *ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks" );
+ *ppObject = nullptr;
+ ThreadingTools::LockHelper Lock( m_LockFlag );
+
+ auto It = m_DescToObjHashMap.find( Desc );
+ if( It != m_DescToObjHashMap.end() )
+ {
+ // Try to obtain strong reference to the object.
+ // This is an atomic operation and we either get
+ // a new strong reference or object has been destroyed
+ // and we get null.
+ auto pObject = It->second.Lock();
+ if( pObject )
+ {
+ *ppObject = pObject.Detach();
+ LOG_INFO_MESSAGE( "Equivalent of the requested state object named \"", Desc.Name ? Desc.Name : "", "\" found in the ", m_RegistryName, " registry. Reusing existing object.");
+ }
+ else
+ {
+ // Expired object found: remove it from the map
+ m_DescToObjHashMap.erase(It);
+ Atomics::AtomicDecrement(m_NumDeletedObjects);
+ }
+ }
+ }
+
+ /// Purges outstanding deleted objects from the registry
+ void Purge()
+ {
+ Uint32 NumPurgedObjects = 0;
+ auto It = m_DescToObjHashMap.begin();
+ while( It != m_DescToObjHashMap.end() )
+ {
+ auto NextIt = It;
+ ++NextIt;
+ // Note that IsValid() is not a thread-safe function in the sense that it
+ // can give false positive results. The only thread-safe way to check if the
+ // object is alive is to lock the weak pointer, but that requires thread
+ // synchronization. We will immediately unlock the pointer anyway, so we
+ // want to detect 100% expired pointers. IsValid() does provide that information
+ // because once a weak pointer becomes invalid, it will be invalid
+ // until it is destroyed. It is not a problem if we miss an expired weak
+ // pointer as it will definitiely be removed next time.
+ if( !It->second.IsValid() )
+ {
+ m_DescToObjHashMap.erase( It );
+ ++NumPurgedObjects;
+ }
+
+ It = NextIt;
+ }
+ LOG_INFO_MESSAGE( "Purged ", NumPurgedObjects, " deleted objects from the ", m_RegistryName, " registry" );
+ }
+
+ /// Increments the number of outstanding deleted objects.
+ /// When this number reaches DeletedObjectsToPurge, Purge() will
+ /// be called.
+ void ReportDeletedObject()
+ {
+ Atomics::AtomicIncrement(m_NumDeletedObjects);
+ }
+
+ private:
+ /// Lock flag to protect the m_DescToObjHashMap
+ ThreadingTools::LockFlag m_LockFlag;
+
+ /// Nmber of outstanding deleted objects that have not been purged
+ Atomics::AtomicLong m_NumDeletedObjects;
+
+ /// Hash map that stores weak pointers to the referenced objects
+ std::unordered_map<ResourceDescType, Diligent::RefCntWeakPtr<IDeviceObject> > m_DescToObjHashMap;
+
+ /// Registry name used for debug output
+ const String m_RegistryName;
+ };
+}
diff --git a/Graphics/GraphicsEngine/include/SwapChainBase.h b/Graphics/GraphicsEngine/include/SwapChainBase.h
new file mode 100644
index 00000000..c3400877
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/SwapChainBase.h
@@ -0,0 +1,96 @@
+/* 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
+/// Implementation of the Diligent::SwapChainBase template class
+
+#include "SwapChain.h"
+#include "DeviceObjectBase.h"
+
+namespace Diligent
+{
+
+/// Base implementation of the swap chain.
+
+/// \remarks Swap chain holds the strong reference to the device and a weak reference to the
+/// immediate context.
+template<class BaseInterface = ISwapChain>
+class SwapChainBase : public ObjectBase<BaseInterface>
+{
+public:
+ typedef ObjectBase<BaseInterface> TObjectBase;
+
+ SwapChainBase( IRenderDevice *pDevice,
+ IDeviceContext *pDeviceContext,
+ const SwapChainDesc& SCDesc ) :
+ m_pRenderDevice(pDevice),
+ m_wpDeviceContext(pDeviceContext),
+ m_SwapChainDesc(SCDesc)
+ {
+ }
+
+ ~SwapChainBase()
+ {
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_SwapChain, TObjectBase )
+
+ virtual const SwapChainDesc& GetDesc()const
+ {
+ return m_SwapChainDesc;
+ }
+
+protected:
+ bool Resize( Uint32 NewWidth, Uint32 NewHeight, Int32 Dummy = 0/*To be different from virtual function*/ )
+ {
+ if( NewWidth != 0 && NewHeight != 0 &&
+ (m_SwapChainDesc.Width != NewWidth || m_SwapChainDesc.Height != NewHeight) )
+ {
+ m_SwapChainDesc.Width = NewWidth;
+ m_SwapChainDesc.Height = NewHeight;
+ return true;
+ }
+
+ return false;
+ }
+
+ /// Strong reference to the render device
+ Diligent::RefCntAutoPtr<IRenderDevice> m_pRenderDevice;
+
+ /// Weak references to the immediate device context. The context holds
+ /// the strong reference to the swap chain.
+ Diligent::RefCntWeakPtr<IDeviceContext> m_wpDeviceContext;
+
+ /// Swap chain description
+ SwapChainDesc m_SwapChainDesc;
+
+private:
+ SwapChainBase( const SwapChainBase& );
+ SwapChainBase( SwapChainBase&& );
+ const SwapChainBase& operator = ( const SwapChainBase& );
+ const SwapChainBase& operator = ( SwapChainBase&& );
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/TextureBase.h b/Graphics/GraphicsEngine/include/TextureBase.h
new file mode 100644
index 00000000..094de62d
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/TextureBase.h
@@ -0,0 +1,394 @@
+/* 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
+/// Implementation of the Diligent::TextureBase template class
+
+#include "Texture.h"
+#include "DeviceObjectBase.h"
+#include "GraphicsUtilities.h"
+#include <memory>
+
+namespace Diligent
+{
+
+void ValidateTextureDesc(const TextureDesc& TexDesc);
+void ValidateUpdateDataParams( const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData );
+void VliadateCopyTextureDataParams( const TextureDesc &SrcTexDesc, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box *pSrcBox,
+ const TextureDesc &DstTexDesc, Uint32 DstMipLevel, Uint32 DstSlice,
+ Uint32 DstX, Uint32 DstY, Uint32 DstZ );
+
+/// Base implementation of the ITexture interface
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::ITextureD3D11 or Diligent::ITextureGL).
+/// \tparam TTextureViewImpl - type of the texture view implementation
+/// (Diligent::TextureViewD3D11Impl or Diligent::TextureViewGLImpl).
+template<class BaseInterface, class TTextureViewImpl>
+class TextureBase : public DeviceObjectBase<BaseInterface, TextureDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, TextureDesc> TDeviceObjectBase;
+
+ /// \param pDevice - pointer to the device
+ /// \param Desc - texture description
+ /// \param bIsDeviceInternal - flag indicating if the texture is an internal device object and
+ /// must not keep a strong reference to the device
+ TextureBase( IRenderDevice *pDevice, const TextureDesc& Desc, bool bIsDeviceInternal = false ) :
+ TDeviceObjectBase( pDevice, Desc, nullptr, bIsDeviceInternal )
+ {
+ if( this->m_Desc.MipLevels == 0 )
+ {
+ // Compute the number of levels in the full mipmap chain based
+ // on the maximum texture dimension
+ Uint32 MaxDim = 0;
+ if( this->m_Desc.Type == TEXTURE_TYPE_1D ||
+ this->m_Desc.Type == TEXTURE_TYPE_1D_ARRAY )
+ {
+ MaxDim = this->m_Desc.Width;
+ }
+ else if( this->m_Desc.Type == TEXTURE_TYPE_2D ||
+ this->m_Desc.Type == TEXTURE_TYPE_2D_ARRAY )
+ {
+ MaxDim = std::max( this->m_Desc.Width, this->m_Desc.Height );
+ }
+ else if( this->m_Desc.Type == TEXTURE_TYPE_3D )
+ {
+ MaxDim = std::max( this->m_Desc.Width, this->m_Desc.Height );
+ MaxDim = std::max( MaxDim, this->m_Desc.Depth );
+ }
+ else
+ {
+ UNEXPECTED( "Unkwnown texture type" );
+ }
+ while( (MaxDim >> this->m_Desc.MipLevels) > 0 )
+ ++this->m_Desc.MipLevels;
+ VERIFY( MaxDim >= (1U << (this->m_Desc.MipLevels-1)) && MaxDim < (1U << this->m_Desc.MipLevels), "Incorrect number of Mip levels" )
+ }
+
+ // Validate correctness of texture description
+ ValidateTextureDesc( this->m_Desc );
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Texture, TDeviceObjectBase )
+
+ virtual void CreateView( const struct TextureViewDesc &ViewDesc, ITextureView **ppView )override
+ {
+ CreateViewInternal( ViewDesc, ppView, false );
+ }
+
+ virtual void UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) = 0;
+
+
+ virtual void CopyData( IDeviceContext *pContext,
+ ITexture *pSrcTexture,
+ Uint32 SrcMipLevel,
+ Uint32 SrcSlice,
+ const Box *pSrcBox,
+ Uint32 DstMipLevel,
+ Uint32 DstSlice,
+ Uint32 DstX,
+ Uint32 DstY,
+ Uint32 DstZ ) = 0;
+
+ virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData ) = 0;
+
+ virtual void Unmap( IDeviceContext *pContext ) = 0;
+
+ void CreateDefaultViews();
+
+protected:
+
+ virtual void CreateViewInternal( const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView ) = 0;
+
+ // WARNING! We cannot use ITextureView here, because ITextureView has no virtual dtor!
+ std::unique_ptr<TTextureViewImpl> m_pDefaultSRV;
+ std::unique_ptr<TTextureViewImpl> m_pDefaultRTV;
+ std::unique_ptr<TTextureViewImpl> m_pDefaultDSV;
+ std::unique_ptr<TTextureViewImpl> m_pDefaultUAV;
+
+ ITextureView* GetDefaultView( TEXTURE_VIEW_TYPE ViewType )override
+ {
+ switch( ViewType )
+ {
+ case TEXTURE_VIEW_SHADER_RESOURCE: return m_pDefaultSRV.get();
+ case TEXTURE_VIEW_RENDER_TARGET: return m_pDefaultRTV.get();
+ case TEXTURE_VIEW_DEPTH_STENCIL: return m_pDefaultDSV.get();
+ case TEXTURE_VIEW_UNORDERED_ACCESS: return m_pDefaultUAV.get();
+ default: UNEXPECTED( "Unknown view type" ); return nullptr;
+ }
+ }
+
+ void CorrectTextureViewDesc( struct TextureViewDesc &ViewDesc );
+
+ // Corrects texture view format. For instance, if texture format is R32_TYPELESS,
+ // then for a depth-stencil view, the function will return D32_FLOAT, but for a shader resource
+ // view, it will return R32_FLOAT.
+ TEXTURE_FORMAT CorrectTextureViewFormat( TEXTURE_FORMAT Fmt, TEXTURE_VIEW_TYPE TexViewType );
+};
+
+
+template<class BaseInterface, class TTextureViewImpl>
+TEXTURE_FORMAT TextureBase<BaseInterface, TTextureViewImpl> :: CorrectTextureViewFormat( TEXTURE_FORMAT Fmt, TEXTURE_VIEW_TYPE TexViewType )
+{
+ // Correct texture view format for depth stencil view
+ if( TexViewType == TEXTURE_VIEW_DEPTH_STENCIL )
+ {
+ if( Fmt == TEX_FORMAT_R32_FLOAT || Fmt == TEX_FORMAT_R32_TYPELESS )
+ {
+ Fmt = TEX_FORMAT_D32_FLOAT;
+ }
+ else if( Fmt == TEX_FORMAT_R16_UNORM || Fmt == TEX_FORMAT_R16_TYPELESS )
+ {
+ Fmt = TEX_FORMAT_D16_UNORM;
+ }
+ else if( Fmt == TEX_FORMAT_R24G8_TYPELESS ||
+ Fmt == TEX_FORMAT_R24_UNORM_X8_TYPELESS ||
+ Fmt == TEX_FORMAT_X24_TYPELESS_G8_UINT )
+ {
+ Fmt = TEX_FORMAT_D24_UNORM_S8_UINT;
+ }
+ else if( Fmt == TEX_FORMAT_R32G8X24_TYPELESS ||
+ Fmt == TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS ||
+ Fmt == TEX_FORMAT_X32_TYPELESS_G8X24_UINT )
+ {
+ Fmt = TEX_FORMAT_D32_FLOAT_S8X24_UINT;
+ }
+ }
+ else
+ {
+ // Correct texture view format for SR, RT or UA views
+ if( Fmt == TEX_FORMAT_D32_FLOAT || Fmt == TEX_FORMAT_R32_TYPELESS )
+ {
+ Fmt = TEX_FORMAT_R32_FLOAT;
+ }
+ else if( Fmt == TEX_FORMAT_D16_UNORM || Fmt == TEX_FORMAT_R16_TYPELESS )
+ {
+ Fmt = TEX_FORMAT_R16_UNORM;
+ }
+ else if( Fmt == TEX_FORMAT_D24_UNORM_S8_UINT ||
+ Fmt == TEX_FORMAT_R24G8_TYPELESS )
+ {
+ Fmt = TEX_FORMAT_R24_UNORM_X8_TYPELESS;
+ }
+ else if( Fmt == TEX_FORMAT_D32_FLOAT_S8X24_UINT ||
+ Fmt == TEX_FORMAT_R32G8X24_TYPELESS )
+ {
+ Fmt = TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS;
+ }
+ }
+
+ return Fmt;
+}
+
+template<class BaseInterface, class TTextureViewImpl>
+void TextureBase<BaseInterface, TTextureViewImpl> :: CorrectTextureViewDesc(struct TextureViewDesc &ViewDesc)
+{
+#define TEX_VIEW_VALIDATION_ERROR(...) LOG_ERROR_AND_THROW( "Texture view \"", ViewDesc.Name ? ViewDesc.Name : "", "\": ", ##__VA_ARGS__ );
+
+ if( !(ViewDesc.ViewType > TEXTURE_VIEW_UNDEFINED && ViewDesc.ViewType < TEXTURE_VIEW_NUM_VIEWS) )
+ TEX_VIEW_VALIDATION_ERROR( "Texture view type is not specified" );
+
+ if( ViewDesc.MostDetailedMip + ViewDesc.NumMipLevels > this->m_Desc.MipLevels )
+ TEX_VIEW_VALIDATION_ERROR( "Most detailed mip (", ViewDesc.MostDetailedMip, ") and number of mip levels in the view (", ViewDesc.NumMipLevels, ") specify more levels than target texture has (", this->m_Desc.MipLevels, ")" );
+
+ if( ViewDesc.Format == TEX_FORMAT_UNKNOWN )
+ ViewDesc.Format = CorrectTextureViewFormat( this->m_Desc.Format, ViewDesc.ViewType );
+
+ if( ViewDesc.TextureType == TEXTURE_TYPE_UNDEFINED )
+ ViewDesc.TextureType = this->m_Desc.Type;
+
+ switch( this->m_Desc.Type )
+ {
+ case TEXTURE_TYPE_1D:
+ if( ViewDesc.TextureType != TEXTURE_TYPE_1D )
+ {
+ TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture 1D view: only Texture 1D is allowed" );
+ }
+ break;
+
+ case TEXTURE_TYPE_1D_ARRAY:
+ if( ViewDesc.TextureType != TEXTURE_TYPE_1D_ARRAY &&
+ ViewDesc.TextureType != TEXTURE_TYPE_1D )
+ {
+ TEX_VIEW_VALIDATION_ERROR( "Incorrect view type for Texture 1D Array: only Texture 1D or Texture 1D Array are allowed" );
+ }
+ break;
+
+ case TEXTURE_TYPE_2D:
+ if(ViewDesc.TextureType != TEXTURE_TYPE_2D )
+ {
+ TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture 2D view: only Texture 2D is allowed" );
+ }
+ break;
+
+ case TEXTURE_TYPE_2D_ARRAY:
+ if( ViewDesc.TextureType != TEXTURE_TYPE_2D_ARRAY &&
+ ViewDesc.TextureType != TEXTURE_TYPE_2D )
+ {
+ TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture 2D Array view: only Texture 2D or Texture 2D Array are allowed" );
+ }
+ break;
+
+ case TEXTURE_TYPE_3D:
+ if( ViewDesc.TextureType != TEXTURE_TYPE_3D )
+ {
+ TEX_VIEW_VALIDATION_ERROR( "Incorrect texture type for Texture 3D view: only Texture 3D is allowed" );
+ }
+ break;
+
+ default:
+ UNEXPECTED( "Unexpected texture type" );
+ break;
+ }
+
+ if( ViewDesc.TextureType == TEXTURE_TYPE_1D_ARRAY ||
+ ViewDesc.TextureType == TEXTURE_TYPE_2D_ARRAY )
+ {
+ if( ViewDesc.FirstArraySlice + ViewDesc.NumArraySlices > this->m_Desc.ArraySize )
+ TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstArraySlice, ") and number of slices in the view (", ViewDesc.NumArraySlices, ") specify more slices than target texture has (", this->m_Desc.ArraySize, ")" );
+ }
+ else if( ViewDesc.TextureType == TEXTURE_TYPE_3D )
+ {
+ auto MipDepth = this->m_Desc.Depth >> ViewDesc.MostDetailedMip;
+ if( ViewDesc.FirstDepthSlice + ViewDesc.NumDepthSlices > MipDepth )
+ TEX_VIEW_VALIDATION_ERROR( "First slice (", ViewDesc.FirstDepthSlice, ") and number of slices in the view (", ViewDesc.NumDepthSlices, ") specify more slices than target 3D texture mip level has (", MipDepth, ")" );
+ }
+#undef TEX_VIEW_VALIDATION_ERROR
+
+ if( ViewDesc.NumMipLevels == 0 )
+ {
+ if( ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE )
+ ViewDesc.NumMipLevels = this->m_Desc.MipLevels - ViewDesc.MostDetailedMip;
+ else
+ ViewDesc.NumMipLevels = 1;
+ }
+
+ if( ViewDesc.NumArraySlices == 0 )
+ {
+ if( ViewDesc.TextureType == TEXTURE_TYPE_1D_ARRAY ||
+ ViewDesc.TextureType == TEXTURE_TYPE_2D_ARRAY )
+ ViewDesc.NumArraySlices = this->m_Desc.ArraySize - ViewDesc.FirstArraySlice;
+ else if( ViewDesc.TextureType == TEXTURE_TYPE_3D )
+ {
+ auto MipDepth = this->m_Desc.Depth >> ViewDesc.MostDetailedMip;
+ ViewDesc.NumDepthSlices = MipDepth - ViewDesc.FirstDepthSlice;
+ }
+ else
+ ViewDesc.NumArraySlices = 1;
+ }
+
+ if( (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET) &&
+ ( ViewDesc.Format == TEX_FORMAT_R8_SNORM || ViewDesc.Format == TEX_FORMAT_RG8_SNORM || ViewDesc.Format == TEX_FORMAT_RGBA8_SNORM ||
+ ViewDesc.Format == TEX_FORMAT_R16_SNORM || ViewDesc.Format == TEX_FORMAT_RG16_SNORM || ViewDesc.Format == TEX_FORMAT_RGBA16_SNORM ) )
+ {
+ const auto *FmtName = GetTextureFormatAttribs( ViewDesc.Format ).Name;
+ LOG_WARNING_MESSAGE( FmtName, " render target view is created.\n"
+ "There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.\n"
+ "Use UNORM format instead." );
+ }
+}
+
+template<class BaseInterface, class TTextureViewImpl>
+void TextureBase<BaseInterface, TTextureViewImpl> :: CreateDefaultViews()
+{
+ if(this->m_Desc.BindFlags & BIND_SHADER_RESOURCE )
+ {
+ TextureViewDesc ViewDesc;
+ ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE;
+ ITextureView *pSRV = nullptr;
+ CreateViewInternal( ViewDesc, &pSRV, true );
+ m_pDefaultSRV.reset( static_cast<TTextureViewImpl*>(pSRV) );
+ VERIFY( m_pDefaultSRV->GetDesc().ViewType == TEXTURE_VIEW_SHADER_RESOURCE, "Unexpected view type" );
+ }
+
+ if(this->m_Desc.BindFlags & BIND_RENDER_TARGET )
+ {
+ TextureViewDesc ViewDesc;
+ ViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET;
+ ITextureView *pRTV = nullptr;
+ CreateViewInternal( ViewDesc, &pRTV, true );
+ m_pDefaultRTV.reset( static_cast<TTextureViewImpl*>(pRTV) );
+ VERIFY( m_pDefaultRTV->GetDesc().ViewType == TEXTURE_VIEW_RENDER_TARGET, "Unexpected view type" );
+ }
+
+ if(this->m_Desc.BindFlags & BIND_DEPTH_STENCIL )
+ {
+ TextureViewDesc ViewDesc;
+ ViewDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL;
+ ITextureView *pDSV = nullptr;
+ CreateViewInternal( ViewDesc, &pDSV, true );
+ m_pDefaultDSV.reset( static_cast<TTextureViewImpl*>(pDSV) );
+ VERIFY( m_pDefaultDSV->GetDesc().ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Unexpected view type" );
+ }
+
+ if(this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS )
+ {
+ TextureViewDesc ViewDesc;
+ ViewDesc.ViewType = TEXTURE_VIEW_UNORDERED_ACCESS;
+ ViewDesc.AccessFlags = UAV_ACCESS_FLAG_READ_WRITE;
+ ITextureView *pUAV = nullptr;
+ CreateViewInternal( ViewDesc, &pUAV, true );
+ m_pDefaultUAV.reset( static_cast<TTextureViewImpl*>(pUAV) );
+ VERIFY( m_pDefaultUAV->GetDesc().ViewType == TEXTURE_VIEW_UNORDERED_ACCESS, "Unexpected view type" );
+ }
+}
+
+
+template<class BaseInterface, class TTextureViewImpl>
+void TextureBase<BaseInterface, TTextureViewImpl> :: UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )
+{
+ ValidateUpdateDataParams( this->m_Desc, MipLevel, Slice, DstBox, SubresData );
+}
+
+template<class BaseInterface, class TTextureViewImpl>
+void TextureBase<BaseInterface, TTextureViewImpl> :: CopyData( IDeviceContext *pContext,
+ ITexture *pSrcTexture,
+ Uint32 SrcMipLevel,
+ Uint32 SrcSlice,
+ const Box *pSrcBox,
+ Uint32 DstMipLevel,
+ Uint32 DstSlice,
+ Uint32 DstX,
+ Uint32 DstY,
+ Uint32 DstZ )
+{
+ VERIFY( pContext, "pContext is null" );
+ VERIFY( pSrcTexture, "pSrcTexture is null" );
+ VliadateCopyTextureDataParams( pSrcTexture->GetDesc(), SrcMipLevel, SrcSlice, pSrcBox,
+ this->GetDesc(), DstMipLevel, DstSlice, DstX, DstY, DstZ );
+}
+
+template<class BaseInterface, class TTextureViewImpl>
+void TextureBase<BaseInterface, TTextureViewImpl> :: Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData )
+{
+}
+
+template<class BaseInterface, class TTextureViewImpl>
+void TextureBase<BaseInterface, TTextureViewImpl> :: Unmap( IDeviceContext *pContext )
+{
+}
+
+}
diff --git a/Graphics/GraphicsEngine/include/TextureViewBase.h b/Graphics/GraphicsEngine/include/TextureViewBase.h
new file mode 100644
index 00000000..af2c93d8
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/TextureViewBase.h
@@ -0,0 +1,90 @@
+/* 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
+/// Implementation of the Diligent::TextureViewBase template class
+
+#include "TextureView.h"
+#include "DeviceObjectBase.h"
+#include "RefCntAutoPtr.h"
+#include "GraphicsUtilities.h"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a texture view interface
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::ITextureViewD3D11 or Diligent::ITextureViewGL).
+template<class BaseInterface = ITextureView>
+class TextureViewBase : public DeviceObjectBase<BaseInterface, TextureViewDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, TextureViewDesc> TDeviceObjectBase;
+
+ TextureViewBase( IRenderDevice *pDevice,
+ const TextureViewDesc& ViewDesc,
+ class ITexture *pTexture,
+ bool bIsDefaultView ) :
+ // Default views are created as part of the texture, so we cannot not keep strong
+ // reference to the texture to avoid cyclic links. Instead, we will attach to the
+ // reference counters of the texture.
+ TDeviceObjectBase( pDevice, ViewDesc, bIsDefaultView ? pTexture : nullptr ),
+ m_pTexture( pTexture ),
+ // For non-default view, we will keep strong reference to texture
+ m_spTexture(bIsDefaultView ? nullptr : pTexture)
+ {}
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_TextureView, TDeviceObjectBase )
+
+ virtual void SetSampler( class ISampler *pSampler )
+ {
+ VERIFY( this->m_Desc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE, "Texture view \"", this->m_Desc.Name, "\": A sampler can be attached to a shader resource view only. The view type is ", GetTexViewTypeLiteralName(this->m_Desc.ViewType) );
+ m_pSampler = pSampler;
+ }
+
+ virtual ISampler* GetSampler()
+ {
+ return m_pSampler;
+ }
+
+ virtual ITexture* GetTexture()
+ {
+ return m_pTexture;
+ }
+
+protected:
+ /// Strong reference to the sampler
+ Diligent::RefCntAutoPtr<ISampler> m_pSampler;
+
+ /// Raw pointer to the texture
+ ITexture *m_pTexture;
+
+ /// Strong reference to the texture. Used for non-default views
+ /// to keep the texture alive
+ Diligent::RefCntAutoPtr<ITexture> m_spTexture;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/VertexDescriptionBase.h b/Graphics/GraphicsEngine/include/VertexDescriptionBase.h
new file mode 100644
index 00000000..fdab3db6
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/VertexDescriptionBase.h
@@ -0,0 +1,96 @@
+/* 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
+/// Implementation of the Diligent::VertexDescriptionBase template class
+
+#include "VertexDescription.h"
+#include "DeviceObjectBase.h"
+#include "GraphicsUtilities.h"
+
+namespace Diligent
+{
+
+/// Template class implementing base functionality for a vertex description object
+
+/// \tparam BaseInterface - base interface that this class will inheret
+/// (Diligent::IVertexDescriptionD3D11 or Diligent::IVertexDescriptionGL).
+template<class BaseInterface = IVertexDescription>
+class VertexDescriptionBase : public DeviceObjectBase<BaseInterface, LayoutDesc>
+{
+public:
+ typedef DeviceObjectBase<BaseInterface, LayoutDesc> TDeviceObjectBase;
+
+ /// \param pDevice - pointer to the device.
+ /// \param LayoutDesc - layout description.
+ /// \param bIsDeviceInternal - flag indicating if the vertex description is an internal device object and
+ /// must not keep a strong reference to the device.
+ VertexDescriptionBase( IRenderDevice *pDevice, const LayoutDesc &LayoutDesc, bool bIsDeviceInternal = false ) :
+ TDeviceObjectBase( pDevice, LayoutDesc, nullptr, bIsDeviceInternal),
+ m_TightStrides( MaxBufferSlots ), // The size of this array must be equal to the
+ // maximum number of buffer slots, because a layout
+ // element can refer to any input slot
+ m_LayoutElements( LayoutDesc.NumElements )
+ {
+ for( size_t Elem = 0; Elem < LayoutDesc.NumElements; ++Elem )
+ m_LayoutElements[Elem] = LayoutDesc.LayoutElements[Elem];
+ this->m_Desc.LayoutElements = m_LayoutElements.data();
+
+ // Correct description and compute offsets and tight strides
+ for( auto It = m_LayoutElements.begin(); It != m_LayoutElements.end(); ++It )
+ {
+ if( It->ValueType == VT_FLOAT32 || It->ValueType == VT_FLOAT16 )
+ It->IsNormalized = false; // Floating point values cannot be normalized
+
+ auto BuffSlot = It->BufferSlot;
+ if( BuffSlot >= m_TightStrides.size() )
+ m_TightStrides.resize( BuffSlot + 1 );
+
+ auto &CurrStride = m_TightStrides[BuffSlot];
+ if( It->RelativeOffset < CurrStride )
+ {
+ if( It->RelativeOffset == 0 )
+ It->RelativeOffset = CurrStride;
+ else
+ UNEXPECTED( "Overlapping layout elements" );
+ }
+
+ CurrStride += It->NumComponents * GetValueSize( It->ValueType );
+ }
+ }
+
+ IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_VertexDescription, TDeviceObjectBase )
+
+ virtual const Uint32* GetTightStrides()
+ {
+ return m_TightStrides.data();
+ }
+
+protected:
+ std::vector<LayoutElement> m_LayoutElements;
+ std::vector<Uint32> m_TightStrides;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/include/pch.h b/Graphics/GraphicsEngine/include/pch.h
new file mode 100644
index 00000000..c911c398
--- /dev/null
+++ b/Graphics/GraphicsEngine/include/pch.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.
+ */
+
+/// \file
+/// Precomputed header
+
+#pragma once
+
+#include <vector>
+#include <list>
+#include <set>
+#include <map>
+#include <unordered_map>
+#include <memory>
+#include <algorithm>
+#include "GraphicsTypes.h"
+#include "RefCntAutoPtr.h"
+#include "Errors.h"
+#include "DebugUtilities.h"
+#include "RenderDeviceBase.h"
+#include "DeviceContextBase.h" \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/interface/BlendState.h b/Graphics/GraphicsEngine/interface/BlendState.h
new file mode 100644
index 00000000..3673bfae
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/BlendState.h
@@ -0,0 +1,344 @@
+/* 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
+/// Definition of the Diligent::IBlendState interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+/// IBlendState interface unique identifier
+// {81CFB7AC-6B9F-45FA-ACE2-CC6A9EDE4E75}
+static const Diligent::INTERFACE_ID IID_BlendState =
+{ 0x81cfb7ac, 0x6b9f, 0x45fa, { 0xac, 0xe2, 0xcc, 0x6a, 0x9e, 0xde, 0x4e, 0x75 } };
+
+
+/// Blend factors
+
+/// [D3D11_BLEND]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476086(v=vs.85).aspx
+/// [glBlendFuncSeparate]: https://www.opengl.org/wiki/GLAPI/glBlendFuncSeparate
+/// This enumeration defines blend factors for alpha-blending.
+/// It generatlly mirrows [D3D11_BLEND][] enumeration and is used by RenderTargetBlendDesc structure
+/// to define source and destination blend factors for color and alpha channels.
+/// \sa [D3D11_BLEND on MSDN][D3D11_BLEND], [glBlendFuncSeparate on OpenGL.org][glBlendFuncSeparate]
+enum BLEND_FACTOR : Int32
+{
+ /// Undefined blend factor
+ BLEND_FACTOR_UNDEFINED = 0,
+
+ /// The blend factor is zero.\n
+ /// D3D11 counterpart: D3D11_BLEND_ZERO. OpenGL counterpart: GL_ZERO.
+ BLEND_FACTOR_ZERO,
+
+ /// The blend factor is one.\n
+ /// D3D11 counterpart: D3D11_BLEND_ONE. OpenGL counterpart: GL_ONE.
+ BLEND_FACTOR_ONE,
+
+ /// The blend factor is RGB data from a pixel shader.\n
+ /// D3D11 counterpart: D3D11_BLEND_SRC_COLOR. OpenGL counterpart: GL_SRC_COLOR.
+ BLEND_FACTOR_SRC_COLOR,
+
+ /// The blend factor is 1-RGB, where RGB is the data from a pixel shader.\n
+ /// D3D11 counterpart: D3D11_BLEND_INV_SRC_COLOR. OpenGL counterpart: GL_ONE_MINUS_SRC_COLOR.
+ BLEND_FACTOR_INV_SRC_COLOR,
+
+ /// The blend factor is alpha (A) data from a pixel shader.\n
+ /// D3D11 counterpart: D3D11_BLEND_SRC_ALPHA. OpenGL counterpart: GL_SRC_ALPHA.
+ BLEND_FACTOR_SRC_ALPHA,
+
+ /// The blend factor is 1-A, where A is alpha data from a pixel shader.\n
+ /// D3D11 counterpart: D3D11_BLEND_INV_SRC_ALPHA. OpenGL counterpart: GL_ONE_MINUS_SRC_ALPHA.
+ BLEND_FACTOR_INV_SRC_ALPHA,
+
+ /// The blend factor is alpha (A) data from a render target.\n
+ /// D3D11 counterpart: D3D11_BLEND_DEST_ALPHA. OpenGL counterpart: GL_DST_ALPHA.
+ BLEND_FACTOR_DEST_ALPHA,
+
+ /// The blend factor is 1-A, where A is alpha data from a render target.\n
+ /// D3D11 counterpart: D3D11_BLEND_INV_DEST_ALPHA. OpenGL counterpart: GL_ONE_MINUS_DST_ALPHA.
+ BLEND_FACTOR_INV_DEST_ALPHA,
+
+ /// The blend factor is RGB data from a render target.\n
+ /// D3D11 counterpart: D3D11_BLEND_DEST_COLOR. OpenGL counterpart: GL_DST_COLOR.
+ BLEND_FACTOR_DEST_COLOR,
+
+ /// The blend factor is 1-RGB, where RGB is the data from a render target.\n
+ /// D3D11 counterpart: D3D11_BLEND_INV_DEST_COLOR. OpenGL counterpart: GL_ONE_MINUS_DST_COLOR.
+ BLEND_FACTOR_INV_DEST_COLOR,
+
+ /// The blend factor is (f,f,f,1), where f = min(As, 1-Ad),
+ /// As is alpha data from a pixel shader, and Ad is alpha data from a render target.\n
+ /// D3D11 counterpart: D3D11_BLEND_SRC_ALPHA_SAT. OpenGL counterpart: GL_SRC_ALPHA_SATURATE.
+ BLEND_FACTOR_SRC_ALPHA_SAT,
+
+ /// The blend factor is the constant blend factor set with IDeviceContext::SetBlendState().\n
+ /// D3D11 counterpart: D3D11_BLEND_BLEND_FACTOR. OpenGL counterpart: GL_CONSTANT_COLOR.
+ BLEND_FACTOR_BLEND_FACTOR,
+
+ /// The blend factor is one minus constant blend factor set with IDeviceContext::SetBlendState().\n
+ /// D3D11 counterpart: D3D11_BLEND_INV_BLEND_FACTOR. OpenGL counterpart: GL_ONE_MINUS_CONSTANT_COLOR.
+ BLEND_FACTOR_INV_BLEND_FACTOR,
+
+ /// The blend factor is the second RGB data output from a pixel shader.\n
+ /// D3D11 counterpart: D3D11_BLEND_SRC1_COLOR. OpenGL counterpart: GL_SRC1_COLOR.
+ BLEND_FACTOR_SRC1_COLOR,
+
+ /// The blend factor is 1-RGB, where RGB is the second RGB data output from a pixel shader.\n
+ /// D3D11 counterpart: D3D11_BLEND_INV_SRC1_COLOR. OpenGL counterpart: GL_ONE_MINUS_SRC1_COLOR.
+ BLEND_FACTOR_INV_SRC1_COLOR,
+
+ /// The blend factor is the second alpha (A) data output from a pixel shader.\n
+ /// D3D11 counterpart: D3D11_BLEND_SRC1_ALPHA. OpenGL counterpart: GL_SRC1_ALPHA.
+ BLEND_FACTOR_SRC1_ALPHA,
+
+ /// The blend factor is 1-A, where A is the second alpha data output from a pixel shader.\n
+ /// D3D11 counterpart: D3D11_BLEND_INV_SRC1_ALPHA. OpenGL counterpart: GL_ONE_MINUS_SRC1_ALPHA.
+ BLEND_FACTOR_INV_SRC1_ALPHA,
+
+ /// Helper value that stores the total number of blend factors in the enumeration.
+ BLEND_FACTOR_NUM_FACTORS
+};
+
+/// Blending operation
+
+/// [D3D11_BLEND_OP]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476088(v=vs.85).aspx
+/// [glBlendEquationSeparate]: https://www.opengl.org/wiki/GLAPI/glBlendEquationSeparate
+/// This enumeration describes blending operation for RGB or Alpha channels and generally mirrows
+/// [D3D11_BLEND_OP][] enum. It is used by RenderTargetBlendDesc structure to define RGB and Alpha
+/// blending operations
+/// \sa [D3D11_BLEND_OP on MSDN][D3D11_BLEND_OP], [glBlendEquationSeparate on OpenGL.org][glBlendEquationSeparate]
+enum BLEND_OPERATION : Int32
+{
+ /// Undefined blend operation
+ BLEND_OPERATION_UNDEFINED = 0,
+
+ /// Add source and destination color components.\n
+ /// D3D11 counterpart: D3D11_BLEND_OP_ADD. OpenGL counterpart: GL_FUNC_ADD.
+ BLEND_OPERATION_ADD,
+
+ /// Subtract destination color components from source color components.\n
+ /// D3D11 counterpart: D3D11_BLEND_OP_SUBTRACT. OpenGL counterpart: GL_FUNC_SUBTRACT.
+ BLEND_OPERATION_SUBTRACT,
+
+ /// Subtract source color components from destination color components.\n
+ /// D3D11 counterpart: D3D11_BLEND_OP_REV_SUBTRACT. OpenGL counterpart: GL_FUNC_REVERSE_SUBTRACT.
+ BLEND_OPERATION_REV_SUBTRACT,
+
+ /// Compute the minimum of source and destination color components.\n
+ /// D3D11 counterpart: D3D11_BLEND_OP_MIN. OpenGL counterpart: GL_MIN.
+ BLEND_OPERATION_MIN,
+
+ /// Compute the maximum of source and destination color components.\n
+ /// D3D11 counterpart: D3D11_BLEND_OP_MAX. OpenGL counterpart: GL_MAX.
+ BLEND_OPERATION_MAX,
+
+ /// Helper value that stores the total number of blend operations in the enumeration.
+ BLEND_OPERATION_NUM_OPERATIONS
+};
+
+/// Color component write flags
+
+/// These flags are used by RenderTargetBlendDesc structure to define
+/// writable components of the render target
+enum COLOR_MASK : Int32
+{
+ /// Allow data to be stored in the red component.
+ COLOR_MASK_RED = 1,
+
+ /// Allow data to be stored in the green component.
+ COLOR_MASK_GREEN = 2,
+
+ /// Allow data to be stored in the blue component.
+ COLOR_MASK_BLUE = 4,
+
+ /// Allow data to be stored in the alpha component.
+ COLOR_MASK_ALPHA = 8,
+
+ /// Allow data to be stored in all components.
+ COLOR_MASK_ALL = ( ( ( COLOR_MASK_RED | COLOR_MASK_GREEN ) | COLOR_MASK_BLUE ) | COLOR_MASK_ALPHA )
+};
+
+/// Describes a blend state for a single render target
+
+/// This structure is used by BlendStateDesc to describe
+/// blend states for render targets
+struct RenderTargetBlendDesc
+{
+ /// Enable or disable blending for this render target.
+ Bool BlendEnable;
+
+ /// Specifies the blend factor to apply to the RGB value output from the pixel shader
+ BLEND_FACTOR SrcBlend;
+
+ /// Specifies the blend factor to apply to the RGB value in the render target
+ BLEND_FACTOR DestBlend;
+
+ /// Defines how to combine the source and destination RGB values
+ /// after applying the SrcBlend and DestBlend factors.
+ BLEND_OPERATION BlendOp;
+
+ /// Specifies the blend factor to apply to the alpha value output from the pixel shader.
+ /// Blend factors that end in _COLOR are not allowed.
+ BLEND_FACTOR SrcBlendAlpha;
+
+ /// Specifies the blend factor to apply to the alpha value in the render target.
+ /// Blend factors that end in _COLOR are not allowed.
+ BLEND_FACTOR DestBlendAlpha;
+
+ /// Defines how to combine the source and destination alpha values
+ /// after applying the SrcBlendAlpha and DestBlendAlpha factors.
+ BLEND_OPERATION BlendOpAlpha;
+
+ /// Render target write mask
+ Uint32 RenderTargetWriteMask;
+
+ /// Constructor initializes structure members with default values
+
+ /// Member | Default value
+ /// ----------------------|--------------
+ /// BlendEnable | False
+ /// SrcBlend | BLEND_FACTOR_ONE
+ /// DestBlend | BLEND_FACTOR_ZERO
+ /// BlendOp | BLEND_OPERATION_ADD
+ /// SrcBlendAlpha | BLEND_FACTOR_ONE
+ /// DestBlendAlpha | BLEND_FACTOR_ZERO
+ /// BlendOpAlpha | BLEND_OPERATION_ADD
+ /// RenderTargetWriteMask | COLOR_MASK_ALL
+ RenderTargetBlendDesc() :
+ BlendEnable ( False ),
+ SrcBlend ( BLEND_FACTOR_ONE ),
+ DestBlend ( BLEND_FACTOR_ZERO ),
+ BlendOp ( BLEND_OPERATION_ADD ),
+ SrcBlendAlpha ( BLEND_FACTOR_ONE ),
+ DestBlendAlpha ( BLEND_FACTOR_ZERO ),
+ BlendOpAlpha ( BLEND_OPERATION_ADD ),
+ RenderTargetWriteMask( COLOR_MASK_ALL )
+ {}
+
+
+ /// Comparison operator tests if two structures are equivalent
+
+ /// \param [in] rhs - reference to the structure to perform comparison with
+ /// \return
+ /// - True if all members of the two structures are equal.
+ /// - False otherwise
+ bool operator == (const RenderTargetBlendDesc& rhs)const
+ {
+ return BlendEnable == rhs.BlendEnable &&
+ SrcBlend == rhs.SrcBlend &&
+ DestBlend == rhs.DestBlend &&
+ BlendOp == rhs.BlendOp &&
+ SrcBlendAlpha == rhs.SrcBlendAlpha &&
+ DestBlendAlpha == rhs.DestBlendAlpha &&
+ BlendOpAlpha == rhs.BlendOpAlpha &&
+ RenderTargetWriteMask == rhs.RenderTargetWriteMask;
+ }
+};
+
+/// Blend state description
+
+/// This structure describes the blend state which is used in a call to
+/// IRenderDevice::CreateBlendState() to create a blend state object
+struct BlendStateDesc : DeviceObjectAttribs
+{
+ /// Specifies whether to use alpha-to-coverage as a multisampling technique
+ /// when setting a pixel to a render target. Default value: False.
+ Bool AlphaToCoverageEnable;
+
+ /// Specifies whether to enable independent blending in simultaneous render targets.
+ /// If set to False, only RenderTargets[0] is used. Default value: False.
+ Bool IndependentBlendEnable;
+
+ /// Constant member defining the maximum number of render targets
+ static const int MaxRenderTargets = 8;
+
+ /// An array of RenderTargetBlendDesc structures that describe the blend
+ /// states for render targets
+ RenderTargetBlendDesc RenderTargets[MaxRenderTargets];
+
+ /// Constructor initializes structure members with default values
+
+ /// Member | Default value
+ /// ----------------------|--------------
+ /// AlphaToCoverageEnable | False
+ /// IndependentBlendEnable| False
+ ///
+ /// Members of RenderTargets[] are initialized with default values by
+ /// RenderTargetBlendDesc::RenderTargetBlendDesc()
+ BlendStateDesc() :
+ AlphaToCoverageEnable(False),
+ IndependentBlendEnable(False)
+ {
+ }
+
+ /// Comparison operator tests if two structures are equivalent
+
+ /// \param [in] RHS - reference to the structure to perform comparison with
+ /// \return
+ /// - True if all members are of the two structures equal.
+ /// \note The operator performs *bitwise comparison* of the two structures.
+ /// That is if for instance both structures have IndependentBlendEnable set to False,
+ /// but differ in render target other than 0, the operator will return False
+ /// even though the two blend states created from these structures will be identical.
+ /// - False otherwise
+ /// \remarks
+ /// The operator ignores DeviceObjectAttribs::Name field as it does not affect the blend state.
+ bool operator == (const BlendStateDesc& RHS)const
+ {
+ bool bRTsEqual = true;
+ for( int i = 0; i < MaxRenderTargets; ++i )
+ if( !(RenderTargets[i] == RHS.RenderTargets[i]) )
+ {
+ bRTsEqual = false;
+ break;
+ }
+
+ return bRTsEqual &&
+ // Name is primarily used for debug purposes and does not affect the state.
+ // It is ignored in comparison operation.
+ // strcmp(Name, RHS.Name) == 0 &&
+ AlphaToCoverageEnable == RHS.AlphaToCoverageEnable &&
+ IndependentBlendEnable== RHS.IndependentBlendEnable;
+ }
+};
+
+/// Blend state interface
+
+/// The interface holds the blending state that can be bound to the pipeline by a call
+/// to IDeviceContext::SetBlendState(). To create a blend state, call
+/// IRenderDevice::CreateBlendState().
+class IBlendState : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details.
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the blend state description used to create the object
+ virtual const BlendStateDesc& GetDesc()const = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/Buffer.h b/Graphics/GraphicsEngine/interface/Buffer.h
new file mode 100644
index 00000000..45dc21bc
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/Buffer.h
@@ -0,0 +1,234 @@
+/* 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 Diligent::IBuffer interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+// {EC47EAD3-A2C4-44F2-81C5-5248D14F10E4}
+static const Diligent::INTERFACE_ID IID_Buffer =
+{ 0xec47ead3, 0xa2c4, 0x44f2, { 0x81, 0xc5, 0x52, 0x48, 0xd1, 0x4f, 0x10, 0xe4 } };
+
+/// Describes the buffer access mode.
+
+/// This enumeration is used by BufferDesc structure.
+enum BUFFER_MODE : Int32
+{
+ /// Undefined mode.
+ BUFFER_MODE_UNDEFINED = 0,
+
+ /// Formated buffer.
+ BUFFER_MODE_FORMATED,
+
+ /// Structured buffer.
+ BUFFER_MODE_STRUCTURED,
+
+ /// Helper value storing the total number of modes in the enumeration.
+ BUFFER_MODE_NUM_MODES
+};
+
+/// Buffer description
+struct BufferDesc : DeviceObjectAttribs
+{
+ /// Size of the buffer, in bytes. For a uniform buffer, this must be multiple of 16.
+ Uint32 uiSizeInBytes;
+
+ /// Buffer bind flags, see Diligent::BIND_FLAGS for details
+
+ /// The following bind flags are allowed:
+ /// Diligent::BIND_VERTEX_BUFFER, Diligent::BIND_INDEX_BUFFER, Diligent::BIND_UNIFORM_BUFFER,
+ /// Diligent::BIND_SHADER_RESOURCE, Diligent::BIND_STREAM_OUTPUT, Diligent::BIND_UNORDERED_ACCESS,
+ /// Diligent::BIND_INDIRECT_DRAW_ARGS
+ Uint32 BindFlags;
+
+ /// Buffer usage, see Diligent::USAGE for details
+ USAGE Usage;
+
+ /// CPU access flags or 0 if no CPU access is allowed,
+ /// see Diligent::CPU_ACCESS_FLAG for details.
+ Uint32 CPUAccessFlags;
+
+ /// Buffer mode
+ BUFFER_MODE Mode;
+
+ /// Buffer format description
+ struct BufferFormat
+ {
+ /// Type of components. For a formatted buffer, this value cannot be VT_UNDEFINED
+ VALUE_TYPE ValueType;
+
+ /// Number of components. Allowed values: 1, 2, 3, 4.
+ /// For a formatted buffer, this value cannot be 0
+ Uint32 NumComponents;
+
+ /// For signed and unsigned integer value types
+ /// (VT_INT8, VT_INT16, VT_INT32, VT_UINT8, VT_UINT16, VT_UINT32)
+ /// indicates if the value should be normalized to [-1,+1] or
+ /// [0, 1] range respectively. For floating point types
+ /// (VT_FLOAT16 and VT_FLOAT32), this member is ignored.
+ Bool IsNormalized;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// --------------------|--------------
+ /// ValueType | VT_UNDEFINED
+ /// NumComponents | 0
+ /// IsNormalized | True
+ BufferFormat() :
+ ValueType( VT_UNDEFINED ),
+ NumComponents( 0 ),
+ IsNormalized(True)
+ {}
+ };
+
+ /// Buffer format
+
+ /// For a formatted buffer (BufferDesc::Mode equals Diligent::BUFFER_MODE_FORMATED), this member describes the
+ /// buffer format, see BufferFormat. Ignored otherwise.
+ BufferFormat Format;
+
+ /// Buffer element stride, in bytes. For a structured buffer (BufferDesc::Mode
+ /// equals Diligent::BUFFER_MODE_STRUCTURED), this member cannot be zero. For a formatted buffer
+ /// (BufferDesc::Mode equals Diligent::BUFFER_MODE_FORMATED), this member can either specify the stride, or
+ /// be 0. In the latter case, the stride is computed automatically based
+ /// on the format size and assuming that elements are densely packed.
+ Uint32 ElementByteStride;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// --------------------|--------------
+ /// uiSizeInBytes | 0
+ /// BindFlags | 0
+ /// Usage | USAGE_DEFAULT
+ /// CPUAccessFlags | 0
+ /// Mode | BUFFER_MODE_UNDEFINED
+ /// ElementByteStride | 0
+ /// Members of BufferDesc::Format are initialized with default values by BufferFormat::BufferFormat()
+ BufferDesc() :
+ uiSizeInBytes(0),
+ BindFlags(0),
+ Usage(USAGE_DEFAULT),
+ CPUAccessFlags(0),
+ Mode( BUFFER_MODE_UNDEFINED ),
+ ElementByteStride(0)
+ {}
+};
+
+/// Describes the buffer initial data
+struct BufferData
+{
+ /// Pointer to the data
+ PVoid pData;
+
+ /// Data size, in bytes
+ Uint32 DataSize;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// --------------------|--------------
+ /// pData | nullptr
+ /// DataSize | 0
+ BufferData() :
+ pData(nullptr),
+ DataSize(0)
+ {}
+};
+
+/// Buffer interface
+
+/// Defines the methods to manipulate a buffer object
+class IBuffer : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the buffer description used to create the object
+ virtual const BufferDesc& GetDesc()const = 0;
+
+ /// Updates the data in the buffer
+
+ /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
+ /// \param [in] Offset - Offset in bytes from the beginning of the buffer to the update region.
+ /// \param [in] Size - Size in bytes of the data region to update.
+ /// \param [in] pData - Pointer to the data to store in the buffer.
+ virtual void UpdateData( class IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData) = 0;
+
+ /// Copies the data from other buffer
+
+ /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
+ /// \param [in] pSrcBuffer - Source buffer to copy data from.
+ /// \param [in] SrcOffset - Offset in bytes from the beginning of the source buffer to the beginning of data to copy.
+ /// \param [in] DstOffset - Offset in bytes from the beginning of the destination buffer to the beginning
+ /// of the destination region.
+ /// \param [in] Size - Size in bytes of data to copy.
+ virtual void CopyData( IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size ) = 0;
+
+ /// Maps the buffer
+
+ /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
+ /// \param [in] MapType - Type of the map operation. See Diligent::MAP_TYPE.
+ /// \param [in] MapFlags - Special map flags. See Diligent::MAP_FLAGS.
+ /// \param [out] pMappedData - Reference to the void pointer to store the address of the mapped region.
+ virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData ) = 0;
+
+ /// Unmaps the previously mapped buffer
+ /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
+ virtual void Unmap( IDeviceContext *pContext ) = 0;
+
+ /// Creates a new buffer view
+
+ /// \param [in] ViewDesc - View description. See Diligent::BufferViewDesc for details.
+ /// \param [out] ppView - Address of the memory location where the pointer to the view interface will be written to.
+ ///
+ /// \remarks To create a view addressing the entire buffer, set only BufferViewDesc::ViewType member
+ /// of the ViewDesc structure and leave all other members in their default values.\n
+ /// Buffer view will contain strong reference to the buffer, so the buffer will not be destroyed
+ /// until all views are released.\n
+ /// The function calls AddRef() for the created interface, so it must be released by
+ /// a call to Release() when it is no longer needed.
+ virtual void CreateView( const struct BufferViewDesc &ViewDesc, class IBufferView **ppView ) = 0;
+
+ /// Returns the pointer to the default view.
+
+ /// \param [in] ViewType - Type of the requested view. See Diligent::BUFFER_VIEW_TYPE.
+ /// \return Pointer to the interface
+ ///
+ /// \note The function does not increase the reference counter for the returned interface, so
+ /// Release() must *NOT* be called.
+ virtual IBufferView* GetDefaultView( BUFFER_VIEW_TYPE ViewType ) = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/BufferView.h b/Graphics/GraphicsEngine/interface/BufferView.h
new file mode 100644
index 00000000..93d52887
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/BufferView.h
@@ -0,0 +1,107 @@
+/* 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
+/// Definition of the Diligent::IBufferView interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+// {E2E83490-E9D2-495B-9A83-ABB413A38B07}
+static const Diligent::INTERFACE_ID IID_BufferView =
+{ 0xe2e83490, 0xe9d2, 0x495b, { 0x9a, 0x83, 0xab, 0xb4, 0x13, 0xa3, 0x8b, 0x7 } };
+
+/// Buffer view description
+struct BufferViewDesc : DeviceObjectAttribs
+{
+ /// View type. See Diligent::BUFFER_VIEW_TYPE for details.
+ BUFFER_VIEW_TYPE ViewType;
+
+ /// Offset in bytes from the beginnig of the buffer to the start of the
+ /// buffer region referenced by the view
+ Uint32 ByteOffset;
+
+ /// Size in bytes of the referenced buffer region
+ Uint32 ByteWidth;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// --------------------|--------------
+ /// ViewType | BUFFER_VIEW_UNDEFINED
+ /// ByteOffset | 0
+ /// ByteWidth | 0
+ BufferViewDesc() :
+ ViewType( BUFFER_VIEW_UNDEFINED ),
+ ByteOffset(0),
+ ByteWidth(0)
+ {
+ }
+
+ /// Comparison operator tests if two structures are equivalent
+
+ /// \param [in] RHS - reference to the structure to perform comparison with
+ /// \return
+ /// - True if all members of the two structures are equal.
+ /// - False otherwise
+ /// \remarks
+ /// The operator ignores DeviceObjectAttribs::Name field.
+ bool operator == (const BufferViewDesc& RHS)const
+ {
+ // Name is primarily used for debug purposes and does not affect the view.
+ // It is ignored in comparison operation.
+ return //strcmp(Name, RHS.Name) == 0 &&
+ ViewType == RHS.ViewType &&
+ ByteOffset== RHS.ByteOffset &&
+ ByteWidth == RHS.ByteWidth;
+ }
+};
+
+/// Buffer view interface
+
+/// To create a buffer view, call IBuffer::CreateView().
+/// \remarks
+/// Buffer view holds strong references to the buffer. The buffer
+/// will not be destroyed until all views are released.
+class IBufferView : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the buffer view description used to create the object
+ virtual const BufferViewDesc& GetDesc()const = 0;
+
+ /// Returns pointer to the referenced buffer object.
+
+ /// The method does *NOT* call AddRef() on the returned interface,
+ /// so Release() must not be called.
+ virtual IBuffer* GetBuffer() = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/Constants.h b/Graphics/GraphicsEngine/interface/Constants.h
new file mode 100644
index 00000000..50d9d427
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/Constants.h
@@ -0,0 +1,36 @@
+/* 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
+/// Definition of the engine constants
+
+namespace Diligent
+{
+ /// Maximum number of input buffer slots.
+ static const Uint32 MaxBufferSlots = 32;
+
+ /// Maximum number of simultaneous render targets.
+ static const Uint32 MaxRenderTargets = 8;
+}
diff --git a/Graphics/GraphicsEngine/interface/DepthStencilState.h b/Graphics/GraphicsEngine/interface/DepthStencilState.h
new file mode 100644
index 00000000..75347935
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/DepthStencilState.h
@@ -0,0 +1,238 @@
+/* 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
+/// Definition of the Diligent::IDepthStencilState interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+// {51C3A67F-FADD-411A-BA36-BDE9EE29722B}
+static const Diligent::INTERFACE_ID IID_DepthStencilState =
+{ 0x51c3a67f, 0xfadd, 0x411a, { 0xba, 0x36, 0xbd, 0xe9, 0xee, 0x29, 0x72, 0x2b } };
+
+/// Stencil operation
+
+/// [D3D11_STENCIL_OP]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476219(v=vs.85).aspx
+/// This enumeration describes the stencil operation and generally mirrows
+/// [D3D11_STENCIL_OP][] enumeration.
+/// It is used by Diligent::StencilOpDesc structure to describe the stencil fail, depth fail
+/// and stencil pass operations
+enum STENCIL_OP : Int32
+{
+ /// Undefined operation.
+ STENCIL_OP_UNDEFINED = 0,
+
+ /// Keep the existing stencil data.\n
+ /// D3D11 Counterpart: D3D11_STENCIL_OP_KEEP. OpenGL counterpart: GL_KEEP.
+ STENCIL_OP_KEEP = 1,
+
+ /// Set the stencil data to 0.\n
+ /// D3D11 Counterpart: D3D11_STENCIL_OP_ZERO. OpenGL counterpart: GL_ZERO.
+ STENCIL_OP_ZERO = 2,
+
+ /// Set the stencil data to the reference value set by calling IDeviceContext::SetDepthStencilState().\n
+ /// D3D11 Counterpart: D3D11_STENCIL_OP_REPLACE. OpenGL counterpart: GL_REPLACE.
+ STENCIL_OP_REPLACE = 3,
+
+ /// Increment the current stencil value, and clamp to the maximum representable unsigned value.\n
+ /// D3D11 Counterpart: D3D11_STENCIL_OP_INCR_SAT. OpenGL counterpart: GL_INCR.
+ STENCIL_OP_INCR_SAT = 4,
+
+ /// Decrement the current stencil value, and clamp to 0.\n
+ /// D3D11 Counterpart: D3D11_STENCIL_OP_DECR_SAT. OpenGL counterpart: GL_DECR.
+ STENCIL_OP_DECR_SAT = 5,
+
+ /// Bitwise invert the current stencil buffer value.\n
+ /// D3D11 Counterpart: D3D11_STENCIL_OP_INVERT. OpenGL counterpart: GL_INVERT.
+ STENCIL_OP_INVERT = 6,
+
+ /// Increment the current stencil value, and wrap the value to zero when incrementing
+ /// the maximum representable unsigned value. \n
+ /// D3D11 Counterpart: D3D11_STENCIL_OP_INCR. OpenGL counterpart: GL_INCR_WRAP.
+ STENCIL_OP_INCR_WRAP = 7,
+
+ /// Decrement the current stencil value, and wrap the value to the maximum representable
+ /// unsigned value when decrementing a value of zero.\n
+ /// D3D11 Counterpart: D3D11_STENCIL_OP_DECR. OpenGL counterpart: GL_DECR_WRAP.
+ STENCIL_OP_DECR_WRAP = 8,
+
+ /// Helper value that stores the total number of stencil operations in the enumeration.
+ STENCIL_OP_NUM_OPS
+};
+
+/// Describes stencil operations that are performed based on the results of depth test.
+
+/// [D3D11_DEPTH_STENCILOP_DESC]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476109(v=vs.85).aspx
+/// The structure generally mirrows [D3D11_DEPTH_STENCILOP_DESC][] structure.
+/// It is used by Diligent::DepthStencilStateDesc structure to describe the stencil
+/// operations for the front and back facing polygons.
+struct StencilOpDesc
+{
+ /// The stencil operation to perform when stencil testing fails.
+ STENCIL_OP StencilFailOp;
+
+ /// The stencil operation to perform when stencil testing passes and depth testing fails.
+ STENCIL_OP StencilDepthFailOp;
+
+ /// The stencil operation to perform when stencil testing and depth testing both pass.
+ STENCIL_OP StencilPassOp;
+
+ /// A function that compares stencil data against existing stencil data. See
+ /// Diligent::COMPARISON_FUNCTION.
+ COMPARISON_FUNCTION StencilFunc;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// --------------------|--------------
+ /// StencilFailOp | STENCIL_OP_KEEP
+ /// StencilDepthFailOp | STENCIL_OP_KEEP
+ /// StencilPassOp | STENCIL_OP_KEEP
+ /// StencilFunc | COMPARISON_FUNC_ALWAYS
+ StencilOpDesc() :
+ StencilFailOp ( STENCIL_OP_KEEP ),
+ StencilDepthFailOp( STENCIL_OP_KEEP ),
+ StencilPassOp ( STENCIL_OP_KEEP ),
+ StencilFunc ( COMPARISON_FUNC_ALWAYS )
+ {}
+
+ /// Tests if two structures are equivalent
+
+ /// \param [in] rhs - reference to the structure to perform comparison with
+ /// \return
+ /// - True if all members of the two structures are equal.
+ /// - False otherwise
+ bool operator == (const StencilOpDesc& rhs)const
+ {
+ return StencilFailOp == rhs.StencilFailOp &&
+ StencilDepthFailOp == rhs.StencilDepthFailOp &&
+ StencilPassOp == rhs.StencilPassOp &&
+ StencilFunc == rhs.StencilFunc;
+ }
+};
+
+/// Depth stencil state description
+
+/// [D3D11_DEPTH_STENCIL_DESC]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476110(v=vs.85).aspx
+/// This structure describes the depth stencil state which is used in a call to
+/// IRenderDevice::CreateDepthStencilState() and generally mirrows [D3D11_DEPTH_STENCIL_DESC][]
+/// structure.
+struct DepthStencilStateDesc : DeviceObjectAttribs
+{
+ /// Enable depth-stencil operations. When it is set to False,
+ /// depth test always passes, depth writes are disabled,
+ /// and no stencil operations are performed
+ Bool DepthEnable;
+
+ /// Enable or disable writes to a depth buffer
+ Bool DepthWriteEnable;
+
+ /// A function that compares depth data against existing depth data.
+ /// See Diligent::COMPARISON_FUNCTION for details.
+ COMPARISON_FUNCTION DepthFunc;
+
+ /// Enable stencil opertaions.
+ Bool StencilEnable;
+
+ /// Identify which bits of the depth-stencil buffer are accessed when reading stencil data.
+ Uint8 StencilReadMask;
+
+ /// Identify which bits of the depth-stencil buffer are accessed when writing stencil data.
+ Uint8 StencilWriteMask;
+
+ /// Identify stencil operations for the front-facing triangles, see Diligent::StencilOpDesc.
+ StencilOpDesc FrontFace;
+
+ /// Identify stencil operations for the back-facing triangles, see Diligent::StencilOpDesc.
+ StencilOpDesc BackFace;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// --------------------|--------------
+ /// DepthEnable | True
+ /// DepthWriteEnable | True
+ /// DepthFunc | COMPARISON_FUNC_LESS
+ /// StencilEnable | False
+ /// StencilReadMask | 0xFF
+ /// StencilWriteMask | 0xFF
+ ///
+ /// Members of FrontFace and BackFace
+ /// are initialized by StencilOpDesc::StencilOpDesc()
+ DepthStencilStateDesc() :
+ DepthEnable ( True ),
+ DepthWriteEnable( True ),
+ DepthFunc ( COMPARISON_FUNC_LESS ),
+ StencilEnable ( False ),
+ StencilReadMask ( 0xFF ),
+ StencilWriteMask( 0xFF )
+ {}
+
+ /// Tests if two structures are equivalent
+
+ /// \param [in] rhs - reference to the structure to perform comparison with
+ /// \return
+ /// - True if all members of the two structures are equal.
+ /// - False otherwise
+ /// \remarks
+ /// The operator ignores DeviceObjectAttribs::Name field as it does not affect
+ /// the depth-stencil state.
+ bool operator == (const DepthStencilStateDesc& rhs)const
+ {
+ // Name is primarily used for debug purposes and does not affect the state.
+ // It is ignored in comparison operation.
+ return // strcmp(Name, rhs.Name) == 0 &&
+ DepthEnable == rhs.DepthEnable &&
+ DepthWriteEnable == rhs.DepthWriteEnable &&
+ DepthFunc == rhs.DepthFunc &&
+ StencilEnable == rhs.StencilEnable &&
+ StencilReadMask == rhs.StencilReadMask &&
+ StencilWriteMask == rhs.StencilWriteMask &&
+ FrontFace == rhs.FrontFace &&
+ BackFace == rhs.BackFace;
+ }
+};
+
+/// Depth stencil state interface
+
+/// The interface holds the depth-stencil state that can be bound to the pipeline by a call
+/// to IDeviceContext::SetDepthStencilState(). To create a depth-stencil state, call
+/// IRenderDevice::CreateDepthStencilState().
+class IDepthStencilState : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the depth stencil state description used to create the object
+ virtual const DepthStencilStateDesc& GetDesc()const = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h
new file mode 100644
index 00000000..3d8284ed
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/DeviceCaps.h
@@ -0,0 +1,129 @@
+/* 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
+/// Definition of the device capabilities
+
+#include "GraphicsTypes.h"
+
+namespace Diligent
+{
+ /// Device type
+ enum class DeviceType : Int32
+ {
+ Undefined = 0, ///< Undefined device
+ DirectX, ///< DirectX device
+ OpenGL, ///< OpenGL device
+ OpenGLES ///< OpenGLES device
+ };
+
+ /// Texture sampler capabilities
+ struct SamplerCaps
+ {
+ /// Indicates if device supports border texture addressing mode
+ Bool bBorderSamplingModeSupported;
+
+ /// Indicates if device supports anisotrpoic filtering
+ Bool bAnisotropicFilteringSupported;
+
+ /// Indicates if device supports MIP load bias
+ Bool bLODBiasSupported;
+
+ /// Initializes the structure members with default values
+ SamplerCaps() :
+ bBorderSamplingModeSupported( True ),
+ bAnisotropicFilteringSupported( True ),
+ bLODBiasSupported( True )
+ {}
+ };
+
+ /// Texture capabilities
+ struct TextureCaps
+ {
+ /// Indicates if device supports 1D textures
+ Bool bTexture1DSupported;
+
+ /// Indicates if device supports 1D texture arrays
+ Bool bTexture1DArraySupported;
+
+ /// Indicates if device supports 2D multisampled textures
+ Bool bTexture2DMSSupported;
+
+ /// Indicates if device supports 2D multisampled texture arrays
+ Bool bTexture2DMSArraySupported;
+
+ /// Indicates if device supports texture views
+ bool bTextureViewSupported;
+
+ /// Initializes the structure members with default values
+ TextureCaps():
+ bTexture1DSupported( True ),
+ bTexture1DArraySupported( True ),
+ bTexture2DMSSupported( True ),
+ bTexture2DMSArraySupported( True ),
+ bTextureViewSupported( True )
+ {}
+ };
+
+ /// Device capabilities
+ struct DeviceCaps
+ {
+ /// Device type. See Diligent::DeviceType.
+ DeviceType DevType;
+
+ /// Major API revision. For instance, for D3D11.2 this value would be 11,
+ /// and for OpenGL4.3 this value would be 4.
+ Int32 MajorVersion;
+
+ /// Major API revision. For instance, for D3D11.2 this value would be 2,
+ /// and for OpenGL4.3 this value would be 3.
+ Int32 MinorVersion;
+
+ /// Indicates if device supports separable programs
+ Bool bSeparableProgramSupported;
+
+ /// Indicates if device supports indirect draw commands
+ Bool bIndirectRenderingSupported;
+
+ /// Indicates if device supports wireframe fill mode
+ Bool bWireframeFillSupported;
+
+ /// Texture sampling capabilities. See Diligent::SamplerCaps.
+ SamplerCaps SamCaps;
+
+ /// Texture capabilities. See Diligent::TextureCaps.
+ TextureCaps TexCaps;
+
+ /// Initializes the structure members with default values
+ DeviceCaps() :
+ DevType( DeviceType::Undefined ),
+ MajorVersion( 0 ),
+ MinorVersion( 0 ),
+ bSeparableProgramSupported( True ),
+ bIndirectRenderingSupported( True ),
+ bWireframeFillSupported( True )
+ {}
+ };
+}
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
new file mode 100644
index 00000000..c1998091
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -0,0 +1,510 @@
+/* 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
+/// Definition of the Diligent::IDeviceContext interface and related data structures
+
+#include "Object.h"
+#include "DeviceCaps.h"
+#include "Constants.h"
+#include "Buffer.h"
+#include "VertexDescription.h"
+#include "Shader.h"
+#include "Texture.h"
+#include "Sampler.h"
+#include "ResourceMapping.h"
+#include "TextureView.h"
+#include "BufferView.h"
+#include "DepthStencilState.h"
+#include "BlendState.h"
+
+namespace Diligent
+{
+
+// {DC92711B-A1BE-4319-B2BD-C662D1CC19E4}
+static const Diligent::INTERFACE_ID IID_DeviceContext =
+{ 0xdc92711b, 0xa1be, 0x4319, { 0xb2, 0xbd, 0xc6, 0x62, 0xd1, 0xcc, 0x19, 0xe4 } };
+
+/// Input primitive topology.
+
+/// This enumeration is used by DrawAttribs structure to define input primitive topology.
+enum PRIMITIVE_TOPOLOGY : Int32
+{
+ /// Undefined topology
+ PRIMITIVE_TOPOLOGY_UNDEFINED = 0,
+
+ /// Interpret the vertex data as a list of triangles.\n
+ /// D3D11 counterpart: D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST. OpenGL counterpart: GL_TRIANGLES.
+ PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
+
+ /// Interpret the vertex data as a triangle strip.\n
+ /// D3D11 counterpart: D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP. OpenGL counterpart: GL_TRIANGLE_STRIP.
+ PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
+
+ /// Interpret the vertex data as a list of points.\n
+ /// D3D11 counterpart: D3D11_PRIMITIVE_TOPOLOGY_POINTLIST. OpenGL counterpart: GL_POINTS.
+ PRIMITIVE_TOPOLOGY_POINT_LIST,
+
+ /// Interpret the vertex data as a list of lines.\n
+ /// D3D11 counterpart: D3D11_PRIMITIVE_TOPOLOGY_LINELIST. OpenGL counterpart: GL_LINES.
+ PRIMITIVE_TOPOLOGY_LINE_LIST,
+
+ /// Helper value that stores the total number of topologies in the enumeration
+ PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES
+};
+
+/// Defines the draw command attributes
+
+/// This structure is used by IRenderDevice::Draw()
+struct DrawAttribs
+{
+ /// Input primitive topology, see Diligent::PRIMITIVE_TOPOLOGY.
+ PRIMITIVE_TOPOLOGY Topology;
+ union
+ {
+ /// For a non-indexed draw call, number of vertices to draw
+ Uint32 NumVertices;
+
+ /// For an indexed draw call, number of indices to draw
+ Uint32 NumIndices;
+ };
+ /// For an indexed draw call, type of elements in the index buffer.
+ /// Allowed values: VT_UINT16 and VT_UINT32. Ignored if DrawAttribs::IsIndexed is False.
+ VALUE_TYPE IndexType;
+
+ /// Indicates if index buffer will be used to index input vertices
+ Bool IsIndexed;
+
+ /// Number of instances to draw. If more than one instance is specified,
+ /// instanced draw call will be performed.
+ Uint32 NumInstances;
+
+ /// Indicates if indirect draw call will be performed. If set to True,
+ /// pIndirectDrawAttribs must contain valid pointer to the buffer, from which
+ /// draw attributes will be read.
+ Bool IsIndirect;
+
+ /// For indexed rendering, a constant which is added to each index before
+ /// accessing the vertex buffer.
+ Uint32 BaseVertex;
+
+ /// For indirect rendering, offset from the beginning of the buffer to the
+ /// location of draw command attributes. Ignored if DrawAttribs::IsIndirect is False.
+ Uint32 IndirectDrawArgsOffset;
+
+ union
+ {
+ /// For non-indexed rendering, LOCATION (or INDEX, but NOT the byte offset) of the
+ /// first vertex in the vertex buffer to start reading vertices from
+ Uint32 StartVertexLocation;
+
+ /// For indexed rendering, LOCATION (NOT the byte offset) of the first index in
+ /// the index buffer to start reading indices from
+ Uint32 FirstIndexLocation;
+ };
+ /// For instanced rendering, LOCATION (or INDEX, but NOT the byte offset) in the vertex
+ /// buffer to start reading instance data from
+ Uint32 FirstInstanceLocation;
+
+ /// For indirect rendering, pointer to the buffer, from which
+ /// draw attributes will be read. Ignored if DrawAttribs::IsIndirect is False.
+ IBuffer *pIndirectDrawAttribs;
+
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// ------------------------|--------------
+ /// Topology | PRIMITIVE_TOPOLOGY_UNDEFINED
+ /// NumVertices | 0
+ /// IndexType | VT_UNDEFINED
+ /// IsIndexed | False
+ /// NumInstances | 1
+ /// IsIndirect | False
+ /// BaseVertex | 0
+ /// IndirectDrawArgsOffset | 0
+ /// StartVertexLocation | 0
+ /// FirstInstanceLocation | 0
+ /// pIndirectDrawAttribs | nullptr
+ DrawAttribs() :
+ Topology(PRIMITIVE_TOPOLOGY_UNDEFINED),
+ NumVertices(0),
+ IndexType(VT_UNDEFINED),
+ IsIndexed(False),
+ NumInstances(1),
+ IsIndirect(False),
+ BaseVertex(0),
+ IndirectDrawArgsOffset(0),
+ StartVertexLocation(0),
+ FirstInstanceLocation(0),
+ pIndirectDrawAttribs(nullptr)
+ {}
+};
+
+/// Defines which parts of the depth-stencil buffer to clear.
+
+/// These flags are used by IDeviceContext::ClearDepthStencil().
+enum CLEAR_DEPTH_STENCIL_FLAGS : Int32
+{
+ CLEAR_DEPTH_FLAG = 0x01, ///< Clear depth part of the buffer
+ CLEAR_STENCIL_FLAG = 0x02 ///< Clear stencil part of the buffer
+};
+
+/// Describes dispatch command arguments.
+
+/// [Dispatch]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476405(v=vs.85).aspx
+/// This structure is used by IDeviceContext::DispatchCompute().
+/// See [ID3D11DeviceContext::Dispatch on MSDN][Dispatch] for details.
+struct DispatchComputeAttribs
+{
+ Uint32 ThreadGroupCountX; ///< Number of groups dispatched in X direction.
+ Uint32 ThreadGroupCountY; ///< Number of groups dispatched in Y direction.
+ Uint32 ThreadGroupCountZ; ///< Number of groups dispatched in Z direction.
+
+ /// Pointer to the buffer containing dispatch arguments.
+ /// If not nullptr, then indirect dispatch command is executed, and
+ /// ThreadGroupCountX, ThreadGroupCountY, and ThreadGroupCountZ are ignored
+ IBuffer *pIndirectDispatchAttribs;
+
+ /// If pIndirectDispatchAttribs is not nullptr, indicates offset from the beginning
+ /// of the buffer to the dispatch command arguments. Ignored otherwise
+ Uint32 DispatchArgsByteOffset;
+
+ /// Initializes the structure to perform non-indirect dispatch command
+
+ /// \param [in] GroupsX - Number of groups dispatched in X direction. Default value is 1.
+ /// \param [in] GroupsY - Number of groups dispatched in Y direction. Default value is 1.
+ /// \param [in] GroupsZ - Number of groups dispatched in Z direction. Default value is 1.
+ DispatchComputeAttribs( Uint32 GroupsX = 1, Uint32 GroupsY = 1, Uint32 GroupsZ = 1 ) :
+ ThreadGroupCountX( GroupsX ),
+ ThreadGroupCountY( GroupsY ),
+ ThreadGroupCountZ( GroupsZ ),
+ pIndirectDispatchAttribs(nullptr),
+ DispatchArgsByteOffset(0)
+ {}
+
+ /// Initializes the structure to perform indirect dispatch command
+
+ /// \param [in] pDispatchAttribs - Pointer to the buffer containing dispatch arguments.
+ /// \param [in] Offset - Offset from the beginning of the buffer to the dispatch command
+ /// arguments. Default value is 0.
+ DispatchComputeAttribs( IBuffer *pDispatchAttribs, Uint32 Offset = 0 ) :
+ ThreadGroupCountX( 0 ),
+ ThreadGroupCountY( 0 ),
+ ThreadGroupCountZ( 0 ),
+ pIndirectDispatchAttribs( pDispatchAttribs ),
+ DispatchArgsByteOffset( Offset )
+ {}
+};
+
+/// Defines allowed flags for IDeviceContext::SetVertexBuffers() function.
+enum SET_VERTEX_BUFFERS_FLAGS : Int32
+{
+ /// Reset the vertex buffers to only the buffers specified in this
+ /// call. All buffers previously bound to the pipeline will be unbound.
+ SET_VERTEX_BUFFERS_FLAG_RESET = 0x01
+};
+
+/// Describes the viewport.
+
+/// This structure is used by IDeviceContext::SetViewports().
+struct Viewport
+{
+ /// X coordinate of the left boundary of the viewport.
+ Float32 TopLeftX;
+
+ /// Y coordinate of the top boundary of the viewport.
+ /// When defining a viewport, DirectX convention is used:
+ /// window coordinate systems originates in the LEFT TOP corner
+ /// of the screen with Y axis pointing down.
+ Float32 TopLeftY;
+
+ /// Viewport width
+ Float32 Width;
+
+ /// Viewport Height
+ Float32 Height;
+
+ /// Minimum depth of the viewport. Ranges between 0 and 1.
+ Float32 MinDepth;
+
+ /// Maximum depth of the viewport. Ranges between 0 and 1.
+ Float32 MaxDepth;
+
+ /// Initializes the structure
+ Viewport(Float32 _TopLeftX = 0, Float32 _TopLeftY = 0,
+ Float32 _Width = 0, Float32 _Height = 0,
+ Float32 _MinDepth = 0, Float32 _MaxDepth = 1 )
+ :
+ TopLeftX( _TopLeftX ),
+ TopLeftY( _TopLeftY ),
+ Width ( _Width ),
+ Height ( _Height ),
+ MinDepth( _MinDepth ),
+ MaxDepth( _MaxDepth )
+ {}
+};
+
+/// Describes the rectangle.
+
+/// This structure is used by IDeviceContext::SetScissorRects().
+///
+/// \remarks When defining a viewport, Windows convention is used:
+/// window coordinate systems originates in the LEFT TOP corner
+/// of the screen with Y axis pointing down.
+struct Rect
+{
+ Int32 left; ///< X coordinate of the left boundary of the viewport.
+ Int32 top; ///< Y coordinate of the top boundary of the viewport.
+ Int32 right; ///< X coordinate of the right boundary of the viewport.
+ Int32 bottom;///< Y coordinate of the bottom boundary of the viewport.
+
+ /// Initializes the structure
+ Rect( Int32 _left = 0, Int32 _top = 0, Int32 _right = 0, Int32 _bottom = 0 ) :
+ left ( _left ),
+ top ( _top ),
+ right ( _right ),
+ bottom( _bottom )
+ {}
+};
+
+
+/// Device context interface
+
+/// \remarks Device context keeps strong references to all objects currently bound to
+/// the pipeline: buffers, states, samplers, shaders, etc.
+/// The context also keeps strong reference to the device and
+/// the swap chain.
+class IDeviceContext : public IObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Binds shaders to the pipeline
+
+ /// \param [in] ppShaders - Array of pointers to IShader interface.
+ /// \param [in] NumShadersToSet - Number of shaders to bind.
+ /// \remarks All shaders must be set atomically. All shaders that are not specified
+ /// in a call to SetShaders() will be unbound.\n
+ /// The device context keeps strong references to all bound shaders.
+ /// Thus a shader cannot be released until it is unbound from the context.
+ virtual void SetShaders(IShader **ppShaders, Uint32 NumShadersToSet) = 0;
+
+ /// Binds resources for all shaders bound to the pipeline
+
+ /// \param [in] pResourceMapping - Pointer to the resource mapping interface.
+ /// \param [in] Flags - Additional flags. See Diligent::BIND_SHADER_RESOURCES_FLAGS.
+ /// \remarks This function is intended to be used with older OpenGL devices that
+ /// do not support program pipelines (OpenGL4.1-, OpenGLES3.0-).\n
+ /// The function should be called AFTER all the required shaders are bound to the
+ /// context. It should also be called for every shader combination.
+ virtual void BindShaderResources( IResourceMapping *pResourceMapping, Uint32 Flags ) = 0;
+
+
+ /// Binds vertex buffers to the pipeline.
+
+ /// \param [in] StartSlot - The first input slot for binding. The first vertex buffer is
+ /// explicitly bound to the start slot; each additional vertex buffer
+ /// in the array is implicitly bound to each subsequent input slot.
+ /// \param [in] NumBuffersSet - The number of vertex buffers in the array.
+ /// \param [in] ppBuffers - A pointer to an array of vertex buffers.
+ // The vertex buffers must have been created with the Diligent::BIND_VERTEX_BUFFER flag.
+ /// \param [in] pStrides - Pointer to an array of stride values; one stride value for each buffer
+ /// in the vertex-buffer array. Each stride is the size (in bytes) of the
+ /// elements that are to be used from that vertex buffer.
+ /// If this parameter is nullptr, tight strides from the input layout
+ /// will be used for each buffer. See IVertexDescription::GetTightStrides().
+ /// \param [in] pOffsets - Pointer to an array of offset values; one offset value for each buffer
+ /// in the vertex-buffer array. Each offset is the number of bytes between
+ /// the first element of a vertex buffer and the first element that will be
+ /// used. If this parameter is nullptr, zero offsets for all buffers will be used.
+ /// \param [in] Flags - Additional flags for the operation. See Diligent::SET_VERTEX_BUFFERS_FLAGS
+ /// for a list of allowed values.
+ /// \remarks The device context keeps strong references to all bound vertex buffers.
+ /// Thus a buffer cannot be released until it is unbound from the context.\n
+ /// It is suggested to specify Diligent::SET_VERTEX_BUFFERS_FLAG_RESET flag
+ /// whenever possible. This will assure that no buffers from previous draw calls are
+ /// are bound to the pipeline.
+ virtual void SetVertexBuffers(Uint32 StartSlot,
+ Uint32 NumBuffersSet,
+ IBuffer **ppBuffers,
+ Uint32 *pStrides,
+ Uint32 *pOffsets,
+ Uint32 Flags) = 0;
+
+ /// Clears the context state.
+ virtual void ClearState() = 0;
+
+ /// Sets vertex description
+
+ /// \param [in] pVertexDesc - Pointer to IVertexDescription interface that describes
+ /// how to read data from input vertex buffers.
+ /// \remarks The device context keeps strong reference to the vertex description.
+ /// Thus a vertex description object cannot be released until it is unbound
+ /// from the context.
+ virtual void SetVertexDescription(IVertexDescription *pVertexDesc) = 0;
+
+ /// Binds an index buffer to the pipeline
+
+ /// \param [in] pIndexBuffer - Pointer to the index buffer. The buffer must have been created
+ /// with the Diligent::BIND_INDEX_BUFFER flag.
+ /// \param [in] ByteOffset - Offset from the beginning of the buffer to
+ /// the start of index data.
+ /// \remarks The device context keeps strong reference to the index buffer.
+ /// Thus an index buffer object cannot be released until it is unbound
+ /// from the context.
+ virtual void SetIndexBuffer(IBuffer *pIndexBuffer, Uint32 ByteOffset) = 0;
+
+
+ /// Sets the depth stencil state
+
+ /// \param [in] pDepthStencilState - Pointer to the IDepthStencilState interface holding the state
+ /// \param [in] StencilRef - Stencil reference value used in stencil operations.
+ /// See DepthStencilStateDesc.
+ /// \remarks The device context keeps strong reference to the bound depth-stencil state.
+ /// Thus a depth-stencil state object cannot be released until it is unbound
+ /// from the context.
+ virtual void SetDepthStencilState( IDepthStencilState *pDepthStencilState, Uint32 StencilRef = 0 ) = 0;
+
+ /// Sets the rasterizer state
+
+ /// \param [in] pRS - Pointer to the IRasterizerState interface holding the state
+ /// \remarks The device context keeps strong reference to the bound rasterizer state.
+ /// Thus a rasterizer state object cannot be released until it is unbound
+ /// from the context.
+ virtual void SetRasterizerState( IRasterizerState *pRS ) = 0;
+
+ /// Sets the blend state
+
+ /// \param [in] pBS - Pointer to the IBlendState interface holding the state
+ /// \param [in] pBlendFactors - Array of four blend factors, one for each RGBA component.
+ /// Theses factors are used if the blend state uses one of the
+ /// Diligent::BLEND_FACTOR_BLEND_FACTOR or
+ /// Diligent::BLEND_FACTOR_INV_BLEND_FACTOR
+ /// blend factors. If nullptr is provided,
+ /// default blend factors array {1,1,1,1} will be used.
+ /// \param [in] SampleMask - 32-bit sample mask that determines which samples get updated
+ /// in all the active render targets. A sample mask is always applied;
+ /// it is independent of whether multisampling is enabled, and does not
+ /// depend on whether an application uses multisample render targets.
+ /// \remarks The device context keeps strong reference to the bound blend state.
+ /// Thus a blend state object cannot be released until it is unbound
+ /// from the context.
+ virtual void SetBlendState( IBlendState *pBS, const float* pBlendFactors = nullptr, Uint32 SampleMask = 0xFFFFFFFF ) = 0;
+
+ /// Sets an array of viewports
+
+ /// \param [in] NumViewports - Number of viewports to set.
+ /// \param [in] pViewports - An array of Viewport structures describing the viewports to bind.
+ /// \param [in] RTWidth - Render target width. If 0 is provided, width of the currently bound render target will be used.
+ /// \param [in] RTHeight- Render target height. If 0 is provided, height of the currently bound render target will be used.
+ /// \remarks
+ /// DirectX and OpenGL use different window coordinate systems. In DirectX, the coordinate system origin
+ /// is in the left top corner of the screen with Y axis pointing down. In OpenGL, the origin
+ /// is in the left bottom corener of the screen with Y axis pointing up. Render target size is
+ /// required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.\n\n
+ /// All viewports must be set atomically as one operation. Any viewports not
+ /// defined by the call are disabled.\n\n
+ /// You can set the viewport size to match the currently bound render target using the
+ /// following call:
+ ///
+ /// pContext->SetViewports(1, nullptr, 0, 0);
+ virtual void SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight ) = 0;
+
+ /// Sets active scissor rects
+
+ /// \param [in] NumRects - Number of scissor rectangles to set.
+ /// \param [in] pRects - An array of Rect structures describing the scissor rectangles to bind.
+ /// \param [in] RTWidth - Render target width. If 0 is provided, width of the currently bound render target will be used.
+ /// \param [in] RTHeight - Render target height. If 0 is provided, height of the currently bound render target will be used.
+ /// \remarks
+ /// DirectX and OpenGL use different window coordinate systems. In DirectX, the coordinate system origin
+ /// is in the left top corner of the screen with Y axis pointing down. In OpenGL, the origin
+ /// is in the left bottom corener of the screen with Y axis pointing up. Render target size is
+ /// required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.\n\n
+ /// All scissor rects must be set atomically as one operation. Any rects not
+ /// defined by the call are disabled.
+ virtual void SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight ) = 0;
+
+ /// Binds one or more render targets and the depth-stencil buffer to the pipeline. It also
+ /// sets the viewport to match the first non-null render target or depth-stencil buffer.
+
+ /// \param [in] NumRenderTargets - Number of render targets to bind.
+ /// \param [in] ppRenderTargets - Array of pointers to ITextureView that represent the render
+ /// targets to bind to the device. The type of each view in the
+ /// array must be Diligent::TEXTURE_VIEW_RENDER_TARGET.
+ /// \param [in] pDepthStencil - Pointer to the ITextureView that represents the depth stencil to
+ /// bind to the device. The view type must be
+ /// Diligent::TEXTURE_VIEW_DEPTH_STENCIL.
+ /// \remarks
+ /// The device context will keep strong references to all bound render target
+ /// and depth-stencil views. Thus these views (and consequently referenced textures)
+ /// cannot be released until they are unbound from the context.\n
+ /// Any render targets not defined by this call are set to nullptr.\n\n
+ /// You can set the default render target and depth stencil using the
+ /// following call:
+ ///
+ /// pContext->SetRenderTargets(0, nullptr, nullptr);
+ virtual void SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil ) = 0;
+
+ /// Executes a draw command
+
+ /// \param [in] DrawAttribs - Structure describing draw command attributes, see DrawAttribs for details.
+ virtual void Draw(DrawAttribs &DrawAttribs) = 0;
+
+ /// Executes a dispatch compute command
+
+ /// \param [in] DispatchAttrs - Structure describing dispatch command attributes,
+ /// see DispatchComputeAttribs for details.
+ virtual void DispatchCompute( const DispatchComputeAttribs &DispatchAttrs ) = 0;
+
+ /// Clears a depth-stencil view
+
+ /// \param [in] pView - Pointer to ITextureView interface to clear. The view type must be
+ /// Diligent::TEXTURE_VIEW_DEPTH_STENCIL.
+ /// \param [in] ClearFlags - Idicates which parts of the buffer to clear, see Diligent::CLEAR_DEPTH_STENCIL_FLAGS.
+ /// \param [in] fDepth - Value to clear depth part of the view with.
+ /// \param [in] Stencil - Value to clear stencil part of the view with.
+ /// \remarks The full extent of the view is always cleared. Viewport and scissor settings are not applied.
+ /// \note The depth-stencil view must be bound to the pipeline for clear operation to be performed.
+ virtual void ClearDepthStencil( ITextureView *pView, Uint32 ClearFlags = CLEAR_DEPTH_FLAG, float fDepth = 1.f, Uint8 Stencil = 0 ) = 0;
+
+ /// Clears a render target view
+
+ /// \param [in] pView - Pointer to ITextureView interface to clear. The view type must be
+ /// Diligent::TEXTURE_VIEW_RENDER_TARGET.
+ /// \param [in] RGBA - A 4-component array that represents the color to fill the render target with.
+ /// If nullptr is provided, the default array {0,0,0,0} will be used.
+ /// \remarks The full extent of the view is always cleared. Viewport and scissor settings are not applied.
+ /// \note The render target view must be bound to the pipeline for clear operation to be performed.
+ virtual void ClearRenderTarget( ITextureView *pView, const float *RGBA = nullptr ) = 0;
+
+ /// Flushes the command buffer
+ virtual void Flush() = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/DeviceObject.h b/Graphics/GraphicsEngine/interface/DeviceObject.h
new file mode 100644
index 00000000..6a3cde70
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/DeviceObject.h
@@ -0,0 +1,50 @@
+/* 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 Diligent::IDeviceObject interface
+
+#include "Object.h"
+#include "GraphicsTypes.h"
+
+namespace Diligent
+{
+
+// {5B4CCA0B-5075-4230-9759-F48769EE5502}
+static const Diligent::INTERFACE_ID IID_DeviceObject =
+{ 0x5b4cca0b, 0x5075, 0x4230, { 0x97, 0x59, 0xf4, 0x87, 0x69, 0xee, 0x55, 0x2 } };
+
+/// Base interface for all objects created by the render device Diligent::IRenderDevice
+class IDeviceObject : public IObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the buffer object description
+ virtual const DeviceObjectAttribs& GetDesc()const = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
new file mode 100644
index 00000000..4f8bbcba
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
@@ -0,0 +1,1087 @@
+/* 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
+/// Contains basic graphics engine type defintions
+
+#include "BasicTypes.h"
+
+/// Graphics engine namespace
+namespace Diligent
+{
+ /// Value type
+
+ /// This enumeration describes value type. It is used by
+ /// - BufferDesc structure to describe value type of a formatted buffer
+ /// - DrawAttribs structure to describe index type for an indexed draw call
+ enum VALUE_TYPE : Int32
+ {
+ VT_UNDEFINED = 0, ///< Undefined type
+ VT_INT8, ///< Signed 8-bit integer
+ VT_INT16, ///< Signed 16-bit integer
+ VT_INT32, ///< Signed 32-bit integer
+ VT_UINT8, ///< Unsigned 8-bit integer
+ VT_UINT16, ///< Unsigned 16-bit integer
+ VT_UINT32, ///< Unsigned 32-bit integer
+ VT_FLOAT16, ///< Half-precision 16-bit floating point
+ VT_FLOAT32, ///< Full-precision 32-bit floating point
+ VT_NUM_TYPES ///< Helper value storing total number of types in the enumeration
+ };
+
+ /// Resource binding flags
+
+ /// [D3D11_BIND_FLAG]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476085(v=vs.85).aspx
+ ///
+ /// This enumeration describes which parts of the pipeline a resource can be bound to.
+ /// It generally mirrows [D3D11_BIND_FLAG][] enumeration. It is used by
+ /// - BufferDesc to describe bind flags for a buffer
+ /// - TextureDesc to describe bind flags for a texture
+ enum BIND_FLAGS : Int32
+ {
+ BIND_NONE = 0x0L, ///< Undefined binding
+ BIND_VERTEX_BUFFER = 0x1L, ///< A buffer can be bound as a vertex buffer
+ BIND_INDEX_BUFFER = 0x2L, ///< A buffer can be bound as an index buffer
+ BIND_UNIFORM_BUFFER = 0x4L, ///< A buffer can be bound as a uniform buffer
+ /// \warning This flag may not be combined with any other bind flag
+ BIND_SHADER_RESOURCE = 0x8L, ///< A buffer or a texture can be bound as a shader resource
+ /// \warning This flag cannot be used with MAP_WRITE_NO_OVERWRITE flag
+ BIND_STREAM_OUTPUT = 0x10L,///< A buffer can be bound as a target for stream output stage
+ BIND_RENDER_TARGET = 0x20L,///< A texture can be bound as a render target
+ BIND_DEPTH_STENCIL = 0x40L,///< A texture can be bound as a depth-stencil target
+ BIND_UNORDERED_ACCESS = 0x80L,///< A buffer or a texture can be bound as an unordered access view
+ BIND_INDIRECT_DRAW_ARGS = 0x100L///< A buffer can be bound as the source buffer for indirect draw commands
+ };
+
+ /// Resource usage
+
+ /// [D3D11_USAGE]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476259(v=vs.85).aspx
+ /// This enumeration describes expected resource usage. It generally mirrows [D3D11_USAGE] enumeration.
+ /// The enumeration is used by
+ /// - BufferDesc to describe usage for a buffer
+ /// - TextureDesc to describe usage for a texture
+ enum USAGE : Int32
+ {
+ /// A resource that can only be read by the GPU. It cannot be written by the GPU,
+ /// and cannot be accessed at all by the CPU. This type of resource must be initialized
+ /// when it is created, since it cannot be changed after creation. \n
+ /// D3D11 Counterpart: D3D11_USAGE_IMMUTABLE. OpenGL counterpart: GL_STATIC_DRAW
+ USAGE_STATIC = 0,
+
+ /// A resource that requires read and write access by the GPU and can also be occasionally
+ /// written by the CPU. \n
+ /// D3D11 Counterpart: D3D11_USAGE_DEFAULT. OpenGL counterpart: GL_DYNAMIC_DRAW
+ USAGE_DEFAULT,
+
+ /// A resource that can be read by the GPU and written at least once per frame by the CPU. \n
+ /// D3D11 Counterpart: D3D11_USAGE_DYNAMIC. OpenGL counterpart: GL_STREAM_DRAW
+ USAGE_DYNAMIC,
+
+ /// A resource that facilitates transferring data from GPU to CPU. \n
+ /// D3D11 Counterpart: D3D11_USAGE_STAGING. OpenGL counterpart: GL_DYNAMIC_READ
+ USAGE_CPU_ACCESSIBLE
+ };
+
+ /// Allowed CPU access mode flags when mapping a resource
+
+ /// The enumeration is used by
+ /// - BufferDesc to describe CPU access mode for a buffer
+ /// - TextureDesc to describe CPU access mode for a texture
+ /// \note Only USAGE_DYNAMIC resources can be mapped
+ enum CPU_ACCESS_FLAG : Int32
+ {
+ CPU_ACCESS_READ = 0x01, ///< A resource can be mapped for reading
+ CPU_ACCESS_WRITE = 0x02 ///< A resource can be mapped for writing
+ };
+
+ /// Resource mapping type
+
+ /// [D3D11_MAP]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476181(v=vs.85).aspx
+ /// Describes how a mapped resource will be accessed. This enumeration generally
+ /// mirrows [D3D11_MAP][] enumeration. It is used by
+ /// - IBuffer::Map to describe buffer mapping type
+ /// - ITexture::Map to describe texture mapping type
+ enum MAP_TYPE : Int32
+ {
+ /// Resource is mapped for reading. \n
+ /// D3D11 counterpart: D3D11_MAP_READ. OpenGL counterpart: GL_MAP_READ_BIT
+ MAP_READ = 0,
+
+ /// Resource is mapped for writing. \n
+ /// D3D11 counterpart: D3D11_MAP_WRITE. OpenGL counterpart: GL_MAP_WRITE_BIT
+ MAP_WRITE,
+
+ /// Resource is mapped for reading and writing. \n
+ /// D3D11 counterpart: D3D11_MAP_READ_WRITE. OpenGL counterpart: GL_MAP_WRITE_BIT | GL_MAP_READ_BIT
+ MAP_READ_WRITE,
+
+ /// Resource is mapped for writing; the previous contents of the resource will be undefined. \n
+ /// D3D11 counterpart: D3D11_MAP_WRITE_DISCARD. OpenGL counterpart: GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT
+ /// \note OpenGL implementation may orphan a buffer instead
+ MAP_WRITE_DISCARD,
+
+ /// Resource is mapped for writing; the existing contents of the resource cannot be overwritten. \n
+ /// D3D11 counterpart: D3D11_MAP_WRITE_NO_OVERWRITE. OpenGL counterpart: GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT
+ MAP_WRITE_NO_OVERWRITE
+ };
+
+ /// Special map flags
+
+ /// Describes special arguments for a map operation.
+ /// This enumeration is used by
+ /// - IBuffer::Map to describe buffer mapping flags
+ /// - ITexture::Map to describe texture mapping flags
+ enum MAP_FLAGS : Int32
+ {
+ /// Specifies that map operation should not wait until previous command that
+ /// using the same resource completes. Map returns null pointer if the resource
+ /// is still in use.\n
+ /// D3D11 counterpart: D3D11_MAP_FLAG_DO_NOT_WAIT
+ /// \note: OpenGL does not have corresponding flag, so a buffer will always be mapped
+ MAP_FLAG_DO_NOT_WAIT = 0x001
+ };
+
+ /// Describes texture type
+
+ /// This enumeration is used by
+ /// - TextureDesc to describe texture type
+ /// - TextureViewDesc to describe texture view type
+ enum TEXTURE_TYPE : Int32
+ {
+ TEXTURE_TYPE_UNDEFINED = 0, ///< Texture type undefined
+ TEXTURE_TYPE_1D, ///< One-dimensional texture
+ TEXTURE_TYPE_1D_ARRAY, ///< One-dimensional texture array
+ TEXTURE_TYPE_2D, ///< Two-dimensional texture
+ TEXTURE_TYPE_2D_ARRAY, ///< Two-dimensional texture array
+ TEXTURE_TYPE_3D, ///< Three-dimensional texture
+ TEXTURE_TYPE_CUBE, ///< Cube-map texture
+ TEXTURE_TYPE_CUBE_ARRAY, ///< Cube-map array texture
+ TEXTURE_TYPE_NUM_TYPES ///< Helper value that stores the total number of texture types in the enumeration
+ };
+
+ /// Texture view type
+
+ /// This enumeration describes allowed view types for a texture view. It is used by TextureViewDesc
+ /// structure.
+ enum TEXTURE_VIEW_TYPE : Int32
+ {
+ /// Undefined view type
+ TEXTURE_VIEW_UNDEFINED = 0,
+
+ /// A texture view will define a shader resource view that will be used
+ /// as the source for the shader read operations
+ TEXTURE_VIEW_SHADER_RESOURCE,
+
+ /// A texture view will define a render target view that will be used
+ /// as the target for rendering operations
+ TEXTURE_VIEW_RENDER_TARGET,
+
+ /// A texture view will define a depth stencil view that will be used
+ /// as the target for rendering operations
+ TEXTURE_VIEW_DEPTH_STENCIL,
+
+ /// A texture view will define an unordered access view that will be used
+ /// for unordered read/write operations from the shaders
+ TEXTURE_VIEW_UNORDERED_ACCESS,
+
+ /// Helper value that stores that total number of texture views
+ TEXTURE_VIEW_NUM_VIEWS
+ };
+
+ /// Buffer view type
+
+ /// This enumeration describes allowed view types for a buffer view. It is used by BufferViewDesc
+ /// structure.
+ enum BUFFER_VIEW_TYPE : Int32
+ {
+ /// Undefined view type
+ BUFFER_VIEW_UNDEFINED = 0,
+
+ /// A buffer view will define a shader resource view that will be used
+ /// as the source for the shader read operations
+ BUFFER_VIEW_SHADER_RESOURCE,
+
+ /// A buffer view will define an unordered access view that will be used
+ /// for unordered read/write operations from the shaders
+ BUFFER_VIEW_UNORDERED_ACCESS,
+
+ /// Helper value that stores that total number of buffer views
+ BUFFER_VIEW_NUM_VIEWS
+ };
+
+ /// Texture formats
+
+ /// This enumeration describes available texture formats and generally mirrows DXGI_FORMAT enumeration.
+ /// The table below provides detailed information on each format. Most of the formats are widely supported
+ /// by all modern APIs (DX10+, OpenGL3.3+ and OpenGLES3.0+). Specific requirements are additionally indicated.
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb173059(v=vs.85).aspx">DXGI_FORMAT enumeration on MSDN</a>,
+ /// <a href = "https://www.opengl.org/wiki/Image_Format">OpenGL Texture Formats</a>
+ ///
+ enum TEXTURE_FORMAT : Int32
+ {
+ /// Unknown format
+ TEX_FORMAT_UNKNOWN = 0,
+
+ /// Four-component 128-bit typeless format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32B32A32_TYPELESS. OpenGL does not have direct counterpart, GL_RGBA32F is used.
+ TEX_FORMAT_RGBA32_TYPELESS,
+
+ /// Four-component 128-bit floating-point format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32B32A32_FLOAT. OpenGL counterpart: GL_RGBA32F.
+ TEX_FORMAT_RGBA32_FLOAT,
+
+ /// Four-component 128-bit unsigned-integer format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32B32A32_UINT. OpenGL counterpart: GL_RGBA32UI.
+ TEX_FORMAT_RGBA32_UINT,
+
+ /// Four-component 128-bit signed-integer format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32B32A32_SINT. OpenGL counterpart: GL_RGBA32I.
+ TEX_FORMAT_RGBA32_SINT,
+
+ /// Three-component 96-bit typeless format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32B32_TYPELESS. OpenGL does not have direct counterpart, GL_RGB32F is used.
+ /// \warning This format has weak hardware support and is not recommended
+ TEX_FORMAT_RGB32_TYPELESS,
+
+ /// Three-component 96-bit floating-point format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32B32_FLOAT. OpenGL counterpart: GL_RGB32F.
+ /// \warning This format has weak hardware support and is not recommended
+ TEX_FORMAT_RGB32_FLOAT,
+
+ /// Three-component 96-bit unsigned-integer format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32B32_UINT. OpenGL counterpart: GL_RGB32UI.
+ /// \warning This format has weak hardware support and is not recommended
+ TEX_FORMAT_RGB32_UINT,
+
+ /// Three-component 96-bit signed-integer format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32B32_SINT. OpenGL counterpart: GL_RGB32I.
+ /// \warning This format has weak hardware support and is not recommended
+ TEX_FORMAT_RGB32_SINT,
+
+ /// Four-component 64-bit typeless format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16B16A16_TYPELESS. OpenGL does not have direct counterpart, GL_RGBA16F is used.
+ TEX_FORMAT_RGBA16_TYPELESS,
+
+ /// Four-component 64-bit half-precision floating-point format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16B16A16_FLOAT. OpenGL counterpart: GL_RGBA16F.
+ TEX_FORMAT_RGBA16_FLOAT,
+
+ /// Four-component 64-bit unsigned-normalized-integer format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16B16A16_UNORM. OpenGL counterpart: GL_RGBA16. \n
+ /// [GL_EXT_texture_norm16]: https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_norm16.txt
+ /// OpenGLES: [GL_EXT_texture_norm16][] extension is required
+ TEX_FORMAT_RGBA16_UNORM,
+
+ /// Four-component 64-bit unsigned-integer format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16B16A16_UINT. OpenGL counterpart: GL_RGBA16UI.
+ TEX_FORMAT_RGBA16_UINT,
+
+ /// [GL_EXT_texture_norm16]: https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_norm16.txt
+ /// Four-component 64-bit signed-normalized-integer format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16B16A16_SNORM. OpenGL counterpart: GL_RGBA16_SNORM. \n
+ /// [GL_EXT_texture_norm16]: https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_norm16.txt
+ /// OpenGLES: [GL_EXT_texture_norm16][] extension is required
+ TEX_FORMAT_RGBA16_SNORM,
+
+ /// Four-component 64-bit signed-integer format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16B16A16_SINT. OpenGL counterpart: GL_RGBA16I.
+ TEX_FORMAT_RGBA16_SINT,
+
+ /// Two-component 64-bit typeless format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32_TYPELESS. OpenGL does not have direct counterpart, GL_RG32F is used.
+ TEX_FORMAT_RG32_TYPELESS,
+
+ /// Two-component 64-bit floating-point format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32_FLOAT. OpenGL counterpart: GL_RG32F.
+ TEX_FORMAT_RG32_FLOAT,
+
+ /// Two-component 64-bit unsigned-integer format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32_UINT. OpenGL counterpart: GL_RG32UI.
+ TEX_FORMAT_RG32_UINT,
+
+ /// Two-component 64-bit signed-integer format with 32-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G32_SINT. OpenGL counterpart: GL_RG32I.
+ TEX_FORMAT_RG32_SINT,
+
+ /// Two-component 64-bit typeless format with 32-bits for R channel and 8 bits for G channel. \n
+ /// D3D counterpart: DXGI_FORMAT_R32G8X24_TYPELESS. OpenGL does not have direct counterpart, GL_DEPTH32F_STENCIL8 is used.
+ TEX_FORMAT_R32G8X24_TYPELESS,
+
+ /// Two-component 64-bit format with 32-bit floating-point depth channel and 8-bit stencil channel. \n
+ /// D3D counterpart: DXGI_FORMAT_D32_FLOAT_S8X24_UINT. OpenGL counterpart: GL_DEPTH32F_STENCIL8.
+ TEX_FORMAT_D32_FLOAT_S8X24_UINT,
+
+ /// Two-component 64-bit format with 32-bit floating-point R channel and 8+24-bits of typeless data. \n
+ /// D3D counterpart: DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS. OpenGL does not have direct counterpart, GL_DEPTH32F_STENCIL8 is used.
+ TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS,
+
+ /// Two-component 64-bit format with 32-bit typeless data and 8-bit G channel. \n
+ /// D3D counterpart: DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
+ /// \warning This format is currently not implemented in OpenGL version
+ TEX_FORMAT_X32_TYPELESS_G8X24_UINT,
+
+ /// Four-component 32-bit typeless format with 10 bits for RGB and 2 bits for alpha channel. \n
+ /// D3D counterpart: DXGI_FORMAT_R10G10B10A2_TYPELESS. OpenGL does not have direct counterpart, GL_RGB10_A2 is used.
+ TEX_FORMAT_RGB10A2_TYPELESS,
+
+ /// Four-component 32-bit unsigned-normalized-integer format with 10 bits for each color and 2 bits for alpha channel. \n
+ /// D3D counterpart: DXGI_FORMAT_R10G10B10A2_UNORM. OpenGL counterpart: GL_RGB10_A2.
+ TEX_FORMAT_RGB10A2_UNORM,
+
+ /// Four-component 32-bit unsigned-integer format with 10 bits for each color and 2 bits for alpha channel. \n
+ /// D3D counterpart: DXGI_FORMAT_R10G10B10A2_UINT. OpenGL counterpart: GL_RGB10_A2UI.
+ TEX_FORMAT_RGB10A2_UINT,
+
+ /// Three-component 32-bit format encoding three partial precision channels using 11 bits for red and green and 10 bits for blue channel. \n
+ /// D3D counterpart: DXGI_FORMAT_R11G11B10_FLOAT. OpenGL counterpart: GL_R11F_G11F_B10F.
+ TEX_FORMAT_R11G11B10_FLOAT,
+
+ /// Four-component 32-bit typeless format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8B8A8_TYPELESS. OpenGL does not have direct counterpart, GL_RGBA8 is used.
+ TEX_FORMAT_RGBA8_TYPELESS,
+
+ /// Four-component 32-bit unsigned-normalized-integer format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8B8A8_UNORM. OpenGL counterpart: GL_RGBA8.
+ TEX_FORMAT_RGBA8_UNORM,
+
+ /// Four-component 32-bit unsigned-normalized-integer sRGB format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8B8A8_UNORM_SRGB. OpenGL counterpart: GL_SRGB8_ALPHA8.
+ TEX_FORMAT_RGBA8_UNORM_SRGB,
+
+ /// Four-component 32-bit unsigned-integer format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8B8A8_UINT. OpenGL counterpart: GL_RGBA8UI.
+ TEX_FORMAT_RGBA8_UINT,
+
+ /// Four-component 32-bit signed-normalized-integer format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8B8A8_SNORM. OpenGL counterpart: GL_RGBA8_SNORM.
+ TEX_FORMAT_RGBA8_SNORM,
+
+ /// Four-component 32-bit signed-integer format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8B8A8_SINT. OpenGL counterpart: GL_RGBA8I.
+ TEX_FORMAT_RGBA8_SINT,
+
+ /// Two-component 32-bit typeless format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16_TYPELESS. OpenGL does not have direct counterpart, GL_RG16F is used.
+ TEX_FORMAT_RG16_TYPELESS,
+
+ /// Two-component 32-bit half-precision floating-point format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16_FLOAT. OpenGL counterpart: GL_RG16F.
+ TEX_FORMAT_RG16_FLOAT,
+
+ /// Two-component 32-bit unsigned-normalized-integer format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16_UNORM. OpenGL counterpart: GL_RG16. \n
+ /// [GL_EXT_texture_norm16]: https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_norm16.txt
+ /// OpenGLES: [GL_EXT_texture_norm16][] extension is required
+ TEX_FORMAT_RG16_UNORM,
+
+ /// Two-component 32-bit unsigned-integer format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16_UINT. OpenGL counterpart: GL_RG16UI.
+ TEX_FORMAT_RG16_UINT,
+
+ /// Two-component 32-bit signed-normalized-integer format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16_SNORM. OpenGL counterpart: GL_RG16_SNORM. \n
+ /// [GL_EXT_texture_norm16]: https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_norm16.txt
+ /// OpenGLES: [GL_EXT_texture_norm16][] extension is required
+ TEX_FORMAT_RG16_SNORM,
+
+ /// Two-component 32-bit signed-integer format with 16-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R16G16_SINT. OpenGL counterpart: GL_RG16I.
+ TEX_FORMAT_RG16_SINT,
+
+ /// Single-component 32-bit typeless format. \n
+ /// D3D counterpart: DXGI_FORMAT_R32_TYPELESS. OpenGL does not have direct counterpart, GL_R32F is used.
+ TEX_FORMAT_R32_TYPELESS,
+
+ /// Single-component 32-bit floating-point depth format. \n
+ /// D3D counterpart: DXGI_FORMAT_D32_FLOAT. OpenGL counterpart: GL_DEPTH_COMPONENT32F.
+ TEX_FORMAT_D32_FLOAT,
+
+ /// Single-component 32-bit floating-point format. \n
+ /// D3D counterpart: DXGI_FORMAT_R32_FLOAT. OpenGL counterpart: GL_R32F.
+ TEX_FORMAT_R32_FLOAT,
+
+ /// Single-component 32-bit unsigned-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R32_UINT. OpenGL counterpart: GL_R32UI.
+ TEX_FORMAT_R32_UINT,
+
+ /// Single-component 32-bit signed-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R32_SINT. OpenGL counterpart: GL_R32I.
+ TEX_FORMAT_R32_SINT,
+
+ /// Two-component 32-bit typeless format with 24 bits for R and 8 bits for G channel. \n
+ /// D3D counterpart: DXGI_FORMAT_R24G8_TYPELESS. OpenGL does not have direct counterpart, GL_DEPTH24_STENCIL8 is used.
+ TEX_FORMAT_R24G8_TYPELESS,
+
+ /// Two-component 32-bit format with 24 bits for unsigned-normalized-integer depth and 8 bits for stencil. \n
+ /// D3D counterpart: DXGI_FORMAT_D24_UNORM_S8_UINT. OpenGL counterpart: GL_DEPTH24_STENCIL8.
+ TEX_FORMAT_D24_UNORM_S8_UINT,
+
+ /// Two-component 32-bit format with 24 bits for unsigned-normalized-integer data and 8 bits of unreferenced data. \n
+ /// D3D counterpart: DXGI_FORMAT_R24_UNORM_X8_TYPELESS. OpenGL does not have direct counterpart, GL_DEPTH24_STENCIL8 is used.
+ TEX_FORMAT_R24_UNORM_X8_TYPELESS,
+
+ /// Two-component 32-bit format with 24 bits of unreferenced data and 8 bits of unsigned-integer data. \n
+ /// D3D counterpart: DXGI_FORMAT_X24_TYPELESS_G8_UINT
+ /// \warning This format is currently not implemented in OpenGL version
+ TEX_FORMAT_X24_TYPELESS_G8_UINT,
+
+ /// Two-component 16-bit typeless format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8_TYPELESS. OpenGL does not have direct counterpart, GL_RG8 is used.
+ TEX_FORMAT_RG8_TYPELESS,
+
+ /// Two-component 16-bit unsigned-normalized-integer format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8_UNORM. OpenGL counterpart: GL_RG8.
+ TEX_FORMAT_RG8_UNORM,
+
+ /// Two-component 16-bit unsigned-integer format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8_UINT. OpenGL counterpart: GL_RG8UI.
+ TEX_FORMAT_RG8_UINT,
+
+ /// Two-component 16-bit signed-normalized-integer format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8_SNORM. OpenGL counterpart: GL_RG8_SNORM.
+ TEX_FORMAT_RG8_SNORM,
+
+ /// Two-component 16-bit signed-integer format with 8-bit channels. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8_SINT. OpenGL counterpart: GL_RG8I.
+ TEX_FORMAT_RG8_SINT,
+
+ /// Single-component 16-bit typeless format. \n
+ /// D3D counterpart: DXGI_FORMAT_R16_TYPELESS. OpenGL does not have direct counterpart, GL_R16F is used.
+ TEX_FORMAT_R16_TYPELESS,
+
+ /// Single-component 16-bit half-precisoin floating-point format. \n
+ /// D3D counterpart: DXGI_FORMAT_R16_FLOAT. OpenGL counterpart: GL_R16F.
+ TEX_FORMAT_R16_FLOAT,
+
+ /// Single-component 16-bit unsigned-normalized-integer depth format. \n
+ /// D3D counterpart: DXGI_FORMAT_D16_UNORM. OpenGL counterpart: GL_DEPTH_COMPONENT16.
+ TEX_FORMAT_D16_UNORM,
+
+ /// Single-component 16-bit unsigned-normalized-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R16_UNORM. OpenGL counterpart: GL_R16.
+ /// [GL_EXT_texture_norm16]: https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_norm16.txt
+ /// OpenGLES: [GL_EXT_texture_norm16][] extension is required
+ TEX_FORMAT_R16_UNORM,
+
+ /// Single-component 16-bit unsigned-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R16_UINT. OpenGL counterpart: GL_R16UI.
+ TEX_FORMAT_R16_UINT,
+
+ /// Single-component 16-bit signed-normalized-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R16_SNORM. OpenGL counterpart: GL_R16_SNORM. \n
+ /// [GL_EXT_texture_norm16]: https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_norm16.txt
+ /// OpenGLES: [GL_EXT_texture_norm16][] extension is required
+ TEX_FORMAT_R16_SNORM,
+
+ /// Single-component 16-bit signed-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R16_SINT. OpenGL counterpart: GL_R16I.
+ TEX_FORMAT_R16_SINT,
+
+ /// Single-component 8-bit typeless format. \n
+ /// D3D counterpart: DXGI_FORMAT_R8_TYPELESS. OpenGL does not have direct counterpart, GL_R8 is used.
+ TEX_FORMAT_R8_TYPELESS,
+
+ /// Single-component 8-bit unsigned-normalized-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R8_UNORM. OpenGL counterpart: GL_R8.
+ TEX_FORMAT_R8_UNORM,
+
+ /// Single-component 8-bit unsigned-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R8_UINT. OpenGL counterpart: GL_R8UI.
+ TEX_FORMAT_R8_UINT,
+
+ /// Single-component 8-bit signed-normalized-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R8_SNORM. OpenGL counterpart: GL_R8_SNORM.
+ TEX_FORMAT_R8_SNORM,
+
+ /// Single-component 8-bit signed-integer format. \n
+ /// D3D counterpart: DXGI_FORMAT_R8_SINT. OpenGL counterpart: GL_R8I.
+ TEX_FORMAT_R8_SINT,
+
+ /// Single-component 8-bit unsigned-normalized-integer format for alpha only. \n
+ /// D3D counterpart: DXGI_FORMAT_A8_UNORM
+ /// \warning This format is not availanle in OpenGL
+ TEX_FORMAT_A8_UNORM,
+
+ /// Single-component 1-bit format. \n
+ /// D3D counterpart: DXGI_FORMAT_R1_UNORM
+ /// \warning This format is not availanle in OpenGL
+ TEX_FORMAT_R1_UNORM,
+
+ /// Three partial-precision floating pointer numbers sharing single exponent encoded into a 32-bit value. \n
+ /// D3D counterpart: DXGI_FORMAT_R9G9B9E5_SHAREDEXP. OpenGL counterpart: GL_RGB9_E5.
+ TEX_FORMAT_RGB9E5_SHAREDEXP,
+
+ /// Four-component unsigned-normalized integer format analogous to UYVY encoding. \n
+ /// D3D counterpart: DXGI_FORMAT_R8G8_B8G8_UNORM
+ /// \warning This format is not availanle in OpenGL
+ TEX_FORMAT_RG8_B8G8_UNORM,
+
+ /// Four-component unsigned-normalized integer format analogous to YUY2 encoding. \n
+ /// D3D counterpart: DXGI_FORMAT_G8R8_G8B8_UNORM
+ /// \warning This format is not availanle in OpenGL
+ TEX_FORMAT_G8R8_G8B8_UNORM,
+
+ /// Four-component typeless block-compression format with 1:8 compression ratio.\n
+ /// D3D counterpart: DXGI_FORMAT_BC1_TYPELESS. OpenGL does not have direct counterpart, GL_COMPRESSED_RGB_S3TC_DXT1_EXT is used. \n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC1">BC1 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT1_Format">DXT1 on OpenGL.org </a>
+ TEX_FORMAT_BC1_TYPELESS,
+
+ /// Four-component unsigned-normalized-integer block-compression format with 5 bits for R, 6 bits for G, 5 bits for B, and 0 or 1 bit for A channel.
+ /// The pixel data is encoded using 8 bytes per 4x4 block (4 bits per pixel) providing 1:8 compression ratio against RGBA8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC1_UNORM. OpenGL counterpart: GL_COMPRESSED_RGB_S3TC_DXT1_EXT.\n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC1">BC1 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT1_Format">DXT1 on OpenGL.org </a>
+ TEX_FORMAT_BC1_UNORM,
+
+ /// Four-component unsigned-normalized-integer block-compression sRGB format with 5 bits for R, 6 bits for G, 5 bits for B, and 0 or 1 bit for A channel. \n
+ /// The pixel data is encoded using 8 bytes per 4x4 block (4 bits per pixel) providing 1:8 compression ratio against RGBA8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC1_UNORM_SRGB. OpenGL counterpart: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT.\n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC1">BC1 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT1_Format">DXT1 on OpenGL.org </a>
+ TEX_FORMAT_BC1_UNORM_SRGB,
+
+ /// Four component typeless block-compression format with 1:4 compression ratio.\n
+ /// D3D counterpart: DXGI_FORMAT_BC2_TYPELESS. OpenGL does not have direct counterpart, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT is used. \n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC2">BC2 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT3_Format">DXT3 on OpenGL.org </a>
+ TEX_FORMAT_BC2_TYPELESS,
+
+ /// Four-component unsigned-normalized-integer block-compression format with 5 bits for R, 6 bits for G, 5 bits for B, and 4 bits for low-coherent separate A channel.
+ /// The pixel data is encoded using 16 bytes per 4x4 block (8 bits per pixel) providing 1:4 compression ratio against RGBA8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC2_UNORM. OpenGL counterpart: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT. \n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC2">BC2 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT3_Format">DXT3 on OpenGL.org </a>
+ TEX_FORMAT_BC2_UNORM,
+
+ /// Four-component signed-normalized-integer block-compression sRGB format with 5 bits for R, 6 bits for G, 5 bits for B, and 4 bits for low-coherent separate A channel.
+ /// The pixel data is encoded using 16 bytes per 4x4 block (8 bits per pixel) providing 1:4 compression ratio against RGBA8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC2_UNORM_SRGB. OpenGL counterpart: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT. \n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC2">BC2 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT3_Format">DXT3 on OpenGL.org </a>
+ TEX_FORMAT_BC2_UNORM_SRGB,
+
+ /// Four-component typeless block-compression format with 1:4 compression ratio.\n
+ /// D3D counterpart: DXGI_FORMAT_BC3_TYPELESS. OpenGL does not have direct counterpart, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT is used. \n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC3">BC3 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT5_Format">DXT5 on OpenGL.org </a>
+ TEX_FORMAT_BC3_TYPELESS,
+
+ /// Four-component unsigned-normalized-integer block-compression format with 5 bits for R, 6 bits for G, 5 bits for B, and 8 bits for highly-coherent A channel.
+ /// The pixel data is encoded using 16 bytes per 4x4 block (8 bits per pixel) providing 1:4 compression ratio against RGBA8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC3_UNORM. OpenGL counterpart: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT. \n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC3">BC3 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT5_Format">DXT5 on OpenGL.org </a>
+ TEX_FORMAT_BC3_UNORM,
+
+ /// Four-component unsigned-normalized-integer block-compression sRGB format with 5 bits for R, 6 bits for G, 5 bits for B, and 8 bits for highly-coherent A channel.
+ /// The pixel data is encoded using 16 bytes per 4x4 block (8 bits per pixel) providing 1:4 compression ratio against RGBA8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC3_UNORM_SRGB. OpenGL counterpart: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT. \n
+ /// [GL_EXT_texture_compression_s3tc]: https://www.khronos.org/registry/gles/extensions/EXT/texture_compression_s3tc.txt
+ /// OpenGL & OpenGLES: [GL_EXT_texture_compression_s3tc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC3">BC3 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/S3_Texture_Compression#DXT5_Format">DXT5 on OpenGL.org </a>
+ TEX_FORMAT_BC3_UNORM_SRGB,
+
+ /// One-component typeless block-compression format with 1:2 compression ratio. \n
+ /// D3D counterpart: DXGI_FORMAT_BC4_TYPELESS. OpenGL does not have direct counterpart, GL_COMPRESSED_RED_RGTC1 is used. \n
+ /// [GL_ARB_texture_compression_rgtc]: https://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
+ /// OpenGL & OpenGLES: [GL_ARB_texture_compression_rgtc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC4">BC4 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/Image_Format#Compressed_formats">Compressed formats on OpenGL.org </a>
+ TEX_FORMAT_BC4_TYPELESS,
+
+ /// One-component unsigned-normalized-integer block-compression format with 8 bits for R channel.
+ /// The pixel data is encoded using 8 bytes per 4x4 block (4 bits per pixel) providing 1:2 compression ratio against R8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC4_UNORM. OpenGL counterpart: GL_COMPRESSED_RED_RGTC1. \n
+ /// [GL_ARB_texture_compression_rgtc]: https://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
+ /// OpenGL & OpenGLES: [GL_ARB_texture_compression_rgtc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC4">BC4 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/Image_Format#Compressed_formats">Compressed formats on OpenGL.org </a>
+ TEX_FORMAT_BC4_UNORM,
+
+ /// One-component signed-normalized-integer block-compression format with 8 bits for R channel.
+ /// The pixel data is encoded using 8 bytes per 4x4 block (4 bits per pixel) providing 1:2 compression ratio against R8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC4_SNORM. OpenGL counterpart: GL_COMPRESSED_SIGNED_RED_RGTC1. \n
+ /// [GL_ARB_texture_compression_rgtc]: https://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
+ /// OpenGL & OpenGLES: [GL_ARB_texture_compression_rgtc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC4">BC4 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/Image_Format#Compressed_formats">Compressed formats on OpenGL.org </a>
+ TEX_FORMAT_BC4_SNORM,
+
+ /// Two-component typeless block-compression format with 1:2 compression ratio. \n
+ /// D3D counterpart: DXGI_FORMAT_BC5_TYPELESS. OpenGL does not have direct counterpart, GL_COMPRESSED_RG_RGTC2 is used. \n
+ /// [GL_ARB_texture_compression_rgtc]: https://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
+ /// OpenGL & OpenGLES: [GL_ARB_texture_compression_rgtc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC5">BC5 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/Image_Format#Compressed_formats">Compressed formats on OpenGL.org </a>
+ TEX_FORMAT_BC5_TYPELESS,
+
+ /// Two-component unsigned-normalized-integer block-compression format with 8 bits for R and 8 bits for G channel.
+ /// The pixel data is encoded using 16 bytes per 4x4 block (8 bits per pixel) providing 1:2 compression ratio against RG8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC5_UNORM. OpenGL counterpart: GL_COMPRESSED_RG_RGTC2. \n
+ /// [GL_ARB_texture_compression_rgtc]: https://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
+ /// OpenGL & OpenGLES: [GL_ARB_texture_compression_rgtc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC5">BC5 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/Image_Format#Compressed_formats">Compressed formats on OpenGL.org </a>
+ TEX_FORMAT_BC5_UNORM,
+
+ /// Two-component signed-normalized-integer block-compression format with 8 bits for R and 8 bits for G channel.
+ /// The pixel data is encoded using 16 bytes per 4x4 block (8 bits per pixel) providing 1:2 compression ratio against RG8 format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC5_SNORM. OpenGL counterpart: GL_COMPRESSED_SIGNED_RG_RGTC2. \n
+ /// [GL_ARB_texture_compression_rgtc]: https://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt
+ /// OpenGL & OpenGLES: [GL_ARB_texture_compression_rgtc][] extension is required
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC5">BC5 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/Image_Format#Compressed_formats">Compressed formats on OpenGL.org </a>
+ TEX_FORMAT_BC5_SNORM,
+
+ /// Three-component 16-bit unsigned-normalized-integer format with 5 bits for blue, 6 bits for green, and 5 bits for red channel. \n
+ /// D3D counterpart: DXGI_FORMAT_B5G6R5_UNORM
+ /// \warning This format is not available until D3D11.1 and Windows 8. It is also not available in OpenGL
+ TEX_FORMAT_B5G6R5_UNORM,
+
+ /// Four-component 16-bit unsigned-normalized-integer format with 5 bits for each color channel and 1-bit alpha. \n
+ /// D3D counterpart: DXGI_FORMAT_B5G5R5A1_UNORM
+ /// \warning This format is not available until D3D11.1 and Windows 8. It is also not available in OpenGL
+ TEX_FORMAT_B5G5R5A1_UNORM,
+
+ /// Four-component 32-bit unsigned-normalized-integer format with 8 bits for each channel. \n
+ /// D3D counterpart: DXGI_FORMAT_B8G8R8A8_UNORM.
+ /// \warning This format is not available in OpenGL
+ TEX_FORMAT_BGRA8_UNORM,
+
+ /// Four-component 32-bit unsigned-normalized-integer format with 8 bits for each color channel and 8 bits unused. \n
+ /// D3D counterpart: DXGI_FORMAT_B8G8R8X8_UNORM.
+ /// \warning This format is not available in OpenGL
+ TEX_FORMAT_BGRX8_UNORM,
+
+ /// Four-component 32-bit 2.8-biased fixed-point format with 10 bits for each color channel and 2-bit alpha. \n
+ /// D3D counterpart: DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM.
+ /// \warning This format is not available in OpenGL
+ TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM,
+
+ /// Four-component 32-bit typeless format with 8 bits for each channel. \n
+ /// D3D counterpart: DXGI_FORMAT_B8G8R8A8_TYPELESS.
+ /// \warning This format is not available in OpenGL
+ TEX_FORMAT_BGRA8_TYPELESS,
+
+ /// Four-component 32-bit unsigned-normalized sRGB format with 8 bits for each channel. \n
+ /// D3D counterpart: DXGI_FORMAT_B8G8R8A8_UNORM_SRGB.
+ /// \warning This format is not available in OpenGL.
+ TEX_FORMAT_BGRA8_UNORM_SRGB,
+
+ /// Four-component 32-bit typeless format that with 8 bits for each color channel, and 8 bits are unused. \n
+ /// D3D counterpart: DXGI_FORMAT_B8G8R8X8_TYPELESS.
+ /// \warning This format is not available in OpenGL.
+ TEX_FORMAT_BGRX8_TYPELESS,
+
+ /// Four-component 32-bit unsigned-normalized sRGB format with 8 bits for each color channel, and 8 bits are unused. \n
+ /// D3D counterpart: DXGI_FORMAT_B8G8R8X8_UNORM_SRGB.
+ /// \warning This format is not available in OpenGL.
+ TEX_FORMAT_BGRX8_UNORM_SRGB,
+
+ /// Three-component typeless block-compression format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC6H_TYPELESS. OpenGL does not have direct counterpart, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT is used. \n
+ /// [GL_ARB_texture_compression_bptc]: https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/specs/ARB/texture_compression_bptc.txt
+ /// OpenGL: [GL_ARB_texture_compression_bptc][] extension is required. Not supported in at least OpenGLES3.1
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/hh308952(v=vs.85).aspx">BC6H on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/BPTC_Texture_Compression">BPTC Texture Compression on OpenGL.org </a>
+ TEX_FORMAT_BC6H_TYPELESS,
+
+ /// Three-component unsigned half-precision floating-point format with 16 bits for each channel. \n
+ /// D3D counterpart: DXGI_FORMAT_BC6H_UF16. OpenGL counterpart: GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT. \n
+ /// [GL_ARB_texture_compression_bptc]: https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/specs/ARB/texture_compression_bptc.txt
+ /// OpenGL: [GL_ARB_texture_compression_bptc][] extension is required. Not supported in at least OpenGLES3.1
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/hh308952(v=vs.85).aspx">BC6H on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/BPTC_Texture_Compression">BPTC Texture Compression on OpenGL.org </a>
+ TEX_FORMAT_BC6H_UF16,
+
+ /// Three-channel signed half-precision floating-point format with 16 bits per each channel. \n
+ /// D3D counterpart: DXGI_FORMAT_BC6H_SF16. OpenGL counterpart: GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT. \n
+ /// [GL_ARB_texture_compression_bptc]: https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/specs/ARB/texture_compression_bptc.txt
+ /// OpenGL: [GL_ARB_texture_compression_bptc][] extension is required. Not supported in at least OpenGLES3.1
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/hh308952(v=vs.85).aspx">BC6H on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/BPTC_Texture_Compression">BPTC Texture Compression on OpenGL.org </a>
+ TEX_FORMAT_BC6H_SF16,
+
+ /// Three-component typeless block-compression format. \n
+ /// D3D counterpart: DXGI_FORMAT_BC7_TYPELESS. OpenGL does not have direct counterpart, GL_COMPRESSED_RGBA_BPTC_UNORM is used. \n
+ /// [GL_ARB_texture_compression_bptc]: https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/specs/ARB/texture_compression_bptc.txt
+ /// OpenGL: [GL_ARB_texture_compression_bptc][] extension is required. Not supported in at least OpenGLES3.1
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/hh308953(v=vs.85).aspx">BC7 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/BPTC_Texture_Compression">BPTC Texture Compression on OpenGL.org </a>
+ TEX_FORMAT_BC7_TYPELESS,
+
+ /// Three-component block-compression unsigned-normalized-integer format with 4 to 7 bits per color channel and 0 to 8 bits of alpha. \n
+ /// D3D counterpart: DXGI_FORMAT_BC7_UNORM. OpenGL counterpart: GL_COMPRESSED_RGBA_BPTC_UNORM. \n
+ /// [GL_ARB_texture_compression_bptc]: https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/specs/ARB/texture_compression_bptc.txt
+ /// OpenGL: [GL_ARB_texture_compression_bptc][] extension is required. Not supported in at least OpenGLES3.1
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/hh308953(v=vs.85).aspx">BC7 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/BPTC_Texture_Compression">BPTC Texture Compression on OpenGL.org </a>
+ TEX_FORMAT_BC7_UNORM,
+
+ /// Three-component block-compression unsigned-normalized-integer sRGB format with 4 to 7 bits per color channel and 0 to 8 bits of alpha. \n
+ /// D3D counterpart: DXGI_FORMAT_BC7_UNORM_SRGB. OpenGL counterpart: GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM. \n
+ /// [GL_ARB_texture_compression_bptc]: https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/specs/ARB/texture_compression_bptc.txt
+ /// OpenGL: [GL_ARB_texture_compression_bptc][] extension is required. Not supported in at least OpenGLES3.1
+ /// \sa <a href = "https://msdn.microsoft.com/en-us/library/windows/desktop/hh308953(v=vs.85).aspx">BC7 on MSDN </a>,
+ /// <a href = "https://www.opengl.org/wiki/BPTC_Texture_Compression">BPTC Texture Compression on OpenGL.org </a>
+ TEX_FORMAT_BC7_UNORM_SRGB,
+
+ /// Helper member containing the total number of texture formats in the enumeration
+ TEX_FORMAT_NUM_FORMATS
+ };
+
+ /// Filter type
+
+ /// This enumeration defines filter type. It is used by SamplerDesc structure to define min, mag and mip filters.
+ /// \note On D3D11, comparison filters only work with textures that have the following formats:
+ /// R32_FLOAT_X8X24_TYPELESS, R32_FLOAT, R24_UNORM_X8_TYPELESS, R16_UNORM.
+ enum FILTER_TYPE : Int32
+ {
+ FILTER_TYPE_UNKNOWN = 0, ///< Unknown filter type
+ FILTER_TYPE_POINT, ///< Point filtering
+ FILTER_TYPE_LINEAR, ///< Linear filtering
+ FILTER_TYPE_ANISOTROPIC, ///< Anisotropic filtering
+ FILTER_TYPE_COMPARISON_POINT, ///< Comparison-point filtering
+ FILTER_TYPE_COMPARISON_LINEAR, ///< Comparison-linear filtering
+ FILTER_TYPE_COMPARISON_ANISOTROPIC, ///< Comparison-anisotropic filtering
+ FILTER_TYPE_NUM_FILTERS ///< Helper value that stores the total number of filter types in the enumeration
+ };
+
+ /// Texture address mode
+
+ /// [D3D11_TEXTURE_ADDRESS_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476256(v=vs.85).aspx
+ /// Defines a technique for resolving texture coordinates that are outside of
+ /// the boundaries of a texture. The enumeration generally mirrows [D3D11_TEXTURE_ADDRESS_MODE][] enumeration.
+ /// It is used by SamplerDesc structure to define the address mode for U,V and W texture coordinates.
+ enum TEXTURE_ADDRESS_MODE : Int32
+ {
+ /// Unknown mode
+ TEXTURE_ADDRESS_UNKNOWN = 0,
+
+ /// Tile the texture at every integer junction. \n
+ /// D3D11 Counterpart: D3D11_TEXTURE_ADDRESS_WRAP. OpenGL counterpart: GL_REPEAT
+ TEXTURE_ADDRESS_WRAP = 1,
+
+ /// Flip the texture at every integer junction. \n
+ /// D3D11 Counterpart: D3D11_TEXTURE_ADDRESS_MIRROR. OpenGL counterpart: GL_MIRRORED_REPEAT
+ TEXTURE_ADDRESS_MIRROR = 2,
+
+ /// Texture coordinates outside the range [0.0, 1.0] are set to the
+ /// texture color at 0.0 or 1.0, respectively. \n
+ /// D3D11 Counterpart: D3D11_TEXTURE_ADDRESS_CLAMP. OpenGL counterpart: GL_CLAMP_TO_EDGE
+ TEXTURE_ADDRESS_CLAMP = 3,
+
+ /// Texture coordinates outside the range [0.0, 1.0] are set to the border color specified
+ /// specified in SamplerDesc structure. \n
+ /// D3D11 Counterpart: D3D11_TEXTURE_ADDRESS_BORDER. OpenGL counterpart: GL_CLAMP_TO_BORDER
+ TEXTURE_ADDRESS_BORDER = 4,
+
+ /// Similar to TEXTURE_ADDRESS_MIRROR and TEXTURE_ADDRESS_CLAMP. Takes the absolute
+ /// value of the texture coordinate (thus, mirroring around 0), and then clamps to
+ /// the maximum value. \n
+ /// D3D11 Counterpart: D3D11_TEXTURE_ADDRESS_MIRROR_ONCE. OpenGL counterpart: GL_MIRROR_CLAMP_TO_EDGE
+ /// \note GL_MIRROR_CLAMP_TO_EDGE is only available in OpenGL4.4+, and is not available until at least OpenGLES3.1
+ TEXTURE_ADDRESS_MIRROR_ONCE = 5,
+
+ /// Helper value that stores the total number of texture address modes in the enumeration
+ TEXTURE_ADDRESS_NUM_MODES
+ };
+
+ /// Comparison function
+
+ /// [D3D11_COMPARISON_FUNC]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476101(v=vs.85).aspx
+ /// This enumeartion defines a comparison function. It generally mirrows [D3D11_COMPARISON_FUNC] enum and is used by
+ /// - SamplerDesc to define a comparison function if one of the comparison mode filters is used
+ /// - StencilOpDesc to define a stencil function
+ /// - DepthStencilStateDesc to define a depth function
+ enum COMPARISON_FUNCTION : Int32
+ {
+ /// Unknown comparison function
+ COMPARISON_FUNC_UNKNOW = 0,
+
+ /// Comparison never passes. \n
+ /// D3D11 counterpart: D3D11_COMPARISON_NEVER. OpenGL counterpart: GL_NEVER.
+ COMPARISON_FUNC_NEVER,
+
+ /// Comparison passes if the source data is less than the destination data.\n
+ /// D3D11 counterpart: D3D11_COMPARISON_LESS. OpenGL counterpart: GL_LESS.
+ COMPARISON_FUNC_LESS,
+
+ /// Comparison passes if the source data is equal to the destination data.\n
+ /// D3D11 counterpart: 3D11_COMPARISON_EQUAL. OpenGL counterpart: GL_EQUAL.
+ COMPARISON_FUNC_EQUAL,
+
+ /// Comparison passes if the source data is less than or equal to the destination data.\n
+ /// D3D11 counterpart: D3D11_COMPARISON_LESS_EQUAL. OpenGL counterpart: GL_LEQUAL.
+ COMPARISON_FUNC_LESS_EQUAL,
+
+ /// Comparison passes if the source data is greater than the destination data.\n
+ /// D3D11 counterpart: 3D11_COMPARISON_GREATER. OpenGL counterpart: GL_GREATER.
+ COMPARISON_FUNC_GREATER,
+
+ /// Comparison passes if the source data is not equal to the destination data.\n
+ /// D3D11 counterpart: D3D11_COMPARISON_NOT_EQUAL. OpenGL counterpart: GL_NOTEQUAL.
+ COMPARISON_FUNC_NOT_EQUAL,
+
+ /// Comparison passes if the source data is greater than or equal to the destination data.\n
+ /// D3D11 counterpart: D3D11_COMPARISON_GREATER_EQUAL. OpenGL counterpart: GL_GEQUAL.
+ COMPARISON_FUNC_GREATER_EQUAL,
+
+ /// Comparison always passes. \n
+ /// D3D11 counterpart: D3D11_COMPARISON_ALWAYS. OpenGL counterpart: GL_ALWAYS.
+ COMPARISON_FUNC_ALWAYS,
+
+ /// Helper value that stores the total number of comparison functions in the enumeration
+ COMPARISON_FUNC_NUM_FUNCTIONS
+ };
+
+ /// Miscellaneous texture flags
+
+ /// The enumeration is used by TextureDesc to describe misc texture flags
+ enum MISC_TEXTURE_FLAG
+ {
+ /// Allow automatic mipmap generation with ITextureView::GenerateMips()
+
+ /// \note A texture must be created with BIND_RENDER_TARGET bind flag
+ MISC_TEXTURE_FLAG_GENERATE_MIPS = 0x01
+ };
+
+ /// Describes common device object attributes
+ struct DeviceObjectAttribs
+ {
+ /// Object name
+ const Char* Name;
+
+ /// Constructor intializes the structure members with default values
+ DeviceObjectAttribs() :
+ Name(nullptr)
+ {}
+ };
+
+ /// Swap chain description
+ struct SwapChainDesc
+ {
+ /// The swap chain width. Default value is 0
+ Uint32 Width;
+
+ /// The swap chain height. Default value is 0
+ Uint32 Height;
+
+ /// Back buffer format. Default value is TEX_FORMAT_RGBA8_UNORM_SRGB
+ TEXTURE_FORMAT ColorBufferFormat;
+
+ /// Depth buffer format. Default value is TEX_FORMAT_D32_FLOAT
+ TEXTURE_FORMAT DepthBufferFormat;
+
+ /// Sample count. Default value is 1
+ Uint32 SamplesCount;
+
+ /// Constructor intializes the structure members with default values
+ SwapChainDesc() :
+ Width(0),
+ Height(0),
+ ColorBufferFormat( TEX_FORMAT_RGBA8_UNORM_SRGB ),
+ DepthBufferFormat( TEX_FORMAT_D32_FLOAT ),
+ SamplesCount( 1 )
+ {}
+ };
+
+ /// Engine creation attibutes
+ struct EngineCreationAttribs
+ {
+ const Char* strShaderCachePath;
+
+ EngineCreationAttribs() :
+ strShaderCachePath(nullptr)
+ {}
+ };
+
+ /// Box
+ struct Box
+ {
+ Uint32 MinX; ///< Minimal X coordinate. Default value is 0
+ Uint32 MaxX; ///< Maximal X coordinate. Default value is 0
+ Uint32 MinY; ///< Minimal Y coordinate. Default value is 0
+ Uint32 MaxY; ///< Maximal Y coordinate. Default value is 0
+ Uint32 MinZ; ///< Minimal Z coordinate. Default value is 0
+ Uint32 MaxZ; ///< Maximal Z coordinate. Default value is 1
+
+ /// Constructor intializes the structure
+ Box(Uint32 _MinX = 0, Uint32 _MaxX = 0,
+ Uint32 _MinY = 0, Uint32 _MaxY = 0,
+ Uint32 _MinZ = 0, Uint32 _MaxZ = 1) :
+ MinX(_MinX), MaxX(_MaxX),
+ MinY(_MinY), MaxY(_MaxY),
+ MinZ(_MinZ), MaxZ(_MaxZ)
+ {}
+ };
+
+
+ /// Describes texture format component type
+ enum COMPONENT_TYPE : Int32
+ {
+ /// Undefined component type
+ COMPONENT_TYPE_UNDEFINED,
+
+ /// Floating point component type
+ COMPONENT_TYPE_FLOAT,
+
+ /// Signed-normalized-integer component type
+ COMPONENT_TYPE_SNORM,
+
+ /// Unsigned-normalized-integer component type
+ COMPONENT_TYPE_UNORM,
+
+ /// Unsigned-normalized-integer sRGB component type
+ COMPONENT_TYPE_UNORM_SRGB,
+
+ /// Signed-integer component type
+ COMPONENT_TYPE_SINT,
+
+ /// Unsigned-integer component type
+ COMPONENT_TYPE_UINT,
+
+ /// Depth component type
+ COMPONENT_TYPE_DEPTH,
+
+ /// Depth-stencil component type
+ COMPONENT_TYPE_DEPTH_STENCIL,
+
+ /// Compound component type (example texture formats: TEX_FORMAT_R11G11B10_FLOAT or TEX_FORMAT_RGB9E5_SHAREDEXP)
+ COMPONENT_TYPE_COMPOUND,
+
+ /// Compressed component type
+ COMPONENT_TYPE_COMPRESSED,
+ };
+
+ /// Describes invariant texture format attributes. These attributes are
+ /// intrinsic to the texture format itself and do not depend on the
+ /// format support.
+ struct TextureFormatAttribs
+ {
+ /// Texture format, see Diligent::TEXTURE_FORMAT for a list of supported texture formats
+ TEXTURE_FORMAT Format;
+
+ /// Literal texture format name (for instance, for TEX_FORMAT_RGBA8_UNORM format, this
+ /// will be "TEX_FORMAT_RGBA8_UNORM")
+ const Char *Name;
+
+ /// Size of one component in bytes (for instance, for TEX_FORMAT_RGBA8_UNORM format, this will be 1)
+ /// For compressed formats, this is the block size in bytes (for TEX_FORMAT_BC1_UNORM format, this will be 8)
+ Uint32 ComponentSize;
+
+ /// Number of components
+ Uint32 NumComponents;
+
+ /// Component type, see Diligent::COMPONENT_TYPE for details.
+ COMPONENT_TYPE ComponentType;
+
+ /// Initializes the structure
+ explicit TextureFormatAttribs( TEXTURE_FORMAT _Format = TEX_FORMAT_UNKNOWN,
+ const Char *_Name = "TEX_FORMAT_UNKNOWN",
+ Uint32 _ComponentSize = 0,
+ Uint32 _NumComponents = 0,
+ COMPONENT_TYPE _ComponentType = COMPONENT_TYPE_UNDEFINED ) :
+ Format(_Format),
+ Name(_Name),
+ ComponentSize(_ComponentSize),
+ NumComponents(_NumComponents),
+ ComponentType(_ComponentType)
+ {}
+ };
+
+ /// Basic texture format description
+
+ /// This structure is returned by IRenderDevice::GetTextureFormatInfo()
+ struct TextureFormatInfo : public TextureFormatAttribs
+ {
+ /// Indicates if the format is supported by the device
+ bool Supported;
+
+ /// Initializes the structure with default values
+ explicit TextureFormatInfo() :
+ Supported(false)
+ {}
+ };
+
+ /// Extended texture format description
+
+ /// This structure is returned by IRenderDevice::GetTextureFormatInfoExt()
+ struct TextureFormatInfoExt : TextureFormatInfo
+ {
+ /// Indicates if the format can be filtered
+ bool Filterable;
+
+ /// Indicates if the format can be used as a render target format
+ bool ColorRenderable;
+
+ /// Indicates if the format can be used as a depth format
+ bool DepthRenderable;
+
+ /// Indicates if the format can be used to create a 1D texture
+ bool Tex1DFmt;
+
+ /// Indicates if the format can be used to create a 2D texture
+ bool Tex2DFmt;
+
+ /// Indicates if the format can be used to create a 3D texture
+ bool Tex3DFmt;
+
+ /// Indicates if the format can be used to create a cube texture
+ bool TexCubeFmt;
+
+ /// Indicates if the format can be used to create a multisampled 2D texture
+ bool SupportsMS;
+
+ /// Initializes the structure with default values
+ explicit TextureFormatInfoExt() :
+ Filterable(false),
+ ColorRenderable(false),
+ DepthRenderable(false),
+ Tex1DFmt(false),
+ Tex2DFmt(false),
+ Tex3DFmt(false),
+ TexCubeFmt(false),
+ SupportsMS(false)
+ {}
+ };
+}
diff --git a/Graphics/GraphicsEngine/interface/MapHelper.h b/Graphics/GraphicsEngine/interface/MapHelper.h
new file mode 100644
index 00000000..9f2aae72
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/MapHelper.h
@@ -0,0 +1,148 @@
+/* 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
+/// Definition of the Diligent::MapHelper helper template class
+
+#include "DebugUtilities.h"
+
+namespace Diligent
+{
+
+/// Facilitates resource mapping
+
+/// \tparam DataType - type of the mapped data.
+///
+/// This class is designed to automate resource mapping/unmapping process.
+/// The class automatically unmaps the resource when the class instance gets out of scope.\n
+/// Usage example:
+///
+/// {
+/// MapHelper<float> UniformData( pDeviceContext, pUniformBuff, MAP_WRITE_DISCARD, 0 );
+/// UniformData[0] = UniformData[1] = UniformData[2] = UniformData[3] = 1;
+/// }
+template<typename DataType>
+class MapHelper
+{
+public:
+
+ /// Initializes the class member with null values
+ MapHelper() :
+ m_pMappedData(nullptr)
+ {
+ }
+
+ /// Initializes the object and maps the provided resource.
+ /// See Map() for details.
+ MapHelper( IDeviceContext *pContext, IBuffer *pBuffer, MAP_TYPE MapType, Uint32 MapFlags ) :
+ m_pMappedData(nullptr)
+ {
+ Map(pContext, pBuffer, MapType, MapFlags);
+ }
+
+ /// Move constructor: takes over resource ownership from Helper
+ MapHelper(MapHelper&& Helper) :
+ m_pBuffer( std::move(Helper.m_pBuffer) ),
+ m_pMappedData( std::move(Helper.m_pMappedData) ),
+ m_pContext( std::move(Helper.m_pContext) )
+ {
+ Helper.m_pBuffer.Release();
+ Helper.m_pContext.Release();
+ Helper.m_pMappedData = nullptr;
+ }
+
+ /// Move-assignement operator: takes over resource ownership from Helper
+ MapHelper& operator = (MapHelper&& Helper)
+ {
+ m_pBuffer = std::move(Helper.m_pBuffer);
+ m_pMappedData = std::move(Helper.m_pMappedData);
+ m_pContext = std::move( Helper.m_pContext );
+ Helper.m_pBuffer.Release();
+ Helper.m_pContext.Release();
+ Helper.m_pMappedData = nullptr;
+ return *this;
+ }
+
+ /// Maps the provided resource.
+
+ /// \param pContext - Pointer to the device context to perform mapping with.
+ /// \param pBuffer - Pointer to the buffer interface to map.
+ /// \param MapType - Type of the map operation, see Diligent::MAP_TYPE for details.
+ /// \param MapFlags - Additional map flags, see Diligent::MAP_FLAGS.
+ void Map( IDeviceContext *pContext, IBuffer *pBuffer, MAP_TYPE MapType, Uint32 MapFlags )
+ {
+ VERIFY(!m_pBuffer && !m_pMappedData && !m_pContext, "Object already mapped");
+ Unmap();
+ m_pContext = pContext;
+ m_pBuffer = pBuffer;
+ m_pBuffer->Map(m_pContext, MapType, MapFlags, (PVoid&)m_pMappedData);
+ VERIFY( m_pMappedData, "Map failed" );
+ }
+
+ /// Unamps the resource and resets the object state to default.
+ void Unmap()
+ {
+ if( m_pBuffer )
+ {
+ m_pBuffer->Unmap(m_pContext);
+ m_pBuffer.Release();
+ }
+ m_pContext.Release();
+ m_pMappedData = nullptr;
+ }
+
+ /// Converts mapped data pointer to DataType*
+ operator DataType* (){return m_pMappedData;}
+
+ /// Converts mapped data pointer to const DataType*
+ operator const DataType* ()const{return m_pMappedData;}
+
+ /// Operator ->
+ DataType* operator->() {return m_pMappedData;}
+
+ /// Operator const ->
+ const DataType* operator->() const{return m_pMappedData;}
+
+ /// Unamps the resource
+ ~MapHelper()
+ {
+ Unmap();
+ }
+
+private:
+ MapHelper(const MapHelper&);
+ MapHelper& operator=(const MapHelper&);
+
+ /// Strong auto pointer to the resource
+ RefCntAutoPtr<IBuffer> m_pBuffer;
+
+ /// Strong auto pointer to the context
+ RefCntAutoPtr<IDeviceContext> m_pContext;
+
+ /// Pointer to the mapped data
+ DataType *m_pMappedData;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/RasterizerState.h b/Graphics/GraphicsEngine/interface/RasterizerState.h
new file mode 100644
index 00000000..e69bf635
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/RasterizerState.h
@@ -0,0 +1,194 @@
+/* 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
+/// Definition of the Diligent::IRasterizerState interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+/// Fill mode
+
+/// [D3D11_FILL_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476131(v=vs.85).aspx
+/// This enumeration determines the fill mode to use when rendering triangles and mirrows the
+/// [D3D11_FILL_MODE][] enum. It is used by RasterizerStateDesc structure to define the fill mode.
+enum FILL_MODE : Int32
+{
+ /// Undefined fill mode.
+ FILL_MODE_UNDEFINED = 0,
+
+ /// Rasterize triangles using wireframe fill. \n
+ /// D3D11 counterpart: D3D11_FILL_WIREFRAME. OpenGL counterpart: GL_LINE.
+ FILL_MODE_WIREFRAME,
+
+ /// Rasterize triangles using solid fill. \n
+ /// D3D11 counterpart: D3D11_FILL_SOLID. OpenGL counterpart: GL_FILL.
+ FILL_MODE_SOLID,
+
+ /// Helper value that stores the total number of fill modes in the enumeration.
+ FILL_MODE_NUM_MODES
+};
+
+/// Cull mode
+
+/// [D3D11_CULL_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476108(v=vs.85).aspx
+/// This enumeration defines which triangles are not drawn during the rasterization and mirrows
+/// [D3D11_CULL_MODE][] enum. It is used by RasterizerStateDesc structure to define the polygin cull mode.
+enum CULL_MODE : Int32
+{
+ /// Undefined cull mode.
+ CULL_MODE_UNDEFINED = 0,
+
+ /// Draw all triangles. \n
+ /// D3D11 counterpart: D3D11_CULL_NONE. OpenGL counterpart: glDisable( GL_CULL_FACE ).
+ CULL_MODE_NONE,
+
+ /// Do not draw triangles that are front-facing. Front- and back-facing triangles are determined
+ /// by the RasterizerStateDesc::FrontCounterClockwise member. \n
+ /// D3D11 counterpart: D3D11_CULL_FRONT. OpenGL counterpart: GL_FRONT.
+ CULL_MODE_FRONT,
+
+ /// Do not draw triangles that are back-facing. Front- and back-facing triangles are determined
+ /// by the RasterizerStateDesc::FrontCounterClockwise member. \n
+ /// D3D11 counterpart: D3D11_CULL_BACK. OpenGL counterpart: GL_BACK.
+ CULL_MODE_BACK,
+
+ /// Helper value that stores the total number of cull modes in the enumeration.
+ CULL_MODE_NUM_MODES
+};
+
+// {530A181E-2777-4DAA-B837-ED7D3C28418E}
+static const Diligent::INTERFACE_ID IID_RasterizerState =
+{ 0x530a181e, 0x2777, 0x4daa, { 0xb8, 0x37, 0xed, 0x7d, 0x3c, 0x28, 0x41, 0x8e } };
+
+/// Rasterizer state description
+
+/// This structure describes the rasterizer state which is used in a call to
+/// IRenderDevice::CreateRasterizerState() to create a rasterizer state object
+struct RasterizerStateDesc : DeviceObjectAttribs
+{
+ /// Determines traingle fill mode, see Diligent::FILL_MODE for details.
+ FILL_MODE FillMode;
+
+ /// Determines traingle cull mode, see Diligent::CULL_MODE for details.
+ CULL_MODE CullMode;
+
+ /// Determines if a triangle is front- or back-facing. If this parameter is True,
+ /// a triangle will be considered front-facing if its vertices are counter-clockwise
+ /// on the render target and considered back-facing if they are clockwise.
+ /// If this parameter is False, the opposite is true.
+ Bool FrontCounterClockwise;
+
+ /// Constant value added to the depth of a given pixel.
+ Int32 DepthBias;
+
+ /// Maximum depth bias of a pixel.
+ /// \warning Depth bias clamp is not available in OpenGL
+ Float32 DepthBiasClamp;
+
+ /// Scalar that scales the given pixel's slope before adding to the pixel's depth.
+ Float32 SlopeScaledDepthBias;
+
+ /// Enable clipping based on distance.
+ /// \warning On DirectX this only disables clipping against far clipping plane,
+ /// while on OpenGL this disables clipping against both far and near clip planes.
+ Bool DepthClipEnable;
+
+ /// Enable scissor-rectangle culling. All pixels outside an active scissor rectangle are culled.
+ Bool ScissorEnable;
+
+ /// Specifies whether to enable line antialiasing.
+ Bool AntialiasedLineEnable;
+
+ /// Initializes the structure members with default values
+
+ /// Member | Default value
+ /// ----------------------|--------------
+ /// FillMode | FILL_MODE_SOLID
+ /// CullMode | CULL_MODE_BACK
+ /// FrontCounterClockwise | False
+ /// DepthBias | 0
+ /// DepthBiasClamp | 0.f
+ /// SlopeScaledDepthBias | 0.f
+ /// DepthClipEnable | True
+ /// ScissorEnable | False
+ /// AntialiasedLineEnable | False
+ RasterizerStateDesc() :
+ FillMode ( FILL_MODE_SOLID ),
+ CullMode ( CULL_MODE_BACK ),
+ FrontCounterClockwise( False ),
+ DepthBias ( 0 ),
+ DepthBiasClamp ( 0.f ),
+ SlopeScaledDepthBias ( 0.f ),
+ DepthClipEnable ( True ),
+ ScissorEnable ( False ),
+ AntialiasedLineEnable( False )
+ {
+ }
+
+
+ /// Tests if two structures are equivalent
+
+ /// \param [in] RHS - reference to the structure to perform comparison with
+ /// \return
+ /// - True if all members of the two structures are equal.
+ /// - False otherwise
+ /// The operator ignores DeviceObjectAttribs::Name field as it does not affect
+ /// the rasterizer state.
+ bool operator == (const RasterizerStateDesc& RHS)const
+ {
+ // Name is primarily used for debug purposes and does not affect the state.
+ // It is ignored in comparison operation.
+ return // strcmp(Name, RHS.Name) == 0 &&
+ FillMode == RHS.FillMode &&
+ CullMode == RHS.CullMode &&
+ FrontCounterClockwise == RHS.FrontCounterClockwise &&
+ DepthBias == RHS.DepthBias &&
+ DepthBiasClamp == RHS.DepthBiasClamp &&
+ SlopeScaledDepthBias == RHS.SlopeScaledDepthBias &&
+ DepthClipEnable == RHS.DepthClipEnable &&
+ ScissorEnable == RHS.ScissorEnable &&
+ AntialiasedLineEnable == RHS.AntialiasedLineEnable;
+ }
+};
+
+/// Rasterizer state interface
+
+/// The interface holds the rasterizer state object that can be bound to the pipeline by a call
+/// to IDeviceContext::SetRasterizerState(). To create a rasterizer state, call
+/// IRenderDevice::CreateRasterizerState().
+class IRasterizerState : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the rasterizer state description used to create the object
+ virtual const RasterizerStateDesc& GetDesc()const = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h
new file mode 100644
index 00000000..f8471e11
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/RenderDevice.h
@@ -0,0 +1,220 @@
+/* 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
+/// Definition of the Diligent::IRenderDevice interface and related data structures
+
+#include "GraphicsTypes.h"
+#include "Object.h"
+#include "DeviceCaps.h"
+#include "Constants.h"
+#include "Buffer.h"
+#include "VertexDescription.h"
+#include "Shader.h"
+#include "Texture.h"
+#include "Sampler.h"
+#include "ResourceMapping.h"
+#include "TextureView.h"
+#include "BufferView.h"
+#include "DepthStencilState.h"
+#include "RasterizerState.h"
+#include "BlendState.h"
+
+namespace Diligent
+{
+
+// {F0E9B607-AE33-4B2B-B1AF-A8B2C3104022}
+static const Diligent::INTERFACE_ID IID_RenderDevice =
+{ 0xf0e9b607, 0xae33, 0x4b2b, { 0xb1, 0xaf, 0xa8, 0xb2, 0xc3, 0x10, 0x40, 0x22 } };
+
+/**
+ * Render device interface
+ */
+class IRenderDevice : public IObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Creates a new buffer object
+
+ /// \param [in] BuffDesc - Buffer description, see Diligent::BufferDesc for details.
+ /// \param [in] BuffData - Reference to a Diligent::BufferData structure that describes
+ /// the initialization data. To allocate space only, provide default value
+ /// BufferData(). Static buffers (USAGE_STATIC) must be initialized
+ /// at creation time.
+ /// \param [out] ppBuffer - Address of the memory location where the pointer to the
+ /// buffer interface will be stored. The function calls AddRef(),
+ /// so that the new buffer will contain one refernce and must be
+ /// released by a call to Release().
+ ///
+ /// \remarks
+ /// Size of a uniform buffer (BIND_UNIFORM_BUFFER) must be multiple of 16.\n
+ /// Stride of a formatted buffer will be computed automatically from the format if
+ /// ElementByteStride member of buffer description is set to default value (0).
+ virtual void CreateBuffer(const BufferDesc& BuffDesc,
+ const BufferData& BuffData,
+ IBuffer **ppBuffer) = 0;
+
+ /// Creates a new vertex description object.
+
+ /// \param [in] LayoutDesc - Layout description, see GraphisEngine::LayoutDesc for details.
+ /// \param [in] pVertexShader - Pointer to the vertex shader which this input layout
+ /// will be used with. If layout description is not compatible
+ /// with the shader's input signature, the method fails.
+ /// \param [out] ppVertexDesc - Address of the memory location where the pointer to the
+ /// vertex description interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one refernce.
+ /// \remark The same vertex description object can be used with all shaders that have
+ /// the same input semantic.
+ virtual void CreateVertexDescription( const LayoutDesc& LayoutDesc,
+ IShader *pVertexShader,
+ IVertexDescription **ppVertexDesc ) = 0;
+
+ /// Creates a new shader object
+
+ /// \param [in] CreationAttribs - Shader creation attributes, see
+ /// Diligent::ShaderCreationAttribs for details.
+ /// \param [out] ppShader - Address of the memory location where the pointer to the
+ /// shader interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one refernce.
+ virtual void CreateShader(const ShaderCreationAttribs &CreationAttribs,
+ IShader **ppShader) = 0;
+
+ /// Creates a new texture object
+
+ /// \param [in] TexDesc - Texture description, see Diligent::TextureDesc for details.
+ /// \param [in] Data - Reference to a Diligent::TextureData structure that describes
+ /// the initialization data. To allocate space only, provide default value
+ /// TextureData(). Static textures (USAGE_STATIC) must be initialized
+ /// at creation time.
+ /// \param [out] ppTexture - Address of the memory location where the pointer to the
+ /// texture interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one refernce.
+ /// \remarks
+ /// To create all mip levels, set the TexDesc.MipLevels to zero.\n
+ /// Multisampled resources cannot be initialzed with data when they are created. \n
+ /// If initial data is provided, number of subresources must exactly match the number
+ /// of subresources in the texture (which is the number of mip levels times the number of array slices.
+ /// For a 3D texture, this is just the number of mip levels).
+ /// For example, for a 15 x 6 x 2 2D texture array, the following array of subresources should be
+ /// provided: \n
+ /// 15x6, 7x3, 3x1, 1x1, 15x6, 7x3, 3x1, 1x1.\n
+ /// For a 15 x 6 x 4 3D texture, the following array of subresources should be provided:\n
+ /// 15x6x4, 7x3x2, 3x1x1, 1x1x1
+ virtual void CreateTexture(const TextureDesc& TexDesc,
+ const TextureData &Data,
+ ITexture **ppTexture) = 0;
+
+ /// Creates a new sampler object
+
+ /// \param [in] SamDesc - Sampler description, see Diligent::SamplerDesc for details.
+ /// \param [out] ppSampler - Address of the memory location where the pointer to the
+ /// sampler interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one refernce.
+ /// \remark If an application attempts to create a sampler interface with the same attributes
+ /// as an existing interface, the same interface will be returned.
+ /// \note In D3D11, 4096 unique sampler state objects can be created on a device at a time.
+ virtual void CreateSampler(const SamplerDesc& SamDesc,
+ ISampler **ppSampler) = 0;
+
+ /// Creates a new resource mapping
+
+ /// \param [in] MappingDesc - Resource mapping description, see Diligent::ResourceMappingDesc for details.
+ /// \param [out] ppMapping - Address of the memory location where the pointer to the
+ /// resource mapping interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one refernce.
+ virtual void CreateResourceMapping( const ResourceMappingDesc &MappingDesc,
+ IResourceMapping **ppMapping ) = 0;
+
+ /// Creates a new depth stencil state object
+
+ /// \param [in] DSSDesc - Depth-stencil state description, see Diligent::DepthStencilStateDesc for details.
+ /// \param [out] ppDepthStencilState - Address of the memory location where the pointer to the
+ /// depth-stencil state interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one refernce.
+ /// \remark If an application attempts to create a depth-stencil state interface with the same attributes
+ /// as an existing interface, the same interface will be returned.
+ /// \note In D3D11, 4096 unique depth-stencil state objects can be created on a device at a time.
+ virtual void CreateDepthStencilState( const DepthStencilStateDesc &DSSDesc,
+ IDepthStencilState **ppDepthStencilState ) = 0;
+
+ /// Creates a rasterizer state object
+
+ /// \param [in] RSDesc - Rasterizer state description, see Diligent::RasterizerStateDesc for details.
+ /// \param [out] ppRasterizerState - Address of the memory location where the pointer to the
+ /// rasterizer state interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one refernce.
+ /// \remark If an application attempts to create a rasterizer state interface with the same attributes
+ /// as an existing interface, the same interface will be returned.
+ /// \note In D3D11, 4096 unique rasterizer state objects can be created on a device at a time.
+ virtual void CreateRasterizerState( const RasterizerStateDesc &RSDesc,
+ IRasterizerState **ppRasterizerState ) = 0;
+
+ /// Creates a blend state object
+
+ /// \param [in] BSDesc - Blend state description, see Diligent::BlendStateDesc for details.
+ /// \param [out] ppBlendState - Address of the memory location where the pointer to the
+ /// blend state interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
+ /// one refernce.
+ /// \remark If an application attempts to create a blend state interface with the same attributes
+ /// as an existing interface, the same interface will be returned.
+ /// \note In D3D11, 4096 unique blend state objects can be created on a device at a time.
+ virtual void CreateBlendState( const BlendStateDesc &BSDesc,
+ IBlendState **ppBlendState ) = 0;
+
+ /// Gets the device capabilities, see Diligent::DeviceCaps for details
+ virtual const DeviceCaps& GetDeviceCaps()const = 0;
+
+ /// Returns the basic texture format information.
+
+ /// See Diligent::TextureFormatInfo for details on the provided information.
+ /// \param [in] TexFormat - Texture format for which to provide the information
+ /// \return Const reference to the TextureFormatInfo structure containing the
+ /// texture format description.
+ virtual const TextureFormatInfo &GetTextureFormatInfo( TEXTURE_FORMAT TexFormat ) = 0;
+
+
+ /// Returns the extended texture format information.
+
+ /// See Diligent::TextureFormatInfoExt for details on the provided information.
+ /// \param [in] TexFormat - Texture format for which to provide the information
+ /// \return Const reference to the TextureFormatInfoExt structure containing the
+ /// extended texture format description.
+ /// \remark The first time this method is called for a particular format, it may be
+ /// considerably slower than GetTextureFormatInfo(). If you do not require
+ /// extended information, call GetTextureFormatInfo() instead.
+ virtual const TextureFormatInfoExt &GetTextureFormatInfoExt( TEXTURE_FORMAT TexFormat ) = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/ResourceMapping.h b/Graphics/GraphicsEngine/interface/ResourceMapping.h
new file mode 100644
index 00000000..f4ee7a17
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/ResourceMapping.h
@@ -0,0 +1,118 @@
+/* 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
+/// Definition of the Diligent::IResourceMapping interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+ // {6C1AC7A6-B429-4139-9433-9E54E93E384A}
+ static const Diligent::INTERFACE_ID IID_ResourceMapping =
+ { 0x6c1ac7a6, 0xb429, 0x4139, { 0x94, 0x33, 0x9e, 0x54, 0xe9, 0x3e, 0x38, 0x4a } };
+
+ /// Describes the resourse mapping object entry
+ struct ResourceMappingEntry
+ {
+ /// Object name
+ const Char* Name;
+
+ /// Pointer to the object's interface
+ IDeviceObject *pObject;
+
+ /// Initializes the structure members
+
+ /// \param [in] InitName - Object name. Default value is nullptr
+ /// \param [in] pInitObject - Pointer to the object. Default value is nullptr
+ ResourceMappingEntry( const Char* InitName = nullptr, IDeviceObject *pInitObject = nullptr) :
+ Name( InitName ),
+ pObject( pInitObject )
+ {}
+ };
+
+ /// Resource mapping description
+ struct ResourceMappingDesc
+ {
+ /// Pointer to the array of resource mapping entries.
+ /// The last element in the array must be default value
+ /// created by ResourceMappingEntry::ResourceMappingEntry()
+ ResourceMappingEntry *pEntries;
+
+ /// Initializes the structure members with default values
+
+ /// Member | Default value
+ /// ----------------------|--------------
+ /// pEntries | nullptr
+ ResourceMappingDesc() : pEntries( nullptr ){}
+ };
+
+ /// Resouce mapping
+
+ /// This interface provides mapping between literal names and resource pointers.
+ /// It is created by IRenderDevice::CreateResourceMapping().
+ /// \remarks Resource mapping holds strong references to all objects it keeps.
+ class IResourceMapping : public IObject
+ {
+ public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Adds a resource to the mapping.
+
+ /// \param [in] Name - Resource name.
+ /// \param [in] pObject - Pointer to the object.
+ /// \param [in] bIsUnique - Flag indicating if a resource with the same name
+ /// is allowed to be found in the mapping. In the latter
+ /// case, the new resource replaces the existing one.
+ ///
+ /// \remarks Resource mapping increases the reference counter for referenced objects. So an
+ /// object will not be released as long as it is in the resource mapping.
+ virtual void AddResource( const Char *Name, IDeviceObject *pObject, bool bIsUnique ) = 0;
+
+ /// Removes a resource from the mapping.
+
+ /// \param [in] pObject - Pointer to the object to remove.
+ virtual void RemoveResource( IDeviceObject *pObject ) = 0;
+
+ /// Removes a resource from the mapping using its literal name.
+
+ /// \param [in] Name - Name of the resource to remove.
+ virtual void RemoveResourceByName( const Char *Name ) = 0;
+
+ /// Finds a resource in the mapping.
+
+ /// \param [in] Name - Resource name.
+ /// \param [out] ppResource - Address of the memory location where the pointer
+ /// to the object with the given name will be written.
+ /// If no object is found, nullptr will be written.
+ /// \remarks The method increases the reference counter
+ /// of the returned object, so Release() must be called.
+ virtual void GetResource( const Char *Name, IDeviceObject **ppResource ) = 0;
+
+ /// Returns the size of the resource mapping, i.e. the number of objects.
+ virtual size_t GetSize() = 0;
+ };
+}
diff --git a/Graphics/GraphicsEngine/interface/Sampler.h b/Graphics/GraphicsEngine/interface/Sampler.h
new file mode 100644
index 00000000..52742b3c
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/Sampler.h
@@ -0,0 +1,174 @@
+/* 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
+/// Definition of the Diligent::ISampler interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+// {595A59BF-FA81-4855-BC5E-C0E048745A95}
+static const Diligent::INTERFACE_ID IID_Sampler =
+{ 0x595a59bf, 0xfa81, 0x4855, { 0xbc, 0x5e, 0xc0, 0xe0, 0x48, 0x74, 0x5a, 0x95 } };
+
+/// Sampler description
+
+/// This structure describes the sampler state which is used in a call to
+/// IRenderDevice::CreateSampler() to create a sampler object.
+///
+/// To create an anisotropic filter, all three filters must either be Diligent::FILTER_TYPE_ANISOTROPIC
+/// or Diligent::FILTER_TYPE_COMPARISON_ANISOTROPIC.
+///
+/// MipFilter cannot be comparison filter except for Diligent::FILTER_TYPE_ANISOTROPIC if all
+/// three filters have that value.
+///
+/// Both MinFilter and MagFilter must either be regular filters or comparison filters.
+/// Mixing comparison and regular filters is an error.
+struct SamplerDesc : DeviceObjectAttribs
+{
+ /// Texture minification filter, see Diligent::FILTER_TYPE for details.
+ FILTER_TYPE MinFilter;
+
+ /// Texture magnification filter, see Diligent::FILTER_TYPE for details.
+ FILTER_TYPE MagFilter;
+
+ /// Mip filter, see Diligent::FILTER_TYPE for details.
+ /// Only FILTER_TYPE_POINT, FILTER_TYPE_LINEAR, FILTER_TYPE_ANISOTROPIC, and
+ /// FILTER_TYPE_COMPARISON_ANISOTROPIC are allowed.
+ FILTER_TYPE MipFilter;
+
+ /// Texture address mode for U coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details
+ TEXTURE_ADDRESS_MODE AddressU;
+
+ /// Texture address mode for V coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details
+ TEXTURE_ADDRESS_MODE AddressV;
+
+ /// Texture address mode for W coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details
+ TEXTURE_ADDRESS_MODE AddressW;
+
+ /// Offset from the calculated mipmap level. For example, if a sampler calculates that a texture
+ /// should be sampled at mipmap level 1.2 and MipLODBias is 2.3, then the texture will be sampled at
+ /// mipmap level 3.5.
+ Float32 MipLODBias;
+
+ /// Maximum anisotropy level for the anisotropic filter.
+ Uint32 MaxAnisotropy;
+
+ /// A function that compares sampled data against existing sampled data when comparsion
+ /// filter is used.
+ COMPARISON_FUNCTION ComparisonFunc;
+
+ /// Border color to use if TEXTURE_ADDRESS_BORDER is specified for AddressU, AddressV, or AddressW.
+ Float32 BorderColor[4];
+
+ /// Specifies the minimum value that LOD is clamped to before accessing the texture MIP levels.
+ /// Must be less than or equal to MaxLOD.
+ float MinLOD;
+
+ /// Specifies the maximum value that LOD is clamped to before accessing the texture MIP levels.
+ /// Must be greater than or equal to MinLOD.
+ float MaxLOD;
+
+ /// Initializes the structure members with default values
+
+ /// Member | Default value
+ /// --------------------|--------------
+ /// MinFilter | FILTER_TYPE_LINEAR
+ /// MagFilter | FILTER_TYPE_LINEAR
+ /// MipFilter | FILTER_TYPE_LINEAR
+ /// AddressU | TEXTURE_ADDRESS_CLAMP
+ /// AddressV | TEXTURE_ADDRESS_CLAMP
+ /// AddressW | TEXTURE_ADDRESS_CLAMP
+ /// MipLODBias | 0
+ /// MaxAnisotropy | 0
+ /// ComparisonFunc | COMPARISON_FUNC_NEVER
+ /// BorderColor | (0,0,0,0)
+ /// MinLOD | 0
+ /// MaxLOD | +FLT_MAX
+ SamplerDesc() :
+ MinFilter(FILTER_TYPE_LINEAR),
+ MagFilter(FILTER_TYPE_LINEAR),
+ MipFilter(FILTER_TYPE_LINEAR),
+ AddressU(TEXTURE_ADDRESS_CLAMP),
+ AddressV(TEXTURE_ADDRESS_CLAMP),
+ AddressW(TEXTURE_ADDRESS_CLAMP),
+ MipLODBias(0),
+ MaxAnisotropy(0),
+ ComparisonFunc(COMPARISON_FUNC_NEVER),
+ MinLOD(0),
+ MaxLOD(+FLT_MAX)
+ {
+ BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0;
+ }
+
+ /// Tests if two structures are equivalent
+
+ /// \param [in] RHS - reference to the structure to perform comparison with
+ /// \return
+ /// - True if all members of the two structures are equal.
+ /// - False otherwise.
+ /// The operator ignores DeviceObjectAttribs::Name field as it does not affect
+ /// the sampler state.
+ bool operator ==(const SamplerDesc& RHS)const
+ {
+ // Name is primarily used for debug purposes and does not affect the state.
+ // It is ignored in comparison operation.
+ return // strcmp(Name, RHS.Name) == 0 &&
+ MinFilter == RHS.MinFilter &&
+ MagFilter == RHS.MagFilter &&
+ MipFilter == RHS.MipFilter &&
+ AddressU == RHS.AddressU &&
+ AddressV == RHS.AddressV &&
+ AddressW == RHS.AddressW &&
+ MipLODBias == RHS.MipLODBias &&
+ MaxAnisotropy == RHS.MaxAnisotropy &&
+ ComparisonFunc == RHS.ComparisonFunc &&
+ BorderColor[0] == RHS.BorderColor[0] &&
+ BorderColor[1] == RHS.BorderColor[1] &&
+ BorderColor[2] == RHS.BorderColor[2] &&
+ BorderColor[3] == RHS.BorderColor[3] &&
+ MinLOD == RHS.MinLOD &&
+ MaxLOD == RHS.MaxLOD;
+ }
+};
+
+/// Texture sampler interface.
+
+/// The interface holds the sampler state that can be used to perform texture filtering.
+/// To create a sampler, call IRenderDevice::CreateSampler(). To use a sampler,
+/// call ITextureView::SetSampler().
+class ISampler : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the sampler description used to create the object
+ virtual const SamplerDesc& GetDesc()const = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h
new file mode 100644
index 00000000..61861648
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/Shader.h
@@ -0,0 +1,208 @@
+/* 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
+/// Definition of the Diligent::IShader interface and related data structures
+
+#include "DeviceObject.h"
+#include "ResourceMapping.h"
+#include "FileStream.h"
+
+namespace Diligent
+{
+
+// {2989B45C-143D-4886-B89C-C3271C2DCC5D}
+static const Diligent::INTERFACE_ID IID_Shader =
+{ 0x2989b45c, 0x143d, 0x4886, { 0xb8, 0x9c, 0xc3, 0x27, 0x1c, 0x2d, 0xcc, 0x5d } };
+
+// {0D57DF3F-977D-4C8F-B64C-6675814BC80C}
+static const Diligent::INTERFACE_ID IID_ShaderVariable =
+{ 0xd57df3f, 0x977d, 0x4c8f, { 0xb6, 0x4c, 0x66, 0x75, 0x81, 0x4b, 0xc8, 0xc } };
+
+/// Describes the shader type
+enum SHADER_TYPE : Int32
+{
+ SHADER_TYPE_UNKNOWN = 0x000, ///< Unknown shader type
+ SHADER_TYPE_VERTEX = 0x001, ///< Vertex shader
+ SHADER_TYPE_PIXEL = 0x002, ///< Pixel (fragment) shader
+ SHADER_TYPE_GEOMETRY = 0x004, ///< Geometry shader
+ SHADER_TYPE_HULL = 0x008, ///< Hull (tessellation control) shader
+ SHADER_TYPE_DOMAIN = 0x010, ///< Domain (tessellation evaluation) shader
+ SHADER_TYPE_COMPUTE = 0x020 ///< Compute shader
+};
+
+enum SHADER_PROFILE : Int32
+{
+ SHADER_PROFILE_DEFAULT = 0,
+ SHADER_PROFILE_DX_4_0,
+ SHADER_PROFILE_DX_5_0,
+ SHADER_PROFILE_GL_4_2
+};
+
+enum SHADER_SOURCE_LANGUAGE : Int32
+{
+ SHADER_SOURCE_LANGUAGE_DEFAULT = 0,
+ SHADER_SOURCE_LANGUAGE_HLSL,
+ SHADER_SOURCE_LANGUAGE_GLSL
+};
+
+/// Describes flags that can be supplied to IShader::BindResources()
+/// and IDeviceContext::BindShaderResources().
+enum BIND_SHADER_RESOURCES_FLAGS : Int32
+{
+ /// Reset all bindings. If this specified, all existing bindings will be
+ /// broken. By default all existing bindings are presereved.
+ BIND_SHADER_RESOURCES_RESET_BINDINGS = 0x01,
+
+ /// If this flag is specified, only unresolved bindings will be updated.
+ /// All resolved bindings will keep their original values.
+ /// If this flag is not specified, every shader variable will be
+ /// updated if the mapping contains corresponding resource.
+ BIND_SHADER_RESOURCES_UPDATE_UNRESOLVED = 0x02,
+
+ /// If this flag is specified, all shader bindings are expected
+ /// to be resolved after the call. If this is not the case, debug error
+ /// will be output.
+ BIND_SHADER_RESOURCES_ALL_RESOLVED = 0x04
+};
+
+/// Shader description
+struct ShaderDesc : DeviceObjectAttribs
+{
+ /// Shader type. See Diligent::SHADER_TYPE
+ SHADER_TYPE ShaderType;
+
+ Bool bCacheCompiledShader;
+ SHADER_PROFILE TargetProfile;
+
+ ShaderDesc() :
+ ShaderType(SHADER_TYPE_VERTEX),
+ bCacheCompiledShader(False),
+ TargetProfile(SHADER_PROFILE_DEFAULT)
+ {}
+};
+
+/// Shader source stream factory interface
+class IShaderSourceInputStreamFactory
+{
+public:
+ virtual void CreateInputStream(const Diligent::Char *Name, IFileStream **ppStream) = 0;
+};
+
+struct ShaderMacro
+{
+ const Char* Name;
+ const Char* Definition;
+ ShaderMacro(const Char* _Name, const Char* _Def) : Name( _Name ), Definition( _Def ) {}
+};
+
+/// Shader creation attributes
+struct ShaderCreationAttribs
+{
+ /// Source file path
+ const Char* FilePath;
+
+ /// Pointer to the shader source input stream factory.
+ /// The factory is used to create additional input streams for
+ /// shader include files
+ IShaderSourceInputStreamFactory *pShaderSourceStreamFactory;
+
+ /// Shader source
+ const Char* Source;
+
+ /// Shader entry point
+ const Char* EntryPoint;
+
+ /// Semicolon-separated list of include search directories.
+ const Char* SearchDirectories;
+
+ /// Shader macros
+ const ShaderMacro *Macros;
+
+ /// Shader description. See Diligent::ShaderDesc.
+ ShaderDesc Desc;
+
+ /// Shader source language. See Diligent::SHADER_SOURCE_LANGUAGE.
+ SHADER_SOURCE_LANGUAGE SourceLanguage;
+
+ ShaderCreationAttribs() :
+ FilePath( nullptr ),
+ Source( nullptr ),
+ pShaderSourceStreamFactory( nullptr ),
+ EntryPoint("main"),
+ SearchDirectories(nullptr),
+ Macros(nullptr),
+ SourceLanguage(SHADER_SOURCE_LANGUAGE_DEFAULT)
+ {}
+};
+
+
+/// Shader resource variable
+class IShaderVariable : public IObject
+{
+public:
+ /// Sets the variable to the given value
+
+ /// \remark The method performs run-time correctness checks.
+ /// For instance, shader resource view cannot
+ /// be assigned to a constant buffer variable.
+ virtual void Set(IDeviceObject *pObject) = 0;
+
+ /// Returns the shader which this shader variable
+ /// belongs to
+
+ /// \remark The method does not increment the reference counter
+ /// of the returned interface.
+ virtual class IShader* GetShader() = 0;
+};
+
+/// Shader interface
+class IShader : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the shader description
+ virtual const ShaderDesc &GetDesc()const = 0;
+
+ /// Binds shader resources.
+ /// \param [in] pResourceMapping - Pointer to IResourceMapping interface to
+ /// look for resources.
+ /// \param [in] Flags - Additional flags for the operation. See
+ /// Diligent::BIND_SHADER_RESOURCES_FLAGS for details.
+ /// \remark The shader will keep strong references to all resources bound to it.
+ virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags ) = 0;
+
+ /// Returns an interface to a shader variable. If the shader variable
+ /// is not found, an interface to a dummy variable will be returned.
+
+ /// \param [in] Name - Name of the variable.
+ /// \remark The method does not increment the reference counter
+ /// of the returned interface.
+ virtual IShaderVariable* GetShaderVariable(const Char* Name) = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/SwapChain.h b/Graphics/GraphicsEngine/interface/SwapChain.h
new file mode 100644
index 00000000..c451bbf6
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/SwapChain.h
@@ -0,0 +1,58 @@
+/* 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
+/// Definition of the Diligent::ISwapChain interface and related data structures
+
+#include "Object.h"
+
+namespace Diligent
+{
+
+// {1C703B77-6607-4EEC-B1FE-15C82D3B4130}
+static const Diligent::INTERFACE_ID IID_SwapChain =
+{ 0x1c703b77, 0x6607, 0x4eec, { 0xb1, 0xfe, 0x15, 0xc8, 0x2d, 0x3b, 0x41, 0x30 } };
+
+/// Swap chain interface
+
+/// The swap chain is created by a platform-dependent function
+class ISwapChain : public IObject
+{
+public:
+
+ /// Presents a rendered image to the user.
+ virtual void Present() = 0;
+
+ /// Returns the swap chain desctription
+ virtual const SwapChainDesc& GetDesc()const = 0;
+
+ /// Changes the swap chain's back buffer size
+
+ /// \param [in] NewWidth - New swap chain width, in pixels
+ /// \param [in] NewHeight - New swap chain height, in pixels
+ virtual void Resize( Uint32 NewWidth, Uint32 NewHeight ) = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/Texture.h b/Graphics/GraphicsEngine/interface/Texture.h
new file mode 100644
index 00000000..de352a3c
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/Texture.h
@@ -0,0 +1,254 @@
+/* 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
+/// Definition of the Diligent::ITexture interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+// {A64B0E60-1B5E-4CFD-B880-663A1ADCBE98}
+static const Diligent::INTERFACE_ID IID_Texture =
+{ 0xa64b0e60, 0x1b5e, 0x4cfd, { 0xb8, 0x80, 0x66, 0x3a, 0x1a, 0xdc, 0xbe, 0x98 } };
+
+/// Texture description
+struct TextureDesc : DeviceObjectAttribs
+{
+ /// Texture type. See Diligent::TEXTURE_TYPE for details.
+ TEXTURE_TYPE Type;
+
+ /// Texture width, in pixels.
+ Uint32 Width;
+
+ /// Texture height, in pixels.
+ Uint32 Height;
+ union
+ {
+ /// For a 1D array or 2D array, number of array slices
+ Uint32 ArraySize;
+
+ /// For a 3D texture, number of depth slices
+ Uint32 Depth;
+ };
+
+ /// Texture format, see Diligent::TEXTURE_FORMAT.
+ TEXTURE_FORMAT Format;
+
+ /// Number of Mip levels in the texture. Multisampled textures can only have 1 Mip level.
+ /// Specify 0 to generate full mipmap chain.
+ Uint32 MipLevels;
+
+ /// Number of samples.\n
+ /// Only 2D textures or 2D texture arrays can be multisampled.
+ Uint32 SampleCount;
+
+ /// Texture usage. See Diligent::USAGE for details.
+ USAGE Usage;
+
+ /// Bind flags, see Diligent::BIND_FLAGS for details. \n
+ /// The following bind flags are allowed:
+ /// Diligent::BIND_SHADER_RESOURCE, Diligent::BIND_RENDER_TARGET, Diligent::BIND_DEPTH_STENCIL,
+ /// Diligent::and BIND_UNORDERED_ACCESS. \n
+ /// Multisampled textures cannot have Diligent::BIND_UNORDERED_ACCESS flag set
+ Uint32 BindFlags;
+
+ /// CPU access flags or 0 if no CPU access is allowed,
+ /// see Diligent::CPU_ACCESS_FLAG for details.
+ Uint32 CPUAccessFlags;
+
+
+ /// Miscellaneous flags, see Diligent::MISC_TEXTURE_FLAG for details.
+ Uint32 MiscFlags;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// ----------------|--------------
+ /// Type | TEXTURE_TYPE_UNDEFINED
+ /// Width | 0
+ /// Height | 0
+ /// ArraySize | 1
+ /// Format | TEX_FORMAT_UNKNOWN
+ /// MipLevels | 1
+ /// SampleCount | 1
+ /// Usage | USAGE_DEFAULT
+ /// BindFlags | 0
+ /// CPUAccessFlags | 0
+ /// MiscFlags | 0
+ TextureDesc() :
+ Type(TEXTURE_TYPE_UNDEFINED),
+ Width(0),
+ Height(0),
+ ArraySize(1),
+ Format(TEX_FORMAT_UNKNOWN),
+ MipLevels(1),
+ SampleCount(1),
+ Usage(USAGE_DEFAULT),
+ BindFlags(0),
+ CPUAccessFlags(0),
+ MiscFlags(0)
+ {
+ }
+};
+
+/// Describes data for one subresource
+struct TextureSubResData
+{
+ /// Pointer to the subresource data
+ const void* pData;
+
+ /// For 2D and 3D textures, row stride in bytes
+ Uint32 Stride;
+
+ /// For 3D textures, depth slice stride in bytes
+ /// \note On OpenGL, this must be a mutliple of Stride
+ Uint32 DepthStride;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// ----------------|--------------
+ /// pData | nullptr
+ /// Stride | 0
+ /// DepthStride | 0
+ TextureSubResData():
+ pData(nullptr),
+ Stride(0),
+ DepthStride(0)
+ {}
+};
+
+/// Describes the initial data to store in the texture
+struct TextureData
+{
+ /// Pointer to the array of the TextureSubResData elements containing
+ /// information about each subresource.
+ TextureSubResData *pSubResources;
+
+ /// Number of elements in pSubResources array.
+ /// NumSubresources must exactly match the number
+ /// of subresources in the texture. Otherwise an error
+ /// occurs.
+ Uint32 NumSubresources;
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// ----------------|--------------
+ /// pSubResources | nullptr
+ /// NumSubresources | 0
+ TextureData() :
+ pSubResources(nullptr),
+ NumSubresources(0)
+ {}
+};
+
+/// Texture inteface
+class ITexture : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the texture description used to create the object
+ virtual const TextureDesc& GetDesc()const = 0;
+
+ /// Creates a new texture view
+
+ /// \param [in] ViewDesc - View description. See Diligent::TextureViewDesc for details.
+ /// \param [out] ppView - Address of the memory location where the pointer to the view interface will be written to.
+ ///
+ /// \remarks To create a shader resource view addressing the entire texture, set only TextureViewDesc::ViewType
+ /// member of the ViewDesc parameter to Diligent::TEXTURE_VIEW_SHADER_RESOURCE and leave all other
+ /// members in their default values. Using the same method, you can create render target or depth stencil
+ /// view addressing the largest mip level.\n
+ /// If texture view format is Diligent::TEX_FORMAT_UNKNOWN, the view format will match the texture format.\n
+ /// If texture view type is Diligent::TEXTURE_VIEW_UNDEFINED, the type will match the texture type.\n
+ /// If the number of mip levels is 0, and the view type is shader resource, the view will address all mip levels.
+ /// For other view types it will address one mip level.\n
+ /// If the number of slices is 0, all slices from FirstArraySlice or FirstDepthSlice will be referenced by the view.
+ /// For non-array textures, the only allowed values for the number of slices are 0 and 1.\n
+ /// Texture view will contain strong reference to the texture, so the texture will not be destroyed
+ /// until all views are released.\n
+ /// The function calls AddRef() for the created interface, so it must be released by
+ /// a call to Release() when it is no longer needed.
+ virtual void CreateView(const struct TextureViewDesc &ViewDesc, class ITextureView **ppView) = 0;
+
+ /// Returns the pointer to the default view.
+
+ /// \param [in] ViewType - Type of the requested view. See Diligent::TEXTURE_VIEW_TYPE.
+ /// \return Pointer to the interface
+ ///
+ /// \note The function does not increase the reference counter for the returned interface, so
+ /// Release() must *NOT* be called.
+ virtual ITextureView* GetDefaultView( TEXTURE_VIEW_TYPE ViewType ) = 0;
+
+ /// Updates the data in the texture
+
+ /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
+ /// \param [in] MipLevel - Mip level of the texture subresource to update.
+ /// \param [in] Slice - Array slice. Should be 0 for non-array textures.
+ /// \param [in] DstBox - Destination region on the texture to update.
+ /// \param [in] SubresData - Source data to copy to the texture.
+ virtual void UpdateData( class IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) = 0;
+
+ /// Copies data from another texture
+
+ /// \param [in] pContext - Pointer to the device context interface to be used to perform the operation.
+ /// \param [in] pSrcTexture - Source texture for the copy operation
+ /// \param [in] SrcMipLevel - Mip level of the source texture to copy data from.
+ /// \param [in] SrcSlice - Array slice of the source texture to copy data from.
+ /// Should be 0 for non-array textures.
+ /// \param [in] pSrcBox - Source region to copy.
+ /// Use nullptr to copy the entire subresource.
+ /// \param [in] DstMipLevel - Mip level to copy data to.
+ /// \param [in] DstSlice - Array slice to copy data to.
+ /// Must be 0 for non-array textures.
+ /// \param [in] DstX - X offset on the destination subresource
+ /// \param [in] DstY - Y offset on the destination subresource
+ /// \param [in] DstZ - Z offset on the destination subresource
+ virtual void CopyData(IDeviceContext *pContext,
+ ITexture *pSrcTexture,
+ Uint32 SrcMipLevel,
+ Uint32 SrcSlice,
+ const Box *pSrcBox,
+ Uint32 DstMipLevel,
+ Uint32 DstSlice,
+ Uint32 DstX,
+ Uint32 DstY,
+ Uint32 DstZ) = 0;
+
+ /// Map the texture - not implemented yet
+ virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData ) = 0;
+ /// Unmap the textute - not implemented yet
+ virtual void Unmap( IDeviceContext *pContext ) = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/TextureView.h b/Graphics/GraphicsEngine/interface/TextureView.h
new file mode 100644
index 00000000..b55e2f0e
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/TextureView.h
@@ -0,0 +1,198 @@
+/* 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
+/// Definition of the Diligent::ITextureView interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+// {5B2EA04E-8128-45E4-AA4D-6DC7E70DC424}
+static const Diligent::INTERFACE_ID IID_TextureView =
+{ 0x5b2ea04e, 0x8128, 0x45e4, { 0xaa, 0x4d, 0x6d, 0xc7, 0xe7, 0xd, 0xc4, 0x24 } };
+
+/// Describes allowed unordered access view mode
+enum UAV_ACCESS_FLAG : Int32
+{
+ /// Access mode is unspecified
+ UAV_ACCESS_UNSPECIFIED = 0x00,
+
+ /// Allow read operations on the UAV
+ UAV_ACCESS_FLAG_READ = 0x01,
+
+ /// Allow write operations on the UAV
+ UAV_ACCESS_FLAG_WRITE = 0x02,
+
+ /// Allow read and write operations on the UAV
+ UAV_ACCESS_FLAG_READ_WRITE = UAV_ACCESS_FLAG_READ | UAV_ACCESS_FLAG_WRITE
+};
+
+/// Texture view description
+struct TextureViewDesc : DeviceObjectAttribs
+{
+ /// Describes the texture view type, see Diligent::TEXTURE_VIEW_TYPE for details.
+ TEXTURE_VIEW_TYPE ViewType;
+
+ /// View interpretation of the original texture. For instance,
+ /// one slice of a 2D texture array can be viewed as a 2D texture.
+ /// See Diligent::TEXTURE_TYPE for a list of texture types.
+ /// If default value Diligent::TEXTURE_TYPE_UNDEFINED is provided,
+ /// the view type will match the type of the referenced texture.
+ TEXTURE_TYPE TextureType;
+
+ /// View format. If default value Diligent::TEX_FORMAT_UNKNOWN is provided,
+ /// the view format will match the referenced texture format.
+ TEXTURE_FORMAT Format;
+
+ /// Most detailed mip level to use
+ Uint32 MostDetailedMip;
+
+ /// Total number of mip levels for the view of the texture.
+ /// Render target and depth stencil views can address only one mip level.
+ /// If 0 is provided, then for a shader resource view all mip levels will be
+ /// referenced, and for a render target or a depth stencil view, one mip level
+ /// will be referenced.
+ Uint32 NumMipLevels;
+
+ union
+ {
+ /// For a texture array, first array slice to address in the view
+ Uint32 FirstArraySlice;
+
+ /// For a 3D texture, first depth slice to address the view
+ Uint32 FirstDepthSlice;
+ };
+
+ union
+ {
+ /// For a texture array, number of array slices to address in the view.
+ /// Set to 0 to address all array slices.
+ Uint32 NumArraySlices;
+
+ /// For a 3D texture, number of depth slices to address in the view
+ /// Set to 0 to address all depth slices.
+ Uint32 NumDepthSlices;
+ };
+
+ /// For an unordered access view, allowed access flags. See Diligent::UAV_ACCESS_FLAG
+ /// for details.
+ Uint32 AccessFlags;
+
+
+ /// Initializes the structure members with default values
+
+ /// Default values:
+ /// Member | Default value
+ /// --------------------|--------------
+ /// ViewType | TEXTURE_VIEW_UNDEFINED
+ /// TextureType | TEXTURE_TYPE_UNDEFINED
+ /// Format | TEX_FORMAT_UNKNOWN
+ /// MostDetailedMip | 0
+ /// NumMipLevels | 0
+ /// FirstArraySlice | 0
+ /// NumArraySlices | 0
+ /// AccessFlags | 0
+ TextureViewDesc() :
+ ViewType( TEXTURE_VIEW_UNDEFINED ),
+ TextureType( TEXTURE_TYPE_UNDEFINED ),
+ Format(TEX_FORMAT_UNKNOWN),
+ MostDetailedMip(0),
+ NumMipLevels(0),
+ FirstArraySlice(0),
+ NumArraySlices(0),
+ AccessFlags(0)
+ {
+ }
+
+ /// Tests if two structures are equivalent
+
+ /// \param [in] RHS - reference to the structure to perform comparison with
+ /// \return
+ /// - True if all members of the two structures are equal.
+ /// - False otherwise
+ bool operator == (const TextureViewDesc& RHS)const
+ {
+ // Name is primarily used for debug purposes and does not affect the view.
+ // It is ignored in comparison operation.
+ return //strcmp(Name, RHS.Name) == 0 &&
+ ViewType == RHS.ViewType &&
+ TextureType == RHS.TextureType &&
+ Format == RHS.Format &&
+ MostDetailedMip == RHS.MostDetailedMip &&
+ NumMipLevels == RHS.NumMipLevels &&
+ FirstArraySlice == RHS.FirstArraySlice &&
+ FirstDepthSlice == RHS.FirstDepthSlice &&
+ NumArraySlices == RHS.NumArraySlices &&
+ NumDepthSlices == RHS.NumDepthSlices &&
+ AccessFlags == RHS.AccessFlags;
+ }
+};
+
+/// Texture view interface
+
+/// \remarks
+/// To create a texture view, call ITexture::CreateView().
+/// Texture view holds strong references to the texture. The texture
+/// will not be destroyed until all views are released.
+/// The texture view will also keep a strong reference to the texture sampler,
+/// if any is set.
+class ITextureView : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns the texture view description used to create the object
+ virtual const TextureViewDesc& GetDesc()const = 0;
+
+ /// Sets the texture sampler to use for filtering operations
+ /// when accessing a texture from shaders. Only
+ /// shader resource views can be assigned a sampler.
+ /// The view will keep strong reference to the sampler.
+ virtual void SetSampler( class ISampler *pSampler ) = 0;
+
+ /// Returns the pointer to the sampler object set by the ITextureView::SetSampler().
+
+ /// The method does *NOT* call AddRef() on the returned interface,
+ /// so Release() must not be called.
+ virtual ISampler* GetSampler() = 0;
+
+
+ /// Returns the pointer to the referenced texture object.
+
+ /// The method does *NOT* call AddRef() on the returned interface,
+ /// so Release() must not be called.
+ virtual class ITexture* GetTexture() = 0;
+
+ /// Generates a mipmap chain
+
+ /// \remarks This function can only be called for a shader resource view
+ /// The texture must be created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag
+ virtual void GenerateMips(IDeviceContext *pContext ) = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/VertexDescription.h b/Graphics/GraphicsEngine/interface/VertexDescription.h
new file mode 100644
index 00000000..4883ab40
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/VertexDescription.h
@@ -0,0 +1,140 @@
+/* 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
+/// Definition of the Diligent::IVertexDescription interface and related data structures
+
+#include "DeviceObject.h"
+
+namespace Diligent
+{
+
+// {2D6915E5-003B-4C68-BDF0-8F93FA7AD4BC}
+static const Diligent::INTERFACE_ID IID_VertexDescription =
+{ 0x2d6915e5, 0x3b, 0x4c68, { 0xbd, 0xf0, 0x8f, 0x93, 0xfa, 0x7a, 0xd4, 0xbc } };
+
+static const Uint32 iMaxLayoutElements = 16;
+
+/// Description of a single element of the input layout
+struct LayoutElement
+{
+ /// Input index of the element, which is specified in the vertex shader.
+ Uint32 InputIndex;
+
+ /// Buffer slot index that this element is read from.
+ Uint32 BufferSlot;
+
+ /// Number of components in the element. Allowed values are 1, 2, 3, and 4.
+ Uint32 NumComponents;
+
+ /// Type of the element components, see Diligent::VALUE_TYPE for details.
+ VALUE_TYPE ValueType;
+
+ /// For signed and unsigned integer value types
+ /// (VT_INT8, VT_INT16, VT_INT32, VT_UINT8, VT_UINT16, VT_UINT32)
+ /// indicates if the value should be normalized to [-1,+1] or
+ /// [0, 1] range respectively. For floating point types
+ /// (VT_FLOAT16 and VT_FLOAT32), this member is ignored.
+ Bool IsNormalized;
+
+ /// Relative offset, in bytes, to the element bits.
+ /// If this value is zero, the offset will be computed automatically
+ /// assuming that all previous elements in the same buffer slot a tightly packed.
+ /// Overlapping elements are not allowed.
+ Uint32 RelativeOffset;
+
+ /// Input frequency
+ enum FREQUENCY : Int32
+ {
+ /// Frequency is undefined.
+ FREQUENCY_UNDEFINED = 0,
+
+ /// Input data is per-vertex data.
+ FREQUENCY_PER_VERTEX,
+
+ /// Input data is per-instance data.
+ FREQUENCY_PER_INSTANCE,
+
+ /// Helper value that stores the total number of frequencies in the enumeration.
+ FREQUENCY_NUM_FREQUENCIES
+ }Frequency;
+
+ /// The number of instances to draw using the same per-instance data before advancing
+ /// in the buffer by one element.
+ Uint32 InstanceDataStepRate;
+
+ /// Initializes the structure
+ LayoutElement(Uint32 _InputIndex = 0,
+ Uint32 _BufferSlot = 0,
+ Uint32 _NumComponents = 0,
+ VALUE_TYPE _ValueType = VT_FLOAT32,
+ Bool _IsNormalized = True,
+ Uint32 _RelativeOffset = 0,
+ FREQUENCY _Frequency = FREQUENCY_PER_VERTEX,
+ Uint32 _InstanceDataStepRate = 1) :
+ InputIndex(_InputIndex),
+ BufferSlot(_BufferSlot),
+ NumComponents(_NumComponents),
+ ValueType(_ValueType),
+ IsNormalized(_IsNormalized),
+ RelativeOffset(_RelativeOffset),
+ Frequency(_Frequency),
+ InstanceDataStepRate(_InstanceDataStepRate)
+ {}
+};
+
+/// Layout description
+
+/// This structure is used by IRenderDevice::CreateVertexDescription().
+struct LayoutDesc : DeviceObjectAttribs
+{
+ /// Array of layout elements
+ const LayoutElement *LayoutElements;
+ Uint32 NumElements;
+ LayoutDesc() :
+ LayoutElements(nullptr),
+ NumElements(0)
+ {}
+};
+
+/// Vertex description interface
+
+/// Vertex description is created by a call to IRenderDevice::CreateVertexDescription().
+/// To bind vertex descption, call IDeviceContext::SetVertexDescription().
+class IVertexDescription : public IDeviceObject
+{
+public:
+ /// Queries the specific interface, see IObject::QueryInterface() for details
+ virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
+
+ /// Returns layout description used to create the object
+ virtual const LayoutDesc &GetDesc()const = 0;
+
+ /// Returns tight strides for each input buffer slot. Tight strides are computed
+ /// assuming that all layout elements in the buffer are tightly packed.
+ virtual const Uint32* GetTightStrides() = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/src/ResourceMapping.cpp b/Graphics/GraphicsEngine/src/ResourceMapping.cpp
new file mode 100644
index 00000000..47a54ed9
--- /dev/null
+++ b/Graphics/GraphicsEngine/src/ResourceMapping.cpp
@@ -0,0 +1,130 @@
+/* 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 "ResourceMappingImpl.h"
+#include "DeviceObjectBase.h"
+
+using namespace std;
+
+namespace Diligent
+{
+ ResourceMappingImpl::~ResourceMappingImpl()
+ {
+ }
+
+ IMPLEMENT_QUERY_INTERFACE( ResourceMappingImpl, IID_ResourceMapping, ObjectBase<IResourceMapping> )
+
+ ThreadingTools::LockHelper ResourceMappingImpl::Lock()
+ {
+ return std::move( ThreadingTools::LockHelper( m_LockFlag ) );
+ }
+
+ void ResourceMappingImpl::AddResource( const Char *Name, IDeviceObject *pObject, bool bIsUnique )
+ {
+ if( Name == nullptr || *Name == 0 )
+ return;
+
+ auto LockHelper = Lock();
+ // Try to construct new element in place
+ auto Elems =
+ m_HashTable.emplace(
+ make_pair( Diligent::HashMapStringKey(Name, true), // Make a copy of the source string
+ Diligent::RefCntAutoPtr<IDeviceObject>(pObject)
+ )
+ );
+ // If there is already element with the same name, replace it
+ if( !Elems.second && Elems.first->second != pObject )
+ {
+ if( bIsUnique )
+ {
+ UNEXPECTED( "Resource with the same name already exists" );
+ LOG_WARNING_MESSAGE(
+ "Resource with name ", Name, " marked is unique, but already present in the hash.\n"
+ "New resource will be used\n." );
+ }
+ Elems.first->second = pObject;
+ }
+ }
+
+ void ResourceMappingImpl::RemoveResourceByName( const Char *Name )
+ {
+ if( *Name == 0 )
+ return;
+
+ auto LockHelper = Lock();
+ // Remove object with the given name
+ // Name will be implicitly converted to HashMapStringKey without making a copy
+ auto It = m_HashTable.erase( Name );
+ }
+
+ void ResourceMappingImpl::RemoveResource( IDeviceObject *pObject )
+ {
+ const auto *Name = pObject->GetDesc().Name;
+ VERIFY( Name, "Name is null" );
+ if( *Name == 0 )
+ return;
+
+ auto LockHelper = Lock();
+
+ // Find active object with the same name
+ // Name will be implicitly converted to HashMapStringKey without making a copy
+ auto It = m_HashTable.find( Name );
+ // Check if the active object is in fact the object being removed
+ if( It != m_HashTable.end() && It->second == pObject )
+ {
+ m_HashTable.erase( It );
+ }
+ }
+
+ void ResourceMappingImpl::GetResource( const Char *Name, IDeviceObject **ppResource )
+ {
+ VERIFY(Name, "Name is null")
+ if( *Name == 0 )
+ return;
+
+ VERIFY( ppResource, "Null pointer provided" );
+ if(!ppResource)
+ return;
+
+ VERIFY( *ppResource == nullptr, "Overwriting reference to existing object may cause memory leaks" );
+ *ppResource = nullptr;
+
+ auto LockHelper = Lock();
+
+ // Find an object with the requested name
+ // Name will be implicitly converted to HashMapStringKey without making a copy
+ auto It = m_HashTable.find( Name );
+ if( It != m_HashTable.end() )
+ {
+ *ppResource = It->second.RawPtr();
+ if(*ppResource)
+ (*ppResource)->AddRef();
+ }
+ }
+
+ size_t ResourceMappingImpl::GetSize()
+ {
+ return m_HashTable.size();
+ }
+}
diff --git a/Graphics/GraphicsEngine/src/Texture.cpp b/Graphics/GraphicsEngine/src/Texture.cpp
new file mode 100644
index 00000000..60440bdc
--- /dev/null
+++ b/Graphics/GraphicsEngine/src/Texture.cpp
@@ -0,0 +1,191 @@
+/* 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 "Texture.h"
+
+namespace Diligent
+{
+
+void ValidateTextureDesc( const TextureDesc& Desc )
+{
+#define LOG_TEXTURE_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Texture \"", Desc.Name ? Desc.Name : "", "\": ", ##__VA_ARGS__)
+
+ // Perform some parameter correctness check
+ if( Desc.Type == TEXTURE_TYPE_1D || Desc.Type == TEXTURE_TYPE_1D_ARRAY )
+ {
+ if( Desc.Height != 1 )
+ LOG_TEXTURE_ERROR_AND_THROW("Height (", Desc.Height,") of Texture 1D/Texture 1D Array must be 1");
+ }
+
+ if( Desc.Type == TEXTURE_TYPE_1D || Desc.Type == TEXTURE_TYPE_2D )
+ {
+ if( Desc.ArraySize != 1 )
+ LOG_TEXTURE_ERROR_AND_THROW("Texture 1D/2D must have one array slice (", Desc.ArraySize, " provided). Use Texture 1D/2D array if you need more than one slice.");
+ }
+
+ Uint32 MaxDim = 0;
+ if( Desc.Type == TEXTURE_TYPE_1D || Desc.Type == TEXTURE_TYPE_1D_ARRAY )
+ MaxDim = Desc.Width;
+ else if( Desc.Type == TEXTURE_TYPE_2D || Desc.Type == TEXTURE_TYPE_2D_ARRAY )
+ MaxDim = std::max(Desc.Width, Desc.Height);
+ else if( Desc.Type == TEXTURE_TYPE_3D )
+ MaxDim = std::max( std::max(Desc.Width, Desc.Height), Desc.Depth );
+ VERIFY( MaxDim >= (1U << (Desc.MipLevels-1)), "Texture \"", Desc.Name ? Desc.Name : "", "\": Incorrect number of Mip levels (", Desc.MipLevels, ")" )
+
+ if( Desc.SampleCount > 1 )
+ {
+ if( !(Desc.Type == TEXTURE_TYPE_2D || Desc.Type == TEXTURE_TYPE_2D_ARRAY) )
+ LOG_TEXTURE_ERROR_AND_THROW("Only Texture 2D/Texture 2D Array can be multisampled");
+
+ if( Desc.MipLevels != 1 )
+ LOG_TEXTURE_ERROR_AND_THROW("Multisampled textures must have one mip level (", Desc.MipLevels, " levels specified)");
+
+ if( Desc.BindFlags & BIND_UNORDERED_ACCESS )
+ LOG_TEXTURE_ERROR_AND_THROW("UAVs are not allowed for multisampled resources");
+ }
+
+ if( (Desc.BindFlags & BIND_RENDER_TARGET) &&
+ ( Desc.Format == TEX_FORMAT_R8_SNORM || Desc.Format == TEX_FORMAT_RG8_SNORM || Desc.Format == TEX_FORMAT_RGBA8_SNORM ||
+ Desc.Format == TEX_FORMAT_R16_SNORM || Desc.Format == TEX_FORMAT_RG16_SNORM || Desc.Format == TEX_FORMAT_RGBA16_SNORM ) )
+ {
+ const auto *FmtName = GetTextureFormatAttribs( Desc.Format ).Name;
+ LOG_WARNING_MESSAGE( FmtName, " texture is created with BIND_RENDER_TARGET flag set.\n"
+ "There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.\n"
+ "Use UNORM format instead." );
+ }
+}
+
+
+void ValidateTextureRegion(const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box &Box)
+{
+#define VERIFY_TEX_PARAMS(Expr, ...) VERIFY(Expr, "Texture \"", TexDesc.Name ? TexDesc.Name : "", "\": ", ##__VA_ARGS__)
+
+ VERIFY_TEX_PARAMS( MipLevel < TexDesc.MipLevels, "Mip level (", MipLevel, ") is out of allowed range [0, ", TexDesc.MipLevels-1, "]" );
+ VERIFY_TEX_PARAMS( Box.MinX < Box.MaxX, "Incorrect X range [",Box.MinX, ", ", Box.MaxX, ")" );
+ VERIFY_TEX_PARAMS( Box.MinY < Box.MaxY, "Incorrect Y range [",Box.MinY, ", ", Box.MaxY, ")" );
+ VERIFY_TEX_PARAMS( Box.MinZ < Box.MaxZ, "Incorrect Z range [",Box.MinZ, ", ", Box.MaxZ, ")" );
+
+ if( TexDesc.Type == TEXTURE_TYPE_1D_ARRAY ||
+ TexDesc.Type == TEXTURE_TYPE_2D_ARRAY )
+ {
+ VERIFY_TEX_PARAMS( Slice < TexDesc.ArraySize, "Array slice (", Slice, ") is out of range [0,", TexDesc.ArraySize-1, "]" );
+ }
+ else
+ {
+ VERIFY_TEX_PARAMS( Slice == 0, "Array slice (", Slice, ") must be 0 for non-array textures" );
+ }
+
+ Uint32 MipWidth = std::max(TexDesc.Width >> MipLevel, 1U);
+ VERIFY_TEX_PARAMS( Box.MaxX <= MipWidth, "Region max X coordinate (", Box.MaxX, ") is out of allowed range [0, ", MipWidth, "]" );
+ if( TexDesc.Type != TEXTURE_TYPE_1D &&
+ TexDesc.Type != TEXTURE_TYPE_1D_ARRAY )
+ {
+ Uint32 MipHeight = std::max(TexDesc.Height >> MipLevel, 1U);
+ VERIFY_TEX_PARAMS( Box.MaxY <= MipHeight, "Region max Y coordinate (", Box.MaxY, ") is out of allowed range [0, ", MipHeight, "]" );
+ }
+
+ if( TexDesc.Type == TEXTURE_TYPE_3D )
+ {
+ Uint32 MipDepth = std::max(TexDesc.Depth >> MipLevel, 1U);
+ VERIFY_TEX_PARAMS( Box.MaxZ <= MipDepth, "Region max Z coordinate (", Box.MaxZ, ") is out of allowed range [0, ", MipDepth, "]" );
+ }
+}
+
+void ValidateUpdateDataParams( const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )
+{
+ ValidateTextureRegion(TexDesc, MipLevel, Slice, DstBox);
+
+ VERIFY_TEX_PARAMS( (SubresData.Stride & 0x03) == 0, "Texture data stride (", SubresData.Stride, ") must be at least 32-bit aligned" );
+ VERIFY_TEX_PARAMS( (SubresData.DepthStride & 0x03) == 0, "Texture data depth stride (", SubresData.DepthStride, ") must be at least 32-bit aligned" );
+}
+
+void VliadateCopyTextureDataParams( const TextureDesc &SrcTexDesc, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box *pSrcBox,
+ const TextureDesc &DstTexDesc, Uint32 DstMipLevel, Uint32 DstSlice,
+ Uint32 DstX, Uint32 DstY, Uint32 DstZ )
+{
+ Box SrcBox;
+ if( pSrcBox == nullptr )
+ {
+ SrcBox.MaxX = std::max( SrcTexDesc.Width >> SrcMipLevel, 1u );
+ if( SrcTexDesc.Type == TEXTURE_TYPE_1D ||
+ SrcTexDesc.Type == TEXTURE_TYPE_1D_ARRAY )
+ SrcBox.MaxY = 1;
+ else
+ SrcBox.MaxY = std::max( SrcTexDesc.Height >> SrcMipLevel, 1u );
+
+ if( SrcTexDesc.Type == TEXTURE_TYPE_3D )
+ SrcBox.MaxZ = std::max( SrcTexDesc.Depth >> SrcMipLevel, 1u );
+ else
+ SrcBox.MaxZ = 1;
+
+ pSrcBox = &SrcBox;
+ }
+ ValidateTextureRegion(SrcTexDesc, SrcMipLevel, SrcSlice, *pSrcBox);
+
+ Box DstBox;
+ DstBox.MinX = DstX;
+ DstBox.MaxX = DstBox.MinX + (pSrcBox->MaxX - pSrcBox->MinX);
+ DstBox.MinY = DstY;
+ DstBox.MaxY = DstBox.MinY + (pSrcBox->MaxY - pSrcBox->MinY);
+ DstBox.MinZ = DstZ;
+ DstBox.MaxZ = DstBox.MinZ + (pSrcBox->MaxZ - pSrcBox->MinZ);
+ ValidateTextureRegion(DstTexDesc, DstMipLevel, DstSlice, DstBox);
+}
+
+
+//void CTexture :: Map(MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData)
+//{
+ //switch(MapType)
+ //{
+ // case MAP_READ:
+ // VERIFY( "Only buffers with usage USAGE_CPU_ACCESSIBLE can be read from" && m_Desc.Usage == USAGE_CPU_ACCESSIBLE);
+ // VERIFY( "Buffer being mapped for reading was not created with CPU_ACCESS_READ flag" && (m_Desc.CPUAccessFlags & CPU_ACCESS_READ));
+ // break;
+
+ // case MAP_WRITE:
+ // VERIFY( "Only buffers with usage USAGE_CPU_ACCESSIBLE can be written to" && m_Desc.Usage == USAGE_CPU_ACCESSIBLE );
+ // VERIFY( "Buffer being mapped for writing was not created with CPU_ACCESS_WRITE flag" && (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE));
+ // break;
+
+ // case MAP_READ_WRITE:
+ // VERIFY( "Only buffers with usage USAGE_CPU_ACCESSIBLE can be read and written" && m_Desc.Usage == USAGE_CPU_ACCESSIBLE );
+ // VERIFY( "Buffer being mapped for reading & writing was not created with CPU_ACCESS_WRITE flag" && (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE));
+ // VERIFY( "Buffer being mapped for reading & writing was not created with CPU_ACCESS_READ flag" && (m_Desc.CPUAccessFlags & CPU_ACCESS_READ));
+ // break;
+
+ // case MAP_WRITE_DISCARD:
+ // VERIFY( "Only dynamic buffers can be mapped with write discard flag" && m_Desc.Usage == USAGE_DYNAMIC );
+ // VERIFY( "Dynamic buffer must be created with CPU_ACCESS_WRITE flag" && (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE) );
+ // break;
+
+ // case MAP_WRITE_NO_OVERWRITE:
+ // VERIFY( "Only dynamic buffers can be mapped with write no overwrite flag" && m_Desc.Usage == USAGE_DYNAMIC );
+ // VERIFY( "Dynamic buffer must be created with CPU_ACCESS_WRITE flag" && (m_Desc.CPUAccessFlags & CPU_ACCESS_WRITE) );
+ // break;
+
+ // default: VERIFY("Unknown map type" && false);
+ //}
+//}
+
+} \ No newline at end of file
diff --git a/Graphics/GraphicsEngine/src/pch.cpp b/Graphics/GraphicsEngine/src/pch.cpp
new file mode 100644
index 00000000..bf010b17
--- /dev/null
+++ b/Graphics/GraphicsEngine/src/pch.cpp
@@ -0,0 +1,31 @@
+/* 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.
+ */
+
+// stdafx.cpp : source file that includes just the standard includes
+// RenderEngine.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "pch.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file