From 9cd697b1af42ca99f59e8ad3a56109b5cb20759f 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, 1 Mar 2019 09:50:58 -0800 Subject: [PATCH] Added warning for bad API use. --- src/bgfx.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 363d42a65..00193a1fe 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -4062,7 +4062,19 @@ namespace bgfx uint16_t getShaderUniforms(ShaderHandle _handle, UniformHandle* _uniforms, uint16_t _max) { - return s_ctx->getShaderUniforms(_handle, _uniforms, _max); + BX_WARN(NULL == _uniforms || 0 != _max + , "Passing uniforms array pointer, but array maximum capacity is set to 0." + ); + + uint16_t num = s_ctx->getShaderUniforms(_handle, _uniforms, _max); + + BX_WARN(0 == _max || num <= _max + , "Shader has more uniforms that capacity of output array. Output is truncated (num %d, max %d)." + , num + , _max + ); + + return num; } void setName(ShaderHandle _handle, const char* _name, int32_t _len)