diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 1fc9023f3..94ea6753b 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -3421,7 +3421,7 @@ namespace bgfx errorState = ErrorState::ContextAllocated; - s_ctx = BX_ALIGNED_NEW(g_allocator, Context, 64); + s_ctx = BX_ALIGNED_NEW(g_allocator, Context, Context::kAlignment); if (s_ctx->init(_init) ) { BX_TRACE("Init complete."); @@ -3434,7 +3434,7 @@ namespace bgfx switch (errorState) { case ErrorState::ContextAllocated: - BX_ALIGNED_DELETE(g_allocator, s_ctx, 64); + BX_ALIGNED_DELETE(g_allocator, s_ctx, Context::kAlignment); s_ctx = NULL; BX_FALLTHROUGH; @@ -3470,7 +3470,7 @@ namespace bgfx ctx->shutdown(); BX_CHECK(NULL == s_ctx, "bgfx is should be uninitialized here."); - BX_ALIGNED_DELETE(g_allocator, ctx, 64); + BX_ALIGNED_DELETE(g_allocator, ctx, Context::kAlignment); BX_TRACE("Shutdown complete."); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 968dfb9e7..072252cc4 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2841,6 +2841,8 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA struct Context { + static constexpr uint32_t kAlignment = 64; + Context() : m_render(&m_frame[0]) , m_submit(&m_frame[BGFX_CONFIG_MULTITHREADED ? 1 : 0])