Browse Source

Added ability to sample stencil part of depth/stencil texture.

Branimir Karadžić 7 years ago
parent
commit
f40bf8e862

+ 2 - 2
examples/09-hdr/hdr.cpp

@@ -307,10 +307,10 @@ public:
 					, false
 					, false
 					, 1
 					, 1
 					, bgfx::TextureFormat::BGRA8
 					, bgfx::TextureFormat::BGRA8
-					, ((msaa + 1) << BGFX_TEXTURE_RT_MSAA_SHIFT) | BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP
+					, (uint64_t(msaa + 1) << BGFX_TEXTURE_RT_MSAA_SHIFT) | BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP
 					);
 					);
 
 
-				const uint32_t textureFlags = BGFX_TEXTURE_RT_WRITE_ONLY|( (msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT);
+				const uint64_t textureFlags = BGFX_TEXTURE_RT_WRITE_ONLY|(uint64_t(msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT);
 
 
 				bgfx::TextureFormat::Enum depthFormat =
 				bgfx::TextureFormat::Enum depthFormat =
 					  bgfx::isTextureValid(0, false, 1, bgfx::TextureFormat::D16,   textureFlags) ? bgfx::TextureFormat::D16
 					  bgfx::isTextureValid(0, false, 1, bgfx::TextureFormat::D16,   textureFlags) ? bgfx::TextureFormat::D16

+ 5 - 5
examples/21-deferred/deferred.cpp

@@ -418,7 +418,7 @@ public:
 						bgfx::destroy(m_gbuffer);
 						bgfx::destroy(m_gbuffer);
 					}
 					}
 
 
-					const uint32_t samplerFlags = 0
+					const uint64_t tsFlags = 0
 						| BGFX_TEXTURE_RT
 						| BGFX_TEXTURE_RT
 						| BGFX_SAMPLER_MIN_POINT
 						| BGFX_SAMPLER_MIN_POINT
 						| BGFX_SAMPLER_MAG_POINT
 						| BGFX_SAMPLER_MAG_POINT
@@ -426,9 +426,9 @@ public:
 						| BGFX_SAMPLER_U_CLAMP
 						| BGFX_SAMPLER_U_CLAMP
 						| BGFX_SAMPLER_V_CLAMP
 						| BGFX_SAMPLER_V_CLAMP
 						;
 						;
-					m_gbufferTex[0] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::BGRA8, samplerFlags);
-					m_gbufferTex[1] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::BGRA8, samplerFlags);
-					m_gbufferTex[2] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::D24,   samplerFlags);
+					m_gbufferTex[0] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::BGRA8, tsFlags);
+					m_gbufferTex[1] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::BGRA8, tsFlags);
+					m_gbufferTex[2] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::D24S8, tsFlags);
 					m_gbuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_gbufferTex), m_gbufferTex, true);
 					m_gbuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_gbufferTex), m_gbufferTex, true);
 
 
 					if (bgfx::isValid(m_lightBuffer) )
 					if (bgfx::isValid(m_lightBuffer) )
@@ -436,7 +436,7 @@ public:
 						bgfx::destroy(m_lightBuffer);
 						bgfx::destroy(m_lightBuffer);
 					}
 					}
 
 
-					m_lightBuffer = bgfx::createFrameBuffer(uint16_t(m_width), uint16_t(m_height), bgfx::TextureFormat::BGRA8, samplerFlags);
+					m_lightBuffer = bgfx::createFrameBuffer(uint16_t(m_width), uint16_t(m_height), bgfx::TextureFormat::BGRA8, tsFlags);
 				}
 				}
 
 
 				ImGui::SetNextWindowPos(
 				ImGui::SetNextWindowPos(

+ 4 - 4
examples/23-vectordisplay/vectordisplay.cpp

@@ -827,7 +827,7 @@ void VectorDisplay::screenSpaceQuad(float _textureWidth, float _textureHeight, f
 
 
 void VectorDisplay::setupResDependent()
 void VectorDisplay::setupResDependent()
 {
 {
-	const uint32_t samplerFlags = 0
+	const uint64_t tsFlags = 0
 		| BGFX_TEXTURE_RT
 		| BGFX_TEXTURE_RT
 		| BGFX_SAMPLER_MIN_POINT
 		| BGFX_SAMPLER_MIN_POINT
 		| BGFX_SAMPLER_MAG_POINT
 		| BGFX_SAMPLER_MAG_POINT
@@ -835,13 +835,13 @@ void VectorDisplay::setupResDependent()
 		| BGFX_SAMPLER_U_CLAMP
 		| BGFX_SAMPLER_U_CLAMP
 		| BGFX_SAMPLER_V_CLAMP
 		| BGFX_SAMPLER_V_CLAMP
 		;
 		;
-	m_sceneFrameBuffer = bgfx::createFrameBuffer(m_screenWidth, m_screenHeight, bgfx::TextureFormat::BGRA8, samplerFlags);
+	m_sceneFrameBuffer = bgfx::createFrameBuffer(m_screenWidth, m_screenHeight, bgfx::TextureFormat::BGRA8, tsFlags);
 
 
 	m_glowWidth = m_screenWidth / 3;
 	m_glowWidth = m_screenWidth / 3;
 	m_glowHeight = m_screenHeight / 3;
 	m_glowHeight = m_screenHeight / 3;
 
 
-	m_glow0FrameBuffer = bgfx::createFrameBuffer(m_glowWidth, m_glowHeight, bgfx::TextureFormat::BGRA8, samplerFlags);
-	m_glow1FrameBuffer = bgfx::createFrameBuffer(m_glowWidth, m_glowHeight, bgfx::TextureFormat::BGRA8, samplerFlags);
+	m_glow0FrameBuffer = bgfx::createFrameBuffer(m_glowWidth, m_glowHeight, bgfx::TextureFormat::BGRA8, tsFlags);
+	m_glow1FrameBuffer = bgfx::createFrameBuffer(m_glowWidth, m_glowHeight, bgfx::TextureFormat::BGRA8, tsFlags);
 }
 }
 
 
 void VectorDisplay::teardownResDependent()
 void VectorDisplay::teardownResDependent()

+ 13 - 13
examples/31-rsm/reflectiveshadowmap.cpp

@@ -302,7 +302,7 @@ public:
 		// Light sphere
 		// Light sphere
 		m_lightSphere = meshLoad("meshes/unit_sphere.bin");
 		m_lightSphere = meshLoad("meshes/unit_sphere.bin");
 
 
-		const uint32_t samplerFlags = 0
+		const uint64_t tsFlags = 0
 			| BGFX_TEXTURE_RT
 			| BGFX_TEXTURE_RT
 			| BGFX_SAMPLER_MIN_POINT
 			| BGFX_SAMPLER_MIN_POINT
 			| BGFX_SAMPLER_MAG_POINT
 			| BGFX_SAMPLER_MAG_POINT
@@ -312,20 +312,20 @@ public:
 			;
 			;
 
 
 		// Make gbuffer and related textures
 		// Make gbuffer and related textures
-		m_gbufferTex[GBUFFER_RT_NORMAL] = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::BGRA8, samplerFlags);
-		m_gbufferTex[GBUFFER_RT_COLOR]  = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::BGRA8, samplerFlags);
-		m_gbufferTex[GBUFFER_RT_DEPTH]  = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::D24,   samplerFlags);
+		m_gbufferTex[GBUFFER_RT_NORMAL] = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::BGRA8, tsFlags);
+		m_gbufferTex[GBUFFER_RT_COLOR]  = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::BGRA8, tsFlags);
+		m_gbufferTex[GBUFFER_RT_DEPTH]  = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::D24,   tsFlags);
 		m_gbuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_gbufferTex), m_gbufferTex, true);
 		m_gbuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_gbufferTex), m_gbufferTex, true);
 
 
 		// Make light buffer
 		// Make light buffer
-		m_lightBufferTex = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::BGRA8, samplerFlags);
+		m_lightBufferTex = bgfx::createTexture2D(bgfx::BackbufferRatio::Equal, false, 1, bgfx::TextureFormat::BGRA8, tsFlags);
 		bgfx::TextureHandle lightBufferRTs[] =  {
 		bgfx::TextureHandle lightBufferRTs[] =  {
 			m_lightBufferTex
 			m_lightBufferTex
 		};
 		};
 		m_lightBuffer = bgfx::createFrameBuffer(BX_COUNTOF(lightBufferRTs), lightBufferRTs, true);
 		m_lightBuffer = bgfx::createFrameBuffer(BX_COUNTOF(lightBufferRTs), lightBufferRTs, true);
 
 
 		// Make shadow buffer
 		// Make shadow buffer
-		const uint32_t rsmFlags = 0
+		const uint64_t rsmFlags = 0
 			| BGFX_TEXTURE_RT
 			| BGFX_TEXTURE_RT
 			| BGFX_SAMPLER_MIN_POINT
 			| BGFX_SAMPLER_MIN_POINT
 			| BGFX_SAMPLER_MAG_POINT
 			| BGFX_SAMPLER_MAG_POINT
@@ -340,8 +340,8 @@ public:
 				, SHADOW_MAP_DIM
 				, SHADOW_MAP_DIM
 				, false
 				, false
 				, 1
 				, 1
-				, bgfx::TextureFormat::BGRA8,
-				rsmFlags
+				, bgfx::TextureFormat::BGRA8
+				, rsmFlags
 				);
 				);
 
 
 		// Typical shadow map
 		// Typical shadow map
@@ -350,12 +350,12 @@ public:
 				, SHADOW_MAP_DIM
 				, SHADOW_MAP_DIM
 				, false
 				, false
 				, 1
 				, 1
