From 600c7798fdba96b9d0c7730efffa44df4a3ce624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 15 Dec 2020 20:23:01 -0800 Subject: [PATCH] Removed BGFX_CAPS_INDEX32 from D3D9. Added validation for BGFX_CAPS_INDEX32 support. --- src/bgfx.cpp | 14 ++++++++++++++ src/renderer_d3d9.cpp | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 8fc24883d..7b6566f59 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -4053,6 +4053,10 @@ namespace bgfx IndexBufferHandle createIndexBuffer(const Memory* _mem, uint16_t _flags) { + BX_ASSERT( + 0 == (_flags & BGFX_BUFFER_INDEX32) || 0 != (g_caps.supported & BGFX_CAPS_INDEX32) + , "32-bit indices are not supported. Use bgfx::getCaps to check BGFX_CAPS_INDEX32 backend renderer capabilities." + ); BX_ASSERT(NULL != _mem, "_mem can't be NULL"); return s_ctx->createIndexBuffer(_mem, _flags); } @@ -4101,6 +4105,10 @@ namespace bgfx DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint16_t _flags) { + BX_ASSERT( + 0 == (_flags & BGFX_BUFFER_INDEX32) || 0 != (g_caps.supported & BGFX_CAPS_INDEX32) + , "32-bit indices are not supported. Use bgfx::getCaps to check BGFX_CAPS_INDEX32 backend renderer capabilities." + ); BX_ASSERT(NULL != _mem, "_mem can't be NULL"); return s_ctx->createDynamicIndexBuffer(_mem, _flags); } @@ -4163,7 +4171,13 @@ namespace bgfx { BX_ASSERT(NULL != _tib, "_tib can't be NULL"); BX_ASSERT(0 < _num, "Requesting 0 indices."); + BX_ASSERT( + !_index32 || 0 != (g_caps.supported & BGFX_CAPS_INDEX32) + , "32-bit indices are not supported. Use bgfx::getCaps to check BGFX_CAPS_INDEX32 backend renderer capabilities." + ); + s_ctx->allocTransientIndexBuffer(_tib, _num, _index32); + const uint32_t indexSize = _tib->isIndex16 ? 2 : 4; BX_ASSERT(_num == _tib->size/ indexSize , "Failed to allocate transient index buffer (requested %d, available %d). " diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index bb63e0c22..22c944d7f 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -710,7 +710,6 @@ namespace bgfx { namespace d3d9 | BGFX_CAPS_VERTEX_ATTRIB_UINT10 | BGFX_CAPS_FRAGMENT_DEPTH | BGFX_CAPS_SWAP_CHAIN - | ( (UINT16_MAX < m_caps.MaxVertexIndex) ? BGFX_CAPS_INDEX32 : 0) | ( (m_caps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES) ? BGFX_CAPS_TEXTURE_BLIT : 0) | BGFX_CAPS_TEXTURE_READ_BACK | (m_occlusionQuerySupport ? BGFX_CAPS_OCCLUSION_QUERY : 0)