2
0
Cedric Guillemet 6 жил өмнө
parent
commit
b4cac17b93

+ 6 - 8
bindings/cs/bgfx.cs

@@ -215,24 +215,22 @@ public static partial class bgfx
 		/// <summary>
 		/// <summary>
 		/// Discard only texture samplers
 		/// Discard only texture samplers
 		/// </summary>
 		/// </summary>
-		DiscardTextureSamplers = 0x0000000000000003,
+		DiscardTextureSamplers = 0x0000000000000004,
 	
 	
 		/// <summary>
 		/// <summary>
 		/// Discard only Compute shader related state
 		/// Discard only Compute shader related state
 		/// </summary>
 		/// </summary>
-		DiscardCompute         = 0x0000000000000004,
+		DiscardCompute         = 0x0000000000000008,
 	
 	
 		/// <summary>
 		/// <summary>
 		/// Discard only state
 		/// Discard only state
 		/// </summary>
 		/// </summary>
-		DiscardState           = 0x0000000000000005,
+		DiscardState           = 0x0000000000000010,
 	
 	
 		/// <summary>
 		/// <summary>
 		/// Discard every rendering states
 		/// Discard every rendering states
 		/// </summary>
 		/// </summary>
-		DiscardAll             = 0xffffffffffffffff,
-		DiscardShift           = 0,
-		DiscardMask            = 0x0000000000000007,
+		DiscardDefault         = 0x000000000000001f,
 		AlphaRefShift          = 40,
 		AlphaRefShift          = 40,
 		AlphaRefMask           = 0x0000ff0000000000,
 		AlphaRefMask           = 0x0000ff0000000000,
 	
 	
@@ -3825,7 +3823,7 @@ public static partial class bgfx
 	/// <param name="_flags">rendering states to discard</param>
 	/// <param name="_flags">rendering states to discard</param>
 	///
 	///
 	[DllImport(DllName, EntryPoint="bgfx_encoder_discard", CallingConvention = CallingConvention.Cdecl)]
 	[DllImport(DllName, EntryPoint="bgfx_encoder_discard", CallingConvention = CallingConvention.Cdecl)]
-	public static extern unsafe void encoder_discard(Encoder* _this, ulong _flags);
+	public static extern unsafe void encoder_discard(Encoder* _this, byte _flags);
 	
 	
 	/// <summary>
 	/// <summary>
 	/// Blit 2D texture region between two 2D textures.
 	/// Blit 2D texture region between two 2D textures.
@@ -4340,7 +4338,7 @@ public static partial class bgfx
 	/// <param name="_flags">rendering states to discard</param>
 	/// <param name="_flags">rendering states to discard</param>
 	///
 	///
 	[DllImport(DllName, EntryPoint="bgfx_discard", CallingConvention = CallingConvention.Cdecl)]
 	[DllImport(DllName, EntryPoint="bgfx_discard", CallingConvention = CallingConvention.Cdecl)]
-	public static extern unsafe void discard(ulong _flags);
+	public static extern unsafe void discard(byte _flags);
 	
 	
 	/// <summary>
 	/// <summary>
 	/// Blit 2D texture region between two 2D textures.
 	/// Blit 2D texture region between two 2D textures.

+ 4 - 4
bindings/d/funcs.d

@@ -1575,7 +1575,7 @@ version(BindBgfx_Static)
 	 * Params:
 	 * Params:
 	 * _flags = rendering states to discard
 	 * _flags = rendering states to discard
 	 */
 	 */
-	void bgfx_encoder_discard(bgfx_encoder_t* _this, ulong _flags);
+	void bgfx_encoder_discard(bgfx_encoder_t* _this, byte _flags);
 	
 	
 	/**
 	/**
 	 * Blit 2D texture region between two 2D textures.
 	 * Blit 2D texture region between two 2D textures.
@@ -2034,7 +2034,7 @@ version(BindBgfx_Static)
 	 * Params:
 	 * Params:
 	 * _flags = rendering states to discard
 	 * _flags = rendering states to discard
 	 */
 	 */
-	void bgfx_discard(ulong _flags);
+	void bgfx_discard(byte _flags);
 	
 	
 	/**
 	/**
 	 * Blit 2D texture region between two 2D textures.
 	 * Blit 2D texture region between two 2D textures.
@@ -3771,7 +3771,7 @@ else
 		 * Params:
 		 * Params:
 		 * _flags = rendering states to discard
 		 * _flags = rendering states to discard
 		 */
 		 */
