Cedric Guillemet 6 anni fa
parent
commit
9ee39e8241
6 ha cambiato i file con 226 aggiunte e 35 eliminazioni
  1. 197 6
      bindings/cs/bgfx.cs
  2. 6 6
      bindings/d/types.d
  3. 1 1
      include/bgfx/bgfx.h
  4. 11 11
      include/bgfx/defines.h
  5. 2 2
      scripts/bgfx.idl
  6. 9 9
      src/bgfx_p.h

+ 197 - 6
bindings/cs/bgfx.cs

@@ -201,36 +201,227 @@ public static partial class bgfx
 		CullCcw                = 0x0000002000000000,
 		CullShift              = 36,
 		CullMask               = 0x0000003000000000,
+	}
 	
+	[Flags]
+	public enum DiscardFlagsFlags : uint
+	{
 		/// <summary>
 		/// Discard only Index Buffer
 		/// </summary>
-		DiscardIndexBuffer     = 0x0000000000000001,
+		IndexBuffer            = 0x00000001,
 	
 		/// <summary>
 		/// Discard only Vertex Streams
 		/// </summary>
-		DiscardVertexStreams   = 0x0000000000000002,
+		VertexStreams          = 0x00000002,
 	
 		/// <summary>
 		/// Discard only texture samplers
 		/// </summary>
-		DiscardTextureSamplers = 0x0000000000000004,
+		TextureSamplers        = 0x00000004,
 	
 		/// <summary>
 		/// Discard only Compute shader related state
 		/// </summary>
-		DiscardCompute         = 0x0000000000000008,
+		Compute                = 0x00000008,
 	
 		/// <summary>
 		/// Discard only state
 		/// </summary>
-		DiscardState           = 0x0000000000000010,
+		State                  = 0x00000010,
 	
 		/// <summary>
 		/// Discard every rendering states
 		/// </summary>
-		DiscardDefault         = 0x000000000000001f,
+		All                    = 0x0000001f,
+	}
+	
+	[Flags]
+	public enum StateFlags : ulong
+	{
+		/// <summary>
+		/// Enable R write.
+		/// </summary>
+		WriteR                 = 0x0000000000000001,
+	
+		/// <summary>
+		/// Enable G write.
+		/// </summary>
+		WriteG                 = 0x0000000000000002,
+	
+		/// <summary>
+		/// Enable B write.
+		/// </summary>
+		WriteB                 = 0x0000000000000004,
+	
+		/// <summary>
+		/// Enable alpha write.
+		/// </summary>
+		WriteA                 = 0x0000000000000008,
+	
+		/// <summary>
+		/// Enable depth write.
+		/// </summary>
+		WriteZ                 = 0x0000004000000000,
+	
+		/// <summary>
+		/// Enable RGB write.
+		/// </summary>
+		WriteRgb               = 0x0000000000000007,
+	
+		/// <summary>
+		/// Write all channels mask.
+		/// </summary>
+		WriteMask              = 0x000000400000000f,
+	
+		/// <summary>
+		/// Enable depth test, less.
+		/// </summary>
+		DepthTestLess          = 0x0000000000000010,
+	
+		/// <summary>
+		/// Enable depth test, less or equal.
+		/// </summary>
+		DepthTestLequal        = 0x0000000000000020,
+	
+		/// <summary>
+		/// Enable depth test, equal.
+		/// </summary>
+		DepthTestEqual         = 0x0000000000000030,
+	
+		/// <summary>
+		/// Enable depth test, greater or equal.
+		/// </summary>
+		DepthTestGequal        = 0x0000000000000040,
+	
+		/// <summary>
+		/// Enable depth test, greater.
+		/// </summary>
+		DepthTestGreater       = 0x0000000000000050,
+	
+		/// <summary>
+		/// Enable depth test, not equal.
+		/// </summary>
+		DepthTestNotequal      = 0x0000000000000060,
+	
+		/// <summary>
+		/// Enable depth test, never.
+		/// </summary>
+		DepthTestNever         = 0x0000000000000070,
+	
+		/// <summary>
+		/// Enable depth test, always.
+		/// </summary>
+		DepthTestAlways        = 0x0000000000000080,
+		DepthTestShift         = 4,
+		DepthTestMask          = 0x00000000000000f0,
+	
+		/// <summary>
+		/// 0, 0, 0, 0
+		/// </summary>
+		BlendZero              = 0x0000000000001000,
+	
+		/// <summary>
+		/// 1, 1, 1, 1
+		/// </summary>
+		BlendOne               = 0x0000000000002000,
+	
+		/// <summary>
+		/// Rs, Gs, Bs, As
+		/// </summary>
+		BlendSrcColor          = 0x0000000000003000,
+	
+		/// <summary>
+		/// 1-Rs, 1-Gs, 1-Bs, 1-As
+		/// </summary>
+		BlendInvSrcColor       = 0x0000000000004000,
+	
+		/// <summary>
+		/// As, As, As, As
+		/// </summary>
+		BlendSrcAlpha          = 0x0000000000005000,
+	
+		/// <summary>
+		/// 1-As, 1-As, 1-As, 1-As
+		/// </summary>
+		BlendInvSrcAlpha       = 0x0000000000006000,
+	
+		/// <summary>
+		/// Ad, Ad, Ad, Ad
+		/// </summary>
+		BlendDstAlpha          = 0x0000000000007000,
+	
+		/// <summary>
+		/// 1-Ad, 1-Ad, 1-Ad ,1-Ad
+		/// </summary>
+		BlendInvDstAlpha       = 0x0000000000008000,
+	
+		/// <summary>
+		/// Rd, Gd, Bd, Ad
+		/// </summary>
+		BlendDstColor          = 0x0000000000009000,
+	
+		/// <summary>
+		/// 1-Rd, 1-Gd, 1-Bd, 1-Ad
+		/// </summary>
+		BlendInvDstColor       = 0x000000000000a000,
+	
+		/// <summary>
+		/// f, f, f, 1; f = min(As, 1-Ad)
+		/// </summary>
+		BlendSrcAlphaSat       = 0x000000000000b000,
+	
+		/// <summary>
+		/// Blend factor
+		/// </summary>
+		BlendFactor            = 0x000000000000c000,
+	
+		/// <summary>
+		/// 1-Blend factor
+		/// </summary>
+		BlendInvFactor         = 0x000000000000d000,
+		BlendShift             = 12,
+		BlendMask              = 0x000000000ffff000,
+	
+		/// <summary>
+		/// Blend add: src + dst.
+		/// </summary>
+		BlendEquationAdd       = 0x0000000000000000,
+	
+		/// <summary>
+		/// Blend subtract: src - dst.
+		/// </summary>
+		BlendEquationSub       = 0x0000000010000000,
+	
+		/// <summary>
+		/// Blend reverse subtract: dst - src.
+		/// </summary>
+		BlendEquationRevsub    = 0x0000000020000000,
+	
+		/// <summary>
+		/// Blend min: min(src, dst).
+		/// </summary>
+		BlendEquationMin       = 0x0000000030000000,
+	
+		/// <summary>
+		/// Blend max: max(src, dst).
+		/// </summary>
+		BlendEquationMax       = 0x0000000040000000,
+		BlendEquationShift     = 28,
+		BlendEquationMask      = 0x00000003f0000000,
+	
+		/// <summary>
+		/// Cull clockwise triangles.
+		/// </summary>
+		CullCw                 = 0x0000001000000000,
+	
+		/// <summary>
+		/// Cull counter-clockwise triangles.
+		/// </summary>
+		CullCcw                = 0x0000002000000000,
+		CullShift              = 36,
+		CullMask               = 0x0000003000000000,
 		AlphaRefShift          = 40,
 		AlphaRefMask           = 0x0000ff0000000000,
 	

+ 6 - 6
bindings/d/types.d

@@ -76,12 +76,12 @@ enum ulong BGFX_STATE_CULL_SHIFT = 36; /// Culling mode bit shift
 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.
-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
+enum ubyte BGFX_DISCARD_FLAGS_INDEX_BUFFER = 0x01; /// Discard only Index Buffer
+enum ubyte BGFX_DISCARD_FLAGS_VERTEX_STREAMS = 0x02; /// Discard only Vertex Streams
+enum ubyte BGFX_DISCARD_FLAGS_TEXTURE_SAMPLERS = 0x04; /// Discard only texture samplers
+enum ubyte BGFX_DISCARD_FLAGS_COMPUTE = 0x08; /// Discard only Compute shader related state
+enum ubyte BGFX_DISCARD_FLAGS_STATE = 0x10; /// Discard only state
+enum ubyte BGFX_DISCARD_FLAGS_ALL = 0x1f; /// Discard every rendering states
 
 /// Alpha reference value.
 enum ulong BGFX_STATE_ALPHA_REF_SHIFT = 40; /// Alpha reference bit shift

+ 1 - 1
include/bgfx/bgfx.h

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

+ 11 - 11
include/bgfx/defines.h

@@ -103,18 +103,18 @@
  * Rendering state discard. When state is preserved in submit, rendering states can be discarded on a finer grain.
  *
  */
-#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
+#define BGFX_DISCARD_FLAGS_INDEX_BUFFER     UINT8_C(0x01) //!< Discard only Index Buffer
+#define BGFX_DISCARD_FLAGS_VERTEX_STREAMS   UINT8_C(0x02) //!< Discard only Vertex Streams
+#define BGFX_DISCARD_FLAGS_TEXTURE_SAMPLERS UINT8_C(0x04) //!< Discard only texture samplers
+#define BGFX_DISCARD_FLAGS_COMPUTE          UINT8_C(0x08) //!< Discard only Compute shader related state
+#define BGFX_DISCARD_FLAGS_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 \
+#define BGFX_DISCARD_FLAGS_ALL (0 \
+	| BGFX_DISCARD_FLAGS_INDEX_BUFFER \
+	| BGFX_DISCARD_FLAGS_VERTEX_STREAMS \
+	| BGFX_DISCARD_FLAGS_TEXTURE_SAMPLERS \
+	| BGFX_DISCARD_FLAGS_COMPUTE \
+	| BGFX_DISCARD_FLAGS_STATE \
 	)
 
 