-				, bgfx::TextureFormat::D16,
-				BGFX_TEXTURE_RT/* | BGFX_TEXTURE_COMPARE_LEQUAL*/
+				, bgfx::TextureFormat::D16
+				, BGFX_TEXTURE_RT /* | BGFX_TEXTURE_COMPARE_LEQUAL*/
 				);  // Note I'm not setting BGFX_TEXTURE_COMPARE_LEQUAL.  Why?
 				);  // Note I'm not setting BGFX_TEXTURE_COMPARE_LEQUAL.  Why?
-		// Normally a PCF shadow map such as this requires a compare.  However, this sample also
-		// reads from this texture in the lighting pass, and only uses the PCF capabilites in the
-		// combine pass, so the flag is disabled by default.
+					// Normally a PCF shadow map such as this requires a compare.  However, this sample also
+					// reads from this texture in the lighting pass, and only uses the PCF capabilites in the
+					// combine pass, so the flag is disabled by default.
 
 
 		m_shadowBuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_shadowBufferTex), m_shadowBufferTex, true);
 		m_shadowBuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_shadowBufferTex), m_shadowBufferTex, true);
 
 

+ 3 - 3
examples/37-gpudrivenrendering/gpudrivenrendering.cpp

@@ -588,7 +588,7 @@ public:
 
 
 		//Setup Occlusion pass
 		//Setup Occlusion pass
 		{
 		{
-			const uint32_t samplerFlags = 0
+			const uint64_t tsFlags = 0
 				| BGFX_TEXTURE_RT
 				| BGFX_TEXTURE_RT
 				| BGFX_SAMPLER_MIN_POINT
 				| BGFX_SAMPLER_MIN_POINT
 				| BGFX_SAMPLER_MAG_POINT
 				| BGFX_SAMPLER_MAG_POINT
@@ -598,9 +598,9 @@ public:
 				;
 				;
 
 
 			// Create buffers for the HiZ pass
 			// Create buffers for the HiZ pass
-			m_hiZDepthBuffer = bgfx::createFrameBuffer(uint16_t(m_hiZwidth), uint16_t(m_hiZheight), bgfx::TextureFormat::D32, samplerFlags);
+			m_hiZDepthBuffer = bgfx::createFrameBuffer(uint16_t(m_hiZwidth), uint16_t(m_hiZheight), bgfx::TextureFormat::D32, tsFlags);
 
 
-			bgfx::TextureHandle buffer = bgfx::createTexture2D(uint16_t(m_hiZwidth), uint16_t(m_hiZheight), true, 1, bgfx::TextureFormat::R32F, BGFX_TEXTURE_COMPUTE_WRITE | samplerFlags);
+			bgfx::TextureHandle buffer = bgfx::createTexture2D(uint16_t(m_hiZwidth), uint16_t(m_hiZheight), true, 1, bgfx::TextureFormat::R32F, BGFX_TEXTURE_COMPUTE_WRITE | tsFlags);
 			m_hiZBuffer = bgfx::createFrameBuffer(1, &buffer, true);
 			m_hiZBuffer = bgfx::createFrameBuffer(1, &buffer, true);
 
 
 			//how many mip will the Hi Z buffer have?
 			//how many mip will the Hi Z buffer have?

+ 11 - 9
include/bgfx/bgfx.h

@@ -2485,7 +2485,7 @@ namespace bgfx
 		, bool _cubeMap
 		, bool _cubeMap
 		, uint16_t _numLayers
 		, uint16_t _numLayers
 		, TextureFormat::Enum _format
 		, TextureFormat::Enum _format
-		, uint32_t _flags
+		, uint64_t _flags
 		);
 		);
 
 
 	/// Calculate amount of memory required for texture.
 	/// Calculate amount of memory required for texture.
@@ -2530,7 +2530,7 @@ namespace bgfx
 	///
 	///
 	TextureHandle createTexture(
 	TextureHandle createTexture(
 		  const Memory* _mem
 		  const Memory* _mem
-		, uint32_t _flags = BGFX_SAMPLER_NONE
+		, uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE
 		, uint8_t _skip = 0
 		, uint8_t _skip = 0
 		, TextureInfo* _info = NULL
 		, TextureInfo* _info = NULL
 		);
 		);
@@ -2562,7 +2562,7 @@ namespace bgfx
 		, bool     _hasMips
 		, bool     _hasMips
 		, uint16_t _numLayers
 		, uint16_t _numLayers
 		, TextureFormat::Enum _format
 		, TextureFormat::Enum _format
-		, uint32_t _flags = BGFX_SAMPLER_NONE
+		, uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE
 		, const Memory* _mem = NULL
 		, const Memory* _mem = NULL
 		);
 		);
 
 
@@ -2589,7 +2589,7 @@ namespace bgfx
 		, bool _hasMips
 		, bool _hasMips
 		, uint16_t _numLayers
 		, uint16_t _numLayers
 		, TextureFormat::Enum _format
 		, TextureFormat::Enum _format
-		, uint32_t _flags = BGFX_SAMPLER_NONE
+		, uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE
 		);
 		);
 
 
 	/// Create 3D texture.
 	/// Create 3D texture.
@@ -2617,7 +2617,7 @@ namespace bgfx
 		, uint16_t _depth
 		, uint16_t _depth
 		, bool _hasMips
 		, bool _hasMips
 		, TextureFormat::Enum _format
 		, TextureFormat::Enum _format
-		, uint32_t _flags = BGFX_SAMPLER_NONE
+		, uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE
 		, const Memory* _mem = NULL
 		, const Memory* _mem = NULL
 		);
 		);
 
 
@@ -2646,7 +2646,7 @@ namespace bgfx
 		, bool _hasMips
 		, bool _hasMips
 		, uint16_t _numLayers
 		, uint16_t _numLayers
 		, TextureFormat::Enum _format
 		, TextureFormat::Enum _format
-		, uint32_t _flags = BGFX_SAMPLER_NONE
+		, uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE
 		, const Memory* _mem = NULL
 		, const Memory* _mem = NULL
 		);
 		);
 
 
@@ -2828,7 +2828,7 @@ namespace bgfx
 		  uint16_t _width
 		  uint16_t _width
 		, uint16_t _height
 		, uint16_t _height
 		, TextureFormat::Enum _format
 		, TextureFormat::Enum _format
-		, uint32_t _textureFlags = BGFX_SAMPLER_U_CLAMP|BGFX_SAMPLER_V_CLAMP
+		, uint64_t _textureFlags = BGFX_SAMPLER_U_CLAMP|BGFX_SAMPLER_V_CLAMP
 		);
 		);
 
 
 	/// Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio
 	/// Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio
@@ -2851,7 +2851,7 @@ namespace bgfx
 	FrameBufferHandle createFrameBuffer(
 	FrameBufferHandle createFrameBuffer(
 		  BackbufferRatio::Enum _ratio
 		  BackbufferRatio::Enum _ratio
 		, TextureFormat::Enum _format
 		, TextureFormat::Enum _format
-		, uint32_t _textureFlags = BGFX_SAMPLER_U_CLAMP|BGFX_SAMPLER_V_CLAMP
+		, uint64_t _textureFlags = BGFX_SAMPLER_U_CLAMP|BGFX_SAMPLER_V_CLAMP
 		);
 		);
 
 
 	/// Create MRT frame buffer from texture handles (simple).
 	/// Create MRT frame buffer from texture handles (simple).
@@ -2894,6 +2894,7 @@ namespace bgfx
 	/// @param[in] _nwh OS' target native window handle.
 	/// @param[in] _nwh OS' target native window handle.
 	/// @param[in] _width Window back buffer width.
 	/// @param[in] _width Window back buffer width.
 	/// @param[in] _height Window back buffer height.
 	/// @param[in] _height Window back buffer height.
+	/// @param[in] _format Window back buffer color format.
 	/// @param[in] _depthFormat Window back buffer depth format.
 	/// @param[in] _depthFormat Window back buffer depth format.
 	///
 	///
 	/// @returns Handle to frame buffer object.
 	/// @returns Handle to frame buffer object.
@@ -2907,7 +2908,8 @@ namespace bgfx
 		  void* _nwh
 		  void* _nwh
 		, uint16_t _width
 		, uint16_t _width
 		, uint16_t _height
 		, uint16_t _height
-		, TextureFormat::Enum _depthFormat = TextureFormat::UnknownDepth
+		, TextureFormat::Enum _format      = TextureFormat::Count
+		, TextureFormat::Enum _depthFormat = TextureFormat::Count
 		);
 		);
 
 
 	/// Obtain texture handle of frame buffer attachment.
 	/// Obtain texture handle of frame buffer attachment.

+ 9 - 9
include/bgfx/c99/bgfx.h

@@ -818,25 +818,25 @@ BGFX_C_API bgfx_program_handle_t bgfx_create_compute_program(bgfx_shader_handle_
 BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle);
 BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle);
 
 
 /**/
 /**/
-BGFX_C_API bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags);
+BGFX_C_API bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
 
 
 /**/
 /**/
 BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format);
 BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format);
 
 
 /**/
 /**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint32_t _flags, uint8_t _skip, bgfx_texture_info_t* _info);
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t* _info);
 
 
 /**/
 /**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
 
 
 /**/
 /**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags);
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
 
 
 /**/
 /**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
 
 
 /**/
 /**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
 
 
 /**/
 /**/
 BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
 BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
@@ -857,10 +857,10 @@ BGFX_C_API void bgfx_set_texture_name(bgfx_texture_handle_t _handle, const char*
 BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle);
 BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle);
 
 
 /**/
 /**/
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint32_t _textureFlags);
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags);
 
 
 /**/
 /**/
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint32_t _textureFlags);
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags);
 
 
 /**/
 /**/
 BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTextures);
 BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTextures);
