Add option to force begin() encoder for a thread (#1497)

This commit is contained in:
Hugo Amnov 2018-09-22 18:52:51 +02:00 committed by Branimir Karadžić
parent 78da1163c2
commit fa2dfdf6c7
4 changed files with 9 additions and 7 deletions

View File

@ -1907,7 +1907,9 @@ namespace bgfx
/// Begin submitting draw calls from thread. /// Begin submitting draw calls from thread.
/// ///
Encoder* begin(); /// @param[in] _forThread Explicitly request an encoder for a worker thread.
///
Encoder* begin(bool _forThread = false);
/// End submitting draw calls from thread. /// End submitting draw calls from thread.
/// ///

View File

@ -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(83) #define BGFX_API_VERSION UINT32_C(84)
/// Color RGB/alpha/depth write. When it's not specified write will be disabled. /// Color RGB/alpha/depth write. When it's not specified write will be disabled.
#define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write. #define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write.

View File

@ -1749,12 +1749,12 @@ namespace bgfx
} }
} }
Encoder* Context::begin() Encoder* Context::begin(bool _forThread)
{ {
EncoderImpl* encoder = &m_encoder[0]; EncoderImpl* encoder = &m_encoder[0];
#if BGFX_CONFIG_MULTITHREADED #if BGFX_CONFIG_MULTITHREADED
if (BGFX_API_THREAD_MAGIC != s_threadIndex) if (_forThread || BGFX_API_THREAD_MAGIC != s_threadIndex)
{ {
bx::MutexScope scopeLock(m_encoderApiLock); bx::MutexScope scopeLock(m_encoderApiLock);
@ -3015,9 +3015,9 @@ namespace bgfx
s_ctx->reset(_width, _height, _flags, _format); s_ctx->reset(_width, _height, _flags, _format);
} }
Encoder* begin() Encoder* begin(bool _forThread)
{ {
return s_ctx->begin(); return s_ctx->begin(_forThread);
} }
#define BGFX_ENCODER(_func) reinterpret_cast<EncoderImpl*>(this)->_func #define BGFX_ENCODER(_func) reinterpret_cast<EncoderImpl*>(this)->_func

View File

@ -4507,7 +4507,7 @@ namespace bgfx
} }
} }
BGFX_API_FUNC(Encoder* begin() ); BGFX_API_FUNC(Encoder* begin(bool _forThread) );
BGFX_API_FUNC(void end(Encoder* _encoder) ); BGFX_API_FUNC(void end(Encoder* _encoder) );