diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-10-23 03:05:14 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-10-23 03:05:14 +0000 |
| commit | de2944ba73141f1ebdef0c7e6f83c2c40b85f547 (patch) | |
| tree | 99fe3994e949ecdc4fe9b5a4ba325803aa97fb2d /Graphics/GraphicsEngine | |
| parent | D3D11 and GL backends: fixed instanced draw calls with one instance and non-z... (diff) | |
| download | DiligentCore-de2944ba73141f1ebdef0c7e6f83c2c40b85f547.tar.gz DiligentCore-de2944ba73141f1ebdef0c7e6f83c2c40b85f547.zip | |
Added validation and correction of IShaderVariable::SetArray arguments
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h b/Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h index 2501bd86..5227f84a 100644 --- a/Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h +++ b/Graphics/GraphicsEngine/include/ShaderResourceVariableBase.h @@ -306,6 +306,22 @@ bool VerifyResourceViewBinding(const ResourceAttribsType& Attribs, return BindingOK; } +inline void VerifyAndCorrectSetArrayArguments(const char* Name, Uint32 ArraySize, Uint32& FirstElement, Uint32& NumElements) +{ + if (FirstElement >= ArraySize) + { + LOG_ERROR_MESSAGE("SetArray arguments are invalid for '", Name,"' variable: FirstElement (", FirstElement, ") is out of allowed range 0 .. ", ArraySize-1); + FirstElement = ArraySize-1; + NumElements = 0; + } + + if (FirstElement + NumElements > ArraySize) + { + LOG_ERROR_MESSAGE("SetArray arguments are invalid for '", Name,"' variable: specified element range (", FirstElement, " .. ", + FirstElement + NumElements-1, ") is out of array bounds 0 .. ", ArraySize-1); + NumElements = ArraySize - FirstElement; + } +} struct DefaultShaderVariableIDComparator { |