@@ -869,7 +869,7 @@ BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint
 BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTextures);
 BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTextures);
 
 
 /**/
 /**/
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _depthFormat);
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat);
 
 
 /**/
 /**/
 BGFX_C_API bgfx_texture_handle_t bgfx_get_texture(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment);
 BGFX_C_API bgfx_texture_handle_t bgfx_get_texture(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment);

+ 9 - 9
include/bgfx/c99/platform.h

@@ -130,13 +130,13 @@ typedef struct bgfx_interface_vtbl
     bgfx_program_handle_t (*create_program)(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders);
     bgfx_program_handle_t (*create_program)(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders);
     bgfx_program_handle_t (*create_compute_program)(bgfx_shader_handle_t _csh, bool _destroyShaders);
     bgfx_program_handle_t (*create_compute_program)(bgfx_shader_handle_t _csh, bool _destroyShaders);
     void (*destroy_program)(bgfx_program_handle_t _handle);
     void (*destroy_program)(bgfx_program_handle_t _handle);
-    bool (*is_texture_valid)(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags);
+    bool (*is_texture_valid)(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
     void (*calc_texture_size)(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format);
     void (*calc_texture_size)(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format);
-    bgfx_texture_handle_t (*create_texture)(const bgfx_memory_t* _mem, uint32_t _flags, uint8_t _skip, bgfx_texture_info_t* _info);
-    bgfx_texture_handle_t (*create_texture_2d)(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
-    bgfx_texture_handle_t (*create_texture_2d_scaled)(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags);
-    bgfx_texture_handle_t (*create_texture_3d)(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
-    bgfx_texture_handle_t (*create_texture_cube)(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
+    bgfx_texture_handle_t (*create_texture)(const bgfx_memory_t* _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t* _info);
+    bgfx_texture_handle_t (*create_texture_2d)(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
+    bgfx_texture_handle_t (*create_texture_2d_scaled)(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
+    bgfx_texture_handle_t (*create_texture_3d)(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
+    bgfx_texture_handle_t (*create_texture_cube)(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
     void (*update_texture_2d)(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
     void (*update_texture_2d)(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
     void (*update_texture_3d)(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem);
     void (*update_texture_3d)(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem);
     void (*update_texture_cube)(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
     void (*update_texture_cube)(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
@@ -144,10 +144,10 @@ typedef struct bgfx_interface_vtbl
     void (*set_texture_name)(bgfx_texture_handle_t _handle, const char* _name, int32_t _len);
     void (*set_texture_name)(bgfx_texture_handle_t _handle, const char* _name, int32_t _len);
     void* (*get_direct_access_ptr)(bgfx_texture_handle_t _handle);
     void* (*get_direct_access_ptr)(bgfx_texture_handle_t _handle);
     void (*destroy_texture)(bgfx_texture_handle_t _handle);
     void (*destroy_texture)(bgfx_texture_handle_t _handle);
-    bgfx_frame_buffer_handle_t (*create_frame_buffer)(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint32_t _textureFlags);
-    bgfx_frame_buffer_handle_t (*create_frame_buffer_scaled)(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint32_t _textureFlags);
+    bgfx_frame_buffer_handle_t (*create_frame_buffer)(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags);
+    bgfx_frame_buffer_handle_t (*create_frame_buffer_scaled)(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags);
     bgfx_frame_buffer_handle_t (*create_frame_buffer_from_attachment)(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTextures);
     bgfx_frame_buffer_handle_t (*create_frame_buffer_from_attachment)(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTextures);
-    bgfx_frame_buffer_handle_t (*create_frame_buffer_from_nwh)(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _depthFormat);
+    bgfx_frame_buffer_handle_t (*create_frame_buffer_from_nwh)(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat);
     bgfx_texture_handle_t (*get_texture)(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment);
     bgfx_texture_handle_t (*get_texture)(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment);
     void (*destroy_frame_buffer)(bgfx_frame_buffer_handle_t _handle);
     void (*destroy_frame_buffer)(bgfx_frame_buffer_handle_t _handle);
     bgfx_uniform_handle_t (*create_uniform)(const char* _name, bgfx_uniform_type_t _type, uint16_t _num);
     bgfx_uniform_handle_t (*create_uniform)(const char* _name, bgfx_uniform_type_t _type, uint16_t _num);

+ 17 - 16
include/bgfx/defines.h

@@ -6,7 +6,7 @@
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 
 
-#define BGFX_API_VERSION UINT32_C(78)
+#define BGFX_API_VERSION UINT32_C(79)
 
 
 /// Color RGB/alpha/depth write. When it's not specified write will be disabled.
 /// Color RGB/alpha/depth write. When it's not specified write will be disabled.
 #define BGFX_STATE_WRITE_R                 UINT64_C(0x0000000000000001) //!< Enable R write.
 #define BGFX_STATE_WRITE_R                 UINT64_C(0x0000000000000001) //!< Enable R write.
@@ -335,21 +335,21 @@
 			)
 			)
 
 
 /// Texture creation flags.
 /// Texture creation flags.
-#define BGFX_TEXTURE_NONE                UINT32_C(0x00000000) //!<
-#define BGFX_TEXTURE_MSAA_SAMPLE         UINT32_C(0x00000800) //!< Texture will be used for MSAA sampling.
-#define BGFX_TEXTURE_RT                  UINT32_C(0x00001000) //!<
-#define BGFX_TEXTURE_RT_MSAA_X2          UINT32_C(0x00002000) //!< Render target MSAAx2 mode.
-#define BGFX_TEXTURE_RT_MSAA_X4          UINT32_C(0x00003000) //!< Render target MSAAx4 mode.
-#define BGFX_TEXTURE_RT_MSAA_X8          UINT32_C(0x00004000) //!< Render target MSAAx8 mode.
-#define BGFX_TEXTURE_RT_MSAA_X16         UINT32_C(0x00005000) //!< Render target MSAAx16 mode.
-#define BGFX_TEXTURE_RT_MSAA_SHIFT       12                   //!<
-#define BGFX_TEXTURE_RT_MSAA_MASK        UINT32_C(0x00007000) //!<
-#define BGFX_TEXTURE_RT_WRITE_ONLY       UINT32_C(0x00008000) //!< Render target will be used for writing only.
-#define BGFX_TEXTURE_RT_MASK             UINT32_C(0x0000f000) //!<
-#define BGFX_TEXTURE_COMPUTE_WRITE       UINT32_C(0x00100000) //!< Texture will be used for compute write.
-#define BGFX_TEXTURE_SRGB                UINT32_C(0x00200000) //!< Sample texture as sRGB.
-#define BGFX_TEXTURE_BLIT_DST            UINT32_C(0x00400000) //!< Texture will be used as blit destination.
-#define BGFX_TEXTURE_READ_BACK           UINT32_C(0x00800000) //!< Texture will be used for read back from GPU.
+#define BGFX_TEXTURE_NONE                UINT64_C(0x0000000000000000) //!<
+#define BGFX_TEXTURE_MSAA_SAMPLE         UINT64_C(0x0000000800000000) //!< Texture will be used for MSAA sampling.
+#define BGFX_TEXTURE_RT                  UINT64_C(0x0000001000000000) //!<
+#define BGFX_TEXTURE_RT_MSAA_X2          UINT64_C(0x0000002000000000) //!< Render target MSAAx2 mode.
+#define BGFX_TEXTURE_RT_MSAA_X4          UINT64_C(0x0000003000000000) //!< Render target MSAAx4 mode.
+#define BGFX_TEXTURE_RT_MSAA_X8          UINT64_C(0x0000004000000000) //!< Render target MSAAx8 mode.
+#define BGFX_TEXTURE_RT_MSAA_X16         UINT64_C(0x0000005000000000) //!< Render target MSAAx16 mode.
+#define BGFX_TEXTURE_RT_MSAA_SHIFT       36                           //!<
+#define BGFX_TEXTURE_RT_MSAA_MASK        UINT64_C(0x0000007000000000) //!<
+#define BGFX_TEXTURE_RT_WRITE_ONLY       UINT64_C(0x0000008000000000) //!< Render target will be used for writing only.
+#define BGFX_TEXTURE_RT_MASK             UINT64_C(0x000000f000000000) //!<
+#define BGFX_TEXTURE_COMPUTE_WRITE       UINT64_C(0x0000100000000000) //!< Texture will be used for compute write.
+#define BGFX_TEXTURE_SRGB                UINT64_C(0x0000200000000000) //!< Sample texture as sRGB.
+#define BGFX_TEXTURE_BLIT_DST            UINT64_C(0x0000400000000000) //!< Texture will be used as blit destination.
+#define BGFX_TEXTURE_READ_BACK           UINT64_C(0x0000800000000000) //!< Texture will be used for read back from GPU.
 
 
 /// Sampler flags.
 /// Sampler flags.
 #define BGFX_SAMPLER_NONE                UINT32_C(0x00000000) //!<
 #define BGFX_SAMPLER_NONE                UINT32_C(0x00000000) //!<
@@ -389,6 +389,7 @@
 #define BGFX_SAMPLER_COMPARE_ALWAYS      UINT32_C(0x00080000) //!< Compare when sampling depth texture: always.
 #define BGFX_SAMPLER_COMPARE_ALWAYS      UINT32_C(0x00080000) //!< Compare when sampling depth texture: always.
 #define BGFX_SAMPLER_COMPARE_SHIFT       16                   //!<
 #define BGFX_SAMPLER_COMPARE_SHIFT       16                   //!<
 #define BGFX_SAMPLER_COMPARE_MASK        UINT32_C(0x000f0000) //!<
 #define BGFX_SAMPLER_COMPARE_MASK        UINT32_C(0x000f0000) //!<
+#define BGFX_SAMPLER_SAMPLE_STENCIL      UINT32_C(0x00100000) //!< Sample stencil instead of depth.
 #define BGFX_SAMPLER_BORDER_COLOR_SHIFT  24                   //!<
 #define BGFX_SAMPLER_BORDER_COLOR_SHIFT  24                   //!<
 #define BGFX_SAMPLER_BORDER_COLOR_MASK   UINT32_C(0x0f000000) //!<
 #define BGFX_SAMPLER_BORDER_COLOR_MASK   UINT32_C(0x0f000000) //!<
 #define BGFX_SAMPLER_RESERVED_SHIFT      28                   //!<
 #define BGFX_SAMPLER_RESERVED_SHIFT      28                   //!<

+ 35 - 23
src/bgfx.cpp

@@ -2516,7 +2516,7 @@ namespace bgfx
 					const Memory* mem;
 					const Memory* mem;
 					_cmdbuf.read(mem);
 					_cmdbuf.read(mem);
 
 
-					uint32_t flags;
+					uint64_t flags;
 					_cmdbuf.read(flags);
 					_cmdbuf.read(flags);
 
 
 					uint8_t skip;
 					uint8_t skip;
@@ -2642,10 +2642,13 @@ namespace bgfx
 						uint16_t height;
 						uint16_t height;
 						_cmdbuf.read(height);
 						_cmdbuf.read(height);
 
 
+						TextureFormat::Enum format;
+						_cmdbuf.read(format);
+
 						TextureFormat::Enum depthFormat;
 						TextureFormat::Enum depthFormat;
 						_cmdbuf.read(depthFormat);
 						_cmdbuf.read(depthFormat);
 
 
-						m_renderCtx->createFrameBuffer(handle, nwh, width, height, depthFormat);
+						m_renderCtx->createFrameBuffer(handle, nwh, width, height, format, depthFormat);
 					}
 					}
 					else
 					else
 					{
 					{
@@ -3603,7 +3606,7 @@ error:
 		s_ctx->destroyProgram(_handle);
 		s_ctx->destroyProgram(_handle);
 	}
 	}
 
 
-	static void isTextureValid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, TextureFormat::Enum _format, uint32_t _flags, bx::Error* _err)
+	static void isTextureValid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags, bx::Error* _err)
 	{
 	{
 		BX_ERROR_SCOPE(_err);
 		BX_ERROR_SCOPE(_err);
 
 
@@ -3712,7 +3715,7 @@ error:
 		}
 		}
 	}
 	}
 
 
-	bool isTextureValid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, TextureFormat::Enum _format, uint32_t _flags)
+	bool isTextureValid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags)
 	{
 	{
 		bx::Error err;
 		bx::Error err;
 		isTextureValid(_depth, _cubeMap, _numLayers, _format, _flags, &err);
 		isTextureValid(_depth, _cubeMap, _numLayers, _format, _flags, &err);
@@ -3724,7 +3727,7 @@ error:
 		bimg::imageGetSize( (bimg::TextureInfo*)&_info, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, bimg::TextureFormat::Enum(_format) );
 		bimg::imageGetSize( (bimg::TextureInfo*)&_info, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, bimg::TextureFormat::Enum(_format) );
 	}
 	}
 
 
-	TextureHandle createTexture(const Memory* _mem, uint32_t _flags, uint8_t _skip, TextureInfo* _info)
+	TextureHandle createTexture(const Memory* _mem, uint64_t _flags, uint8_t _skip, TextureInfo* _info)
 	{
 	{
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		return s_ctx->createTexture(_mem, _flags, _skip, _info, BackbufferRatio::Count, false);
 		return s_ctx->createTexture(_mem, _flags, _skip, _info, BackbufferRatio::Count, false);
@@ -3748,7 +3751,7 @@ error:
 		_height = bx::max<uint16_t>(1, _height);
 		_height = bx::max<uint16_t>(1, _height);
 	}
 	}
 
 
-	static TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
+	static TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags, const Memory* _mem)
 	{
 	{
 		bx::Error err;
 		bx::Error err;
 		isTextureValid(0, false, _numLayers, _format, _flags, &err);
 		isTextureValid(0, false, _numLayers, _format, _flags, &err);
@@ -3801,19 +3804,19 @@ error:
 		return s_ctx->createTexture(mem, _flags, 0, NULL, _ratio, NULL != _mem);
 		return s_ctx->createTexture(mem, _flags, 0, NULL, _ratio, NULL != _mem);
 	}
 	}
 
 
-	TextureHandle createTexture2D(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
+	TextureHandle createTexture2D(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags, const Memory* _mem)
 	{
 	{
 		BX_CHECK(_width > 0 && _height > 0, "Invalid texture size (width %d, height %d).", _width, _height);
 		BX_CHECK(_width > 0 && _height > 0, "Invalid texture size (width %d, height %d).", _width, _height);
 		return createTexture2D(BackbufferRatio::Count, _width, _height, _hasMips, _numLayers, _format, _flags, _mem);
 		return createTexture2D(BackbufferRatio::Count, _width, _height, _hasMips, _numLayers, _format, _flags, _mem);
 	}
 	}
 
 
-	TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint32_t _flags)
+	TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags)
 	{
 	{
 		BX_CHECK(_ratio < BackbufferRatio::Count, "Invalid back buffer ratio.");
 		BX_CHECK(_ratio < BackbufferRatio::Count, "Invalid back buffer ratio.");
 		return createTexture2D(_ratio, 0, 0, _hasMips, _numLayers, _format, _flags, NULL);
 		return createTexture2D(_ratio, 0, 0, _hasMips, _numLayers, _format, _flags, NULL);
 	}
 	}
 
 