+ 2 - 2
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.
-flag.StateDiscard { bits = 8, base = 1, desc = "Discard flags" }
+flag.DiscardFlags { 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
+	.All { "IndexBuffer", "VertexStreams", "TextureSamplers", "Compute", "State" }  --- Discard every rendering states
 	()
 
 --- Alpha reference value.

+ 9 - 9
src/bgfx_p.h

@@ -1543,9 +1543,9 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderBind
 	{
-		void clear(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT)
+		void clear(uint8_t flags = BGFX_DISCARD_FLAGS_ALL)
 		{
-			if (flags & BGFX_STATE_DISCARD_TEXTURE_SAMPLERS)
+			if (flags & BGFX_DISCARD_FLAGS_TEXTURE_SAMPLERS)
 			{
 				for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++ii)
 				{
@@ -1562,9 +1562,9 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderDraw
 	{
-		void clear(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT)
+		void clear(uint8_t flags = BGFX_DISCARD_FLAGS_ALL)
 		{
-			if (flags & BGFX_STATE_DISCARD_STATE)
+			if (flags & BGFX_DISCARD_FLAGS_STATE)
 			{
 				m_uniformBegin = 0;
 				m_uniformEnd   = 0;
@@ -1589,12 +1589,12 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 				m_occlusionQuery.idx     = kInvalidHandle;
 				m_uniformIdx = UINT8_MAX;
 			}
-			if (flags & BGFX_STATE_DISCARD_VERTEX_STREAMS)
+			if (flags & BGFX_DISCARD_FLAGS_VERTEX_STREAMS)
 			{
 				m_streamMask = 0;
 				m_stream[0].clear();
 			}
-			if (flags & BGFX_STATE_DISCARD_INDEX_BUFFER)
+			if (flags & BGFX_DISCARD_FLAGS_INDEX_BUFFER)
 			{
 				m_indexBuffer.idx = kInvalidHandle;
 			}
@@ -1638,9 +1638,9 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 
 	BX_ALIGN_DECL_CACHE_LINE(struct) RenderCompute
 	{
-		void clear(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT)
+		void clear(uint8_t flags = BGFX_DISCARD_FLAGS_ALL)
 		{
-			if (flags & BGFX_STATE_DISCARD_COMPUTE)
+			if (flags & BGFX_DISCARD_FLAGS_COMPUTE)
 			{
 				m_uniformBegin = 0;
 				m_uniformEnd   = 0;
@@ -2494,7 +2494,7 @@ constexpr uint64_t kSortKeyComputeProgramMask  = uint64_t(BGFX_CONFIG_MAX_PROGRA
 			bind.m_mip    = _mip;
 		}
 
-		void discard(uint8_t flags = BGFX_STATE_DISCARD_DEFAULT)
+		void discard(uint8_t flags = BGFX_DISCARD_FLAGS_ALL)
 		{
 			if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
 			{