mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-20 13:53:14 +01:00
Added BGFX_FRAME_* flags to add ability to discard all draw calls. (#3599)
This commit is contained in:
committed by
GitHub
parent
2800f17970
commit
c85fa25266
@@ -1369,6 +1369,25 @@ public static class bgfx
|
||||
NegativeZ = 0x00000005,
|
||||
}
|
||||
|
||||
[AllowDuplicates]
|
||||
public enum FrameFlags : uint32
|
||||
{
|
||||
/// <summary>
|
||||
/// No frame flags.
|
||||
/// </summary>
|
||||
None = 0x00000000,
|
||||
|
||||
/// <summary>
|
||||
/// Capture frame with graphics debugger.
|
||||
/// </summary>
|
||||
DebugCapture = 0x00000001,
|
||||
|
||||
/// <summary>
|
||||
/// Discard all draw calls.
|
||||
/// </summary>
|
||||
Discard = 0x00000002,
|
||||
}
|
||||
|
||||
[AllowDuplicates]
|
||||
public enum Fatal : uint32
|
||||
{
|
||||
@@ -2712,10 +2731,10 @@ public static class bgfx
|
||||
/// singlethreaded renderer this call does frame rendering.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="_capture">Capture frame with graphics debugger.</param>
|
||||
/// <param name="_flags">Frame flags. See: `BGFX_FRAME_*` for more info. - `BGFX_FRAME_NONE` - No frame flag. - `BGFX_FRAME_DEBUG_CAPTURE` - Capture frame with graphics debugger. - `BGFX_FRAME_DISCARD` - Discard all draw calls.</param>
|
||||
///
|
||||
[LinkName("bgfx_frame")]
|
||||
public static extern uint32 frame(bool _capture);
|
||||
public static extern uint32 frame(uint8 _flags);
|
||||
|
||||
/// <summary>
|
||||
/// Returns current renderer backend API type.
|
||||
|
||||
@@ -862,6 +862,18 @@ enum CubeMapFlags : const uint
|
||||
NEGATIVEZ = 0x00000005,
|
||||
}
|
||||
|
||||
enum FrameFlags : const uint
|
||||
{
|
||||
// No frame flags.
|
||||
NONE = 0x00000000,
|
||||
|
||||
// Capture frame with graphics debugger.
|
||||
DEBUGCAPTURE = 0x00000001,
|
||||
|
||||
// Discard all draw calls.
|
||||
DISCARD = 0x00000002,
|
||||
}
|
||||
|
||||
enum Fatal : uint
|
||||
{
|
||||
DEBUGCHECK,
|
||||
@@ -2036,8 +2048,8 @@ extern fn void reset(uint _width, uint _height, uint _flags, TextureFormat _form
|
||||
// Advance to next frame. When using multithreaded renderer, this call
|
||||
// just swaps internal buffers, kicks render thread, and returns. In
|
||||
// singlethreaded renderer this call does frame rendering.
|
||||
// _capture : `Capture frame with graphics debugger.`
|
||||
extern fn uint frame(bool _capture) @extern("bgfx_frame");
|
||||
// _flags : `Frame flags. See: `BGFX_FRAME_*` for more info. - `BGFX_FRAME_NONE` - No frame flag. - `BGFX_FRAME_DEBUG_CAPTURE` - Capture frame with graphics debugger. - `BGFX_FRAME_DISCARD` - Discard all draw calls.`
|
||||
extern fn uint frame(char _flags) @extern("bgfx_frame");
|
||||
|
||||
// Returns current renderer backend API type.
|
||||
// @remarks
|
||||
|
||||
@@ -1368,6 +1368,25 @@ public static partial class bgfx
|
||||
NegativeZ = 0x00000005,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum FrameFlags : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// No frame flags.
|
||||
/// </summary>
|
||||
None = 0x00000000,
|
||||
|
||||
/// <summary>
|
||||
/// Capture frame with graphics debugger.
|
||||
/// </summary>
|
||||
DebugCapture = 0x00000001,
|
||||
|
||||
/// <summary>
|
||||
/// Discard all draw calls.
|
||||
/// </summary>
|
||||
Discard = 0x00000002,
|
||||
}
|
||||
|
||||
public enum Fatal
|
||||
{
|
||||
DebugCheck,
|
||||
@@ -2662,10 +2681,10 @@ public static partial class bgfx
|
||||
/// singlethreaded renderer this call does frame rendering.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="_capture">Capture frame with graphics debugger.</param>
|
||||
/// <param name="_flags">Frame flags. See: `BGFX_FRAME_*` for more info. - `BGFX_FRAME_NONE` - No frame flag. - `BGFX_FRAME_DEBUG_CAPTURE` - Capture frame with graphics debugger. - `BGFX_FRAME_DISCARD` - Discard all draw calls.</param>
|
||||
///
|
||||
[DllImport(DllName, EntryPoint="bgfx_frame", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe uint frame(bool _capture);
|
||||
public static extern unsafe uint frame(byte _flags);
|
||||
|
||||
/// <summary>
|
||||
/// Returns current renderer backend API type.
|
||||
|
||||
@@ -9,7 +9,7 @@ import bindbc.common.types: c_int64, c_uint64, va_list;
|
||||
import bindbc.bgfx.config;
|
||||
static import bgfx.impl;
|
||||
|
||||
enum uint apiVersion = 137;
|
||||
enum uint apiVersion = 138;
|
||||
|
||||
alias ViewID = ushort;
|
||||
|
||||
@@ -579,6 +579,13 @@ enum CubeMap: CubeMap_{
|
||||
negativeZ = 0x05, ///Cubemap -z.
|
||||
}
|
||||
|
||||
alias Frame_ = ubyte;
|
||||
enum Frame: Frame_{
|
||||
none = 0x00, ///No frame flags.
|
||||
debugCapture = 0x01, ///Capture frame with graphics debugger.
|
||||
discard = 0x02, ///Discard all draw calls.
|
||||
}
|
||||
|
||||
///Fatal error enum.
|
||||
enum Fatal: bgfx.impl.Fatal.Enum{
|
||||
debugCheck = bgfx.impl.Fatal.Enum.debugCheck,
|
||||
@@ -2069,9 +2076,12 @@ mixin(joinFnBinds((){
|
||||
* just swaps internal buffers, kicks render thread, and returns. In
|
||||
* singlethreaded renderer this call does frame rendering.
|
||||
Params:
|
||||
capture = Capture frame with graphics debugger.
|
||||
flags = Frame flags. See: `BGFX_FRAME_*` for more info.
|
||||
- `BGFX_FRAME_NONE` - No frame flag.
|
||||
- `BGFX_FRAME_DEBUG_CAPTURE` - Capture frame with graphics debugger.
|
||||
- `BGFX_FRAME_DISCARD` - Discard all draw calls.
|
||||
*/
|
||||
{q{uint}, q{frame}, q{bool capture=false}, ext: `C++, "bgfx"`},
|
||||
{q{uint}, q{frame}, q{ubyte flags=BGFX_FRAME_NONE}, ext: `C++, "bgfx"`},
|
||||
|
||||
/**
|
||||
* Returns current renderer backend API type.
|
||||
|
||||
@@ -835,6 +835,16 @@ pub const CubeMapFlags_PositiveZ: CubeMapFlags = 0x00000004;
|
||||
/// Cubemap -z.
|
||||
pub const CubeMapFlags_NegativeZ: CubeMapFlags = 0x00000005;
|
||||
|
||||
pub const FrameFlags = u32;
|
||||
/// No frame flags.
|
||||
pub const FrameFlags_None: FrameFlags = 0x00000000;
|
||||
|
||||
/// Capture frame with graphics debugger.
|
||||
pub const FrameFlags_DebugCapture: FrameFlags = 0x00000001;
|
||||
|
||||
/// Discard all draw calls.
|
||||
pub const FrameFlags_Discard: FrameFlags = 0x00000002;
|
||||
|
||||
pub const Fatal = enum(c_int) {
|
||||
DebugCheck,
|
||||
InvalidShader,
|
||||
@@ -2156,11 +2166,11 @@ extern fn bgfx_reset(_width: u32, _height: u32, _flags: u32, _format: TextureFor
|
||||
/// Advance to next frame. When using multithreaded renderer, this call
|
||||
/// just swaps internal buffers, kicks render thread, and returns. In
|
||||
/// singlethreaded renderer this call does frame rendering.
|
||||
/// <param name="_capture">Capture frame with graphics debugger.</param>
|
||||
pub inline fn frame(_capture: bool) u32 {
|
||||
return bgfx_frame(_capture);
|
||||
/// <param name="_flags">Frame flags. See: `BGFX_FRAME_*` for more info. - `BGFX_FRAME_NONE` - No frame flag. - `BGFX_FRAME_DEBUG_CAPTURE` - Capture frame with graphics debugger. - `BGFX_FRAME_DISCARD` - Discard all draw calls.</param>
|
||||
pub inline fn frame(_flags: u8) u32 {
|
||||
return bgfx_frame(_flags);
|
||||
}
|
||||
extern fn bgfx_frame(_capture: bool) u32;
|
||||
extern fn bgfx_frame(_flags: u8) u32;
|
||||
|
||||
/// Returns current renderer backend API type.
|
||||
/// @remarks
|
||||
|
||||
@@ -68,6 +68,10 @@ Reset
|
||||
Frame
|
||||
*****
|
||||
|
||||
.. doxygendefine:: BGFX_FRAME_NONE
|
||||
.. doxygendefine:: BGFX_FRAME_DEBUG_CAPTURE
|
||||
.. doxygendefine:: BGFX_FRAME_DISCARD
|
||||
|
||||
.. doxygenfunction:: bgfx::frame
|
||||
|
||||
Debug
|
||||
|
||||
@@ -2132,7 +2132,7 @@ namespace bgfx
|
||||
/// just swaps internal buffers, kicks render thread, and returns. In
|
||||
/// singlethreaded renderer this call does frame rendering.
|
||||
///
|
||||
/// @param[in] _capture Capture frame with graphics debugger.
|
||||
/// @param[in] _flags Frame flags. See: `BGFX_FRAME_*`.
|
||||
///
|
||||
/// @returns Current frame number. This might be used in conjunction with
|
||||
/// double/multi buffering data outside the library and passing it to
|
||||
@@ -2140,7 +2140,7 @@ namespace bgfx
|
||||
///
|
||||
/// @attention C99's equivalent binding is `bgfx_frame`.
|
||||
///
|
||||
uint32_t frame(bool _capture = false);
|
||||
uint32_t frame(uint8_t _flags = BGFX_FRAME_NONE);
|
||||
|
||||
/// Returns current renderer backend API type.
|
||||
///
|
||||
|
||||
@@ -1250,14 +1250,17 @@ BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags, b
|
||||
* just swaps internal buffers, kicks render thread, and returns. In
|
||||
* singlethreaded renderer this call does frame rendering.
|
||||
*
|
||||
* @param[in] _capture Capture frame with graphics debugger.
|
||||
* @param[in] _flags Frame flags. See: `BGFX_FRAME_*` for more info.
|
||||
* - `BGFX_FRAME_NONE` - No frame flag.
|
||||
* - `BGFX_FRAME_DEBUG_CAPTURE` - Capture frame with graphics debugger.
|
||||
* - `BGFX_FRAME_DISCARD` - Discard all draw calls.
|
||||
*
|
||||
* @returns Current frame number. This might be used in conjunction with
|
||||
* double/multi buffering data outside the library and passing it to
|
||||
* library via `bgfx::makeRef` calls.
|
||||
*
|
||||
*/
|
||||
BGFX_C_API uint32_t bgfx_frame(bool _capture);
|
||||
BGFX_C_API uint32_t bgfx_frame(uint8_t _flags);
|
||||
|
||||
/**
|
||||
* Returns current renderer backend API type.
|
||||
@@ -3829,7 +3832,7 @@ struct bgfx_interface_vtbl
|
||||
bool (*init)(const bgfx_init_t * _init);
|
||||
void (*shutdown)(void);
|
||||
void (*reset)(uint32_t _width, uint32_t _height, uint32_t _flags, bgfx_texture_format_t _format);
|
||||
uint32_t (*frame)(bool _capture);
|
||||
uint32_t (*frame)(uint8_t _flags);
|
||||
bgfx_renderer_type_t (*get_renderer_type)(void);
|
||||
const bgfx_caps_t* (*get_caps)(void);
|
||||
const bgfx_stats_t* (*get_stats)(void);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(137)
|
||||
#define BGFX_API_VERSION UINT32_C(138)
|
||||
|
||||
/**
|
||||
* Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
||||
@@ -541,6 +541,10 @@
|
||||
#define BGFX_CUBE_MAP_POSITIVE_Z UINT8_C(0x04) //!< Cubemap +z.
|
||||
#define BGFX_CUBE_MAP_NEGATIVE_Z UINT8_C(0x05) //!< Cubemap -z.
|
||||
|
||||
#define BGFX_FRAME_NONE UINT8_C(0x00) //!< No frame flags.
|
||||
#define BGFX_FRAME_DEBUG_CAPTURE UINT8_C(0x01) //!< Capture frame with graphics debugger.
|
||||
#define BGFX_FRAME_DISCARD UINT8_C(0x02) //!< Discard all draw calls.
|
||||
|
||||
|
||||
/// Blend function separate.
|
||||
#define BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA) (UINT64_C(0) \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- vim: syntax=lua
|
||||
-- bgfx interface
|
||||
|
||||
version(137)
|
||||
version(138)
|
||||
|
||||
typedef "bool"
|
||||
typedef "char"
|
||||
@@ -28,7 +28,7 @@ funcptr.ReleaseFn
|
||||
.userData "void*" --- User defined data if needed.
|
||||
|
||||
--- Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
||||
flag.StateWrite { bits = 64 , base = 1 }
|
||||
flag.StateWrite { bits = 64, base = 1 }
|
||||
.R --- Enable R write.
|
||||
.G --- Enable G write.
|
||||
.B --- Enable B write.
|
||||
@@ -450,6 +450,12 @@ flag.CubeMap { bits = 8, const }
|
||||
.NegativeZ (0x05) --- Cubemap -z.
|
||||
()
|
||||
|
||||
flag.Frame { bits = 8 }
|
||||
.None --- No frame flags.
|
||||
.DebugCapture --- Capture frame with graphics debugger.
|
||||
.Discard --- Discard all draw calls.
|
||||
()
|
||||
|
||||
--- Fatal error enum.
|
||||
enum.Fatal { underscore, comment = "" }
|
||||
.DebugCheck
|
||||
@@ -1240,11 +1246,13 @@ func.reset
|
||||
--- just swaps internal buffers, kicks render thread, and returns. In
|
||||
--- singlethreaded renderer this call does frame rendering.
|
||||
func.frame
|
||||
"uint32_t" --- Current frame number. This might be used in conjunction with
|
||||
--- double/multi buffering data outside the library and passing it to
|
||||
--- library via `bgfx::makeRef` calls.
|
||||
.capture "bool" --- Capture frame with graphics debugger.
|
||||
{ default = false }
|
||||
"uint32_t" --- Current frame number. This might be used in conjunction with
|
||||
--- double/multi buffering data outside the library and passing it to
|
||||
--- library via `bgfx::makeRef` calls.
|
||||
.flags "uint8_t" --- Frame flags. See: `BGFX_FRAME_*` for more info.
|
||||
{ default = "BGFX_FRAME_NONE" } --- - `BGFX_FRAME_NONE` - No frame flag.
|
||||
--- - `BGFX_FRAME_DEBUG_CAPTURE` - Capture frame with graphics debugger.
|
||||
--- - `BGFX_FRAME_DISCARD` - Discard all draw calls.
|
||||
|
||||
--- Returns current renderer backend API type.
|
||||
---
|
||||
|
||||
13
src/bgfx.cpp
13
src/bgfx.cpp
@@ -2400,7 +2400,7 @@ namespace bgfx
|
||||
#endif // BGFX_CONFIG_MULTITHREADED
|
||||
}
|
||||
|
||||
uint32_t Context::frame(bool _capture)
|
||||
uint32_t Context::frame(uint8_t _flags)
|
||||
{
|
||||
m_encoder[0].end(true);
|
||||
|
||||
@@ -2413,7 +2413,12 @@ namespace bgfx
|
||||
encoderApiWait();
|
||||
#endif // BGFX_CONFIG_MULTITHREADED
|
||||
|
||||
m_submit->m_capture = _capture;
|
||||
if (0 != (_flags & BGFX_FRAME_DISCARD) )
|
||||
{
|
||||
m_submit->m_numRenderItems = 0;
|
||||
}
|
||||
|
||||
m_submit->m_capture = 0 != (_flags & BGFX_FRAME_DEBUG_CAPTURE);
|
||||
|
||||
uint32_t frameNum = m_submit->m_frameNum;
|
||||
|
||||
@@ -4234,10 +4239,10 @@ namespace bgfx
|
||||
s_ctx->end(_encoder);
|
||||
}
|
||||
|
||||
uint32_t frame(bool _capture)
|
||||
uint32_t frame(uint8_t _flags)
|
||||
{
|
||||
BGFX_CHECK_API_THREAD();
|
||||
return s_ctx->frame(_capture);
|
||||
return s_ctx->frame(_flags);
|
||||
}
|
||||
|
||||
const Caps* getCaps()
|
||||
|
||||
@@ -172,9 +172,9 @@ BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags, b
|
||||
bgfx::reset(_width, _height, _flags, (bgfx::TextureFormat::Enum)_format);
|
||||
}
|
||||
|
||||
BGFX_C_API uint32_t bgfx_frame(bool _capture)
|
||||
BGFX_C_API uint32_t bgfx_frame(uint8_t _flags)
|
||||
{
|
||||
return bgfx::frame(_capture);
|
||||
return bgfx::frame(_flags);
|
||||
}
|
||||
|
||||
BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type(void)
|
||||
|
||||
@@ -5804,7 +5804,7 @@ namespace bgfx
|
||||
|
||||
BGFX_API_FUNC(void end(Encoder* _encoder) );
|
||||
|
||||
BGFX_API_FUNC(uint32_t frame(bool _capture = false) );
|
||||
BGFX_API_FUNC(uint32_t frame(uint8_t _flags = BGFX_FRAME_NONE) );
|
||||
|
||||
uint32_t getSeqIncr(ViewId _id)
|
||||
{
|
||||
|
||||
@@ -1918,7 +1918,7 @@ namespace bgfx { namespace d3d11
|
||||
bx::write(&writer, tc, bx::ErrorAssert{});
|
||||
|
||||
texture.destroy();
|
||||
texture.create(mem, texture.m_flags, 0, NULL);
|
||||
texture.create(mem, texture.m_flags, 0, 0);
|
||||
|
||||
release(mem);
|
||||
}
|
||||
@@ -4656,7 +4656,7 @@ namespace bgfx { namespace d3d11
|
||||
&& !writeOnly
|
||||
;
|
||||
|
||||
if (NULL != _external)
|
||||
if (0 != _external)
|
||||
{
|
||||
if (externalShared)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user