Added timeout period for renderFrame call.
This commit is contained in:
parent
3b290ebb7e
commit
393ee208ca
@ -31,7 +31,7 @@ typedef enum bgfx_render_frame
|
|||||||
* allow creating separate rendering thread. If it is called before
|
* allow creating separate rendering thread. If it is called before
|
||||||
* to bgfx_init, render thread won't be created by bgfx_init call.
|
* to bgfx_init, render thread won't be created by bgfx_init call.
|
||||||
*/
|
*/
|
||||||
BGFX_C_API bgfx_render_frame_t bgfx_render_frame();
|
BGFX_C_API bgfx_render_frame_t bgfx_render_frame(int32_t _msecs);
|
||||||
|
|
||||||
typedef struct bgfx_platform_data
|
typedef struct bgfx_platform_data
|
||||||
{
|
{
|
||||||
@ -66,7 +66,7 @@ BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handl
|
|||||||
/**/
|
/**/
|
||||||
typedef struct bgfx_interface_vtbl
|
typedef struct bgfx_interface_vtbl
|
||||||
{
|
{
|
||||||
bgfx_render_frame_t (*render_frame)();
|
bgfx_render_frame_t (*render_frame)(int32_t _msecs);
|
||||||
void (*set_platform_data)(const bgfx_platform_data_t* _data);
|
void (*set_platform_data)(const bgfx_platform_data_t* _data);
|
||||||
const bgfx_internal_data_t* (*get_internal_data)();
|
const bgfx_internal_data_t* (*get_internal_data)();
|
||||||
uintptr_t (*override_internal_texture_ptr)(bgfx_texture_handle_t _handle, uintptr_t _ptr);
|
uintptr_t (*override_internal_texture_ptr)(bgfx_texture_handle_t _handle, uintptr_t _ptr);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||||
|
|
||||||
#define BGFX_API_VERSION UINT32_C(44)
|
#define BGFX_API_VERSION UINT32_C(45)
|
||||||
|
|
||||||
///
|
///
|
||||||
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
|
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
|
||||||
|
@ -34,12 +34,19 @@ namespace bgfx
|
|||||||
|
|
||||||
/// Render frame.
|
/// Render frame.
|
||||||
///
|
///
|
||||||
|
/// @param _msecs Timeout in milliseconds.
|
||||||
|
///
|
||||||
/// @returns Current renderer state. See: `bgfx::RenderFrame`.
|
/// @returns Current renderer state. See: `bgfx::RenderFrame`.
|
||||||
///
|
///
|
||||||
|
/// @attention `bgfx::renderFrame` is blocking call. It waits for
|
||||||
|
/// `bgfx::frame` to be called from API thread to process frame.
|
||||||
|
/// If timeout value is passed call will timeout and return even
|
||||||
|
/// if `bgfx::frame` is not called.
|
||||||
|
///
|
||||||
/// @warning This call should be only used on platforms that don't
|
/// @warning This call should be only used on platforms that don't
|
||||||
/// allow creating separate rendering thread. If it is called before
|
/// allow creating separate rendering thread. If it is called before
|
||||||
/// to bgfx::init, render thread won't be created by bgfx::init call.
|
/// to bgfx::init, render thread won't be created by bgfx::init call.
|
||||||
RenderFrame::Enum renderFrame();
|
RenderFrame::Enum renderFrame(int32_t _msecs = -1);
|
||||||
|
|
||||||
/// Platform data.
|
/// Platform data.
|
||||||
///
|
///
|
||||||
|
12
src/bgfx.cpp
12
src/bgfx.cpp
@ -1031,7 +1031,7 @@ namespace bgfx
|
|||||||
bx::radixSort(m_blitKeys, (uint32_t*)&s_ctx->m_tempKeys, m_numBlitItems);
|
bx::radixSort(m_blitKeys, (uint32_t*)&s_ctx->m_tempKeys, m_numBlitItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderFrame::Enum renderFrame()
|
RenderFrame::Enum renderFrame(int32_t _msecs)
|
||||||
{
|
{
|
||||||
if (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
|
if (BX_ENABLED(BGFX_CONFIG_MULTITHREADED) )
|
||||||
{
|
{
|
||||||
@ -1043,7 +1043,11 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
|
|
||||||
BGFX_CHECK_RENDER_THREAD();
|
BGFX_CHECK_RENDER_THREAD();
|
||||||
RenderFrame::Enum result = s_ctx->renderFrame(BGFX_CONFIG_API_SEMAPHORE_TIMEOUT);
|
int32_t msecs = -1 == _msecs
|
||||||
|
? BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
|
||||||
|
: _msecs
|
||||||
|
;
|
||||||
|
RenderFrame::Enum result = s_ctx->renderFrame(msecs);
|
||||||
if (RenderFrame::Exiting == result)
|
if (RenderFrame::Exiting == result)
|
||||||
{
|
{
|
||||||
Context* ctx = s_ctx;
|
Context* ctx = s_ctx;
|
||||||
@ -4944,9 +4948,9 @@ BGFX_C_API void bgfx_request_screen_shot(bgfx_frame_buffer_handle _handle, const
|
|||||||
bgfx::requestScreenShot(handle.cpp, _filePath);
|
bgfx::requestScreenShot(handle.cpp, _filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
BGFX_C_API bgfx_render_frame_t bgfx_render_frame()
|
BGFX_C_API bgfx_render_frame_t bgfx_render_frame(int32_t _msecs)
|
||||||
{
|
{
|
||||||
return bgfx_render_frame_t(bgfx::renderFrame() );
|
return bgfx_render_frame_t(bgfx::renderFrame(_msecs) );
|
||||||
}
|
}
|
||||||
|
|
||||||
BGFX_C_API void bgfx_set_platform_data(const bgfx_platform_data_t* _data)
|
BGFX_C_API void bgfx_set_platform_data(const bgfx_platform_data_t* _data)
|
||||||
|
@ -325,7 +325,7 @@
|
|||||||
#endif // BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS
|
#endif // BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS
|
||||||
|
|
||||||
#ifndef BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
|
#ifndef BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
|
||||||
# define BGFX_CONFIG_API_SEMAPHORE_TIMEOUT (-1)
|
# define BGFX_CONFIG_API_SEMAPHORE_TIMEOUT (5000)
|
||||||
#endif // BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
|
#endif // BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
|
||||||
|
|
||||||
#endif // BGFX_CONFIG_H_HEADER_GUARD
|
#endif // BGFX_CONFIG_H_HEADER_GUARD
|
||||||
|
Loading…
Reference in New Issue
Block a user