diff --git a/include/bgfx/c99/platform.h b/include/bgfx/c99/platform.h index 0011bf777..5940a855a 100644 --- a/include/bgfx/c99/platform.h +++ b/include/bgfx/c99/platform.h @@ -31,7 +31,7 @@ typedef enum bgfx_render_frame * allow creating separate rendering thread. If it is called before * 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 { @@ -66,7 +66,7 @@ BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handl /**/ 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); const bgfx_internal_data_t* (*get_internal_data)(); uintptr_t (*override_internal_texture_ptr)(bgfx_texture_handle_t _handle, uintptr_t _ptr); diff --git a/include/bgfx/defines.h b/include/bgfx/defines.h index 4c79f9a3f..fa56353e8 100644 --- a/include/bgfx/defines.h +++ b/include/bgfx/defines.h @@ -6,7 +6,7 @@ #ifndef 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. diff --git a/include/bgfx/platform.h b/include/bgfx/platform.h index 7d85c7309..7e89f2fa7 100644 --- a/include/bgfx/platform.h +++ b/include/bgfx/platform.h @@ -34,12 +34,19 @@ namespace bgfx /// Render frame. /// + /// @param _msecs Timeout in milliseconds. + /// /// @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 /// allow creating separate rendering thread. If it is called before /// 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. /// diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 7f47bdf01..27a65cafd 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1031,7 +1031,7 @@ namespace bgfx 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) ) { @@ -1043,7 +1043,11 @@ namespace bgfx } 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) { 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_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) diff --git a/src/config.h b/src/config.h index 487a3c4fe..14d24cfed 100644 --- a/src/config.h +++ b/src/config.h @@ -325,7 +325,7 @@ #endif // BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS #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_H_HEADER_GUARD