Add glu::BufferOffsetAsPointer utility
authorJesse Hall <jessehall@google.com>
Tue, 27 Mar 2018 23:49:03 +0000 (16:49 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 29 Mar 2018 14:51:49 +0000 (10:51 -0400)
Clang 6.x adds a warning that doing arithmetic involving a NULL
pointer is a GNU extension. This affects the common GL pattern
    (deUint8*)DE_NULL + offset
used to pass an offset into a bound buffer object as a client pointer
parameter.

This change replaces that pattern with a call to a new utility
function glu::BufferOffsetAsPointer(), which will hopefully be
warning-free on all compilers.

Change-Id: I8be939297b02c44091441c71ae75e45ceab30639
Components: Framework, OpenGL, AOSP

13 files changed:
external/openglcts/modules/gl/gl4cDirectStateAccessTexturesTests.cpp
external/openglcts/modules/gl/gl4cDirectStateAccessVertexArraysTests.cpp
framework/opengl/gluDefs.hpp
framework/opengl/simplereference/sglrReferenceContext.cpp
modules/gles3/functional/es3fShaderStateQueryTests.cpp
modules/gles3/performance/es3pBufferDataUploadTests.cpp
modules/gles31/functional/es31fDrawTests.cpp
modules/gles31/functional/es31fGeometryShaderTests.cpp
modules/gles31/functional/es31fMultisampleShaderRenderCase.cpp
modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp
modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp
modules/gles31/functional/es31fVertexAttributeBindingTests.cpp
modules/glshared/glsDrawTest.cpp

index 6bc7fe2..0f81b54 100644 (file)
@@ -10313,7 +10313,7 @@ bool SubImageErrorsTest::Test1D()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
                gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type,
-                                                        (glw::GLubyte*)NULL + s_reference_size * 2);
+                                                        glu::BufferOffsetAsPointer(s_reference_size * 2));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
                                                                  "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
                                                                  "data would be unpacked from the buffer object such that the memory reads required "
@@ -10332,7 +10332,7 @@ bool SubImageErrorsTest::Test1D()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
                gl.textureSubImage1D(m_to_1D, 0, 0, s_reference_width, s_reference_format, s_reference_type,
-                                                        (glw::GLubyte*)NULL + 1);
+                                                        glu::BufferOffsetAsPointer(1));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage1D",
                                                                  "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
                                                                  "is not evenly divisible into the number of bytes needed to store in memory a datum "
@@ -10554,7 +10554,7 @@ bool SubImageErrorsTest::Test2D()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
                gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
-                                                        s_reference_type, (glw::GLubyte*)NULL + s_reference_size * 2);
+                                                        s_reference_type, glu::BufferOffsetAsPointer(s_reference_size * 2));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
                                                                  "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
                                                                  "data would be unpacked from the buffer object such that the memory reads required "
@@ -10573,7 +10573,7 @@ bool SubImageErrorsTest::Test2D()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
                gl.textureSubImage2D(m_to_2D, 0, 0, 0, s_reference_width, s_reference_height, s_reference_format,
-                                                        s_reference_type, (glw::GLubyte*)NULL + 1);
+                                                        s_reference_type, glu::BufferOffsetAsPointer(1));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage2D",
                                                                  "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
                                                                  "is not evenly divisible into the number of bytes needed to store in memory a datum "
@@ -10808,7 +10808,7 @@ bool SubImageErrorsTest::Test3D()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
                gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
-                                                        s_reference_format, s_reference_type, (glw::GLubyte*)NULL + s_reference_size * 2);
+                                                        s_reference_format, s_reference_type, glu::BufferOffsetAsPointer(s_reference_size * 2));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
                                                                  "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and the "
                                                                  "data would be unpacked from the buffer object such that the memory reads required "
