Skip to content

Commit 91814c9

Browse files
authored
Added flag for texture formats that can be used as back-buffer format. (#3605)
1 parent 651c203 commit 91814c9

File tree

17 files changed

+172
-137
lines changed

17 files changed

+172
-137
lines changed

bindings/bf/bgfx.bf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,11 @@ public static class bgfx
12751275
/// Texture format supports auto-generated mips.
12761276
/// </summary>
12771277
TextureMipAutogen = 0x00008000,
1278+
1279+
/// <summary>
1280+
/// Texture format can be used as back buffer format.
1281+
/// </summary>
1282+
TextureBackbuffer = 0x00010000,
12781283
}
12791284

12801285
[AllowDuplicates]
@@ -2223,7 +2228,7 @@ public static class bgfx
22232228
public uint8 numGPUs;
22242229
public GPU[4] gpu;
22252230
public Limits limits;
2226-
public uint16[100] formats;
2231+
public uint32[100] formats;
22272232
}
22282233

22292234
[CRepr]

bindings/c3/bgfx.c3

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,9 @@ enum CapsFormatFlags : const uint
803803

804804
// Texture format supports auto-generated mips.
805805
TEXTUREMIPAUTOGEN = 0x00008000,
806+
807+
// Texture format can be used as back buffer format.
808+
TEXTUREBACKBUFFER = 0x00010000,
806809
}
807810

808811
enum ResolveFlags : const uint
@@ -1510,7 +1513,8 @@ struct Caps
15101513
// - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA.
15111514
// - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated
15121515
// mips.
1513-
ushort[100] formats;
1516+
// - `BGFX_CAPS_FORMAT_TEXTURE_BACKBUFFER` - Texture format can be used as back buffer format.
1517+
uint[100] formats;
15141518
}
15151519

15161520
// Internal data.

bindings/cs/bgfx.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,11 @@ public enum CapsFormatFlags : uint
12741274
/// Texture format supports auto-generated mips.
12751275
/// </summary>
12761276
TextureMipAutogen = 0x00008000,
1277+
1278+
/// <summary>
1279+
/// Texture format can be used as back buffer format.
1280+
/// </summary>
1281+
TextureBackbuffer = 0x00010000,
12771282
}
12781283

12791284
[Flags]
@@ -2202,7 +2207,7 @@ public unsafe struct Limits
22022207
public byte numGPUs;
22032208
public fixed uint gpu[4];
22042209
public Limits limits;
2205-
public fixed ushort formats[100];
2210+
public fixed uint formats[100];
22062211
}
22072212

22082213
public unsafe struct InternalData

bindings/d/package.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import bindbc.common.types: c_int64, c_uint64, va_list;
99
import bindbc.bgfx.config;
1010
static import bgfx.impl;
1111

12-
enum uint apiVersion = 139;
12+
enum uint apiVersion = 140;
1313

1414
alias ViewID = ushort;
1515

@@ -548,6 +548,7 @@ enum CapsFormat: CapsFormat_{
548548
textureFramebufferMSAA = 0x0000_2000, ///Texture format can be used as MSAA frame buffer.
549549
textureMSAA = 0x0000_4000, ///Texture can be sampled as MSAA.
550550
textureMIPAutogen = 0x0000_8000, ///Texture format supports auto-generated mips.
551+
textureBackbuffer = 0x0001_0000, ///Texture format can be used as back buffer format.
551552
}
552553

553554
alias Resolve_ = ubyte;
@@ -1107,8 +1108,9 @@ extern(C++, "bgfx") struct Caps{
11071108
- `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA.
11081109
- `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated
11091110
mips.
1111+
- `BGFX_CAPS_FORMAT_TEXTURE_BACKBUFFER` - Texture format can be used as back buffer format.
11101112
*/
1111-
ushort[TextureFormat.count] formats;
1113+
uint[TextureFormat.count] formats;
11121114
}
11131115

11141116
///Internal data.

bindings/zig/bgfx.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,9 @@ pub const CapsFormatFlags_TextureMsaa: CapsFormatFlags = 0x00004000;
784784
/// Texture format supports auto-generated mips.
785785
pub const CapsFormatFlags_TextureMipAutogen: CapsFormatFlags = 0x00008000;
786786

787+
/// Texture format can be used as back buffer format.
788+
pub const CapsFormatFlags_TextureBackbuffer: CapsFormatFlags = 0x00010000;
789+
787790
pub const ResolveFlags = u32;
788791
/// No resolve flags.
789792
pub const ResolveFlags_None: ResolveFlags = 0x00000000;
@@ -1398,7 +1401,7 @@ pub const Caps = extern struct {
13981401
numGPUs: u8,
13991402
gpu: [4]GPU,
14001403
limits: Limits,
1401-
formats: [100]u16,
1404+
formats: [100]u32,
14021405
};
14031406