-	TextureHandle createTexture3D(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
+	TextureHandle createTexture3D(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, TextureFormat::Enum _format, uint64_t _flags, const Memory* _mem)
 	{
 	{
 		bx::Error err;
 		bx::Error err;
 		isTextureValid(_depth, false, 1, _format, _flags, &err);
 		isTextureValid(_depth, false, 1, _format, _flags, &err);
@@ -3854,7 +3857,7 @@ error:
 		return s_ctx->createTexture(mem, _flags, 0, NULL, BackbufferRatio::Count, NULL != _mem);
 		return s_ctx->createTexture(mem, _flags, 0, NULL, BackbufferRatio::Count, NULL != _mem);
 	}
 	}
 
 
-	TextureHandle createTextureCube(uint16_t _size, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
+	TextureHandle createTextureCube(uint16_t _size, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags, const Memory* _mem)
 	{
 	{
 		bx::Error err;
 		bx::Error err;
 		isTextureValid(0, true, _numLayers, _format, _flags, &err);
 		isTextureValid(0, true, _numLayers, _format, _flags, &err);
@@ -3964,14 +3967,14 @@ error:
 		return s_ctx->readTexture(_handle, _data, _mip);
 		return s_ctx->readTexture(_handle, _data, _mip);
 	}
 	}
 
 
-	FrameBufferHandle createFrameBuffer(uint16_t _width, uint16_t _height, TextureFormat::Enum _format, uint32_t _textureFlags)
+	FrameBufferHandle createFrameBuffer(uint16_t _width, uint16_t _height, TextureFormat::Enum _format, uint64_t _textureFlags)
 	{
 	{
 		_textureFlags |= _textureFlags&BGFX_TEXTURE_RT_MSAA_MASK ? 0 : BGFX_TEXTURE_RT;
 		_textureFlags |= _textureFlags&BGFX_TEXTURE_RT_MSAA_MASK ? 0 : BGFX_TEXTURE_RT;
 		TextureHandle th = createTexture2D(_width, _height, false, 1, _format, _textureFlags);
 		TextureHandle th = createTexture2D(_width, _height, false, 1, _format, _textureFlags);
 		return createFrameBuffer(1, &th, true);
 		return createFrameBuffer(1, &th, true);
 	}
 	}
 
 
-	FrameBufferHandle createFrameBuffer(BackbufferRatio::Enum _ratio, TextureFormat::Enum _format, uint32_t _textureFlags)
+	FrameBufferHandle createFrameBuffer(BackbufferRatio::Enum _ratio, TextureFormat::Enum _format, uint64_t _textureFlags)
 	{
 	{
 		BX_CHECK(_ratio < BackbufferRatio::Count, "Invalid back buffer ratio.");
 		BX_CHECK(_ratio < BackbufferRatio::Count, "Invalid back buffer ratio.");
 		_textureFlags |= _textureFlags&BGFX_TEXTURE_RT_MSAA_MASK ? 0 : BGFX_TEXTURE_RT;
 		_textureFlags |= _textureFlags&BGFX_TEXTURE_RT_MSAA_MASK ? 0 : BGFX_TEXTURE_RT;
@@ -4004,7 +4007,7 @@ error:
 		return s_ctx->createFrameBuffer(_num, _attachment, _destroyTextures);
 		return s_ctx->createFrameBuffer(_num, _attachment, _destroyTextures);
 	}
 	}
 
 
-	FrameBufferHandle createFrameBuffer(void* _nwh, uint16_t _width, uint16_t _height, TextureFormat::Enum _depthFormat)
+	FrameBufferHandle createFrameBuffer(void* _nwh, uint16_t _width, uint16_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat)
 	{
 	{
 		BGFX_CHECK_CAPS(BGFX_CAPS_SWAP_CHAIN, "Swap chain is not supported!");
 		BGFX_CHECK_CAPS(BGFX_CAPS_SWAP_CHAIN, "Swap chain is not supported!");
 		BX_WARN(_width > 0 && _height > 0
 		BX_WARN(_width > 0 && _height > 0
@@ -4012,10 +4015,19 @@ error:
 			, _width
 			, _width
 			, _height
 			, _height
 			);
 			);
+		BX_CHECK(_format == TextureFormat::Count || bimg::isColor(bimg::TextureFormat::Enum(_format) )
+			, "Invalid texture format for color (%s)."
+			, bimg::getName(bimg::TextureFormat::Enum(_format) )
+			);
+		BX_CHECK(_format == TextureFormat::Count || bimg::isDepth(bimg::TextureFormat::Enum(_depthFormat) )
+			, "Invalid texture format for depth (%s)."
+			, bimg::getName(bimg::TextureFormat::Enum(_depthFormat) )
+			);
 		return s_ctx->createFrameBuffer(
 		return s_ctx->createFrameBuffer(
 			  _nwh
 			  _nwh
 			, bx::max<uint16_t>(_width, 1)
 			, bx::max<uint16_t>(_width, 1)
 			, bx::max<uint16_t>(_height, 1)
 			, bx::max<uint16_t>(_height, 1)
+			, _format
 			, _depthFormat
 			, _depthFormat
 			);
 			);
 	}
 	}
@@ -5103,7 +5115,7 @@ BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle)
 	bgfx::destroy(handle.cpp);
 	bgfx::destroy(handle.cpp);
 }
 }
 
 