@@ -10827,7 +10827,7 @@ bool SubImageErrorsTest::Test3D()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
                gl.textureSubImage3D(m_to_3D, 0, 0, 0, 0, s_reference_width, s_reference_height, s_reference_depth,
-                                                        s_reference_format, s_reference_type, (glw::GLubyte*)NULL + 1);
+                                                        s_reference_format, s_reference_type, glu::BufferOffsetAsPointer(1));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureSubImage3D",
                                                                  "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and pixels "
                                                                  "is not evenly divisible into the number of bytes needed to store in memory a datum "
@@ -10937,7 +10937,7 @@ bool SubImageErrorsTest::Test1DCompressed()
 
                        gl.compressedTextureSubImage1D(m_to_1D_compressed, 0, 0, s_reference_width,
                                                                                   m_reference_compressed_1D_format, m_reference_compressed_1D_size,
-                                                                                  (glw::GLubyte*)NULL + s_reference_size * 2);
+                                                                                  glu::BufferOffsetAsPointer(s_reference_size * 2));
                        is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage1D",
                                                                          "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
                                                                          "the buffer object's data store is currently mapped.");
@@ -11047,7 +11047,7 @@ bool SubImageErrorsTest::Test2DCompressed()
 
                        gl.compressedTextureSubImage2D(m_to_2D_compressed, 0, 0, 0, s_reference_width, s_reference_height,
                                                                                   m_reference_compressed_2D_format, m_reference_compressed_2D_size,
-                                                                                  (glw::GLubyte*)NULL + s_reference_size * 2);
+                                                                                  glu::BufferOffsetAsPointer(s_reference_size * 2));
                        is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage2D",
                                                                          "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
                                                                          "the buffer object's data store is currently mapped.");
@@ -11180,7 +11180,7 @@ bool SubImageErrorsTest::Test3DCompressed()
 
                        gl.compressedTextureSubImage3D(m_to_3D_compressed, 0, 0, 0, 0, s_reference_width, s_reference_height,
                                                                                   s_reference_depth, m_reference_compressed_3D_format,
-                                                                                  m_reference_compressed_3D_size, (glw::GLubyte*)NULL + s_reference_size * 2);
+                                                                                  m_reference_compressed_3D_size, glu::BufferOffsetAsPointer(s_reference_size * 2));
                        is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glCompressedTextureSubImage3D",
                                                                          "a non-zero buffer object name is bound to the PIXEL_UNPACK_BUFFER target and "
                                                                          "the buffer object's data store is currently mapped.");
@@ -13316,7 +13316,7 @@ tcu::TestNode::IterateResult ImageQueryErrorsTest::iterate()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
                gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type, s_reference_size,
-                                                  (glw::GLuint*)NULL + 1);
+                                                  glu::BufferOffsetAsPointer(1 * sizeof(GLuint)));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
                                                                  "a pixel pack buffer object is bound and packing the texture image into the buffer’s "
                                                                  "memory would exceed the size of the buffer.");
@@ -13332,7 +13332,7 @@ tcu::TestNode::IterateResult ImageQueryErrorsTest::iterate()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
                gl.getTextureImage(texture_2D, 0, s_reference_format, s_reference_type, s_reference_size,
-                                                  (glw::GLubyte*)NULL + 1);
+                                                  glu::BufferOffsetAsPointer(1));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetTextureImage",
                                                                  "a pixel pack buffer object is bound and pixels is not evenly divisible by the "
                                                                  "number of basic machine units needed to store in memory the GL data type "
@@ -13410,7 +13410,7 @@ tcu::TestNode::IterateResult ImageQueryErrorsTest::iterate()
                gl.bindBuffer(GL_PIXEL_PACK_BUFFER, buffer);
                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer has failed");
 
-               gl.getCompressedTextureImage(texture_2D_compressed, 0, s_reference_size, (char*)NULL + s_reference_size - 1);
+               gl.getCompressedTextureImage(texture_2D_compressed, 0, s_reference_size, glu::BufferOffsetAsPointer(s_reference_size - 1));
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glGetCompressedTextureImage",
                                                                  "a non-zero buffer object name is bound to the PIXEL_PACK_BUFFER target and the data "
                                                                  "would be packed to the buffer object such that the memory writes required would "
