Migrate deRoundUp32 to deInt32.h
authorCourtney Goeltzenleuchter <courtneygo@google.com>
Fri, 20 Dec 2019 20:29:38 +0000 (13:29 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 23 Jan 2020 08:11:50 +0000 (03:11 -0500)
deRoundUp32 is used in a number of places, promote to utility function.

Components: OpenGL ES
VK-GL-CTS issue: 2151

Change-Id: I26a648f3c228564c6d269e211a9cb7115b7fcbbe

external/openglcts/modules/common/glcUniformBlockCase.cpp
external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutCase.cpp
external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp
framework/delibs/debase/deInt32.h
modules/gles31/functional/es31fSSBOLayoutCase.cpp
modules/glshared/glsUniformBlockCase.cpp

index 098dafe..c2b973f 100644 (file)
@@ -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<int>(sizeof(deUint32) * 4);
index 6146063..bdc3d1e 100644 (file)
  * \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;
index 70adcd6..943f54c 100644 (file)
@@ -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)
 {
index 4cb5b09..781ffa9 100644 (file)
@@ -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)
index 3665383..041db6a 100644 (file)
 #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 <algorithm>
 #include <map>
@@ -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;
index e766c52..6623215 100644 (file)
 #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 <algorithm>
 #include <map>
@@ -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;