-BGFX_C_API bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags)
+BGFX_C_API bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags)
 {
 {
 	return bgfx::isTextureValid(_depth, _cubeMap, _numLayers, bgfx::TextureFormat::Enum(_format), _flags);
 	return bgfx::isTextureValid(_depth, _cubeMap, _numLayers, bgfx::TextureFormat::Enum(_format), _flags);
 }
 }
@@ -5114,7 +5126,7 @@ BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t* _info, uint16_t _wid
 	bgfx::calcTextureSize(info, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format) );
 	bgfx::calcTextureSize(info, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format) );
 }
 }
 
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint32_t _flags, uint8_t _skip, bgfx_texture_info_t* _info)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t* _info)
 {
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	bgfx::TextureInfo* info = (bgfx::TextureInfo*)_info;
 	bgfx::TextureInfo* info = (bgfx::TextureInfo*)_info;
@@ -5122,28 +5134,28 @@ BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem,
 	return handle.c;
 	return handle.c;
 }
 }
 
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
 {
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	handle.cpp = bgfx::createTexture2D(_width, _height, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
 	handle.cpp = bgfx::createTexture2D(_width, _height, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
 	return handle.c;
 	return handle.c;
 }
 }
 
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags)
 {
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	handle.cpp = bgfx::createTexture2D(bgfx::BackbufferRatio::Enum(_ratio), _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags);
 	handle.cpp = bgfx::createTexture2D(bgfx::BackbufferRatio::Enum(_ratio), _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags);
 	return handle.c;
 	return handle.c;
 }
 }
 
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
 {
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	handle.cpp = bgfx::createTexture3D(_width, _height, _depth, _hasMips, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
 	handle.cpp = bgfx::createTexture3D(_width, _height, _depth, _hasMips, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
 	return handle.c;
 	return handle.c;
 }
 }
 
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
 {
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle;
 	handle.cpp = bgfx::createTextureCube(_size, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
 	handle.cpp = bgfx::createTextureCube(_size, _hasMips, _numLayers, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem);
@@ -5192,14 +5204,14 @@ BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle)
 	bgfx::destroy(handle.cpp);
 	bgfx::destroy(handle.cpp);
 }
 }
 
 
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint32_t _textureFlags)
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags)
 {
 {
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
 	handle.cpp = bgfx::createFrameBuffer(_width, _height, bgfx::TextureFormat::Enum(_format), _textureFlags);
 	handle.cpp = bgfx::createFrameBuffer(_width, _height, bgfx::TextureFormat::Enum(_format), _textureFlags);
 	return handle.c;
 	return handle.c;
 }
 }
 
 
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint32_t _textureFlags)
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags)
 {
 {
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
 	handle.cpp = bgfx::createFrameBuffer(bgfx::BackbufferRatio::Enum(_ratio), bgfx::TextureFormat::Enum(_format), _textureFlags);
 	handle.cpp = bgfx::createFrameBuffer(bgfx::BackbufferRatio::Enum(_ratio), bgfx::TextureFormat::Enum(_format), _textureFlags);
@@ -5220,10 +5232,10 @@ BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(u
 	return handle.c;
 	return handle.c;
 }
 }
 
 
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _depthFormat)
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat)
 {
 {
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
-	handle.cpp = bgfx::createFrameBuffer(_nwh, _width, _height, bgfx::TextureFormat::Enum(_depthFormat) );
+	handle.cpp = bgfx::createFrameBuffer(_nwh, _width, _height, bgfx::TextureFormat::Enum(_format), bgfx::TextureFormat::Enum(_depthFormat) );
 	return handle.c;
 	return handle.c;
 }
 }
 
 

+ 5 - 4
src/bgfx_p.h

@@ -2643,7 +2643,7 @@ namespace bgfx
 		virtual void destroyShader(ShaderHandle _handle) = 0;
 		virtual void destroyShader(ShaderHandle _handle) = 0;
 		virtual void createProgram(ProgramHandle _handle, ShaderHandle _vsh, ShaderHandle _fsh) = 0;
 		virtual void createProgram(ProgramHandle _handle, ShaderHandle _vsh, ShaderHandle _fsh) = 0;
 		virtual void destroyProgram(ProgramHandle _handle) = 0;
 		virtual void destroyProgram(ProgramHandle _handle) = 0;
-		virtual void* createTexture(TextureHandle _handle, const Memory* _mem, uint32_t _flags, uint8_t _skip) = 0;
+		virtual void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip) = 0;
 		virtual void updateTextureBegin(TextureHandle _handle, uint8_t _side, uint8_t _mip) = 0;
 		virtual void updateTextureBegin(TextureHandle _handle, uint8_t _side, uint8_t _mip) = 0;
 		virtual void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) = 0;
 		virtual void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem) = 0;
 		virtual void updateTextureEnd() = 0;
 		virtual void updateTextureEnd() = 0;
@@ -2653,7 +2653,7 @@ namespace bgfx
 		virtual uintptr_t getInternal(TextureHandle _handle) = 0;
 		virtual uintptr_t getInternal(TextureHandle _handle) = 0;
 		virtual void destroyTexture(TextureHandle _handle) = 0;
 		virtual void destroyTexture(TextureHandle _handle) = 0;
 		virtual void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) = 0;
 		virtual void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) = 0;
-		virtual void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) = 0;
+		virtual void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) = 0;
 		virtual void destroyFrameBuffer(FrameBufferHandle _handle) = 0;
 		virtual void destroyFrameBuffer(FrameBufferHandle _handle) = 0;
 		virtual void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) = 0;
 		virtual void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) = 0;
 		virtual void destroyUniform(UniformHandle _handle) = 0;
 		virtual void destroyUniform(UniformHandle _handle) = 0;
@@ -3854,7 +3854,7 @@ namespace bgfx
 			}
 			}
 		}
 		}
 
 
-		BGFX_API_FUNC(TextureHandle createTexture(const Memory* _mem, uint32_t _flags, uint8_t _skip, TextureInfo* _info, BackbufferRatio::Enum _ratio, bool _immutable) )
+		BGFX_API_FUNC(TextureHandle createTexture(const Memory* _mem, uint64_t _flags, uint8_t _skip, TextureInfo* _info, BackbufferRatio::Enum _ratio, bool _immutable) )
 		{
 		{
 			BGFX_MUTEX_SCOPE(m_resourceApiLock);
 			BGFX_MUTEX_SCOPE(m_resourceApiLock);
 
 
@@ -4161,7 +4161,7 @@ namespace bgfx
 			return handle;
 			return handle;
 		}
 		}
 
 
-		BGFX_API_FUNC(FrameBufferHandle createFrameBuffer(void* _nwh, uint16_t _width, uint16_t _height, TextureFormat::Enum _depthFormat) )
+		BGFX_API_FUNC(FrameBufferHandle createFrameBuffer(void* _nwh, uint16_t _width, uint16_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) )
 		{
 		{
 			BGFX_MUTEX_SCOPE(m_resourceApiLock);
 			BGFX_MUTEX_SCOPE(m_resourceApiLock);
 
 
@@ -4176,6 +4176,7 @@ namespace bgfx
 				cmdbuf.write(_nwh);
 				cmdbuf.write(_nwh);
 				cmdbuf.write(_width);
 				cmdbuf.write(_width);
 				cmdbuf.write(_height);
 				cmdbuf.write(_height);
+				cmdbuf.write(_format);
 				cmdbuf.write(_depthFormat);
 				cmdbuf.write(_depthFormat);
 
 
 				FrameBufferRef& ref = m_frameBufferRef[handle.idx];
 				FrameBufferRef& ref = m_frameBufferRef[handle.idx];

+ 27 - 11
src/renderer_d3d11.cpp

@@ -1683,7 +1683,7 @@ namespace bgfx { namespace d3d11
 			m_program[_handle.idx].destroy();
 			m_program[_handle.idx].destroy();
 		}
 		}
 
 
-		void* createTexture(TextureHandle _handle, const Memory* _mem, uint32_t _flags, uint8_t _skip) override
+		void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip) override
 		{
 		{
 			return m_textures[_handle.idx].create(_mem, _flags, _skip);
 			return m_textures[_handle.idx].create(_mem, _flags, _skip);
 		}
 		}
@@ -1783,11 +1783,11 @@ namespace bgfx { namespace d3d11
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 		}
 		}
 
 