-		alias da_bgfx_encoder_discard = void function(bgfx_encoder_t* _this, ulong _flags);
+		alias da_bgfx_encoder_discard = void function(bgfx_encoder_t* _this, byte _flags);
 		da_bgfx_encoder_discard bgfx_encoder_discard;
 		da_bgfx_encoder_discard bgfx_encoder_discard;
 		
 		
 		/**
 		/**
@@ -4272,7 +4272,7 @@ else
 		 * Params:
 		 * Params:
 		 * _flags = rendering states to discard
 		 * _flags = rendering states to discard
 		 */
 		 */
-		alias da_bgfx_discard = void function(ulong _flags);
+		alias da_bgfx_discard = void function(byte _flags);
 		da_bgfx_discard bgfx_discard;
 		da_bgfx_discard bgfx_discard;
 		
 		
 		/**
 		/**

+ 6 - 8
bindings/d/types.d

@@ -76,14 +76,12 @@ enum ulong BGFX_STATE_CULL_SHIFT = 36; /// Culling mode bit shift
 enum ulong BGFX_STATE_CULL_MASK = 0x0000003000000000; /// Culling mode bit mask
 enum ulong BGFX_STATE_CULL_MASK = 0x0000003000000000; /// Culling mode bit mask
 
 
 /// Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
 /// Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
-enum ulong BGFX_STATE_DISCARD_INDEX_BUFFER = 0x0000000000000001; /// Discard only Index Buffer
-enum ulong BGFX_STATE_DISCARD_VERTEX_STREAMS = 0x0000000000000002; /// Discard only Vertex Streams
-enum ulong BGFX_STATE_DISCARD_TEXTURE_SAMPLERS = 0x0000000000000003; /// Discard only texture samplers
-enum ulong BGFX_STATE_DISCARD_COMPUTE = 0x0000000000000004; /// Discard only Compute shader related state
-enum ulong BGFX_STATE_DISCARD_STATE = 0x0000000000000005; /// Discard only state
-enum ulong BGFX_STATE_DISCARD_ALL = 0xffffffffffffffff; /// Discard every rendering states
-enum ulong BGFX_STATE_DISCARD_SHIFT = 0; /// Discard flags bit shift
-enum ulong BGFX_STATE_DISCARD_MASK = 0x0000000000000007; /// Discard flags bit mask
+enum ubyte BGFX_STATE_DISCARD_INDEX_BUFFER = 0x01; /// Discard only Index Buffer
+enum ubyte BGFX_STATE_DISCARD_VERTEX_STREAMS = 0x02; /// Discard only Vertex Streams
+enum ubyte BGFX_STATE_DISCARD_TEXTURE_SAMPLERS = 0x04; /// Discard only texture samplers
+enum ubyte BGFX_STATE_DISCARD_COMPUTE = 0x08; /// Discard only Compute shader related state
+enum ubyte BGFX_STATE_DISCARD_STATE = 0x10; /// Discard only state
+enum ubyte BGFX_STATE_DISCARD_DEFAULT = 0x1f; /// Discard every rendering states
 
 
 /// Alpha reference value.
 /// Alpha reference value.
 enum ulong BGFX_STATE_ALPHA_REF_SHIFT = 40; /// Alpha reference bit shift
 enum ulong BGFX_STATE_ALPHA_REF_SHIFT = 40; /// Alpha reference bit shift

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

@@ -272,7 +272,7 @@ void VectorDisplay::endFrame()
 		}
 		}
 	}
 	}
 
 
-	bgfx::discard(BGFX_STATE_DISCARD_ALL);
+	bgfx::discard();
 
 
 	//now do last pass, combination of blur and normal buffer to screen
 	//now do last pass, combination of blur and normal buffer to screen
 	bgfx::setViewTransform(viewCounter, NULL, proj);
 	bgfx::setViewTransform(viewCounter, NULL, proj);

+ 2 - 2
include/bgfx/bgfx.h

@@ -1590,7 +1590,7 @@ namespace bgfx
 		///
 		///
 		/// @attention C99 equivalent is `bgfx_encoder_discard`.
 		/// @attention C99 equivalent is `bgfx_encoder_discard`.
 		///
 		///
-		void discard(uint64_t flags);
+		void discard(uint8_t flags);
 
 
 		/// Blit texture 2D region between two 2D textures.
 		/// Blit texture 2D region between two 2D textures.
 		///
 		///
@@ -3985,7 +3985,7 @@ namespace bgfx
 	///
 	///
 	/// @attention C99 equivalent is `bgfx_discard`.
 	/// @attention C99 equivalent is `bgfx_discard`.
 	///
 	///
-	void discard(uint64_t flags);
+	void discard(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT);
 
 
 	/// Blit 2D texture region between two 2D textures.
 	/// Blit 2D texture region between two 2D textures.
 	///
 	///

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

@@ -2675,7 +2675,7 @@ BGFX_C_API void bgfx_encoder_dispatch_indirect(bgfx_encoder_t* _this, bgfx_view_
  * @param[in] _flags rendering states to discard
  * @param[in] _flags rendering states to discard
  *
  *
  */
  */
-BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this, uint64_t _flags);
+BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this, uint8_t _flags);
 
 
 /**
 /**
  * Blit 2D texture region between two 2D textures.
  * Blit 2D texture region between two 2D textures.
@@ -3193,7 +3193,7 @@ BGFX_C_API void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t
  * @param[in] _flags rendering states to discard
  * @param[in] _flags rendering states to discard
  *
  *
  */
  */
-BGFX_C_API void bgfx_discard(uint64_t _flags);
+BGFX_C_API void bgfx_discard(uint8_t _flags);
 
 
 /**
 /**
  * Blit 2D texture region between two 2D textures.
  * Blit 2D texture region between two 2D textures.
@@ -3558,7 +3558,7 @@ struct bgfx_interface_vtbl
     void (*encoder_set_image)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
     void (*encoder_set_image)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
     void (*encoder_dispatch)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
     void (*encoder_dispatch)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
     void (*encoder_dispatch_indirect)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
     void (*encoder_dispatch_indirect)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
-    void (*encoder_discard)(bgfx_encoder_t* _this, uint64_t _flags);
+    void (*encoder_discard)(bgfx_encoder_t* _this, uint8_t _flags);
     void (*encoder_blit)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
     void (*encoder_blit)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
     void (*request_screen_shot)(bgfx_frame_buffer_handle_t _handle, const char* _filePath);
     void (*request_screen_shot)(bgfx_frame_buffer_handle_t _handle, const char* _filePath);
     bgfx_render_frame_t (*render_frame)(int32_t _msecs);
     bgfx_render_frame_t (*render_frame)(int32_t _msecs);
@@ -3600,7 +3600,7 @@ struct bgfx_interface_vtbl
     void (*set_image)(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
     void (*set_image)(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
     void (*dispatch)(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
     void (*dispatch)(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
     void (*dispatch_indirect)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
     void (*dispatch_indirect)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
-    void (*discard)(uint64_t _flags);
+    void (*discard)(uint8_t _flags);
     void (*blit)(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
     void (*blit)(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
 };
 };
 
 

+ 14 - 8
include/bgfx/defines.h

@@ -103,14 +103,20 @@
  * Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
  * Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
  *
  *
  */
  */