index f3d4a6c..fa27408 100644 (file)
@@ -510,7 +510,7 @@ void EnableDisableAttributesTest::PrepareVAO()
        for (glw::GLint i = 0; i < m_max_attributes; ++i)
        {
                gl.vertexAttribIPointer(i, 1, GL_INT, static_cast<glw::GLsizei>(sizeof(glw::GLint) * m_max_attributes),
-                                                               (glw::GLvoid*)((glw::GLint*)NULL + i));
+                                                               glu::BufferOffsetAsPointer(i * sizeof(glw::GLint)));
 
                GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribIPointer call failed.");
        }
@@ -1511,7 +1511,7 @@ bool VertexBuffersTest::PrepareVAO(bool use_multiple_buffers_function)
        if (use_multiple_buffers_function)
        {
                const glw::GLuint                  buffers[2] = { m_bo_array_0, m_bo_array_0 };
-               static const glw::GLintptr offsets[2] = { (glw::GLintptr)NULL, (glw::GLintptr)((glw::GLint*)NULL + 1) };
+               static const glw::GLintptr offsets[2] = { 0, sizeof(glw::GLint) };
                static const glw::GLsizei  strides[2] = { sizeof(glw::GLint) * 2, sizeof(glw::GLint) * 2 };
 
                gl.vertexArrayVertexBuffers(m_vao, 0, 2, buffers, offsets, strides);
@@ -1540,7 +1540,7 @@ bool VertexBuffersTest::PrepareVAO(bool use_multiple_buffers_function)
                        return false;
                }
 