-		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) override
+		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) override
 		{
 		{
 			uint16_t denseIdx = m_numWindows++;
 			uint16_t denseIdx = m_numWindows++;
 			m_windows[denseIdx] = _handle;
 			m_windows[denseIdx] = _handle;
-			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _depthFormat);
+			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
 		}
 		}
 
 
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
@@ -2938,7 +2938,7 @@ namespace bgfx { namespace d3d11
 			return uav;
 			return uav;
 		}
 		}
 
 
-		ID3D11ShaderResourceView* getCachedSrv(TextureHandle _handle, uint8_t _mip, bool _compute = false)
+		ID3D11ShaderResourceView* getCachedSrv(TextureHandle _handle, uint8_t _mip, bool _compute = false, bool _stencil = false)
 		{
 		{
 			bx::HashMurmur2A murmur;
 			bx::HashMurmur2A murmur;
 			murmur.begin();
 			murmur.begin();
@@ -2946,6 +2946,7 @@ namespace bgfx { namespace d3d11
 			murmur.add(_mip);
 			murmur.add(_mip);
 			murmur.add(0);
 			murmur.add(0);
 			murmur.add(_compute);
 			murmur.add(_compute);
+			murmur.add(_stencil);
 			uint32_t hash = murmur.end();
 			uint32_t hash = murmur.end();
 
 
 			IUnknown** ptr = m_srvUavLru.find(hash);
 			IUnknown** ptr = m_srvUavLru.find(hash);
@@ -2958,7 +2959,7 @@ namespace bgfx { namespace d3d11
 				const bool msaaSample = 1 < msaa.Count && 0 != (texture.m_flags&BGFX_TEXTURE_MSAA_SAMPLE);
 				const bool msaaSample = 1 < msaa.Count && 0 != (texture.m_flags&BGFX_TEXTURE_MSAA_SAMPLE);
 
 
 				D3D11_SHADER_RESOURCE_VIEW_DESC desc;
 				D3D11_SHADER_RESOURCE_VIEW_DESC desc;
-				desc.Format = texture.getSrvFormat();
+				desc.Format = _stencil ? DXGI_FORMAT_X24_TYPELESS_G8_UINT : texture.getSrvFormat();
 				switch (texture.m_type)
 				switch (texture.m_type)
 				{
 				{
 				case TextureD3D11::Texture2D:
 				case TextureD3D11::Texture2D:
@@ -3990,7 +3991,7 @@ namespace bgfx { namespace d3d11
 		}
 		}
 	}
 	}
 
 
-	void* TextureD3D11::create(const Memory* _mem, uint32_t _flags, uint8_t _skip)
+	void* TextureD3D11::create(const Memory* _mem, uint64_t _flags, uint8_t _skip)
 	{
 	{
 		void* directAccessPtr = NULL;
 		void* directAccessPtr = NULL;
 
 
@@ -4406,10 +4407,24 @@ namespace bgfx { namespace d3d11
 	void TextureD3D11::commit(uint8_t _stage, uint32_t _flags, const float _palette[][4])
 	void TextureD3D11::commit(uint8_t _stage, uint32_t _flags, const float _palette[][4])
 	{
 	{
 		TextureStage& ts = s_renderD3D11->m_textureStage;
 		TextureStage& ts = s_renderD3D11->m_textureStage;
-		ts.m_srv[_stage] = m_srv;
-		uint32_t flags = 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags)
+
+		if (0 != (_flags & BGFX_SAMPLER_SAMPLE_STENCIL) )
+		{
+			ts.m_srv[_stage] = s_renderD3D11->getCachedSrv(
+				  TextureHandle{ uint16_t(this - s_renderD3D11->m_textures) }
+				, 0
+				, false
+				, true
+				);
+		}
+		else
+		{
+			ts.m_srv[_stage] = m_srv;
+		}
+
+		const uint32_t flags = 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags)
 			? _flags
 			? _flags
-			: m_flags
+			: uint32_t(m_flags)
 			;
 			;
 		uint32_t index = (flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
 		uint32_t index = (flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
 		ts.m_sampler[_stage] = s_renderD3D11->getSamplerState(flags
 		ts.m_sampler[_stage] = s_renderD3D11->getSamplerState(flags
@@ -4471,10 +4486,11 @@ namespace bgfx { namespace d3d11
 		postReset();
 		postReset();
 	}
 	}
 
 
-	void FrameBufferD3D11::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat)
+	void FrameBufferD3D11::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat)
 	{
 	{
 		SwapChainDesc scd;
 		SwapChainDesc scd;
 		bx::memCopy(&scd, &s_renderD3D11->m_scd, sizeof(SwapChainDesc) );
 		bx::memCopy(&scd, &s_renderD3D11->m_scd, sizeof(SwapChainDesc) );
+		scd.format = TextureFormat::Count == _format ? scd.format : s_textureFormat[_format].m_fmt;
 		scd.width  = _width;
 		scd.width  = _width;
 		scd.height = _height;
 		scd.height = _height;
 		scd.nwh    = _nwh;
 		scd.nwh    = _nwh;
@@ -5394,7 +5410,7 @@ namespace bgfx { namespace d3d11
 									else
 									else
 									{
 									{
 										srv[ii] = s_renderD3D11->getCachedSrv(texture.getHandle(), bind.m_un.m_compute.m_mip, true);
 										srv[ii] = s_renderD3D11->getCachedSrv(texture.getHandle(), bind.m_un.m_compute.m_mip, true);
-										sampler[ii] = s_renderD3D11->getSamplerState(texture.m_flags, NULL);
+										sampler[ii] = s_renderD3D11->getSamplerState(uint32_t(texture.m_flags), NULL);
 									}
 									}
 								}
 								}
 								break;
 								break;

+ 3 - 3
src/renderer_d3d11.h

@@ -264,7 +264,7 @@ namespace bgfx { namespace d3d11
 		{
 		{
 		}
 		}
 
 
-		void* create(const Memory* _mem, uint32_t _flags, uint8_t _skip);
+		void* create(const Memory* _mem, uint64_t _flags, uint8_t _skip);
 		void destroy();
 		void destroy();
 		void overrideInternal(uintptr_t _ptr);
 		void overrideInternal(uintptr_t _ptr);
 		void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
 		void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
@@ -290,7 +290,7 @@ namespace bgfx { namespace d3d11
 
 
 		ID3D11ShaderResourceView*  m_srv;
 		ID3D11ShaderResourceView*  m_srv;
 		ID3D11UnorderedAccessView* m_uav;
 		ID3D11UnorderedAccessView* m_uav;
-		uint32_t m_flags;
+		uint64_t m_flags;
 		uint32_t m_width;
 		uint32_t m_width;
 		uint32_t m_height;
 		uint32_t m_height;
 		uint32_t m_depth;
 		uint32_t m_depth;
@@ -315,7 +315,7 @@ namespace bgfx { namespace d3d11
 		}
 		}
 
 
 		void create(uint8_t _num, const Attachment* _attachment);
 		void create(uint8_t _num, const Attachment* _attachment);
-		void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
+		void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat);
 		uint16_t destroy();
 		uint16_t destroy();
 		void preReset(bool _force = false);
 		void preReset(bool _force = false);
 		void postReset();
 		void postReset();

+ 7 - 6
src/renderer_d3d12.cpp

@@ -1523,7 +1523,7 @@ namespace bgfx { namespace d3d12
 			m_program[_handle.idx].destroy();
 			m_program[_handle.idx].destroy();
 		}
 		}
 
 
-		void* createTexture(TextureHandle _handle, const Memory* _mem, uint32_t _flags, uint8_t _skip) override
+		void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip) override
 		{
 		{
 			return m_textures[_handle.idx].create(_mem, _flags, _skip);
 			return m_textures[_handle.idx].create(_mem, _flags, _skip);
 		}
 		}
@@ -1654,7 +1654,7 @@ namespace bgfx { namespace d3d12
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 		}
 		}
 
 
-		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) override
+		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) override
 		{
 		{
 			finishAll(true);
 			finishAll(true);
 
 
@@ -1668,7 +1668,7 @@ namespace bgfx { namespace d3d12
 
 
 			uint16_t denseIdx = m_numWindows++;
 			uint16_t denseIdx = m_numWindows++;
 			m_windows[denseIdx] = _handle;
 			m_windows[denseIdx] = _handle;
-			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _depthFormat);
+			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
 		}
 		}
 
 
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
@@ -4435,7 +4435,7 @@ namespace bgfx { namespace d3d12
 		bx::read(&reader, m_size);
 		bx::read(&reader, m_size);
 	}
 	}
 
 
-	void* TextureD3D12::create(const Memory* _mem, uint32_t _flags, uint8_t _skip)
+	void* TextureD3D12::create(const Memory* _mem, uint64_t _flags, uint8_t _skip)
 	{
 	{
 		bimg::ImageContainer imageContainer;
 		bimg::ImageContainer imageContainer;
 
 
@@ -4892,13 +4892,14 @@ namespace bgfx { namespace d3d12
 		postReset();
 		postReset();
 	}
 	}
 
 
-	void FrameBufferD3D12::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat)
+	void FrameBufferD3D12::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat)
 	{
 	{
 		BX_UNUSED(_nwh, _width, _height, _depthFormat);
 		BX_UNUSED(_nwh, _width, _height, _depthFormat);
 
 
 #if BX_PLATFORM_WINDOWS
 #if BX_PLATFORM_WINDOWS
 		SwapChainDesc scd;
 		SwapChainDesc scd;
 		bx::memCopy(&scd, &s_renderD3D12->m_scd, sizeof(DXGI_SWAP_CHAIN_DESC) );
 		bx::memCopy(&scd, &s_renderD3D12->m_scd, sizeof(DXGI_SWAP_CHAIN_DESC) );
+		scd.format = TextureFormat::Count == _format ? scd.format : s_textureFormat[_format].m_fmt;
 		scd.width  = _width;
 		scd.width  = _width;
 		scd.height = _height;
 		scd.height = _height;
 		scd.nwh    = _nwh;
 		scd.nwh    = _nwh;
@@ -5791,7 +5792,7 @@ namespace bgfx { namespace d3d12
 											{
 											{
 												texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
 												texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
 												scratchBuffer.allocSrv(srvHandle[ii], texture, bind.m_un.m_compute.m_mip);
 												scratchBuffer.allocSrv(srvHandle[ii], texture, bind.m_un.m_compute.m_mip);
-												samplerFlags[ii] = texture.m_flags;
+												samplerFlags[ii] = uint32_t(texture.m_flags);
 											}
 											}
 										}
 										}
 										break;
 										break;

+ 3 - 3
src/renderer_d3d12.h

@@ -311,7 +311,7 @@ namespace bgfx { namespace d3d12
 			bx::memSet(&m_uavd, 0, sizeof(m_uavd) );
 			bx::memSet(&m_uavd, 0, sizeof(m_uavd) );
 		}
 		}
 
 
-		void* create(const Memory* _mem, uint32_t _flags, uint8_t _skip);
+		void* create(const Memory* _mem, uint64_t _flags, uint8_t _skip);
 		void destroy();
 		void destroy();
 		void update(ID3D12GraphicsCommandList* _commandList, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
 		void update(ID3D12GraphicsCommandList* _commandList, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
 		void resolve();
 		void resolve();
@@ -322,7 +322,7 @@ namespace bgfx { namespace d3d12
 		ID3D12Resource* m_ptr;
 		ID3D12Resource* m_ptr;
 		void* m_directAccessPtr;
 		void* m_directAccessPtr;
 		D3D12_RESOURCE_STATES m_state;
 		D3D12_RESOURCE_STATES m_state;
-		uint32_t m_flags;
+		uint64_t m_flags;
 		uint32_t m_width;
 		uint32_t m_width;
 		uint32_t m_height;
 		uint32_t m_height;
 		uint32_t m_depth;
 		uint32_t m_depth;
@@ -350,7 +350,7 @@ namespace bgfx { namespace d3d12
 		}
 		}
 
 
 		void create(uint8_t _num, const Attachment* _attachment);
 		void create(uint8_t _num, const Attachment* _attachment);
-		void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
+		void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat);
 		uint16_t destroy();
 		uint16_t destroy();
 		HRESULT present(uint32_t _syncInterval, uint32_t _flags);
 		HRESULT present(uint32_t _syncInterval, uint32_t _flags);
 		void preReset();
 		void preReset();

+ 8 - 7
src/renderer_d3d9.cpp

@@ -1035,7 +1035,7 @@ namespace bgfx { namespace d3d9
 			m_program[_handle.idx].destroy();
 			m_program[_handle.idx].destroy();
 		}
 		}
 
 
-		void* createTexture(TextureHandle _handle, const Memory* _mem, uint32_t _flags, uint8_t _skip) override
+		void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip) override
 		{
 		{
 			m_textures[_handle.idx].create(_mem, _flags, _skip);
 			m_textures[_handle.idx].create(_mem, _flags, _skip);
 			return NULL;
 			return NULL;
@@ -1145,11 +1145,11 @@ namespace bgfx { namespace d3d9
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 		}
 		}
 
 
-		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) override
+		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) override
 		{
 		{
 			uint16_t denseIdx = m_numWindows++;
 			uint16_t denseIdx = m_numWindows++;
 			m_windows[denseIdx] = _handle;
 			m_windows[denseIdx] = _handle;
-			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _depthFormat);
+			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
 		}
 		}
 
 
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
@@ -2894,7 +2894,7 @@ namespace bgfx { namespace d3d9
 		return surface;
 		return surface;
 	}
 	}
 
 
