mesa: add offset_is_int32 param into _mesa_bind_vertex_buffer for glthread

glthread will pass signed integer offsets, so don't reset negative offsets
to 0 there.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4758>
This commit is contained in:
Marek Olšák 2020-03-06 21:23:11 -05:00 committed by Marge Bot
parent b8223244c3
commit e9afe045cf
6 changed files with 21 additions and 17 deletions

View file

@ -356,7 +356,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
*buf_obj, 0, sizeof(struct vertex));
*buf_obj, 0, sizeof(struct vertex), false);
_mesa_enable_vertex_array_attrib(ctx, array_obj,
VERT_ATTRIB_GENERIC(0));
if (texcoord_size > 0) {
@ -365,7 +365,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE, GL_FALSE,
offsetof(struct vertex, tex));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
*buf_obj, 0, sizeof(struct vertex));
*buf_obj, 0, sizeof(struct vertex), false);
_mesa_enable_vertex_array_attrib(ctx, array_obj,
VERT_ATTRIB_GENERIC(1));
}
@ -375,7 +375,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
*buf_obj, 0, sizeof(struct vertex));
*buf_obj, 0, sizeof(struct vertex), false);
_mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
if (texcoord_size > 0) {
@ -384,7 +384,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, tex));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0),
*buf_obj, 0, sizeof(struct vertex));
*buf_obj, 0, sizeof(struct vertex), false);
_mesa_enable_vertex_array_attrib(ctx, array_obj,
VERT_ATTRIB_TEX(0));
}
@ -395,7 +395,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, r));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0,
*buf_obj, 0, sizeof(struct vertex));
*buf_obj, 0, sizeof(struct vertex), false);
_mesa_enable_vertex_array_attrib(ctx, array_obj,
VERT_ATTRIB_COLOR0);
}
@ -3396,7 +3396,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
drawtex->buf_obj, 0, sizeof(struct vertex));
drawtex->buf_obj, 0, sizeof(struct vertex),
false);
_mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
@ -3407,7 +3408,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, st[i]));
_mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(i),
drawtex->buf_obj, 0, sizeof(struct vertex));
drawtex->buf_obj, 0, sizeof(struct vertex),
false);
_mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(i));
}
}

View file

@ -1148,7 +1148,7 @@ unbind(struct gl_context *ctx,
if (vao->BufferBinding[index].BufferObj == obj) {
_mesa_bind_vertex_buffer(ctx, vao, index, NULL,
vao->BufferBinding[index].Offset,
vao->BufferBinding[index].Stride);
vao->BufferBinding[index].Stride, true);
}
}

View file

@ -198,14 +198,15 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
struct gl_vertex_array_object *vao,
GLuint index,
struct gl_buffer_object *vbo,
GLintptr offset, GLsizei stride)
GLintptr offset, GLsizei stride,
bool offset_is_int32)
{
assert(index < ARRAY_SIZE(vao->BufferBinding));
assert(!vao->SharedAndImmutable);
struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
if (ctx->Const.VertexBufferOffsetIsInt32 && (int)offset < 0 &&
vbo) {
!offset_is_int32 && vbo) {
/* The offset will be interpreted as a signed int, so make sure
* the user supplied offset is not negative (driver limitation).
*/
@ -909,7 +910,7 @@ update_array(struct gl_context *ctx,
stride : array->Format._ElementSize;
_mesa_bind_vertex_buffer(ctx, vao, attrib,
obj, (GLintptr) ptr,
effectiveStride);
effectiveStride, false);
}
@ -2939,7 +2940,7 @@ vertex_array_vertex_buffer(struct gl_context *ctx,
}
_mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(bindingIndex),
vbo, offset, stride);
vbo, offset, stride, false);
}
@ -3104,7 +3105,7 @@ vertex_array_vertex_buffers(struct gl_context *ctx,
*/
for (i = 0; i < count; i++)
_mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i),
NULL, 0, 16);
NULL, 0, 16, false);
return;
}
@ -3182,7 +3183,7 @@ vertex_array_vertex_buffers(struct gl_context *ctx,
}
_mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i),
vbo, offsets[i], strides[i]);
vbo, offsets[i], strides[i], false);
}
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);

View file

@ -109,7 +109,8 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
struct gl_vertex_array_object *vao,
GLuint index,
struct gl_buffer_object *vbo,
GLintptr offset, GLsizei stride);
GLintptr offset, GLsizei stride,
bool offset_is_int32);
extern void GLAPIENTRY
_mesa_VertexPointer_no_error(GLint size, GLenum type, GLsizei stride,

View file

@ -110,7 +110,7 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
/* Bind the buffer object */
const GLuint stride = exec->vtx.vertex_size*sizeof(GLfloat);
_mesa_bind_vertex_buffer(ctx, vao, 0, exec->vtx.bufferobj, buffer_offset,
stride);
stride, false);
/* Retrieve the mapping from VBO_ATTRIB to VERT_ATTRIB space
* Note that the position/generic0 aliasing is done in the VAO.

View file

@ -434,7 +434,7 @@ update_vao(struct gl_context *ctx,
*/
/* Bind the buffer object at binding point 0 */
_mesa_bind_vertex_buffer(ctx, *vao, 0, bo, buffer_offset, stride);
_mesa_bind_vertex_buffer(ctx, *vao, 0, bo, buffer_offset, stride, false);
/* Retrieve the mapping from VBO_ATTRIB to VERT_ATTRIB space
* Note that the position/generic0 aliasing is done in the VAO.