From fe62fe5ebf9e57dcab76719556d228ab4de82c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 18 Apr 2016 20:08:50 -0700 Subject: [PATCH 1/4] Fixed dynamic buffer overrun. Issue #760. --- src/bgfx_p.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 1bb850e47..531fd38c0 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2535,7 +2535,10 @@ namespace bgfx } uint32_t offset = (dvb.m_startVertex + _startVertex)*dvb.m_stride; - uint32_t size = bx::uint32_min(bx::uint32_satsub(dvb.m_size, _startVertex*dvb.m_stride), _mem->size); + uint32_t size = bx::uint32_min(offset + + bx::uint32_min(bx::uint32_satsub(dvb.m_size, _startVertex*dvb.m_stride), _mem->size) + , BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE) - offset + ; BX_CHECK(_mem->size <= size, "Truncating dynamic vertex buffer update (size %d, mem size %d)." , dvb.m_size , _mem->size From 7e0390e32bb7768dfa26f147c6ae11b4e1364616 Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Tue, 19 Apr 2016 01:07:27 -0700 Subject: [PATCH 2/4] match bgfx::Stats struct --- include/bgfx/c99/bgfx.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/bgfx/c99/bgfx.h b/include/bgfx/c99/bgfx.h index 927933353..35132b839 100644 --- a/include/bgfx/c99/bgfx.h +++ b/include/bgfx/c99/bgfx.h @@ -298,10 +298,12 @@ typedef struct bgfx_hmd /**/ typedef struct bgfx_stats { - uint64_t cpuTime; + uint64_t cpuTimeBegin; + uint64_t cpuTimeEnd; uint64_t cpuTimerFreq; - uint64_t gpuTime; + uint64_t gpuTimeBegin; + uint64_t gpuTimeEnd; uint64_t gpuTimerFreq; } bgfx_stats_t; From da0af1e3562e1eae2fc527808449047975bfac88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 19 Apr 2016 09:12:04 -0700 Subject: [PATCH 3/4] Fixed assert message. --- src/bgfx_p.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 531fd38c0..243c23ca2 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2385,7 +2385,10 @@ namespace bgfx } uint32_t offset = (dib.m_startIndex + _startIndex)*indexSize; - uint32_t size = bx::uint32_min(bx::uint32_satsub(dib.m_size, _startIndex*indexSize), _mem->size); + uint32_t size = bx::uint32_min(offset + + bx::uint32_min(bx::uint32_satsub(dib.m_size, _startIndex*indexSize), _mem->size) + , BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE) - offset + ; BX_CHECK(_mem->size <= size, "Truncating dynamic index buffer update (size %d, mem size %d)." , size , _mem->size @@ -2540,7 +2543,7 @@ namespace bgfx , BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE) - offset ; BX_CHECK(_mem->size <= size, "Truncating dynamic vertex buffer update (size %d, mem size %d)." - , dvb.m_size + , size , _mem->size ); From 150fe0dd10c26e9122f3caffcb82bf2e3da50f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 19 Apr 2016 09:17:29 -0700 Subject: [PATCH 4/4] Added missing ABI asserts for C99 headers. --- src/bgfx.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 13fc896d7..bf5f020f4 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -3657,11 +3657,17 @@ BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT); BX_STATIC_ASSERT(sizeof(_cppstruct) == sizeof(_c99struct) ) BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Memory, bgfx_memory_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Transform, bgfx_transform_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::HMD::Eye, bgfx_hmd_eye_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::HMD, bgfx_hmd_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Stats, bgfx_stats_t); BGFX_C99_STRUCT_SIZE_CHECK(bgfx::VertexDecl, bgfx_vertex_decl_t); BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientIndexBuffer, bgfx_transient_index_buffer_t); BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientVertexBuffer, bgfx_transient_vertex_buffer_t); BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InstanceDataBuffer, bgfx_instance_data_buffer_t); BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TextureInfo, bgfx_texture_info_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Attachment, bgfx_attachment_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::GPU, bgfx_caps_gpu_t); BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps, bgfx_caps_t); BGFX_C99_STRUCT_SIZE_CHECK(bgfx::PlatformData, bgfx_platform_data_t); BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InternalData, bgfx_internal_data_t);