14041407
pub const InternalData = extern struct {

include/bgfx/bgfx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,8 @@ namespace bgfx
894894
/// - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA.
895895
/// - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated
896896
/// mips.
897-
uint16_t formats[TextureFormat::Count];
897+
/// - `BGFX_CAPS_FORMAT_TEXTURE_BACKBUFFER` - Texture format can be used as back buffer format.
898+
uint32_t formats[TextureFormat::Count];
898899
};
899900

900901
/// Transient index buffer.

include/bgfx/c99/bgfx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,9 @@ typedef struct bgfx_caps_s
626626
* - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA.
627627
* - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated
628628
* mips.
629+
* - `BGFX_CAPS_FORMAT_TEXTURE_BACKBUFFER` - Texture format can be used as back buffer format.
629630
*/
630-
uint16_t formats[BGFX_TEXTURE_FORMAT_COUNT];
631+
uint32_t formats[BGFX_TEXTURE_FORMAT_COUNT];
631632

632633
} bgfx_caps_t;
633634

include/bgfx/defines.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifndef BGFX_DEFINES_H_HEADER_GUARD
1616
#define BGFX_DEFINES_H_HEADER_GUARD
1717

18-
#define BGFX_API_VERSION UINT32_C(139)
18+
#define BGFX_API_VERSION UINT32_C(140)
1919