-               gl.vertexArrayVertexBuffer(m_vao, 1, m_bo_array_0, (glw::GLintptr)((glw::GLint*)NULL + 1),
+               gl.vertexArrayVertexBuffer(m_vao, 1, m_bo_array_0, sizeof(glw::GLint),
                                                                   sizeof(glw::GLint) * 2);
 
                if (glw::GLenum error = gl.getError())
@@ -2232,7 +2232,7 @@ bool AttributeFormatTest::PrepareVAO(glw::GLint size, glw::GLenum type_gl_name,
        }
 
        gl.bindVertexBuffer(0, m_bo_array, 0, static_cast<glw::GLsizei>(sizeof(T) * size * 2));
-       gl.bindVertexBuffer(1, m_bo_array, (glw::GLintptr)((T*)NULL + size),
+       gl.bindVertexBuffer(1, m_bo_array, size * sizeof(T),
                                                static_cast<glw::GLsizei>(sizeof(T) * size * 2));
 
        GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData call failed.");
@@ -2826,7 +2826,7 @@ bool AttributeBindingTest::PrepareVAO()
        gl.vertexAttribIPointer(0, 1, GL_INT, sizeof(glw::GLint) * 2, NULL);
        GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribIPointer call failed.");
 
-       gl.vertexAttribIPointer(1, 1, GL_INT, sizeof(glw::GLint) * 2, (glw::GLvoid*)((glw::GLint*)NULL + 1));
+       gl.vertexAttribIPointer(1, 1, GL_INT, sizeof(glw::GLint) * 2, glu::BufferOffsetAsPointer(1 * sizeof(glw::GLint)));
        GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribIPointer call failed.");
 
        gl.enableVertexAttribArray(0);
@@ -3779,7 +3779,7 @@ void GetVertexArrayIndexedTest::PrepareVAO()
        gl.bindBuffer(GL_ARRAY_BUFFER, m_bo[1]);
        GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer call failed.");
 
-       gl.vertexAttribIPointer(1, 2, GL_SHORT, 2, ((glw::GLchar*)NULL + 2));
+       gl.vertexAttribIPointer(1, 2, GL_SHORT, 2, glu::BufferOffsetAsPointer(2 * sizeof(glw::GLchar)));
        GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer call failed.");
 
        gl.enableVertexAttribArray(1);
@@ -3811,7 +3811,7 @@ void GetVertexArrayIndexedTest::PrepareVAO()
        gl.bindBuffer(GL_ARRAY_BUFFER, m_bo[3]);
        GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer call failed.");
 
-       gl.vertexAttribPointer(3, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 8, ((glw::GLchar*)NULL + 4));
+       gl.vertexAttribPointer(3, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 8, glu::BufferOffsetAsPointer(4 * sizeof(glw::GLchar)));
        GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer call failed.");
 
        gl.enableVertexAttribArray(3);
index 9275db6..87c5b9b 100644 (file)
 namespace glu
 {
 
+DE_INLINE   void*   BufferOffsetAsPointer   (uintptr_t byteOffset)
+{
+    return reinterpret_cast<void*>(byteOffset);
+}
+
 class RenderContext;
 
 class Error : public tcu::TestError
index 288b0a9..61d2d53 100644 (file)
@@ -4143,7 +4143,7 @@ void ReferenceContext::drawElementsIndirect       (deUint32 mode, deUint32 type, const
        // Draw
        {
                const size_t                    sizeOfType              = (type == GL_UNSIGNED_BYTE) ?  (1) : ((type == GL_UNSIGNED_SHORT) ? (2) : (4));
-               const void*                             indicesPtr              = (deUint8*)DE_NULL + (command->firstIndex * sizeOfType);
+               const void*                             indicesPtr              = glu::BufferOffsetAsPointer(command->firstIndex * sizeOfType);
 
                drawElementsInstancedBaseVertex(mode, (int)command->count, type, indicesPtr, (int)command->primCount, command->baseVertex);
        }
index 672e8c8..90aa7a7 100644 (file)
@@ -2929,13 +2929,13 @@ public:
                        // set vao 0 to some value
                        glBindVertexArray(vaos[0]);
                        glBindBuffer(GL_ARRAY_BUFFER, bufs[0]);
-                       glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, ((deUint8*)DE_NULL) + 8);
+                       glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, glu::BufferOffsetAsPointer(8));
                        expectError(GL_NO_ERROR);
 
                        // set vao 1 to some other value
                        glBindVertexArray(vaos[1]);
                        glBindBuffer(GL_ARRAY_BUFFER, bufs[1]);
-                       glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, ((deUint8*)DE_NULL) + 4);
+                       glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, glu::BufferOffsetAsPointer(4));
                        expectError(GL_NO_ERROR);
 
                        // verify vao 1 state
@@ -2943,7 +2943,7 @@ public:
                                StateQueryMemoryWriteGuard<GLvoid*> state;
                                glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
                                state.verifyValidity(m_testCtx);
-                               checkPointerEquals(m_testCtx, state, ((deUint8*)DE_NULL) + 4);
+                               checkPointerEquals(m_testCtx, state, glu::BufferOffsetAsPointer(4));
                        }
                        expectError(GL_NO_ERROR);
 
@@ -2953,7 +2953,7 @@ public:
                                StateQueryMemoryWriteGuard<GLvoid*> state;
                                glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state);
                                state.verifyValidity(m_testCtx);
-                               checkPointerEquals(m_testCtx, state, ((deUint8*)DE_NULL) + 8);
+                               checkPointerEquals(m_testCtx, state, glu::BufferOffsetAsPointer(8));
                        }
                        expectError(GL_NO_ERROR);
 
index b8de44d..793e30d 100644 (file)
@@ -3997,8 +3997,8 @@ void RenderPerformanceTestBase::setupVertexAttribs (void) const
        gl.enableVertexAttribArray(m_colorLoc);
        gl.enableVertexAttribArray(m_positionLoc);
 
