From ae7aeba72c0663d006e99d51015ff6fcb7ba4d1d 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: Fri, 25 Feb 2022 17:21:55 -0800 Subject: [PATCH] GL: Fixed vertex layout binding. --- src/renderer_gl.cpp | 2 +- src/vertexlayout.cpp | 15 +++++++++++++++ src/vertexlayout.h | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index ca3f60557..ae617b6b3 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -5164,7 +5164,7 @@ namespace bgfx { namespace gl uint32_t baseVertex = _baseVertex*_layout.m_stride + _layout.m_offset[attr]; if ( (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL >= 30) || s_renderGL->m_gles3) - && (AttribType::Uint8 == type || AttribType::Int16 == type) + && !isFloat(type) && !normalized) { GL_CHECK(glVertexAttribIPointer(loc diff --git a/src/vertexlayout.cpp b/src/vertexlayout.cpp index ba88fc134..4cebdb4a2 100644 --- a/src/vertexlayout.cpp +++ b/src/vertexlayout.cpp @@ -122,6 +122,21 @@ namespace bgfx _asInt = !!(val&(1<<8) ); } + static const bool s_attribTypeIsFloat[] = + { + false, // Uint8 + false, // Uint10 + false, // Int16 + true, // Half + true, // Float + }; + BX_STATIC_ASSERT(BX_COUNTOF(s_attribTypeIsFloat) == AttribType::Count); + + bool isFloat(AttribType::Enum _type) + { + return s_attribTypeIsFloat[_type]; + } + static const char* s_attrName[] = { "P", "Attrib::Position", diff --git a/src/vertexlayout.h b/src/vertexlayout.h index 83887bd5c..afb649a0b 100644 --- a/src/vertexlayout.h +++ b/src/vertexlayout.h @@ -14,6 +14,9 @@ namespace bgfx /// void initAttribTypeSizeTable(RendererType::Enum _type); + /// + bool isFloat(AttribType::Enum _type); + /// Returns attribute name. const char* getAttribName(Attrib::Enum _attr);