From d98aed66bf082dde0c064a7716a5985c38d09b55 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Fri, 20 Dec 2019 13:29:38 -0700 Subject: [PATCH] Migrate deRoundUp32 to deInt32.h deRoundUp32 is used in a number of places, promote to utility function. Components: OpenGL ES VK-GL-CTS issue: 2151 Change-Id: I26a648f3c228564c6d269e211a9cb7115b7fcbbe --- .../modules/common/glcUniformBlockCase.cpp | 7 +----- .../modules/vulkan/ssbo/vktSSBOLayoutCase.cpp | 25 +++++++++------------- .../modules/vulkan/ubo/vktUniformBlockCase.cpp | 7 +----- framework/delibs/debase/deInt32.h | 12 +++++++++++ modules/gles31/functional/es31fSSBOLayoutCase.cpp | 11 +++------- modules/glshared/glsUniformBlockCase.cpp | 11 +++------- 6 files changed, 30 insertions(+), 43 deletions(-) diff --git a/external/openglcts/modules/common/glcUniformBlockCase.cpp b/external/openglcts/modules/common/glcUniformBlockCase.cpp index 098dafe..c2b973f 100644 --- a/external/openglcts/modules/common/glcUniformBlockCase.cpp +++ b/external/openglcts/modules/common/glcUniformBlockCase.cpp @@ -23,6 +23,7 @@ */ /*-------------------------------------------------------------------*/ #include "glcUniformBlockCase.hpp" +#include "deInt32.h" #include "deMemory.h" #include "deRandom.hpp" #include "deString.h" @@ -376,12 +377,6 @@ int getDataTypeArrayStride(glu::DataType type) return de::max(baseStride, vec4Alignment); // Really? See rule 4. } -static inline int deRoundUp32(int a, int b) -{ - int d = a / b; - return d * b == a ? a : (d + 1) * b; -} - int computeStd140BaseAlignment(const VarType& type) { const int vec4Alignment = static_cast(sizeof(deUint32) * 4); diff --git a/external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutCase.cpp b/external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutCase.cpp index 6146063..bdc3d1e 100644 --- a/external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutCase.cpp +++ b/external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutCase.cpp @@ -23,20 +23,21 @@ * \brief SSBO layout case. *//*--------------------------------------------------------------------*/ -#include "vktSSBOLayoutCase.hpp" -#include "gluShaderProgram.hpp" +#include "deFloat16.h" +#include "deInt32.h" +#include "deMath.h" +#include "deMemory.h" +#include "deRandom.hpp" +#include "deSharedPtr.hpp" +#include "deString.h" +#include "deStringUtil.hpp" #include "gluContextInfo.hpp" +#include "gluShaderProgram.hpp" #include "gluShaderUtil.hpp" #include "gluVarType.hpp" #include "gluVarTypeUtil.hpp" #include "tcuTestLog.hpp" -#include "deRandom.hpp" -#include "deStringUtil.hpp" -#include "deMemory.h" -#include "deString.h" -#include "deMath.h" -#include "deSharedPtr.hpp" -#include "deFloat16.h" +#include "vktSSBOLayoutCase.hpp" #include "vkBuilderUtil.hpp" #include "vkMemUtil.hpp" @@ -316,12 +317,6 @@ int getDataTypeByteAlignment (glu::DataType type) } } -static inline int deRoundUp32 (int a, int b) -{ - int d = a/b; - return d*b == a ? a : (d+1)*b; -} - int computeStd140BaseAlignment (const VarType& type, deUint32 layoutFlags) { const int vec4Alignment = (int)sizeof(deUint32)*4; diff --git a/external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp b/external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp index 70adcd6..943f54c 100644 --- a/external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp +++ b/external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp @@ -30,6 +30,7 @@ #include "gluVarType.hpp" #include "tcuTestLog.hpp" #include "tcuSurface.hpp" +#include "deInt32.h" #include "deRandom.hpp" #include "deStringUtil.hpp" @@ -400,12 +401,6 @@ deInt32 getminUniformBufferOffsetAlignment (Context &ctx) return (deInt32)align; } -static inline int deRoundUp32 (int a, int b) -{ - int d = a/b; - return d*b == a ? a : (d+1)*b; -} - int computeStd140BaseAlignment (const VarType& type, deUint32 layoutFlags) { diff --git a/framework/delibs/debase/deInt32.h b/framework/delibs/debase/deInt32.h index 4cb5b09..781ffa9 100644 --- a/framework/delibs/debase/deInt32.h +++ b/framework/delibs/debase/deInt32.h @@ -535,6 +535,18 @@ DE_INLINE deInt32 deDivRoundUp32 (deInt32 a, deInt32 b) return a/b + ((a%b) ? 1 : 0); } +/*--------------------------------------------------------------------*//*! + * \brief Return value a rounded up to nearest multiple of b. + * \param a Input value. + * \param b Alignment to use. + * \return a if already aligned to b, otherwise next largest aligned value + *//*--------------------------------------------------------------------*/ +DE_INLINE deInt32 deRoundUp32(deInt32 a, deInt32 b) +{ + deInt32 d = a / b; + return d * b == a ? a : (d + 1) * b; +} + /* \todo [petri] Move to deInt64.h? */ DE_INLINE deInt32 deMulAsr32 (deInt32 a, deInt32 b, int shift) diff --git a/modules/gles31/functional/es31fSSBOLayoutCase.cpp b/modules/gles31/functional/es31fSSBOLayoutCase.cpp index 3665383..041db6a 100644 --- a/modules/gles31/functional/es31fSSBOLayoutCase.cpp +++ b/modules/gles31/functional/es31fSSBOLayoutCase.cpp @@ -35,11 +35,12 @@ #include "tcuTestLog.hpp" #include "tcuSurface.hpp" #include "tcuRenderTarget.hpp" +#include "deInt32.h" #include "deRandom.hpp" -#include "deStringUtil.hpp" +#include "deMath.h" #include "deMemory.h" #include "deString.h" -#include "deMath.h" +#include "deStringUtil.hpp" #include #include @@ -362,12 +363,6 @@ int getDataTypeByteAlignment (glu::DataType type) } } -static inline int deRoundUp32 (int a, int b) -{ - int d = a/b; - return d*b == a ? a : (d+1)*b; -} - int computeStd140BaseAlignment (const VarType& type, deUint32 layoutFlags) { const int vec4Alignment = (int)sizeof(deUint32)*4; diff --git a/modules/glshared/glsUniformBlockCase.cpp b/modules/glshared/glsUniformBlockCase.cpp index e766c52..6623215 100644 --- a/modules/glshared/glsUniformBlockCase.cpp +++ b/modules/glshared/glsUniformBlockCase.cpp @@ -33,10 +33,11 @@ #include "tcuTestLog.hpp" #include "tcuSurface.hpp" #include "tcuRenderTarget.hpp" -#include "deRandom.hpp" -#include "deStringUtil.hpp" +#include "deInt32.h" #include "deMemory.h" +#include "deRandom.hpp" #include "deString.h" +#include "deStringUtil.hpp" #include #include @@ -405,12 +406,6 @@ int getDataTypeArrayStride (glu::DataType type) return de::max(baseStride, vec4Alignment); // Really? See rule 4. } -static inline int deRoundUp32 (int a, int b) -{ - int d = a/b; - return d*b == a ? a : (d+1)*b; -} - int computeStd140BaseAlignment (const VarType& type) { const int vec4Alignment = (int)sizeof(deUint32)*4; -- 2.7.4