-	void TextureD3D9::create(const Memory* _mem, uint32_t _flags, uint8_t _skip)
+	void TextureD3D9::create(const Memory* _mem, uint64_t _flags, uint8_t _skip)
 	{
 	{
 		bimg::ImageContainer imageContainer;
 		bimg::ImageContainer imageContainer;
 
 
@@ -3107,9 +3107,9 @@ namespace bgfx { namespace d3d9
 
 
 	void TextureD3D9::commit(uint8_t _stage, uint32_t _flags, const float _palette[][4])
 	void TextureD3D9::commit(uint8_t _stage, uint32_t _flags, const float _palette[][4])
 	{
 	{
-		uint32_t flags = 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags)
+		const uint32_t flags = 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags)
 			? _flags
 			? _flags
-			: m_flags
+			: uint32_t(m_flags)
 			;
 			;
 		uint32_t index = (flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
 		uint32_t index = (flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
 		s_renderD3D9->setSamplerState(_stage, flags, _palette[index]);
 		s_renderD3D9->setSamplerState(_stage, flags, _palette[index]);
@@ -3235,7 +3235,7 @@ namespace bgfx { namespace d3d9
 		}
 		}
 	}
 	}
 
 
-	void FrameBufferD3D9::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat)
+	void FrameBufferD3D9::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat)
 	{
 	{
 		BX_UNUSED(_depthFormat);
 		BX_UNUSED(_depthFormat);
 
 
@@ -3246,6 +3246,7 @@ namespace bgfx { namespace d3d9
 
 
 		D3DPRESENT_PARAMETERS params;
 		D3DPRESENT_PARAMETERS params;
 		bx::memCopy(&params, &s_renderD3D9->m_params, sizeof(D3DPRESENT_PARAMETERS) );
 		bx::memCopy(&params, &s_renderD3D9->m_params, sizeof(D3DPRESENT_PARAMETERS) );
+		params.BackBufferFormat = TextureFormat::Count == _format ? params.BackBufferFormat : s_textureFormat[_format].m_fmt;
 		params.BackBufferWidth  = m_width;
 		params.BackBufferWidth  = m_width;
 		params.BackBufferHeight = m_height;
 		params.BackBufferHeight = m_height;
 
 

+ 3 - 3
src/renderer_d3d9.h

@@ -314,7 +314,7 @@ namespace bgfx { namespace d3d9
 		void dirty(uint8_t _side, const Rect& _rect, uint16_t _z, uint16_t _depth);
 		void dirty(uint8_t _side, const Rect& _rect, uint16_t _z, uint16_t _depth);
 		IDirect3DSurface9* getSurface(uint8_t _side = 0, uint8_t _mip = 0) const;
 		IDirect3DSurface9* getSurface(uint8_t _side = 0, uint8_t _mip = 0) const;
 
 
-		void create(const Memory* _mem, uint32_t _flags, uint8_t _skip);
+		void create(const Memory* _mem, uint64_t _flags, uint8_t _skip);
 
 
 		void destroy(bool _resize = false)
 		void destroy(bool _resize = false)
 		{
 		{
@@ -371,7 +371,7 @@ namespace bgfx { namespace d3d9
 			IDirect3DCubeTexture9*   m_stagingCube;
 			IDirect3DCubeTexture9*   m_stagingCube;
 		};
 		};
 
 
-		uint32_t m_flags;
+		uint64_t m_flags;
 		uint32_t m_width;
 		uint32_t m_width;
 		uint32_t m_height;
 		uint32_t m_height;
 		uint32_t m_depth;
 		uint32_t m_depth;
@@ -395,7 +395,7 @@ namespace bgfx { namespace d3d9
 		}
 		}
 
 
 		void create(uint8_t _num, const Attachment* _attachment);
 		void create(uint8_t _num, const Attachment* _attachment);
-		void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
+		void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat);
 		uint16_t destroy();
 		uint16_t destroy();
 		HRESULT present();
 		HRESULT present();
 		void resolve() const;
 		void resolve() const;

+ 10 - 10
src/renderer_gl.cpp

@@ -2723,7 +2723,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 			m_program[_handle.idx].destroy();
 			m_program[_handle.idx].destroy();
 		}
 		}
 
 
-		void* createTexture(TextureHandle _handle, const Memory* _mem, uint32_t _flags, uint8_t _skip) override
+		void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip) override
 		{
 		{
 			m_textures[_handle.idx].create(_mem, _flags, _skip);
 			m_textures[_handle.idx].create(_mem, _flags, _skip);
 			return NULL;
 			return NULL;
@@ -2865,11 +2865,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 		}
 		}
 
 
-		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) override
+		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) override
 		{
 		{
 			uint16_t denseIdx = m_numWindows++;
 			uint16_t denseIdx = m_numWindows++;
 			m_windows[denseIdx] = _handle;
 			m_windows[denseIdx] = _handle;
-			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _depthFormat);
+			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
 		}
 		}
 
 
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
@@ -4535,7 +4535,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 		GL_CHECK(glDeleteBuffers(1, &m_id) );
 		GL_CHECK(glDeleteBuffers(1, &m_id) );
 	}
 	}
 
 
-	bool TextureGL::init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips, uint32_t _flags)
+	bool TextureGL::init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips, uint64_t _flags)
 	{
 	{
 		m_target  = _target;
 		m_target  = _target;
 		m_numMips = _numMips;
 		m_numMips = _numMips;
@@ -4621,7 +4621,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 				}
 				}
 			}
 			}
 
 
-			setSamplerState(_flags, NULL);
+			setSamplerState(uint32_t(_flags), NULL);
 
 
 			if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
 			if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
 			&&  TextureFormat::BGRA8 == m_requestedFormat
 			&&  TextureFormat::BGRA8 == m_requestedFormat
@@ -4681,7 +4681,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 		return true;
 		return true;
 	}
 	}
 
 