2020
/**
2121
* Color RGB/alpha/depth write. When it's not specified write will be disabled.
@@ -521,6 +521,7 @@
521521
#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA UINT32_C(0x00002000) //!< Texture format can be used as MSAA frame buffer.
522522
#define BGFX_CAPS_FORMAT_TEXTURE_MSAA UINT32_C(0x00004000) //!< Texture can be sampled as MSAA.
523523
#define BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN UINT32_C(0x00008000) //!< Texture format supports auto-generated mips.
524+
#define BGFX_CAPS_FORMAT_TEXTURE_BACKBUFFER UINT32_C(0x00010000) //!< Texture format can be used as back buffer format.
524525

525526
#define BGFX_RESOLVE_NONE UINT8_C(0x00) //!< No resolve flags.
526527
#define BGFX_RESOLVE_AUTO_GEN_MIPS UINT8_C(0x01) //!< Auto-generate mip maps on resolve.

scripts/bgfx.idl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- vim: syntax=lua
22
-- bgfx interface
33

4-
version(139)
4+
version(140)
55

66
typedef "bool"
77
typedef "char"
@@ -423,6 +423,7 @@ flag.CapsFormat { bits = 32 }
423423
.TextureFramebufferMsaa --- Texture format can be used as MSAA frame buffer.
424424
.TextureMsaa --- Texture can be sampled as MSAA.
425425
.TextureMipAutogen --- Texture format supports auto-generated mips.
426+
.TextureBackbuffer --- Texture format can be used as back buffer format.
426427
()
427428

428429
flag.Resolve { bits = 8 }
@@ -781,7 +782,7 @@ struct.Caps
781782
.numGPUs "uint8_t" --- Number of enumerated GPUs.
782783
.gpu "GPU[4]" --- Enumerated GPUs.
783784
.limits "Limits" --- Renderer runtime limits.
784-
.formats "uint16_t[TextureFormat::Count]"
785+
.formats "uint32_t[TextureFormat::Count]"
785786
--- Supported texture format capabilities flags:
786787
--- - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported.
787788
--- - `BGFX_CAPS_FORMAT_TEXTURE_2D` - Texture format is supported.
@@ -805,6 +806,7 @@ struct.Caps
805806
--- - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA.
806807
--- - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated
807808
--- mips.
809+
--- - `BGFX_CAPS_FORMAT_TEXTURE_BACKBUFFER` - Texture format can be used as back buffer format.
808810

809811
--- Internal data.
810812
struct.InternalData

src/bgfx.cpp

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,39 +1798,46 @@ namespace bgfx
17981798

17991799
BX_TRACE("");
18001800
BX_TRACE("Supported texture formats:");
1801-
BX_TRACE("\t +---------------- 2D: x = supported / * = emulated");
1802-
BX_TRACE("\t |+--------------- 2D: sRGB format");
1803-
BX_TRACE("\t ||+-------------- 3D: x = supported / * = emulated");
1804-
BX_TRACE("\t |||+------------- 3D: sRGB format");
1805-
BX_TRACE("\t ||||+------------ Cube: x = supported / * = emulated");
1806-
BX_TRACE("\t |||||+----------- Cube: sRGB format");
1807-
BX_TRACE("\t ||||||+---------- vertex format");
1808-
BX_TRACE("\t |||||||+--------- image: i = read-write / r = read / w = write");
1809-
BX_TRACE("\t ||||||||+-------- framebuffer");
1810-
BX_TRACE("\t |||||||||+------- MSAA framebuffer");
1811-
BX_TRACE("\t ||||||||||+------ MSAA texture");
1812-
BX_TRACE("\t |||||||||||+----- Auto-generated mips");
1813-
BX_TRACE("\t |||||||||||| +-- name");
1801+
BX_TRACE("\t +----------------- 2D: x = supported / * = emulated");
1802+
BX_TRACE("\t |+---------------- 2D: sRGB format");
1803+
BX_TRACE("\t ||+--------------- 3D: x = supported / * = emulated");
1804+
BX_TRACE("\t |||+-------------- 3D: sRGB format");
1805+
BX_TRACE("\t ||||+------------- Cube: x = supported / * = emulated");
1806+
BX_TRACE("\t |||||+------------ Cube: sRGB format");
1807+
BX_TRACE("\t ||||||+----------- Vertex format");
1808+
BX_TRACE("\t |||||||+---------- Image: i = read-write / r = read / w = write");
1809+
BX_TRACE("\t ||||||||+--------- Framebuffer");
1810+
BX_TRACE("\t |||||||||+-------- MSAA framebuffer");
1811+
BX_TRACE("\t ||||||||||+------- MSAA texture");
1812+
BX_TRACE("\t |||||||||||+------ Auto-generated mips");
1813+
BX_TRACE("\t ||||||||||||+----- Back-buffer");
1814+
BX_TRACE("\t ||||||||||||| +-- name");
18141815
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
18151816
{
18161817
if (TextureFormat::Unknown != ii
18171818
&& TextureFormat::UnknownDepth != ii)
18181819
{
18191820
uint32_t flags = g_caps.formats[ii];
1820-
BX_TRACE("\t[%c%c%c%c%c%c%c%c%c%c%c%c] %s"
1821-
, flags&BGFX_CAPS_FORMAT_TEXTURE_2D ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED ? '*' : ' '
1822-
, flags&BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB ? 'l' : ' '
1823-
, flags&BGFX_CAPS_FORMAT_TEXTURE_3D ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED ? '*' : ' '
1824-
, flags&BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB ? 'l' : ' '
1825-
, flags&BGFX_CAPS_FORMAT_TEXTURE_CUBE ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED ? '*' : ' '
1826-
, flags&BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB ? 'l' : ' '
1827-
, flags&BGFX_CAPS_FORMAT_TEXTURE_VERTEX ? 'v' : ' '
1828-
, (flags&BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ) &&
1829-
(flags&BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE) ? 'i' : flags&BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ ? 'r' : flags&BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE ? 'w' : ' '
1830-
, flags&BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER ? 'f' : ' '
1831-
, flags&BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA ? '+' : ' '
1832-
, flags&BGFX_CAPS_FORMAT_TEXTURE_MSAA ? 'm' : ' '
1833-
, flags&BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN ? 'M' : ' '
1821+
BX_TRACE("\t[%c%c%c%c%c%c%c%c%c%c%c%c%c] %s"
1822+
, flags & BGFX_CAPS_FORMAT_TEXTURE_2D ? 'x'
1823+
: flags & BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED ? '*' : ' '
1824+
, flags & BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB ? 'l' : ' '
1825+
, flags & BGFX_CAPS_FORMAT_TEXTURE_3D ? 'x'
1826+
: flags & BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED ? '*' : ' '
1827+
, flags & BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB ? 'l' : ' '
1828+
, flags & BGFX_CAPS_FORMAT_TEXTURE_CUBE ? 'x'
1829+
: flags & BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED ? '*' : ' '
1830+
, flags & BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB ? 'l' : ' '
1831+
, flags & BGFX_CAPS_FORMAT_TEXTURE_VERTEX ? 'v' : ' '
1832+
, (flags & BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ) &&
1833+
(flags & BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE) ? 'i'
1834+
: flags & BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ ? 'r'
1835+
: flags & BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE ? 'w' : ' '
1836+
, flags & BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER ? 'f' : ' '
1837+
, flags & BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA ? '+' : ' '
1838+
, flags & BGFX_CAPS_FORMAT_TEXTURE_MSAA ? 'm' : ' '
1839+
, flags & BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN ? 'M' : ' '
1840+
, flags & BGFX_CAPS_FORMAT_TEXTURE_BACKBUFFER ? 'b' : ' '
18341841
, getName(TextureFormat::Enum(ii) )
18351842
);
18361843
BX_UNUSED(flags);

0 commit comments

Comments
 (0)