-       gl.vertexAttribPointer(m_colorLoc,    4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(8 * sizeof(float)), (const tcu::Vec4*)DE_NULL + 0);
-       gl.vertexAttribPointer(m_positionLoc, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(8 * sizeof(float)), (const tcu::Vec4*)DE_NULL + 1);
+       gl.vertexAttribPointer(m_colorLoc,    4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(8 * sizeof(float)), glu::BufferOffsetAsPointer(0 * sizeof(tcu::Vec4)));
+       gl.vertexAttribPointer(m_positionLoc, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(8 * sizeof(float)), glu::BufferOffsetAsPointer(1 * sizeof(tcu::Vec4)));
 
        gl.useProgram(m_renderProgram->getProgram());
 
index daa5307..4ca39c7 100644 (file)
@@ -1504,7 +1504,7 @@ void ComputeShaderGeneratedCase::renderTo (tcu::Surface& dst)
 
        gl.bindBuffer(GL_ARRAY_BUFFER, m_dataBufferID);
        gl.vertexAttribPointer(positionLoc, 4, GL_FLOAT, GL_FALSE, 8 * (int)sizeof(float), DE_NULL);
-       gl.vertexAttribPointer(colorLoc,    4, GL_FLOAT, GL_FALSE, 8 * (int)sizeof(float), ((const deUint8*)DE_NULL) + 4*sizeof(float));
+       gl.vertexAttribPointer(colorLoc,    4, GL_FLOAT, GL_FALSE, 8 * (int)sizeof(float), glu::BufferOffsetAsPointer(4*sizeof(float)));
        gl.enableVertexAttribArray(positionLoc);
        gl.enableVertexAttribArray(colorLoc);
 
@@ -1525,7 +1525,7 @@ void ComputeShaderGeneratedCase::renderTo (tcu::Surface& dst)
        gl.useProgram(m_shaderProgram->getProgram());
        for (int drawCmdNdx = 0; drawCmdNdx < m_numDrawCmds; ++drawCmdNdx)
        {
-               const void* offset = ((deUint8*)DE_NULL) + drawCmdNdx*m_commandSize;
+               const void* offset = glu::BufferOffsetAsPointer(drawCmdNdx*m_commandSize);
 
                if (m_drawMethod == DRAWMETHOD_DRAWELEMENTS)
                        gl.drawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, offset);
index fdfd40a..a90b51e 100644 (file)
@@ -4735,7 +4735,7 @@ PrimitivesGeneratedQueryCase::IterateResult PrimitivesGeneratedQueryCase::iterat
 
                if (oneLocation != -1)
                {
-                       gl.vertexAttribPointer(oneLocation, 4, GL_FLOAT, GL_FALSE, 2 * (int)sizeof(tcu::Vec4), (const tcu::Vec4*)DE_NULL + 1);
+                       gl.vertexAttribPointer(oneLocation, 4, GL_FLOAT, GL_FALSE, 2 * (int)sizeof(tcu::Vec4), glu::BufferOffsetAsPointer(1 * sizeof(tcu::Vec4)));
                        gl.enableVertexAttribArray(oneLocation);
                }
 
index 72eebc8..e8a31cd 100644 (file)
@@ -496,7 +496,7 @@ void MultisampleRenderCase::drawOneIteration (void)
 
                        if (location != -1)
                        {
-                               gl.vertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, it->second.stride, (deUint8*)DE_NULL + it->second.offset);
+                               gl.vertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, it->second.stride, glu::BufferOffsetAsPointer(it->second.offset));
                                gl.enableVertexAttribArray(location);
                        }
                }
index de99dd7..c389aec 100644 (file)
@@ -881,8 +881,8 @@ void BBoxRenderCase::setupRender (const IterationConfig& config)
        gl.clear(GL_COLOR_BUFFER_BIT);
 
        gl.bindBuffer(GL_ARRAY_BUFFER, **m_vbo);