-#define BGFX_STATE_DISCARD_INDEX_BUFFER     UINT64_C(0x0000000000000001) //!< Discard only Index Buffer
-#define BGFX_STATE_DISCARD_VERTEX_STREAMS   UINT64_C(0x0000000000000002) //!< Discard only Vertex Streams
-#define BGFX_STATE_DISCARD_TEXTURE_SAMPLERS UINT64_C(0x0000000000000003) //!< Discard only texture samplers
-#define BGFX_STATE_DISCARD_COMPUTE          UINT64_C(0x0000000000000004) //!< Discard only Compute shader related state
-#define BGFX_STATE_DISCARD_STATE            UINT64_C(0x0000000000000005) //!< Discard only state
-#define BGFX_STATE_DISCARD_ALL              UINT64_C(0xffffffffffffffff) //!< Discard every rendering states
-#define BGFX_STATE_DISCARD_SHIFT            0                            //!< Discard flags bit shift
-#define BGFX_STATE_DISCARD_MASK             UINT64_C(0x0000000000000007) //!< Discard flags bit mask
+#define BGFX_STATE_DISCARD_INDEX_BUFFER     UINT8_C(0x01) //!< Discard only Index Buffer
+#define BGFX_STATE_DISCARD_VERTEX_STREAMS   UINT8_C(0x02) //!< Discard only Vertex Streams
+#define BGFX_STATE_DISCARD_TEXTURE_SAMPLERS UINT8_C(0x04) //!< Discard only texture samplers
+#define BGFX_STATE_DISCARD_COMPUTE          UINT8_C(0x08) //!< Discard only Compute shader related state
+#define BGFX_STATE_DISCARD_STATE            UINT8_C(0x10) //!< Discard only state
+/// Discard every rendering states
+#define BGFX_STATE_DISCARD_DEFAULT (0 \
+	| BGFX_STATE_DISCARD_INDEX_BUFFER \
+	| BGFX_STATE_DISCARD_VERTEX_STREAMS \
+	| BGFX_STATE_DISCARD_TEXTURE_SAMPLERS \
+	| BGFX_STATE_DISCARD_COMPUTE \
+	| BGFX_STATE_DISCARD_STATE \
+	)
+
 
 
 /**
 /**
  * Alpha reference value.
  * Alpha reference value.

+ 11 - 9
scripts/bgfx.idl

@@ -84,13 +84,13 @@ flag.StateCull { bits = 64, shift = 36, range = 2, base = 1, desc = "Culling mod
 	()
 	()
 
 
 --- Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
 --- Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
-flag.StateDiscard { bits = 64, shift = 0, range = 3, base = 1, desc = "Discard flags" }
-	.IndexBuffer                --- Discard only Index Buffer
-	.VertexStreams              --- Discard only Vertex Streams
-    .TextureSamplers            --- Discard only texture samplers
-    .Compute                    --- Discard only Compute shader related state
-    .State                      --- Discard only state
-	.All (0xffffffffffffffff)   --- Discard every rendering states
+flag.StateDiscard { bits = 8, base = 1, desc = "Discard flags" }
+	.IndexBuffer                                                                        --- Discard only Index Buffer
+	.VertexStreams                                                                      --- Discard only Vertex Streams
+	.TextureSamplers                                                                    --- Discard only texture samplers
+	.Compute                                                                            --- Discard only Compute shader related state
+	.State                                                                              --- Discard only state
+	.Default { "IndexBuffer", "VertexStreams", "TextureSamplers", "Compute", "State" }  --- Discard every rendering states
 	()
 	()
 
 
 --- Alpha reference value.
 --- Alpha reference value.
@@ -2451,7 +2451,8 @@ func.Encoder.dispatch { cname = "dispatch_indirect" }
 --- Discard previously set state for draw or compute call.
 --- Discard previously set state for draw or compute call.
 func.Encoder.discard
 func.Encoder.discard
 	"void"
 	"void"
-	.flags   "uint64_t"     --- rendering states to discard
+	.flags   "uint8_t"     --- rendering states to discard
+	 { default = "Default" }
 
 
 --- Blit 2D texture region between two 2D textures.
 --- Blit 2D texture region between two 2D textures.
 ---
 ---
@@ -2962,7 +2963,8 @@ func.dispatch { cname = "dispatch_indirect" }
 --- Discard previously set state for draw or compute call.
 --- Discard previously set state for draw or compute call.
 func.discard
 func.discard
 	"void"
 	"void"
-	.flags   "uint64_t"     --- rendering states to discard
+	.flags   "uint8_t"     --- rendering states to discard
+	 { default = "Default" }
 
 
 --- Blit 2D texture region between two 2D textures.
 --- Blit 2D texture region between two 2D textures.
 ---
 ---

+ 11 - 11
src/bgfx.cpp

@@ -1184,14 +1184,14 @@ namespace bgfx
 
 
 		if (m_discard)
 		if (m_discard)
 		{
 		{
-			discard(BGFX_STATE_DISCARD_ALL);
+			discard();
 			return;
 			return;
 		}
 		}
 
 
 		if (0 == m_draw.m_numVertices
 		if (0 == m_draw.m_numVertices
 		&&  0 == m_draw.m_numIndices)
 		&&  0 == m_draw.m_numIndices)
 		{
 		{
-			discard(BGFX_STATE_DISCARD_ALL);
+			discard();
 			++m_numDropped;
 			++m_numDropped;
 			return;
 			return;
 		}
 		}
@@ -1199,7 +1199,7 @@ namespace bgfx
 		const uint32_t renderItemIdx = bx::atomicFetchAndAddsat<uint32_t>(&m_frame->m_numRenderItems, 1, BGFX_CONFIG_MAX_DRAW_CALLS);
 		const uint32_t renderItemIdx = bx::atomicFetchAndAddsat<uint32_t>(&m_frame->m_numRenderItems, 1, BGFX_CONFIG_MAX_DRAW_CALLS);
 		if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= renderItemIdx)
 		if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= renderItemIdx)
 		{
 		{
-			discard(BGFX_STATE_DISCARD_ALL);
+			discard();
 			++m_numDropped;
 			++m_numDropped;
 			return;
 			return;
 		}
 		}
@@ -1266,8 +1266,8 @@ namespace bgfx
 
 
 		if (!_preserveState)
 		if (!_preserveState)
 		{
 		{
-			m_draw.clear(BGFX_STATE_DISCARD_ALL);
-			m_bind.clear(BGFX_STATE_DISCARD_ALL);
+			m_draw.clear();
+			m_bind.clear();
 			m_uniformBegin = m_uniformEnd;
 			m_uniformBegin = m_uniformEnd;
 		}
 		}
 	}
 	}
@@ -1281,14 +1281,14 @@ namespace bgfx
 
 
 		if (m_discard)
 		if (m_discard)
 		{
 		{
-			discard(BGFX_STATE_DISCARD_ALL);
+			discard();
 			return;
 			return;
 		}
 		}
 
 
 		const uint32_t renderItemIdx = bx::atomicFetchAndAddsat<uint32_t>(&m_frame->m_numRenderItems, 1, BGFX_CONFIG_MAX_DRAW_CALLS);
 		const uint32_t renderItemIdx = bx::atomicFetchAndAddsat<uint32_t>(&m_frame->m_numRenderItems, 1, BGFX_CONFIG_MAX_DRAW_CALLS);
 		if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= renderItemIdx)
 		if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= renderItemIdx)
 		{
 		{
-			discard(BGFX_STATE_DISCARD_ALL);
+			discard();
 			++m_numDropped;
 			++m_numDropped;
 			return;
 			return;
 		}
 		}
@@ -1319,8 +1319,8 @@ namespace bgfx
 		m_frame->m_renderItem[renderItemIdx].compute = m_compute;
 		m_frame->m_renderItem[renderItemIdx].compute = m_compute;
 		m_frame->m_renderItemBind[renderItemIdx]     = m_bind;
 		m_frame->m_renderItemBind[renderItemIdx]     = m_bind;
 
 
-		m_compute.clear(BGFX_STATE_DISCARD_ALL);
-		m_bind.clear(BGFX_STATE_DISCARD_ALL);
+		m_compute.clear();
+		m_bind.clear();
 		m_uniformBegin = m_uniformEnd;
 		m_uniformBegin = m_uniformEnd;
 	}
 	}
 
 
@@ -3780,7 +3780,7 @@ namespace bgfx
 		BGFX_ENCODER(dispatch(_id, _program, _indirectHandle, _start, _num) );
 		BGFX_ENCODER(dispatch(_id, _program, _indirectHandle, _start, _num) );
 	}
 	}
 
 
-	void Encoder::discard(uint64_t flags)
+	void Encoder::discard(uint8_t flags)
 	{
 	{
 		BGFX_ENCODER(discard(flags) );
 		BGFX_ENCODER(discard(flags) );
 	}
 	}
@@ -4992,7 +4992,7 @@ namespace bgfx
 		s_ctx->m_encoder0->dispatch(_id, _handle, _indirectHandle, _start, _num);
 		s_ctx->m_encoder0->dispatch(_id, _handle, _indirectHandle, _start, _num);
 	}
 	}
 
 
-	void discard(uint64_t flags)
+	void discard(uint8_t flags)
 	{
 	{
 		BGFX_CHECK_API_THREAD();
 		BGFX_CHECK_API_THREAD();
 		s_ctx->m_encoder0->discard(flags);
 		s_ctx->m_encoder0->discard(flags);

+ 2 - 2
src/bgfx.idl.inl

@@ -912,7 +912,7 @@ BGFX_C_API void bgfx_encoder_dispatch_indirect(bgfx_encoder_t* _this, bgfx_view_
 	This->dispatch((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num);
 	This->dispatch((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num);
 }
 }
 
 
-BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this, uint64_t _flags)
+BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this, uint8_t _flags)
 {
 {
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
 	This->discard(_flags);
 	This->discard(_flags);
@@ -1154,7 +1154,7 @@ BGFX_C_API void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t
 	bgfx::dispatch((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num);
 	bgfx::dispatch((bgfx::ViewId)_id, program.cpp, indirectHandle.cpp, _start, _num);
 }
 }
 
 
-BGFX_C_API void bgfx_discard(uint64_t _flags)
+BGFX_C_API void bgfx_discard(uint8_t _flags)
 {
 {
 	bgfx::discard(_flags);
 	bgfx::discard(_flags);
 }
 }

+ 5 - 5
src/bgfx_p.h

@@ -1543,7 +1543,7 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 
 
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderBind
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderBind
 	{
 	{
-		void clear(uint64_t flags)
+		void clear(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT)
 		{
 		{
 			if (flags & BGFX_STATE_DISCARD_TEXTURE_SAMPLERS)
 			if (flags & BGFX_STATE_DISCARD_TEXTURE_SAMPLERS)
 			{
 			{
@@ -1562,7 +1562,7 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 
 
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderDraw
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderDraw
 	{
 	{
-		void clear(uint64_t flags)
+		void clear(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT)
 		{
 		{
 			if (flags & BGFX_STATE_DISCARD_STATE)
 			if (flags & BGFX_STATE_DISCARD_STATE)
 			{
 			{
@@ -1638,7 +1638,7 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 
 
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderCompute
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderCompute
 	{
 	{
-		void clear(uint64_t flags)
+		void clear(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT)
 		{
 		{
 			if (flags & BGFX_STATE_DISCARD_COMPUTE)
 			if (flags & BGFX_STATE_DISCARD_COMPUTE)
 			{
 			{
@@ -2199,7 +2199,7 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 	{
 	{
 		EncoderImpl()
 		EncoderImpl()
 		{
 		{
-			discard(BGFX_STATE_DISCARD_ALL);
+			discard();
 		}
 		}
 
 
 		void begin(Frame* _frame, uint8_t _idx)
 		void begin(Frame* _frame, uint8_t _idx)
@@ -2494,7 +2494,7 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 			bind.m_mip    = _mip;
 			bind.m_mip    = _mip;
 		}
 		}
 
 
-		void discard(uint64_t flags)
+		void discard(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT)
 		{
 		{
 			if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
 			if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
 			{
 			{

+ 6 - 6
src/renderer_d3d11.cpp

@@ -5309,12 +5309,12 @@ namespace bgfx { namespace d3d11
 		_render->sort();
 		_render->sort();
 
 
 		RenderDraw currentState;
 		RenderDraw currentState;
-		currentState.clear(BGFX_STATE_DISCARD_ALL);
+		currentState.clear();
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 		currentState.m_stencil = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 
 
 		RenderBind currentBind;
 		RenderBind currentBind;
-		currentBind.clear(BGFX_STATE_DISCARD_ALL);
+		currentBind.clear();
 
 
 		static ViewState viewState;
 		static ViewState viewState;
 		viewState.reset(_render);
 		viewState.reset(_render);
@@ -5617,9 +5617,9 @@ namespace bgfx { namespace d3d11
 					{
 					{
 						if (resetState)
 						if (resetState)
 						{
 						{
-							currentState.clear(BGFX_STATE_DISCARD_ALL);
+							currentState.clear();
 							currentState.m_scissor = !draw.m_scissor;
 							currentState.m_scissor = !draw.m_scissor;
-							currentBind.clear(BGFX_STATE_DISCARD_ALL);
+							currentBind.clear();
 						}
 						}
 
 
 						continue;
 						continue;
@@ -5640,14 +5640,14 @@ namespace bgfx { namespace d3d11
 				{
 				{
 					wasCompute = false;
 					wasCompute = false;
 
 
-					currentState.clear(BGFX_STATE_DISCARD_ALL);
+					currentState.clear();
 					currentState.m_scissor = !draw.m_scissor;
 					currentState.m_scissor = !draw.m_scissor;
 					changedFlags = BGFX_STATE_MASK;
 					changedFlags = BGFX_STATE_MASK;
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stencil    = newStencil;
 					currentState.m_stencil    = newStencil;
 
 
-					currentBind.clear(BGFX_STATE_DISCARD_ALL);
+					currentBind.clear();
 
 
 					setBlendState(newFlags);
 					setBlendState(newFlags);
 					setDepthStencilState(newFlags, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) );
 					setDepthStencilState(newFlags, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) );

+ 8 - 8
src/renderer_d3d12.cpp

@@ -5753,12 +5753,12 @@ namespace bgfx { namespace d3d12
 		_render->sort();
 		_render->sort();
 
 
 		RenderDraw currentState;
 		RenderDraw currentState;
-		currentState.clear(BGFX_STATE_DISCARD_ALL);
+		currentState.clear();
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 
 
 		RenderBind currentBind;
 		RenderBind currentBind;
-		currentBind.clear(BGFX_STATE_DISCARD_ALL);
+		currentBind.clear();
 
 
 		static ViewState viewState;
 		static ViewState viewState;
 		viewState.reset(_render);
 		viewState.reset(_render);
@@ -6174,9 +6174,9 @@ namespace bgfx { namespace d3d12
 					{
 					{
 						if (resetState)
 						if (resetState)
 						{
 						{
-							currentState.clear(BGFX_STATE_DISCARD_ALL);
+							currentState.clear();
 							currentState.m_scissor = !draw.m_scissor;
 							currentState.m_scissor = !draw.m_scissor;
-							currentBind.clear(BGFX_STATE_DISCARD_ALL);
+							currentBind.clear();
 							commandListChanged = true;
 							commandListChanged = true;
 						}
 						}
 
 
@@ -6196,14 +6196,14 @@ namespace bgfx { namespace d3d12
 				{
 				{
 					wasCompute = false;
 					wasCompute = false;
 
 
-					currentState.clear(BGFX_STATE_DISCARD_ALL);
+					currentState.clear();
 					currentState.m_scissor = !draw.m_scissor;
 					currentState.m_scissor = !draw.m_scissor;
 					changedFlags = BGFX_STATE_MASK;
 					changedFlags = BGFX_STATE_MASK;
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stencil    = newStencil;
 					currentState.m_stencil    = newStencil;
 
 
-					currentBind.clear(BGFX_STATE_DISCARD_ALL);
+					currentBind.clear();
 
 
 					commandListChanged = true;
 					commandListChanged = true;
 				}
 				}
@@ -6223,14 +6223,14 @@ namespace bgfx { namespace d3d12
 					currentBindHash        = 0;
 					currentBindHash        = 0;
 					currentSamplerStateIdx = kInvalidHandle;
 					currentSamplerStateIdx = kInvalidHandle;
 					currentProgram         = BGFX_INVALID_HANDLE;
 					currentProgram         = BGFX_INVALID_HANDLE;
-					currentState.clear(BGFX_STATE_DISCARD_ALL);
+					currentState.clear();
 					currentState.m_scissor = !draw.m_scissor;
 					currentState.m_scissor = !draw.m_scissor;
 					changedFlags = BGFX_STATE_MASK;
 					changedFlags = BGFX_STATE_MASK;
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stencil    = newStencil;
 					currentState.m_stencil    = newStencil;
 
 
-					currentBind.clear(BGFX_STATE_DISCARD_ALL);
+					currentBind.clear();
 
 
 					const uint64_t pt = newFlags&BGFX_STATE_PT_MASK;
 					const uint64_t pt = newFlags&BGFX_STATE_PT_MASK;
 					primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);
 					primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT);

+ 3 - 3
src/renderer_d3d9.cpp

@@ -3746,12 +3746,12 @@ namespace bgfx { namespace d3d9
 		_render->sort();
 		_render->sort();
 
 
 		RenderDraw currentState;
 		RenderDraw currentState;
-		currentState.clear(BGFX_STATE_DISCARD_ALL);
+		currentState.clear();
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 
 
 		RenderBind currentBind;
 		RenderBind currentBind;
-		currentBind.clear(BGFX_STATE_DISCARD_ALL);
+		currentBind.clear();
 
 
 		static ViewState viewState;
 		static ViewState viewState;
 		viewState.reset(_render);
 		viewState.reset(_render);
@@ -3839,7 +3839,7 @@ namespace bgfx { namespace d3d9
 
 
 				if (key.m_view != view)
 				if (key.m_view != view)
 				{
 				{
-					currentState.clear(BGFX_STATE_DISCARD_ALL);
+					currentState.clear();
 					currentState.m_scissor = !draw.m_scissor;
 					currentState.m_scissor = !draw.m_scissor;
 					changedFlags = BGFX_STATE_MASK;
 					changedFlags = BGFX_STATE_MASK;
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);

+ 6 - 6
src/renderer_gl.cpp

@@ -6482,12 +6482,12 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 		_render->sort();
 		_render->sort();
 
 
 		RenderDraw currentState;
 		RenderDraw currentState;
-		currentState.clear(BGFX_STATE_DISCARD_ALL);
+		currentState.clear();
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 
 
 		RenderBind currentBind;
 		RenderBind currentBind;
-		currentBind.clear(BGFX_STATE_DISCARD_ALL);
+		currentBind.clear();
 
 
 		static ViewState viewState;
 		static ViewState viewState;
 		viewState.reset(_render);
 		viewState.reset(_render);
@@ -6769,9 +6769,9 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 					{
 					{
 						if (resetState)
 						if (resetState)
 						{
 						{
-							currentState.clear(BGFX_STATE_DISCARD_ALL);
+							currentState.clear();
 							currentState.m_scissor = !draw.m_scissor;
 							currentState.m_scissor = !draw.m_scissor;
-							currentBind.clear(BGFX_STATE_DISCARD_ALL);
+							currentBind.clear();
 						}
 						}
 
 
 						continue;
 						continue;
@@ -6788,14 +6788,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 
 
 				if (resetState)
 				if (resetState)
 				{
 				{
-					currentState.clear(BGFX_STATE_DISCARD_ALL);
+					currentState.clear();
 					currentState.m_scissor = !draw.m_scissor;
 					currentState.m_scissor = !draw.m_scissor;
 					changedFlags   = BGFX_STATE_MASK;
 					changedFlags   = BGFX_STATE_MASK;
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stencil    = newStencil;
 					currentState.m_stencil    = newStencil;
 
 
-					currentBind.clear(BGFX_STATE_DISCARD_ALL);
+					currentBind.clear();
 				}
 				}
 
 
 				uint16_t scissor = draw.m_scissor;
 				uint16_t scissor = draw.m_scissor;

+ 6 - 6
src/renderer_mtl.mm

@@ -3687,12 +3687,12 @@ namespace bgfx { namespace mtl
 		_render->sort();
 		_render->sort();
 
 
 		RenderDraw currentState;
 		RenderDraw currentState;
-		currentState.clear(BGFX_STATE_DISCARD_ALL);
+		currentState.clear();
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 
 
 		RenderBind currentBind;
 		RenderBind currentBind;
-		currentBind.clear(BGFX_STATE_DISCARD_ALL);
+		currentBind.clear();
 
 
 		static ViewState viewState;
 		static ViewState viewState;
 		viewState.reset(_render);
 		viewState.reset(_render);
@@ -4136,9 +4136,9 @@ namespace bgfx { namespace mtl
 					{
 					{
 						if (resetState)
 						if (resetState)
 						{
 						{
-							currentState.clear(BGFX_STATE_DISCARD_ALL);
+							currentState.clear();
 							currentState.m_scissor = !draw.m_scissor;
 							currentState.m_scissor = !draw.m_scissor;
-							currentBind.clear(BGFX_STATE_DISCARD_ALL);
+							currentBind.clear();
 						}
 						}
 
 
 						continue;
 						continue;
@@ -4155,14 +4155,14 @@ namespace bgfx { namespace mtl
 
 
 				if (resetState)
 				if (resetState)
 				{
 				{
-					currentState.clear(BGFX_STATE_DISCARD_ALL);
+					currentState.clear();
 					currentState.m_scissor = !draw.m_scissor;
 					currentState.m_scissor = !draw.m_scissor;
 					changedFlags = BGFX_STATE_MASK;
 					changedFlags = BGFX_STATE_MASK;
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stateFlags = newFlags;
 					currentState.m_stencil    = newStencil;
 					currentState.m_stencil    = newStencil;
 
 
-					currentBind.clear(BGFX_STATE_DISCARD_ALL);
+					currentBind.clear();
 
 
 					currentProgram = BGFX_INVALID_HANDLE;
 					currentProgram = BGFX_INVALID_HANDLE;
 					setDepthStencilState(newFlags, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) );
 					setDepthStencilState(newFlags, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) );

+ 2 - 2
src/renderer_vk.cpp

@@ -5733,7 +5733,7 @@ VK_DESTROY
 		_render->sort();
 		_render->sort();
 
 
 		RenderDraw currentState;
 		RenderDraw currentState;
-		currentState.clear(BGFX_STATE_DISCARD_ALL);
+		currentState.clear();
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stateFlags = BGFX_STATE_NONE;
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 		currentState.m_stencil    = packStencil(BGFX_STENCIL_NONE, BGFX_STENCIL_NONE);
 
 
@@ -6138,7 +6138,7 @@ VK_DESTROY
 					currentDslHash         = 0;
 					currentDslHash         = 0;
 					currentSamplerStateIdx = kInvalidHandle;
 					currentSamplerStateIdx = kInvalidHandle;
 					currentProgram         = BGFX_INVALID_HANDLE;
 					currentProgram         = BGFX_INVALID_HANDLE;
-					currentState.clear(BGFX_STATE_DISCARD_ALL);
+					currentState.clear();
 					currentState.m_scissor = !draw.m_scissor;
 					currentState.m_scissor = !draw.m_scissor;
 					changedFlags = BGFX_STATE_MASK;
 					changedFlags = BGFX_STATE_MASK;
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
 					changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);