-	void TextureGL::create(const Memory* _mem, uint32_t _flags, uint8_t _skip)
+	void TextureGL::create(const Memory* _mem, uint64_t _flags, uint8_t _skip)
 	{
 	{
 		bimg::ImageContainer imageContainer;
 		bimg::ImageContainer imageContainer;
 
 
@@ -5150,7 +5150,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 	{
 	{
 		const uint32_t flags = 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags)
 		const uint32_t flags = 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags)
 			? _flags
 			? _flags
-			: m_flags
+			: uint32_t(m_flags)
 			;
 			;
 		const uint32_t index = (flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
 		const uint32_t index = (flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT;
 
 
@@ -5988,9 +5988,9 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 		}
 		}
 	}
 	}
 
 
-	void FrameBufferGL::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat)
+	void FrameBufferGL::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat)
 	{
 	{
-		BX_UNUSED(_depthFormat);
+		BX_UNUSED(_format, _depthFormat);
 		m_swapChain = s_renderGL->m_glctx.createSwapChain(_nwh);
 		m_swapChain = s_renderGL->m_glctx.createSwapChain(_nwh);
 		m_width     = _width;
 		m_width     = _width;
 		m_height    = _height;
 		m_height    = _height;
@@ -6514,7 +6514,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 										if (Access::Read == bind.m_un.m_compute.m_access)
 										if (Access::Read == bind.m_un.m_compute.m_access)
 										{
 										{
 											TextureGL& texture = m_textures[bind.m_idx];
 											TextureGL& texture = m_textures[bind.m_idx];
-											texture.commit(ii, texture.m_flags, _render->m_colorPalette);
+											texture.commit(ii, uint32_t(texture.m_flags), _render->m_colorPalette);
 										}
 										}
 										else
 										else
 										{
 										{

+ 4 - 4
src/renderer_gl.h

@@ -1238,8 +1238,8 @@ namespace bgfx { namespace gl
 		{
 		{
 		}
 		}
 
 
-		bool init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips, uint32_t _flags);
-		void create(const Memory* _mem, uint32_t _flags, uint8_t _skip);
+		bool init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips, uint64_t _flags);
+		void create(const Memory* _mem, uint64_t _flags, uint8_t _skip);
 		void destroy();
 		void destroy();
 		void overrideInternal(uintptr_t _ptr);
 		void overrideInternal(uintptr_t _ptr);
 		void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
 		void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
@@ -1260,7 +1260,7 @@ namespace bgfx { namespace gl
 		GLenum m_target;
 		GLenum m_target;
 		GLenum m_fmt;
 		GLenum m_fmt;
 		GLenum m_type;
 		GLenum m_type;
-		uint32_t m_flags;
+		uint64_t m_flags;
 		uint32_t m_currentSamplerHash;
 		uint32_t m_currentSamplerHash;
 		uint32_t m_width;
 		uint32_t m_width;
 		uint32_t m_height;
 		uint32_t m_height;
@@ -1299,7 +1299,7 @@ namespace bgfx { namespace gl
 		}
 		}
 
 
 		void create(uint8_t _num, const Attachment* _attachment);
 		void create(uint8_t _num, const Attachment* _attachment);
-		void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
+		void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat);
 		void postReset();
 		void postReset();
 		uint16_t destroy();
 		uint16_t destroy();
 		void resolve();
 		void resolve();

+ 3 - 2
src/renderer_mtl.h

@@ -849,7 +849,7 @@ namespace bgfx { namespace mtl
 		{
 		{
 		}
 		}
 
 
-		void create(const Memory* _mem, uint32_t _flags, uint8_t _skip);
+		void create(const Memory* _mem, uint64_t _flags, uint8_t _skip);
 
 
 		void destroy()
 		void destroy()
 		{
 		{
@@ -878,7 +878,7 @@ namespace bgfx { namespace mtl
 		Texture m_ptrMSAA;
 		Texture m_ptrMSAA;
 		Texture m_ptrStencil; // for emulating packed depth/stencil formats - only for iOS8...
 		Texture m_ptrStencil; // for emulating packed depth/stencil formats - only for iOS8...
 		SamplerState m_sampler;
 		SamplerState m_sampler;
-		uint32_t m_flags;
+		uint64_t m_flags;
 		uint32_t m_width;
 		uint32_t m_width;
 		uint32_t m_height;
 		uint32_t m_height;
 		uint32_t m_depth;
 		uint32_t m_depth;
@@ -904,6 +904,7 @@ namespace bgfx { namespace mtl
 			, void* _nwh
 			, void* _nwh
 			, uint32_t _width
 			, uint32_t _width
 			, uint32_t _height
 			, uint32_t _height
+			, TextureFormat::Enum _format
 			, TextureFormat::Enum _depthFormat
 			, TextureFormat::Enum _depthFormat
 			);
 			);
 		void postReset();
 		void postReset();

+ 7 - 7
src/renderer_mtl.mm

@@ -831,7 +831,7 @@ namespace bgfx { namespace mtl
 			m_program[_handle.idx].destroy();
 			m_program[_handle.idx].destroy();
 		}
 		}
 
 
-		void* createTexture(TextureHandle _handle, const Memory* _mem, uint32_t _flags, uint8_t _skip) override
+		void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip) override
 		{
 		{
 			m_textures[_handle.idx].create(_mem, _flags, _skip);
 			m_textures[_handle.idx].create(_mem, _flags, _skip);
 			return NULL;
 			return NULL;
@@ -921,11 +921,11 @@ namespace bgfx { namespace mtl
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 			m_frameBuffers[_handle.idx].create(_num, _attachment);
 		}
 		}
 
 
-		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) override
+		void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) override
 		{
 		{
 			uint16_t denseIdx = m_numWindows++;
 			uint16_t denseIdx = m_numWindows++;
 			m_windows[denseIdx] = _handle;
 			m_windows[denseIdx] = _handle;
-			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _depthFormat);
+			m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
 		}
 		}
 
 
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
 		void destroyFrameBuffer(FrameBufferHandle _handle) override
@@ -2551,9 +2551,9 @@ namespace bgfx { namespace mtl
 		BufferMtl::create(_size, _data, _flags, stride, true);
 		BufferMtl::create(_size, _data, _flags, stride, true);
 	}
 	}
 
 
-	void TextureMtl::create(const Memory* _mem, uint32_t _flags, uint8_t _skip)
+	void TextureMtl::create(const Memory* _mem, uint64_t _flags, uint8_t _skip)
 	{
 	{
-		m_sampler = s_renderMtl->getSamplerState(_flags);
+		m_sampler = s_renderMtl->getSamplerState(uint32_t(_flags) );
 
 
 		bimg::ImageContainer imageContainer;
 		bimg::ImageContainer imageContainer;
 
 
@@ -2950,9 +2950,9 @@ namespace bgfx { namespace mtl
 		m_pixelFormatHash = murmur.end();
 		m_pixelFormatHash = murmur.end();
 	}
 	}
 
 
-	void FrameBufferMtl::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat)
+	void FrameBufferMtl::create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat)
 	{
 	{
-		BX_UNUSED(_denseIdx, _nwh, _width, _height, _depthFormat);
+		BX_UNUSED(_denseIdx, _nwh, _width, _height, _format, _depthFormat);
 	}
 	}
 
 
 	void FrameBufferMtl::postReset()
 	void FrameBufferMtl::postReset()

+ 2 - 2
src/renderer_noop.cpp

@@ -155,7 +155,7 @@ namespace bgfx { namespace noop
 		{
 		{
 		}
 		}
 
 
-		void* createTexture(TextureHandle /*_handle*/, const Memory* /*_mem*/, uint32_t /*_flags*/, uint8_t /*_skip*/) override
+		void* createTexture(TextureHandle /*_handle*/, const Memory* /*_mem*/, uint64_t /*_flags*/, uint8_t /*_skip*/) override
 		{
 		{
 			return NULL;
 			return NULL;
 		}
 		}
@@ -197,7 +197,7 @@ namespace bgfx { namespace noop
 		{
 		{
 		}
 		}
 
 
-		void createFrameBuffer(FrameBufferHandle /*_handle*/, void* /*_nwh*/, uint32_t /*_width*/, uint32_t /*_height*/, TextureFormat::Enum /*_depthFormat*/) override
+		void createFrameBuffer(FrameBufferHandle /*_handle*/, void* /*_nwh*/, uint32_t /*_width*/, uint32_t /*_height*/, TextureFormat::Enum /*_format*/, TextureFormat::Enum /*_depthFormat*/) override
 		{
 		{
 		}
 		}
 
 

+ 2 - 2
src/renderer_vk.cpp

@@ -2060,7 +2060,7 @@ VK_IMPORT_DEVICE
 			m_program[_handle.idx].destroy();
 			m_program[_handle.idx].destroy();
 		}
 		}
 
 
-		void* createTexture(TextureHandle /*_handle*/, const Memory* /*_mem*/, uint32_t /*_flags*/, uint8_t /*_skip*/) override
+		void* createTexture(TextureHandle /*_handle*/, const Memory* /*_mem*/, uint64_t /*_flags*/, uint8_t /*_skip*/) override
 		{
 		{
 			return NULL;
 			return NULL;
 		}
 		}
@@ -2102,7 +2102,7 @@ VK_IMPORT_DEVICE
 		{
 		{
 		}
 		}
 
 
-		void createFrameBuffer(FrameBufferHandle /*_handle*/, void* /*_nwh*/, uint32_t /*_width*/, uint32_t /*_height*/, TextureFormat::Enum /*_depthFormat*/) override
+		void createFrameBuffer(FrameBufferHandle /*_handle*/, void* /*_nwh*/, uint32_t /*_width*/, uint32_t /*_height*/, TextureFormat::Enum /*_format*/, TextureFormat::Enum /*_depthFormat*/) override
 		{
 		{
 		}
 		}