-       gl.vertexAttribPointer(posLocation, 4, GL_FLOAT, GL_FALSE, (int)(VA_NUM_ATTRIB_VECS * sizeof(float[4])), (const float*)DE_NULL + 4 * VA_POS_VEC_NDX);
-       gl.vertexAttribPointer(colLocation, 4, GL_FLOAT, GL_FALSE, (int)(VA_NUM_ATTRIB_VECS * sizeof(float[4])), (const float*)DE_NULL + 4 * VA_COL_VEC_NDX);
+       gl.vertexAttribPointer(posLocation, 4, GL_FLOAT, GL_FALSE, (int)(VA_NUM_ATTRIB_VECS * sizeof(float[4])), glu::BufferOffsetAsPointer(4 * VA_POS_VEC_NDX * sizeof(float)));
+       gl.vertexAttribPointer(colLocation, 4, GL_FLOAT, GL_FALSE, (int)(VA_NUM_ATTRIB_VECS * sizeof(float[4])), glu::BufferOffsetAsPointer(4 * VA_COL_VEC_NDX * sizeof(float)));
        gl.enableVertexAttribArray(posLocation);
        gl.enableVertexAttribArray(colLocation);
        gl.useProgram(m_program->getProgram());
@@ -3860,8 +3860,8 @@ DepthDrawCase::IterateResult DepthDrawCase::iterate (void)
        GLU_EXPECT_NO_ERROR(gl.getError(), "setup viewport");
 
        gl.bindBuffer(GL_ARRAY_BUFFER, **m_vbo);
-       gl.vertexAttribPointer(posLocation, 4, GL_FLOAT, GL_FALSE, (int)(8 * sizeof(float)), (const float*)DE_NULL);
-       gl.vertexAttribPointer(colLocation, 4, GL_FLOAT, GL_FALSE, (int)(8 * sizeof(float)), (const float*)DE_NULL + 4);
+       gl.vertexAttribPointer(posLocation, 4, GL_FLOAT, GL_FALSE, (int)(8 * sizeof(float)), glu::BufferOffsetAsPointer(0 * sizeof(float)));
+       gl.vertexAttribPointer(colLocation, 4, GL_FLOAT, GL_FALSE, (int)(8 * sizeof(float)), glu::BufferOffsetAsPointer(4 * sizeof(float)));
        gl.enableVertexAttribArray(posLocation);
        gl.enableVertexAttribArray(colLocation);
        gl.useProgram(m_program->getProgram());
index 309123c..e06f5c1 100644 (file)
@@ -607,7 +607,7 @@ void MixedVertexBindingOffsetCase::test (tcu::ResultCollector& result)
        gl.enableLogging(true);
 
        gl.glBindBuffer(GL_ARRAY_BUFFER, *buffer);
-       gl.glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (const deUint8*)DE_NULL + 12);
+       gl.glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, glu::BufferOffsetAsPointer(12));
 
        verifyStateIndexedInteger(result, gl, GL_VERTEX_BINDING_OFFSET, 1, 12, m_verifier);
 }
index 765d553..e430fd4 100644 (file)
@@ -918,7 +918,7 @@ void MixedBindingCase::renderTo (tcu::Surface& dst)
 
                        gl.glBindBuffer(GL_ARRAY_BUFFER, m_colorOffsetBuffer);
                        gl.glVertexAttribPointer(colorLoc, 4, GL_FLOAT, GL_FALSE, glw::GLsizei(2 * sizeof(tcu::Vec4)), DE_NULL);
-                       gl.glVertexAttribPointer(offsetLoc, 4, GL_FLOAT, GL_FALSE, glw::GLsizei(2 * sizeof(tcu::Vec4)), (deUint8*)DE_NULL + sizeof(tcu::Vec4));
+                       gl.glVertexAttribPointer(offsetLoc, 4, GL_FLOAT, GL_FALSE, glw::GLsizei(2 * sizeof(tcu::Vec4)), glu::BufferOffsetAsPointer(sizeof(tcu::Vec4)));
                        GLU_EXPECT_NO_ERROR(gl.glGetError(), "set va");
 
                        // draw
@@ -967,7 +967,7 @@ void MixedBindingCase::renderTo (tcu::Surface& dst)
                        // bind color using old api
                        gl.glBindBuffer(GL_ARRAY_BUFFER, m_colorOffsetBuffer);
                        gl.glVertexAttribPointer(colorLoc, 4, GL_FLOAT, GL_FALSE, glw::GLsizei(2 * sizeof(tcu::Vec4)), DE_NULL);
