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