Add glu::BufferOffsetAsPointer utility
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
Bug: b/124254224
Components: Framework, OpenGL, AOSP
(cherry picked from commit 05d98991304fce712732124e5e12fb670ee5a799)
diff --git a/external/openglcts/modules/gl/gl4cDirectStateAccessTexturesTests.cpp b/external/openglcts/modules/gl/gl4cDirectStateAccessTexturesTests.cpp
index 0c1fb6c..e4d38d5 100644
--- a/external/openglcts/modules/gl/gl4cDirectStateAccessTexturesTests.cpp
+++ b/external/openglcts/modules/gl/gl4cDirectStateAccessTexturesTests.cpp
@@ -9709,7 +9709,7 @@
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 "
@@ -9728,7 +9728,7 @@
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 "
@@ -9950,7 +9950,7 @@
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 "
@@ -9969,7 +9969,7 @@
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 "
@@ -10204,7 +10204,7 @@
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 "
@@ -10223,7 +10223,7 @@
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 "
@@ -10333,7 +10333,7 @@
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.");
@@ -10443,7 +10443,7 @@
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.");
@@ -10576,7 +10576,7 @@
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.");
@@ -12712,7 +12712,7 @@
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.");
@@ -12728,7 +12728,7 @@
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 "
@@ -12806,7 +12806,7 @@
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 "
diff --git a/external/openglcts/modules/gl/gl4cDirectStateAccessVertexArraysTests.cpp b/external/openglcts/modules/gl/gl4cDirectStateAccessVertexArraysTests.cpp
index f3d4a6c..fa27408 100644
--- a/external/openglcts/modules/gl/gl4cDirectStateAccessVertexArraysTests.cpp
+++ b/external/openglcts/modules/gl/gl4cDirectStateAccessVertexArraysTests.cpp
@@ -510,7 +510,7 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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);
diff --git a/framework/opengl/gluDefs.hpp b/framework/opengl/gluDefs.hpp
index 9275db6..87c5b9b 100644
--- a/framework/opengl/gluDefs.hpp
+++ b/framework/opengl/gluDefs.hpp
@@ -43,6 +43,11 @@
namespace glu
{
+DE_INLINE void* BufferOffsetAsPointer (uintptr_t byteOffset)
+{
+ return reinterpret_cast<void*>(byteOffset);
+}
+
class RenderContext;
class Error : public tcu::TestError
diff --git a/framework/opengl/simplereference/sglrReferenceContext.cpp b/framework/opengl/simplereference/sglrReferenceContext.cpp
index 288b0a9..61d2d53 100644
--- a/framework/opengl/simplereference/sglrReferenceContext.cpp
+++ b/framework/opengl/simplereference/sglrReferenceContext.cpp
@@ -4143,7 +4143,7 @@
// 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);
}
diff --git a/modules/gles3/functional/es3fShaderStateQueryTests.cpp b/modules/gles3/functional/es3fShaderStateQueryTests.cpp
index 672e8c8..90aa7a7 100644
--- a/modules/gles3/functional/es3fShaderStateQueryTests.cpp
+++ b/modules/gles3/functional/es3fShaderStateQueryTests.cpp
@@ -2929,13 +2929,13 @@
// 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 @@
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 @@
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);
diff --git a/modules/gles3/performance/es3pBufferDataUploadTests.cpp b/modules/gles3/performance/es3pBufferDataUploadTests.cpp
index b8de44d..793e30d 100644
--- a/modules/gles3/performance/es3pBufferDataUploadTests.cpp
+++ b/modules/gles3/performance/es3pBufferDataUploadTests.cpp
@@ -3997,8 +3997,8 @@
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());
diff --git a/modules/gles31/functional/es31fDrawTests.cpp b/modules/gles31/functional/es31fDrawTests.cpp
index daa5307..4ca39c7 100644
--- a/modules/gles31/functional/es31fDrawTests.cpp
+++ b/modules/gles31/functional/es31fDrawTests.cpp
@@ -1504,7 +1504,7 @@
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 @@
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);
diff --git a/modules/gles31/functional/es31fGeometryShaderTests.cpp b/modules/gles31/functional/es31fGeometryShaderTests.cpp
index fdfd40a..a90b51e 100644
--- a/modules/gles31/functional/es31fGeometryShaderTests.cpp
+++ b/modules/gles31/functional/es31fGeometryShaderTests.cpp
@@ -4735,7 +4735,7 @@
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);
}
diff --git a/modules/gles31/functional/es31fMultisampleShaderRenderCase.cpp b/modules/gles31/functional/es31fMultisampleShaderRenderCase.cpp
index 72eebc8..e8a31cd 100644
--- a/modules/gles31/functional/es31fMultisampleShaderRenderCase.cpp
+++ b/modules/gles31/functional/es31fMultisampleShaderRenderCase.cpp
@@ -496,7 +496,7 @@
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);
}
}
diff --git a/modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp b/modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp
index de99dd7..c389aec 100644
--- a/modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp
+++ b/modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp
@@ -881,8 +881,8 @@
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 @@
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());
diff --git a/modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp b/modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp
index 309123c..e06f5c1 100644
--- a/modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp
+++ b/modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp
@@ -607,7 +607,7 @@
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);
}
diff --git a/modules/gles31/functional/es31fVertexAttributeBindingTests.cpp b/modules/gles31/functional/es31fVertexAttributeBindingTests.cpp
index 765d553..e430fd4 100644
--- a/modules/gles31/functional/es31fVertexAttributeBindingTests.cpp
+++ b/modules/gles31/functional/es31fVertexAttributeBindingTests.cpp
@@ -918,7 +918,7 @@
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 @@
// 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 @@
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 @@
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
diff --git a/modules/glshared/glsDrawTest.cpp b/modules/glshared/glsDrawTest.cpp
index c485b6e..b8cff9c 100644
--- a/modules/glshared/glsDrawTest.cpp
+++ b/modules/glshared/glsDrawTest.cpp
@@ -1941,7 +1941,7 @@
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 @@
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);