-                       gl.glVertexAttribPointer(offsetLoc, 4, GL_FLOAT, GL_FALSE, glw::GLsizei(2 * sizeof(tcu::Vec4)), (deUint8*)DE_NULL + sizeof(tcu::Vec4));
+                       gl.glVertexAttribPointer(offsetLoc, 4, GL_FLOAT, GL_FALSE, glw::GLsizei(2 * sizeof(tcu::Vec4)), glu::BufferOffsetAsPointer(sizeof(tcu::Vec4)));
                        gl.glVertexAttribDivisor(colorLoc, 1);
                        gl.glVertexAttribDivisor(offsetLoc, 1);
                        GLU_EXPECT_NO_ERROR(gl.glGetError(), "set va");
@@ -1147,7 +1147,7 @@ void MixedApiCase::renderTo (tcu::Surface& dst)
 
                        gl.glBindBuffer(GL_ARRAY_BUFFER, *dummyBuffer);
                        gl.glVertexAttribPointer(positionLoc, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(2 * sizeof(tcu::Vec4)), (const deUint8*)DE_NULL);
-                       gl.glVertexAttribPointer(colorLoc,    4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(2 * sizeof(tcu::Vec4)), (const deUint8*)DE_NULL + sizeof(tcu::Vec4));
+                       gl.glVertexAttribPointer(colorLoc,    4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(2 * sizeof(tcu::Vec4)), glu::BufferOffsetAsPointer(sizeof(tcu::Vec4)));
 
                        // change buffer with vertex_attrib_binding
 
@@ -1202,7 +1202,7 @@ void MixedApiCase::renderTo (tcu::Surface& dst)
 
                        gl.glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
                        gl.glVertexAttribPointer(bindingPoint1, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(2 * sizeof(tcu::Vec4)), (const deUint8*)DE_NULL);
-                       gl.glVertexAttribPointer(bindingPoint2, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(2 * sizeof(tcu::Vec4)), (const deUint8*)DE_NULL + sizeof(tcu::Vec4));
+                       gl.glVertexAttribPointer(bindingPoint2, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(2 * sizeof(tcu::Vec4)), glu::BufferOffsetAsPointer(sizeof(tcu::Vec4)));
 
                        // change buffer binding point with vertex_attrib_binding
 
index c485b6e..b8cff9c 100644 (file)
@@ -1941,7 +1941,7 @@ void AttributePack::render (DrawTestSpec::Primitive primitive, DrawTestSpec::Dra
 
                GLU_EXPECT_NO_ERROR(m_ctx.getError(), "Setup draw indirect buffer");
 
-               m_ctx.drawArraysIndirect(primitiveToGL(primitive), (const deInt8*)DE_NULL + indirectOffset);
+               m_ctx.drawArraysIndirect(primitiveToGL(primitive), glu::BufferOffsetAsPointer(indirectOffset));
                GLU_EXPECT_NO_ERROR(m_ctx.getError(), "glDrawArraysIndirect()");
 
                m_ctx.deleteBuffers(1, &indirectBuf);
@@ -1992,7 +1992,7 @@ void AttributePack::render (DrawTestSpec::Primitive primitive, DrawTestSpec::Dra
 
                GLU_EXPECT_NO_ERROR(m_ctx.getError(), "Setup draw indirect buffer");
 
-               m_ctx.drawElementsIndirect(primitiveToGL(primitive), indexTypeToGL(indexType), (const deInt8*)DE_NULL + indirectOffset);
+               m_ctx.drawElementsIndirect(primitiveToGL(primitive), indexTypeToGL(indexType), glu::BufferOffsetAsPointer(indirectOffset));
                GLU_EXPECT_NO_ERROR(m_ctx.getError(), "glDrawArraysIndirect()");
 
                m_ctx.deleteBuffers(1, &indirectBuf);