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 "
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 "
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 "
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 "
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 "
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 "
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.");
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.");
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.");
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.");
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 "
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 "
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.");
}
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);
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())
}
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.");
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);
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);
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);
namespace glu
{
+DE_INLINE void* BufferOffsetAsPointer (uintptr_t byteOffset)
+{
+ return reinterpret_cast<void*>(byteOffset);
+}
+
class RenderContext;
class Error : public tcu::TestError
// 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);
}
// 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
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);
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);
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());
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);
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);
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);
}
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);
}
}
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());
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());
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);
}
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
// 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");
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
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
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);
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);